opencode-config/.opencode/tools/merge-pr.ts
opencode-agent 93e7843438
All checks were successful
CI / bootstrap (push) Successful in 7s
CI / lint (push) Successful in 17s
CI / typecheck (push) Successful in 25s
CI / test (3.12) (push) Successful in 2m48s
CI / test (3.13) (push) Successful in 1m41s
CI / test (3.14) (push) Successful in 1m34s
CI / complexity (push) Successful in 21s
feat(tools): add Forgejo backend with gh CLI fallback
2026-08-06 15:02:20 +00:00

23 lines
No EOL
996 B
TypeScript

import { tool } from "@opencode-ai/plugin"
import { runGh } from "./_shared"
export default tool({
description: "Merge a PR via squash + delete branch. Orchestrator-safe wrapper for `gh pr merge N --squash --delete-branch`. Main agent calls this tool instead of raw bash, aligning with the pure-orchestrator model (tool-led philosophy, see ADR-010).",
args: {
pr_number: tool.schema.number().describe("PR number to merge"),
repo: tool.schema.string().optional().describe("Optional repo (owner/name). If omitted, gh auto-detects from context.worktree."),
},
async execute(args, context) {
const r = await runGh(
["pr", "merge", String(args.pr_number), "--squash", "--delete-branch"],
args.repo,
{ cwd: context.worktree },
)
if (r.status !== 0) {
return `⚠️ merge_pr failed for PR #${args.pr_number} (exit ${r.status}): ${r.stderr || r.stdout}`
}
return `PR #${args.pr_number} merged successfully (squash, branch deleted).`
},
})