Skip to content

Comments

docs: 添加项目 README 文档#77

Closed
WhiteElephantIsNotARobot wants to merge 2 commits intoWhiteElephant-abc:mainfrom
WhiteElephantIsNotARobot:main
Closed

docs: 添加项目 README 文档#77
WhiteElephantIsNotARobot wants to merge 2 commits intoWhiteElephant-abc:mainfrom
WhiteElephantIsNotARobot:main

Conversation

@WhiteElephantIsNotARobot
Copy link
Contributor

Summary

创建了完整的 README.md 文档,详细描述了整个项目的架构和功能。

Changes

添加了 README.md 文件,包含以下内容:

项目概述

  • AI GitHub Agent 的核心功能介绍
  • 双 Token 架构说明

架构概览

  • 系统架构图(GitHub → FastAPI → GitHub Actions)
  • 各组件职责说明

项目结构

  • 完整的目录结构说明
  • 每个文件的作用

核心组件详解

  1. FastAPI 服务器 (server.py)

    • 端点说明(/health, /stats)
    • 主要功能模块
  2. 智能截断算法

    • 3新1老比例抓取算法
    • 超限撤销机制
  3. 双 Token 架构

    • BOT_TOKEN(读取通知)
    • GQL_TOKEN(GraphQL/Workflow)
  4. 上下文数据模型 (TaskContext)

    • 完整的字段说明
    • JSON 序列化逻辑

GitHub Actions 工作流

  • llm-bot-runner.yml 详细流程
  • opencode.yml 触发方式

环境变量配置

  • 必需和可选环境变量列表
  • 说明和默认值

API 端点

  • /health 健康检查
  • /stats 统计信息

特性列表

  • smart_truncation_3_1
  • rich_context
  • graphql_enhanced
  • dual_token
  • test_context_fix
  • direct_trigger_task

使用方式

  • 通过 GitHub 提及触发
  • 通过 GitHub Actions 手动触发
  • 通过 /oc 命令触发

Test Plan

  • README.md 文件已创建
  • 内容已审核
  • 已提交到仓库

🤖 Generated with Claude Code

创建了完整的 README.md 文件,包含:
- 项目概述和核心功能
- 架构概览图
- 项目结构说明
- 核心组件详解(智能截断算法、双 Token 架构、上下文模型)
- 环境变量配置说明
- GitHub Actions 工作流介绍
- API 端点文档
- 特性列表和使用方式

Co-Authored-By: Claude (mimo-v2-flash) <[email protected]>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @WhiteElephantIsNotARobot, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

本次拉取请求旨在通过添加一个全面且详细的 README.md 文档,显著提升项目的可理解性和可维护性。该文档系统地概述了 AI GitHub Agent 的设计理念、技术架构、核心功能、使用方法及部署配置,为新用户和开发者提供了快速入门和深入了解项目所需的全部信息,从而降低了项目的学习曲线并促进了社区协作。

Highlights

  • 新增项目文档: 引入了全面的 README.md 文件,详细阐述了项目的各个方面,包括项目概述、架构、核心组件、工作流、配置和使用指南。
  • 核心功能阐述: 详细介绍了 AI GitHub Agent 的核心功能,包括智能通知处理、丰富的上下文构建、双 Token 架构和智能截断算法。
  • 架构与组件解析: 提供了清晰的系统架构概览、项目结构说明以及 FastAPI 服务器、智能截断算法、双 Token 机制和 TaskContext 数据模型等核心组件的详细解释。
  • 工作流与配置指南: 包含了 GitHub Actions 工作流(llm-bot-runner.ymlopencode.yml)的详细步骤、环境变量配置列表以及 API 端点说明。
  • 使用方法指导: 明确了通过 GitHub 提及、手动触发 GitHub Actions 和使用 /oc 命令三种触发 AI Agent 任务的方式。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 添加了非常详尽和结构清晰的 README.md 文档,极大地提高了项目的可理解性。文档内容全面,覆盖了从项目概述、架构、核心组件到使用方式的方方面面。我发现了一些可以改进的小问题,主要涉及示例代码的语法准确性和许可证信息的一致性,并已在具体的审查评论中提出了修改建议。整体而言,这是一项出色的文档工作!

README.md Outdated
Comment on lines 114 to 134
class TaskContext(BaseModel):
# 基础信息
repo: str # 仓库名 (owner/repo)
event_type: str # 事件类型 (pr/issue/discussion)
event_id: str # 通知 ID

