Part of #1367 (Phase 2 — AI Review Parity).
Goal
CodeRabbit's "Finishing Touches" (docs) as agent-runtime tasks — on-demand agentic actions on a PR, each invocable via a @buddy-bot command (#1376) and optionally offered as one-click checkboxes under the review summary:
generate docstrings— add missing doc comments for changed public APIs (JSDoc per repo convention; respectCLAUDE.mdJSDoc style). Commit to the PR branch or a stacked PR (config)generate unit tests— generatebun:testtests for changed functions, following the repo'stest/structure and describe/it conventions; verified by actually running them in the sandbox before committing (agentstopScript-style loop from #1374)autofix— apply all committable suggestions from the current review (and fixable linter findings from #1378) as one commitsimplify— refactor pass on changed code for clarity without behavior change; must pass existing tests before committing- Custom finishing touches — config-defined named prompts (CodeRabbit caps at 5 recipes / 10K chars; we can be more generous):
ai.finishingTouches.custom: { name, instructions, tools?: 'read-only' | 'write' }[]
Design
src/agent/tasks/— one module per task (docstrings.ts,unit-tests.ts,autofix.ts,simplify.ts,custom.ts), each a mode definition (playbook + tool tier) for the #1374 runner- Output modes per task:
commit(push to PR branch — requires the PR author to be the bot or explicit maintainer invocation),stacked-pr(branch off the PR branch, open PR targeting it — safest default for human PRs), orsuggestion(post as committable suggestions only) - Verification gates: unit-test task runs the generated tests; simplify/autofix run the repo's test command (from learnings #1379 or
package.jsonscripts) before pushing; failures → post partial result as suggestions instead - Checkbox offering: review summary (#1375) appends an offer section with
<!-- buddy-bot:touch=<task> -->markers; checked boxes handled by the same comment/edited machinery as #1370
Config
ai.finishingTouches?: {
docstrings?: boolean | { output?: 'commit' | 'stacked-pr' | 'suggestion' }
unitTests?: boolean | { output?: ..., pathInstructions?: {...}[] }
autofix?: boolean
simplify?: boolean
custom?: { name: string, instructions: string, tools?: 'read-only' | 'write' }[]
}Tasks
- Task modules + mode/permission definitions; command wiring in #1376 dispatcher
- Stacked-PR mechanics in
src/git/github-provider.ts(branch-off-branch, PR targeting PR head branch) - Verification gates with sandboxed test runs + partial-result fallback
- Checkbox offer/consume flow
- Per-task fixtures: repo with missing docstrings, uncovered function, failing lint, convoluted function
docs/ai/finishing-touches.md
Acceptance criteria
- Each of the four built-in tasks produces a correct commit/stacked-PR/suggestion in fixture repos
- Generated tests actually run green before being committed; red generations degrade to suggestions
- Custom recipes execute with their declared tool tier only