Skip to content

feat: add AI assistant message type support#12

Closed
hu-qi wants to merge 1 commit into
Open-Source-Bazaar:masterfrom
hu-qi:feature/ai-assistant-message
Closed

feat: add AI assistant message type support#12
hu-qi wants to merge 1 commit into
Open-Source-Bazaar:masterfrom
hu-qi:feature/ai-assistant-message

Conversation

@hu-qi

@hu-qi hu-qi commented Feb 4, 2026

Copy link
Copy Markdown
Collaborator

🚀 新增功能:AI助手消息类型支持

解决的问题

随着AI助手(如Clawdbot、ChatGPT等)在GitHub workflows中的普及,现有的消息类型无法很好地展示AI生成的复杂内容,如代码块、结构化数据、任务状态等。

新增功能

  1. 新的msg_type: ai_assistant
  2. 结构化消息格式: 支持header、summary、code、metrics、text、divider、actions等多种章节
  3. 代码高亮: 自动识别编程语言并高亮显示
  4. 任务状态跟踪: 显示pending/running/completed/failed状态
  5. 交互式按钮: 支持快速操作按钮

使用示例

- name: AI Assistant Message
  uses: Open-Source-Bazaar/feishu-action@feature/ai-assistant-message
  with:
    url: ${{ secrets.FEISHU_BOT_WEBHOOK_URL }}
    msg_type: ai_assistant
    content: |
      ai_assistant:
        title: "代码审查报告"
        assistant: "Clawdbot"
        status: "completed"
        sections:
          - type: "header"
            text: "审查完成"
          
          - type: "code"
            language: "typescript"
            code: |
              const result = calculate();
            suggestions:
              - "使用const声明不变的值"
          
          - type: "metrics"
            items:
              - label: "代码质量"
                value: "85/100"
                trend: "+5"

技术实现

  • 新增 src/ai-assistant.ts - AI助手消息转换器
  • 扩展 src/main.ts - 支持新的消息类型
  • 更新 action.yml - 添加ai_assistant到支持的msg_type
  • 添加 __tests__/ai-assistant.test.ts - 完整的单元测试
  • 更新 README.md - 详细的使用文档

文件变更

M  README.md
M  action.yml
M  src/main.ts
A  src/ai-assistant.ts
A  __tests__/ai-assistant.test.ts

测试覆盖

  • ✅ 基本配置转换
  • ✅ YAML解析
  • ✅ 代码块处理
  • ✅ 指标展示
  • ✅ 操作按钮

相关issue

Resolves #11


审查要点:

  1. 消息格式设计是否合理
  2. 飞书卡片转换逻辑
  3. 错误处理边界情况
  4. 向后兼容性

建议测试:

  1. 使用真实的飞书webhook测试
  2. 验证各种状态显示
  3. 测试代码高亮效果

贡献者: @hu-qi

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for a new AI assistant message type in Feishu workflows, enabling structured formatting with code blocks, metrics, suggestions, and action buttons.
  • Documentation

    • Added example configuration for the AI assistant workflow step.
  • Tests

    • Added comprehensive test coverage for AI assistant functionality.

- Add new msg_type: ai_assistant
- Implement AI assistant to Feishu card conversion
- Support structured sections: header, summary, code, metrics, text, divider, actions
- Add comprehensive test cases
- Update documentation with usage examples
- Resolves Open-Source-Bazaar#11
@coderabbitai

coderabbitai Bot commented Feb 4, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This pull request introduces support for a new ai_assistant message type to the Feishu action. It includes YAML parsing and conversion logic to transform structured AI assistant configurations into Feishu card messages, along with configuration updates, documentation, and comprehensive unit tests.

Changes

Cohort / File(s) Summary
Documentation
README.md
Added example documentation block demonstrating ai_assistant message type usage with Feishu action, including YAML structure with title, sections, metrics, and actions.
Configuration
action.yml
Extended msg_type input to include new ai_assistant option and updated content description to reference structured AI assistant format.
Core Implementation
src/ai-assistant.ts
New module providing AIAssistantConfig and AIAssistantSection interfaces, convertAIAssistantToCard() function for YAML-to-Feishu card conversion supporting sections (header, summary, code, metrics, text, divider), actions, and timestamps, plus parseAIAssistantContent() YAML parser.
Integration
src/main.ts
Added parseAIAssistantContent import and new conditional handler for ai_assistant msg_type that parses content and reposts as interactive message type.
Tests
__tests__/ai-assistant.test.ts
New test suite with 5 test cases covering basic config conversion, YAML parsing, code sections with suggestions, metrics rendering, and action button handling.

Sequence Diagram(s)

sequenceDiagram
    participant Workflow as GitHub Workflow
    participant Main as main.ts
    participant Parser as ai-assistant.ts
    participant Feishu as Feishu API

    Workflow->>Main: POST with msg_type: 'ai_assistant'
    Main->>Main: Detect msg_type === 'ai_assistant'
    Main->>Parser: parseAIAssistantContent(content)
    Parser->>Parser: Parse YAML structure
    Parser->>Parser: Extract AIAssistantConfig
    Parser->>Parser: convertAIAssistantToCard(config)
    Parser->>Parser: Build header, sections, actions
    Parser-->>Main: Return Feishu card JSON
    Main->>Feishu: POST with msg_type: 'interactive'
    Feishu-->>Workflow: Message delivered
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 The rabbits hop with joy today,
AI assistants now find their way!
Cards and code blocks, metrics so bright,
YAML transforms to pure delight!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hu-qi

hu-qi commented Feb 4, 2026

Copy link
Copy Markdown
Collaborator Author

关闭来自 AI 的 pr

@hu-qi hu-qi closed this Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add AI Assistant message type support

1 participant