pi-maestro-flow 0.2.0 → 0.3.1

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 (235) hide show
  1. package/README.md +44 -72
  2. package/agents/cross-role-reviewer.md +1 -1
  3. package/agents/impeccable-agent.md +1 -1
  4. package/agents/ralph-executor.md +1 -1
  5. package/agents/team-worker.md +1 -1
  6. package/agents/workflow-analyzer.md +1 -1
  7. package/agents/workflow-codebase-mapper.md +1 -1
  8. package/agents/workflow-collab-planner.md +1 -1
  9. package/agents/workflow-debugger.md +1 -1
  10. package/agents/workflow-executor.md +1 -1
  11. package/agents/workflow-integration-checker.md +1 -1
  12. package/agents/workflow-nyquist-auditor.md +1 -1
  13. package/agents/workflow-phase-researcher.md +1 -1
  14. package/agents/workflow-planner.md +1 -1
  15. package/agents/workflow-project-researcher.md +1 -1
  16. package/agents/workflow-reviewer.md +1 -1
  17. package/agents/workflow-verifier.md +1 -1
  18. package/package.json +18 -4
  19. package/skills/codify-to-knowhow/SKILL.md +1 -1
  20. package/skills/delegation-check/SKILL.md +1 -1
  21. package/skills/domain-add/SKILL.md +5 -5
  22. package/skills/insight-challenge/SKILL.md +1 -1
  23. package/skills/learn-decompose/SKILL.md +4 -4
  24. package/skills/learn-follow/SKILL.md +5 -5
  25. package/skills/learn-investigate/SKILL.md +5 -5
  26. package/skills/learn-second-opinion/SKILL.md +5 -5
  27. package/skills/maestro/SKILL.md +8 -8
  28. package/skills/maestro-amend/SKILL.md +4 -4
  29. package/skills/maestro-analyze/SKILL.md +9 -9
  30. package/skills/maestro-blueprint/SKILL.md +7 -7
  31. package/skills/maestro-brainstorm/SKILL.md +10 -10
  32. package/skills/maestro-collab/SKILL.md +4 -4
  33. package/skills/maestro-companion/SKILL.md +3 -3
  34. package/skills/maestro-composer/SKILL.md +10 -10
  35. package/skills/maestro-execute/SKILL.md +8 -8
  36. package/skills/maestro-fork/SKILL.md +7 -7
  37. package/skills/maestro-grill/SKILL.md +12 -12
  38. package/skills/maestro-guard/SKILL.md +5 -5
  39. package/skills/maestro-help/SKILL.md +3 -3
  40. package/skills/maestro-impeccable/SKILL.md +7 -7
  41. package/skills/maestro-init/SKILL.md +8 -8
  42. package/skills/maestro-merge/SKILL.md +6 -6
  43. package/skills/maestro-milestone-audit/SKILL.md +3 -3
  44. package/skills/maestro-milestone-complete/SKILL.md +8 -8
  45. package/skills/maestro-milestone-release/SKILL.md +9 -9
  46. package/skills/maestro-next/SKILL.md +5 -5
  47. package/skills/maestro-overlay/SKILL.md +19 -19
  48. package/skills/maestro-plan/SKILL.md +8 -8
  49. package/skills/maestro-player/SKILL.md +5 -5
  50. package/skills/maestro-quick/SKILL.md +5 -5
  51. package/skills/maestro-ralph/SKILL.md +15 -15
  52. package/skills/maestro-ralph-cli/SKILL.md +6 -6
  53. package/skills/maestro-ralph-cli-execute/SKILL.md +2 -2
  54. package/skills/maestro-ralph-execute/SKILL.md +4 -4
  55. package/skills/maestro-ralph-v2/SKILL.md +17 -17
  56. package/skills/maestro-roadmap/SKILL.md +7 -7
  57. package/skills/maestro-swarm-workflow/SKILL.md +9 -9
  58. package/skills/maestro-tools-execute/SKILL.md +5 -5
  59. package/skills/maestro-tools-register/SKILL.md +7 -7
  60. package/skills/maestro-ui-codify/SKILL.md +8 -8
  61. package/skills/maestro-universal-workflow/SKILL.md +15 -15
  62. package/skills/maestro-update/SKILL.md +10 -10
  63. package/skills/manage-codebase-rebuild/SKILL.md +4 -4
  64. package/skills/manage-drift-realign/SKILL.md +7 -7
  65. package/skills/manage-harvest/SKILL.md +5 -5
  66. package/skills/manage-issue/SKILL.md +4 -4
  67. package/skills/manage-issue-discover/SKILL.md +7 -7
  68. package/skills/manage-kg-extractors/SKILL.md +3 -3
  69. package/skills/manage-knowhow/SKILL.md +3 -3
  70. package/skills/manage-knowhow-capture/SKILL.md +4 -4
  71. package/skills/manage-knowledge-audit/SKILL.md +5 -5
  72. package/skills/manage-status/SKILL.md +3 -3
  73. package/skills/manage-wiki/SKILL.md +5 -5
  74. package/skills/odyssey-debug/SKILL.md +13 -13
  75. package/skills/odyssey-improve/SKILL.md +15 -15
  76. package/skills/odyssey-planex/SKILL.md +16 -16
  77. package/skills/odyssey-review-test-fix/SKILL.md +11 -11
  78. package/skills/odyssey-ui/SKILL.md +10 -10
  79. package/skills/prompt-generator/SKILL.md +5 -5
  80. package/skills/quality-auto-test/SKILL.md +3 -3
  81. package/skills/quality-debug/SKILL.md +3 -3
  82. package/skills/quality-refactor/SKILL.md +3 -3
  83. package/skills/quality-retrospective/SKILL.md +9 -9
  84. package/skills/quality-review/SKILL.md +4 -4
  85. package/skills/quality-sync/SKILL.md +3 -3
  86. package/skills/quality-test/SKILL.md +4 -4
  87. package/skills/scholar-anti-ai-writing/SKILL.md +1 -1
  88. package/skills/scholar-citation-verify/SKILL.md +1 -1
  89. package/skills/scholar-experiment/SKILL.md +2 -2
  90. package/skills/scholar-ideation/SKILL.md +7 -7
  91. package/skills/scholar-latex-organizer/SKILL.md +1 -1
  92. package/skills/scholar-publish/SKILL.md +3 -3
  93. package/skills/scholar-rebuttal-pro/SKILL.md +3 -3
  94. package/skills/scholar-review/SKILL.md +1 -1
  95. package/skills/scholar-writing/SKILL.md +1 -1
  96. package/skills/security-audit/SKILL.md +2 -2
  97. package/skills/skill-generator/SKILL.md +3 -3
  98. package/skills/skill-iter-tune/SKILL.md +3 -3
  99. package/skills/skill-simplify/SKILL.md +1 -1
  100. package/skills/skill-tuning/SKILL.md +1 -1
  101. package/skills/spec-add/SKILL.md +5 -5
  102. package/skills/spec-load/SKILL.md +3 -3
  103. package/skills/spec-remove/SKILL.md +4 -4
  104. package/skills/spec-setup/SKILL.md +6 -6
  105. package/skills/team-adversarial-swarm/SKILL.md +5 -5
  106. package/skills/team-arch-opt/SKILL.md +2 -2
  107. package/skills/team-brainstorm/SKILL.md +3 -3
  108. package/skills/team-coordinate/SKILL.md +4 -4
  109. package/skills/team-designer/SKILL.md +1 -1
  110. package/skills/team-executor/SKILL.md +3 -3
  111. package/skills/team-frontend/SKILL.md +2 -2
  112. package/skills/team-frontend-debug/SKILL.md +3 -3
  113. package/skills/team-interactive-craft/SKILL.md +2 -2
  114. package/skills/team-issue/SKILL.md +3 -3
  115. package/skills/team-lifecycle-v4/SKILL.md +4 -4
  116. package/skills/team-motion-design/SKILL.md +2 -2
  117. package/skills/team-perf-opt/SKILL.md +3 -3
  118. package/skills/team-planex/SKILL.md +2 -2
  119. package/skills/team-quality-assurance/SKILL.md +3 -3
  120. package/skills/team-review/SKILL.md +3 -3
  121. package/skills/team-roadmap-dev/SKILL.md +3 -3
  122. package/skills/team-swarm/SKILL.md +4 -4
  123. package/skills/team-tech-debt/SKILL.md +2 -2
  124. package/skills/team-testing/SKILL.md +3 -3
  125. package/skills/team-ui-polish/SKILL.md +2 -2
  126. package/skills/team-uidesign/SKILL.md +2 -2
  127. package/skills/team-ultra-analyze/SKILL.md +4 -4
  128. package/skills/team-ux-improve/SKILL.md +3 -3
  129. package/skills/team-visual-a11y/SKILL.md +2 -2
  130. package/skills/workflow-skill-designer/SKILL.md +8 -8
  131. package/templates/business-test-report.json +68 -0
  132. package/templates/config.json +48 -0
  133. package/templates/context.md +16 -0
  134. package/templates/doc-index.json +11 -0
  135. package/templates/index.json +68 -0
  136. package/templates/issue.json +36 -0
  137. package/templates/plan.json +38 -0
  138. package/templates/project.md +60 -0
  139. package/templates/reflection-log.md +20 -0
  140. package/templates/roadmap.md +45 -0
  141. package/templates/scratch-index.json +19 -0
  142. package/templates/search-tool.json +1 -0
  143. package/templates/search-tools.md +47 -0
  144. package/templates/state.json +18 -0
  145. package/templates/task-summary.md +21 -0
  146. package/templates/task.json +89 -0
  147. package/templates/terminology-template.json +22 -0
  148. package/templates/uat.md +21 -0
  149. package/templates/validation.json +31 -0
  150. package/templates/verification.json +37 -0
  151. package/templates/workflow.md +14 -0
  152. package/templates/worktree-scope.json +9 -0
  153. package/templates/worktrees.json +26 -0
  154. package/workflows/agy-instructions.md +156 -0
  155. package/workflows/analyze.md +768 -0
  156. package/workflows/auto-test.md +705 -0
  157. package/workflows/blueprint.md +406 -0
  158. package/workflows/boundary-grill.md +50 -0
  159. package/workflows/brainstorm.md +508 -0
  160. package/workflows/business-test.md +574 -0
  161. package/workflows/chinese-response.md +25 -0
  162. package/workflows/claude-instructions.md +167 -0
  163. package/workflows/codebase-rebuild.md +267 -0
  164. package/workflows/codebase-refresh.md +168 -0
  165. package/workflows/codex-instructions.md +156 -0
  166. package/workflows/coding-philosophy.md +70 -0
  167. package/workflows/command-authoring.md +823 -0
  168. package/workflows/debug.md +409 -0
  169. package/workflows/delegate-usage.md +99 -0
  170. package/workflows/domain-add.md +121 -0
  171. package/workflows/drift-realign.md +396 -0
  172. package/workflows/execute.md +631 -0
  173. package/workflows/explore-usage.md +93 -0
  174. package/workflows/finish-work.md +124 -0
  175. package/workflows/fork.md +162 -0
  176. package/workflows/grill.md +494 -0
  177. package/workflows/harvest.md +478 -0
  178. package/workflows/impeccable.md +168 -0
  179. package/workflows/init.md +157 -0
  180. package/workflows/instruction-authoring-guide.md +97 -0
  181. package/workflows/integration-test.md +186 -0
  182. package/workflows/interview-mechanics.md +8 -0
  183. package/workflows/issue-analyze.md +20 -0
  184. package/workflows/issue-discover.md +238 -0
  185. package/workflows/issue-execute.md +110 -0
  186. package/workflows/issue-gaps-analyze.codex.md +256 -0
  187. package/workflows/issue-gaps-analyze.md +215 -0
  188. package/workflows/issue-plan.md +110 -0
  189. package/workflows/issue.md +338 -0
  190. package/workflows/knowhow.md +429 -0
  191. package/workflows/knowledge-audit.md +355 -0
  192. package/workflows/learn.md +271 -0
  193. package/workflows/maestro-chain-execute.md +20 -0
  194. package/workflows/maestro-link-coordinate.md +114 -0
  195. package/workflows/maestro-super.md +120 -0
  196. package/workflows/maestro.md +501 -0
  197. package/workflows/map.md +74 -0
  198. package/workflows/merge.md +122 -0
  199. package/workflows/milestone-audit.md +155 -0
  200. package/workflows/milestone-complete.md +167 -0
  201. package/workflows/milestone-release.md +82 -0
  202. package/workflows/odyssey-base-codex.md +305 -0
  203. package/workflows/odyssey-base.md +256 -0
  204. package/workflows/overlays.md +109 -0
  205. package/workflows/plan.md +520 -0
  206. package/workflows/quick.md +350 -0
  207. package/workflows/ralph-amend-goal.md +177 -0
  208. package/workflows/refactor.md +87 -0
  209. package/workflows/retrospective.md +471 -0
  210. package/workflows/review.md +448 -0
  211. package/workflows/roadmap-common.md +193 -0
  212. package/workflows/roadmap.md +106 -0
  213. package/workflows/shell-exec-protocol.md +30 -0
  214. package/workflows/skill-authoring.md +265 -0
  215. package/workflows/spec-generate.md +475 -0
  216. package/workflows/specs-add.md +123 -0
  217. package/workflows/specs-load.md +76 -0
  218. package/workflows/specs-remove.md +104 -0
  219. package/workflows/specs-setup.md +316 -0
  220. package/workflows/status.md +149 -0
  221. package/workflows/sync.md +116 -0
  222. package/workflows/tdd.md +255 -0
  223. package/workflows/test-gen.md +226 -0
  224. package/workflows/test.md +385 -0
  225. package/workflows/tools-spec.md +70 -0
  226. package/workflows/ui-codify-extract.md +372 -0
  227. package/workflows/ui-codify-knowhow.md +258 -0
  228. package/workflows/ui-codify-package.md +159 -0
  229. package/workflows/ui-codify.md +227 -0
  230. package/workflows/ui-design.md +393 -0
  231. package/workflows/ui-style.md +201 -0
  232. package/workflows/verify.md +557 -0
  233. package/workflows/wiki-connect.md +153 -0
  234. package/workflows/wiki-digest.md +180 -0
  235. package/workflows/wiki-manage.md +113 -0
