import * as vm from "../vm.ts" import * as state from "../state.ts" import { spinner } from "../spinner.ts" import { requireSession, saveChanges } from "./helpers.ts" export async function action(branch: string, extra: string | undefined, opts: { print?: boolean }) { const { root, session } = await requireSession(branch) const spin = spinner("Starting container", branch) await vm.ensure((msg) => { spin.text = msg }) let prompt = ` You're a grumpy old senior software engineer. You need to review some code my co-worker wrote. Launch four agents to review the diff between this branch and main with the following specializations: 1. Checks CLAUDE.md compliance 2. Looks specifically for bugs 3. Also looks specifically for bugs 4. Looks for opportunities to simplify code Have them focus only on the diff! + lines are added in this branch, - lines are overwritten or deleted. They must focus mostly on the + lines. Each agent should deliver you a report in this format (the are just for you, not part of their output): # Problem Identified Description of problem. Tell each agent: Run \`git diff main...HEAD\` and focus on the "+" lines, not the "-" lines. Once the agents are done, look at all their suggestions and let me know what you think. Give me your opinion in this format, with the : # {branch name} Review **OK TO SHIP: yes or no** # Showstoppers 1. BUG: Bug that both bug hunters found. 2. BUG: Bug that one of the hunters found. 3. COMPLIANCE: Describe CLAUDE.md compliance issue. # Recommendations 4. BUG: Bug that both bug hunters found. 5. BUG: Bug that one of the hunters found. 6. COMPLIANCE: Describe CLAUDE.md compliance issue. 7. SIMPLIFY: Opportunities to simplify code. # Optional 8. BUG: Bug that both bug hunters found. 9. BUG: Bug that one of the hunters found. 10. COMPLIANCE: Describe CLAUDE.md compliance issue. 11. SIMPLIFY: Opportunities to simplify code. # Summary Your thoughts, in brief. ` if (extra) prompt += "\n\n" + extra await state.patchSession(root, session.branch, { in_review: true }) try { if (opts.print) { spin.text = "Running review…" const result = await vm.claude(session.worktree, { print: prompt }) spin.stop() if (result.output) process.stdout.write(result.output + "\n") } else { spin.succeed("Session ready") await vm.claude(session.worktree, { prompt }) } } catch (e) { spin.stop() throw e } finally { // Clear review flag before saveChanges to minimize the race window await state.patchSession(root, session.branch, { in_review: false }).catch(() => {}) // Save worktree changes only in interactive mode if (!opts.print) await saveChanges(session.worktree, session.branch) } }