maestro-flow 0.3.43 → 0.3.45

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