maestro-flow-one 0.1.0

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 (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -0
  3. package/bin/maestro-flow.js +730 -0
  4. package/claude/maestro-flow/SKILL.md +239 -0
  5. package/claude/maestro-flow/chains/templates.json +256 -0
  6. package/claude/maestro-flow/commands/learn/decompose.md +176 -0
  7. package/claude/maestro-flow/commands/learn/follow.md +167 -0
  8. package/claude/maestro-flow/commands/learn/investigate.md +221 -0
  9. package/claude/maestro-flow/commands/learn/retro.md +303 -0
  10. package/claude/maestro-flow/commands/learn/second-opinion.md +167 -0
  11. package/claude/maestro-flow/commands/lifecycle/amend.md +300 -0
  12. package/claude/maestro-flow/commands/lifecycle/analyze.md +126 -0
  13. package/claude/maestro-flow/commands/lifecycle/brainstorm.md +100 -0
  14. package/claude/maestro-flow/commands/lifecycle/composer.md +354 -0
  15. package/claude/maestro-flow/commands/lifecycle/execute.md +114 -0
  16. package/claude/maestro-flow/commands/lifecycle/fork.md +86 -0
  17. package/claude/maestro-flow/commands/lifecycle/init.md +78 -0
  18. package/claude/maestro-flow/commands/lifecycle/learn.md +140 -0
  19. package/claude/maestro-flow/commands/lifecycle/link-coordinate.md +71 -0
  20. package/claude/maestro-flow/commands/lifecycle/merge.md +61 -0
  21. package/claude/maestro-flow/commands/lifecycle/overlay.md +178 -0
  22. package/claude/maestro-flow/commands/lifecycle/plan.md +138 -0
  23. package/claude/maestro-flow/commands/lifecycle/player.md +404 -0
  24. package/claude/maestro-flow/commands/lifecycle/quick.md +56 -0
  25. package/claude/maestro-flow/commands/lifecycle/roadmap.md +164 -0
  26. package/claude/maestro-flow/commands/lifecycle/ui-design.md +93 -0
  27. package/claude/maestro-flow/commands/lifecycle/update.md +176 -0
  28. package/claude/maestro-flow/commands/lifecycle/verify.md +90 -0
  29. package/claude/maestro-flow/commands/manage/codebase-rebuild.md +75 -0
  30. package/claude/maestro-flow/commands/manage/codebase-refresh.md +57 -0
  31. package/claude/maestro-flow/commands/manage/harvest.md +94 -0
  32. package/claude/maestro-flow/commands/manage/issue-discover.md +77 -0
  33. package/claude/maestro-flow/commands/manage/issue.md +73 -0
  34. package/claude/maestro-flow/commands/manage/knowhow-capture.md +193 -0
  35. package/claude/maestro-flow/commands/manage/knowhow.md +77 -0
  36. package/claude/maestro-flow/commands/manage/learn.md +67 -0
  37. package/claude/maestro-flow/commands/manage/status.md +51 -0
  38. package/claude/maestro-flow/commands/manage/wiki.md +62 -0
  39. package/claude/maestro-flow/commands/milestone/audit.md +68 -0
  40. package/claude/maestro-flow/commands/milestone/complete.md +75 -0
  41. package/claude/maestro-flow/commands/milestone/release.md +96 -0
  42. package/claude/maestro-flow/commands/quality/auto-test.md +124 -0
  43. package/claude/maestro-flow/commands/quality/debug.md +115 -0
  44. package/claude/maestro-flow/commands/quality/refactor.md +55 -0
  45. package/claude/maestro-flow/commands/quality/retrospective.md +78 -0
  46. package/claude/maestro-flow/commands/quality/review.md +108 -0
  47. package/claude/maestro-flow/commands/quality/sync.md +51 -0
  48. package/claude/maestro-flow/commands/quality/test.md +103 -0
  49. package/claude/maestro-flow/commands/spec/add.md +49 -0
  50. package/claude/maestro-flow/commands/spec/load.md +51 -0
  51. package/claude/maestro-flow/commands/spec/remove.md +51 -0
  52. package/claude/maestro-flow/commands/spec/setup.md +51 -0
  53. package/claude/maestro-flow/commands/wiki/connect.md +62 -0
  54. package/claude/maestro-flow/commands/wiki/digest.md +69 -0
  55. package/codex/maestro-flow/SKILL.md +505 -0
  56. package/codex/maestro-flow/chains/templates.json +256 -0
  57. package/codex/maestro-flow/commands/learn/decompose.md +113 -0
  58. package/codex/maestro-flow/commands/learn/follow.md +83 -0
  59. package/codex/maestro-flow/commands/learn/investigate.md +83 -0
  60. package/codex/maestro-flow/commands/learn/retro.md +83 -0
  61. package/codex/maestro-flow/commands/learn/second-opinion.md +86 -0
  62. package/codex/maestro-flow/commands/lifecycle/amend.md +300 -0
  63. package/codex/maestro-flow/commands/lifecycle/analyze.md +483 -0
  64. package/codex/maestro-flow/commands/lifecycle/brainstorm.md +397 -0
  65. package/codex/maestro-flow/commands/lifecycle/composer.md +213 -0
  66. package/codex/maestro-flow/commands/lifecycle/execute.md +318 -0
  67. package/codex/maestro-flow/commands/lifecycle/fork.md +98 -0
  68. package/codex/maestro-flow/commands/lifecycle/init.md +134 -0
  69. package/codex/maestro-flow/commands/lifecycle/learn.md +80 -0
  70. package/codex/maestro-flow/commands/lifecycle/link-coordinate.md +257 -0
  71. package/codex/maestro-flow/commands/lifecycle/merge.md +69 -0
  72. package/codex/maestro-flow/commands/lifecycle/overlay.md +119 -0
  73. package/codex/maestro-flow/commands/lifecycle/plan.md +460 -0
  74. package/codex/maestro-flow/commands/lifecycle/player.md +323 -0
  75. package/codex/maestro-flow/commands/lifecycle/quick.md +124 -0
  76. package/codex/maestro-flow/commands/lifecycle/roadmap.md +468 -0
  77. package/codex/maestro-flow/commands/lifecycle/ui-design.md +135 -0
  78. package/codex/maestro-flow/commands/lifecycle/update.md +176 -0
  79. package/codex/maestro-flow/commands/lifecycle/verify.md +468 -0
  80. package/codex/maestro-flow/commands/manage/codebase-rebuild.md +347 -0
  81. package/codex/maestro-flow/commands/manage/codebase-refresh.md +66 -0
  82. package/codex/maestro-flow/commands/manage/harvest.md +91 -0
  83. package/codex/maestro-flow/commands/manage/issue-discover.md +431 -0
  84. package/codex/maestro-flow/commands/manage/issue.md +75 -0
  85. package/codex/maestro-flow/commands/manage/knowhow-capture.md +110 -0
  86. package/codex/maestro-flow/commands/manage/knowhow.md +95 -0
  87. package/codex/maestro-flow/commands/manage/learn.md +137 -0
  88. package/codex/maestro-flow/commands/manage/status.md +76 -0
  89. package/codex/maestro-flow/commands/manage/wiki.md +55 -0
  90. package/codex/maestro-flow/commands/milestone/audit.md +87 -0
  91. package/codex/maestro-flow/commands/milestone/complete.md +91 -0
  92. package/codex/maestro-flow/commands/milestone/release.md +70 -0
  93. package/codex/maestro-flow/commands/quality/auto-test.md +547 -0
  94. package/codex/maestro-flow/commands/quality/debug.md +334 -0
  95. package/codex/maestro-flow/commands/quality/refactor.md +151 -0
  96. package/codex/maestro-flow/commands/quality/retrospective.md +292 -0
  97. package/codex/maestro-flow/commands/quality/review.md +364 -0
  98. package/codex/maestro-flow/commands/quality/sync.md +111 -0
  99. package/codex/maestro-flow/commands/quality/test.md +498 -0
  100. package/codex/maestro-flow/commands/spec/add.md +101 -0
  101. package/codex/maestro-flow/commands/spec/load.md +77 -0
  102. package/codex/maestro-flow/commands/spec/remove.md +69 -0
  103. package/codex/maestro-flow/commands/spec/setup.md +75 -0
  104. package/codex/maestro-flow/commands/wiki/connect.md +73 -0
  105. package/codex/maestro-flow/commands/wiki/digest.md +87 -0
  106. package/package.json +24 -0
@@ -0,0 +1,483 @@
1
+ ---
2
+ name: maestro-analyze
3
+ description: Multi-dimensional analysis via CSV wave pipeline. Diamond topology — CLI exploration agents (Wave 1), 6-dimension scoring agents (Wave 2), decision synthesis agent (Wave 3). Supports dual depth with -q quick mode and --gaps issue root cause analysis. Replaces maestro-analyze command.
4
+ argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"<phase|topic> [-q|--quick] [--gaps [ISS-ID]]\""
5
+ allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ <purpose>
9
+ Wave-based multi-dimensional analysis using `spawn_agents_on_csv`. Diamond topology: CLI exploration agents gather codebase context (Wave 1), 6-dimension scoring agents evaluate in parallel (Wave 2), then decision synthesis agent compiles final decisions and context.md (Wave 3).
10
+
11
+ **Core workflow**: Parse Subject -> CLI Exploration -> 6-Dimension Scoring -> Decision Synthesis
12
+
13
+ **Tri-depth**: Full mode (all 3 waves), Quick mode (`-q`, Wave 3 only), or Gaps mode (`--gaps`, issue root cause analysis pipeline).
14
+
15
+ ```
16
+ +---------------------------------------------------------------------------+
17
+ | ANALYZE CSV WAVE WORKFLOW |
18
+ +---------------------------------------------------------------------------+
19
+ | |
20
+ | Phase 1: Subject Resolution -> CSV |
21
+ | +-- Parse phase number or topic text from arguments |
22
+ | +-- Detect mode (phase / scratch) and depth (full / quick) |
23
+ | +-- Resolve output directory |
24
+ | +-- Load prior context (project.md, roadmap, brainstorm artifacts) |
25
+ | +-- Select dimensions and perspectives (interactive or auto) |
26
+ | +-- Generate tasks.csv with exploration + scoring + synthesis rows |
27
+ | +-- User validates dimension breakdown (skip if -y) |
28
+ | |
29
+ | Phase 2: Wave Execution Engine |
30
+ | +-- Wave 1: CLI Exploration (parallel) [SKIP in -q mode] |
31
+ | | +-- Each agent explores codebase for a specific dimension |
32
+ | | +-- 3-layer exploration: module discovery, structure tracing, |
33
+ | | | code anchor extraction |
34
+ | | +-- Discoveries shared via board (code patterns, tech stack) |
35
+ | | +-- Results: findings + relevant file paths per dimension |
36
+ | +-- Wave 2: 6-Dimension Scoring (parallel) [SKIP in -q mode] |
37
+ | | +-- Each agent scores one dimension (1-5) with evidence |
38
+ | | +-- Receives exploration findings via prev_context |
39
+ | | +-- Discoveries shared via board (risks, alternatives) |
40
+ | | +-- Results: score + recommendations per dimension |
41
+ | +-- Wave 3: Decision Synthesis (single agent) |
42
+ | | +-- Compile all scores into analysis.md |
43
+ | | +-- Identify gray areas, generate Locked/Free/Deferred decisions |
44
+ | | +-- Build context.md for downstream plan |
45
+ | | +-- Go/No-Go recommendation with confidence level |
46
+ | +-- discoveries.ndjson shared across all waves (append-only) |
47
+ | |
48
+ | Phase 3: Results Aggregation |
49
+ | +-- Export results.csv + analysis.md + context.md |
50
+ | +-- Generate conclusions.json with decision trail |
51
+ | +-- Auto-create issues for deferred items |
52
+ | +-- Update phase index.json with analysis status |
53
+ | +-- Display summary with verdict + next steps |
54
+ | |
55
+ +---------------------------------------------------------------------------+
56
+ ```
57
+ </purpose>
58
+
59
+ <context>
60
+ ```bash
61
+ $maestro-analyze "3"
62
+ $maestro-analyze -y "microservices vs monolith"
63
+ $maestro-analyze -c 6 "3 -q"
64
+ $maestro-analyze --continue "20260318-analyze-microservices"
65
+ ```
66
+
67
+ **Flags**:
68
+ - `-y, --yes`: Skip all confirmations (auto mode)
69
+ - `-c, --concurrency N`: Max concurrent agents within each wave (default: 6)
70
+ - `--continue`: Resume existing session
71
+ - `-q, --quick`: Quick mode -- skip exploration + scoring, go straight to decision extraction (Wave 3 only)
72
+ - `--gaps [ISS-ID]`: Issue root cause analysis mode. If ISS-ID provided, analyze single issue. If omitted, analyze all open/registered issues from issues.jsonl. Replaces manage-issue-analyze.
73
+
74
+ When `--yes` or `-y`: Auto-confirm dimension selection, skip interactive scoping, use defaults for perspectives and depth, auto-deepen for up to 3 rounds.
75
+
76
+ **Output Directory**: `.workflow/.csv-wave/{session-id}/`
77
+ **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (decision extraction report) + `analysis.md` (6-dimension scoring summary)
78
+ </context>
79
+
80
+ <csv_schema>
81
+
82
+ ### tasks.csv (Master State)
83
+
84
+ ```csv
85
+ id,title,description,dimension,analysis_type,deps,context_from,wave,status,findings,score,recommendations,error
86
+ "1","Explore: Architecture","Explore codebase for architecture-relevant patterns: module boundaries, dependency graph, layer violations, design patterns in use. 3-layer exploration: module discovery, structure tracing, code anchor extraction.","architecture","explore","","","1","","","","",""
87
+ "2","Explore: Implementation","Explore codebase for implementation patterns: code structure, error handling, algorithm choices, type safety. Extract code anchors with file:line references.","implementation","explore","","","1","","","","",""
88
+ "3","Explore: Performance","Explore codebase for performance characteristics: hot paths, resource utilization, concurrency patterns, potential bottlenecks.","performance","explore","","","1","","","","",""
89
+ "4","Score: Feasibility","Score feasibility (0-100) with evidence: technical difficulty, team capability gaps, time estimate, tooling requirements. Reference exploration findings.","feasibility","score","1;2;3","1;2;3","2","","","","",""
90
+ "5","Score: Impact","Score impact (0-100) with evidence: user value, business value, tech debt reduction, developer experience improvement.","impact","score","1;2;3","1;2;3","2","","","","",""
91
+ "6","Score: Risk","Score risk (0-100) with evidence: failure modes, security concerns, scalability limits, regression potential. Build probability-impact matrix.","risk","score","1;2;3","1;2;3","2","","","","",""
92
+ "7","Score: Complexity","Score complexity (0-100) with evidence: integration points, dependency count, learning curve, testing difficulty.","complexity","score","1;2;3","1;2;3","2","","","","",""
93
+ "8","Score: Alignment","Score alignment (0-100) with evidence: project vision fit, roadmap consistency, architecture principle adherence.","alignment","score","1;2;3","1;2;3","2","","","","",""
94
+ "9","Score: Maintainability","Score maintainability (0-100) with evidence: code clarity, documentation coverage, test coverage, refactoring safety.","maintainability","score","1;2;3","1;2;3","2","","","","",""
95
+ "10","Decision Synthesis","Compile all dimension scores into analysis.md. Identify gray areas. Generate Locked/Free/Deferred decisions for context.md. Formulate Go/No-Go recommendation with confidence. Build conclusions.json.","synthesis","decide","4;5;6;7;8;9","4;5;6;7;8;9","3","","","","",""
96
+ ```
97
+
98
+ **Columns**:
99
+
100
+ | Column | Phase | Description |
101
+ |--------|-------|-------------|
102
+ | `id` | Input | Unique task identifier (string) |
103
+ | `title` | Input | Short task title |
104
+ | `description` | Input | Detailed analysis instructions for this task |
105
+ | `dimension` | Input | Analysis dimension: architecture/implementation/performance/feasibility/impact/risk/complexity/alignment/maintainability/synthesis |
106
+ | `analysis_type` | Input | Task type: explore/score/decide |
107
+ | `deps` | Input | Semicolon-separated dependency task IDs |
108
+ | `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
109
+ | `wave` | Computed | Wave number (1 = explore, 2 = score, 3 = decide) |
110
+ | `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
111
+ | `findings` | Output | Key findings summary (max 500 chars) |
112
+ | `score` | Output | Dimension score (0-100 for scoring tasks, empty for explore/decide) |
113
+ | `recommendations` | Output | Dimension-specific recommendations |
114
+ | `error` | Output | Error message if failed |
115
+
116
+ ### Per-Wave CSV (Temporary)
117
+
118
+ Each wave generates `wave-{N}.csv` with extra `prev_context` column.
119
+
120
+ ### Output Artifacts
121
+
122
+ | File | Purpose | Lifecycle |
123
+ |------|---------|-----------|
124
+ | `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
125
+ | `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
126
+ | `results.csv` | Final export of all task results | Created in Phase 3 |
127
+ | `discoveries.ndjson` | Shared exploration board | Append-only, carries across waves |
128
+ | `context.md` | Locked/Free/Deferred decisions for downstream plan | Created in Phase 3 |
129
+ | `analysis.md` | 6-dimension scoring summary + risk matrix + Go/No-Go | Created in Phase 3 (full mode only) |
130
+ | `conclusions.json` | Structured conclusions with decision trail | Created in Phase 3 (full mode only) |
131
+
132
+ ### Session Structure
133
+
134
+ ```
135
+ .workflow/.csv-wave/{YYYYMMDD}-analyze-{slug}/
136
+ +-- tasks.csv
137
+ +-- results.csv
138
+ +-- discoveries.ndjson
139
+ +-- context.md
140
+ +-- analysis.md
141
+ +-- conclusions.json
142
+ +-- wave-{N}.csv (temporary)
143
+ ```
144
+ </csv_schema>
145
+
146
+ <invariants>
147
+ 1. **Start Immediately**: First action is session initialization, then Phase 1
148
+ 2. **Wave Order is Sacred**: Never execute wave 2 before wave 1 completes and results are merged
149
+ 3. **CSV is Source of Truth**: Master tasks.csv holds all state
150
+ 4. **Context Propagation**: prev_context built from master CSV, not from memory
151
+ 5. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
152
+ 6. **Quick Mode Shortcut**: With -q flag, generate only wave 3 task, skip exploration and scoring
153
+ 6b. **Gaps Mode Pipeline**: With --gaps flag, load issues, explore per issue, write analysis records back to issues.jsonl, output context.md for plan --gaps
154
+ 7. **Skip on Failure**: Degrade gracefully -- missing exploration reduces scoring quality, missing scoring reduces synthesis quality
155
+ 8. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
156
+ 9. **DO NOT STOP**: Continuous execution until all waves complete
157
+ 10. **Tri-Output**: context.md is ALWAYS produced (all modes). analysis.md + conclusions.json are full-mode only. Gaps mode writes analysis records to issues.jsonl + context.md for plan --gaps.
158
+ </invariants>
159
+
160
+ <execution>
161
+
162
+ ### Session Initialization
163
+
164
+ **Parse from `$ARGUMENTS`**:
165
+
166
+ | Variable | Source | Default |
167
+ |----------|--------|---------|
168
+ | `AUTO_YES` | `--yes` or `-y` | false |
169
+ | `continueMode` | `--continue` | false |
170
+ | `maxConcurrency` | `--concurrency N` or `-c N` | 6 |
171
+ | `QUICK_MODE` | `-q` or `--quick` | false |
172
+ | `GAPS_MODE` | `--gaps` | false |
173
+ | `gapsIssueId` | `--gaps ISS-{id}` | null |
174
+ | `subjectArg` | remaining text after flag removal | "" |
175
+
176
+ **Auto-bootstrap**: If `.workflow/state.json` missing, create minimal `{ project: null, status: "active", current_milestone: null, artifacts: [] }`.
177
+
178
+ **Scope determination** (from `state.json` + `subjectArg`):
179
+
180
+ | Condition | Scope | Slug |
181
+ |-----------|-------|------|
182
+ | `GAPS_MODE` | `gaps` | `gapsIssueId` slugified or `"issue-gaps"` |
183
+ | Empty subject + milestone + roadmap | `milestone` | milestone name slugified |
184
+ | Empty subject, no roadmap | ERROR: `"E001: No args and no roadmap"` | — |
185
+ | Numeric subject + milestone + roadmap | `phase` | phase slug from roadmap |
186
+ | Numeric subject, no roadmap | ERROR: `"Phase number requires init + roadmap"` | — |
187
+ | Text subject + milestone | `adhoc` | subject slugified (max 40 chars) |
188
+ | Text subject, no milestone | `standalone` | subject slugified (max 40 chars) |
189
+
190
+ **Session paths** (UTC+8 date prefix):
191
+ - `sessionFolder`: `.workflow/.csv-wave/{YYYYMMDD}-analyze-{slug}/`
192
+ - `scratchDir`: `.workflow/scratch/{YYYYMMDD}-analyze-{slug}/`
193
+
194
+ Create both directories.
195
+
196
+ ### Phase 1: Subject Resolution -> CSV
197
+
198
+ **Objective**: Parse subject, load context, select dimensions, generate tasks.csv.
199
+
200
+ **Decomposition Rules**:
201
+
202
+ 1. **Scope detection**: Already determined in Session Initialization (milestone/phase/adhoc/standalone)
203
+ 2. **Context loading** (milestone/phase scope):
204
+ - Read `.workflow/project.md` -- project vision and constraints
205
+ - Read `.workflow/roadmap.md` -- phase structure and dependencies
206
+ - Read `.workflow/state.json` → `current_milestone`, `artifacts[]`, `accumulated_context`
207
+ - Find prior analyze artifacts from `state.json.artifacts[]` (type=analyze, same milestone) → load their `context.md`
208
+ - Find brainstorm artifacts from `state.json.artifacts[]` (type=brainstorm, same milestone) → load `guidance-specification.md`
209
+ - Load project specs: `maestro spec load --category arch`
210
+
211
+ 3. **Quick mode routing**: If QUICK_MODE, generate only wave 3 (synthesis/decide) task in CSV. Skip exploration and scoring.
212
+
213
+ 3b. **Gaps mode routing** (if GAPS_MODE):
214
+ - Load issues from `.workflow/issues/issues.jsonl`
215
+ - If `gapsIssueId`: load single issue, validate existence
216
+ - If no ISS-ID: filter `status == "open" || status == "registered"`
217
+ - For each issue, generate an exploration task (wave 1) focused on issue context
218
+ - Generate a synthesis task (wave 2) that writes analysis records back to issues.jsonl
219
+ - Skip standard dimension scoring (wave 2 in normal mode)
220
+ - Pipeline: Load Issues → CLI Exploration per issue → Root Cause Synthesis → Write issue.analysis → Output context.md
221
+ - On completion: append history entry `{ action: "analyzed", at: <ISO>, by: "maestro-analyze --gaps" }` per issue
222
+
223
+ 4. **Dimension and perspective selection** (full mode):
224
+
225
+ | Depth | Exploration Dimensions | Scoring Dimensions |
226
+ |-------|----------------------|-------------------|
227
+ | Standard (default) | architecture, implementation, performance | feasibility, impact, risk, complexity, alignment, maintainability |
228
+ | Custom (interactive) | User-selected from 8 available | All 6 scoring dimensions |
229
+
230
+ Available exploration dimensions:
231
+ - architecture, implementation, performance, security, concept, comparison, decision, external_research
232
+
233
+ 5. **CSV generation**:
234
+ - Full mode: N exploration rows (wave 1) + 6 scoring rows (wave 2) + 1 synthesis row (wave 3)
235
+ - Quick mode: 1 synthesis row only (wave 1, no deps)
236
+
237
+ **Wave computation**: 3-wave diamond -- explore = wave 1, score = wave 2, decide = wave 3. Quick mode: single wave.
238
+
239
+ **User validation**: Display task breakdown (skip if AUTO_YES).
240
+
241
+ ### Phase 2: Wave Execution Engine
242
+
243
+ **Objective**: Execute analysis pipeline wave-by-wave via spawn_agents_on_csv.
244
+
245
+ #### Wave 1: CLI Exploration (Parallel) [SKIP in -q mode]
246
+
247
+ Filter `wave == 1 && status == pending` from master CSV. No prev_context (no predecessors). Write `wave-1.csv`.
248
+
249
+ ```javascript
250
+ spawn_agents_on_csv({
251
+ csv_path: `${sessionFolder}/wave-1.csv`,
252
+ id_column: "id",
253
+ instruction: buildExplorationInstruction(sessionFolder),
254
+ max_concurrency: maxConcurrency,
255
+ max_runtime_seconds: 3600,
256
+ output_csv_path: `${sessionFolder}/wave-1-results.csv`,
257
+ output_schema: { id, status: ["completed"|"failed"], findings, score, recommendations, error }
258
+ // required: id, status, findings
259
+ })
260
+ ```
261
+
262
+ Merge results into master `tasks.csv`, delete `wave-1.csv`.
263
+
264
+ **Exploration agent responsibilities** (3-layer per dimension):
265
+ 1. **Module Discovery** (breadth) -- keyword search, relevant files, module boundaries
266
+ 2. **Structure Tracing** (depth) -- top 3-5 files: call chains 2-3 levels, data flow
267
+ 3. **Code Anchor Extraction** (detail) -- code snippet (20-50 lines) with file:line per finding
268
+ - Share findings via discovery board
269
+
270
+ #### Wave 2: 6-Dimension Scoring (Parallel) [SKIP in -q mode]
271
+
272
+ Filter `wave == 2 && status == pending` from master CSV. Build `prev_context` from wave 1 findings (format: `[Task N: Title] summary...` per exploration task). Write `wave-2.csv` with `prev_context` column.
273
+
274
+ ```javascript
275
+ spawn_agents_on_csv({
276
+ csv_path: `${sessionFolder}/wave-2.csv`,
277
+ id_column: "id",
278
+ instruction: buildScoringInstruction(sessionFolder),
279
+ max_concurrency: maxConcurrency,
280
+ max_runtime_seconds: 3600,
281
+ output_csv_path: `${sessionFolder}/wave-2-results.csv`,
282
+ output_schema: { id, status: ["completed"|"failed"], findings, score, recommendations, error }
283
+ // required: id, status, findings, score
284
+ })
285
+ ```
286
+
287
+ Merge results into master `tasks.csv`, delete `wave-2.csv`.
288
+
289
+ **Scoring agent responsibilities** (6 dimensions):
290
+
291
+ | Dimension | Focus Areas | Score Range |
292
+ |-----------|------------|-------------|
293
+ | Feasibility | Technical difficulty, team capability, time, tooling | 0-100 |
294
+ | Impact | User value, business value, tech debt reduction, DX | 0-100 |
295
+ | Risk | Failure modes, security, scalability, regression | 0-100 |
296
+ | Complexity | Integration points, dependencies, learning curve, testing | 0-100 |
297
+ | Alignment | Project vision fit, roadmap consistency, architecture principles | 0-100 |
298
+ | Maintainability | Code clarity, documentation, test coverage, refactoring safety | 0-100 |
299
+
300
+ Each score MUST include specific evidence (code refs, data points from exploration findings).
301
+
302
+ #### Wave 3: Decision Synthesis (Single Agent)
303
+
304
+ Filter `wave == 3` (or wave 1 in quick mode) `&& status == pending`. If full mode and all wave 2 failed, fall back to available exploration context.
305
+
306
+ **prev_context source**:
307
+ - Full mode: wave 2 scoring findings (format: `[Task N: Score Dim] Score: X. summary...`)
308
+ - Quick mode: loaded project context (project.md, roadmap, brainstorm artifacts)
309
+
310
+ Write wave CSV with `prev_context`, execute `spawn_agents_on_csv` for synthesis agent, merge results, delete temp CSV.
311
+
312
+ **Synthesis agent responsibilities**:
313
+ - Compile dimension scores into analysis.md (full mode):
314
+ - Executive summary with overall assessment
315
+ - Per-dimension scores with key evidence
316
+ - Risk matrix visualization
317
+ - Go/No-Go recommendation with confidence
318
+ - Identify gray areas (both modes):
319
+ - Domain-aware: something users SEE/CALL/RUN/READ/are ORGANIZED
320
+ - Phase-specific: skip areas decided in prior context.md
321
+ - If guidance-specification.md loaded: skip MUST/MUST NOT, focus on SHOULD/MAY gaps
322
+ - Generate Locked/Free/Deferred decisions for context.md
323
+ - Build conclusions.json (full mode) with decision trail and recommendations
324
+
325
+ ### Phase 3: Results Aggregation
326
+
327
+ **Objective**: Generate final results and output artifacts.
328
+
329
+ 1. Read final master `tasks.csv`
330
+ 2. Export as `results.csv`
331
+ 3. Build `analysis.md` (full mode only):
332
+
333
+ ```markdown
334
+ # Analysis Report -- {subject}
335
+
336
+ ## Executive Summary
337
+ - Overall assessment: {Go/No-Go/Conditional}
338
+ - Confidence: {high/medium/low}
339
+ - Key risk: {top risk}
340
+
341
+ ## Dimension Scores
342
+ | Dimension | Score | Key Evidence |
343
+ |-----------|-------|-------------|
344
+ | Feasibility | {N}/100 | {evidence} |
345
+ | Impact | {N}/100 | {evidence} |
346
+ | Risk | {N}/100 | {evidence} |
347
+ | Complexity | {N}/100 | {evidence} |
348
+ | Alignment | {N}/100 | {evidence} |
349
+ | Maintainability | {N}/100 | {evidence} |
350
+
351
+ ## Risk Matrix
352
+ {probability-impact matrix}
353
+
354
+ ## Recommendations
355
+ {prioritized recommendations with rationale}
356
+ ```
357
+
358
+ 4. Build `context.md` (both modes):
359
+
360
+ ```markdown
361
+ # Context: {subject}
362
+
363
+ **Date**: {date}
364
+ **Mode**: {full|quick}
365
+ **Areas discussed**: {list}
366
+
367
+ ## Decisions
368
+
369
+ ### Decision N: {TITLE}
370
+ - **Context**: {what and why}
371
+ - **Options**: 1. {opt1} 2. {opt2}
372
+ - **Chosen**: {selected}
373
+ - **Reason**: {rationale}
374
+
375
+ ## Constraints
376
+
377
+ ### Locked
378
+ {decisions that are final and must be followed}
379
+
380
+ ### Free
381
+ {decisions left to implementer discretion}
382
+
383
+ ### Deferred
384
+ {ideas captured but postponed to later phases}
385
+
386
+ ## Code Context
387
+ {relevant code references from exploration}
388
+ ```
389
+
390
+ 5. Build `conclusions.json` (full mode only):
391
+
392
+ ```json
393
+ {
394
+ "session_id": "<session>",
395
+ "subject": "<subject>",
396
+ "mode": "full",
397
+ "recommendation": "Go|No-Go|Conditional",
398
+ "confidence": "high|medium|low",
399
+ "dimensions": [
400
+ { "name": "feasibility", "score": 75, "findings": "...", "recommendations": "..." }
401
+ ],
402
+ "decisions": [
403
+ { "title": "...", "classification": "locked|free|deferred", "rationale": "..." }
404
+ ],
405
+ "risk_matrix": [...],
406
+ "timestamp": "<ISO>"
407
+ }
408
+ ```
409
+
410
+ 6. **Auto-create issues from Deferred items**: Filter decisions with `classification == "Deferred"`, append each as issue to `.workflow/issues/issues.jsonl`.
411
+
412
+ 7b. **Spec Enrichment**: For each Locked decision in context.md, persist via CLI:
413
+ - `maestro spec add arch "<decision.title>" "<decision.rationale>" --keywords ... --source analyze:{sessionId}`
414
+ - For non-trivial code patterns discovered during exploration → `maestro spec add coding ...`
415
+
416
+ 7. **Register artifact in state.json**: Append `{ id: "ANL-{next_id}", type: "analyze", milestone, phase, scope, path: scratchDir, status: "completed", depends_on: null, harvested: false, created_at, completed_at }`.
417
+ 8. Copy final outputs (context.md, analysis.md, conclusions.json) from CSV session folder to `scratchDir`
418
+ 9. Display summary
419
+
420
+ ### Shared Discovery Board Protocol
421
+
422
+ #### Standard Discovery Types
423
+
424
+ | Type | Dedup Key | Data Schema | Description |
425
+ |------|-----------|-------------|-------------|
426
+ | `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
427
+ | `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
428
+ | `convention` | singleton | `{naming, imports, formatting}` | Project code conventions |
429
+ | `blocker` | `data.issue` | `{issue, severity, impact}` | Blocking issue found |
430
+ | `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack info |
431
+
432
+ #### Domain Discovery Types
433
+
434
+ | Type | Dedup Key | Data Schema | Description |
435
+ |------|-----------|-------------|-------------|
436
+ | `exploration_finding` | `data.file+data.line` | `{file, line, snippet, dimension, significance}` | Code anchor from exploration |
437
+ | `dimension_score` | `data.dimension` | `{dimension, score, evidence, confidence}` | Scoring result |
438
+ | `risk_item` | `data.description` | `{description, probability, impact, mitigation}` | Identified risk |
439
+ | `decision_candidate` | `data.area` | `{area, options[], recommendation, classification}` | Gray area for decision |
440
+ | `alternative` | `data.name` | `{name, description, pros[], cons[], fit_score}` | Alternative approach |
441
+
442
+ #### Protocol
443
+
444
+ 1. **Read** `{session_folder}/discoveries.ndjson` before own analysis
445
+ 2. **Skip covered**: If discovery of same type + dedup key exists, skip
446
+ 3. **Write immediately**: Append findings as found
447
+ 4. **Append-only**: Never modify or delete
448
+ 5. **Deduplicate**: Check before writing
449
+
450
+ ```bash
451
+ echo '{"ts":"<ISO>","worker":"{id}","type":"exploration_finding","data":{"file":"src/auth/login.ts","line":42,"snippet":"export async function verifyToken(...)","dimension":"architecture","significance":"Core auth entry point"}}' >> {session_folder}/discoveries.ndjson
452
+ ```
453
+ </execution>
454
+
455
+ <error_codes>
456
+
457
+ | Error | Resolution |
458
+ |-------|------------|
459
+ | Subject argument missing (non-gaps) | Abort with error: "Analysis subject required (phase number or topic text)" |
460
+ | --gaps but no issues found | Abort with error: "No open/registered issues in issues.jsonl" |
461
+ | --gaps ISS-ID not found | Abort with error: "Issue {ISS-ID} not found — run manage-issue list" |
462
+ | Phase directory not found | List available phases, abort with error |
463
+ | No prior context for quick mode | Warn: limited context, proceed with available information |
464
+ | Exploration agent timeout | Mark as failed, continue with remaining exploration agents |
465
+ | All exploration agents failed | Proceed to scoring with limited context, note limitation |
466
+ | Scoring agent timeout | Mark as failed, use available scores for synthesis |
467
+ | All scoring agents failed | Skip analysis.md, proceed to decision extraction only |
468
+ | Synthesis agent failed | Use raw scores/exploration as fallback, generate minimal context.md |
469
+ | CSV parse error | Validate format, show line number |
470
+ | discoveries.ndjson corrupt | Ignore malformed lines |
471
+ | Continue mode: no session found | List available sessions |
472
+ </error_codes>
473
+
474
+ <success_criteria>
475
+ - [ ] Session folder created with valid tasks.csv
476
+ - [ ] All waves executed in order (or skipped per mode)
477
+ - [ ] context.md produced (all modes)
478
+ - [ ] analysis.md + conclusions.json produced (full mode only)
479
+ - [ ] Deferred items auto-created as issues
480
+ - [ ] Artifact registered in state.json
481
+ - [ ] Final outputs copied to scratchDir
482
+ - [ ] discoveries.ndjson append-only throughout
483
+ </success_criteria>