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:
@@ -17,25 +17,39 @@ Example: `/spawn-issues 42 43 44`
|
|||||||
## Orchestration Flow
|
## Orchestration Flow
|
||||||
|
|
||||||
```
|
```
|
||||||
┌─────────────────────────────────────────────────────────────┐
|
Concurrent Pipeline - each issue flows independently:
|
||||||
│ spawn-issues │
|
|
||||||
│ (orchestrator) │
|
Issue #42 ──► worker ──► PR #55 ──► review ──► fix? ──► ✓
|
||||||
├─────────────────────────────────────────────────────────────┤
|
Issue #43 ──► worker ──► PR #56 ──► review ──► ✓
|
||||||
│ Phase 1: Implementation │
|
Issue #44 ──► worker ──► PR #57 ──► review ──► fix ──► ✓
|
||||||
│ ├── Spawn issue-worker agents (background, parallel) │
|
|
||||||
│ ├── Wait for all workers to complete │
|
As each step completes, immediately:
|
||||||
│ └── Collect PR numbers from results │
|
1. Print a status update
|
||||||
├─────────────────────────────────────────────────────────────┤
|
2. Start the next step for that issue
|
||||||
│ Phase 2: Review Loop (for each PR) │
|
|
||||||
│ ├── Spawn code-reviewer (background) │
|
Don't wait for all workers before reviewing - pipeline each issue.
|
||||||
│ ├── Wait for review │
|
```
|
||||||
│ ├── If needs work → spawn pr-fixer (background) │
|
|
||||||
│ ├── Wait for fix │
|
## Status Updates
|
||||||
│ └── Repeat until approved (max 3 iterations per PR) │
|
|
||||||
├─────────────────────────────────────────────────────────────┤
|
Print a brief status update whenever any step completes:
|
||||||
│ Phase 3: Report │
|
|
||||||
│ └── Display final status table │
|
```
|
||||||
└─────────────────────────────────────────────────────────────┘
|
[#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
|
## Implementation
|
||||||
@@ -55,9 +69,9 @@ REPO_PATH=$(pwd)
|
|||||||
REPO_NAME=$(basename $REPO_PATH)
|
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:
|
Task tool with:
|
||||||
@@ -66,6 +80,23 @@ Task tool with:
|
|||||||
- prompt: <issue-worker prompt below>
|
- 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:**
|
**Issue Worker Prompt:**
|
||||||
```
|
```
|
||||||
You are an issue-worker agent. Implement issue #<NUMBER> autonomously.
|
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.
|
Work autonomously. If blocked, note it in PR description and report status as partial/failed.
|
||||||
```
|
```
|
||||||
|
|
||||||
Display progress:
|
### Step 4: Poll and Pipeline
|
||||||
```
|
|
||||||
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: Wait for Workers
|
Run a polling loop until all issues reach a terminal state (approved, failed, or max iterations):
|
||||||
|
|
||||||
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):
|
|
||||||
|
|
||||||
```
|
```
|
||||||
for each PR:
|
while any issue not in terminal state:
|
||||||
iteration = 0
|
for each issue:
|
||||||
while iteration < 3:
|
check TaskOutput (block=false) for current task
|
||||||
# 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>"
|
|
||||||
|
|
||||||
# Wait for review
|
if task completed:
|
||||||
Use TaskOutput to get result, parse verdict
|
parse result
|
||||||
|
print status update
|
||||||
|
start next step (spawn next agent)
|
||||||
|
update issue state
|
||||||
|
|
||||||
if verdict == "approved":
|
brief pause before next poll iteration
|
||||||
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++
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Display progress:
|
**State transitions:**
|
||||||
```
|
|
||||||
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:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
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 |
|
**On each completion, print status:**
|
||||||
|-------|-----|----------------|----------|
|
|
||||||
| #42 | #55 | success | approved |
|
|
||||||
| #43 | #56 | success | approved |
|
|
||||||
| #44 | - | failed | - |
|
|
||||||
|
|
||||||
Summary:
|
```
|
||||||
- 2 PRs created and approved
|
[#42] Worker completed → PR #55 created, starting review
|
||||||
- 1 issue failed (see PR description for details)
|
[#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
|
## PR Fixer Prompt
|
||||||
|
|||||||
Reference in New Issue
Block a user