Update spawn-issues to concurrent pipeline with status updates

- Each issue flows independently through: implement → review → fix → review
- Don't wait for all workers before starting reviews
- Print status update as each step completes
- Poll loop checks all tasks, advances each issue independently
- State machine: implementing → reviewing → fixing → approved/failed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-09 18:11:05 +01:00
parent 3afe930a27
commit 22962c22cf

View File

@@ -17,25 +17,39 @@ Example: `/spawn-issues 42 43 44`
## Orchestration Flow
```
┌─────────────────────────────────────────────────────────────┐
│ spawn-issues │
│ (orchestrator) │
├─────────────────────────────────────────────────────────────┤
Phase 1: Implementation │
│ ├── Spawn issue-worker agents (background, parallel) │
│ ├── Wait for all workers to complete │
│ └── Collect PR numbers from results │
├─────────────────────────────────────────────────────────────┤
│ Phase 2: Review Loop (for each PR) │
│ ├── Spawn code-reviewer (background) │
│ ├── Wait for review │
│ ├── If needs work → spawn pr-fixer (background) │
│ ├── Wait for fix │
│ └── Repeat until approved (max 3 iterations per PR) │
├─────────────────────────────────────────────────────────────┤
│ Phase 3: Report │
│ └── Display final status table │
└─────────────────────────────────────────────────────────────┘
Concurrent Pipeline - each issue flows independently:
Issue #42 ──► worker ──► PR #55 ──► review ──► fix? ──► ✓
Issue #43 ──► worker ──► PR #56 ──► review ──► ✓
Issue #44 ──► worker ──► PR #57 ──► review ──► fix ──► ✓
As each step completes, immediately:
1. Print a status update
2. Start the next step for that issue
Don't wait for all workers before reviewing - pipeline each issue.
```
## Status Updates
Print a brief status update whenever any step completes:
```
[#42] Worker completed → PR #55 created
[#43] Worker completed → PR #56 created
[#42] Review: needs work → spawning fixer
[#43] Review: approved ✓
[#42] Fix completed → re-reviewing
[#44] Worker completed → PR #57 created
[#42] Review: approved ✓
[#44] Review: approved ✓
All done! Final summary:
| Issue | PR | Status |
|-------|-----|----------|
| #42 | #55 | approved |
| #43 | #56 | approved |
| #44 | #57 | approved |
```
## Implementation
@@ -55,9 +69,9 @@ REPO_PATH=$(pwd)
REPO_NAME=$(basename $REPO_PATH)
```
### Step 3: Phase 1 - Spawn Issue Workers
### Step 3: Spawn All Issue Workers
For each issue number, spawn a background issue-worker agent:
For each issue number, spawn a background issue-worker agent and track its task_id:
```
Task tool with:
@@ -66,6 +80,23 @@ Task tool with:
- prompt: <issue-worker prompt below>
```
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 },
}
```
Print initial status:
```
Spawned 3 issue workers:
[#42] implementing...
[#43] implementing...
[#44] implementing...
```
**Issue Worker Prompt:**
```
You are an issue-worker agent. Implement issue #<NUMBER> autonomously.
@@ -106,95 +137,75 @@ Process:
Work autonomously. If blocked, note it in PR description and report status as partial/failed.
```
Display progress:
```
Phase 1: Implementation
Spawning issue-worker agents...
- Issue #42: spawned (task_id: xxx)
- Issue #43: spawned (task_id: xxx)
- Issue #44: spawned (task_id: xxx)
```
### Step 4: Poll and Pipeline
### Step 4: Wait for Workers
Use TaskOutput to wait for each worker to complete. Parse the ISSUE_WORKER_RESULT from each output to extract:
- issue number
- pr number
- status
Build a tracking table:
```
| Issue | PR | Status |
|-------|-----|---------|
| #42 | #55 | success |
| #43 | #56 | success |
| #44 | - | failed |
```
### Step 5: Phase 2 - Review Loop
For each PR that was created successfully, run a review loop (max 3 iterations):
Run a polling loop until all issues reach a terminal state (approved, failed, or max iterations):
```
for each PR:
iteration = 0
while iteration < 3:
# Spawn code-reviewer in background
Task tool with:
- subagent_type: "code-reviewer"
- run_in_background: true
- prompt: "Review PR #<PR_NUMBER> in <REPO_PATH>. Output EXACTLY:
REVIEW_RESULT
pr: <PR_NUMBER>
verdict: <approved|needs-work>
summary: <1-2 sentences>"
while any issue not in terminal state:
for each issue:
check TaskOutput (block=false) for current task
# Wait for review
Use TaskOutput to get result, parse verdict
if task completed:
parse result
print status update
start next step (spawn next agent)
update issue state
if verdict == "approved":
mark PR as approved, break
if verdict == "needs-work":
# Spawn pr-fixer in background
Task tool with:
- subagent_type: "general-purpose"
- run_in_background: true
- prompt: <pr-fixer prompt - address feedback, commit, push>
# Wait for fix
Use TaskOutput to get result
iteration++
brief pause before next poll iteration
```
Display progress:
```
Phase 2: Review
PR #55: reviewing...
PR #55: needs work → fixing...
PR #55: re-reviewing...
PR #55: approved ✓
PR #56: reviewing...
PR #56: approved ✓
```
### Step 6: Phase 3 - Final Report
Display final status:
**State transitions:**
```
Completed: 3 issues processed
implementing → (worker done) → reviewing → (approved) → DONE
→ (needs-work) → fixing → reviewing...
→ (3 iterations) → needs-manual-review
→ (worker failed) → FAILED
```
| Issue | PR | Implementation | Review |
|-------|-----|----------------|----------|
| #42 | #55 | success | approved |
| #43 | #56 | success | approved |
| #44 | - | failed | - |
**On each completion, print status:**
Summary:
- 2 PRs created and approved
- 1 issue failed (see PR description for details)
```
[#42] Worker completed → PR #55 created, starting review
[#43] Worker completed → PR #56 created, starting review
[#42] Review: needs work → spawning fixer
[#43] Review: approved ✓
[#42] Fix completed → re-reviewing
[#44] Worker completed → PR #57 created, starting review
[#42] Review: approved ✓
[#44] Review: approved ✓
```
### Step 5: Spawn Reviewers and Fixers
**Code Reviewer Prompt:**
```
Review PR #<PR_NUMBER> in <REPO_PATH>.
Output EXACTLY this format:
REVIEW_RESULT
pr: <PR_NUMBER>
verdict: <approved|needs-work>
summary: <1-2 sentences>
```
**PR Fixer Prompt:** (see below)
### Step 6: Final Report
When all issues reach terminal state, display summary:
```
All done!
| Issue | PR | Status |
|-------|-----|---------------------|
| #42 | #55 | approved |
| #43 | #56 | approved |
| #44 | #57 | approved |
3 PRs created and approved
```
## PR Fixer Prompt