claude-code-workflow 7.2.3 → 7.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/.claude/agents/team-worker.md +2 -2
  2. package/.claude/skills/team-arch-opt/SKILL.md +1 -1
  3. package/.claude/skills/team-arch-opt/roles/coordinator/commands/monitor.md +1 -1
  4. package/.claude/skills/team-arch-opt/specs/team-config.json +1 -1
  5. package/.claude/skills/team-brainstorm/SKILL.md +2 -2
  6. package/.claude/skills/team-brainstorm/roles/coordinator/commands/monitor.md +1 -1
  7. package/.claude/skills/team-designer/SKILL.md +2 -2
  8. package/.claude/skills/team-designer/phases/03-content-generation.md +2 -2
  9. package/.claude/skills/team-edict/SKILL.md +1 -1
  10. package/.claude/skills/team-edict/role-specs/xingbu.md +1 -1
  11. package/.claude/skills/team-edict/roles/coordinator/role.md +4 -4
  12. package/.claude/skills/team-frontend/SKILL.md +1 -1
  13. package/.claude/skills/team-frontend/roles/coordinator/commands/monitor.md +1 -1
  14. package/.claude/skills/team-frontend-debug/SKILL.md +1 -1
  15. package/.claude/skills/team-frontend-debug/roles/coordinator/commands/dispatch.md +11 -11
  16. package/.claude/skills/team-issue/SKILL.md +2 -2
  17. package/.claude/skills/team-issue/roles/coordinator/commands/monitor.md +2 -2
  18. package/.claude/skills/team-iterdev/SKILL.md +1 -1
  19. package/.claude/skills/team-iterdev/roles/coordinator/commands/monitor.md +1 -1
  20. package/.claude/skills/team-lifecycle-v4/SKILL.md +2 -2
  21. package/.claude/skills/team-lifecycle-v4/roles/coordinator/commands/dispatch.md +2 -2
  22. package/.claude/skills/team-perf-opt/SKILL.md +1 -1
  23. package/.claude/skills/team-perf-opt/roles/coordinator/commands/monitor.md +1 -1
  24. package/.claude/skills/team-perf-opt/roles/coordinator/role.md +1 -1
  25. package/.claude/skills/team-perf-opt/specs/team-config.json +1 -1
  26. package/.claude/skills/team-planex/SKILL.md +1 -1
  27. package/.claude/skills/team-planex/roles/coordinator/commands/monitor.md +1 -1
  28. package/.claude/skills/team-quality-assurance/SKILL.md +1 -1
  29. package/.claude/skills/team-quality-assurance/roles/coordinator/commands/dispatch.md +1 -1
  30. package/.claude/skills/team-quality-assurance/roles/coordinator/commands/monitor.md +3 -3
  31. package/.claude/skills/team-review/SKILL.md +1 -1
  32. package/.claude/skills/team-review/roles/coordinator/commands/dispatch.md +1 -1
  33. package/.claude/skills/team-review/roles/coordinator/commands/monitor.md +4 -4
  34. package/.claude/skills/team-roadmap-dev/SKILL.md +1 -1
  35. package/.claude/skills/team-roadmap-dev/roles/coordinator/commands/monitor.md +4 -4
  36. package/.claude/skills/team-roadmap-dev/specs/pipelines.md +3 -3
  37. package/.claude/skills/team-roadmap-dev/specs/team-config.json +1 -1
  38. package/.claude/skills/team-tech-debt/SKILL.md +1 -1
  39. package/.claude/skills/team-tech-debt/roles/coordinator/commands/monitor.md +1 -1
  40. package/.claude/skills/team-testing/SKILL.md +1 -1
  41. package/.claude/skills/team-testing/roles/coordinator/commands/dispatch.md +1 -1
  42. package/.claude/skills/team-testing/roles/coordinator/commands/monitor.md +7 -7
  43. package/.claude/skills/team-uidesign/SKILL.md +1 -1
  44. package/.claude/skills/team-uidesign/roles/coordinator/commands/monitor.md +1 -1
  45. package/.claude/skills/team-ultra-analyze/SKILL.md +1 -1
  46. package/.claude/skills/team-ultra-analyze/roles/coordinator/commands/monitor.md +5 -5
  47. package/.claude/skills/team-ultra-analyze/roles/coordinator/role.md +1 -1
  48. package/.claude/skills/team-ux-improve/SKILL.md +1 -1
  49. package/.claude/skills/team-ux-improve/roles/coordinator/commands/monitor.md +1 -1
  50. package/.claude/skills/team-ux-improve/roles/coordinator/role.md +2 -2
  51. package/.claude/skills/team-ux-improve/specs/pipelines.md +1 -1
  52. package/.claude/skills/team-ux-improve/specs/team-config.json +1 -1
  53. package/.codex/skills/team-arch-opt/SKILL.md +38 -0
  54. package/.codex/skills/team-arch-opt/instructions/agent-instruction.md +114 -114
  55. package/.codex/skills/team-brainstorm/SKILL.md +725 -687
  56. package/.codex/skills/team-coordinate/SKILL.md +38 -0
  57. package/.codex/skills/team-designer/SKILL.md +691 -653
  58. package/.codex/skills/team-designer/schemas/tasks-schema.md +180 -180
  59. package/.codex/skills/team-edict/SKILL.md +781 -742
  60. package/.codex/skills/team-edict/agents/aggregator.md +246 -246
  61. package/.codex/skills/team-edict/agents/qa-verifier.md +274 -274
  62. package/.codex/skills/team-edict/agents/shangshu-dispatcher.md +247 -247
  63. package/.codex/skills/team-edict/agents/zhongshu-planner.md +198 -198
  64. package/.codex/skills/team-edict/instructions/agent-instruction.md +177 -177
  65. package/.codex/skills/team-executor/SKILL.md +38 -0
  66. package/.codex/skills/team-frontend/SKILL.md +38 -0
  67. package/.codex/skills/team-frontend-debug/SKILL.md +38 -0
  68. package/.codex/skills/team-issue/SKILL.md +740 -702
  69. package/.codex/skills/team-iterdev/SKILL.md +826 -788
  70. package/.codex/skills/team-lifecycle/SKILL.md +38 -0
  71. package/.codex/skills/team-lifecycle/agents/analyst.md +6 -6
  72. package/.codex/skills/team-lifecycle/agents/discuss-agent.md +1 -1
  73. package/.codex/skills/team-lifecycle/agents/explore-agent.md +3 -3
  74. package/.codex/skills/team-lifecycle/agents/writer.md +3 -3
  75. package/.codex/skills/team-lifecycle/phases/01-requirement-clarification.md +1 -1
  76. package/.codex/skills/team-lifecycle/phases/02-team-initialization.md +1 -1
  77. package/.codex/skills/team-lifecycle/phases/03-task-chain-creation.md +1 -1
  78. package/.codex/skills/team-lifecycle/phases/04-pipeline-coordination.md +1 -1
  79. package/.codex/skills/team-lifecycle/phases/05-completion-report.md +1 -1
  80. package/.codex/skills/team-lifecycle-v4/SKILL.md +775 -737
  81. package/.codex/skills/team-perf-opt/SKILL.md +38 -0
  82. package/.codex/skills/team-perf-opt/instructions/agent-instruction.md +122 -122
  83. package/.codex/skills/team-planex/SKILL.md +38 -0
  84. package/.codex/skills/team-planex-v2/SKILL.md +39 -1
  85. package/.codex/skills/team-quality-assurance/SKILL.md +38 -0
  86. package/.codex/skills/team-review/SKILL.md +38 -0
  87. package/.codex/skills/team-roadmap-dev/SKILL.md +38 -0
  88. package/.codex/skills/team-tech-debt/SKILL.md +38 -0
  89. package/.codex/skills/team-testing/SKILL.md +38 -0
  90. package/.codex/skills/team-uidesign/SKILL.md +38 -0
  91. package/.codex/skills/team-ultra-analyze/SKILL.md +787 -749
  92. package/.codex/skills/team-ux-improve/SKILL.md +38 -0
  93. package/ccw/dist/tools/smart-search.d.ts +23 -0
  94. package/ccw/dist/tools/smart-search.d.ts.map +1 -1
  95. package/ccw/dist/tools/smart-search.js +41 -10
  96. package/ccw/dist/tools/smart-search.js.map +1 -1
  97. package/codex-lens/src/codexlens/config.py +32 -0
  98. package/codex-lens/src/codexlens/storage/index_tree.py +101 -33
  99. package/package.json +1 -1
