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,292 @@
1
+ ---
2
+ name: quality-retrospective
3
+ description: Multi-lens 复盘 (retrospective) for completed phases. Context-Agent Fork loads phase artifacts once; four parallel lens agents (technical, process, quality, decision) analyze independently; synthesizer distills insights; outputs are routed to spec stubs, knowhow tips, issues, and lessons.jsonl.
4
+ argument-hint: "[phase|N..M] [--lens technical|process|quality|decision] [--all] [--no-route] [--compare N] [-y]"
5
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep
6
+ ---
7
+
8
+ <purpose>
9
+ Multi-lens retrospective for completed phases. Context-Agent Fork loads phase artifacts once;
10
+ four parallel lens agents (technical, process, quality, decision) analyze independently;
11
+ synthesizer distills insights; outputs are routed to spec stubs, knowhow tips, issues, and lessons.jsonl.
12
+
13
+ ```
14
+ +------------------------------------------------------------------+
15
+ | quality-retrospective -- Context-Agent Fork + Parallel Fan-out |
16
+ +------------------------------------------------------------------+
17
+
18
+ Stage 1-3: Read-only resolution (no writes)
19
+ +---------------------------------------------+
20
+ | Parse mode -> Validate artifacts |
21
+ | -> [scan] Find unreviewed phases |
22
+ +----------------------+-----------------------+
23
+ |
24
+ Stage 4: Context-Agent Fork (Pattern 2.10)
25
+ +----------------------------------------------------------------+
26
+ | spawn ctx (fork_turns: "none") |
27
+ | wait ctx |
28
+ | +----------+ +----------+ +----------+ +----------+ |
29
+ | |lens-tech | |lens-proc | |lens-qual | |lens-dec | |
30
+ | |fork=true | |fork=true | |fork=true | |fork=true | |
31
+ | +----------+ +----------+ +----------+ +----------+ |
32
+ | wait_agent([lens-tech, lens-proc, lens-qual, lens-dec]) |
33
+ | close lenses -> close ctx LAST |
34
+ +----------------------+-----------------------------------------+
35
+ | lens results
36
+ Stage 5: Synthesizer
37
+ +------------------------------------------+
38
+ | spawn synthesizer (fork_turns: "none") |
39
+ | -> wait -> close |
40
+ +----------------------+-------------------+
41
+ | distilled_insights
42
+ Stage 6-8: Route -> Write -> Report
43
+ ```
44
+ </purpose>
45
+
46
+ <context>
47
+ ```bash
48
+ $quality-retrospective
49
+ $quality-retrospective "3"
50
+ $quality-retrospective "2..4"
51
+ $quality-retrospective "--all"
52
+ $quality-retrospective "3 --lens technical --no-route"
53
+ $quality-retrospective "3 --compare 2 -y"
54
+ ```
55
+
56
+ **Flags**:
57
+ - No phase argument -> `scan` mode: report unreviewed completed phases, prompt selection
58
+ - `<N>` -> `single` mode: retrospect phase N
59
+ - `<N>..<M>` -> `range` mode: retrospect phases N through M (inclusive)
60
+ - `--all` -> batch mode: re-run for every completed phase
61
+ - `--lens <name>` -- restrict to one lens (repeatable): `technical|process|quality|decision`
62
+ - `--no-route` -- produce retrospective.{md,json} only; skip auto-creation of spec/note/issue
63
+ - `--compare <M>` -- emit a delta section vs phase M's prior retrospective
64
+ - `-y` -- accept all routing recommendations without prompting
65
+
66
+ When `-y`: Accept all routing recommendations without prompting. Route all insights automatically.
67
+
68
+ **Storage written**:
69
+ - `{target_dir}/retrospective.md` -- human-readable record (target_dir resolved via state.json artifact registry to `.workflow/scratch/{YYYYMMDD}-{type}-{slug}/`)
70
+ - `{target_dir}/retrospective.json` -- structured record
71
+ - `.workflow/specs/{category-file}.md` -- `<spec-entry>` entries appended to matching category files (one per spec-routed insight)
72
+ - `.workflow/issues/issues.jsonl` -- appended issue rows (`source: "retrospective"`)
73
+ - `.workflow/knowhow/TIP-*.md` -- knowhow tips (via `manage-knowhow-capture` skill)
74
+ - `.workflow/learning/lessons.jsonl` -- append-only insight log
75
+ - `.workflow/learning/learning-index.json` -- updated searchable index
76
+
77
+ **Storage read (never modified)** — all resolved via `state.json.artifacts[]`:
78
+ ```
79
+ related = artifacts.filter(a =>
80
+ a.phase === target_phase && a.milestone === current_milestone
81
+ ).sort_by(completed_at asc)
82
+ ```
83
+ Each artifact's type determines its outputs at `.workflow/{a.path}/`:
84
+ - **execute** → index.json, plan.json, .task/TASK-*.json, .summaries/TASK-*-summary.md
85
+ - **verify** → verification.json
86
+ - **review** → review.json (findings, verdict, severity distribution)
87
+ - **debug** → understanding.md, evidence.ndjson (root causes, fix directions)
88
+ - **test** → uat.md, .tests/ (UAT results, gaps, coverage)
89
+ - Also reads: `.workflow/issues/issues.jsonl`, `.workflow/state.json`
90
+
91
+ ### Agent Registry
92
+
93
+ | Agent | task_name | fork_turns | Responsibility |
94
+ |-------|-----------|------------|----------------|
95
+ | Context Agent | `ctx` | "none" | Load all phase artifacts: index.json, plan.json, verification.json, review.json, uat.md, issues.jsonl, task summaries |
96
+ | Technical Lens | `lens-tech` | "all" | Technical debt, architecture decisions, code quality gaps, performance issues |
97
+ | Process Lens | `lens-proc` | "all" | Workflow efficiency, collaboration patterns, planning accuracy, bottlenecks |
98
+ | Quality Lens | `lens-qual` | "all" | Test coverage gaps, verification failures, UAT issues, quality gate outcomes |
99
+ | Decision Lens | `lens-dec` | "all" | Key decisions made, tradeoffs accepted, ADR candidates, reversibility |
100
+ | Synthesizer | `synthesizer` | "none" | Merge lens results, deduplicate insights, classify routing targets |
101
+
102
+ ### Fork Turns Strategy
103
+
104
+ | Agent | task_name | fork_turns | fork_from | Rationale |
105
+ |-------|-----------|------------|-----------|-----------|
106
+ | Context Agent | `ctx` | "none" | -- | Independent artifact loader; clean start |
107
+ | Technical Lens | `lens-tech` | "all" | `ctx` | Inherits loaded artifacts -- no redundant file reads |
108
+ | Process Lens | `lens-proc` | "all" | `ctx` | Inherits loaded artifacts -- no redundant file reads |
109
+ | Quality Lens | `lens-qual` | "all" | `ctx` | Inherits loaded artifacts -- no redundant file reads |
110
+ | Decision Lens | `lens-dec` | "all" | `ctx` | Inherits loaded artifacts -- no redundant file reads |
111
+ | Synthesizer | `synthesizer` | "none" | -- | Clean context; receives lens results via message |
112
+
113
+ **Context-Agent Lifecycle**: Spawn `ctx` first -> `wait_agent` -> spawn all lens agents (`fork_turns: "all"`) -> `wait_agent` batch for lenses -> `close_agent` lenses -> `close_agent ctx` LAST.
114
+
115
+ > **fork_turns semantics**: `fork_turns: "all"` means the spawned agent inherits the *orchestrator's* current conversation context -- not the ctx agent's own context. When `wait_agent` for ctx returns, the ctx agent's completed artifact summaries are visible in the orchestrator's context. Lens agents forked after that point therefore inherit those summaries. Lens agents do **not** fork directly from `ctx`; the `fork_from: ctx` column above is conceptual shorthand for this sequencing.
116
+ </context>
117
+
118
+ <invariants>
119
+ 1. **Read-only until Stage 6**: Stages 1-5 must not write any files -- only read and analyze
120
+ 2. **Context-agent spawns first**: `ctx` must complete before any lens agent is spawned
121
+ 3. **Parallel lens dispatch**: All active lens agents spawned in a single batch, then `wait_agent` for all together -- never sequentially
122
+ 4. **Context-agent closes last**: Close all lens agents before closing `ctx`
123
+ 5. **Synthesizer is isolated**: `fork_turns: "none"` -- receives lens results only via message, not full conversation history
124
+ 6. **Stable INS-ids**: `INS-{8hex}` from `hash(phase_num + lens + title)` -- re-runs do not create duplicates
125
+ 7. **Archive before overwrite**: Move existing retrospective.{md,json} to `.history/` with timestamp before writing new ones
126
+ 8. **Spec learnings.md backward-compat**: Append to it only if it already exists -- never create it
127
+ 9. **Route confirmation**: Unless `-y`, present routing table and ask per-group before writing spec/issue/knowhow
128
+ 10. **Lessons always written**: Append to `lessons.jsonl` regardless of `--no-route` -- routing only controls spec/issue/knowhow creation
129
+ </invariants>
130
+
131
+ <execution>
132
+
133
+ ### Session Initialization
134
+
135
+ Update plan: Stages 1-3 → in_progress; Stages 4-8 → pending.
136
+
137
+ ### Stages 1-3: Parse Mode and Validate Artifacts
138
+
139
+ **Stage 1: Parse mode** from `$ARGUMENTS`:
140
+
141
+ | First non-flag token | Mode |
142
+ |---------------------|------|
143
+ | (empty) | scan |
144
+ | `<N>` (single digit/number) | single |
145
+ | `<N>..<M>` | range |
146
+ | `--all` flag present | all |
147
+
148
+ Validate `--lens` values. If `--compare <M>` present, require single mode.
149
+
150
+ **Stage 2: Validate phase artifacts**. For each target phase:
151
+ - Phase directory must exist (resolved via state.json artifact registry to `.workflow/scratch/{YYYYMMDD}-{type}-{slug}/`)
152
+ - `index.json` must show `status: "completed"`
153
+ - `.task/` directory must exist with at least one `TASK-*.json`
154
+ - If existing `retrospective.json` found and not `--all`: emit W002, prompt overwrite
155
+
156
+ **Stage 3: Scan mode** -- list all completed phases without retrospective.json. Prompt user to select.
157
+
158
+ Update plan: Stages 1-3 → completed; Stage 4 → in_progress.
159
+
160
+ ### Stage 4: Context-Agent Fork + Parallel Lens Analysis
161
+
162
+ **Archive if overwriting**:
163
+ If existing `retrospective.{md,json}` present, move to `{artifact_dir}/.history/` with timestamp suffix before spawning.
164
+
165
+ **Step 4a: Spawn context agent**
166
+ ```javascript
167
+ spawn_agent({
168
+ task_name: "ctx",
169
+ fork_turns: "none",
170
+ message: `Load and summarize all phase ${targetPhase} artifacts for retrospective.
171
+ 1. Query state.json artifacts[] for phase === ${targetPhase} && milestone === current_milestone
172
+ 2. Load per-artifact outputs (execute→index/plan/tasks/summaries, verify→verification.json, review→review.json, debug→understanding/evidence, test→uat/tests)
173
+ 3. Filter issues.jsonl for this phase; read state.json for project context
174
+ EXPECTED: Goals vs outcomes, completion rates, verification/review/UAT results, issue counts, key metrics`
175
+ })
176
+ wait_agent({ timeout_ms: 1800000 })
177
+ ```
178
+
179
+ **Step 4b: Fork 4 lens agents** (only active lenses based on `--lens` flag; default: all 4)
180
+
181
+ All lenses use `fork_turns: "all"` and return the same JSON array schema:
182
+ ```json
183
+ [{ "title": "<80 chars>", "summary": "...", "category": "pattern|antipattern|decision|tool|gotcha|technique",
184
+ "routing": "spec|issue|knowhow|none", "severity": "critical|high|medium|low", "evidence": "<file:line>" }]
185
+ ```
186
+
187
+ | Agent | task_name | Focus |
188
+ |-------|-----------|-------|
189
+ | Technical | `lens-tech` | Tech debt, architecture decisions, code quality, performance, security, dependencies |
190
+ | Process | `lens-proc` | Planning accuracy, collaboration, workflow efficiency, communication, process improvements |
191
+ | Quality | `lens-qual` | Test coverage gaps, quality gates, UAT failures, review blockers, missing scenarios |
192
+ | Decision | `lens-dec` | Key decisions, tradeoffs, ADR candidates, reversibility, retrospective judgment |
193
+
194
+ ```javascript
195
+ // Spawn all 4 lenses in parallel
196
+ ["lens-tech", "lens-proc", "lens-qual", "lens-dec"].forEach(name =>
197
+ spawn_agent({ task_name: name, fork_turns: "all", message: `<lens-specific prompt>` })
198
+ )
199
+ const lensResults = wait_agent({ timeout_ms: 1800000 })
200
+
201
+ // Close lenses first, then context agent LAST
202
+ ["lens-tech", "lens-proc", "lens-qual", "lens-dec"].forEach(n => close_agent({ target: n }))
203
+ close_agent({ target: "ctx" })
204
+ ```
205
+
206
+ If `lensResults.timed_out` for any agent: emit W001, continue with partial coverage.
207
+
208
+ ### Stage 5: Synthesize Insights
209
+
210
+ ```javascript
211
+ spawn_agent({
212
+ task_name: "synthesizer",
213
+ fork_turns: "none",
214
+ message: `Merge and distill insights from 4 lens analyses.
215
+ Input: ${JSON.stringify(lensResults.status)}
216
+ 1. Merge all insights, deduplicate (same issue across lenses → keep higher severity, combine evidence)
217
+ 2. Generate stable INS-{8hex} id: hash(phase_num + lens + title)
218
+ 3. Classify routing: spec | issue | knowhow | none
219
+ 4. Produce phase-level metrics summary
220
+ EXPECTED JSON: { insights: [{id,title,summary,category,lens,routing,severity,evidence}],
221
+ metrics: {tasks_completed,tasks_failed,test_pass_rate,review_issues_count,uat_scenarios_passed},
222
+ routing_summary: {spec:N, issue:N, knowhow:N, none:N} }`
223
+ })
224
+ const synthResult = wait_agent({ timeout_ms: 1800000 })
225
+ close_agent({ target: "synthesizer" })
226
+ ```
227
+
228
+ Update plan: Stages 1-5 → completed; Stage 6 → in_progress.
229
+
230
+ ### Stage 6: Route Outputs
231
+
232
+ If `--no-route`: skip this stage.
233
+
234
+ For each insight in `synthResult.insights`, route based on `routing` field:
235
+
236
+ **Spec routing** (`routing: "spec"`):
237
+ Map category (pattern/convention → `coding`, architecture → `arch`, quality → `quality`). Append `<spec-entry>` with category, auto-extracted keywords, date, source="retrospective", title, summary, evidence, phase/lens/INS-id.
238
+
239
+ **Issue routing** (`routing: "issue"`, severity critical/high):
240
+ Append to `.workflow/issues/issues.jsonl` with `ISS-<date>-<seq>` id, source="retrospective", phase/INS-id context, and history entry.
241
+
242
+ **Memory routing** (`routing: "knowhow"`):
243
+ Invoke `manage-knowhow-capture` skill with tip content and `--tag retrospective,phase-{N}`.
244
+
245
+ If `!AUTO_YES`: present routing table and ask confirmation before routing each group.
246
+
247
+ ### Stage 7: Write Artifacts
248
+
249
+ Write two files to `{target_dir}/`:
250
+ - **retrospective.json**: phase, slug, timestamp, lenses_run, metrics, findings_by_lens, distilled_insights, routing_summary
251
+ - **retrospective.md**: Header with phase/slug/timestamp, metrics table (tasks completed, test pass rate, review issues, UAT scenarios), findings by lens, distilled insights, routing summary
252
+
253
+ Append each insight to `.workflow/learning/lessons.jsonl` and update `learning-index.json`.
254
+
255
+ If `.workflow/specs/learnings.md` already exists, append each insight as `<spec-entry>` (category=`learning`, auto-extract keywords, date=today, source=`retrospective`). Never create the file -- only append if it exists.
256
+
257
+ Update plan: Stages 1-7 → completed; Stage 8 → in_progress.
258
+
259
+ ### Stage 8: Report
260
+
261
+ Display summary: phase, lenses run, insight counts (new vs merged duplicates), routing breakdown (spec/issue/knowhow/lesson counts with target paths), key metrics (task completion, test pass rate, review issues).
262
+
263
+ Next steps: `$manage-status`, `$manage-issue "list --source retrospective"`, `$manage-learn "list --phase <N>"`, `$manage-wiki health`, `$wiki-digest "<phase-topic>"`.
264
+ </execution>
265
+
266
+ <error_codes>
267
+
268
+ | Code | Severity | Description | Stage |
269
+ |------|----------|-------------|-------|
270
+ | E001 | error | `.workflow/` not initialized | parse_input |
271
+ | E002 | error | Unknown `--lens` name | parse_input |
272
+ | E003 | error | `--compare` requires single phase mode | parse_input |
273
+ | E004 | error | Phase has no execution artifacts (no .task/) | load_artifacts |
274
+ | E005 | error | Phase directory not found or phase not completed | scan_unreviewed |
275
+ | W001 | warning | One or more lens agents timed out -- partial coverage | multi_lens_analysis |
276
+ | W002 | warning | Existing retrospective.json found -- prompted to overwrite | scan_unreviewed |
277
+ | W003 | warning | `manage-knowhow-capture` did not return parseable TIP id; fell back to direct write | route_outputs |
278
+ | W004 | warning | `--compare` target phase has no retrospective.json; delta omitted | load_artifacts |
279
+ </error_codes>
280
+
281
+ <success_criteria>
282
+ - [ ] Mode correctly parsed from arguments (scan/single/range/all)
283
+ - [ ] Phase artifacts validated before analysis begins
284
+ - [ ] Context agent loads all artifacts before lens agents spawn
285
+ - [ ] All active lens agents spawned in parallel, waited as batch
286
+ - [ ] Context agent closed last (after all lens agents)
287
+ - [ ] Synthesizer produces deduplicated insights with stable INS-ids
288
+ - [ ] Routing applied per insight (spec/issue/knowhow/none) with confirmation
289
+ - [ ] retrospective.{md,json} written to phase directory
290
+ - [ ] Lessons appended to lessons.jsonl regardless of --no-route flag
291
+ - [ ] Existing retrospective archived before overwrite
292
+ </success_criteria>
@@ -0,0 +1,364 @@
1
+ ---
2
+ name: quality-review
3
+ description: Tiered code review via CSV wave pipeline. Decomposes into 6 dimension agents running in parallel, with optional deep-dive aggregation wave. Replaces quality-review command.
4
+ argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"<phase> [--level quick|standard|deep] [--dimensions list]\""
5
+ allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ <purpose>
9
+ Wave-based multi-dimensional code review using `spawn_agents_on_csv`. Decomposes review into independent dimension agents (Wave 1), then aggregates findings into a unified report with verdict (Wave 2).
10
+
11
+ **Core workflow**: Collect Files -> Decompose Dimensions -> Parallel Review -> Aggregate + Verdict
12
+
13
+ ```
14
+ +---------------------------------------------------------------------------+
15
+ | CODE REVIEW CSV WAVE WORKFLOW |
16
+ +---------------------------------------------------------------------------+
17
+ | |
18
+ | Phase 1: Phase Resolution -> CSV |
19
+ | +-- Resolve phase directory from arguments |
20
+ | +-- Collect changed files from task summaries |
21
+ | +-- Auto-detect review level (quick/standard/deep) |
22
+ | +-- Determine active dimensions |
23
+ | +-- Generate tasks.csv with one row per dimension |
24
+ | +-- User validates dimension breakdown (skip if -y) |
25
+ | |
26
+ | Phase 2: Wave Execution Engine |
27
+ | +-- Wave 1: Dimension Review (parallel) |
28
+ | | +-- Each dimension agent reviews all changed files |
29
+ | | +-- Agent classifies findings by severity |
30
+ | | +-- Discoveries shared via board (patterns, conventions) |
31
+ | | +-- Results: severity_counts + top_issues per dimension |
32
+ | +-- Wave 2: Aggregation + Deep-Dive (if needed) |
33
+ | | +-- Aggregate all dimension findings |
34
+ | | +-- If criticals > 0 (standard) or always (deep): deep-dive |
35
+ | | +-- Cross-dimension impact analysis |
36
+ | | +-- Generate verdict: PASS / WARN / BLOCK |
37
+ | +-- discoveries.ndjson shared across all waves (append-only) |
38
+ | |
39
+ | Phase 3: Results Aggregation |
40
+ | +-- Export results.csv + review.json |
41
+ | +-- Generate context.md with all findings |
42
+ | +-- Auto-create issues for qualifying findings |
43
+ | +-- Update phase index.json with review status |
44
+ | +-- Display summary with verdict + next steps |
45
+ | |
46
+ +---------------------------------------------------------------------------+
47
+ ```
48
+ </purpose>
49
+
50
+ <context>
51
+ ```bash
52
+ $quality-review "3"
53
+ $quality-review -c 6 "3 --level deep"
54
+ $quality-review -y "3 --dimensions security,performance"
55
+ $quality-review --continue "20260318-review-P3-auth"
56
+ ```
57
+
58
+ **Flags**:
59
+ - `-y, --yes`: Skip all confirmations (auto mode)
60
+ - `-c, --concurrency N`: Max concurrent agents within each wave (default: 6)
61
+ - `--continue`: Resume existing session
62
+
63
+ When `--yes` or `-y`: Auto-confirm dimension selection, skip interactive validation, use defaults for level detection.
64
+
65
+ **Output Directory**: `.workflow/.csv-wave/{session-id}/`
66
+ **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report) + `review.json` (structured review output)
67
+ </context>
68
+
69
+ <csv_schema>
70
+
71
+ ### tasks.csv (Master State)
72
+
73
+ ```csv
74
+ id,title,description,dimension,changed_files,project_specs,review_level,deps,context_from,wave,status,findings,severity_counts,top_issues,error
75
+ "1","Correctness Review","Review all changed files for correctness: logic errors, missing edge cases, incorrect return values, null/undefined handling, off-by-one errors. Classify each finding as critical/high/medium/low with file:line references.","correctness","src/auth/login.ts;src/auth/register.ts;src/utils/validation.ts","Existing patterns use Result type for error handling","standard","","","1","","","","",""
76
+ "2","Security Review","Review all changed files for security vulnerabilities: injection flaws, XSS, CSRF, auth bypass, sensitive data exposure, insecure crypto. Reference OWASP Top 10. Classify each finding.","security","src/auth/login.ts;src/auth/register.ts;src/utils/validation.ts","Auth uses bcrypt + JWT","standard","","","1","","","","",""
77
+ "3","Performance Review","Review all changed files for performance issues: N+1 queries, unnecessary re-renders, memory leaks, blocking operations, unoptimized algorithms.","performance","src/auth/login.ts;src/auth/register.ts;src/utils/validation.ts","","standard","","","1","","","","",""
78
+ "4","Architecture Review","Review all changed files for architecture issues: layer violations, circular dependencies, inappropriate coupling, missing abstractions, SRP violations.","architecture","src/auth/login.ts;src/auth/register.ts;src/utils/validation.ts","ESM modules, strict TypeScript","standard","","","1","","","","",""
79
+ "5","Maintainability Review","Review all changed files for maintainability: code duplication, overly complex functions, poor naming, missing types, unclear control flow.","maintainability","src/auth/login.ts;src/auth/register.ts;src/utils/validation.ts","","standard","","","1","","","","",""
80
+ "6","Best Practices Review","Review all changed files for best-practice violations: error handling gaps, missing validation, hardcoded values, deprecated API usage, inconsistent patterns.","best-practices","src/auth/login.ts;src/auth/register.ts;src/utils/validation.ts","","standard","","","1","","","","",""
81
+ "7","Aggregate + Deep-Dive","Aggregate all dimension findings. Calculate severity distribution. Determine verdict (PASS/WARN/BLOCK). If critical findings exist, perform deep-dive with cross-file impact analysis.","aggregation","src/auth/login.ts;src/auth/register.ts;src/utils/validation.ts","","standard","1;2;3;4;5;6","1;2;3;4;5;6","2","","","","",""
82
+ ```
83
+
84
+ **Columns**:
85
+
86
+ | Column | Phase | Description |
87
+ |--------|-------|-------------|
88
+ | `id` | Input | Unique task identifier (string) |
89
+ | `title` | Input | Short task title |
90
+ | `description` | Input | Detailed review instructions for this dimension |
91
+ | `dimension` | Input | Review dimension: correctness/security/performance/architecture/maintainability/best-practices/aggregation |
92
+ | `changed_files` | Input | Semicolon-separated file paths to review |
93
+ | `project_specs` | Input | Relevant project specs/conventions context |
94
+ | `review_level` | Input | quick/standard/deep -- controls depth |
95
+ | `deps` | Input | Semicolon-separated dependency task IDs |
96
+ | `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
97
+ | `wave` | Computed | Wave number (1 = dimension review, 2 = aggregation) |
98
+ | `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
99
+ | `findings` | Output | Key review findings summary (max 500 chars) |
100
+ | `severity_counts` | Output | JSON: `{"critical":N,"high":N,"medium":N,"low":N}` |
101
+ | `top_issues` | Output | Top 5 issues with `[severity] description (file:line)` format |
102
+ | `error` | Output | Error message if failed |
103
+
104
+ ### Per-Wave CSV (Temporary)
105
+
106
+ Each wave generates `wave-{N}.csv` with extra `prev_context` column.
107
+
108
+ ### Output Artifacts
109
+
110
+ | File | Purpose | Lifecycle |
111
+ |------|---------|-----------|
112
+ | `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
113
+ | `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
114
+ | `results.csv` | Final export of all task results | Created in Phase 3 |
115
+ | `discoveries.ndjson` | Shared exploration board | Append-only, carries across waves |
116
+ | `context.md` | Human-readable review report | Created in Phase 3 |
117
+ | `review.json` | Structured review output for downstream | Created in Phase 3 |
118
+
119
+ ### Session Structure
120
+
121
+ ```
122
+ .workflow/.csv-wave/{YYYYMMDD}-review-P{N}-{slug}/
123
+ +-- tasks.csv
124
+ +-- results.csv
125
+ +-- discoveries.ndjson
126
+ +-- context.md
127
+ +-- review.json
128
+ +-- wave-{N}.csv (temporary)
129
+ ```
130
+ </csv_schema>
131
+
132
+ <invariants>
133
+ 1. **Start Immediately**: First action is session initialization, then Phase 1
134
+ 2. **Wave Order is Sacred**: Never execute wave 2 before wave 1 completes and results are merged
135
+ 3. **CSV is Source of Truth**: Master tasks.csv holds all state
136
+ 4. **Context Propagation**: prev_context built from master CSV, not from memory
137
+ 5. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
138
+ 6. **Skip on Failure**: If all dimension agents failed, skip aggregation
139
+ 7. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
140
+ 8. **DO NOT STOP**: Continuous execution until all waves complete
141
+ </invariants>
142
+
143
+ <execution>
144
+
145
+ ### Session Initialization
146
+
147
+ Parse `$ARGUMENTS` to extract:
148
+ - `AUTO_YES` from `--yes` / `-y`
149
+ - `continueMode` from `--continue`
150
+ - `maxConcurrency` from `--concurrency N` / `-c N` (default: 6)
151
+ - `levelMatch` from `--level quick|standard|deep`
152
+ - `dimsMatch` from `--dimensions <list>`
153
+ - `phaseArg` = remaining text after stripping all flags
154
+
155
+ Session ID: `{YYYYMMDD}-review-P{phaseArg}-{phaseSlug}` (phaseSlug from index.json or roadmap)
156
+ Session folder: `.workflow/.csv-wave/{sessionId}/` — create via `mkdir -p`
157
+
158
+ ### Phase 1: Phase Resolution -> CSV
159
+
160
+ **Objective**: Resolve phase, collect changed files, determine review level, generate tasks.csv.
161
+
162
+ **Decomposition Rules**:
163
+
164
+ 1. **Phase resolution**: Resolve `{phaseArg}` via `state.json` artifact registry to `.workflow/scratch/{YYYYMMDD}-{type}-{slug}/`
165
+ 2. **Related session discovery**: Query `state.json.artifacts[]` for matching phase + milestone. Extract prior quality context (verdicts, root causes, UAT gaps) from artifact outputs by type (execute → .summaries/.task/, review → review.json, debug → understanding.md, test → uat.md)
166
+ 3. **File collection**: Read `.task/TASK-*.json` → collect `files[].path` where action != "read"
167
+ 4. **Level detection**:
168
+
169
+ | Condition | Level |
170
+ |-----------|-------|
171
+ | `--level` flag provided | Use explicit level |
172
+ | <=3 changed files | quick |
173
+ | 4-19 changed files | standard |
174
+ | >=20 files OR phase marked critical | deep |
175
+
176
+ 5. **Dimension selection**:
177
+
178
+ | Level | Dimensions |
179
+ |-------|------------|
180
+ | quick | correctness, security |
181
+ | standard | correctness, security, performance, architecture, maintainability, best-practices |
182
+ | deep | all 6 + forced deep-dive in aggregation |
183
+
184
+ If `--dimensions` flag provided, override with explicit list.
185
+
186
+ 6. **Specs loading**: Read `.workflow/specs/` for project conventions (unless `--skip-specs`)
187
+ 7. **CSV generation**: One row per dimension + one aggregation row
188
+
189
+ **Wave computation**: Simple 2-wave -- all dimension tasks = wave 1, aggregation = wave 2.
190
+
191
+ **User validation**: Display task breakdown (skip if AUTO_YES).
192
+
193
+ ### Phase 2: Wave Execution Engine
194
+
195
+ **Objective**: Execute dimension reviews wave-by-wave via spawn_agents_on_csv.
196
+
197
+ #### Wave 1: Dimension Reviews (Parallel)
198
+
199
+ Filter master `tasks.csv` for `wave == 1 AND status == pending` → write `wave-1.csv` (no prev_context needed).
200
+
201
+ ```javascript
202
+ spawn_agents_on_csv({
203
+ csv_path: `${sessionFolder}/wave-1.csv`,
204
+ id_column: "id",
205
+ instruction: buildReviewInstruction(sessionFolder),
206
+ max_concurrency: maxConcurrency,
207
+ max_runtime_seconds: 3600,
208
+ output_csv_path: `${sessionFolder}/wave-1-results.csv`,
209
+ output_schema: {
210
+ type: "object",
211
+ properties: {
212
+ id: { type: "string" },
213
+ status: { type: "string", enum: ["completed", "failed"] },
214
+ findings: { type: "string" },
215
+ severity_counts: { type: "string" },
216
+ top_issues: { type: "string" },
217
+ error: { type: "string" }
218
+ },
219
+ required: ["id", "status", "findings"]
220
+ }
221
+ })
222
+ ```
223
+
224
+ Merge `wave-1-results.csv` into master `tasks.csv`, delete `wave-1.csv`.
225
+
226
+ #### Wave 2: Aggregation + Deep-Dive
227
+
228
+ Filter master `tasks.csv` for `wave == 2 AND status == pending`. If all wave 1 tasks failed, skip aggregation.
229
+
230
+ Build `prev_context` from wave 1 findings (format: `[Task N: Title] summary...` per task).
231
+ Write `wave-2.csv` with `prev_context` column → execute `spawn_agents_on_csv` → merge results → delete `wave-2.csv`.
232
+
233
+ ### Phase 3: Results Aggregation
234
+
235
+ **Objective**: Generate final results and human-readable report.
236
+
237
+ Export master `tasks.csv` as `results.csv`. Build `review.json`:
238
+
239
+ ```json
240
+ {
241
+ "phase": "<phase>",
242
+ "level": "<level>",
243
+ "verdict": "PASS|WARN|BLOCK",
244
+ "severity_distribution": { "critical": 0, "high": 0, "medium": 0, "low": 0 },
245
+ "dimensions": [
246
+ { "dimension": "correctness", "status": "completed", "severity_counts": {...}, "top_issues": [...] }
247
+ ],
248
+ "deep_dive": { "performed": true/false, "iterations": N, "impact_analysis": "..." },
249
+ "issues_created": [],
250
+ "timestamp": "<ISO>"
251
+ }
252
+ ```
253
+
254
+ Generate `context.md`:
255
+
256
+ ```markdown
257
+ # Code Review Report -- Phase {phase}
258
+
259
+ ## Summary
260
+ - Level: {level}
261
+ - Files reviewed: {file_count}
262
+ - Dimensions: {dimension_count}
263
+ - Verdict: **{verdict}**
264
+
265
+ ## Severity Distribution
266
+ | Severity | Count |
267
+ |----------|-------|
268
+ | Critical | {N} |
269
+ | High | {N} |
270
+ | Medium | {N} |
271
+ | Low | {N} |
272
+
273
+ ## Dimension Results
274
+ ### {dimension_name}
275
+ {findings}
276
+
277
+ **Top Issues:**
278
+ {top_issues}
279
+
280
+ ## Deep-Dive Analysis
281
+ {if performed: impact analysis results}
282
+
283
+ ## Issues Created
284
+ {list of created issue IDs}
285
+ ```
286
+
287
+ **Verdict determination**:
288
+
289
+ | Condition | Verdict |
290
+ |-----------|---------|
291
+ | Any critical findings | BLOCK |
292
+ | High findings > 3 | BLOCK |
293
+ | Any high findings | WARN |
294
+ | Medium findings > 5 | WARN |
295
+ | Otherwise | PASS |
296
+
297
+ **Issue creation** by level threshold:
298
+
299
+ | Level | Create Issues For |
300
+ |-------|------------------|
301
+ | quick | critical only |
302
+ | standard | critical + high |
303
+ | deep | critical + high + medium |
304
+
305
+ **Phase index update**: Update `{artifact_dir}/index.json` with review status.
306
+
307
+ **Register artifact**: Append to `state.json.artifacts[]` with `type: "review"`, `id: REV-NNN`, `path: "scratch/{YYYYMMDD}-review-P{N}-{slug}"`, `depends_on: exec_art.id`. Output directory is independent scratch, not shared with plan.
308
+
309
+ Display summary.
310
+
311
+ ### Shared Discovery Board Protocol
312
+
313
+ #### Standard Discovery Types
314
+
315
+ | Type | Dedup Key | Data Schema | Description |
316
+ |------|-----------|-------------|-------------|
317
+ | `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
318
+ | `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
319
+ | `convention` | singleton | `{naming, imports, formatting}` | Project code conventions |
320
+ | `blocker` | `data.issue` | `{issue, severity, impact}` | Blocking issue found |
321
+ | `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack info |
322
+
323
+ #### Domain Discovery Types
324
+
325
+ | Type | Dedup Key | Data Schema | Description |
326
+ |------|-----------|-------------|-------------|
327
+ | `vulnerability` | `data.location` | `{location, type, severity, cwe}` | Security vulnerability |
328
+ | `code_smell` | `data.location` | `{location, type, severity, description}` | Code quality issue |
329
+ | `performance_hotspot` | `data.location` | `{location, type, impact}` | Performance issue |
330
+ | `architecture_violation` | `data.location` | `{location, rule, description}` | Architecture rule violation |
331
+
332
+ #### Protocol
333
+
334
+ Read `{session_folder}/discoveries.ndjson` before own review. Deduplicate by type + dedup key before writing. Append-only — never modify or delete.
335
+
336
+ ```bash
337
+ echo '{"ts":"<ISO>","worker":"{id}","type":"vulnerability","data":{"location":"src/auth/login.ts:42","type":"sql_injection","severity":"critical","cwe":"CWE-89"}}' >> {session_folder}/discoveries.ndjson
338
+ ```
339
+ </execution>
340
+
341
+ <error_codes>
342
+
343
+ | Error | Resolution |
344
+ |-------|------------|
345
+ | Phase directory not found | Abort with error: "Phase {N} not found" |
346
+ | No task summaries found | Abort with error: "No execution results -- run execute first" |
347
+ | No changed files | Abort with error: "No changed files detected" |
348
+ | Dimension agent timeout | Mark as failed, skip dependent aggregation if all failed |
349
+ | Aggregation agent failed | Use wave 1 results directly, verdict based on raw counts |
350
+ | CSV parse error | Validate format, show line number |
351
+ | discoveries.ndjson corrupt | Ignore malformed lines |
352
+ | Continue mode: no session found | List available sessions |
353
+ </error_codes>
354
+
355
+ <success_criteria>
356
+ - [ ] Session folder created with valid tasks.csv
357
+ - [ ] All dimension reviews executed in parallel (wave 1)
358
+ - [ ] Aggregation + deep-dive executed (wave 2)
359
+ - [ ] review.json produced with verdict and severity distribution
360
+ - [ ] context.md produced with full review report
361
+ - [ ] Issues auto-created for qualifying severity findings
362
+ - [ ] Phase index.json updated with review status
363
+ - [ ] discoveries.ndjson append-only throughout
364
+ </success_criteria>