maestro-flow 0.3.9 → 0.3.11

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 (281) hide show
  1. package/.claude/agents/workflow-collab-planner.md +1 -1
  2. package/.claude/agents/workflow-executor.md +1 -1
  3. package/.claude/agents/workflow-plan-checker.md +1 -1
  4. package/.claude/agents/workflow-planner.md +1 -1
  5. package/.claude/commands/learn-decompose.md +176 -176
  6. package/.claude/commands/learn-follow.md +167 -167
  7. package/.claude/commands/learn-retro.md +1 -1
  8. package/.claude/commands/maestro-analyze.md +46 -3
  9. package/.claude/commands/maestro-coordinate.md +1 -3
  10. package/.claude/commands/maestro-execute.md +14 -0
  11. package/.claude/commands/maestro-plan.md +16 -0
  12. package/.claude/commands/manage-harvest.md +131 -131
  13. package/.claude/commands/manage-issue-discover.md +2 -2
  14. package/.claude/commands/manage-issue.md +5 -5
  15. package/.claude/commands/spec-add.md +67 -56
  16. package/.claude/commands/spec-load.md +66 -64
  17. package/.claude/commands/spec-setup.md +5 -9
  18. package/.codex/skills/learn-decompose/SKILL.md +119 -0
  19. package/.codex/skills/learn-follow/SKILL.md +83 -0
  20. package/.codex/skills/learn-investigate/SKILL.md +83 -0
  21. package/.codex/skills/learn-retro/SKILL.md +83 -0
  22. package/.codex/skills/learn-second-opinion/SKILL.md +86 -0
  23. package/.codex/skills/maestro/SKILL.md +335 -0
  24. package/.codex/skills/maestro-analyze/SKILL.md +84 -75
  25. package/.codex/skills/maestro-brainstorm/SKILL.md +452 -463
  26. package/.codex/skills/maestro-chain/SKILL.md +233 -0
  27. package/.codex/skills/maestro-coordinate/SKILL.md +167 -278
  28. package/.codex/skills/maestro-execute/SKILL.md +435 -438
  29. package/.codex/skills/maestro-fork/SKILL.md +68 -0
  30. package/.codex/skills/maestro-init/SKILL.md +171 -167
  31. package/.codex/skills/maestro-learn/SKILL.md +80 -0
  32. package/.codex/skills/maestro-link-coordinate/SKILL.md +224 -220
  33. package/.codex/skills/maestro-merge/SKILL.md +62 -0
  34. package/.codex/skills/maestro-milestone-audit/SKILL.md +108 -103
  35. package/.codex/skills/maestro-milestone-complete/SKILL.md +155 -149
  36. package/.codex/skills/maestro-milestone-release/SKILL.md +70 -0
  37. package/.codex/skills/maestro-overlay/SKILL.md +188 -185
  38. package/.codex/skills/maestro-plan/SKILL.md +66 -69
  39. package/.codex/skills/maestro-quick/SKILL.md +26 -23
  40. package/.codex/skills/maestro-roadmap/SKILL.md +65 -73
  41. package/.codex/skills/maestro-spec-generate/SKILL.md +66 -74
  42. package/.codex/skills/maestro-ui-design/SKILL.md +34 -31
  43. package/.codex/skills/maestro-verify/SKILL.md +556 -566
  44. package/.codex/skills/manage-codebase-rebuild/SKILL.md +397 -405
  45. package/.codex/skills/manage-codebase-refresh/SKILL.md +93 -82
  46. package/.codex/skills/manage-harvest/SKILL.md +82 -0
  47. package/.codex/skills/manage-issue/SKILL.md +80 -65
  48. package/.codex/skills/manage-issue-discover/SKILL.md +491 -503
  49. package/.codex/skills/manage-learn/SKILL.md +190 -186
  50. package/.codex/skills/manage-memory/SKILL.md +95 -72
  51. package/.codex/skills/manage-memory-capture/SKILL.md +99 -86
  52. package/.codex/skills/manage-status/SKILL.md +102 -89
  53. package/.codex/skills/quality-business-test/SKILL.md +228 -223
  54. package/.codex/skills/quality-debug/SKILL.md +54 -66
  55. package/.codex/skills/quality-integration-test/SKILL.md +532 -544
  56. package/.codex/skills/quality-refactor/SKILL.md +197 -191
  57. package/.codex/skills/quality-retrospective/SKILL.md +512 -505
  58. package/.codex/skills/quality-review/SKILL.md +93 -105
  59. package/.codex/skills/quality-sync/SKILL.md +101 -89
  60. package/.codex/skills/quality-test/SKILL.md +202 -198
  61. package/.codex/skills/quality-test-gen/SKILL.md +93 -104
  62. package/.codex/skills/spec-add/SKILL.md +58 -39
  63. package/.codex/skills/spec-load/SKILL.md +45 -40
  64. package/.codex/skills/spec-map/SKILL.md +180 -182
  65. package/.codex/skills/spec-setup/SKILL.md +94 -76
  66. package/.codex/skills/team-coordinate/SKILL.md +346 -357
  67. package/.codex/skills/team-executor/SKILL.md +70 -112
  68. package/.codex/skills/team-lifecycle-v4/SKILL.md +311 -299
  69. package/.codex/skills/team-quality-assurance/SKILL.md +234 -227
  70. package/.codex/skills/team-review/SKILL.md +232 -225
  71. package/.codex/skills/team-tech-debt/SKILL.md +78 -100
  72. package/.codex/skills/team-testing/SKILL.md +242 -235
  73. package/.codex/skills/wiki-connect/SKILL.md +75 -0
  74. package/.codex/skills/wiki-digest/SKILL.md +87 -0
  75. package/README.md +14 -11
  76. package/README.zh-CN.md +14 -11
  77. package/chains/issue-lifecycle.json +13 -13
  78. package/chains/singles/issue-analyze.json +3 -3
  79. package/chains/singles/issue-execute.json +3 -3
  80. package/chains/singles/issue-plan.json +3 -3
  81. package/dashboard/dist-server/dashboard/src/server/commander/commander-agent.js +2 -2
  82. package/dashboard/dist-server/dashboard/src/server/commander/commander-agent.js.map +1 -1
  83. package/dashboard/dist-server/dashboard/src/server/coordinator/chain-map.js +3 -3
  84. package/dashboard/dist-server/dashboard/src/server/coordinator/chain-map.js.map +1 -1
  85. package/dashboard/dist-server/dashboard/src/server/routes/issues.js +34 -0
  86. package/dashboard/dist-server/dashboard/src/server/routes/issues.js.map +1 -1
  87. package/dashboard/dist-server/dashboard/src/server/routes/specs.d.ts +1 -1
  88. package/dashboard/dist-server/dashboard/src/server/routes/specs.js +75 -30
  89. package/dashboard/dist-server/dashboard/src/server/routes/specs.js.map +1 -1
  90. package/dashboard/dist-server/dashboard/src/server/state/event-bus.d.ts +5 -0
  91. package/dashboard/dist-server/dashboard/src/server/state/event-bus.js +5 -0
  92. package/dashboard/dist-server/dashboard/src/server/state/event-bus.js.map +1 -1
  93. package/dashboard/dist-server/dashboard/src/server/ws/handlers/execution-handler.js +2 -3
  94. package/dashboard/dist-server/dashboard/src/server/ws/handlers/execution-handler.js.map +1 -1
  95. package/dashboard/dist-server/dashboard/src/shared/constants.js +5 -0
  96. package/dashboard/dist-server/dashboard/src/shared/constants.js.map +1 -1
  97. package/dashboard/dist-server/dashboard/src/shared/issue-types.d.ts +5 -0
  98. package/dashboard/dist-server/dashboard/src/shared/issue-types.js.map +1 -1
  99. package/dashboard/dist-server/dashboard/src/shared/normalize-task.d.ts +2 -0
  100. package/dashboard/dist-server/dashboard/src/shared/normalize-task.js +75 -0
  101. package/dashboard/dist-server/dashboard/src/shared/normalize-task.js.map +1 -0
  102. package/dashboard/dist-server/dashboard/src/shared/team-types.d.ts +21 -0
  103. package/dashboard/dist-server/dashboard/src/shared/team-types.js.map +1 -1
  104. package/dashboard/dist-server/dashboard/src/shared/types.d.ts +3 -2
  105. package/dashboard/dist-server/dashboard/src/shared/ws-protocol.d.ts +1 -1
  106. package/dashboard/dist-server/dashboard/src/shared/ws-protocol.js.map +1 -1
  107. package/dashboard/dist-server/src/hooks/constants.d.ts +92 -12
  108. package/dashboard/dist-server/src/hooks/constants.js +151 -16
  109. package/dashboard/dist-server/src/hooks/constants.js.map +1 -1
  110. package/dashboard/dist-server/src/types/index.d.ts +5 -0
  111. package/dist/src/commands/collab.d.ts +1 -34
  112. package/dist/src/commands/collab.d.ts.map +1 -1
  113. package/dist/src/commands/collab.js +8 -76
  114. package/dist/src/commands/collab.js.map +1 -1
  115. package/dist/src/commands/hooks.d.ts +5 -1
  116. package/dist/src/commands/hooks.d.ts.map +1 -1
  117. package/dist/src/commands/hooks.js +115 -10
  118. package/dist/src/commands/hooks.js.map +1 -1
  119. package/dist/src/commands/install-ui/InstallConfirm.d.ts +3 -1
  120. package/dist/src/commands/install-ui/InstallConfirm.d.ts.map +1 -1
  121. package/dist/src/commands/install-ui/InstallConfirm.js +3 -1
  122. package/dist/src/commands/install-ui/InstallConfirm.js.map +1 -1
  123. package/dist/src/commands/install-ui/InstallExecution.d.ts.map +1 -1
  124. package/dist/src/commands/install-ui/InstallExecution.js +5 -1
  125. package/dist/src/commands/install-ui/InstallExecution.js.map +1 -1
  126. package/dist/src/commands/install-ui/InstallFlow.d.ts.map +1 -1
  127. package/dist/src/commands/install-ui/InstallFlow.js +7 -3
  128. package/dist/src/commands/install-ui/InstallFlow.js.map +1 -1
  129. package/dist/src/commands/install-ui/StatuslineConfig.d.ts +6 -1
  130. package/dist/src/commands/install-ui/StatuslineConfig.d.ts.map +1 -1
  131. package/dist/src/commands/install-ui/StatuslineConfig.js +27 -5
  132. package/dist/src/commands/install-ui/StatuslineConfig.js.map +1 -1
  133. package/dist/src/commands/spec.d.ts.map +1 -1
  134. package/dist/src/commands/spec.js +7 -2
  135. package/dist/src/commands/spec.js.map +1 -1
  136. package/dist/src/hooks/__tests__/statusline-visual-test.d.ts +7 -0
  137. package/dist/src/hooks/__tests__/statusline-visual-test.d.ts.map +1 -0
  138. package/dist/src/hooks/__tests__/statusline-visual-test.js +236 -0
  139. package/dist/src/hooks/__tests__/statusline-visual-test.js.map +1 -0
  140. package/dist/src/hooks/constants.d.ts +92 -12
  141. package/dist/src/hooks/constants.d.ts.map +1 -1
  142. package/dist/src/hooks/constants.js +151 -16
  143. package/dist/src/hooks/constants.js.map +1 -1
  144. package/dist/src/hooks/guards/index.d.ts +2 -0
  145. package/dist/src/hooks/guards/index.d.ts.map +1 -1
  146. package/dist/src/hooks/guards/index.js +2 -0
  147. package/dist/src/hooks/guards/index.js.map +1 -1
  148. package/dist/src/hooks/guards/preflight-guard.d.ts +29 -0
  149. package/dist/src/hooks/guards/preflight-guard.d.ts.map +1 -0
  150. package/dist/src/hooks/guards/preflight-guard.js +95 -0
  151. package/dist/src/hooks/guards/preflight-guard.js.map +1 -0
  152. package/dist/src/hooks/guards/spec-validator.d.ts +25 -0
  153. package/dist/src/hooks/guards/spec-validator.d.ts.map +1 -0
  154. package/dist/src/hooks/guards/spec-validator.js +66 -0
  155. package/dist/src/hooks/guards/spec-validator.js.map +1 -0
  156. package/dist/src/hooks/index.d.ts +1 -0
  157. package/dist/src/hooks/index.d.ts.map +1 -1
  158. package/dist/src/hooks/index.js +1 -0
  159. package/dist/src/hooks/index.js.map +1 -1
  160. package/dist/src/hooks/keyword-spec-injector.d.ts +21 -0
  161. package/dist/src/hooks/keyword-spec-injector.d.ts.map +1 -0
  162. package/dist/src/hooks/keyword-spec-injector.js +96 -0
  163. package/dist/src/hooks/keyword-spec-injector.js.map +1 -0
  164. package/dist/src/hooks/plugins/spec-injection-plugin.d.ts +2 -1
  165. package/dist/src/hooks/plugins/spec-injection-plugin.d.ts.map +1 -1
  166. package/dist/src/hooks/plugins/spec-injection-plugin.js +21 -12
  167. package/dist/src/hooks/plugins/spec-injection-plugin.js.map +1 -1
  168. package/dist/src/hooks/preflight-core.d.ts +37 -0
  169. package/dist/src/hooks/preflight-core.d.ts.map +1 -0
  170. package/dist/src/hooks/preflight-core.js +86 -0
  171. package/dist/src/hooks/preflight-core.js.map +1 -0
  172. package/dist/src/hooks/spec-bridge.d.ts +40 -0
  173. package/dist/src/hooks/spec-bridge.d.ts.map +1 -0
  174. package/dist/src/hooks/spec-bridge.js +97 -0
  175. package/dist/src/hooks/spec-bridge.js.map +1 -0
  176. package/dist/src/hooks/spec-injector.d.ts.map +1 -1
  177. package/dist/src/hooks/spec-injector.js +18 -12
  178. package/dist/src/hooks/spec-injector.js.map +1 -1
  179. package/dist/src/hooks/statusline.d.ts +8 -17
  180. package/dist/src/hooks/statusline.d.ts.map +1 -1
  181. package/dist/src/hooks/statusline.js +269 -112
  182. package/dist/src/hooks/statusline.js.map +1 -1
  183. package/dist/src/i18n/locales/en.d.ts.map +1 -1
  184. package/dist/src/i18n/locales/en.js +5 -0
  185. package/dist/src/i18n/locales/en.js.map +1 -1
  186. package/dist/src/i18n/locales/zh.d.ts.map +1 -1
  187. package/dist/src/i18n/locales/zh.js +5 -0
  188. package/dist/src/i18n/locales/zh.js.map +1 -1
  189. package/dist/src/i18n/types.d.ts +5 -0
  190. package/dist/src/i18n/types.d.ts.map +1 -1
  191. package/dist/src/team/phase-orchestrator.d.ts +52 -0
  192. package/dist/src/team/phase-orchestrator.d.ts.map +1 -0
  193. package/dist/src/team/phase-orchestrator.js +165 -0
  194. package/dist/src/team/phase-orchestrator.js.map +1 -0
  195. package/dist/src/team/phase-types.d.ts +51 -0
  196. package/dist/src/team/phase-types.d.ts.map +1 -0
  197. package/dist/src/team/phase-types.js +41 -0
  198. package/dist/src/team/phase-types.js.map +1 -0
  199. package/dist/src/tools/collab-adapter.d.ts +17 -0
  200. package/dist/src/tools/collab-adapter.d.ts.map +1 -1
  201. package/dist/src/tools/collab-adapter.js +138 -0
  202. package/dist/src/tools/collab-adapter.js.map +1 -1
  203. package/dist/src/tools/index.d.ts.map +1 -1
  204. package/dist/src/tools/index.js +6 -0
  205. package/dist/src/tools/index.js.map +1 -1
  206. package/dist/src/tools/merge-validator.d.ts +24 -0
  207. package/dist/src/tools/merge-validator.d.ts.map +1 -0
  208. package/dist/src/tools/merge-validator.js +220 -0
  209. package/dist/src/tools/merge-validator.js.map +1 -0
  210. package/dist/src/tools/spec-entry-parser.d.ts +56 -0
  211. package/dist/src/tools/spec-entry-parser.d.ts.map +1 -0
  212. package/dist/src/tools/spec-entry-parser.js +196 -0
  213. package/dist/src/tools/spec-entry-parser.js.map +1 -0
  214. package/dist/src/tools/spec-init.d.ts.map +1 -1
  215. package/dist/src/tools/spec-init.js +66 -92
  216. package/dist/src/tools/spec-init.js.map +1 -1
  217. package/dist/src/tools/spec-keyword-index.d.ts +30 -0
  218. package/dist/src/tools/spec-keyword-index.d.ts.map +1 -0
  219. package/dist/src/tools/spec-keyword-index.js +101 -0
  220. package/dist/src/tools/spec-keyword-index.js.map +1 -0
  221. package/dist/src/tools/spec-loader.d.ts +3 -3
  222. package/dist/src/tools/spec-loader.d.ts.map +1 -1
  223. package/dist/src/tools/spec-loader.js +49 -23
  224. package/dist/src/tools/spec-loader.js.map +1 -1
  225. package/dist/src/tools/team-agents.d.ts +27 -0
  226. package/dist/src/tools/team-agents.d.ts.map +1 -0
  227. package/dist/src/tools/team-agents.js +362 -0
  228. package/dist/src/tools/team-agents.js.map +1 -0
  229. package/dist/src/tools/team-mailbox.d.ts +40 -0
  230. package/dist/src/tools/team-mailbox.d.ts.map +1 -0
  231. package/dist/src/tools/team-mailbox.js +384 -0
  232. package/dist/src/tools/team-mailbox.js.map +1 -0
  233. package/dist/src/tools/team-msg.d.ts +17 -8
  234. package/dist/src/tools/team-msg.d.ts.map +1 -1
  235. package/dist/src/tools/team-msg.js +110 -13
  236. package/dist/src/tools/team-msg.js.map +1 -1
  237. package/dist/src/tools/team-tasks-mcp.d.ts +27 -0
  238. package/dist/src/tools/team-tasks-mcp.d.ts.map +1 -0
  239. package/dist/src/tools/team-tasks-mcp.js +408 -0
  240. package/dist/src/tools/team-tasks-mcp.js.map +1 -0
  241. package/dist/src/types/index.d.ts +5 -0
  242. package/dist/src/types/index.d.ts.map +1 -1
  243. package/package.json +2 -1
  244. package/templates/cli/prompts/workflow-skill-conflict-patterns.txt +3 -3
  245. package/templates/cli/prompts/workflow-skill-lessons-learned.txt +3 -3
  246. package/templates/search-tools.md +1 -1
  247. package/workflows/analyze.md +816 -816
  248. package/workflows/brainstorm.md +471 -471
  249. package/workflows/cli-tools-usage.md +44 -27
  250. package/workflows/codebase-rebuild.md +332 -332
  251. package/workflows/codebase-refresh.md +240 -240
  252. package/workflows/delegate-usage.md +3 -3
  253. package/workflows/execute.md +1 -1
  254. package/workflows/harvest.md +420 -420
  255. package/workflows/integration-test.md +343 -343
  256. package/workflows/issue-analyze.md +6 -2
  257. package/workflows/issue-discover.md +414 -414
  258. package/workflows/issue-execute.md +6 -3
  259. package/workflows/issue-plan.md +5 -2
  260. package/workflows/maestro-coordinate.codex.md +281 -470
  261. package/workflows/maestro-coordinate.md +14 -14
  262. package/workflows/maestro-link-coordinate.md +2 -2
  263. package/workflows/maestro.codex.md +710 -0
  264. package/workflows/maestro.md +10 -11
  265. package/workflows/map.md +111 -111
  266. package/workflows/milestone-complete.md +176 -176
  267. package/workflows/plan.md +1 -1
  268. package/workflows/quick.md +497 -497
  269. package/workflows/refactor.md +300 -300
  270. package/workflows/retrospective.md +1 -1
  271. package/workflows/roadmap.md +335 -335
  272. package/workflows/spec-generate.md +640 -640
  273. package/workflows/specs-add.md +46 -81
  274. package/workflows/specs-load.md +15 -17
  275. package/workflows/specs-setup.md +40 -161
  276. package/.claude/commands/manage-issue-analyze.md +0 -62
  277. package/.claude/commands/manage-issue-execute.md +0 -73
  278. package/.claude/commands/manage-issue-plan.md +0 -62
  279. package/.codex/skills/manage-issue-analyze/SKILL.md +0 -207
  280. package/.codex/skills/manage-issue-execute/SKILL.md +0 -200
  281. package/.codex/skills/manage-issue-plan/SKILL.md +0 -186