@@ -0,0 +1,448 @@
1
+ # Review Workflow
2
+
3
+ Tiered multi-dimensional code review with parallel agents, severity classification, and iterative deep-dive.
4
+
5
+ ---
6
+
7
+ ## Spec Compliance Pre-Check (Phase 0)
8
+
9
+ 1. Load `convergence.criteria[]` from each `.task/TASK-{NNN}.json`
10
+ 2. For each criterion, grep for functions/endpoints/components named in the criterion
11
+ 3. Classify: **MET** (evidence found) | **UNMET** (not implemented) | **PARTIAL** (incomplete)
12
+
13
+ | Result | Action |
14
+ |--------|--------|
15
+ | All MET | Proceed to Step 1 (dimensional review) |
16
+ | Any UNMET | Report as spec_compliance_failures, add to findings with severity=critical, dimension="spec-compliance" |
17
+ | Any PARTIAL | Report with severity=high |
18
+
19
+ ---
20
+
21
+ ## Receiving Review Feedback
22
+
23
+ 1. **Verify before implementing** — Check each suggestion against codebase reality.
24
+ 2. **Technical acknowledgment only** — No performative agreement. State the fix or provide technical reasoning.
25
+ 3. **Push back when wrong** — If a suggestion would break functionality or violate constraints, explain why with evidence.
26
+ 4. **YAGNI check** — Verify suggested features/abstractions are actually needed.
27
+ 5. **Implement one at a time** — Fix one item, test, then next. NEVER batch-implement all feedback.
28
+ 6. **Priority order** — Blocking (breaks, security) → Simple (typos, imports) → Complex (refactoring, logic).
29
+
30
+ ---
31
+
32
+ ## Phase Resolution
33
+
34
+ ```
35
+ Input: <phase> argument (number or slug)
36
+
37
+ Resolve phase from .workflow/state.json artifacts (type=execute, match by phase number or slug)
38
+ → PHASE_DIR = ".workflow/" + artifact.path
39
+ → Error if not found or no completed tasks
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Flag Processing
45
+
46
+ | Flag | Effect |
47
+ |------|--------|
48
+ | `--level quick\|standard\|deep` | Explicit review level (default: auto-detect) |
49
+ | `--dimensions <list>` | Comma-separated subset (overrides level defaults) |
50
+ | `--skip-specs` | Skip loading project specs |
51
+
52
+ ---
53
+
54
+ ## Review Levels
55
+
56
+ | Aspect | Quick | Standard | Deep |
57
+ |--------|-------|----------|------|
58
+ | **Trigger** | `--level quick`, or auto ≤3 files | Default, or auto 4-19 files | `--level deep`, or auto ≥20 files / critical phase |
59
+ | **Dimensions** | correctness, security | All 6 | All 6 |
60
+ | **Execution** | Inline (no agents) | Parallel agents | Parallel agents |
61
+ | **Deep-Dive** | None | Auto (if critical > 0) | Forced, max 3 iterations |
62
+ | **Issue Creation** | Critical only | Critical + High | Critical + High + Medium |
63
+ | **Cross-File Analysis** | None | Critical files (3+ dims) | Full impact radius |
64
+
65
+ ---
66
+
67
+ ## Step 1: Collect Changed Files
68
+
69
+ ### 1a: Extract from task summaries
70
+
71
+ ```
72
+ Collect changed_files from PHASE_DIR:
73
+ - .summaries/TASK-{NNN}-summary.md → extract referenced file paths (created/modified/deleted)
74
+ - .task/TASK-{NNN}.json → extract files[].path where action is create|modify
75
+ Deduplicate result
76
+ ```
77
+
78
+ ### 1b: Validate files exist
79
+
80
+ ```
81
+ review_files = changed_files filtered to: exists on disk AND not in excluded patterns
82
+
83
+ Excluded patterns:
84
+ - node_modules/**, vendor/**, dist/**, build/**
85
+ - *.lock, *.min.js, *.min.css
86
+ - .workflow/**, .claude/**
87
+ ```
88
+
89
+ ### 1c: Error if empty
90
+
91
+ ```
92
+ Abort E004 if review_files is empty
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Step 2: Determine Review Level
98
+
99
+ ```
100
+ level = --level flag value, or auto-detect:
101
+ ≤3 files → quick | ≥20 files or critical phase → deep | otherwise → standard
102
+
103
+ Log: "Review level: {level} ({file_count} files)"
104
+ ```
105
+
106
+ ### Determine dimensions
107
+
108
+ ```
109
+ dimensions = --dimensions flag (comma-separated), or level defaults:
110
+ quick → [correctness, security]
111
+ standard|deep → [correctness, security, performance, architecture, maintainability, best-practices]
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Step 3: Load Project Specs
117
+
118
+ **Skip if `--skip-specs`.**
119
+
120
+ ```
121
+ specs_content = maestro spec load --category review
122
+ → Pass to reviewer agents as quality standards context
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Step 4: Load Review Context
128
+
129
+ Build context object for reviewer agents:
130
+
131
+ ```
132
+ review_context = {
133
+ phase_goal: index.json.goal || index.json.description,
134
+ success_criteria: index.json.success_criteria,
135
+ tech_stack: detect from package.json / pyproject.toml / go.mod / Cargo.toml,
136
+ specs: specs_content (from Step 3),
137
+ verification_gaps: load from ${PHASE_DIR}/verification.json .gaps if exists, else []
138
+ }
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Step 5: Execute Review
144
+
145
+ ### Quick Level — Inline Scan
146
+
147
+ ```
148
+ Scan each review_file against each dimension, collecting findings:
149
+
150
+ correctness: unhandled null/undefined, missing error propagation, type mismatches,
151
+ off-by-one, missing boundary checks, unreachable code, logic contradictions
152
+ security: SQL/command injection, hardcoded secrets/keys/passwords,
153
+ missing input validation, XSS vectors
154
+
155
+ Each finding: { id: "{PREFIX}-{NNN}", dimension, severity, title, file, line, snippet,
156
+ description, impact, suggestion }
157
+ ```
158
+
159
+ **After inline scan, skip to Step 6.**
160
+
161
+ ### Standard Level — Parallel Agent Review
162
+
163
+ ```
164
+ MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep: Per dimension → spawn workflow-reviewer agent (all parallel):
165
+ Context: dimension, phase_name, phase_goal, review_files, success_criteria,
166
+ tech_stack, specs_content, verification_gaps
167
+ Instructions:
168
+ - Read each file, analyze for {dimension}-specific issues only
169
+ - Classify: critical / high / medium / low
170
+ - Return JSON array: id, dimension, severity, title, file, line, snippet,
171
+ description, impact, suggestion, spec_violation (if applicable)
172
+ - Top 20 findings by severity, each with file:line evidence
173
+ ```
174
+
175
+ Launch ALL dimension agents in a single message. Collect dimension_results (JSON findings array). Log W001 on agent failure, continue with partial results; flag review as [LOW CONFIDENCE] (partial results).
176
+
177
+ ### Deep Level — Enhanced Agent Review
178
+
179
+ ```
180
+ Same as standard, with deep-mode enhancements:
181
+ - Also read direct imports for context
182
+ - Trace callers/dependents for critical/high findings
183
+ - Cross-reference patterns across files (duplication, inconsistency)
184
+ - Return includes additional field: related_files[]
185
+ - Top 30 findings (vs 20 for standard)
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Step 6: Aggregate Findings
191
+
192
+ ### 6a: Merge all findings
193
+
194
+ ```
195
+ all_findings = merge all dimension results, sorted by severity (critical > high > medium > low), then dimension
196
+ ```
197
+
198
+ ### 6b: Severity distribution
199
+
200
+ ```
201
+ severity_dist = count all_findings by severity {critical, high, medium, low}
202
+ ```
203
+
204
+ ### 6c: Identify critical files (standard + deep only)
205
+
206
+ ```
207
+ IF level != "quick":
208
+ critical_files = files with critical/high findings across 3+ distinct dimensions
209
+ → [{ file, dimensions[] }]
210
+ ```
211
+
212
+ ### 6d: Determine verdict
213
+
214
+ ```
215
+ verdict:
216
+ BLOCK → any critical, or >5 high
217
+ WARN → any high (≤5)
218
+ PASS → no critical or high
219
+ ```
220
+
221
+ ---
222
+
223
+ ## Step 6.5: CLI Supplementary Analysis (standard + deep only)
224
+
225
+ **Skip for quick level or if no enabled CLI tools.**
226
+
227
+ ```
228
+ IF level == "quick" OR no CLI tools enabled: skip to Step 7
229
+
230
+ # Gather critical/high findings for CLI cross-check
231
+ cli_targets = all_findings.filter(f => f.severity in ["critical", "high"])
232
+ IF cli_targets.length == 0: skip to Step 7
233
+
234
+ # Build concise review prompt from findings
235
+ finding_summary = cli_targets.map(f => "${f.id}: [${f.severity}] ${f.file}:${f.line} — ${f.title}").join("\n")
236
+
237
+ MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep:
238
+ Bash({
239
+ command: 'maestro delegate "PURPOSE: Cross-verify code review findings and identify missed issues
240
+ TASK: For each finding, verify severity is accurate | Check for false positives | Identify any critical issues missed by initial review in the same files
241
+ MODE: analysis
242
+ CONTEXT: @${review_files as glob pattern}
243
+ EXPECTED: JSON array of { finding_id, verified: bool, adjusted_severity?, missed_issues?: [{ severity, file, line, title, description }] }
244
+ CONSTRAINTS: Only report missed issues of severity high or above | Do not duplicate existing findings
245
+
246
+ Existing findings to verify:
247
+ ${finding_summary}
248
+ " --role review --mode analysis',
249
+ run_in_background: true
250
+ })
251
+ ```
252
+
253
+ **On callback:**
254
+ ```
255
+ cli_result = maestro delegate output <id>
256
+ Parse JSON from cli_result
257
+
258
+ For each verified finding:
259
+ If adjusted_severity differs: update finding.severity, add finding.cli_note = "severity adjusted by CLI review"
260
+ For each missed_issue:
261
+ Append to all_findings with id: "CLI-{NNN}", source: "cli-supplementary"
262
+
263
+ Recalculate severity_dist after merge
264
+ ```
265
+
266
+ ---
267
+
268
+ ## Step 7: Deep-Dive (Conditional)
269
+
270
+ **Skip for quick level.**
271
+
272
+ | Level | Trigger |
273
+ |-------|---------|
274
+ | Standard | `severity_dist.critical > 0` |
275
+ | Deep | Always |
276
+
277
+ ### 7a: Select deep-dive targets
278
+
279
+ ```
280
+ deep_dive_targets:
281
+ deep → critical + high findings, top 15
282
+ standard → critical findings only, top 10
283
+ ```
284
+
285
+ ### 7b: Deep-dive iteration
286
+
287
+ ```
288
+ Iterate up to max_iterations (deep=3, standard=1) over unresolved targets:
289
+
290
+ MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep: Per target → spawn workflow-reviewer agent:
291
+ Context: original finding JSON, previous analysis (if iteration > 1)
292
+ Tasks: read affected file, find callers/imports, check test coverage
293
+ Analyze: root cause, impact radius, remediation (with code example), risk if unfixed
294
+
295
+ Return JSON:
296
+ {
297
+ "finding_id": "{target.id}",
298
+ "root_cause": "...",
299
+ "impact_radius": ["file1.ts", "file2.ts"],
300
+ "remediation": { "approach": "...", "code_example": "..." },
301
+ "risk_if_unfixed": "...",
302
+ "reassessed_severity": "critical|high|medium|low",
303
+ "confidence": 0.0-1.0
304
+ }
305
+
306
+ Merge: enrich original finding, mark complete if confidence >= 0.8,
307
+ update severity if reassessed. Stop early if all resolved.
308
+ ```
309
+
310
+ ---
311
+
312
+ ## Step 8: Auto-Create Issues
313
+
314
+ | Level | Create issues for |
315
+ |-------|-------------------|
316
+ | Quick | Critical only |
317
+ | Standard | Critical + High |
318
+ | Deep | Critical + High + Medium |
319
+
320
+ ```
321
+ Filter findings by level threshold
322
+
323
+ For each qualifying finding → append issue to .workflow/issues/issues.jsonl:
324
+ id: "ISS-{YYYYMMDD}-{NNN}" (auto-increment from existing today's entries)
325
+ title: "[{dimension}] {title}" (max 100 chars)
326
+ status: "registered"
327
+ priority: severity_to_priority (critical→1, high→2, medium→3)
328
+ severity, source: "review", phase_ref, gap_ref: finding.id
329
+ description, fix_direction: finding.suggestion
330
+ context: { location: "{file}:{line}", suggested_fix, notes: impact }
331
+ tags: ["review", dimension]
332
+ Timestamps: created_at, updated_at = now()
333
+
334
+ Link finding.issue_id back to created issue
335
+ ```
336
+
337
+ ---
338
+
339
+ ## Step 9: Write review.json
340
+
341
+ Archive existing `review.json` → `${PHASE_DIR}/.history/review-{YYYY-MM-DDTHH-mm-ss}.json`
342
+
343
+ ```
344
+ Write ${PHASE_DIR}/review.json:
345
+ {
346
+ "phase": PHASE_NUM,
347
+ "level": "quick" | "standard" | "deep",
348
+ "verdict": "PASS" | "WARN" | "BLOCK",
349
+ "reviewed_at": now(),
350
+ "reviewer": "workflow-reviewer",
351
+ "dimensions_reviewed": dimensions,
352
+ "files_reviewed": review_files,
353
+ "severity_distribution": {
354
+ "critical": N,
355
+ "high": N,
356
+ "medium": N,
357
+ "low": N,
358
+ "total": N
359
+ },
360
+ "critical_files": critical_files,
361
+ "findings": all_findings,
362
+ "deep_dives": deep_dive_results (if any),
363
+ "issues_created": issue_ids[]
364
+ }
365
+ ```
366
+
367
+ ---
368
+
369
+ ## Step 10: Update index.json
370
+
371
+ ```
372
+ Update index.json.updated_at = now()
373
+ Glob review.json MUST exist before Step 10 complete; BLOCKED if missing.
374
+ Set index.json.review = { level, verdict, reviewed_at, severity_distribution,
375
+ findings_count, issues_created count }
376
+ ```
377
+
378
+ ---
379
+
380
+ ## Report Format
381
+
382
+ ```
383
+ === CODE REVIEW RESULTS ===
384
+ Phase: {phase_name}
385
+ Level: {quick | standard | deep}
386
+ Files: {files_reviewed.length} files across {dimensions.length} dimensions
387
+ Duration: {duration}
388
+
389
+ Severity Distribution:
390
+ Critical: {critical}
391
+ High: {high}
392
+ Medium: {medium}
393
+ Low: {low}
394
+
395
+ Top Issues:
396
+ 1. [{severity}] {finding_id}: {title} ({file}:{line})
397
+ 2. [{severity}] {finding_id}: {title} ({file}:{line})
398
+ 3. [{severity}] {finding_id}: {title} ({file}:{line})
399
+ ... (up to 10)
400
+
401
+ {IF level != "quick":
402
+ Critical Files (3+ dimensions flagged):
403
+ - {file} ({dimension1}, {dimension2}, {dimension3})
404
+ }
405
+
406
+ Verdict: {PASS | WARN | BLOCK}
407
+ Issues Created: {count}
408
+
409
+ Files:
410
+ {artifact_dir}/review.json
411
+
412
+ Next steps:
413
+ {suggested_next_command}
414
+ ```
415
+
416
+ ---
417
+
418
+ ## Next Step Routing
419
+
420
+ | Verdict | Suggestion |
421
+ |---------|------------|
422
+ | PASS | Skill({ skill: "quality-test", args: "{phase}" }) for UAT, or Skill({ skill: "maestro-milestone-audit" }) if UAT already passed |
423
+ | WARN | Review findings, then Skill({ skill: "quality-test", args: "{phase}" }) — acknowledge warnings before proceeding |
424
+ | BLOCK (≤3 findings, all medium/low) | **Lightweight fix loop**: fix inline → re-run review on affected files only → repeat until PASS/WARN (max 2 iterations) |
425
+ | BLOCK (>3 findings or any critical) | Full fix cycle: Skill({ skill: "maestro-plan", args: "{phase} --gaps" }) -> Skill({ skill: "maestro-execute", args: "{phase}" }) -> re-run Skill({ skill: "quality-review", args: "{phase}" }) |
426
+
427
+ ---
428
+
429
+ ## Error Handling
430
+
431
+ | Error | Action |
432
+ |-------|--------|
433
+ | Phase directory not found | Abort: "Phase {phase} not found." |
434
+ | No execution results | Abort: "No completed tasks found. Run maestro-execute first." |
435
+ | No changed files | Abort: "No changed files detected in this phase." |
436
+ | Reviewer agent fails | Log W001, continue with available dimension results |
437
+ | All agents fail | Abort: "Review could not complete — all dimension agents failed." |
438
+ | Deep-dive agent fails | Log finding as unresolved, skip enrichment; flag finding as [LOW CONFIDENCE] (enrichment skipped) |
439
+
440
+ ---
441
+
442
+ ## State Updates
443
+
444
+ | When | Field | Value |
445
+ |------|-------|-------|
446
+ | Step 5 start | index.json.status | "reviewing" (if currently "verifying") |
447
+ | Step 10 | index.json.review | Review results summary |
448
+ | Step 10 | index.json.updated_at | Current timestamp |
@@ -0,0 +1,193 @@
1
+ # Workflow: Roadmap Common
2
+
3
+ ---
4
+
5
+ ## Worktree Guard
6
+
7
+ Block if `.workflow/worktree-scope.json` exists — must run from main worktree.
8
+
9
+ ---
10
+
11
+ ## Load Project Context
12
+
13
+ ### Load Specs
14
+
15
+ ```
16
+ specs_content = maestro spec load --category arch
17
+ ```
18
+
19
+ ### Load Project History (if `.workflow/` exists)
20
+
21
+ Read project artifacts to understand what has already been built:
22
+
23
+ - `project.md` → already_shipped (Validated), current_scope (Active), project_history (Context), locked_decisions (Key Decisions)
24
+ - `state.json.accumulated_context` → deferred[] (candidate reqs), key_decisions[] (constraints), blockers[] (risks)
25
+ - `.workflow/codebase/` → feature inventory from codebase docs
26
+
27
+ **Context assembly** — pass downstream as `project_context`:
28
+ ```json
29
+ {
30
+ "already_shipped": ["REQ-001: User auth", "REQ-002: API layer"],
31
+ "current_scope": ["REQ-003: Payments", "REQ-004: i18n"],
32
+ "deferred_from_previous": ["Internationalization deferred from v1.0"],
33
+ "locked_decisions": ["JWT stateless auth", "PostgreSQL"],
34
+ "learnings": ["JWT has perf issues at scale — consider caching"],
35
+ "project_history": "Milestone v1.0 completed 2026-03-15: auth + API layer shipped"
36
+ }
37
+ ```
38
+
39
+ **Rules**:
40
+ - NEVER re-plan features listed in `already_shipped` — they are done
41
+ - `deferred_from_previous` items are HIGH PRIORITY candidates for new phases
42
+ - `locked_decisions` constrain technology choices in decomposition
43
+ - `learnings` inform risk assessment and phase sizing
44
+
45
+ ---
46
+
47
+ ## Codebase Exploration (conditional)
48
+
49
+ - Detect if project has source files
50
+ - MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep: If yes: spawn `cli-explore-agent` for context discovery
51
+ - If `project_context.already_shipped` exists: include as "feature audit" directive — agent should verify which shipped features are present in code and identify integration points for new work
52
+ - Output: relevant files, patterns, tech stack, feature_audit
53
+
54
+ ---
55
+
56
+ ## External Research — API & Technology Details (Optional)
57
+
58
+ MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep: Spawn `workflow-external-researcher` agent when requirement mentions specific technologies, APIs, or external services.
59
+
60
+ **Trigger**: Technology keywords detected in requirement or codebase exploration found external dependencies. Auto-trigger in auto mode (`-y`). Skip if requirement is purely organizational/conceptual.
61
+
62
+ Extract named technologies/APIs/frameworks/protocols from requirement + codebase exploration.
63
+
64
+ If topics found → spawn `workflow-external-researcher` agent for API research:
65
+ - Per technology: stable version, core API surface, auth model, integration patterns, limitations, effort signals
66
+ - Focus on details affecting phase decomposition and dependency ordering
67
+ - Output → `apiResearchContext` (in-memory)
68
+
69
+ If no topics or research fails → `apiResearchContext = null`, continue; flag roadmap as [LOW CONFIDENCE] (no external research).
70
+
71
+ ---
72
+
73
+ ## Minimum-Phase Principle (MANDATORY)
74
+
75
+ **Core rule: Phase = synchronization barrier.** Each Phase triggers a full plan→execute→verify→transition serial cycle. More phases = slower delivery. The wave DAG inside each Phase already handles task ordering and parallelism, so only create a new Phase when tasks **cannot** start until a previous Phase's entire output exists.
76
+
77
+ **Default: 1 Phase.** Put everything into a single Phase unless a hard dependency forces a split.
78
+
79
+ | Rule | Constraint |
80
+ |------|-----------|
81
+ | **Default** | **1 Phase**. All work in one plan→execute cycle; wave DAG handles internal ordering. |
82
+ | **Maximum** | **2 Phases**. Only when a hard dependency boundary exists that cannot be resolved. |
83
+ | **Exceptional** | **3 Phases**. Must explicitly justify why 2 is insufficient. |
84
+ | **Minimum tasks per phase** | 5 tasks/stories. If a phase would have fewer, merge it into an adjacent phase. |
85
+ | **Merge principle** | Same-module, same-concern, or tightly-coupled work belongs in ONE phase. Infra + core logic + API in one phase is fine. Multiple Epics → one phase is normal. |
86
+ | **Split principle** | Only split when ALL three hard-dependency conditions are met (see below). |
87
+
88
+ **Hard dependency — all three conditions required to justify a Phase split:**
89
+ 1. **Runtime dependency**: Phase B code at runtime MUST call Phase A's real output (cannot mock/stub).
90
+ 2. **Not parallelizable**: A and B cannot develop concurrently via contract/interface/type agreement.
91
+ 3. **Full barrier**: ALL of Phase A's tasks must complete before ANY of Phase B's tasks can start.
92
+
93
+ If only 1-2 conditions are met → keep in the same Phase, use wave dependencies instead.
94
+
95
+ **Phase sizing checklist (applied after decomposition, before presenting to user):**
96
+ 1. Count total phases. If > 2 → justify each split against the 3 hard-dependency conditions, merge if unjustified.
97
+ 2. Count estimated tasks per phase. Any phase < 5 tasks → merge into neighbor.
98
+ 3. Verify each phase has a meaningful deliverable boundary (not just "setup" or "cleanup").
99
+
100
+ **Scope escalation:**
101
+ - **Single project** (any size): 1-2 Phases. Use wave DAG for internal parallelism.
102
+ - **Large scope** (monorepo with 2+ independently deployable services): Use **Milestones** to divide scope. Each Milestone follows the 1-2 Phase limit independently.
103
+
104
+ **Progressive mode**:
105
+ - Progressive layers (MVP → Usable → Refined) map to **Milestones**, not Phases.
106
+ - Each Milestone contains 1-2 Phases following the minimum-phase principle.
107
+ - MVP must be self-contained (no external dependencies)
108
+ - Each feature in exactly ONE milestone (no overlap)
109
+
110
+ **Direct mode**:
111
+ - Topologically-sorted task sequence
112
+ - Each task: title, type, scope, inputs, outputs, convergence, depends_on
113
+ - parallel_group for truly independent tasks
114
+
115
+ **Phase format** (both modes):
116
+ ```markdown
117
+ ### Phase {N}: {Title}
118
+ - **Goal**: <what this phase achieves>
119
+ - **Depends on**: <prerequisite phases or "Nothing">
120
+ - **Requirements**: <REQ-IDs mapped from project.md Active requirements>
121
+ - **Success Criteria** (what must be TRUE):
122
+ 1. <observable behavior from user perspective>
123
+ 2. <observable behavior from user perspective>
124
+ ```
125
+
126
+ Phase numbering: integers (1, 2, 3) for planned work, decimals (2.1, 2.2) for inserted phases.
127
+ Decimal phases count toward the total phase limit.
128
+ Phase directories use `{NN}-{slug}` format (e.g., `01-auth`, `02-api`).
129
+
130
+ **Requirements traceability**: Every Active requirement from project.md MUST appear in exactly one phase's Requirements field. If a requirement maps to no phase, surface it as a gap.
131
+
132
+ ---
133
+
134
+ ## Roadmap Write Logic
135
+
136
+ ### Roadmap Template
137
+
138
+ Write `roadmap.md` to `.workflow/roadmap.md` using `@templates/roadmap.md`:
139
+
140
+ ```markdown
141
+ # Roadmap: {project_name}
142
+
143
+ ## Overview
144
+ <one paragraph describing the journey>
145
+
146
+ ## Phases
147
+ - [ ] **Phase 1: {Title}** - {one-line description}
148
+
149
+ ## Phase Details
150
+
151
+ ### Phase 1: {Title}
152
+ **Goal**: {what this phase delivers}
153
+ **Depends on**: Nothing (first phase)
154
+ **Requirements**: {REQ-IDs}
155
+ **Success Criteria** (what must be TRUE):
156
+ 1. {observable behavior from user perspective}
157
+ 2. {observable behavior from user perspective}
158
+
159
+ ## Scope Decisions
160
+ - **In scope**: <included>
161
+ - **Deferred**: <later milestones>
162
+ - **Out of scope**: <excluded>
163
+
164
+ ## Progress
165
+ | Phase | Status | Completed |
166
+ |-------|--------|-----------|
167
+ | 1. {Title} | Not started | - |
168
+ ```
169
+
170
+ **Requirements traceability**: Cross-check that every Active requirement from project.md maps to exactly one phase. Surface unmapped requirements as gaps.
171
+
172
+ ### Overwrite vs Edit Rules (MANDATORY)
173
+
174
+ Before writing `.workflow/roadmap.md`, check existing state:
175
+
176
+ | Scenario | Action |
177
+ |----------|--------|
178
+ | `roadmap.md` does not exist | Create (write) |
179
+ | `roadmap.md` exists, no completed phases in Progress table | Overwrite (with `-y` auto-confirm, otherwise ask user) |
180
+ | `roadmap.md` exists, has completed phases | **Refuse overwrite** → instruct user to use `--revise` mode |
181
+
182
+ ### state.json Update Rules
183
+
184
+ After writing roadmap.md, update state.json consistently regardless of mode:
185
+
186
+ | Scenario | Action |
187
+ |----------|--------|
188
+ | `state.json` exists | Update `milestones` array and `current_milestone` field from roadmap phases (partial update, not overwrite) |
189
+ | `state.json` does not exist | Do not create (leave to maestro-init) |
190
+
191
+ ### Scratch Directory
192
+
193
+ Ensure scratch directory exists: `mkdir -p .workflow/scratch/`