* feat(tools): add merge_pr TS tool wrapper * refactor(run-pipeline): replace raw gh pr merge with merge_pr tool * fix(scripts): update pipeline-status MERGE NEXT action * docs(handoff): add pr-16 handoff + ADR-010 * fix(handoff): remove dangling ADR-012/ADR-016 references * docs(handoff): set PR number 30 * docs(project-map): add merge-pr.ts tool (PR#30) --------- Co-authored-by: opencode-agent <agent@slaid098.dev>
24 lines
894 B
TypeScript
24 lines
894 B
TypeScript
import { spawnSync } from "child_process"
|
|
import { tool } from "@opencode-ai/plugin"
|
|
|
|
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"),
|
|
},
|
|
async execute(args, context) {
|
|
const r = spawnSync("gh", [
|
|
"pr", "merge", String(args.pr_number),
|
|
"--squash", "--delete-branch",
|
|
], {
|
|
encoding: "utf-8",
|
|
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).`
|
|
},
|
|
})
|