zai-code-review 是一个使用 Z.ai 模型进行 AI 驱动的 GitHub Pull Request 代码审查的工具。它通过 GitHub Actions 集成到仓库中,能够自动对 PR 发表评论、检测 bug 并给出改进建议。
主要能力:
- 提供 AI 驱动的 PR 反馈
- 检测 bug
- 给出改进建议
- 自动发表 PR 评论
- 与 GitHub Actions 配合工作
使用方式: 将配置添加到 .github/workflows/code-review.yml 中。使用时必须将 Z.ai API 密钥添加为 GitHub Secret。
- 获取 Z.ai API 密钥:从 Z.ai 仪表板生成 API 密钥。
- 将 API 密钥添加到仓库:进入 GitHub 仓库,导航到 Secrets and variables → Actions,点击 New repository secret 并添加:Name 为 ZAI_API_KEY,Value 为你的 Z.ai API 密钥。
默认系统提示词为:You are an expert code reviewer. Review the provided code changes and give clear, actionable feedback.
可以覆盖默认提示词,以聚焦特定关注点、执行编码规范或调整审查语气,例如:You are a security-focused code reviewer. Identify vulnerabilities, unsafe patterns, and authentication issues. Skip style comments.
高级配置: 可以不使用 ZAI_MODEL、ZAI_SYSTEM_PROMPT 和 ZAI_REVIEWER_NAME 的默认值,而是覆盖它们,并将它们作为 GitHub Actions 变量进行管理。这样无需修改工作流文件即可更新模型、审查提示词或审查者名称。
- 将变量添加到仓库:点击 Variables 标签,点击 New repository variable 并添加:Name 为 ZAI_MODEL,Value 例如 glm-4.7;Name 为 ZAI_SYSTEM_PROMPT,Value 为你的自定义系统提示词;Name 为 ZAI_REVIEWER_NAME,Value 例如 AI Code Review。
- 在工作流中引用它们。
该项目采用 MIT 许可证。欢迎贡献。