Fix spawn-issues: use worktrees for code reviewers

The code reviewer prompt was minimal and didn't specify worktree setup,
causing parallel reviewers to interfere with each other by checking out
different branches in the same directory.

Changes:
- Add worktree setup/cleanup to code reviewer prompt (like issue-worker/fixer)
- Add branch tracking to issue state
- Add note about passing branch name to reviewers
- Expand reviewer prompt with full review process

This ensures each reviewer works in isolation at:
  ../<repo>-review-<pr-number>

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-10 01:14:05 +01:00
parent 095b5e7982
commit 73caf4e4cf

View File

@@ -83,9 +83,9 @@ Task tool with:
Track state for each issue:
```
issues = {
42: { task_id: "xxx", stage: "implementing", pr: null, review_iterations: 0 },
43: { task_id: "yyy", stage: "implementing", pr: null, review_iterations: 0 },
44: { task_id: "zzz", stage: "implementing", pr: null, review_iterations: 0 },
42: { task_id: "xxx", stage: "implementing", pr: null, branch: null, review_iterations: 0 },
43: { task_id: "yyy", stage: "implementing", pr: null, branch: null, review_iterations: 0 },
44: { task_id: "zzz", stage: "implementing", pr: null, branch: null, review_iterations: 0 },
}
```
@@ -181,15 +181,46 @@ implementing → (worker done) → reviewing → (approved) → DONE
### Step 5: Spawn Reviewers and Fixers
When spawning reviewers, pass the PR number AND branch name from the issue worker result.
Each reviewer/fixer uses its own worktree for isolation - this prevents parallel agents from interfering with each other.
**Code Reviewer Prompt:**
```
Review PR #<PR_NUMBER> in <REPO_PATH>.
You are a code-reviewer agent. Review PR #<PR_NUMBER> autonomously.
Output EXACTLY this format:
REVIEW_RESULT
pr: <PR_NUMBER>
verdict: <approved|needs-work>
summary: <1-2 sentences>
Context:
- Repository path: <REPO_PATH>
- Repository name: <REPO_NAME>
- PR number: <PR_NUMBER>
- PR branch: <BRANCH_NAME>
Process:
1. Setup worktree for isolated review:
cd <REPO_PATH> && git fetch origin
git worktree add ../<REPO_NAME>-review-<PR_NUMBER> origin/<BRANCH_NAME>
cd ../<REPO_NAME>-review-<PR_NUMBER>
2. Get PR details: tea pulls <PR_NUMBER> --comments
3. Review the diff: git diff origin/main...HEAD
4. Analyze changes for:
- Code quality and style
- Potential bugs or logic errors
- Test coverage
- Documentation
5. Post review comment: tea comment <PR_NUMBER> "<review summary>"
6. Cleanup: cd <REPO_PATH> && git worktree remove ../<REPO_NAME>-review-<PR_NUMBER> --force
7. Output EXACTLY this format:
REVIEW_RESULT
pr: <PR_NUMBER>
verdict: <approved|needs-work>
summary: <1-2 sentences>
Work autonomously. Be constructive but thorough.
```
**PR Fixer Prompt:** (see below)