@@ -1,702 +1,740 @@
1
- ---
2
- name: team-issue
3
- description: Hybrid team skill for issue resolution. CSV wave primary for exploration, planning, integration, and implementation. Interactive agents for review gates with fix cycles. Supports Quick, Full, and Batch pipelines.
4
- argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] [--mode=quick|full|batch] \"issue-ids or --all-pending\""
5
- allowed-tools: spawn_agents_on_csv, spawn_agent, wait, send_input, close_agent, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
- ---
7
-
8
- ## Auto Mode
9
-
10
- When `--yes` or `-y`: Auto-confirm task decomposition, skip interactive validation, use defaults.
11
-
12
- # Team Issue Resolution
13
-
14
- ## Usage
15
-
16
- ```bash
17
- $team-issue "ISS-20260308-120000 ISS-20260308-120001"
18
- $team-issue -c 4 "ISS-20260308-120000 --mode=full"
19
- $team-issue -y "--all-pending"
20
- $team-issue --continue "issue-auth-fix-20260308"
21
- ```
22
-
23
- **Flags**:
24
- - `-y, --yes`: Skip all confirmations (auto mode)
25
- - `-c, --concurrency N`: Max concurrent agents within each wave (default: 3)
26
- - `--continue`: Resume existing session
27
- - `--mode=quick|full|batch`: Force pipeline mode (default: auto-detect)
28
-
29
- **Output Directory**: `.workflow/.csv-wave/{session-id}/`
30
- **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report)
31
-
32
- ---
33
-
34
- ## Overview
35
-
36
- Orchestrate issue resolution pipeline: explore context, plan solution, review (optional), marshal queue, implement. Supports Quick, Full, and Batch pipelines with review-fix cycle.
37
-
38
- **Execution Model**: Hybrid -- CSV wave pipeline (primary) + individual agent spawn (secondary)
39
-
40
- ```
41
- +---------------------------------------------------------------------------+
42
- | TEAM ISSUE RESOLUTION WORKFLOW |
43
- +---------------------------------------------------------------------------+
44
- | |
45
- | Phase 1: Requirement Parsing + Pipeline Selection |
46
- | +-- Parse issue IDs (GH-\d+, ISS-\d{8}-\d{6}, --all-pending) |
47
- | +-- Auto-detect pipeline mode (quick/full/batch) |
48
- | +-- Determine execution method (codex/gemini/auto) |
49
- | +-- Generate tasks.csv with wave + exec_mode columns |
50
- | +-- User validates task breakdown (skip if -y) |
51
- | |
52
- | Phase 2: Wave Execution Engine (Extended) |
53
- | +-- For each wave (1..N): |
54
- | | +-- Execute pre-wave interactive tasks (if any) |
55
- | | +-- Build wave CSV (filter csv-wave tasks for this wave) |
56
- | | +-- Inject previous findings into prev_context column |
57
- | | +-- spawn_agents_on_csv(wave CSV) |
58
- | | +-- Execute post-wave interactive tasks (if any) |
59
- | | +-- Merge all results into master tasks.csv |
60
- | | +-- Check: any failed? -> skip dependents |
61
- | +-- discoveries.ndjson shared across all modes (append-only) |
62
- | |
63
- | Phase 3: Post-Wave Interactive (Review Gate) |
64
- | +-- Reviewer agent: multi-dimensional review with verdict |
65
- | +-- Fix cycle: rejected -> revise solution -> re-review (max 2) |
66
- | +-- Final aggregation / report |
67
- | |
68
- | Phase 4: Results Aggregation |
69
- | +-- Export final results.csv |
70
- | +-- Generate context.md with all findings |
71
- | +-- Display summary: completed/failed/skipped per wave |
72
- | +-- Offer: view results | retry failed | done |
73
- | |
74
- +---------------------------------------------------------------------------+
75
- ```
76
-
77
- ---
78
-
79
- ## Task Classification Rules
80
-
81
- Each task is classified by `exec_mode`:
82
-
83
- | exec_mode | Mechanism | Criteria |
84
- |-----------|-----------|----------|
85
- | `csv-wave` | `spawn_agents_on_csv` | One-shot, structured I/O, no multi-round interaction |
86
- | `interactive` | `spawn_agent`/`wait`/`send_input`/`close_agent` | Multi-round, clarification, review gates |
87
-
88
- **Classification Decision**:
89
-
90
- | Task Property | Classification |
91
- |---------------|---------------|
92
- | Codebase exploration (EXPLORE-*) | `csv-wave` |
93
- | Solution planning (SOLVE-*) | `csv-wave` |
94
- | Queue formation / integration (MARSHAL-*) | `csv-wave` |
95
- | Code implementation (BUILD-*) | `csv-wave` |
96
- | Technical review with verdict (AUDIT-*) | `interactive` |
97
- | Solution revision after rejection (SOLVE-fix-*) | `csv-wave` |
98
-
99
- ---
100
-
101
- ## CSV Schema
102
-
103
- ### tasks.csv (Master State)
104
-
105
- ```csv
106
- id,title,description,role,issue_ids,exec_mode,execution_method,deps,context_from,wave,status,findings,artifact_path,error
107
- "EXPLORE-001","Context analysis","Analyze issue context and map codebase impact for ISS-20260308-120000","explorer","ISS-20260308-120000","csv-wave","","","","1","pending","","","",""
108
- "SOLVE-001","Solution design","Design solution and decompose into implementation tasks","planner","ISS-20260308-120000","csv-wave","","EXPLORE-001","EXPLORE-001","2","pending","","","",""
109
- "AUDIT-001","Technical review","Review solution for feasibility, risk, and completeness","reviewer","ISS-20260308-120000","interactive","","SOLVE-001","SOLVE-001","3","pending","","","",""
110
- "MARSHAL-001","Queue formation","Form execution queue with conflict detection","integrator","ISS-20260308-120000","csv-wave","","AUDIT-001","SOLVE-001","4","pending","","","",""
111
- "BUILD-001","Implementation","Implement solution plan and verify with tests","implementer","ISS-20260308-120000","csv-wave","gemini","MARSHAL-001","EXPLORE-001;SOLVE-001","5","pending","","","",""
112
- ```
113
-
114
- **Columns**:
115
-
116
- | Column | Phase | Description |
117
- |--------|-------|-------------|
118
- | `id` | Input | Unique task identifier (EXPLORE-NNN, SOLVE-NNN, AUDIT-NNN, MARSHAL-NNN, BUILD-NNN) |
119
- | `title` | Input | Short task title |
120
- | `description` | Input | Detailed task description |
121
- | `role` | Input | Worker role: explorer, planner, reviewer, integrator, implementer |
122
- | `issue_ids` | Input | Semicolon-separated issue IDs this task covers |
123
- | `exec_mode` | Input | `csv-wave` or `interactive` |
124
- | `execution_method` | Input | codex, gemini, qwen, or empty (for non-BUILD tasks) |
125
- | `deps` | Input | Semicolon-separated dependency task IDs |
126
- | `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
127
- | `wave` | Computed | Wave number (computed by topological sort, 1-based) |
128
- | `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
129
- | `findings` | Output | Key discoveries or implementation notes (max 500 chars) |
130
- | `artifact_path` | Output | Path to generated artifact (context report, solution, queue, etc.) |
131
- | `error` | Output | Error message if failed (empty if success) |
132
-
133
- ### Per-Wave CSV (Temporary)
134
-
135
- Each wave generates a temporary `wave-{N}.csv` with extra `prev_context` column (csv-wave tasks only).
136
-
137
- ---
138
-
139
- ## Agent Registry (Interactive Agents)
140
-
141
- | Agent | Role File | Pattern | Responsibility | Position |
142
- |-------|-----------|---------|----------------|----------|
143
- | reviewer | agents/reviewer.md | 2.3 (structured review) | Multi-dimensional solution review with verdict | post-wave (after SOLVE wave) |
144
-
145
- > **COMPACT PROTECTION**: Agent files are execution documents. When context compression occurs, **you MUST immediately `Read` the corresponding agent.md** to reload.
146
-
147
- ---
148
-
149
- ## Output Artifacts
150
-
151
- | File | Purpose | Lifecycle |
152
- |------|---------|-----------|
153
- | `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
154
- | `wave-{N}.csv` | Per-wave input (temporary, csv-wave tasks only) | Created before wave, deleted after |
155
- | `results.csv` | Final export of all task results | Created in Phase 4 |
156
- | `discoveries.ndjson` | Shared exploration board (all agents, both modes) | Append-only, carries across waves |
157
- | `context.md` | Human-readable execution report | Created in Phase 4 |
158
- | `explorations/context-{issueId}.json` | Explorer context reports | Created by explorer agents |
159
- | `solutions/solution-{issueId}.json` | Planner solution plans | Created by planner agents |
160
- | `audits/audit-report.json` | Reviewer audit report | Created by reviewer agent |
161
- | `queue/execution-queue.json` | Integrator execution queue | Created by integrator agent |
162
- | `builds/build-{issueId}.json` | Implementer build results | Created by implementer agents |
163
- | `interactive/{id}-result.json` | Results from interactive tasks | Created per interactive task |
164
-
165
- ---
166
-
167
- ## Session Structure
168
-
169
- ```
170
- .workflow/.csv-wave/{session-id}/
171
- +-- tasks.csv # Master state (all tasks, both modes)
172
- +-- results.csv # Final results export
173
- +-- discoveries.ndjson # Shared discovery board (all agents)
174
- +-- context.md # Human-readable report
175
- +-- wave-{N}.csv # Temporary per-wave input (csv-wave only)
176
- +-- explorations/ # Explorer output
177
- | +-- context-{issueId}.json
178
- +-- solutions/ # Planner output
179
- | +-- solution-{issueId}.json
180
- +-- audits/ # Reviewer output
181
- | +-- audit-report.json
182
- +-- queue/ # Integrator output
183
- | +-- execution-queue.json
184
- +-- builds/ # Implementer output
185
- | +-- build-{issueId}.json
186
- +-- interactive/ # Interactive task artifacts
187
- | +-- {id}-result.json
188
- +-- wisdom/ # Cross-task knowledge
189
- +-- learnings.md
190
- +-- decisions.md
191
- +-- conventions.md
192
- +-- issues.md
193
- ```
194
-
195
- ---
196
-
197
- ## Implementation
198
-
199
- ### Session Initialization
200
-
201
- ```javascript
202
- const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
203
-
204
- const AUTO_YES = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
205
- const continueMode = $ARGUMENTS.includes('--continue')
206
- const concurrencyMatch = $ARGUMENTS.match(/(?:--concurrency|-c)\s+(\d+)/)
207
- const maxConcurrency = concurrencyMatch ? parseInt(concurrencyMatch[1]) : 3
208
-
209
- const requirement = $ARGUMENTS
210
- .replace(/--yes|-y|--continue|--concurrency\s+\d+|-c\s+\d+/g, '')
211
- .trim()
212
-
213
- // Parse issue IDs
214
- const issueIdPattern = /(?:GH-\d+|ISS-\d{8}-\d{6})/g
215
- let issueIds = requirement.match(issueIdPattern) || []
216
-
217
- // Parse mode override
218
- const modeMatch = requirement.match(/--mode=(\w+)/)
219
- let pipelineMode = modeMatch ? modeMatch[1] : null
220
-
221
- // Handle --all-pending
222
- if (requirement.includes('--all-pending')) {
223
- const result = Bash("ccw issue list --status registered,pending --json")
224
- issueIds = JSON.parse(result).map(i => i.id)
225
- }
226
-
227
- // If no issue IDs, ask user
228
- if (issueIds.length === 0) {
229
- const answer = AskUserQuestion("No issue IDs found. Please provide issue IDs (e.g., ISS-20260308-120000):")
230
- issueIds = answer.match(issueIdPattern) || []
231
- if (issueIds.length === 0) return // abort
232
- }
233
-
234
- // Auto-detect pipeline mode
235
- if (!pipelineMode) {
236
- // Load issue priorities
237
- const priorities = []
238
- for (const id of issueIds) {
239
- const info = JSON.parse(Bash(`ccw issue status ${id} --json`))
240
- priorities.push(info.priority || 0)
241
- }
242
- const hasHighPriority = priorities.some(p => p >= 4)
243
-
244
- if (issueIds.length <= 2 && !hasHighPriority) pipelineMode = 'quick'
245
- else if (issueIds.length <= 4) pipelineMode = 'full'
246
- else pipelineMode = 'batch'
247
- }
248
-
249
- // Execution method selection
250
- let executionMethod = 'gemini' // default
251
- const execMatch = requirement.match(/--exec=(\w+)/)
252
- if (execMatch) executionMethod = execMatch[1]
253
-
254
- const slug = issueIds[0].toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 30)
255
- const dateStr = getUtc8ISOString().substring(0, 10).replace(/-/g, '')
256
- const sessionId = `issue-${slug}-${dateStr}`
257
- const sessionFolder = `.workflow/.csv-wave/${sessionId}`
258
-
259
- Bash(`mkdir -p ${sessionFolder}/{explorations,solutions,audits,queue,builds,interactive,wisdom}`)
260
-
261
- Write(`${sessionFolder}/discoveries.ndjson`, `# Discovery Board - ${sessionId}\n# Format: NDJSON\n`)
262
-
263
- // Initialize wisdom files
264
- Write(`${sessionFolder}/wisdom/learnings.md`, `# Learnings\n\nAccumulated during ${sessionId}\n`)
265
- Write(`${sessionFolder}/wisdom/decisions.md`, `# Decisions\n\n`)
266
- Write(`${sessionFolder}/wisdom/conventions.md`, `# Conventions\n\n`)
267
- Write(`${sessionFolder}/wisdom/issues.md`, `# Issues\n\n`)
268
-
269
- // Store session metadata
270
- Write(`${sessionFolder}/session.json`, JSON.stringify({
271
- session_id: sessionId,
272
- pipeline_mode: pipelineMode,
273
- issue_ids: issueIds,
274
- execution_method: executionMethod,
275
- fix_cycles: 0,
276
- max_fix_cycles: 2,
277
- created_at: getUtc8ISOString()
278
- }, null, 2))
279
- ```
280
-
281
- ---
282
-
283
- ### Phase 1: Requirement -> CSV + Classification
284
-
285
- **Objective**: Parse issue IDs, determine pipeline mode, generate tasks.csv with wave and exec_mode assignments.
286
-
287
- **Decomposition Rules**:
288
-
289
- | Pipeline | Tasks Generated |
290
- |----------|----------------|
291
- | quick | EXPLORE-001, SOLVE-001, MARSHAL-001, BUILD-001 (4 tasks, waves 1-4) |
292
- | full | EXPLORE-001, SOLVE-001, AUDIT-001, MARSHAL-001, BUILD-001 (5 tasks, waves 1-5) |
293
- | batch | EXPLORE-001..N, SOLVE-001..N, AUDIT-001, MARSHAL-001, BUILD-001..M (N+N+1+1+M tasks) |
294
-
295
- **Classification Rules**:
296
-
297
- | Task Prefix | Role | exec_mode | Rationale |
298
- |-------------|------|-----------|-----------|
299
- | EXPLORE-* | explorer | csv-wave | One-shot codebase analysis |
300
- | SOLVE-* | planner | csv-wave | One-shot solution design via CLI |
301
- | SOLVE-fix-* | planner | csv-wave | One-shot revision addressing feedback |
302
- | AUDIT-* | reviewer | interactive | Multi-round review with verdict routing |
303
- | MARSHAL-* | integrator | csv-wave | One-shot queue formation |
304
- | BUILD-* | implementer | csv-wave | One-shot implementation via CLI |
305
-
306
- **Wave Computation**: Kahn's BFS topological sort with depth tracking (csv-wave tasks only).
307
-
308
- **User Validation**: Display task breakdown with wave + exec_mode assignment (skip if AUTO_YES).
309
-
310
- **Task Generation by Pipeline Mode**:
311
-
312
- Quick pipeline:
313
- ```csv
314
- id,title,description,role,issue_ids,exec_mode,execution_method,deps,context_from,wave,status,findings,artifact_path,error
315
- "EXPLORE-001","Context analysis","Analyze issue context and map codebase impact","explorer","<issue-ids>","csv-wave","","","","1","pending","","",""
316
- "SOLVE-001","Solution design","Design solution and decompose into implementation tasks","planner","<issue-ids>","csv-wave","","EXPLORE-001","EXPLORE-001","2","pending","","",""
317
- "MARSHAL-001","Queue formation","Form execution queue with conflict detection and ordering","integrator","<issue-ids>","csv-wave","","SOLVE-001","SOLVE-001","3","pending","","",""
318
- "BUILD-001","Implementation","Implement solution plan and verify with tests","implementer","<issue-ids>","csv-wave","<exec-method>","MARSHAL-001","EXPLORE-001;SOLVE-001","4","pending","","",""
319
- ```
320
-
321
- Full pipeline (adds AUDIT-001 as interactive between SOLVE and MARSHAL):
322
- ```csv
323
- "AUDIT-001","Technical review","Review solution for feasibility, risk, and completeness","reviewer","<issue-ids>","interactive","","SOLVE-001","SOLVE-001","3","pending","","",""
324
- "MARSHAL-001","Queue formation","...","integrator","<issue-ids>","csv-wave","","AUDIT-001","SOLVE-001","4","pending","","",""
325
- "BUILD-001","Implementation","...","implementer","<issue-ids>","csv-wave","<exec-method>","MARSHAL-001","EXPLORE-001;SOLVE-001","5","pending","","",""
326
- ```
327
-
328
- Batch pipeline (parallel EXPLORE, sequential SOLVE, then AUDIT, MARSHAL, deferred BUILD):
329
- - EXPLORE-001..N with wave=1, no deps
330
- - SOLVE-001..N with wave=2, deps on all EXPLORE-*
331
- - AUDIT-001 with wave=3, deps on all SOLVE-*, interactive
332
- - MARSHAL-001 with wave=4, deps on AUDIT-001
333
- - BUILD-001..M created after MARSHAL completes (deferred)
334
-
335
- **Success Criteria**:
336
- - tasks.csv created with valid schema, wave, and exec_mode assignments
337
- - No circular dependencies
338
- - User approved (or AUTO_YES)
339
-
340
- ---
341
-
342
- ### Phase 2: Wave Execution Engine (Extended)
343
-
344
- **Objective**: Execute tasks wave-by-wave with hybrid mechanism support and cross-wave context propagation.
345
-
346
- ```javascript
347
- const masterCsv = Read(`${sessionFolder}/tasks.csv`)
348
- let tasks = parseCsv(masterCsv)
349
- const maxWave = Math.max(...tasks.map(t => parseInt(t.wave)))
350
- let fixCycles = 0
351
-
352
- for (let wave = 1; wave <= maxWave; wave++) {
353
- console.log(`\nWave ${wave}/${maxWave}`)
354
-
355
- // 1. Separate tasks by exec_mode
356
- const waveTasks = tasks.filter(t => parseInt(t.wave) === wave)
357
- const csvTasks = waveTasks.filter(t => t.exec_mode === 'csv-wave' && t.status === 'pending')
358
- const interactiveTasks = waveTasks.filter(t => t.exec_mode === 'interactive' && t.status === 'pending')
359
-
360
- // 2. Check dependencies - skip if upstream failed
361
- for (const task of waveTasks) {
362
- const depIds = (task.deps || '').split(';').filter(Boolean)
363
- const depStatuses = depIds.map(id => tasks.find(t => t.id === id)?.status)
364
- if (depStatuses.some(s => s === 'failed' || s === 'skipped')) {
365
- task.status = 'skipped'
366
- task.error = `Dependency failed: ${depIds.filter((id, i) =>
367
- ['failed','skipped'].includes(depStatuses[i])).join(', ')}`
368
- }
369
- }
370
-
371
- // 3. Execute csv-wave tasks
372
- const pendingCsv = csvTasks.filter(t => t.status === 'pending')
373
- if (pendingCsv.length > 0) {
374
- // Build prev_context for each task
375
- for (const task of pendingCsv) {
376
- const contextIds = (task.context_from || '').split(';').filter(Boolean)
377
- const prevFindings = contextIds.map(id => {
378
- const src = tasks.find(t => t.id === id)
379
- if (!src?.findings) return ''
380
- return `## [${src.id}] ${src.title}\n${src.findings}`
381
- }).filter(Boolean).join('\n\n')
382
- task.prev_context = prevFindings
383
- }
384
-
385
- // Write wave CSV
386
- Write(`${sessionFolder}/wave-${wave}.csv`, toCsv(pendingCsv))
387
-
388
- // Execute
389
- spawn_agents_on_csv({
390
- csv_path: `${sessionFolder}/wave-${wave}.csv`,
391
- id_column: "id",
392
- instruction: Read(".codex/skills/team-issue/instructions/agent-instruction.md"),
393
- max_concurrency: maxConcurrency,
394
- max_runtime_seconds: 1200,
395
- output_csv_path: `${sessionFolder}/wave-${wave}-results.csv`,
396
- output_schema: {
397
- type: "object",
398
- properties: {
399
- id: { type: "string" },
400
- status: { type: "string", enum: ["completed", "failed"] },
401
- findings: { type: "string" },
402
- artifact_path: { type: "string" },
403
- error: { type: "string" }
404
- }
405
- }
406
- })
407
-
408
- // Merge results
409
- const results = parseCsv(Read(`${sessionFolder}/wave-${wave}-results.csv`))
410
- for (const r of results) {
411
- const t = tasks.find(t => t.id === r.id)
412
- if (t) Object.assign(t, r)
413
- }
414
-
415
- // Cleanup temp files
416
- Bash(`rm -f ${sessionFolder}/wave-${wave}.csv ${sessionFolder}/wave-${wave}-results.csv`)
417
- }
418
-
419
- // 4. Execute interactive tasks (post-wave)
420
- const pendingInteractive = interactiveTasks.filter(t => t.status === 'pending')
421
- for (const task of pendingInteractive) {
422
- // Read agent definition
423
- const agentDef = Read(`.codex/skills/team-issue/agents/reviewer.md`)
424
-
425
- // Build context from upstream tasks
426
- const contextIds = (task.context_from || '').split(';').filter(Boolean)
427
- const prevContext = contextIds.map(id => {
428
- const src = tasks.find(t => t.id === id)
429
- if (!src?.findings) return ''
430
- return `## [${src.id}] ${src.title}\n${src.findings}\nArtifact: ${src.artifact_path || 'N/A'}`
431
- }).filter(Boolean).join('\n\n')
432
-
433
- const agent = spawn_agent({
434
- message: `## TASK ASSIGNMENT
435
-
436
- ### MANDATORY FIRST STEPS (Agent Execute)
437
- 1. **Read role definition**: .codex/skills/team-issue/agents/reviewer.md (MUST read first)
438
- 2. Read: ${sessionFolder}/discoveries.ndjson (shared discoveries)
439
- 3. Read: .workflow/project-tech.json (if exists)
440
-
441
- ---
442
-
443
- Goal: ${task.description}
444
- Issue IDs: ${task.issue_ids}
445
- Session: ${sessionFolder}
446
- Scope: Review all solutions in ${sessionFolder}/solutions/ for technical feasibility, risk, and completeness
447
-
448
- Deliverables:
449
- - Audit report at ${sessionFolder}/audits/audit-report.json
450
- - Per-issue verdict: approved (>=80), concerns (60-79), rejected (<60)
451
- - Overall verdict
452
-
453
- ### Previous Context
454
- ${prevContext}`
455
- })
456
-
457
- const result = wait({ ids: [agent], timeout_ms: 600000 })
458
-
459
- if (result.timed_out) {
460
- send_input({ id: agent, message: "Please finalize and output current findings immediately." })
461
- const retry = wait({ ids: [agent], timeout_ms: 120000 })
462
- }
463
-
464
- // Store interactive result
465
- Write(`${sessionFolder}/interactive/${task.id}-result.json`, JSON.stringify({
466
- task_id: task.id,
467
- status: "completed",
468
- findings: "Review completed",
469
- timestamp: getUtc8ISOString()
470
- }))
471
-
472
- close_agent({ id: agent })
473
-
474
- // Parse review verdict from audit report
475
- let verdict = 'approved'
476
- try {
477
- const auditReport = JSON.parse(Read(`${sessionFolder}/audits/audit-report.json`))
478
- verdict = auditReport.overall_verdict || 'approved'
479
- } catch (e) { /* default to approved */ }
480
-
481
- task.status = 'completed'
482
- task.findings = `Review verdict: ${verdict}`
483
-
484
- // Handle review-fix cycle
485
- if (verdict === 'rejected' && fixCycles < 2) {
486
- fixCycles++
487
- // Create SOLVE-fix and AUDIT re-review tasks
488
- const fixTask = {
489
- id: `SOLVE-fix-${String(fixCycles).padStart(3, '0')}`,
490
- title: `Revise solution (fix cycle ${fixCycles})`,
491
- description: `Revise solution addressing reviewer feedback. Read audit report for rejection reasons.`,
492
- role: 'planner',
493
- issue_ids: task.issue_ids,
494
- exec_mode: 'csv-wave',
495
- execution_method: '',
496
- deps: task.id,
497
- context_from: task.id,
498
- wave: String(parseInt(task.wave) + 1),
499
- status: 'pending',
500
- findings: '', artifact_path: '', error: ''
501
- }
502
- const reReviewTask = {
503
- id: `AUDIT-${String(fixCycles + 1).padStart(3, '0')}`,
504
- title: `Re-review revised solution (cycle ${fixCycles})`,
505
- description: `Re-review revised solution focusing on previously rejected dimensions.`,
506
- role: 'reviewer',
507
- issue_ids: task.issue_ids,
508
- exec_mode: 'interactive',
509
- execution_method: '',
510
- deps: fixTask.id,
511
- context_from: fixTask.id,
512
- wave: String(parseInt(task.wave) + 2),
513
- status: 'pending',
514
- findings: '', artifact_path: '', error: ''
515
- }
516
- tasks.push(fixTask, reReviewTask)
517
- // Adjust MARSHAL and BUILD waves
518
- for (const t of tasks) {
519
- if (t.id.startsWith('MARSHAL') || t.id.startsWith('BUILD')) {
520
- t.wave = String(parseInt(reReviewTask.wave) + (t.id.startsWith('MARSHAL') ? 1 : 2))
521
- if (t.id.startsWith('MARSHAL')) t.deps = reReviewTask.id
522
- }
523
- }
524
- } else if (verdict === 'rejected' && fixCycles >= 2) {
525
- // Force proceed with warning
526
- console.log(`WARNING: Fix cycle limit (${fixCycles}) reached. Forcing proceed to MARSHAL.`)
527
- }
528
- }
529
-
530
- // 5. Merge all results into master CSV
531
- Write(`${sessionFolder}/tasks.csv`, toCsv(tasks))
532
-
533
- // 6. Handle deferred BUILD task creation (batch mode after MARSHAL)
534
- const completedMarshal = tasks.find(t => t.id === 'MARSHAL-001' && t.status === 'completed')
535
- if (completedMarshal && pipelineMode === 'batch') {
536
- try {
537
- const queue = JSON.parse(Read(`${sessionFolder}/queue/execution-queue.json`))
538
- const buildCount = queue.parallel_groups?.length || 1
539
- for (let b = 1; b <= Math.min(buildCount, 3); b++) {
540
- const buildIssues = queue.parallel_groups[b-1]?.issues || issueIds
541
- tasks.push({
542
- id: `BUILD-${String(b).padStart(3, '0')}`,
543
- title: `Implementation group ${b}`,
544
- description: `Implement solutions for issues in parallel group ${b}`,
545
- role: 'implementer',
546
- issue_ids: buildIssues.join(';'),
547
- exec_mode: 'csv-wave',
548
- execution_method: executionMethod,
549
- deps: 'MARSHAL-001',
550
- context_from: 'EXPLORE-001;SOLVE-001',
551
- wave: String(parseInt(completedMarshal.wave) + 1),
552
- status: 'pending',
553
- findings: '', artifact_path: '', error: ''
554
- })
555
- }
556
- Write(`${sessionFolder}/tasks.csv`, toCsv(tasks))
557
- } catch (e) { /* single BUILD fallback */ }
558
- }
559
- }
560
- ```
561
-
562
- **Success Criteria**:
563
- - All waves executed in order
564
- - Both csv-wave and interactive tasks handled per wave
565
- - Each wave's results merged into master CSV before next wave starts
566
- - Dependent tasks skipped when predecessor failed
567
- - discoveries.ndjson accumulated across all waves and mechanisms
568
- - Review-fix cycles handled (max 2)
569
- - Deferred BUILD tasks created after MARSHAL (batch mode)
570
-
571
- ---
572
-
573
- ### Phase 3: Post-Wave Interactive
574
-
575
- **Objective**: Handle any remaining interactive tasks after all waves complete. In most cases, the review gate is handled inline during Phase 2 wave execution.
576
-
577
- If any interactive tasks remain unprocessed (e.g., from dynamically added fix cycles), execute them using the same spawn_agent protocol as Phase 2.
578
-
579
- **Success Criteria**:
580
- - All interactive tasks completed or skipped
581
- - Fix cycle limit respected
582
-
583
- ---
584
-
585
- ### Phase 4: Results Aggregation
586
-
587
- **Objective**: Generate final results and human-readable report.
588
-
589
- ```javascript
590
- const tasks = parseCsv(Read(`${sessionFolder}/tasks.csv`))
591
- const completed = tasks.filter(t => t.status === 'completed')
592
- const failed = tasks.filter(t => t.status === 'failed')
593
- const skipped = tasks.filter(t => t.status === 'skipped')
594
-
595
- // Export results.csv
596
- Bash(`cp ${sessionFolder}/tasks.csv ${sessionFolder}/results.csv`)
597
-
598
- // Generate context.md
599
- let contextMd = `# Issue Resolution Report\n\n`
600
- contextMd += `**Session**: ${sessionId}\n`
601
- contextMd += `**Pipeline**: ${pipelineMode}\n`
602
- contextMd += `**Issues**: ${issueIds.join(', ')}\n`
603
- contextMd += `**Fix Cycles**: ${fixCycles}/${2}\n\n`
604
-
605
- contextMd += `## Summary\n\n`
606
- contextMd += `| Status | Count |\n|--------|-------|\n`
607
- contextMd += `| Completed | ${completed.length} |\n`
608
- contextMd += `| Failed | ${failed.length} |\n`
609
- contextMd += `| Skipped | ${skipped.length} |\n\n`
610
-
611
- contextMd += `## Task Details\n\n`
612
- for (const t of tasks) {
613
- const icon = t.status === 'completed' ? '[OK]' : t.status === 'failed' ? '[FAIL]' : '[SKIP]'
614
- contextMd += `${icon} **${t.id}**: ${t.title} (${t.role})\n`
615
- if (t.findings) contextMd += ` Findings: ${t.findings.substring(0, 200)}\n`
616
- if (t.artifact_path) contextMd += ` Artifact: ${t.artifact_path}\n`
617
- if (t.error) contextMd += ` Error: ${t.error}\n`
618
- contextMd += `\n`
619
- }
620
-
621
- contextMd += `## Deliverables\n\n`
622
- contextMd += `| Artifact | Path |\n|----------|------|\n`
623
- contextMd += `| Context Reports | ${sessionFolder}/explorations/ |\n`
624
- contextMd += `| Solution Plans | ${sessionFolder}/solutions/ |\n`
625
- contextMd += `| Audit Report | ${sessionFolder}/audits/audit-report.json |\n`
626
- contextMd += `| Execution Queue | ${sessionFolder}/queue/execution-queue.json |\n`
627
- contextMd += `| Build Results | ${sessionFolder}/builds/ |\n`
628
-
629
- Write(`${sessionFolder}/context.md`, contextMd)
630
-
631
- // Display summary
632
- console.log(`
633
- Issue Resolution Complete
634
- Pipeline: ${pipelineMode}
635
- Completed: ${completed.length} | Failed: ${failed.length} | Skipped: ${skipped.length}
636
- Fix Cycles Used: ${fixCycles}/2
637
- Output: ${sessionFolder}
638
- `)
639
- ```
640
-
641
- **Success Criteria**:
642
- - results.csv exported (all tasks, both modes)
643
- - context.md generated
644
- - Summary displayed to user
645
-
646
- ---
647
-
648
- ## Shared Discovery Board Protocol
649
-
650
- Both csv-wave and interactive agents share the same discoveries.ndjson file:
651
-
652
- ```jsonl
653
- {"ts":"2026-03-08T10:00:00Z","worker":"EXPLORE-001","type":"file_found","data":{"path":"src/auth/handler.ts","relevance":"high","purpose":"Main auth handler"}}
654
- {"ts":"2026-03-08T10:01:00Z","worker":"EXPLORE-001","type":"pattern_found","data":{"pattern":"middleware-chain","location":"src/middleware/","description":"Express middleware chain pattern"}}
655
- {"ts":"2026-03-08T10:05:00Z","worker":"SOLVE-001","type":"solution_approach","data":{"issue_id":"ISS-20260308-120000","approach":"refactor","estimated_files":5}}
656
- {"ts":"2026-03-08T10:10:00Z","worker":"BUILD-001","type":"impl_result","data":{"issue_id":"ISS-20260308-120000","files_changed":3,"tests_pass":true}}
657
- ```
658
-
659
- **Discovery Types**:
660
-
661
- | Type | Dedup Key | Data Schema | Description |
662
- |------|-----------|-------------|-------------|
663
- | `file_found` | `path` | `{path, relevance, purpose}` | Relevant file discovered |
664
- | `pattern_found` | `pattern+location` | `{pattern, location, description}` | Code pattern identified |
665
- | `dependency_found` | `from+to` | `{from, to, type}` | Dependency relationship |
666
- | `solution_approach` | `issue_id` | `{issue_id, approach, estimated_files}` | Solution strategy |
667
- | `conflict_found` | `files` | `{issues, files, resolution}` | File conflict between issues |
668
- | `impl_result` | `issue_id` | `{issue_id, files_changed, tests_pass}` | Implementation outcome |
669
-
670
- ---
671
-
672
- ## Error Handling
673
-
674
- | Error | Resolution |
675
- |-------|------------|
676
- | Circular dependency | Detect in wave computation, abort with error message |
677
- | CSV agent timeout | Mark as failed in results, continue with wave |
678
- | CSV agent failed | Mark as failed, skip dependent tasks in later waves |
679
- | Interactive agent timeout | Urge convergence via send_input, then close if still timed out |
680
- | Interactive agent failed | Mark as failed, skip dependents |
681
- | All agents in wave failed | Log error, offer retry or abort |
682
- | CSV parse error | Validate CSV format before execution, show line number |
683
- | discoveries.ndjson corrupt | Ignore malformed lines, continue with valid entries |
684
- | Review rejection exceeds 2 rounds | Force convergence to MARSHAL with warning |
685
- | No issues found for given IDs | Report error, ask user for valid IDs |
686
- | Deferred BUILD count unknown | Read execution-queue.json after MARSHAL completes |
687
- | Continue mode: no session found | List available sessions, prompt user to select |
688
-
689
- ---
690
-
691
- ## Core Rules
692
-
693
- 1. **Start Immediately**: First action is session initialization, then Phase 1
694
- 2. **Wave Order is Sacred**: Never execute wave N before wave N-1 completes and results are merged
695
- 3. **CSV is Source of Truth**: Master tasks.csv holds all state (both csv-wave and interactive)
696
- 4. **CSV First**: Default to csv-wave for tasks; only use interactive when interaction pattern requires it
697
- 5. **Context Propagation**: prev_context built from master CSV, not from memory
698
- 6. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson -- both mechanisms share it
699
- 7. **Skip on Failure**: If a dependency failed, skip the dependent task (regardless of mechanism)
700
- 8. **Lifecycle Balance**: Every spawn_agent MUST have a matching close_agent
701
- 9. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
702
- 10. **DO NOT STOP**: Continuous execution until all waves complete or all remaining tasks are skipped
1
+ ---
2
+ name: team-issue
3
+ description: Hybrid team skill for issue resolution. CSV wave primary for exploration, planning, integration, and implementation. Interactive agents for review gates with fix cycles. Supports Quick, Full, and Batch pipelines.
4
+ argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] [--mode=quick|full|batch] \"issue-ids or --all-pending\""
5
+ allowed-tools: spawn_agents_on_csv, spawn_agent, wait, send_input, close_agent, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ ## Auto Mode
9
+
10
+ When `--yes` or `-y`: Auto-confirm task decomposition, skip interactive validation, use defaults.
11
+
12
+ # Team Issue Resolution
13
+
14
+ ## Usage
15
+
16
+ ```bash
17
+ $team-issue "ISS-20260308-120000 ISS-20260308-120001"
18
+ $team-issue -c 4 "ISS-20260308-120000 --mode=full"
19
+ $team-issue -y "--all-pending"
20
+ $team-issue --continue "issue-auth-fix-20260308"
21
+ ```
22
+
23
+ **Flags**:
24
+ - `-y, --yes`: Skip all confirmations (auto mode)
25
+ - `-c, --concurrency N`: Max concurrent agents within each wave (default: 3)
26
+ - `--continue`: Resume existing session
27
+ - `--mode=quick|full|batch`: Force pipeline mode (default: auto-detect)
28
+
29
+ **Output Directory**: `.workflow/.csv-wave/{session-id}/`
30
+ **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report)
31
+
32
+ ---
33
+
34
+ ## Overview
35
+
36
+ Orchestrate issue resolution pipeline: explore context, plan solution, review (optional), marshal queue, implement. Supports Quick, Full, and Batch pipelines with review-fix cycle.
37
+
38
+ **Execution Model**: Hybrid -- CSV wave pipeline (primary) + individual agent spawn (secondary)
39
+
40
+ ```
41
+ +---------------------------------------------------------------------------+
42
+ | TEAM ISSUE RESOLUTION WORKFLOW |
43
+ +---------------------------------------------------------------------------+
44
+ | |
45
+ | Phase 1: Requirement Parsing + Pipeline Selection |
46
+ | +-- Parse issue IDs (GH-\d+, ISS-\d{8}-\d{6}, --all-pending) |
47
+ | +-- Auto-detect pipeline mode (quick/full/batch) |
48
+ | +-- Determine execution method (codex/gemini/auto) |
49
+ | +-- Generate tasks.csv with wave + exec_mode columns |
50
+ | +-- User validates task breakdown (skip if -y) |
51
+ | |
52
+ | Phase 2: Wave Execution Engine (Extended) |
53
+ | +-- For each wave (1..N): |
54
+ | | +-- Execute pre-wave interactive tasks (if any) |
55
+ | | +-- Build wave CSV (filter csv-wave tasks for this wave) |
56
+ | | +-- Inject previous findings into prev_context column |
57
+ | | +-- spawn_agents_on_csv(wave CSV) |
58
+ | | +-- Execute post-wave interactive tasks (if any) |
59
+ | | +-- Merge all results into master tasks.csv |
60
+ | | +-- Check: any failed? -> skip dependents |
61
+ | +-- discoveries.ndjson shared across all modes (append-only) |
62
+ | |
63
+ | Phase 3: Post-Wave Interactive (Review Gate) |
64
+ | +-- Reviewer agent: multi-dimensional review with verdict |
65
+ | +-- Fix cycle: rejected -> revise solution -> re-review (max 2) |
66
+ | +-- Final aggregation / report |
67
+ | |
68
+ | Phase 4: Results Aggregation |
69
+ | +-- Export final results.csv |
70
+ | +-- Generate context.md with all findings |
71
+ | +-- Display summary: completed/failed/skipped per wave |
72
+ | +-- Offer: view results | retry failed | done |
73
+ | |
74
+ +---------------------------------------------------------------------------+
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Task Classification Rules
80
+
81
+ Each task is classified by `exec_mode`:
82
+
83
+ | exec_mode | Mechanism | Criteria |
84
+ |-----------|-----------|----------|
85
+ | `csv-wave` | `spawn_agents_on_csv` | One-shot, structured I/O, no multi-round interaction |
86
+ | `interactive` | `spawn_agent`/`wait`/`send_input`/`close_agent` | Multi-round, clarification, review gates |
87
+
88
+ **Classification Decision**:
89
+
90
+ | Task Property | Classification |
91
+ |---------------|---------------|
92
+ | Codebase exploration (EXPLORE-*) | `csv-wave` |
93
+ | Solution planning (SOLVE-*) | `csv-wave` |
94
+ | Queue formation / integration (MARSHAL-*) | `csv-wave` |
95
+ | Code implementation (BUILD-*) | `csv-wave` |
96
+ | Technical review with verdict (AUDIT-*) | `interactive` |
97
+ | Solution revision after rejection (SOLVE-fix-*) | `csv-wave` |
98
+
99
+ ---
100
+
101
+ ## CSV Schema
102
+
103
+ ### tasks.csv (Master State)
104
+
105
+ ```csv
106
+ id,title,description,role,issue_ids,exec_mode,execution_method,deps,context_from,wave,status,findings,artifact_path,error
107
+ "EXPLORE-001","Context analysis","Analyze issue context and map codebase impact for ISS-20260308-120000","explorer","ISS-20260308-120000","csv-wave","","","","1","pending","","","",""
108
+ "SOLVE-001","Solution design","Design solution and decompose into implementation tasks","planner","ISS-20260308-120000","csv-wave","","EXPLORE-001","EXPLORE-001","2","pending","","","",""
109
+ "AUDIT-001","Technical review","Review solution for feasibility, risk, and completeness","reviewer","ISS-20260308-120000","interactive","","SOLVE-001","SOLVE-001","3","pending","","","",""
110
+ "MARSHAL-001","Queue formation","Form execution queue with conflict detection","integrator","ISS-20260308-120000","csv-wave","","AUDIT-001","SOLVE-001","4","pending","","","",""
111
+ "BUILD-001","Implementation","Implement solution plan and verify with tests","implementer","ISS-20260308-120000","csv-wave","gemini","MARSHAL-001","EXPLORE-001;SOLVE-001","5","pending","","","",""
112
+ ```
113
+
114
+ **Columns**:
115
+
116
+ | Column | Phase | Description |
117
+ |--------|-------|-------------|
118
+ | `id` | Input | Unique task identifier (EXPLORE-NNN, SOLVE-NNN, AUDIT-NNN, MARSHAL-NNN, BUILD-NNN) |
119
+ | `title` | Input | Short task title |
120
+ | `description` | Input | Detailed task description |
121
+ | `role` | Input | Worker role: explorer, planner, reviewer, integrator, implementer |
122
+ | `issue_ids` | Input | Semicolon-separated issue IDs this task covers |
123
+ | `exec_mode` | Input | `csv-wave` or `interactive` |
124
+ | `execution_method` | Input | codex, gemini, qwen, or empty (for non-BUILD tasks) |
125
+ | `deps` | Input | Semicolon-separated dependency task IDs |
126
+ | `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
127
+ | `wave` | Computed | Wave number (computed by topological sort, 1-based) |
128
+ | `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
129
+ | `findings` | Output | Key discoveries or implementation notes (max 500 chars) |
130
+ | `artifact_path` | Output | Path to generated artifact (context report, solution, queue, etc.) |
131
+ | `error` | Output | Error message if failed (empty if success) |
132
+
133
+ ### Per-Wave CSV (Temporary)
134
+
135
+ Each wave generates a temporary `wave-{N}.csv` with extra `prev_context` column (csv-wave tasks only).
136
+
137
+ ---
138
+
139
+ ## Agent Registry (Interactive Agents)
140
+
141
+ | Agent | Role File | Pattern | Responsibility | Position |
142
+ |-------|-----------|---------|----------------|----------|
143
+ | reviewer | agents/reviewer.md | 2.3 (structured review) | Multi-dimensional solution review with verdict | post-wave (after SOLVE wave) |
144
+
145
+ > **COMPACT PROTECTION**: Agent files are execution documents. When context compression occurs, **you MUST immediately `Read` the corresponding agent.md** to reload.
146
+
147
+ ---
148
+
149
+ ## Output Artifacts
150
+
151
+ | File | Purpose | Lifecycle |
152
+ |------|---------|-----------|
153
+ | `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
154
+ | `wave-{N}.csv` | Per-wave input (temporary, csv-wave tasks only) | Created before wave, deleted after |
155
+ | `results.csv` | Final export of all task results | Created in Phase 4 |
156
+ | `discoveries.ndjson` | Shared exploration board (all agents, both modes) | Append-only, carries across waves |
157
+ | `context.md` | Human-readable execution report | Created in Phase 4 |
158
+ | `explorations/context-{issueId}.json` | Explorer context reports | Created by explorer agents |
159
+ | `solutions/solution-{issueId}.json` | Planner solution plans | Created by planner agents |
160
+ | `audits/audit-report.json` | Reviewer audit report | Created by reviewer agent |
161
+ | `queue/execution-queue.json` | Integrator execution queue | Created by integrator agent |
162
+ | `builds/build-{issueId}.json` | Implementer build results | Created by implementer agents |
163
+ | `interactive/{id}-result.json` | Results from interactive tasks | Created per interactive task |
164
+
165
+ ---
166
+
167
+ ## Session Structure
168
+
169
+ ```
170
+ .workflow/.csv-wave/{session-id}/
171
+ +-- tasks.csv # Master state (all tasks, both modes)
172
+ +-- results.csv # Final results export
173
+ +-- discoveries.ndjson # Shared discovery board (all agents)
174
+ +-- context.md # Human-readable report
175
+ +-- wave-{N}.csv # Temporary per-wave input (csv-wave only)
176
+ +-- explorations/ # Explorer output
177
+ | +-- context-{issueId}.json
178
+ +-- solutions/ # Planner output
179
+ | +-- solution-{issueId}.json
180
+ +-- audits/ # Reviewer output
181
+ | +-- audit-report.json
182
+ +-- queue/ # Integrator output
183
+ | +-- execution-queue.json
184
+ +-- builds/ # Implementer output
185
+ | +-- build-{issueId}.json
186
+ +-- interactive/ # Interactive task artifacts
187
+ | +-- {id}-result.json
188
+ +-- wisdom/ # Cross-task knowledge
189
+ +-- learnings.md
190
+ +-- decisions.md
191
+ +-- conventions.md
192
+ +-- issues.md
193
+ ```
194
+
195
+ ---
196
+
197
+ ## Implementation
198
+
199
+ ### Session Initialization
200
+
201
+ ```javascript
202
+ const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
203
+
204
+ const AUTO_YES = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
205
+ const continueMode = $ARGUMENTS.includes('--continue')
206
+ const concurrencyMatch = $ARGUMENTS.match(/(?:--concurrency|-c)\s+(\d+)/)
207
+ const maxConcurrency = concurrencyMatch ? parseInt(concurrencyMatch[1]) : 3
208
+
209
+ const requirement = $ARGUMENTS
210
+ .replace(/--yes|-y|--continue|--concurrency\s+\d+|-c\s+\d+/g, '')
211
+ .trim()
212
+
213
+ // Parse issue IDs
214
+ const issueIdPattern = /(?:GH-\d+|ISS-\d{8}-\d{6})/g
215
+ let issueIds = requirement.match(issueIdPattern) || []
216
+
217
+ // Parse mode override
218
+ const modeMatch = requirement.match(/--mode=(\w+)/)
219
+ let pipelineMode = modeMatch ? modeMatch[1] : null
220
+
221
+ // Handle --all-pending
222
+ if (requirement.includes('--all-pending')) {
223
+ const result = Bash("ccw issue list --status registered,pending --json")
224
+ issueIds = JSON.parse(result).map(i => i.id)
225
+ }
226
+
227
+ // If no issue IDs, ask user
228
+ if (issueIds.length === 0) {
229
+ const answer = AskUserQuestion("No issue IDs found. Please provide issue IDs (e.g., ISS-20260308-120000):")
230
+ issueIds = answer.match(issueIdPattern) || []
231
+ if (issueIds.length === 0) return // abort
232
+ }
233
+
234
+ // Auto-detect pipeline mode
235
+ if (!pipelineMode) {
236
+ // Load issue priorities
237
+ const priorities = []
238
+ for (const id of issueIds) {
239
+ const info = JSON.parse(Bash(`ccw issue status ${id} --json`))
240
+ priorities.push(info.priority || 0)
241
+ }
242
+ const hasHighPriority = priorities.some(p => p >= 4)
243
+
244
+ if (issueIds.length <= 2 && !hasHighPriority) pipelineMode = 'quick'
245
+ else if (issueIds.length <= 4) pipelineMode = 'full'
246
+ else pipelineMode = 'batch'
247
+ }
248
+
249
+ // Execution method selection
250
+ let executionMethod = 'gemini' // default
251
+ const execMatch = requirement.match(/--exec=(\w+)/)
252
+ if (execMatch) executionMethod = execMatch[1]
253
+
254
+ const slug = issueIds[0].toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 30)
255
+ const dateStr = getUtc8ISOString().substring(0, 10).replace(/-/g, '')
256
+ const sessionId = `issue-${slug}-${dateStr}`
257
+ const sessionFolder = `.workflow/.csv-wave/${sessionId}`
258
+
259
+ Bash(`mkdir -p ${sessionFolder}/{explorations,solutions,audits,queue,builds,interactive,wisdom}`)
260
+
261
+ Write(`${sessionFolder}/discoveries.ndjson`, `# Discovery Board - ${sessionId}\n# Format: NDJSON\n`)
262
+
263
+ // Initialize wisdom files
264
+ Write(`${sessionFolder}/wisdom/learnings.md`, `# Learnings\n\nAccumulated during ${sessionId}\n`)
265
+ Write(`${sessionFolder}/wisdom/decisions.md`, `# Decisions\n\n`)
266
+ Write(`${sessionFolder}/wisdom/conventions.md`, `# Conventions\n\n`)
267
+ Write(`${sessionFolder}/wisdom/issues.md`, `# Issues\n\n`)
268
+
269
+ // Store session metadata
270
+ Write(`${sessionFolder}/session.json`, JSON.stringify({
271
+ session_id: sessionId,
272
+ pipeline_mode: pipelineMode,
273
+ issue_ids: issueIds,
274
+ execution_method: executionMethod,
275
+ fix_cycles: 0,
276
+ max_fix_cycles: 2,
277
+ created_at: getUtc8ISOString()
278
+ }, null, 2))
279
+ ```
280
+
281
+ ---
282
+
283
+ ### Phase 1: Requirement -> CSV + Classification
284
+
285
+ **Objective**: Parse issue IDs, determine pipeline mode, generate tasks.csv with wave and exec_mode assignments.
286
+
287
+ **Decomposition Rules**:
288
+
289
+ | Pipeline | Tasks Generated |
290
+ |----------|----------------|
291
+ | quick | EXPLORE-001, SOLVE-001, MARSHAL-001, BUILD-001 (4 tasks, waves 1-4) |
292
+ | full | EXPLORE-001, SOLVE-001, AUDIT-001, MARSHAL-001, BUILD-001 (5 tasks, waves 1-5) |
293
+ | batch | EXPLORE-001..N, SOLVE-001..N, AUDIT-001, MARSHAL-001, BUILD-001..M (N+N+1+1+M tasks) |
294
+
295
+ **Classification Rules**:
296
+
297
+ | Task Prefix | Role | exec_mode | Rationale |
298
+ |-------------|------|-----------|-----------|
299
+ | EXPLORE-* | explorer | csv-wave | One-shot codebase analysis |
300
+ | SOLVE-* | planner | csv-wave | One-shot solution design via CLI |
301
+ | SOLVE-fix-* | planner | csv-wave | One-shot revision addressing feedback |
302
+ | AUDIT-* | reviewer | interactive | Multi-round review with verdict routing |
303
+ | MARSHAL-* | integrator | csv-wave | One-shot queue formation |
304
+ | BUILD-* | implementer | csv-wave | One-shot implementation via CLI |
305
+
306
+ **Wave Computation**: Kahn's BFS topological sort with depth tracking (csv-wave tasks only).
307
+
308
+ **User Validation**: Display task breakdown with wave + exec_mode assignment (skip if AUTO_YES).
309
+
310
+ **Task Generation by Pipeline Mode**:
311
+
312
+ Quick pipeline:
313
+ ```csv
314
+ id,title,description,role,issue_ids,exec_mode,execution_method,deps,context_from,wave,status,findings,artifact_path,error
315
+ "EXPLORE-001","Context analysis","Analyze issue context and map codebase impact","explorer","<issue-ids>","csv-wave","","","","1","pending","","",""
316
+ "SOLVE-001","Solution design","Design solution and decompose into implementation tasks","planner","<issue-ids>","csv-wave","","EXPLORE-001","EXPLORE-001","2","pending","","",""
317
+ "MARSHAL-001","Queue formation","Form execution queue with conflict detection and ordering","integrator","<issue-ids>","csv-wave","","SOLVE-001","SOLVE-001","3","pending","","",""
318
+ "BUILD-001","Implementation","Implement solution plan and verify with tests","implementer","<issue-ids>","csv-wave","<exec-method>","MARSHAL-001","EXPLORE-001;SOLVE-001","4","pending","","",""
319
+ ```
320
+
321
+ Full pipeline (adds AUDIT-001 as interactive between SOLVE and MARSHAL):
322
+ ```csv
323
+ "AUDIT-001","Technical review","Review solution for feasibility, risk, and completeness","reviewer","<issue-ids>","interactive","","SOLVE-001","SOLVE-001","3","pending","","",""
324
+ "MARSHAL-001","Queue formation","...","integrator","<issue-ids>","csv-wave","","AUDIT-001","SOLVE-001","4","pending","","",""
325
+ "BUILD-001","Implementation","...","implementer","<issue-ids>","csv-wave","<exec-method>","MARSHAL-001","EXPLORE-001;SOLVE-001","5","pending","","",""
326
+ ```
327
+
328
+ Batch pipeline (parallel EXPLORE, sequential SOLVE, then AUDIT, MARSHAL, deferred BUILD):
329
+ - EXPLORE-001..N with wave=1, no deps
330
+ - SOLVE-001..N with wave=2, deps on all EXPLORE-*
331
+ - AUDIT-001 with wave=3, deps on all SOLVE-*, interactive
332
+ - MARSHAL-001 with wave=4, deps on AUDIT-001
333
+ - BUILD-001..M created after MARSHAL completes (deferred)
334
+
335
+ **Success Criteria**:
336
+ - tasks.csv created with valid schema, wave, and exec_mode assignments
337
+ - No circular dependencies
338
+ - User approved (or AUTO_YES)
339
+
340
+ ---
341
+
342
+ ### Phase 2: Wave Execution Engine (Extended)
343
+
344
+ **Objective**: Execute tasks wave-by-wave with hybrid mechanism support and cross-wave context propagation.
345
+
346
+ ```javascript
347
+ const masterCsv = Read(`${sessionFolder}/tasks.csv`)
348
+ let tasks = parseCsv(masterCsv)
349
+ const maxWave = Math.max(...tasks.map(t => parseInt(t.wave)))
350
+ let fixCycles = 0
351
+
352
+ for (let wave = 1; wave <= maxWave; wave++) {
353
+ console.log(`\nWave ${wave}/${maxWave}`)
354
+
355
+ // 1. Separate tasks by exec_mode
356
+ const waveTasks = tasks.filter(t => parseInt(t.wave) === wave)
357
+ const csvTasks = waveTasks.filter(t => t.exec_mode === 'csv-wave' && t.status === 'pending')
358
+ const interactiveTasks = waveTasks.filter(t => t.exec_mode === 'interactive' && t.status === 'pending')
359
+
360
+ // 2. Check dependencies - skip if upstream failed
361
+ for (const task of waveTasks) {
362
+ const depIds = (task.deps || '').split(';').filter(Boolean)
363
+ const depStatuses = depIds.map(id => tasks.find(t => t.id === id)?.status)
364
+ if (depStatuses.some(s => s === 'failed' || s === 'skipped')) {
365
+ task.status = 'skipped'
366
+ task.error = `Dependency failed: ${depIds.filter((id, i) =>
367
+ ['failed','skipped'].includes(depStatuses[i])).join(', ')}`
368
+ }
369
+ }
370
+
371
+ // 3. Execute csv-wave tasks
372
+ const pendingCsv = csvTasks.filter(t => t.status === 'pending')
373
+ if (pendingCsv.length > 0) {
374
+ // Build prev_context for each task
375
+ for (const task of pendingCsv) {
376
+ const contextIds = (task.context_from || '').split(';').filter(Boolean)
377
+ const prevFindings = contextIds.map(id => {
378
+ const src = tasks.find(t => t.id === id)
379
+ if (!src?.findings) return ''
380
+ return `## [${src.id}] ${src.title}\n${src.findings}`
381
+ }).filter(Boolean).join('\n\n')
382
+ task.prev_context = prevFindings
383
+ }
384
+
385
+ // Write wave CSV
386
+ Write(`${sessionFolder}/wave-${wave}.csv`, toCsv(pendingCsv))
387
+
388
+ // Execute
389
+ spawn_agents_on_csv({
390
+ csv_path: `${sessionFolder}/wave-${wave}.csv`,
391
+ id_column: "id",
392
+ instruction: Read("~ or <project>/.codex/skills/team-issue/instructions/agent-instruction.md"),
393
+ max_concurrency: maxConcurrency,
394
+ max_runtime_seconds: 1200,
395
+ output_csv_path: `${sessionFolder}/wave-${wave}-results.csv`,
396
+ output_schema: {
397
+ type: "object",
398
+ properties: {
399
+ id: { type: "string" },
400
+ status: { type: "string", enum: ["completed", "failed"] },
401
+ findings: { type: "string" },
402
+ artifact_path: { type: "string" },
403
+ error: { type: "string" }
404
+ }
405
+ }
406
+ })
407
+
408
+ // Merge results
409
+ const results = parseCsv(Read(`${sessionFolder}/wave-${wave}-results.csv`))
410
+ for (const r of results) {
411
+ const t = tasks.find(t => t.id === r.id)
412
+ if (t) Object.assign(t, r)
413
+ }
414
+
415
+ // Cleanup temp files
416
+ Bash(`rm -f ${sessionFolder}/wave-${wave}.csv ${sessionFolder}/wave-${wave}-results.csv`)
417
+ }
418
+
419
+ // 4. Execute interactive tasks (post-wave)
420
+ const pendingInteractive = interactiveTasks.filter(t => t.status === 'pending')
421
+ for (const task of pendingInteractive) {
422
+ // Read agent definition
423
+ const agentDef = Read(`~ or <project>/.codex/skills/team-issue/agents/reviewer.md`)
424
+
425
+ // Build context from upstream tasks
426
+ const contextIds = (task.context_from || '').split(';').filter(Boolean)
427
+ const prevContext = contextIds.map(id => {
428
+ const src = tasks.find(t => t.id === id)
429
+ if (!src?.findings) return ''
430
+ return `## [${src.id}] ${src.title}\n${src.findings}\nArtifact: ${src.artifact_path || 'N/A'}`
431
+ }).filter(Boolean).join('\n\n')
432
+
433
+ const agent = spawn_agent({
434
+ message: `## TASK ASSIGNMENT
435
+
436
+ ### MANDATORY FIRST STEPS (Agent Execute)
437
+ 1. **Read role definition**: ~ or <project>/.codex/skills/team-issue/agents/reviewer.md (MUST read first)
438
+ 2. Read: ${sessionFolder}/discoveries.ndjson (shared discoveries)
439
+ 3. Read: .workflow/project-tech.json (if exists)
440
+
441
+ ---
442
+
443
+ Goal: ${task.description}
444
+ Issue IDs: ${task.issue_ids}
445
+ Session: ${sessionFolder}
446
+ Scope: Review all solutions in ${sessionFolder}/solutions/ for technical feasibility, risk, and completeness
447
+
448
+ Deliverables:
449
+ - Audit report at ${sessionFolder}/audits/audit-report.json
450
+ - Per-issue verdict: approved (>=80), concerns (60-79), rejected (<60)
451
+ - Overall verdict
452
+
453
+ ### Previous Context
454
+ ${prevContext}`
455
+ })
456
+
457
+ const result = wait({ ids: [agent], timeout_ms: 600000 })
458
+
459
+ if (result.timed_out) {
460
+ send_input({ id: agent, message: "Please finalize and output current findings immediately." })
461
+ const retry = wait({ ids: [agent], timeout_ms: 120000 })
462
+ }
463
+
464
+ // Store interactive result
465
+ Write(`${sessionFolder}/interactive/${task.id}-result.json`, JSON.stringify({
466
+ task_id: task.id,
467
+ status: "completed",
468
+ findings: "Review completed",
469
+ timestamp: getUtc8ISOString()
470
+ }))
471
+
472
+ close_agent({ id: agent })
473
+
474
+ // Parse review verdict from audit report
475
+ let verdict = 'approved'
476
+ try {
477
+ const auditReport = JSON.parse(Read(`${sessionFolder}/audits/audit-report.json`))
478
+ verdict = auditReport.overall_verdict || 'approved'
479
+ } catch (e) { /* default to approved */ }
480
+
481
+ task.status = 'completed'
482
+ task.findings = `Review verdict: ${verdict}`
483
+
484
+ // Handle review-fix cycle
485
+ if (verdict === 'rejected' && fixCycles < 2) {
486
+ fixCycles++
487
+ // Create SOLVE-fix and AUDIT re-review tasks
488
+ const fixTask = {
489
+ id: `SOLVE-fix-${String(fixCycles).padStart(3, '0')}`,
490
+ title: `Revise solution (fix cycle ${fixCycles})`,
491
+ description: `Revise solution addressing reviewer feedback. Read audit report for rejection reasons.`,
492
+ role: 'planner',
493
+ issue_ids: task.issue_ids,
494
+ exec_mode: 'csv-wave',
495
+ execution_method: '',
496
+ deps: task.id,
497
+ context_from: task.id,
498
+ wave: String(parseInt(task.wave) + 1),
499
+ status: 'pending',
500
+ findings: '', artifact_path: '', error: ''
501
+ }
502
+ const reReviewTask = {
503
+ id: `AUDIT-${String(fixCycles + 1).padStart(3, '0')}`,
504
+ title: `Re-review revised solution (cycle ${fixCycles})`,
505
+ description: `Re-review revised solution focusing on previously rejected dimensions.`,
506
+ role: 'reviewer',
507
+ issue_ids: task.issue_ids,
508
+ exec_mode: 'interactive',
509
+ execution_method: '',
510
+ deps: fixTask.id,
511
+ context_from: fixTask.id,
512
+ wave: String(parseInt(task.wave) + 2),
513
+ status: 'pending',
514
+ findings: '', artifact_path: '', error: ''
515
+ }
516
+ tasks.push(fixTask, reReviewTask)
517
+ // Adjust MARSHAL and BUILD waves
518
+ for (const t of tasks) {
519
+ if (t.id.startsWith('MARSHAL') || t.id.startsWith('BUILD')) {
520
+ t.wave = String(parseInt(reReviewTask.wave) + (t.id.startsWith('MARSHAL') ? 1 : 2))
521
+ if (t.id.startsWith('MARSHAL')) t.deps = reReviewTask.id
522
+ }
523
+ }
524
+ } else if (verdict === 'rejected' && fixCycles >= 2) {
525
+ // Force proceed with warning
526
+ console.log(`WARNING: Fix cycle limit (${fixCycles}) reached. Forcing proceed to MARSHAL.`)
527
+ }
528
+ }
529
+
530
+ // 5. Merge all results into master CSV
531
+ Write(`${sessionFolder}/tasks.csv`, toCsv(tasks))
532
+
533
+ // 6. Handle deferred BUILD task creation (batch mode after MARSHAL)
534
+ const completedMarshal = tasks.find(t => t.id === 'MARSHAL-001' && t.status === 'completed')
535
+ if (completedMarshal && pipelineMode === 'batch') {
536
+ try {
537
+ const queue = JSON.parse(Read(`${sessionFolder}/queue/execution-queue.json`))
538
+ const buildCount = queue.parallel_groups?.length || 1
539
+ for (let b = 1; b <= Math.min(buildCount, 3); b++) {
540
+ const buildIssues = queue.parallel_groups[b-1]?.issues || issueIds
541
+ tasks.push({
542
+ id: `BUILD-${String(b).padStart(3, '0')}`,
543
+ title: `Implementation group ${b}`,
544
+ description: `Implement solutions for issues in parallel group ${b}`,
545
+ role: 'implementer',
546
+ issue_ids: buildIssues.join(';'),
547
+ exec_mode: 'csv-wave',
548
+ execution_method: executionMethod,
549
+ deps: 'MARSHAL-001',
550
+ context_from: 'EXPLORE-001;SOLVE-001',
551
+ wave: String(parseInt(completedMarshal.wave) + 1),
552
+ status: 'pending',
553
+ findings: '', artifact_path: '', error: ''
554
+ })
555
+ }
556
+ Write(`${sessionFolder}/tasks.csv`, toCsv(tasks))
557
+ } catch (e) { /* single BUILD fallback */ }
558
+ }
559
+ }
560
+ ```
561
+
562
+ **Success Criteria**:
563
+ - All waves executed in order
564
+ - Both csv-wave and interactive tasks handled per wave
565
+ - Each wave's results merged into master CSV before next wave starts
566
+ - Dependent tasks skipped when predecessor failed
567
+ - discoveries.ndjson accumulated across all waves and mechanisms
568
+ - Review-fix cycles handled (max 2)
569
+ - Deferred BUILD tasks created after MARSHAL (batch mode)
570
+
571
+ ---
572
+
573
+ ### Phase 3: Post-Wave Interactive
574
+
575
+ **Objective**: Handle any remaining interactive tasks after all waves complete. In most cases, the review gate is handled inline during Phase 2 wave execution.
576
+
577
+ If any interactive tasks remain unprocessed (e.g., from dynamically added fix cycles), execute them using the same spawn_agent protocol as Phase 2.
578
+
579
+ **Success Criteria**:
580
+ - All interactive tasks completed or skipped
581
+ - Fix cycle limit respected
582
+
583
+ ---
584
+
585
+ ### Phase 4: Results Aggregation
586
+
587
+ **Objective**: Generate final results and human-readable report.
588
+
589
+ ```javascript
590
+ const tasks = parseCsv(Read(`${sessionFolder}/tasks.csv`))
591
+ const completed = tasks.filter(t => t.status === 'completed')
592
+ const failed = tasks.filter(t => t.status === 'failed')
593
+ const skipped = tasks.filter(t => t.status === 'skipped')
594
+
595
+ // Export results.csv
596
+ Bash(`cp ${sessionFolder}/tasks.csv ${sessionFolder}/results.csv`)
597
+
598
+ // Generate context.md
599
+ let contextMd = `# Issue Resolution Report\n\n`
600
+ contextMd += `**Session**: ${sessionId}\n`
601
+ contextMd += `**Pipeline**: ${pipelineMode}\n`
602
+ contextMd += `**Issues**: ${issueIds.join(', ')}\n`
603
+ contextMd += `**Fix Cycles**: ${fixCycles}/${2}\n\n`
604
+
605
+ contextMd += `## Summary\n\n`
606
+ contextMd += `| Status | Count |\n|--------|-------|\n`
607
+ contextMd += `| Completed | ${completed.length} |\n`
608
+ contextMd += `| Failed | ${failed.length} |\n`
609
+ contextMd += `| Skipped | ${skipped.length} |\n\n`
610
+
611
+ contextMd += `## Task Details\n\n`
612
+ for (const t of tasks) {
613
+ const icon = t.status === 'completed' ? '[OK]' : t.status === 'failed' ? '[FAIL]' : '[SKIP]'
614
+ contextMd += `${icon} **${t.id}**: ${t.title} (${t.role})\n`
615
+ if (t.findings) contextMd += ` Findings: ${t.findings.substring(0, 200)}\n`
616
+ if (t.artifact_path) contextMd += ` Artifact: ${t.artifact_path}\n`
617
+ if (t.error) contextMd += ` Error: ${t.error}\n`
618
+ contextMd += `\n`
619
+ }
620
+
621
+ contextMd += `## Deliverables\n\n`
622
+ contextMd += `| Artifact | Path |\n|----------|------|\n`
623
+ contextMd += `| Context Reports | ${sessionFolder}/explorations/ |\n`
624
+ contextMd += `| Solution Plans | ${sessionFolder}/solutions/ |\n`
625
+ contextMd += `| Audit Report | ${sessionFolder}/audits/audit-report.json |\n`
626
+ contextMd += `| Execution Queue | ${sessionFolder}/queue/execution-queue.json |\n`
627
+ contextMd += `| Build Results | ${sessionFolder}/builds/ |\n`
628
+
629
+ Write(`${sessionFolder}/context.md`, contextMd)
630
+
631
+ // Display summary
632
+ console.log(`
633
+ Issue Resolution Complete
634
+ Pipeline: ${pipelineMode}
635
+ Completed: ${completed.length} | Failed: ${failed.length} | Skipped: ${skipped.length}
636
+ Fix Cycles Used: ${fixCycles}/2
637
+ Output: ${sessionFolder}
638
+ `)
639
+ ```
640
+
641
+ **Success Criteria**:
642
+ - results.csv exported (all tasks, both modes)
643
+ - context.md generated
644
+ - Summary displayed to user
645
+
646
+ ---
647
+
648
+ ## Shared Discovery Board Protocol
649
+
650
+ Both csv-wave and interactive agents share the same discoveries.ndjson file:
651
+
652
+ ```jsonl
653
+ {"ts":"2026-03-08T10:00:00Z","worker":"EXPLORE-001","type":"file_found","data":{"path":"src/auth/handler.ts","relevance":"high","purpose":"Main auth handler"}}
654
+ {"ts":"2026-03-08T10:01:00Z","worker":"EXPLORE-001","type":"pattern_found","data":{"pattern":"middleware-chain","location":"src/middleware/","description":"Express middleware chain pattern"}}
655
+ {"ts":"2026-03-08T10:05:00Z","worker":"SOLVE-001","type":"solution_approach","data":{"issue_id":"ISS-20260308-120000","approach":"refactor","estimated_files":5}}
656
+ {"ts":"2026-03-08T10:10:00Z","worker":"BUILD-001","type":"impl_result","data":{"issue_id":"ISS-20260308-120000","files_changed":3,"tests_pass":true}}
657
+ ```
658
+
659
+ **Discovery Types**:
660
+
661
+ | Type | Dedup Key | Data Schema | Description |
662
+ |------|-----------|-------------|-------------|
663
+ | `file_found` | `path` | `{path, relevance, purpose}` | Relevant file discovered |
664
+ | `pattern_found` | `pattern+location` | `{pattern, location, description}` | Code pattern identified |
665
+ | `dependency_found` | `from+to` | `{from, to, type}` | Dependency relationship |
666
+ | `solution_approach` | `issue_id` | `{issue_id, approach, estimated_files}` | Solution strategy |
667
+ | `conflict_found` | `files` | `{issues, files, resolution}` | File conflict between issues |
668
+ | `impl_result` | `issue_id` | `{issue_id, files_changed, tests_pass}` | Implementation outcome |
669
+
670
+ ---
671
+
672
+ ## Error Handling
673
+
674
+ | Error | Resolution |
675
+ |-------|------------|
676
+ | Circular dependency | Detect in wave computation, abort with error message |
677
+ | CSV agent timeout | Mark as failed in results, continue with wave |
678
+ | CSV agent failed | Mark as failed, skip dependent tasks in later waves |
679
+ | Interactive agent timeout | Urge convergence via send_input, then close if still timed out |
680
+ | Interactive agent failed | Mark as failed, skip dependents |
681
+ | All agents in wave failed | Log error, offer retry or abort |
682
+ | CSV parse error | Validate CSV format before execution, show line number |
683
+ | discoveries.ndjson corrupt | Ignore malformed lines, continue with valid entries |
684
+ | Review rejection exceeds 2 rounds | Force convergence to MARSHAL with warning |
685
+ | No issues found for given IDs | Report error, ask user for valid IDs |
686
+ | Deferred BUILD count unknown | Read execution-queue.json after MARSHAL completes |
687
+ | Continue mode: no session found | List available sessions, prompt user to select |
688
+
689
+ ---
690
+
691
+ ## Core Rules
692
+
693
+ 1. **Start Immediately**: First action is session initialization, then Phase 1
694
+ 2. **Wave Order is Sacred**: Never execute wave N before wave N-1 completes and results are merged
695
+ 3. **CSV is Source of Truth**: Master tasks.csv holds all state (both csv-wave and interactive)
696
+ 4. **CSV First**: Default to csv-wave for tasks; only use interactive when interaction pattern requires it
697
+ 5. **Context Propagation**: prev_context built from master CSV, not from memory
698
+ 6. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson -- both mechanisms share it
699
+ 7. **Skip on Failure**: If a dependency failed, skip the dependent task (regardless of mechanism)
700
+ 8. **Lifecycle Balance**: Every spawn_agent MUST have a matching close_agent
701
+ 9. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
702
+ 10. **DO NOT STOP**: Continuous execution until all waves complete or all remaining tasks are skipped
703
+
704
+
705
+ ---
706
+
707
+ ## Coordinator Role Constraints (Main Agent)
708
+
709
+ **CRITICAL**: The coordinator (main agent executing this skill) is responsible for **orchestration only**, NOT implementation.
710
+
711
+ 15. **Coordinator Does NOT Execute Code**: The main agent MUST NOT write, modify, or implement any code directly. All implementation work is delegated to spawned team agents. The coordinator only:
712
+ - Spawns agents with task assignments
713
+ - Waits for agent callbacks
714
+ - Merges results and coordinates workflow
715
+ - Manages workflow transitions between phases
716
+
717
+ 16. **Patient Waiting is Mandatory**: Agent execution takes significant time (typically 10-30 minutes per phase, sometimes longer). The coordinator MUST:
718
+ - Wait patiently for `wait()` calls to complete
719
+ - NOT skip workflow steps due to perceived delays
720
+ - NOT assume agents have failed just because they're taking time
721
+ - Trust the timeout mechanisms defined in the skill
722
+
723
+ 17. **Use send_input for Clarification**: When agents need guidance or appear stuck, the coordinator MUST:
724
+ - Use `send_input()` to ask questions or provide clarification
725
+ - NOT skip the agent or move to next phase prematurely
726
+ - Give agents opportunity to respond before escalating
727
+ - Example: `send_input({ id: agent_id, message: "Please provide status update or clarify blockers" })`
728
+
729
+ 18. **No Workflow Shortcuts**: The coordinator MUST NOT:
730
+ - Skip phases or stages defined in the workflow
731
+ - Bypass required approval or review steps
732
+ - Execute dependent tasks before prerequisites complete
733
+ - Assume task completion without explicit agent callback
734
+ - Make up or fabricate agent results
735
+
736
+ 19. **Respect Long-Running Processes**: This is a complex multi-agent workflow that requires patience:
737
+ - Total execution time may range from 30-90 minutes or longer
738
+ - Each phase may take 10-30 minutes depending on complexity
739
+ - The coordinator must remain active and attentive throughout the entire process
740
+ - Do not terminate or skip steps due to time concerns