# 内容
pr_title/pr_body: str # PR 标题和正文
issue_body: str # Issue 正文
discussion_title/discussion_body: str

# 历史记录
comments_history: List[Dict] # 普通评论
reviews_history: List[Dict] # 审核记录
review_comments_batch: List[Dict] # 行内代码评论

# 代码上下文
diff_content: str # PR diff
clone_url: str # SSH 克隆地址
head_ref/base_ref: str # 分支信息
head_repo/base_repo: str # repo:branch 格式
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

TaskContext 数据模型的示例代码中包含一些无效的 Python 语法(例如 pr_title/pr_body: str),这可能会误导开发者。建议将这些合并的属性拆分为独立的、符合语法的行,以提高文档的准确性和可读性。

class TaskContext(BaseModel):
    # 基础信息
    repo: str                    # 仓库名 (owner/repo)
    event_type: str              # 事件类型 (pr/issue/discussion)
    event_id: str                # 通知 ID

    # 内容
    pr_title: str                # PR 标题
    pr_body: str                 # PR 正文
    issue_body: str              # Issue 正文
    discussion_title: str        # Discussion 标题
    discussion_body: str         # Discussion 正文

    # 历史记录
    comments_history: List[Dict]     # 普通评论
    reviews_history: List[Dict]      # 审核记录
    review_comments_batch: List[Dict] # 行内代码评论

    # 代码上下文
    diff_content: str           # PR diff
    clone_url: str              # SSH 克隆地址
    head_ref: str               # head 分支
    base_ref: str               # base 分支
    head_repo: str              # head repo:branch 格式
    base_repo: str              # base repo:branch 格式

README.md Outdated

## 许可证

本项目采用 [AGPL-3.0 许可证](LICENSE)。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

文档中声明项目采用 AGPL-3.0 许可证,但这与仓库中 LICENSE 文件的内容(GPL-3.0)不一致。请核实项目的正确许可证,并更新文档以保持一致。在项目结构部分(第61行)也存在同样的问题。

@WhiteElephant-abc
Copy link
Owner

@WhiteElephantIsNotARobot 解决review

1. Fix TaskContext example code syntax
   - Split merged property declarations (pr_title/pr_body, etc.) into separate lines
   - Each field now has its own type declaration with proper comment

2. Fix license inconsistency
   - Update README to correctly reference GPL-3.0 (not AGPL-3.0)
   - Align with LICENSE file content

Co-Authored-By: Claude (mimo-v2-flash) <[email protected]>
@WhiteElephantIsNotARobot
Copy link
Contributor Author

已根据 review 意见完成修复:

修复内容

1. TaskContext 示例代码语法问题 ✅

  • 将合并的属性声明(如 pr_title/pr_body: str)拆分为独立的行
  • 每个字段都有单独的类型声明和注释
  • 代码现在是有效的 Python 语法,可直接复制使用

2. 许可证不一致问题 ✅

  • 将 README 中的 AGPL-3.0 引用更新为 GPL-3.0
  • 与 LICENSE 文件内容保持一致

修改详情

  • README.md 第 61 行:AGPL-3.0GPL-3.0
  • README.md 第 121-123 行:拆分 pr_title/pr_body 为独立字段
  • README.md 第 123 行:拆分 discussion_title/discussion_body 为独立字段
  • README.md 第 133-134 行:拆分 head_ref/base_ref 为独立字段
  • README.md 第 135-136 行:拆分 head_repo/base_repo 为独立字段
  • README.md 第 309 行:AGPL-3.0GPL-3.0

@WhiteElephant-abc
Copy link
Owner

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这份 README 文档写得非常全面和清晰,为项目提供了出色的概述。架构图、项目结构和使用说明都很有帮助。我发现了一些可以改进的地方,主要集中在保持文档与代码实现同步,以及澄清一些模糊的术语,这将有助于新用户更好地理解项目。请查看我的具体建议。

Comment on lines +114 to +138
class TaskContext(BaseModel):
# 基础信息
repo: str # 仓库名 (owner/repo)
event_type: str # 事件类型 (pr/issue/discussion)
event_id: str # 通知 ID

# 内容
pr_title: str # PR 标题
pr_body: str # PR 正文
issue_body: str # Issue 正文
discussion_title: str # Discussion 标题
discussion_body: str # Discussion 正文

# 历史记录
comments_history: List[Dict] # 普通评论
reviews_history: List[Dict] # 审核记录
review_comments_batch: List[Dict] # 行内代码评论

