GitHub 集成 (GitHub)
OpenCode 可以集成到 GitHub 的 Issue 和 Pull Request (PR) 工作流中,通过 GitHub Actions 运行任务。
核心功能
- 分类 Issue:让 OpenCode 分析并解释 Issue 内容。
- 修复与实现:直接要求 OpenCode 修复 Bug 或实现功能,它会自动创建分支并提交 PR。
- 安全运行:在您自己的 GitHub Actions Runner 中运行,确保安全。
快速安装
在 GitHub 仓库根目录下运行:
opencode github install
手动设置
- 安装应用:访问
github.com/apps/opencode-agent并安装到目标仓库。 - 添加工作流:在
.github/workflows/opencode.yml中配置 Action。 - 配置密钥:在仓库设置中添加
ANTHROPIC_API_KEY等必要的 API 密钥。
支持的事件
- issue_comment:在 Issue 或 PR 中提及
/opencode或/oc触发。 - pull_request_review_comment:在 PR 代码行评论中提及
/oc进行针对性修改。 - schedule:按计划(如 Cron)运行自动化任务(如扫描代码中的 TODO)。
- workflow_dispatch:在 GitHub UI 中手动触发。
使用示例
- 解释 Issue:在评论区输入
/opencode explain this issue。 - 修复 Bug:在评论区输入
/opencode fix this。 - 精准修改:在代码行评论区输入
/oc add error handling here,它会自动获取文件路径、行号和上下文。