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,471 @@
1
+ # Retrospective Workflow
2
+
3
+ Multi-lens 复盘 of completed phase artifacts. Read-only until routing stage, where it writes to spec / issue / knowhow stores. NEVER modifies existing phase artifacts.
4
+
5
+ ---
6
+
7
+ ## Argument Shape
8
+
9
+ ```
10
+ /quality-retrospective → auto-scan unreviewed phases, prompt selection
11
+ /quality-retrospective <N> → retrospect single phase
12
+ /quality-retrospective <N>..<M> → retrospect range (inclusive)
13
+ /quality-retrospective --all → re-run for every completed phase (force)
14
+ /quality-retrospective <N> --lens <name> → restrict to one lens (technical|process|quality|decision|all)
15
+ /quality-retrospective <N> --no-route → produce retrospective.{md,json} only, skip auto-create of spec/note/issue
16
+ /quality-retrospective <N> --compare <M> → delta vs phase M (gstack-style trend)
17
+ ```
18
+
19
+ | Flag | Effect |
20
+ |------|--------|
21
+ | `--lens <name>` | Run only the named lens. Default: all four. Repeatable. |
22
+ | `--no-route` | Synthesize but skip Stage 6 (no spec/note/issue creation). |
23
+ | `--all` | Force re-run for every completed phase (overwrites existing retrospective.json after archiving). |
24
+ | `--compare <M>` | Load phase M's retrospective.json and emit a delta section. |
25
+ | `--auto-yes` | Skip routing confirmation prompts; accept all recommendations. |
26
+
27
+ ---
28
+
29
+ ## Stage 1: parse_input
30
+
31
+ ```
32
+ Require .workflow/ exists (E001).
33
+ Parse $ARGUMENTS → first non-flag token as phase/range/"--all", remaining as flags.
34
+
35
+ Build config:
36
+ mode = "scan" | "single" | "range" | "all"
37
+ phases = [] (filled in Stage 2)
38
+ lenses = ["technical","process","quality","decision"]
39
+ route = true (false if --no-route)
40
+ compare_to = null | <phase number>
41
+ auto_yes = false
42
+
43
+ Validate: --lens names must be known (E002), --compare requires single mode (E003).
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Stage 2: scan_unreviewed (mode = "scan" or "all")
49
+
50
+ ```
51
+ Read .workflow/state.json → state
52
+
53
+ candidates = all completed execute artifacts from state.artifacts, each mapped to:
54
+ { number, slug, title, completed_at, has_retro, phase_dir, gaps: 0, review_verdict: "—" }
55
+
56
+ where phase_dir = ".workflow/" + artifact.path
57
+ has_retro = exists "{phase_dir}/retrospective.json"
58
+ ```
59
+
60
+ ### Display backlog
61
+
62
+ ```
63
+ === RETROSPECTIVE BACKLOG ===
64
+
65
+ Phase Title Completed Retro? Gaps Review
66
+ ───── ────────────────────── ────────────── ────── ──── ──────
67
+ 01 Authentication 2026-03-15 MISSING 3 WARN
68
+ 02 Rate limiting 2026-03-22 ✓ 0 PASS
69
+ 03 Refresh tokens 2026-04-02 MISSING 1 PASS
70
+
71
+ Unreviewed: 2 phases
72
+ ```
73
+
74
+ ### Selection logic
75
+
76
+ | Mode | Action |
77
+ |------|--------|
78
+ | `scan`, 0 unreviewed | Print "All phases retrospected", exit 0 |
79
+ | `scan`, 1 unreviewed | Default to that phase, ask AskUserQuestion to confirm |
80
+ | `scan`, ≥2 unreviewed | AskUserQuestion with options: each phase as a choice + "All unreviewed" |
81
+ | `all` | `phases = candidates` (overwrite existing — archive old retrospective.json to `.history/` first) |
82
+ | `single` | `phases = [parsed_phase]` (validate it exists and is completed; if `has_retro` and not `--all`, prompt to overwrite) |
83
+ | `range` | `phases = candidates.filter(c => N <= c.number <= M)` |
84
+
85
+ If overwriting existing retrospective.json:
86
+ ```
87
+ Archive existing retrospective.{json,md} to "{candidate.phase_dir}/.history/retrospective-{YYYY-MM-DDTHH-mm-ss}.{ext}"
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Stage 3: load_artifacts (per phase)
93
+
94
+ ```
95
+ artifact_dir = candidate.phase_dir
96
+
97
+ Load artifacts bundle:
98
+ index ← {artifact_dir}/index.json
99
+ state ← .workflow/state.json
100
+ plan ← {artifact_dir}/plan.json
101
+ verification ← {artifact_dir}/verification.json
102
+ review ← {artifact_dir}/review.json
103
+ uat ← {artifact_dir}/uat.md
104
+ task_summaries ← {artifact_dir}/.summaries/TASK-*-summary.md
105
+ task_jsons ← {artifact_dir}/.task/TASK-*.json
106
+ phase_issues ← .workflow/issues/{issues,issue-history}.jsonl filtered by phase_ref == slug|NN
107
+ prior_retro ← if --compare M: load phase M's retrospective.json via artifact registry
108
+ ```
109
+
110
+ ### Compute base metrics
111
+
112
+ ```
113
+ metrics = {
114
+ tasks_planned ← plan.tasks.length or task_jsons.length
115
+ tasks_completed ← task_jsons where status=="completed"
116
+ tasks_deferred ← state.accumulated_context.deferred for this phase
117
+ gaps_found / closed ← verification.gaps (total vs status=="closed")
118
+ antipatterns ← verification.antipatterns count
119
+ constraint_violations ← verification.constraint_violations count
120
+ issues_opened ← phase_issues where source in [verification,review,antipattern,discovery]
121
+ issues_closed ← phase_issues where status in [completed,failed]
122
+ rework_iterations ← count .history/verification-*.json
123
+ severity_distribution ← review.severity_distribution or {critical:0,high:0,medium:0,low:0,total:0}
124
+ review_verdict/level ← review.verdict or "not_run", review.level
125
+ uat_blockers ← count blockers from uat.md
126
+ }
127
+ ```
128
+
129
+ If `--compare M` is set, compute delta (current minus prior_retro) for:
130
+ ```
131
+ delta = { vs_phase, tasks_completed, gaps_found, issues_opened, rework_iterations, severity_critical, severity_high }
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Stage 4: multi_lens_analysis
137
+
138
+ MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep: Spawn one Agent per active lens **in parallel** (`run_in_background: false`). Each returns JSON.
139
+
140
+ ### Lens registry
141
+
142
+ | Lens | subagent_type | --rule template (for any inner CLI calls) | Primary inputs | Output candidates |
143
+ |------|--------------|-------------------------------------------|----------------|-------------------|
144
+ | technical | general-purpose | analysis-analyze-code-patterns | task_summaries, task_jsons, state.accumulated_context.key_decisions | spec stubs |
145
+ | process | general-purpose | analysis-trace-code-execution | plan.json (planned), task_jsons (actual), issue_history timestamps, state.deferred | notes |
146
+ | quality | general-purpose | analysis-review-code-quality | verification (gaps + antipatterns), review (severity_distribution + findings), phase_issues | issues |
147
+ | decision | general-purpose | analysis-review-architecture | state.accumulated_context.key_decisions, task_summaries, plan.json rationale fields | notes (or spec) |
148
+
149
+ ### Lens prompt template
150
+
151
+ ```
152
+ You are the {LENS} lens of a workflow retrospective for phase {NN}-{slug}.
153
+
154
+ ## Goal
155
+ Analyze the phase artifacts from the {LENS} perspective and return structured JSON
156
+ that will be merged into a multi-lens retrospective and used to route insights into
157
+ the project's spec / note / issue stores.
158
+
159
+ ## Lens focus
160
+ {lens_specific_focus_paragraph}
161
+
162
+ ## Phase context
163
+ - Title: {index.title}
164
+ - Goal: {index.goal}
165
+ - Success criteria: {index.success_criteria}
166
+ - Status: {index.status}
167
+ - Completed at: {index.completed_at}
168
+
169
+ ## Artifacts (read these from disk)
170
+ - Plan: {artifact_dir}/plan.json
171
+ - Verification: {artifact_dir}/verification.json
172
+ - Review: {artifact_dir}/review.json
173
+ - UAT notes: {artifact_dir}/uat.md
174
+ - Task summaries: {artifact_dir}/.summaries/
175
+ - Task JSONs: {artifact_dir}/.task/
176
+ - Phase issues: .workflow/issues/issues.jsonl (filter phase_ref == "{phase_slug}")
177
+ - Project state: .workflow/state.json (decisions, deferred)
178
+
179
+ ## Pre-computed metrics
180
+ {json_dump of metrics block from Stage 3}
181
+
182
+ ## Instructions
183
+ 1. Read the listed artifacts; do not guess at files that don't exist.
184
+ 2. Identify exactly:
185
+ - 3 wins (what worked, with concrete evidence refs)
186
+ - 3 challenges (what was hard, with concrete evidence refs)
187
+ - 3 watch_patterns (recurring concerns to monitor in future phases)
188
+ 3. Distill 1–3 reusable insights from this lens. Each insight is portable —
189
+ stated so a future planner who has never seen this phase can apply it.
190
+ 4. For each insight, recommend a routing target:
191
+ - "spec" → reusable architectural pattern, contract, or convention
192
+ - "note" → process tip, decision rationale, or contextual reminder
193
+ - "issue" → recurring gap, antipattern, or technical debt that needs fix work
194
+ - "none" → insight is interesting but not actionable
195
+ 5. Ground every finding in evidence_refs that include the file path AND
196
+ either a line number, JSON pointer (#field), or section heading.
197
+
198
+ ## Output
199
+ Return ONLY a single JSON object, no prose, matching this schema:
200
+
201
+ {
202
+ "lens": "{LENS}",
203
+ "wins": [{ "title": "...", "evidence_refs": ["..."] }, ...],
204
+ "challenges": [{ "title": "...", "evidence_refs": ["..."] }, ...],
205
+ "watch_patterns": [{ "title": "...", "evidence_refs": ["..."] }, ...],
206
+ "insights": [
207
+ {
208
+ "category": "pattern|antipattern|decision|tool|gotcha|technique",
209
+ "title": "Short imperative title",
210
+ "summary": "1–3 sentences a future planner can act on",
211
+ "confidence": "high|medium|low",
212
+ "evidence_refs": ["{artifact_dir}/verification.json#gaps[2]", "..."],
213
+ "routed_to": "spec|note|issue|none",
214
+ "tags": ["..."]
215
+ }
216
+ ]
217
+ }
218
+ ```
219
+
220
+ ### Lens-specific focus paragraphs
221
+
222
+ **technical**:
223
+ > Identify reusable architecture decisions, API contracts, integration patterns, and tech debt incurred. Focus on what should become a project-wide spec or convention. Watch for: ad-hoc patterns that should be standardized, abstractions that leaked, libraries chosen without rationale.
224
+
225
+ **process**:
226
+ > Compare planned vs actual: did the wave order survive contact? How many gap-fix loops were required? Which tasks slipped or were deferred? What blocked progress? Watch for: rework caused by missing context, deferrals that hide unresolved scope, planning estimates that systematically miss.
227
+
228
+ **quality**:
229
+ > Cluster the verification gaps, review findings, and antipatterns. Which files appear in multiple severity buckets? Which categories of bug recurred? Which UAT blockers slipped past static review? Watch for: recurring antipattern shapes, files with cross-dimension findings, test coverage gaps that mirror the gap list.
230
+
231
+ **decision**:
232
+ > Reconstruct the key decisions made during the phase, their stated rationale, and the alternatives rejected. Where did mid-phase pivots happen and why? What constraints surfaced late? Watch for: decisions made without recorded rationale, late pivots that suggest weak upfront framing.
233
+
234
+ ### Spawn pattern
235
+
236
+ Spawn all lenses in parallel. Collect into `lens_results`. If any fails, log W001, proceed with successful lenses; flag retrospective as [LOW CONFIDENCE] (partial lenses).
237
+
238
+ ---
239
+
240
+ **GATE Stage 4→5**: REQUIRED lens analyses complete BEFORE synthesis; BLOCKED if lens_results missing
241
+
242
+ ## Stage 5: synthesize
243
+
244
+ ### Generate insight IDs
245
+
246
+ `INS-{8 lowercase hex}` via stable hash of `phase_num + lens + title` (idempotent).
247
+
248
+ ### Build retrospective.json
249
+
250
+ Structure: `{ phase, phase_slug, phase_title, retrospected_at, lenses_run, metrics, delta, findings_by_lens, distilled_insights, routing_recommendations, tweetable }`. Each insight's `routed_id` is null (populated in Stage 6).
251
+
252
+ ### Build retrospective.md
253
+
254
+ Sections: Header (tweetable, metadata) → Metrics table → Delta table (if --compare) → Findings by Lens → Distilled Insights → Routing Recommendations.
255
+
256
+ Write both to `{artifact_dir}/`.
257
+
258
+ Glob `{artifact_dir}/retrospective.json` AND `retrospective.md` MUST exist before Stage 8 complete; BLOCKED if missing.
259
+
260
+ ---
261
+
262
+ ## Stage 6: route_outputs
263
+
264
+ **Skip if `--no-route`.** Prompt user per recommendation (skip if `--auto-yes`).
265
+
266
+ ### Display routing table
267
+
268
+ ```
269
+ === ROUTING RECOMMENDATIONS ===
270
+
271
+ ID Target Lens Title
272
+ ────────────── ────── ───────── ───────────────────────────────────
273
+ INS-a1b2c3d4 spec technical Standardize JWT refresh rotation
274
+ INS-b2c3d4e5 issue quality Recurring null-deref in handlers
275
+ INS-c3d4e5f6 note process Wave 3 always slips by 2 tasks
276
+
277
+ Accept all? [Y/n/i for individual]
278
+ ```
279
+
280
+ ### Per-target routing
281
+
282
+ #### Target: spec
283
+
284
+ Route spec-routed insights as `<spec-entry>` entries into the appropriate target file. Map insight type to roles:
285
+ - `pattern` / `convention` → `implement`
286
+ - `adr-candidate` / architecture → `plan`
287
+ - quality-related → `review`
288
+
289
+ ```
290
+ Map insight type → roles → target file:
291
+ pattern/convention → implement → coding-conventions.md
292
+ adr-candidate/architecture → plan → arch-decisions.md
293
+ quality-related → review → quality-conventions.md
294
+
295
+ Append <spec-entry> to .workflow/specs/{target_file} with:
296
+ roles, keywords (3-5 extracted from title+summary), date, source="retrospective"
297
+ Body: insight title, summary, evidence refs, phase/lens/INS_id/confidence metadata
298
+
299
+ Create target file with roles frontmatter if it does not exist.
300
+
301
+ insight.routed_id = "{target_file}#INS-{INS_id}"
302
+ ```
303
+
304
+ #### Target: note
305
+
306
+ ```
307
+ Invoke manage-learn tip with:
308
+ text = "[Retro phase {NN} / {lens}] {insight.title}: {insight.summary}"
309
+ tags = insight.tags + ["retrospective", "phase-{NN}", insight.lens]
310
+
311
+ insight.routed_id = "TIP-{captured_id}"
312
+ ```
313
+
314
+ Fallback: if skill ID cannot be captured, write tip file directly per `workflows/knowhow.md` Part B Step 3 and update `wiki-index.json` per Step 4; flag tip as [LOW CONFIDENCE] (skill not captured).
315
+
316
+ #### Target: issue
317
+
318
+ Append a new entry to `.workflow/issues/issues.jsonl` matching the canonical schema from `workflows/issue.md` Step 4.
319
+
320
+ ```
321
+ Ensure .workflow/issues/issues.jsonl exists.
322
+
323
+ Generate issue_id = "ISS-{YYYYMMDD}-{NNN}" (next sequence from issues.jsonl + issue-history.jsonl).
324
+
325
+ Map insight.category → severity:
326
+ antipattern→high, gotcha→medium, pattern/decision/tool/technique→low, default→medium
327
+ Map severity → priority: critical→1, high→2, medium→3, low→4
328
+
329
+ Create issue per canonical schema (workflows/issue.md Step 4):
330
+ title: "[Retro] {insight.title}" (max 100 chars)
331
+ source: "retrospective", phase_ref: phase_slug, gap_ref: insight.id
332
+ description: insight.summary
333
+ fix_direction: "Surfaced by phase {NN} retrospective ({lens} lens). Review evidence refs."
334
+ tags: insight.tags + ["retrospective", "phase-{NN}", insight.lens]
335
+ Initial issue_history entry with actor="retrospective"
336
+
337
+ Append to .workflow/issues/issues.jsonl
338
+ insight.routed_id = issue_id
339
+ ```
340
+
341
+ ### Update retrospective.json with routed_ids
342
+
343
+ After all routings complete, re-write `retrospective.json` with the `routed_id` field on each insight populated. Re-render `retrospective.md` routing recommendations table to show the resolved IDs.
344
+
345
+ ---
346
+
347
+ ## Stage 7: persist_insights
348
+
349
+ Append every distilled insight (including `routed_to: "none"`) to the knowhow store.
350
+
351
+ ### Bootstrap
352
+
353
+ ```
354
+ Ensure .workflow/specs/ exists and learnings.md exists.
355
+ Create learnings.md with frontmatter (title, type: spec, roles: [implement]) if new.
356
+ ```
357
+
358
+ ### Append entries
359
+
360
+ For each insight in `distilled_insights`, append a `<spec-entry>` to `.workflow/specs/learnings.md`:
361
+
362
+ ```html
363
+ <spec-entry category="{insight.category}" keywords="{insight.tags joined by comma}" date="{YYYY-MM-DD}" id="{insight.id}" source="retrospective">
364
+
365
+ ### {insight.title}
366
+
367
+ {insight.summary}
368
+
369
+ - **Phase**: {phase} ({phase_slug})
370
+ - **Lens**: {insight.lens}
371
+ - **Confidence**: {insight.confidence}
372
+ - **Evidence**: {insight.evidence_refs}
373
+ - **Routed to**: {insight.routed_to} ({insight.routed_id or "—"})
374
+
375
+ </spec-entry>
376
+ ```
377
+
378
+ Also append each insight to `.workflow/specs/learnings.md` as `<spec-entry>` with `category="learning"` (backward compat with milestone-complete).
379
+
380
+ ---
381
+
382
+ ## Stage 8: next_step
383
+
384
+ Print: phase, lenses run, insight count, routing summary, output paths.
385
+
386
+ Next steps: `manage-status` | `manage-issue list --source retrospective` | `manage-learn list` | `maestro-milestone-audit`
387
+
388
+ If range/all mode: loop Stages 3-8 per phase, then print aggregate summary.
389
+
390
+ ---
391
+
392
+ ## Schemas
393
+
394
+ ### retrospective.json
395
+
396
+ ```json
397
+ {
398
+ "phase": 1,
399
+ "phase_slug": "01-auth",
400
+ "phase_title": "Authentication",
401
+ "retrospected_at": "2026-04-11T10:00:00Z",
402
+ "lenses_run": ["technical", "process", "quality", "decision"],
403
+ "metrics": {
404
+ "tasks_planned": 12,
405
+ "tasks_completed": 10,
406
+ "tasks_deferred": 2,
407
+ "gaps_found": 5,
408
+ "gaps_closed": 4,
409
+ "antipatterns": 3,
410
+ "constraint_violations": 0,
411
+ "issues_opened": 4,
412
+ "issues_closed": 3,
413
+ "rework_iterations": 1,
414
+ "severity_distribution": { "critical": 0, "high": 2, "medium": 8, "low": 11, "total": 21 },
415
+ "review_verdict": "WARN",
416
+ "review_level": "standard",
417
+ "uat_blockers": 0
418
+ },
419
+ "delta": null,
420
+ "findings_by_lens": {
421
+ "technical": {
422
+ "wins": [{"title": "...", "evidence_refs": ["..."]}],
423
+ "challenges": [{"title": "...", "evidence_refs": ["..."]}],
424
+ "watch_patterns": [{"title": "...", "evidence_refs": ["..."]}]
425
+ },
426
+ "process": { "wins": [], "challenges": [], "watch_patterns": [] },
427
+ "quality": { "wins": [], "challenges": [], "watch_patterns": [] },
428
+ "decision": { "wins": [], "challenges": [], "watch_patterns": [] }
429
+ },
430
+ "distilled_insights": [
431
+ {
432
+ "id": "INS-a1b2c3d4",
433
+ "lens": "technical",
434
+ "category": "pattern",
435
+ "title": "JWT refresh tokens must rotate on every use",
436
+ "summary": "Refresh-on-use prevents replay attacks. Implemented in src/auth/refresh.ts; should become a project-wide convention.",
437
+ "confidence": "high",
438
+ "evidence_refs": [
439
+ ".workflow/scratch/20260415-plan-P1-auth/verification.json#gaps[2]",
440
+ ".workflow/scratch/20260415-plan-P1-auth/.summaries/TASK-005-summary.md:42"
441
+ ],
442
+ "tags": ["auth", "jwt", "security"],
443
+ "routed_to": "spec",
444
+ "routed_id": "coding-conventions.md#INS-a1b2c3d4"
445
+ }
446
+ ],
447
+ "routing_recommendations": [
448
+ { "insight_id": "INS-a1b2c3d4", "target": "spec", "rationale": "Reusable security pattern" }
449
+ ],
450
+ "tweetable": "Phase 1 (auth): 10 tasks shipped, 4/5 gaps closed, verdict WARN. Insight: JWT refresh tokens must rotate on every use."
451
+ }
452
+ ```
453
+
454
+ ### spec-entry (in specs/learnings.md)
455
+
456
+ ```html
457
+ <spec-entry category="coding" keywords="pattern,auth,jwt,security" date="2026-04-11" id="INS-a1b2c3d4" source="retrospective">
458
+
459
+ ### JWT refresh tokens must rotate on every use
460
+
461
+ Refresh-on-use prevents replay attacks. Implemented in src/auth/refresh.ts; should become a project-wide convention.
462
+
463
+ - **Phase**: 1 (01-auth)
464
+ - **Lens**: technical
465
+ - **Confidence**: high
466
+ - **Evidence**: .workflow/scratch/20260415-plan-P1-auth/verification.json#gaps[2]
467
+ - **Routed to**: spec (coding-conventions.md#INS-a1b2c3d4)
468
+
469
+ </spec-entry>
470
+ ```
471
+