# 代码上下文
diff_content: str # PR diff
clone_url: str # SSH 克隆地址
head_ref: str # head 分支
base_ref: str # base 分支
head_repo: str # head repo:branch 格式
base_repo: str # base repo:branch 格式
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

文档中提供的 TaskContext 数据模型与 server.py 中的实际定义不一致。当前的定义缺少了许多重要字段(如 title, trigger_user, issue_number 等),并且没有正确反映字段的可选性(Optional)。这可能会误导开发者。建议将此处的模型定义更新为与 server.py 中完全一致,以确保文档的准确性。更新后的模型会使用 pydantic.BaseModel 以及 typing 中的 Optional, List, Dict

class TaskContext(BaseModel):
    # 基础信息
    repo: str                                   # 仓库名 (owner/repo)
    event_type: str                             # 事件类型 (pr/issue/discussion)
    event_id: str                               # 通知 ID
    trigger_user: Optional[str] = None          # 触发工作流的用户名
    issue_number: Optional[int] = None          # Issue/PR 编号

    # 标题和正文
    title: Optional[str] = None                 # Issue/Discussion 标题
    issue_body: Optional[str] = None            # Issue 正文
    pr_title: Optional[str] = None              # PR 标题
    pr_body: Optional[str] = None               # PR 正文
    discussion_title: Optional[str] = None      # Discussion 标题
    discussion_body: Optional[str] = None       # Discussion 正文

    # 历史数据
    comments_history: Optional[List[Dict]] = None      # 普通评论历史
    reviews_history: Optional[List[Dict]] = None       # 审核记录历史
    review_comments_batch: Optional[List[Dict]] = None # 行内代码评论

    # 代码上下文
    diff_content: Optional[str] = None          # PR diff 内容
    diff_url: Optional[str] = None              # PR diff 的 URL
    clone_url: Optional[str] = None             # SSH 克隆地址
    head_ref: Optional[str] = None              # head 分支
    base_ref: Optional[str] = None              # base 分支
    head_repo: Optional[str] = None             # head repo:branch 格式
    base_repo: Optional[str] = None             # base repo:branch 格式
    commit_sha: Optional[str] = None            # Commit SHA

    # 元数据
    current_comment_id: Optional[str] = None    # 触发评论的 ID
    current_review_id: Optional[str] = None     # 触发审核的 ID
    is_mention_in_body: Optional[bool] = None   # 是否在正文中被提及
    is_mention_in_review: Optional[bool] = None # 是否在审核中被提及
    is_truncated: Optional[bool] = None         # 上下文是否被截断
    latest_comment_url: Optional[str] = None    # 最新评论的 URL


| 变量名 | 默认值 | 说明 |
|--------|--------|------|
| `ALLOWED_USERS` | - | 允许触发的用户列表 (逗号分隔) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

在可选环境变量表格中,ALLOWED_USERS 的默认值被标记为 -,这有些模糊。根据 server.py 中的实现,如果这个环境变量未设置,则 ALLOWED_USERS 列表为空,此时权限检查会被跳过,相当于允许所有用户触发。建议将默认值的说明修改为“无限制”或“所有用户”,这样能更清晰地表达其行为。

Suggested change
| `ALLOWED_USERS` | - | 允许触发的用户列表 (逗号分隔) |
| `ALLOWED_USERS` | 无限制 | 允许触发的用户列表 (逗号分隔) |


1. **创建 Issue**:记录任务和上下文
2. **安装 Claude CLI**:从官方脚本安装
3. **配置 MCP 服务器**:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

llm-bot-runner.yml 工作流的步骤描述中,提到了“配置 MCP 服务器”,但文档中没有对 MCP 这个缩写进行任何解释。为了让读者更容易理解,建议在此处或项目概述中对 MCP 进行简要说明,或者直接使用全称。

@WhiteElephant-abc
Copy link
Owner

@WhiteElephantIsNotARobot 解决review

@WhiteElephantIsNotARobot
Copy link
Contributor Author

已根据 review 意见完成修复,详见新 PR #91#91

修复内容

1. TaskContext 示例代码语法问题 ✅

  • 与 server.py 中的实际定义保持一致
  • 使用 pydantic.BaseModel 和 typing.Optional
  • 每个字段都有独立的类型声明和注释
  • 添加了所有缺失的字段

2. ALLOWED_USERS 默认值说明 ✅

  • 将 "-" 改为 "无限制"
  • 更清晰地表达未设置时的行为

3. MCP 解释 ✅

  • 添加 MCP (Model Context Protocol) 说明
  • 解释其用于扩展 AI 模型能力的作用

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.

2 participants