Skip to content

建立 2026-09-15 更新 2026-09-15

GitHub

在 issue 或 PR 留言寫 /opencode/oc,OpenCode 會在你的 GitHub Actions runner 裡執行:說明 issue、開分支實作並送 PR,或依 review 留言改程式。運算跑在你的 runner,不是把 repo 交出去給不明主機。

安裝

在已連 GitHub 的專案裡:

opencode github install

會引導安裝 OpenCode GitHub App、寫 workflow、設定 secrets。也可以手動在 .github/workflows/opencode.yml 使用 anomalyco/opencode/github@latest

必要輸入:

  • modelprovider/model,必填
  • ANTHROPIC_API_KEY 等:依模型放在 Actions secrets

可選:agentprompt(覆寫預設行為)、mentions(觸發詞,預設 /opencode,/oc)、share(公開 repo 預設分享 session)。

可以觸發的事件

事件 典型用法
issue/PR 留言 註解裡提到 /oc
PR review 某幾行 針對該檔、該行改
issues opened 自動 triage(需自訂 prompt
pull_request 自動 review
scheduleworkflow_dispatch 定期或手動任務(需 prompt

留言例子

/opencode 說明這個 issue
/opencode 修正這個問題
把刪除筆記時一併刪掉 S3 附件 /oc

前兩種會讀整個討論串;第三種可在 PR 既有分支上直接 commit。在 Files 分頁對特定行留言時,agent 會拿到檔案路徑、行號與 diff。

排程與自動 triage 範例見 官方 GitHub 文件。沒有使用者留言的事件必須自己寫 prompt

相關資料