* feat(tools): add post-review and post-docs-review tools * refactor(agents): use post-review/post-docs-review tools in reviewer and docs-reviewer * feat(permissions): add post_review and post_docs_review to agent.tools map * test(tools): add tests for post-review and post-docs-review tools * docs(handoff): add handoff ADR and project-map for review posting tools * docs(handoff): set PR number * docs: fix PR#45→PR#46 refs in project map --------- Co-authored-by: opencode-agent <agent@slaid098.dev>
25 lines
No EOL
1.3 KiB
TypeScript
25 lines
No EOL
1.3 KiB
TypeScript
import { spawnSync } from "child_process"
|
|
import { tool } from "@opencode-ai/plugin"
|
|
|
|
const VERDICTS = ["APPROVE", "FIXED", "NO_CHANGES"] as const
|
|
type Verdict = typeof VERDICTS[number]
|
|
|
|
export default tool({
|
|
description: "Post docs review verdict as PR comment with deterministic heading. Docs-reviewer agent uses this instead of raw `gh pr comment` to guarantee `## Docs Review Summary` heading that pipeline-status.py parses.",
|
|
args: {
|
|
pr_number: tool.schema.number().describe("PR number to comment on"),
|
|
verdict: tool.schema.enum(VERDICTS).describe("Docs review verdict: APPROVE, FIXED, or NO_CHANGES"),
|
|
body: tool.schema.string().describe("Docs review body text (without heading — heading is auto-generated)"),
|
|
},
|
|
async execute(args, context) {
|
|
const comment = `## Docs Review Summary\n\n${args.body}\n\n### Verdict: ${args.verdict}`
|
|
const r = spawnSync("gh", ["pr", "comment", String(args.pr_number), "--body", comment, "--repo", "slaid098/opencode-config"], {
|
|
encoding: "utf-8",
|
|
cwd: context.worktree,
|
|
})
|
|
if (r.status !== 0) {
|
|
return `⚠️ post-docs-review failed for PR #${args.pr_number} (exit ${r.status}): ${r.stderr || r.stdout}`
|
|
}
|
|
return `Docs review posted on PR #${args.pr_number}: verdict=${args.verdict}`
|
|
},
|
|
}) |