opencode-config/.opencode/tools/post-docs-review.ts
Sergey 15fc7d014d
refactor(tools): add repo parameter + shared module + tunnel tests (#65)
* refactor(tools): extract shared module for gh spawnSync logic

* feat(tools): add repo parameter to 5 GitHub tools

* test(tools): add tunnel tool tests

* test(tools): add repo parameter test cases for 5 tools

* docs(handoff): scaffold handoff and ADR for PR

* docs(handoff): set PR number

* docs(project-map): update after PR#65 structural changes

---------

Co-authored-by: opencode-agent <agent@opencode.local>
2026-07-25 19:19:19 +03:00

23 lines
No EOL
1.3 KiB
TypeScript

import { tool } from "@opencode-ai/plugin"
import { runGh } from "./_shared"
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)"),
repo: tool.schema.string().optional().describe("Optional repo (owner/name). If omitted, gh auto-detects from context.worktree."),
},
async execute(args, context) {
const comment = `## Docs Review Summary\n\n${args.body}\n\n### Verdict: ${args.verdict}`
const r = runGh(["pr", "comment", String(args.pr_number), "--body", comment], args.repo, { 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}`
},
})