@@ -1,816 +1,816 @@
1
- # Workflow: Analyze
2
-
3
- Multi-dimensional iterative analysis with CLI exploration, multi-perspective synthesis, discussion timeline, intent tracking, and decision extraction.
4
-
5
- ## Pipeline Position
6
-
7
- ```
8
- maestro-brainstorm (optional upstream)
9
- ↓ ideas, scored options
10
- maestro-analyze ← THIS
11
- ↓ analysis.md, discussion.md, conclusions.json, context.md
12
- maestro-plan → maestro-execute → maestro-verify
13
- ```
14
-
15
- ## Architecture
16
-
17
- ```
18
- Full mode (-q omitted):
19
- Phase 1: Setup & Scoping → session init, dimension selection, discussion.md
20
- |
21
- Phase 2: CLI Exploration → exploration-codebase.json, explorations.json/perspectives.json
22
- | (cli-explore-agent 3-layer + multi-CLI parallel)
23
- |
24
- Phase 3: Interactive Discussion → discussion.md rounds (max 5)
25
- | (Decision Recording Protocol, Intent Coverage)
26
- |
27
- Phase 4: Six-Dimension Scoring → 6 dimensions × 1-5 score + risk matrix
28
- |
29
- Phase 5: Synthesis & Conclusion → conclusions.json, analysis.md, final discussion.md
30
- |
31
- Phase 6: Decision Extraction → context.md (Locked/Free/Deferred)
32
- └── Next Step: plan / issue / done
33
-
34
- Quick mode (-q):
35
- Phase 1: Setup (minimal) → load context, skip scoping
36
- |
37
- Phase 6: Decision Extraction → context.md (Locked/Free/Deferred)
38
- └── Next Step: plan / done
39
- ```
40
-
41
- ## Arguments
42
-
43
- ```
44
- $ARGUMENTS: "[phase|topic] [-y] [-c] [-q]"
45
-
46
- (no args) -- Milestone-wide analysis (requires init + roadmap)
47
- <phase> -- Phase number (phase-scoped, requires init + roadmap)
48
- <topic> -- Topic text (adhoc if milestone exists, standalone if not)
49
- -y / --yes -- Auto mode, skip interactive scoping, auto-deepen
50
- -c / --continue -- Resume from existing session
51
- -q / --quick -- Quick mode, skip exploration + scoring, go straight to decision extraction
52
- ```
53
-
54
- ## Scope Routing
55
-
56
- ```
57
- // Worktree scope check
58
- IF file_exists(".workflow/worktree-scope.json"):
59
- scope = read(".workflow/worktree-scope.json")
60
- IF $ARGUMENTS matches /^\d+$/ AND parseInt($ARGUMENTS) NOT IN scope.owned_phases:
61
- ERROR "Phase {$ARGUMENTS} not owned by this worktree. Owned: {scope.owned_phases}"
62
- EXIT
63
-
64
- // Auto-bootstrap state.json if missing
65
- IF NOT file_exists(".workflow/state.json"):
66
- mkdir -p .workflow/scratch/
67
- Write minimal state.json: { project: null, status: "active", current_milestone: null,
68
- current_task_id: null, milestones: [], artifacts: [], last_updated: now() }
69
-
70
- // Scope determination
71
- IF $ARGUMENTS is empty:
72
- IF state.json.current_milestone is non-null AND roadmap.md exists:
73
- → scope = "milestone"
74
- → milestone_slug = slugify(current_milestone name)
75
- → Set OUTPUT_DIR = .workflow/scratch/analyze-{milestone_slug}-{date}/
76
- ELSE:
77
- → ERROR E001 "No args and no roadmap — provide topic text or create roadmap first"
78
-
79
- ELSE IF $ARGUMENTS matches /^\d+$/:
80
- IF state.json.current_milestone is non-null AND roadmap.md exists:
81
- → scope = "phase"
82
- → phase_num = parsed number
83
- → phase_slug = resolve from roadmap.md
84
- → Set OUTPUT_DIR = .workflow/scratch/analyze-{phase_slug}-{date}/
85
- ELSE:
86
- → ERROR "Phase number requires init + roadmap"
87
-
88
- ELSE (text argument):
89
- → topic_slug = slugify(text, max 40 chars)
90
- IF state.json.current_milestone is non-null:
91
- → scope = "adhoc"
92
- ELSE:
93
- → scope = "standalone"
94
- → Set OUTPUT_DIR = .workflow/scratch/analyze-{topic_slug}-{date}/
95
-
96
- // Create output directory
97
- mkdir -p {OUTPUT_DIR}
98
- ```
99
-
100
- ## Output Structure
101
-
102
- ```
103
- {OUTPUT_DIR}/
104
- ├── discussion.md # Full timeline: TOC, rounds, decisions, intent coverage
105
- ├── analysis.md # 6-dimension scoring summary + risk matrix + Go/No-Go (skip in -q)
106
- ├── exploration-codebase.json # Codebase exploration (skip in -q)
107
- ├── explorations.json # Single perspective aggregated findings (skip in -q)
108
- ├── perspectives.json # Multi-perspective findings + synthesis (skip in -q)
109
- ├── conclusions.json # Final synthesis, recommendations, decision trail (skip in -q)
110
- └── context.md # Decision extraction: Locked/Free/Deferred decisions for plan
111
- ```
112
-
113
- ---
114
-
115
- ## Process
116
-
117
- ### Step 1: Parse Input & Initialize Session
118
-
119
- Parse $ARGUMENTS to determine mode and flags:
120
- - `-c` present: locate existing session folder (discussion.md exists), resume from last round
121
- - `-y` present: set AUTO_MODE=true
122
- - `-q` present: set QUICK_MODE=true (skip Steps 2-7, jump to Step 8: Decision Extraction)
123
- - Number (e.g., "3") = phase scope: resolve phase slug from roadmap, output to scratch/analyze-{phase-slug}-{date}/
124
- - Text (e.g., "microservices vs monolith") = adhoc/standalone scope: output to scratch/analyze-{slug}-{date}/
125
- - Missing/empty = milestone scope (if roadmap exists) or error E001
126
-
127
- **Session initialization:**
128
- - Session ID: `ANL-{slug}-{YYYY-MM-DD}`
129
- - Output: `OUTPUT_DIR` (always under `.workflow/scratch/`)
130
-
131
- **Load prior context** (milestone/phase scope):
132
- 1. Read `.workflow/project.md` — project vision, constraints, Validated requirements (already shipped), Active requirements (current scope)
133
- 2. Read `.workflow/roadmap.md` — phase structure and dependencies
134
- 3. Read `.workflow/state.json` → `current_milestone`, `artifacts[]`, `accumulated_context` (key_decisions, deferred items, blockers)
135
- 4. Find prior analyze artifacts from `state.json.artifacts[]` where type=analyze and same milestone → load their `context.md` to skip already-decided areas
136
- 5. Find brainstorm artifacts from `state.json.artifacts[]` where type=brainstorm and same milestone → load `guidance-specification.md` if exists
137
- 6. Load project specs: `specs_content = maestro spec load --category planning`
138
-
139
- **Load prior context** (adhoc/standalone scope):
140
- 1. Read `.workflow/project.md` (if exists) — project vision, Validated requirements, Active requirements, Key Decisions
141
- 2. Read `.workflow/state.json` (if exists) → `accumulated_context` (key_decisions, deferred, blockers)
142
- 3. Load project specs: `specs_content = maestro spec load --category planning`
143
-
144
- **Quick mode routing**: If QUICK_MODE, skip to Step 8 (Decision Extraction) after loading context.
145
-
146
- ### Step 1.5: Archive Previous Artifacts
147
-
148
- Skip if `-c` (resuming — working on existing session).
149
-
150
- Before writing any new artifacts, archive existing ones to preserve history:
151
-
152
- ```
153
- ARCHIVE_TARGETS = ["discussion.md", "analysis.md", "explorations.json", "perspectives.json", "conclusions.json", "exploration-codebase.json"]
154
-
155
- has_existing = false
156
- FOR artifact IN ARCHIVE_TARGETS:
157
- IF file exists "$OUTPUT_DIR/${artifact}":
158
- has_existing = true
159
- break
160
-
161
- IF has_existing:
162
- mkdir -p "$OUTPUT_DIR/.history"
163
- TIMESTAMP = current timestamp formatted as "YYYY-MM-DDTHH-mm-ss"
164
- FOR artifact IN ARCHIVE_TARGETS:
165
- IF file exists "$OUTPUT_DIR/${artifact}":
166
- // Extract name and extension: "analysis.md" → "analysis" + "md"
167
- mv "$OUTPUT_DIR/${artifact}" "$OUTPUT_DIR/.history/${name}-${TIMESTAMP}.${ext}"
168
- display "Archived previous analysis artifacts to .history/"
169
- ```
170
-
171
- ### Step 2: Scoping & Dimension Selection
172
-
173
- Skip if `-c` (resuming) or `-y` (auto mode uses defaults).
174
-
175
- **Interactive scoping** via single AskUserQuestion (up to 3 questions):
176
-
177
- 1. **Focus** (multiSelect, header: "分析方向"): Present 3-4 directions from Dimension-Direction Mapping:
178
-
179
- | Dimension | Directions |
180
- |-----------|-----------|
181
- | architecture | System Design, Component Interactions, Technology Choices, Design Patterns |
182
- | implementation | Code Structure, Patterns, Error Handling, Algorithm Analysis |
183
- | performance | Bottlenecks, Optimization, Resource Utilization, Concurrency |
184
- | security | Vulnerabilities, Auth, Data Protection, Input Validation |
185
- | concept | Foundation, Core Mechanisms, Patterns, Trade-offs |
186
- | comparison | Solution Comparison, Pros/Cons, Technology Evaluation |
187
- | decision | Criteria, Trade-off Analysis, Risk Assessment, Impact |
188
- | external_research | Standard Stack, Architecture Patterns, Don't Hand-Roll, Common Pitfalls (external web search) |
189
-
190
- **Auto-suggest `external_research`** when phase goal contains unfamiliar technology keywords or when no codebase patterns exist for the domain (codebase exploration in Step 4.1 returns empty relevant_files).
191
-
192
- 2. **Perspectives** (multiSelect, header: "分析视角"): Up to 4:
193
-
194
- | Perspective | CLI Tool | Focus |
195
- |-------------|----------|-------|
196
- | Technical | gemini | Implementation, code patterns, feasibility |
197
- | Architectural | claude | System design, scalability, interactions |
198
- | Business | codex | Value, ROI, stakeholder impact |
199
- | Domain Expert | gemini | Domain patterns, best practices, standards |
200
-
201
- 3. **Depth** (single-select, header: "分析深度"):
202
- - Quick Overview / Standard / Deep Dive
203
-
204
- **Auto mode defaults**: all dimensions relevant to topic, single comprehensive perspective, Standard depth.
205
-
206
- ### Step 3: Initialize discussion.md
207
-
208
- Write initial `discussion.md` to output directory:
209
- - Dynamic TOC (updated after each round/phase)
210
- - Session metadata (id, topic, dimensions, perspectives, depth)
211
- - User Intent section (original topic/question for intent tracking)
212
- - Current Understanding block (replaceable — overwritten each round, NOT appended): initialized as "To be populated after exploration"
213
- - Empty discussion timeline
214
- - Dimension selection rationale
215
-
216
- ### Step 4: CLI Exploration
217
-
218
- Codebase exploration FIRST, then (optionally) external research, then CLI analysis.
219
-
220
- **Step 4.0: External Research** (only if `external_research` dimension selected)
221
-
222
- Orchestrator performs targeted web searches, then hands results to `workflow-phase-researcher` agent for synthesis.
223
-
224
- ```
225
- // Step 4.0.1: Orchestrator web searches (2-3 focused queries)
226
- queries = [
227
- "{phase_goal} standard library stack {current_year}",
228
- "{phase_goal} architecture patterns best practices",
229
- "{phase_goal} common pitfalls mistakes"
230
- ]
231
-
232
- For each query:
233
- results = WebSearch(query)
234
- // For top 1-2 results: WebFetch(url) to get official docs / README
235
-
236
- // Step 4.0.2: Hand raw search output to researcher agent
237
- Agent(
238
- subagent_type="workflow-phase-researcher",
239
- prompt="""
240
- <objective>
241
- Synthesize the following web search results for Phase {PHASE_NUM}: {phase_name}.
242
- Goal: {phase_goal}
243
- </objective>
244
-
245
- <search_results>
246
- {raw_search_output}
247
- </search_results>
248
-
249
- <task>
250
- From the search results above, extract and structure:
251
- - ## Standard Stack: concrete library recommendations with versions
252
- - ## Architecture Patterns: recommended patterns for this type of work
253
- - ## Don't Hand-Roll: problems with existing solutions (don't build custom)
254
- - ## Common Pitfalls: mistakes to avoid
255
-
256
- Be prescriptive ("use X") not exploratory ("consider X or Y").
257
- Cite sources. Assign confidence levels (HIGH/MEDIUM/LOW).
258
- Do NOT write any files — return structured markdown only.
259
- </task>
260
- """,
261
- run_in_background=false
262
- )
263
-
264
- // Step 4.0.3: Store as researchContext (in-memory, no file written)
265
- researchContext = agent_output
266
- ```
267
-
268
- `researchContext` is passed into Step 4.2 CLI Analysis and Step 8 Decision Extraction.
269
- If `external_research` not selected: `researchContext = null`.
270
-
271
- **Step 4.1: Codebase Exploration** (cli-explore-agent)
272
-
273
- Spawn cli-explore-agent with 3-layer exploration:
274
-
275
- | Layer | Focus | Output |
276
- |-------|-------|--------|
277
- | Layer 1: Module Discovery (Breadth) | Search by topic keywords, identify ALL relevant files, map module boundaries | `relevant_files[]` |
278
- | Layer 2: Structure Tracing (Depth) | Top 3-5 key files: trace call chains 2-3 levels deep, identify data flow | `call_chains[]`, `data_flows[]` |
279
- | Layer 3: Code Anchor Extraction (Detail) | Each key finding: extract code snippet (20-50 lines) with file:line | `code_anchors[]` |
280
-
281
- Output: `exploration-codebase.json` (single) or `explorations/{perspective}.json` (multi-perspective, parallel up to 4)
282
-
283
- **Step 4.2: CLI Analysis** (AFTER exploration)
284
-
285
- Build exploration context from Step 4.1 findings, then spawn CLI analysis.
286
- If `researchContext` is set (from Step 4.0), include it as additional context in each CLI call:
287
-
288
- ```
289
- // Append to CLI prompt when researchContext exists:
290
- "External research findings (treat as strong recommendations, not laws):
291
- {researchContext}"
292
- ```
293
-
294
- - **Single perspective**: one comprehensive CLI call with exploration context
295
- - **Multi-perspective** (up to 4): parallel CLI calls per perspective, each with perspective-specific focus
296
-
297
- CLI calls use `run_in_background: true`. Wait for results before continuing.
298
-
299
- **Step 4.3: Aggregate Findings**
300
-
301
- - Consolidate explorations + CLI results
302
- - Multi-perspective: extract synthesis (convergent themes, conflicting views, unique contributions)
303
- - Write to `explorations.json` (single) or `perspectives.json` (multi)
304
-
305
- `explorations.json` includes `technical_solutions[]`: `{round, solution, problem, rationale, alternatives, status: proposed|validated|rejected, evidence_refs[], next_action}` — populated throughout Step 5 rounds.
306
-
307
- **Step 4.4: Update discussion.md — Round 1**
308
-
309
- Append Round 1 to discussion timeline:
310
- - Sources used
311
- - Key findings with code anchors
312
- - Discussion points
313
- - Open questions
314
-
315
- **Step 4.5: Initial Intent Coverage Check**
316
-
317
- Re-read original User Intent from discussion.md header. Check each intent item against Round 1 findings:
318
- - ✅ addressed
319
- - 🔄 in-progress
320
- - ❌ not yet touched
321
-
322
- Append initial Intent Coverage Check to discussion.md.
323
-
324
- ### Step 5: Interactive Discussion Loop
325
-
326
- Max 5 rounds. Each round follows this sequence:
327
-
328
- **5.1: Current Understanding Summary** (Round >= 2, BEFORE presenting new findings):
329
- Generate 1-2 sentence recap linking previous round conclusions to current starting point.
330
-
331
- **5.2: Present Findings** from latest exploration/analysis
332
-
333
- **5.3: Gather Feedback** (AskUserQuestion, single-select, header: "分析反馈"):
334
- - **继续深入**: Deepen analysis — auto or user-specified direction
335
- - **调整方向**: Different focus or specific questions
336
- - **补充信息**: User has additional context, constraints, or corrections
337
- - **分析完成**: Sufficient — exit to Phase 4
338
-
339
- **5.4: Process Response** (always record user choice + impact to discussion.md):
340
-
341
- | Choice | Action |
342
- |--------|--------|
343
- | 继续深入 | Sub-question (max 4 options: 3 context-driven + 1 heuristic frame-breaker) → CLI/agent exploration → merge findings |
344
- | 调整方向 | Capture new direction → new CLI exploration → Record Decision (old vs new, reason, impact) |
345
- | 补充信息 | Capture user input → integrate → answer questions via CLI if needed → Record corrections |
346
- | 分析完成 | Exit loop → Record why concluding |
347
-
348
- **5.5: Update discussion.md** after each round:
349
- - **Append** Round N: user input, direction, Q&A, corrections, new insights
350
- - **Append Technical Solutions** — for every solution proposed, validated, or rejected this round, record immediately using Technical Solution Record Format in `#### Technical Solutions`
351
- - **Replace** `## Current Understanding` block with latest consolidated understanding
352
- - **Update** `## Table of Contents` with links to new sections
353
-
354
- **5.6: Round Narrative Synthesis** (append after each round):
355
- ```markdown
356
- ### Round N: Narrative Synthesis
357
- **起点**: 基于上一轮的 [conclusions/questions],本轮从 [starting point] 切入。
358
- **关键进展**: [New findings] [confirmed/refuted/modified] 了之前关于 [hypothesis] 的理解。
359
- **决策影响**: 用户选择 [feedback type],导致分析方向 [adjusted/deepened/maintained]。
360
- **当前理解**: 经过本轮,核心认知更新为 [updated understanding]。
361
- **遗留问题**: [remaining questions driving next round]
362
- ```
363
-
364
- **5.7: Intent Drift Check** (every round >= 2):
365
- Re-read original User Intent. Check each item:
366
- - ✅ addressed (in Round N)
367
- - 🔄 in-progress
368
- - ⚠️ implicitly absorbed (needs confirmation)
369
- - ❌ not yet discussed
370
-
371
- If ❌ or ⚠️ items exist → proactively surface to user at start of next round.
372
-
373
- **Auto mode (-y)**: auto-deepen for up to 3 rounds, then synthesize.
374
-
375
- ### Step 6: Six-Dimension Scoring
376
-
377
- Using all exploration findings, discussion insights, and user feedback, score across 6 dimensions:
378
-
379
- | Dimension | Focus Areas | Score |
380
- |-----------|------------|-------|
381
- | Feasibility | Technical difficulty, team capability, time, tooling | 1-5 |
382
- | Impact | User value, business value, tech debt reduction, DX | 1-5 |
383
- | Risk | Failure modes, security, scalability, regression | 1-5 |
384
- | Complexity | Integration points, dependencies, learning curve, testing | 1-5 |
385
- | Dependencies | External services, internal modules, data, infrastructure | 1-5 |
386
- | Alternatives | 2+ other approaches with tradeoffs | N/A |
387
-
388
- Each dimension scored with specific evidence (code refs, data points from exploration).
389
-
390
- Build probability-impact risk matrix from identified risks.
391
-
392
- Formulate Go/No-Go/Conditional recommendation with confidence level.
393
-
394
- ### Step 7: Synthesis & Conclusion
395
-
396
- **7.1: Intent Coverage Verification** (MANDATORY before synthesis):
397
-
398
- ```markdown
399
- ### Intent Coverage Matrix
400
- | # | Original Intent | Status | Where Addressed | Notes |
401
- |---|----------------|--------|-----------------|-------|
402
- | 1 | [intent] | ✅ Addressed | Round N, Conclusion #M | |
403
- | 2 | [intent] | 🔀 Transformed | Round N → M | Original: X → Final: Y |
404
- | 3 | [intent] | ❌ Missed | — | Reason |
405
- ```
406
-
407
- Gate: ❌ Missed items must be either (a) addressed in additional round or (b) confirmed deferred by user.
408
-
409
- **7.2: Consolidate Insights**
410
-
411
- Compile from all phases:
412
- - Decision Trail from all rounds
413
- - Key conclusions with evidence + confidence (high/medium/low)
414
- - Recommendations with rationale + priority (high/medium/low) + actionable steps — **merge validated `technical_solutions[]` from explorations.json as high-priority recommendations**
415
- - Open questions, follow-up suggestions
416
- - Write to `conclusions.json`
417
-
418
- **7.3: Write analysis.md** (legacy compatible — 6-dimension summary):
419
- - Executive summary with overall assessment
420
- - Per-dimension scores with key evidence
421
- - Dimension summary table
422
- - Risk matrix visualization
423
- - Go/No-Go recommendation with confidence
424
-
425
- **7.4: Final discussion.md Update**:
426
- - Conclusions section: summary, ranked key conclusions, prioritized recommendations
427
- - Current Understanding (Final): what established, what clarified/corrected, key insights
428
- - Decision Trail: critical decisions, direction changes timeline, trade-offs
429
- - Intent Coverage Matrix
430
- - Session statistics: rounds, duration, sources, artifacts, decision count
431
-
432
- **7.5: Interactive Recommendation Review** (skip in auto mode):
433
-
434
- Present recommendations, batch-confirm via AskUserQuestion (max 4 per call, ordered by priority):
435
- - **确认**: Accept as-is → review_status = "accepted"
436
- - **修改**: Adjust scope/steps → review_status = "modified"
437
- - **删除**: Not needed → review_status = "rejected"
438
-
439
- Update conclusions.json with review_status for each recommendation.
440
-
441
- ### Step 8: Decision Extraction
442
-
443
- **This step runs ALWAYS** — in full mode after synthesis, in quick mode (`-q`) as the main step.
444
-
445
- **8.1: Identify Gray Areas**
446
-
447
- Analyze phase goal + loaded context (project.md, roadmap, brainstorm, prior context.md files, exploration findings if available) to find undecided implementation areas.
448
-
449
- **Domain-aware gray area generation:**
450
- - Something users SEE: layout, density, interactions, states
451
- - Something users CALL: responses, errors, auth, versioning
452
- - Something users RUN: output format, flags, modes, error handling
453
- - Something users READ: structure, tone, depth, flow
454
- - Something being ORGANIZED: criteria, grouping, naming, exceptions
455
-
456
- Generate 3-5 **phase-specific** gray areas.
457
- Skip areas already decided in prior context.md files.
458
- If `guidance-specification.md` loaded: skip MUST/MUST NOT areas (already locked), focus on SHOULD/MAY areas and gaps.
459
- If full mode completed: use exploration findings + scoring to inform gray area quality.
460
-
461
- **8.2: Area Selection** (skip if `-y`)
462
-
463
- ```
464
- AskUserQuestion({
465
- question: "Which areas need discussion for this phase?",
466
- options: [
467
- { label: "Area 1: {title}", description: "{brief description}" },
468
- { label: "Area 2: {title}", description: "{brief description}" },
469
- { label: "Area 3: {title}", description: "{brief description}" },
470
- { label: "All areas", description: "Discuss everything" },
471
- { label: "Skip", description: "Context is clear enough — no decisions needed" }
472
- ]
473
- })
474
- ```
475
-
476
- If "Skip": write minimal context.md (empty Locked/Free/Deferred sections), proceed to Step 9.
477
-
478
- **8.3: Deep-Dive Discussion**
479
-
480
- For each selected area, conduct multi-round interactive dialog (3-4 questions per area):
481
-
482
- ```
483
- AskUserQuestion({
484
- question: "[{area}] {specific question about implementation choice}",
485
- options: [
486
- { label: "Option A", description: "{description with tradeoffs}" },
487
- { label: "Option B", description: "{description with tradeoffs}" },
488
- { label: "Option C", description: "{description with tradeoffs}" }
489
- ]
490
- })
491
- ```
492
-
493
- Record each decision using Decision Recording Protocol.
494
-
495
- After questions per area: "More questions about {area}, or move to next?"
496
-
497
- **Scope guardrail**: Phase boundary from roadmap.md is FIXED. Discussion clarifies HOW to implement, not WHETHER to add more. If user suggests new capabilities → "That belongs in its own phase. I will note it for later." → capture in Deferred.
498
-
499
- **8.4: Classify Decisions**
500
-
501
- - **Locked**: firm decisions that cannot be changed during implementation
502
- - **Free**: open for implementation discretion (implementer can choose)
503
- - **Deferred**: postponed to a later phase (captured but not acted on)
504
-
505
- **If `researchContext` is set**: for each Free decision area, append a research-backed recommendation:
506
-
507
- ```
508
- ### Free — {area}
509
- Implementer's choice. Research suggests: {relevant finding from researchContext}.
510
- (e.g., "Standard Stack recommends React Query for server state. Common pitfall: avoid mixing with Redux for async.")
511
- ```
512
-
513
- This makes research findings visible to the planner through context.md without imposing hard constraints.
514
-
515
- **8.5: Write context.md**
516
-
517
- Write to `OUTPUT_DIR/context.md`:
518
-
519
- ```markdown
520
- # Context: Phase {NN} -- {PHASE_TITLE}
521
-
522
- **Date**: {date}
523
- **Areas discussed**: {list of areas}
524
-
525
- ## Decisions
526
-
527
- ### Decision 1: {TITLE}
528
- - **Context**: {what and why}
529
- - **Options**:
530
- 1. {opt1}
531
- 2. {opt2}
532
- - **Chosen**: {selected}
533
- - **Reason**: {rationale}
534
-
535
- ## Constraints
536
-
537
- ### Locked
538
- {decisions that are final and must be followed}
539
-
540
- ### Free
541
- {decisions left to implementer discretion}
542
-
543
- ### Deferred
544
- {ideas captured but postponed to later phases}
545
-
546
- ## Code Context
547
- {relevant code references from exploration or discussion}
548
- ```
549
-
550
- **8.6: Update project.md Key Decisions** (phase mode only)
551
-
552
- ```
553
- IF phase mode AND Locked decisions exist:
554
- Read .workflow/project.md
555
- Find "## Key Decisions" table
556
-
557
- For each Locked decision from Step 8.4:
558
- Check if decision already exists in Key Decisions table (by title match)
559
- If not duplicate:
560
- Append row to Key Decisions table:
561
- | {decision title} | {rationale summary} | Phase {NN} — {date} |
562
-
563
- Write updated project.md
564
- Display: "project.md: {count} key decisions recorded"
565
- ```
566
-
567
- **8.7: Auto-create Issues from Deferred Items**
568
-
569
- ```
570
- deferred_items = decisions.filter(d => d.classification == "Deferred")
571
-
572
- IF deferred_items.length > 0:
573
- mkdir -p ".workflow/issues"
574
- today = format(now(), "YYYYMMDD")
575
- counter = next sequence number for today
576
-
577
- FOR each item IN deferred_items:
578
- issue_id = "ISS-{today}-{counter padded to 3 digits}"
579
- issue = {
580
- id: issue_id,
581
- title: "Deferred: " + item.title,
582
- status: "deferred",
583
- priority: 5,
584
- severity: "low",
585
- source: "analyze",
586
- phase_ref: PHASE_NUM,
587
- description: item.context + " -- Chosen to defer: " + item.reason,
588
- tags: ["deferred", "analyze"],
589
- created_at: now()
590
- }
591
- Append JSON line to .workflow/issues/issues.jsonl
592
- counter++
593
-
594
- Print: "Created {deferred_items.length} deferred issues for tracking"
595
- ```
596
-
597
- ### Step 8.8: Register Artifact
598
-
599
- ```
600
- // Register in state.json artifact registry
601
- Read .workflow/state.json
602
- next_id = max(artifacts.filter(a => a.type == "analyze").map(a => parseInt(a.id.replace("ANL-","")))) + 1
603
- // If no analyze artifacts exist: next_id = 1
604
-
605
- artifact = {
606
- id: "ANL-{next_id padded to 3}",
607
- type: "analyze",
608
- milestone: state.json.current_milestone, // null if standalone
609
- phase: phase_num, // null if milestone/adhoc/standalone
610
- scope: scope, // "milestone"|"phase"|"adhoc"|"standalone"
611
- path: OUTPUT_DIR relative to .workflow/, // e.g. "scratch/analyze-auth-2026-04-20"
612
- status: "completed",
613
- depends_on: null,
614
- harvested: false,
615
- created_at: session_start_time,
616
- completed_at: now()
617
- }
618
-
619
- state.json.artifacts.push(artifact)
620
- state.json.last_updated = now()
621
- Write state.json (atomic: write tmp + rename)
622
- ```
623
-
624
- ### Step 9: Report & Next Step
625
-
626
- Display summary:
627
- - Overall assessment score and recommendation (full mode) or "Quick decision extraction" (quick mode)
628
- - Decisions captured (Locked/Free/Deferred counts)
629
- - Key conclusions (if full mode)
630
- - Session stats
631
-
632
- **Next Step Selection** (AskUserQuestion, single-select, header: "Next Step"):
633
- - **快速执行**: Skill({ skill: "maestro-quick", args: "{task_description} --full" }) — build context from conclusions
634
- - **进入规划**: Phase mode → Skill({ skill: "maestro-plan", args: "{phase}" }); Scratch mode → Skill({ skill: "maestro-plan", args: "--dir {output_dir}" }) — plan directly against scratch directory
635
- - **产出Issue**: Convert recommendations to tracked issues
636
- - **完成**: No further action
637
-
638
- Handle selection:
639
-
640
- | Choice | Action |
641
- |--------|--------|
642
- | 快速执行 | Build `taskDescription` from high/medium priority accepted recommendations. Assemble context from exploration. Invoke Skill immediately. |
643
- | 进入规划 | **Implementation Scoping** (below), then invoke Skill. |
644
- | 产出Issue | For each accepted/modified recommendation: create issue. |
645
- | 完成 | No further action. |
646
-
647
- **Implementation Scoping** (for "进入规划" only):
648
-
649
- Before invoking maestro-plan, build and persist `implementation_scope` so the planner has concrete "what + done-when" specs:
650
-
651
- ```
652
- // Step A: Build implementation scope from accepted/modified recommendations
653
- actionableRecs = conclusions.recommendations
654
- .filter(r => r.review_status in ["accepted", "modified"])
655
- .sort by priority (high first)
656
-
657
- implementation_scope = actionableRecs.map(rec => ({
658
- objective: rec.action, // WHAT to do
659
- rationale: rec.rationale, // WHY
660
- priority: rec.priority,
661
- target_files: rec.steps.flatMap(s => s.target) // WHERE (from steps + code_anchors)
662
- .concat(code_anchors matching rec),
663
- acceptance_criteria: rec.steps.map(s => // DONE WHEN
664
- s.verification || s.description),
665
- change_summary: rec.steps.map(s => // HOW (brief)
666
- "${s.target}: ${s.description}").join('; ')
667
- }))
668
-
669
- // Step B: User scope confirmation (skip in auto mode / quick mode)
670
- IF NOT AUTO_MODE:
671
- Display implementation scope summary:
672
- For each item: objective [priority], target files, "Done when: ..."
673
- AskUserQuestion (single-select, header: "Scope确认"):
674
- - "确认执行": Scope is clear, proceed to planning
675
- - "调整范围": Narrow or expand scope
676
- - "补充标准": Add/refine acceptance criteria
677
- Handle adjustments, re-confirm if needed
678
-
679
- // Step C: Persist to conclusions.json
680
- conclusions.implementation_scope = implementation_scope
681
- Write updated conclusions.json to OUTPUT_DIR
682
-
683
- // Step D: Invoke plan
684
- Phase mode: Skill({ skill: "maestro-plan", args: "{phase}" })
685
- Scratch mode: Skill({ skill: "maestro-plan", args: "--dir {output_dir}" })
686
- ```
687
-
688
- The planner reads `conclusions.json.implementation_scope` and maps:
689
- - `scope.objective` → task title/description
690
- - `scope.acceptance_criteria` → `convergence.criteria` (seed, planner makes grep-verifiable)
691
- - `scope.target_files` → `files[]` + `read_first[]`
692
- - `scope.priority` → task/wave ordering
693
-
694
- Update index.json timestamps.
695
-
696
- ```
697
- == maestro-analyze complete ==
698
- Session: {session_id}
699
- Output: {output_dir}/
700
- Mode: {full|quick}
701
- Rounds: {round_count} (full mode only)
702
- Score: {recommendation} ({confidence}) (full mode only)
703
- Decisions: {decision_count} (Locked: {n}, Free: {n}, Deferred: {n})
704
-
705
- Files:
706
- context.md — Locked/Free/Deferred decisions for plan
707
- discussion.md — Full discussion timeline (full mode)
708
- analysis.md — 6-dimension scoring summary (full mode)
709
- conclusions.json — Structured conclusions (full mode)
710
-
711
- Next:
712
- Skill({ skill: "maestro-quick", args: "{task}" }) — Quick execute
713
- Skill({ skill: "maestro-plan", args: "{phase}" }) — Full phase planning (phase mode)
714
- Skill({ skill: "maestro-plan", args: "--dir {output_dir}" }) — Plan in scratch dir (scratch mode)
715
- ```
716
-
717
- ---
718
-
719
- ## Decision Recording Protocol
720
-
721
- Record immediately when any occur:
722
-
723
- | Trigger | What to Record |
724
- |---------|---------------|
725
- | Direction choice | What chosen, why, alternatives discarded |
726
- | Key finding | Content, impact scope, confidence, hypothesis impact |
727
- | Assumption change | Old → new understanding, reason, impact |
728
- | User feedback | Input, rationale for adoption/adjustment |
729
- | Disagreement/trade-off | Conflicting views, trade-off basis, final choice |
730
- | Scope adjustment | Before/after scope, trigger reason |
731
- | **Technical solution proposed/validated/rejected** | Solution description, rationale, alternatives considered, status |
732
-
733
- **Decision Record Format**:
734
- ```
735
- > **Decision**: [Description]
736
- > - **Context**: [Trigger]
737
- > - **Options considered**: [Alternatives]
738
- > - **Chosen**: [Approach] — **Reason**: [Rationale]
739
- > - **Rejected**: [Why other options were discarded]
740
- > - **Impact**: [Effect on analysis]
741
- ```
742
-
743
- **Technical Solution Record Format**:
744
- ```
745
- > **Solution**: [Description — what approach, pattern, or implementation]
746
- > - **Status**: [Proposed / Validated / Rejected]
747
- > - **Problem**: [What problem this solves]
748
- > - **Rationale**: [Why this approach]
749
- > - **Alternatives**: [Other options considered and why not chosen]
750
- > - **Evidence**: [file:line or code anchor references]
751
- > - **Next Action**: [Follow-up required or none]
752
- ```
753
-
754
- ## Discussion Timeline (discussion.md)
755
-
756
- Each round appends:
757
- - User feedback and direction choice
758
- - New findings with code anchors
759
- - Narrative Synthesis (起点 → 关键进展 → 决策影响 → 当前理解 → 遗留问题)
760
- - Intent Coverage Check (Round >= 2)
761
-
762
- Replaceable blocks (overwritten each round):
763
- - `## Current Understanding` — latest consolidated understanding
764
- - `## Table of Contents` — updated with new section links
765
-
766
- ## Six Dimensions
767
-
768
- | Dimension | Focus Areas |
769
- |-----------|------------|
770
- | Feasibility | Technical difficulty, team capability, time, tooling |
771
- | Impact | User value, business value, tech debt reduction, DX |
772
- | Risk | Failure modes, security, scalability, regression |
773
- | Complexity | Integration points, dependencies, learning curve, testing |
774
- | Dependencies | External services, internal modules, data, infrastructure |
775
- | Alternatives | 2+ other approaches with tradeoffs |
776
-
777
- ## Key Design Principles
778
-
779
- 1. **Iterative Deepening**: Multi-round discussion (max 5) with user feedback steering direction
780
- 2. **CLI-Assisted Exploration**: cli-explore-agent for codebase + multi-CLI parallel analysis
781
- 3. **Discussion Timeline**: discussion.md as living document — rounds appended, Current Understanding replaced
782
- 4. **Decision Recording Protocol**: Immediate capture of decisions, findings, assumption changes
783
- 5. **Intent Coverage Tracking**: Original user intent checked every round (✅🔄⚠️❌)
784
- 6. **Six-Dimension Scoring**: Feasibility, Impact, Risk, Complexity, Dependencies, Alternatives
785
- 7. **Multi-Perspective Synthesis**: Up to 4 perspectives with convergent/conflicting/unique extraction
786
- 8. **Decision Extraction**: Gray area identification → interactive discussion → Locked/Free/Deferred classification → context.md
787
- 9. **Dual Depth**: Full mode (explore→score→decide) or Quick mode (-q, decide only)
788
-
789
- ## Quality Criteria
790
-
791
- **Full mode:**
792
- - All 6 dimensions analyzed with evidence-backed scores
793
- - Discussion timeline has narrative synthesis per round
794
- - Decision Recording Protocol applied consistently
795
- - Intent Coverage verified with no unresolved ❌ items
796
- - Risk matrix populated with identified risks
797
- - At least 2 alternatives compared with tradeoffs
798
- - Go/No-Go/Conditional recommendation with confidence level
799
- - Code references included where relevant (file paths, line numbers)
800
-
801
- **Both modes (full + quick):**
802
- - context.md written with all decisions classified as Locked/Free/Deferred
803
- - Gray areas identified through phase-specific analysis
804
- - Scope creep redirected to Deferred section
805
- - Every decision follows Context/Options/Chosen/Reason protocol
806
- - Prior context loaded and applied (no re-asking decided questions)
807
-
808
- ## Error Handling
809
-
810
- | Error | Resolution |
811
- |-------|------------|
812
- | cli-explore-agent fails | Continue with available context, note limitation |
813
- | CLI timeout | Retry with shorter prompt, or skip perspective |
814
- | Max rounds reached | Force synthesis, offer continuation |
815
- | No relevant findings | Broaden search, ask user for clarification |
816
- | Session folder conflict | Append timestamp suffix |
1
+ # Workflow: Analyze
2
+
3
+ Multi-dimensional iterative analysis with CLI exploration, multi-perspective synthesis, discussion timeline, intent tracking, and decision extraction.
4
+
5
+ ## Pipeline Position
6
+
7
+ ```
8
+ maestro-brainstorm (optional upstream)
9
+ ↓ ideas, scored options
10
+ maestro-analyze ← THIS
11
+ ↓ analysis.md, discussion.md, conclusions.json, context.md
12
+ maestro-plan → maestro-execute → maestro-verify
13
+ ```
14
+
15
+ ## Architecture
16
+
17
+ ```
18
+ Full mode (-q omitted):
19
+ Phase 1: Setup & Scoping → session init, dimension selection, discussion.md
20
+ |
21
+ Phase 2: CLI Exploration → exploration-codebase.json, explorations.json/perspectives.json
22
+ | (cli-explore-agent 3-layer + multi-CLI parallel)
23
+ |
24
+ Phase 3: Interactive Discussion → discussion.md rounds (max 5)
25
+ | (Decision Recording Protocol, Intent Coverage)
26
+ |
27
+ Phase 4: Six-Dimension Scoring → 6 dimensions × 1-5 score + risk matrix
28
+ |
29
+ Phase 5: Synthesis & Conclusion → conclusions.json, analysis.md, final discussion.md
30
+ |
31
+ Phase 6: Decision Extraction → context.md (Locked/Free/Deferred)
32
+ └── Next Step: plan / issue / done
33
+
34
+ Quick mode (-q):
35
+ Phase 1: Setup (minimal) → load context, skip scoping
36
+ |
37
+ Phase 6: Decision Extraction → context.md (Locked/Free/Deferred)
38
+ └── Next Step: plan / done
39
+ ```
40
+
41
+ ## Arguments
42
+
43
+ ```
44
+ $ARGUMENTS: "[phase|topic] [-y] [-c] [-q]"
45
+
46
+ (no args) -- Milestone-wide analysis (requires init + roadmap)
47
+ <phase> -- Phase number (phase-scoped, requires init + roadmap)
48
+ <topic> -- Topic text (adhoc if milestone exists, standalone if not)
49
+ -y / --yes -- Auto mode, skip interactive scoping, auto-deepen
50
+ -c / --continue -- Resume from existing session
51
+ -q / --quick -- Quick mode, skip exploration + scoring, go straight to decision extraction
52
+ ```
53
+
54
+ ## Scope Routing
55
+
56
+ ```
57
+ // Worktree scope check
58
+ IF file_exists(".workflow/worktree-scope.json"):
59
+ scope = read(".workflow/worktree-scope.json")
60
+ IF $ARGUMENTS matches /^\d+$/ AND parseInt($ARGUMENTS) NOT IN scope.owned_phases:
61
+ ERROR "Phase {$ARGUMENTS} not owned by this worktree. Owned: {scope.owned_phases}"
62
+ EXIT
63
+
64
+ // Auto-bootstrap state.json if missing
65
+ IF NOT file_exists(".workflow/state.json"):
66
+ mkdir -p .workflow/scratch/
67
+ Write minimal state.json: { project: null, status: "active", current_milestone: null,
68
+ current_task_id: null, milestones: [], artifacts: [], last_updated: now() }
69
+
70
+ // Scope determination
71
+ IF $ARGUMENTS is empty:
72
+ IF state.json.current_milestone is non-null AND roadmap.md exists:
73
+ → scope = "milestone"
74
+ → milestone_slug = slugify(current_milestone name)
75
+ → Set OUTPUT_DIR = .workflow/scratch/analyze-{milestone_slug}-{date}/
76
+ ELSE:
77
+ → ERROR E001 "No args and no roadmap — provide topic text or create roadmap first"
78
+
79
+ ELSE IF $ARGUMENTS matches /^\d+$/:
80
+ IF state.json.current_milestone is non-null AND roadmap.md exists:
81
+ → scope = "phase"
82
+ → phase_num = parsed number
83
+ → phase_slug = resolve from roadmap.md
84
+ → Set OUTPUT_DIR = .workflow/scratch/analyze-{phase_slug}-{date}/
85
+ ELSE:
86
+ → ERROR "Phase number requires init + roadmap"
87
+
88
+ ELSE (text argument):
89
+ → topic_slug = slugify(text, max 40 chars)
90
+ IF state.json.current_milestone is non-null:
91
+ → scope = "adhoc"
92
+ ELSE:
93
+ → scope = "standalone"
94
+ → Set OUTPUT_DIR = .workflow/scratch/analyze-{topic_slug}-{date}/
95
+
96
+ // Create output directory
97
+ mkdir -p {OUTPUT_DIR}
98
+ ```
99
+
100
+ ## Output Structure
101
+
102
+ ```
103
+ {OUTPUT_DIR}/
104
+ ├── discussion.md # Full timeline: TOC, rounds, decisions, intent coverage
105
+ ├── analysis.md # 6-dimension scoring summary + risk matrix + Go/No-Go (skip in -q)
106
+ ├── exploration-codebase.json # Codebase exploration (skip in -q)
107
+ ├── explorations.json # Single perspective aggregated findings (skip in -q)
108
+ ├── perspectives.json # Multi-perspective findings + synthesis (skip in -q)
109
+ ├── conclusions.json # Final synthesis, recommendations, decision trail (skip in -q)
110
+ └── context.md # Decision extraction: Locked/Free/Deferred decisions for plan
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Process
116
+
117
+ ### Step 1: Parse Input & Initialize Session
118
+
119
+ Parse $ARGUMENTS to determine mode and flags:
120
+ - `-c` present: locate existing session folder (discussion.md exists), resume from last round
121
+ - `-y` present: set AUTO_MODE=true
122
+ - `-q` present: set QUICK_MODE=true (skip Steps 2-7, jump to Step 8: Decision Extraction)
123
+ - Number (e.g., "3") = phase scope: resolve phase slug from roadmap, output to scratch/analyze-{phase-slug}-{date}/
124
+ - Text (e.g., "microservices vs monolith") = adhoc/standalone scope: output to scratch/analyze-{slug}-{date}/
125
+ - Missing/empty = milestone scope (if roadmap exists) or error E001
126
+
127
+ **Session initialization:**
128
+ - Session ID: `ANL-{slug}-{YYYY-MM-DD}`
129
+ - Output: `OUTPUT_DIR` (always under `.workflow/scratch/`)
130
+
131
+ **Load prior context** (milestone/phase scope):
132
+ 1. Read `.workflow/project.md` — project vision, constraints, Validated requirements (already shipped), Active requirements (current scope)
133
+ 2. Read `.workflow/roadmap.md` — phase structure and dependencies
134
+ 3. Read `.workflow/state.json` → `current_milestone`, `artifacts[]`, `accumulated_context` (key_decisions, deferred items, blockers)
135
+ 4. Find prior analyze artifacts from `state.json.artifacts[]` where type=analyze and same milestone → load their `context.md` to skip already-decided areas
136
+ 5. Find brainstorm artifacts from `state.json.artifacts[]` where type=brainstorm and same milestone → load `guidance-specification.md` if exists
137
+ 6. Load project specs: `specs_content = maestro spec load --category arch`
138
+
139
+ **Load prior context** (adhoc/standalone scope):
140
+ 1. Read `.workflow/project.md` (if exists) — project vision, Validated requirements, Active requirements, Key Decisions
141
+ 2. Read `.workflow/state.json` (if exists) → `accumulated_context` (key_decisions, deferred, blockers)
142
+ 3. Load project specs: `specs_content = maestro spec load --category arch`
143
+
144
+ **Quick mode routing**: If QUICK_MODE, skip to Step 8 (Decision Extraction) after loading context.
145
+
146
+ ### Step 1.5: Archive Previous Artifacts
147
+
148
+ Skip if `-c` (resuming — working on existing session).
149
+
150
+ Before writing any new artifacts, archive existing ones to preserve history:
151
+
152
+ ```
153
+ ARCHIVE_TARGETS = ["discussion.md", "analysis.md", "explorations.json", "perspectives.json", "conclusions.json", "exploration-codebase.json"]
154
+
155
+ has_existing = false
156
+ FOR artifact IN ARCHIVE_TARGETS:
157
+ IF file exists "$OUTPUT_DIR/${artifact}":
158
+ has_existing = true
159
+ break
160
+
161
+ IF has_existing:
162
+ mkdir -p "$OUTPUT_DIR/.history"
163
+ TIMESTAMP = current timestamp formatted as "YYYY-MM-DDTHH-mm-ss"
164
+ FOR artifact IN ARCHIVE_TARGETS:
165
+ IF file exists "$OUTPUT_DIR/${artifact}":
166
+ // Extract name and extension: "analysis.md" → "analysis" + "md"
167
+ mv "$OUTPUT_DIR/${artifact}" "$OUTPUT_DIR/.history/${name}-${TIMESTAMP}.${ext}"
168
+ display "Archived previous analysis artifacts to .history/"
169
+ ```
170
+
171
+ ### Step 2: Scoping & Dimension Selection
172
+
173
+ Skip if `-c` (resuming) or `-y` (auto mode uses defaults).
174
+
175
+ **Interactive scoping** via single AskUserQuestion (up to 3 questions):
176
+
177
+ 1. **Focus** (multiSelect, header: "分析方向"): Present 3-4 directions from Dimension-Direction Mapping:
178
+
179
+ | Dimension | Directions |
180
+ |-----------|-----------|
181
+ | architecture | System Design, Component Interactions, Technology Choices, Design Patterns |
182
+ | implementation | Code Structure, Patterns, Error Handling, Algorithm Analysis |
183
+ | performance | Bottlenecks, Optimization, Resource Utilization, Concurrency |
184
+ | security | Vulnerabilities, Auth, Data Protection, Input Validation |
185
+ | concept | Foundation, Core Mechanisms, Patterns, Trade-offs |
186
+ | comparison | Solution Comparison, Pros/Cons, Technology Evaluation |
187
+ | decision | Criteria, Trade-off Analysis, Risk Assessment, Impact |
188
+ | external_research | Standard Stack, Architecture Patterns, Don't Hand-Roll, Common Pitfalls (external web search) |
189
+
190
+ **Auto-suggest `external_research`** when phase goal contains unfamiliar technology keywords or when no codebase patterns exist for the domain (codebase exploration in Step 4.1 returns empty relevant_files).
191
+
192
+ 2. **Perspectives** (multiSelect, header: "分析视角"): Up to 4:
193
+
194
+ | Perspective | CLI Tool | Focus |
195
+ |-------------|----------|-------|
196
+ | Technical | gemini | Implementation, code patterns, feasibility |
197
+ | Architectural | claude | System design, scalability, interactions |
198
+ | Business | codex | Value, ROI, stakeholder impact |
199
+ | Domain Expert | gemini | Domain patterns, best practices, standards |
200
+
201
+ 3. **Depth** (single-select, header: "分析深度"):
202
+ - Quick Overview / Standard / Deep Dive
203
+
204
+ **Auto mode defaults**: all dimensions relevant to topic, single comprehensive perspective, Standard depth.
205
+
206
+ ### Step 3: Initialize discussion.md
207
+
208
+ Write initial `discussion.md` to output directory:
209
+ - Dynamic TOC (updated after each round/phase)
210
+ - Session metadata (id, topic, dimensions, perspectives, depth)
211
+ - User Intent section (original topic/question for intent tracking)
212
+ - Current Understanding block (replaceable — overwritten each round, NOT appended): initialized as "To be populated after exploration"
213
+ - Empty discussion timeline
214
+ - Dimension selection rationale
215
+
216
+ ### Step 4: CLI Exploration
217
+
218
+ Codebase exploration FIRST, then (optionally) external research, then CLI analysis.
219
+
220
+ **Step 4.0: External Research** (only if `external_research` dimension selected)
221
+
222
+ Orchestrator performs targeted web searches, then hands results to `workflow-phase-researcher` agent for synthesis.
223
+
224
+ ```
225
+ // Step 4.0.1: Orchestrator web searches (2-3 focused queries)
226
+ queries = [
227
+ "{phase_goal} standard library stack {current_year}",
228
+ "{phase_goal} architecture patterns best practices",
229
+ "{phase_goal} common pitfalls mistakes"
230
+ ]
231
+
232
+ For each query:
233
+ results = WebSearch(query)
234
+ // For top 1-2 results: WebFetch(url) to get official docs / README
235
+
236
+ // Step 4.0.2: Hand raw search output to researcher agent
237
+ Agent(
238
+ subagent_type="workflow-phase-researcher",
239
+ prompt="""
240
+ <objective>
241
+ Synthesize the following web search results for Phase {PHASE_NUM}: {phase_name}.
242
+ Goal: {phase_goal}
243
+ </objective>
244
+
245
+ <search_results>
246
+ {raw_search_output}
247
+ </search_results>
248
+
249
+ <task>
250
+ From the search results above, extract and structure:
251
+ - ## Standard Stack: concrete library recommendations with versions
252
+ - ## Architecture Patterns: recommended patterns for this type of work
253
+ - ## Don't Hand-Roll: problems with existing solutions (don't build custom)
254
+ - ## Common Pitfalls: mistakes to avoid
255
+
256
+ Be prescriptive ("use X") not exploratory ("consider X or Y").
257
+ Cite sources. Assign confidence levels (HIGH/MEDIUM/LOW).
258
+ Do NOT write any files — return structured markdown only.
259
+ </task>
260
+ """,
261
+ run_in_background=false
262
+ )
263
+
264
+ // Step 4.0.3: Store as researchContext (in-memory, no file written)
265
+ researchContext = agent_output
266
+ ```
267
+
268
+ `researchContext` is passed into Step 4.2 CLI Analysis and Step 8 Decision Extraction.
269
+ If `external_research` not selected: `researchContext = null`.
270
+
271
+ **Step 4.1: Codebase Exploration** (cli-explore-agent)
272
+
273
+ Spawn cli-explore-agent with 3-layer exploration:
274
+
275
+ | Layer | Focus | Output |
276
+ |-------|-------|--------|
277
+ | Layer 1: Module Discovery (Breadth) | Search by topic keywords, identify ALL relevant files, map module boundaries | `relevant_files[]` |
278
+ | Layer 2: Structure Tracing (Depth) | Top 3-5 key files: trace call chains 2-3 levels deep, identify data flow | `call_chains[]`, `data_flows[]` |
279
+ | Layer 3: Code Anchor Extraction (Detail) | Each key finding: extract code snippet (20-50 lines) with file:line | `code_anchors[]` |
280
+
281
+ Output: `exploration-codebase.json` (single) or `explorations/{perspective}.json` (multi-perspective, parallel up to 4)
282
+
283
+ **Step 4.2: CLI Analysis** (AFTER exploration)
284
+
285
+ Build exploration context from Step 4.1 findings, then spawn CLI analysis.
286
+ If `researchContext` is set (from Step 4.0), include it as additional context in each CLI call:
287
+
288
+ ```
289
+ // Append to CLI prompt when researchContext exists:
290
+ "External research findings (treat as strong recommendations, not laws):
291
+ {researchContext}"
292
+ ```
293
+
294
+ - **Single perspective**: one comprehensive CLI call with exploration context
295
+ - **Multi-perspective** (up to 4): parallel CLI calls per perspective, each with perspective-specific focus
296
+
297
+ CLI calls use `run_in_background: true`. Wait for results before continuing.
298
+
299
+ **Step 4.3: Aggregate Findings**
300
+
301
+ - Consolidate explorations + CLI results
302
+ - Multi-perspective: extract synthesis (convergent themes, conflicting views, unique contributions)
303
+ - Write to `explorations.json` (single) or `perspectives.json` (multi)
304
+
305
+ `explorations.json` includes `technical_solutions[]`: `{round, solution, problem, rationale, alternatives, status: proposed|validated|rejected, evidence_refs[], next_action}` — populated throughout Step 5 rounds.
306
+
307
+ **Step 4.4: Update discussion.md — Round 1**
308
+
309
+ Append Round 1 to discussion timeline:
310
+ - Sources used
311
+ - Key findings with code anchors
312
+ - Discussion points
313
+ - Open questions
314
+
315
+ **Step 4.5: Initial Intent Coverage Check**
316
+
317
+ Re-read original User Intent from discussion.md header. Check each intent item against Round 1 findings:
318
+ - ✅ addressed
319
+ - 🔄 in-progress
320
+ - ❌ not yet touched
321
+
322
+ Append initial Intent Coverage Check to discussion.md.
323
+
324
+ ### Step 5: Interactive Discussion Loop
325
+
326
+ Max 5 rounds. Each round follows this sequence:
327
+
328
+ **5.1: Current Understanding Summary** (Round >= 2, BEFORE presenting new findings):
329
+ Generate 1-2 sentence recap linking previous round conclusions to current starting point.
330
+
331
+ **5.2: Present Findings** from latest exploration/analysis
332
+
333
+ **5.3: Gather Feedback** (AskUserQuestion, single-select, header: "分析反馈"):
334
+ - **继续深入**: Deepen analysis — auto or user-specified direction
335
+ - **调整方向**: Different focus or specific questions
336
+ - **补充信息**: User has additional context, constraints, or corrections
337
+ - **分析完成**: Sufficient — exit to Phase 4
338
+
339
+ **5.4: Process Response** (always record user choice + impact to discussion.md):
340
+
341
+ | Choice | Action |
342
+ |--------|--------|
343
+ | 继续深入 | Sub-question (max 4 options: 3 context-driven + 1 heuristic frame-breaker) → CLI/agent exploration → merge findings |
344
+ | 调整方向 | Capture new direction → new CLI exploration → Record Decision (old vs new, reason, impact) |
345
+ | 补充信息 | Capture user input → integrate → answer questions via CLI if needed → Record corrections |
346
+ | 分析完成 | Exit loop → Record why concluding |
347
+
348
+ **5.5: Update discussion.md** after each round:
349
+ - **Append** Round N: user input, direction, Q&A, corrections, new insights
350
+ - **Append Technical Solutions** — for every solution proposed, validated, or rejected this round, record immediately using Technical Solution Record Format in `#### Technical Solutions`
351
+ - **Replace** `## Current Understanding` block with latest consolidated understanding
352
+ - **Update** `## Table of Contents` with links to new sections
353
+
354
+ **5.6: Round Narrative Synthesis** (append after each round):
355
+ ```markdown
356
+ ### Round N: Narrative Synthesis
357
+ **起点**: 基于上一轮的 [conclusions/questions],本轮从 [starting point] 切入。
358
+ **关键进展**: [New findings] [confirmed/refuted/modified] 了之前关于 [hypothesis] 的理解。
359
+ **决策影响**: 用户选择 [feedback type],导致分析方向 [adjusted/deepened/maintained]。
360
+ **当前理解**: 经过本轮,核心认知更新为 [updated understanding]。
361
+ **遗留问题**: [remaining questions driving next round]
362
+ ```
363
+
364
+ **5.7: Intent Drift Check** (every round >= 2):
365
+ Re-read original User Intent. Check each item:
366
+ - ✅ addressed (in Round N)
367
+ - 🔄 in-progress
368
+ - ⚠️ implicitly absorbed (needs confirmation)
369
+ - ❌ not yet discussed
370
+
371
+ If ❌ or ⚠️ items exist → proactively surface to user at start of next round.
372
+
373
+ **Auto mode (-y)**: auto-deepen for up to 3 rounds, then synthesize.
374
+
375
+ ### Step 6: Six-Dimension Scoring
376
+
377
+ Using all exploration findings, discussion insights, and user feedback, score across 6 dimensions:
378
+
379
+ | Dimension | Focus Areas | Score |
380
+ |-----------|------------|-------|
381
+ | Feasibility | Technical difficulty, team capability, time, tooling | 1-5 |
382
+ | Impact | User value, business value, tech debt reduction, DX | 1-5 |
383
+ | Risk | Failure modes, security, scalability, regression | 1-5 |
384
+ | Complexity | Integration points, dependencies, learning curve, testing | 1-5 |
385
+ | Dependencies | External services, internal modules, data, infrastructure | 1-5 |
386
+ | Alternatives | 2+ other approaches with tradeoffs | N/A |
387
+
388
+ Each dimension scored with specific evidence (code refs, data points from exploration).
389
+
390
+ Build probability-impact risk matrix from identified risks.
391
+
392
+ Formulate Go/No-Go/Conditional recommendation with confidence level.
393
+
394
+ ### Step 7: Synthesis & Conclusion
395
+
396
+ **7.1: Intent Coverage Verification** (MANDATORY before synthesis):
397
+
398
+ ```markdown
399
+ ### Intent Coverage Matrix
400
+ | # | Original Intent | Status | Where Addressed | Notes |
401
+ |---|----------------|--------|-----------------|-------|
402
+ | 1 | [intent] | ✅ Addressed | Round N, Conclusion #M | |
403
+ | 2 | [intent] | 🔀 Transformed | Round N → M | Original: X → Final: Y |
404
+ | 3 | [intent] | ❌ Missed | — | Reason |
405
+ ```
406
+
407
+ Gate: ❌ Missed items must be either (a) addressed in additional round or (b) confirmed deferred by user.
408
+
409
+ **7.2: Consolidate Insights**
410
+
411
+ Compile from all phases:
412
+ - Decision Trail from all rounds
413
+ - Key conclusions with evidence + confidence (high/medium/low)
414
+ - Recommendations with rationale + priority (high/medium/low) + actionable steps — **merge validated `technical_solutions[]` from explorations.json as high-priority recommendations**
415
+ - Open questions, follow-up suggestions
416
+ - Write to `conclusions.json`
417
+
418
+ **7.3: Write analysis.md** (legacy compatible — 6-dimension summary):
419
+ - Executive summary with overall assessment
420
+ - Per-dimension scores with key evidence
421
+ - Dimension summary table
422
+ - Risk matrix visualization
423
+ - Go/No-Go recommendation with confidence
424
+
425
+ **7.4: Final discussion.md Update**:
426
+ - Conclusions section: summary, ranked key conclusions, prioritized recommendations
427
+ - Current Understanding (Final): what established, what clarified/corrected, key insights
428
+ - Decision Trail: critical decisions, direction changes timeline, trade-offs
429
+ - Intent Coverage Matrix
430
+ - Session statistics: rounds, duration, sources, artifacts, decision count
431
+
432
+ **7.5: Interactive Recommendation Review** (skip in auto mode):
433
+
434
+ Present recommendations, batch-confirm via AskUserQuestion (max 4 per call, ordered by priority):
435
+ - **确认**: Accept as-is → review_status = "accepted"
436
+ - **修改**: Adjust scope/steps → review_status = "modified"
437
+ - **删除**: Not needed → review_status = "rejected"
438
+
439
+ Update conclusions.json with review_status for each recommendation.
440
+
441
+ ### Step 8: Decision Extraction
442
+
443
+ **This step runs ALWAYS** — in full mode after synthesis, in quick mode (`-q`) as the main step.
444
+
445
+ **8.1: Identify Gray Areas**
446
+
447
+ Analyze phase goal + loaded context (project.md, roadmap, brainstorm, prior context.md files, exploration findings if available) to find undecided implementation areas.
448
+
449
+ **Domain-aware gray area generation:**
450
+ - Something users SEE: layout, density, interactions, states
451
+ - Something users CALL: responses, errors, auth, versioning
452
+ - Something users RUN: output format, flags, modes, error handling
453
+ - Something users READ: structure, tone, depth, flow
454
+ - Something being ORGANIZED: criteria, grouping, naming, exceptions
455
+
456
+ Generate 3-5 **phase-specific** gray areas.
457
+ Skip areas already decided in prior context.md files.
458
+ If `guidance-specification.md` loaded: skip MUST/MUST NOT areas (already locked), focus on SHOULD/MAY areas and gaps.
459
+ If full mode completed: use exploration findings + scoring to inform gray area quality.
460
+
461
+ **8.2: Area Selection** (skip if `-y`)
462
+
463
+ ```
464
+ AskUserQuestion({
465
+ question: "Which areas need discussion for this phase?",
466
+ options: [
467
+ { label: "Area 1: {title}", description: "{brief description}" },
468
+ { label: "Area 2: {title}", description: "{brief description}" },
469
+ { label: "Area 3: {title}", description: "{brief description}" },
470
+ { label: "All areas", description: "Discuss everything" },
471
+ { label: "Skip", description: "Context is clear enough — no decisions needed" }
472
+ ]
473
+ })
474
+ ```
475
+
476
+ If "Skip": write minimal context.md (empty Locked/Free/Deferred sections), proceed to Step 9.
477
+
478
+ **8.3: Deep-Dive Discussion**
479
+
480
+ For each selected area, conduct multi-round interactive dialog (3-4 questions per area):
481
+
482
+ ```
483
+ AskUserQuestion({
484
+ question: "[{area}] {specific question about implementation choice}",
485
+ options: [
486
+ { label: "Option A", description: "{description with tradeoffs}" },
487
+ { label: "Option B", description: "{description with tradeoffs}" },
488
+ { label: "Option C", description: "{description with tradeoffs}" }
489
+ ]
490
+ })
491
+ ```
492
+
493
+ Record each decision using Decision Recording Protocol.
494
+
495
+ After questions per area: "More questions about {area}, or move to next?"
496
+
497
+ **Scope guardrail**: Phase boundary from roadmap.md is FIXED. Discussion clarifies HOW to implement, not WHETHER to add more. If user suggests new capabilities → "That belongs in its own phase. I will note it for later." → capture in Deferred.
498
+
499
+ **8.4: Classify Decisions**
500
+
501
+ - **Locked**: firm decisions that cannot be changed during implementation
502
+ - **Free**: open for implementation discretion (implementer can choose)
503
+ - **Deferred**: postponed to a later phase (captured but not acted on)
504
+
505
+ **If `researchContext` is set**: for each Free decision area, append a research-backed recommendation:
506
+
507
+ ```
508
+ ### Free — {area}
509
+ Implementer's choice. Research suggests: {relevant finding from researchContext}.
510
+ (e.g., "Standard Stack recommends React Query for server state. Common pitfall: avoid mixing with Redux for async.")
511
+ ```
512
+
513
+ This makes research findings visible to the planner through context.md without imposing hard constraints.
514
+
515
+ **8.5: Write context.md**
516
+
517
+ Write to `OUTPUT_DIR/context.md`:
518
+
519
+ ```markdown
520
+ # Context: Phase {NN} -- {PHASE_TITLE}
521
+
522
+ **Date**: {date}
523
+ **Areas discussed**: {list of areas}
524
+
525
+ ## Decisions
526
+
527
+ ### Decision 1: {TITLE}
528
+ - **Context**: {what and why}
529
+ - **Options**:
530
+ 1. {opt1}
531
+ 2. {opt2}
532
+ - **Chosen**: {selected}
533
+ - **Reason**: {rationale}
534
+
535
+ ## Constraints
536
+
537
+ ### Locked
538
+ {decisions that are final and must be followed}
539
+
540
+ ### Free
541
+ {decisions left to implementer discretion}
542
+
543
+ ### Deferred
544
+ {ideas captured but postponed to later phases}
545
+
546
+ ## Code Context
547
+ {relevant code references from exploration or discussion}
548
+ ```
549
+
550
+ **8.6: Update project.md Key Decisions** (phase mode only)
551
+
552
+ ```
553
+ IF phase mode AND Locked decisions exist:
554
+ Read .workflow/project.md
555
+ Find "## Key Decisions" table
556
+
557
+ For each Locked decision from Step 8.4:
558
+ Check if decision already exists in Key Decisions table (by title match)
559
+ If not duplicate:
560
+ Append row to Key Decisions table:
561
+ | {decision title} | {rationale summary} | Phase {NN} — {date} |
562
+
563
+ Write updated project.md
564
+ Display: "project.md: {count} key decisions recorded"
565
+ ```
566
+
567
+ **8.7: Auto-create Issues from Deferred Items**
568
+
569
+ ```
570
+ deferred_items = decisions.filter(d => d.classification == "Deferred")
571
+
572
+ IF deferred_items.length > 0:
573
+ mkdir -p ".workflow/issues"
574
+ today = format(now(), "YYYYMMDD")
575
+ counter = next sequence number for today
576
+
577
+ FOR each item IN deferred_items:
578
+ issue_id = "ISS-{today}-{counter padded to 3 digits}"
579
+ issue = {
580
+ id: issue_id,
581
+ title: "Deferred: " + item.title,
582
+ status: "deferred",
583
+ priority: 5,
584
+ severity: "low",
585
+ source: "analyze",
586
+ phase_ref: PHASE_NUM,
587
+ description: item.context + " -- Chosen to defer: " + item.reason,
588
+ tags: ["deferred", "analyze"],
589
+ created_at: now()
590
+ }
591
+ Append JSON line to .workflow/issues/issues.jsonl
592
+ counter++
593
+
594
+ Print: "Created {deferred_items.length} deferred issues for tracking"
595
+ ```
596
+
597
+ ### Step 8.8: Register Artifact
598
+
599
+ ```
600
+ // Register in state.json artifact registry
601
+ Read .workflow/state.json
602
+ next_id = max(artifacts.filter(a => a.type == "analyze").map(a => parseInt(a.id.replace("ANL-","")))) + 1
603
+ // If no analyze artifacts exist: next_id = 1
604
+
605
+ artifact = {
606
+ id: "ANL-{next_id padded to 3}",
607
+ type: "analyze",
608
+ milestone: state.json.current_milestone, // null if standalone
609
+ phase: phase_num, // null if milestone/adhoc/standalone
610
+ scope: scope, // "milestone"|"phase"|"adhoc"|"standalone"
611
+ path: OUTPUT_DIR relative to .workflow/, // e.g. "scratch/analyze-auth-2026-04-20"
612
+ status: "completed",
613
+ depends_on: null,
614
+ harvested: false,
615
+ created_at: session_start_time,
616
+ completed_at: now()
617
+ }
618
+
619
+ state.json.artifacts.push(artifact)
620
+ state.json.last_updated = now()
621
+ Write state.json (atomic: write tmp + rename)
622
+ ```
623
+
624
+ ### Step 9: Report & Next Step
625
+
626
+ Display summary:
627
+ - Overall assessment score and recommendation (full mode) or "Quick decision extraction" (quick mode)
628
+ - Decisions captured (Locked/Free/Deferred counts)
629
+ - Key conclusions (if full mode)
630
+ - Session stats
631
+
632
+ **Next Step Selection** (AskUserQuestion, single-select, header: "Next Step"):
633
+ - **快速执行**: Skill({ skill: "maestro-quick", args: "{task_description} --full" }) — build context from conclusions
634
+ - **进入规划**: Phase mode → Skill({ skill: "maestro-plan", args: "{phase}" }); Scratch mode → Skill({ skill: "maestro-plan", args: "--dir {output_dir}" }) — plan directly against scratch directory
635
+ - **产出Issue**: Convert recommendations to tracked issues
636
+ - **完成**: No further action
637
+
638
+ Handle selection:
639
+
640
+ | Choice | Action |
641
+ |--------|--------|
642
+ | 快速执行 | Build `taskDescription` from high/medium priority accepted recommendations. Assemble context from exploration. Invoke Skill immediately. |
643
+ | 进入规划 | **Implementation Scoping** (below), then invoke Skill. |
644
+ | 产出Issue | For each accepted/modified recommendation: create issue. |
645
+ | 完成 | No further action. |
646
+
647
+ **Implementation Scoping** (for "进入规划" only):
648
+
649
+ Before invoking maestro-plan, build and persist `implementation_scope` so the planner has concrete "what + done-when" specs:
650
+
651
+ ```
652
+ // Step A: Build implementation scope from accepted/modified recommendations
653
+ actionableRecs = conclusions.recommendations
654
+ .filter(r => r.review_status in ["accepted", "modified"])
655
+ .sort by priority (high first)
656
+
657
+ implementation_scope = actionableRecs.map(rec => ({
658
+ objective: rec.action, // WHAT to do
659
+ rationale: rec.rationale, // WHY
660
+ priority: rec.priority,
661
+ target_files: rec.steps.flatMap(s => s.target) // WHERE (from steps + code_anchors)
662
+ .concat(code_anchors matching rec),
663
+ acceptance_criteria: rec.steps.map(s => // DONE WHEN
664
+ s.verification || s.description),
665
+ change_summary: rec.steps.map(s => // HOW (brief)
666
+ "${s.target}: ${s.description}").join('; ')
667
+ }))
668
+
669
+ // Step B: User scope confirmation (skip in auto mode / quick mode)
670
+ IF NOT AUTO_MODE:
671
+ Display implementation scope summary:
672
+ For each item: objective [priority], target files, "Done when: ..."
673
+ AskUserQuestion (single-select, header: "Scope确认"):
674
+ - "确认执行": Scope is clear, proceed to planning
675
+ - "调整范围": Narrow or expand scope
676
+ - "补充标准": Add/refine acceptance criteria
677
+ Handle adjustments, re-confirm if needed
678
+
679
+ // Step C: Persist to conclusions.json
680
+ conclusions.implementation_scope = implementation_scope
681
+ Write updated conclusions.json to OUTPUT_DIR
682
+
683
+ // Step D: Invoke plan
684
+ Phase mode: Skill({ skill: "maestro-plan", args: "{phase}" })
685
+ Scratch mode: Skill({ skill: "maestro-plan", args: "--dir {output_dir}" })
686
+ ```
687
+
688
+ The planner reads `conclusions.json.implementation_scope` and maps:
689
+ - `scope.objective` → task title/description
690
+ - `scope.acceptance_criteria` → `convergence.criteria` (seed, planner makes grep-verifiable)
691
+ - `scope.target_files` → `files[]` + `read_first[]`
692
+ - `scope.priority` → task/wave ordering
693
+
694
+ Update index.json timestamps.
695
+
696
+ ```
697
+ == maestro-analyze complete ==
698
+ Session: {session_id}
699
+ Output: {output_dir}/
700
+ Mode: {full|quick}
701
+ Rounds: {round_count} (full mode only)
702
+ Score: {recommendation} ({confidence}) (full mode only)
703
+ Decisions: {decision_count} (Locked: {n}, Free: {n}, Deferred: {n})
704
+
705
+ Files:
706
+ context.md — Locked/Free/Deferred decisions for plan
707
+ discussion.md — Full discussion timeline (full mode)
708
+ analysis.md — 6-dimension scoring summary (full mode)
709
+ conclusions.json — Structured conclusions (full mode)
710
+
711
+ Next:
712
+ Skill({ skill: "maestro-quick", args: "{task}" }) — Quick execute
713
+ Skill({ skill: "maestro-plan", args: "{phase}" }) — Full phase planning (phase mode)
714
+ Skill({ skill: "maestro-plan", args: "--dir {output_dir}" }) — Plan in scratch dir (scratch mode)
715
+ ```
716
+
717
+ ---
718
+
719
+ ## Decision Recording Protocol
720
+
721
+ Record immediately when any occur:
722
+
723
+ | Trigger | What to Record |
724
+ |---------|---------------|
725
+ | Direction choice | What chosen, why, alternatives discarded |
726
+ | Key finding | Content, impact scope, confidence, hypothesis impact |
727
+ | Assumption change | Old → new understanding, reason, impact |
728
+ | User feedback | Input, rationale for adoption/adjustment |
729
+ | Disagreement/trade-off | Conflicting views, trade-off basis, final choice |
730
+ | Scope adjustment | Before/after scope, trigger reason |
731
+ | **Technical solution proposed/validated/rejected** | Solution description, rationale, alternatives considered, status |
732
+
733
+ **Decision Record Format**:
734
+ ```
735
+ > **Decision**: [Description]
736
+ > - **Context**: [Trigger]
737
+ > - **Options considered**: [Alternatives]
738
+ > - **Chosen**: [Approach] — **Reason**: [Rationale]
739
+ > - **Rejected**: [Why other options were discarded]
740
+ > - **Impact**: [Effect on analysis]
741
+ ```
742
+
743
+ **Technical Solution Record Format**:
744
+ ```
745
+ > **Solution**: [Description — what approach, pattern, or implementation]
746
+ > - **Status**: [Proposed / Validated / Rejected]
747
+ > - **Problem**: [What problem this solves]
748
+ > - **Rationale**: [Why this approach]
749
+ > - **Alternatives**: [Other options considered and why not chosen]
750
+ > - **Evidence**: [file:line or code anchor references]
751
+ > - **Next Action**: [Follow-up required or none]
752
+ ```
753
+
754
+ ## Discussion Timeline (discussion.md)
755
+
756
+ Each round appends:
757
+ - User feedback and direction choice
758
+ - New findings with code anchors
759
+ - Narrative Synthesis (起点 → 关键进展 → 决策影响 → 当前理解 → 遗留问题)
760
+ - Intent Coverage Check (Round >= 2)
761
+
762
+ Replaceable blocks (overwritten each round):
763
+ - `## Current Understanding` — latest consolidated understanding
764
+ - `## Table of Contents` — updated with new section links
765
+
766
+ ## Six Dimensions
767
+
768
+ | Dimension | Focus Areas |
769
+ |-----------|------------|
770
+ | Feasibility | Technical difficulty, team capability, time, tooling |
771
+ | Impact | User value, business value, tech debt reduction, DX |
772
+ | Risk | Failure modes, security, scalability, regression |
773
+ | Complexity | Integration points, dependencies, learning curve, testing |
774
+ | Dependencies | External services, internal modules, data, infrastructure |
775
+ | Alternatives | 2+ other approaches with tradeoffs |
776
+
777
+ ## Key Design Principles
778
+
779
+ 1. **Iterative Deepening**: Multi-round discussion (max 5) with user feedback steering direction
780
+ 2. **CLI-Assisted Exploration**: cli-explore-agent for codebase + multi-CLI parallel analysis
781
+ 3. **Discussion Timeline**: discussion.md as living document — rounds appended, Current Understanding replaced
782
+ 4. **Decision Recording Protocol**: Immediate capture of decisions, findings, assumption changes
783
+ 5. **Intent Coverage Tracking**: Original user intent checked every round (✅🔄⚠️❌)
784
+ 6. **Six-Dimension Scoring**: Feasibility, Impact, Risk, Complexity, Dependencies, Alternatives
785
+ 7. **Multi-Perspective Synthesis**: Up to 4 perspectives with convergent/conflicting/unique extraction
786
+ 8. **Decision Extraction**: Gray area identification → interactive discussion → Locked/Free/Deferred classification → context.md
787
+ 9. **Dual Depth**: Full mode (explore→score→decide) or Quick mode (-q, decide only)
788
+
789
+ ## Quality Criteria
790
+
791
+ **Full mode:**
792
+ - All 6 dimensions analyzed with evidence-backed scores
793
+ - Discussion timeline has narrative synthesis per round
794
+ - Decision Recording Protocol applied consistently
795
+ - Intent Coverage verified with no unresolved ❌ items
796
+ - Risk matrix populated with identified risks
797
+ - At least 2 alternatives compared with tradeoffs
798
+ - Go/No-Go/Conditional recommendation with confidence level
799
+ - Code references included where relevant (file paths, line numbers)
800
+
801
+ **Both modes (full + quick):**
802
+ - context.md written with all decisions classified as Locked/Free/Deferred
803
+ - Gray areas identified through phase-specific analysis
804
+ - Scope creep redirected to Deferred section
805
+ - Every decision follows Context/Options/Chosen/Reason protocol
806
+ - Prior context loaded and applied (no re-asking decided questions)
807
+
808
+ ## Error Handling
809
+
810
+ | Error | Resolution |
811
+ |-------|------------|
812
+ | cli-explore-agent fails | Continue with available context, note limitation |
813
+ | CLI timeout | Retry with shorter prompt, or skip perspective |
814
+ | Max rounds reached | Force synthesis, offer continuation |
815
+ | No relevant findings | Broaden search, ask user for clarification |
816
+ | Session folder conflict | Append timestamp suffix |