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,508 @@
1
+ # Workflow: Brainstorm
2
+
3
+ ## Architecture
4
+
5
+ ```
6
+ ┌─────────────────────────────────────────────────────────┐
7
+ │ /maestro-brainstorm │
8
+ │ Unified Entry Point + Interactive Routing │
9
+ └───────────────────────┬─────────────────────────────────┘
10
+
11
+ ┌─────────┴─────────┐
12
+ ↓ ↓
13
+ ┌─────────────────┐ ┌──────────────────┐
14
+ │ Auto Mode │ │ Single Role Mode │
15
+ └────────┬────────┘ └────────┬─────────┘
16
+ │ │
17
+ ┌────────┬──────────┬───────┐ │
18
+ ↓ ↓ ↓ ↓ ↓
19
+ Phase 2 Phase 3 Phase 4 Phase 5 Phase 3
20
+ Artifacts N×Role Cross- Apply 1×Role
21
+ Analysis Role Resol. Analysis
22
+ (multi- Review
23
+ file) (digest)
24
+ ```
25
+
26
+ ## Dual-Mode Routing
27
+
28
+ **Auto Mode** (`--yes`/`-y`): Phase 1 → 1.5 → 2 → 3 → 4 → 5 (full pipeline)
29
+ **Single Role Mode** (first arg = role name): Phase 1 → 3 (single role)
30
+
31
+ ## Input
32
+
33
+ - `$ARGUMENTS`: topic text (auto mode) or role name (single role mode)
34
+ - All output goes to `.workflow/scratch/{YYYYMMDD}-brainstorm-{slug}/`
35
+ - Registers artifact (type=brainstorm) in state.json on completion
36
+
37
+ ### Parameters
38
+
39
+ | Parameter | Description | Default |
40
+ |-----------|-------------|---------|
41
+ | `--yes`, `-y` | Auto mode, skip all questions | - |
42
+ | `--count N` | Number of roles to select | 3 |
43
+ | `--session ID` | Use existing session | - |
44
+ | `--update` | Update existing analysis | - |
45
+ | `--include-questions` | Interactive context gathering | - |
46
+ | `--skip-questions` | Use default answers | - |
47
+ | `--style-skill PKG` | Style package for ui-designer | - |
48
+ | `--review-only` | Skip Phase 3 (role analysis); run only Step 4.5 + Step 5 on existing role analyses | - |
49
+
50
+ ### Available Roles
51
+
52
+ | Role ID | Title | Focus Area |
53
+ |---------|-------|------------|
54
+ | `data-architect` | 数据架构师 | Data models, storage strategies, data flow |
55
+ | `product-manager` | 产品经理 | Product strategy, roadmap, prioritization |
56
+ | `product-owner` | 产品负责人 | Backlog management, user stories, acceptance criteria |
57
+ | `scrum-master` | 敏捷教练 | Process facilitation, impediment removal |
58
+ | `subject-matter-expert` | 领域专家 | Domain knowledge, business rules, compliance |
59
+ | `system-architect` | 系统架构师 | Technical architecture, scalability, integration |
60
+ | `test-strategist` | 测试策略师 | Test strategy, quality assurance |
61
+ | `ui-designer` | UI设计师 | Visual design, mockups, design systems |
62
+ | `ux-expert` | UX专家 | User research, information architecture, journey |
63
+
64
+ ## Output
65
+
66
+ ### Directory Structure
67
+
68
+ All brainstorm output goes to scratch:
69
+ ```
70
+ .workflow/scratch/{YYYYMMDD}-brainstorm-{slug}/
71
+ ├── guidance-specification.md # Phase 2 output — machine contract (downstream consumes this)
72
+ ├── design-research.md # Optional Step 1.7 output
73
+ ├── system-architect/ # Phase 3 per-role analysis (one folder per selected role)
74
+ │ ├── analysis.md # INDEX — digest + cross-cutting foundations + file index
75
+ │ ├── analysis-F-001-agent-loop.md # per-feature analysis
76
+ │ ├── analysis-F-002-skill-engine.md
77
+ │ └── findings-perf-risk.md # additional discoveries
78
+ ├── ux-expert/
79
+ │ ├── analysis.md
80
+ │ ├── analysis-F-001-agent-loop.md
81
+ │ └── analysis-F-003-tui-frontend.md
82
+ └── {role}/
83
+ └── ...
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Process
89
+
90
+ ### Step 1: Parse & Route (Mode Detection)
91
+
92
+ **Mode Detection (priority order)**:
93
+ 1. `--review-only` flag → **Review-Only Mode** (requires `--session ID`; runs Step 4.5 + Step 5 only)
94
+ 2. `--yes` or `-y` flag → **Auto Mode** (no question asked)
95
+ 3. First non-flag arg matches valid role name → **Single Role Mode**
96
+ 4. First non-flag arg is a number → **Phase Mode** (resolve phase dir, then auto)
97
+ 5. Text provided without flags → Ask user via AskUserQuestion:
98
+ - "自动模式 (推荐)" — 完整流程:框架生成 → 多角色并行分析 → 跨角色复审 → 决议回流
99
+ - "单角色分析" — 为单个角色生成 {role}/ 分析文件
100
+ - "跨角色复审" — 已有多个角色分析,仅运行复审与决议回流
101
+
102
+ **Parameter Parsing**:
103
+ - `--count N`: cap at 9, default 3
104
+ - `--session ID`: target specific session
105
+ - `--from <source>`: load upstream context package (grill:ID, blueprint:ID, @file, or path)
106
+ - `--style-skill PKG`: validate `.claude/skills/style-{PKG}/SKILL.md` exists
107
+ - Missing/empty args without flags = error E001
108
+
109
+ **Session Detection**:
110
+ - Check `.workflow/scratch/*-brainstorm-*/` for existing sessions
111
+ - Multiple → AskUserQuestion to select | Single → use it
112
+ - None + auto mode → will create new session
113
+ - None + single role mode → error E002
114
+
115
+ **Output Directory Resolution**:
116
+ - Phase mode (number): resolve `state.json.artifacts[phase == phaseNum].path` → `.workflow/{path}/.brainstorming/` (ERROR if phase not found)
117
+ - All output: `.workflow/scratch/{YYYYMMDD}-brainstorm-{slug}/`
118
+ - Existing session: use existing session directory
119
+
120
+ ---
121
+
122
+ ### Step 1.3: Load Upstream Context (if `--from`)
123
+
124
+ Resolve to `context-package.json` (`grill:ID` / `blueprint:ID` / `@file` / `path/`).
125
+
126
+ Pre-seed from context-package:
127
+ - `domain.terminology[]` → Step 2 (skip locked terms)
128
+ - `constraints[locked]` → guidance §4-N
129
+ - `non_goals[]` → Step 2
130
+ - `open_questions[]` → Step 3 Phase 1
131
+ - `insights[]` → Step 4 role agents
132
+ - `requirements[]` → Step 3 Phase 4.5
133
+
134
+ W007 if source not found: continue without upstream; flag guidance-specification.md as [LOW CONFIDENCE] (no upstream context).
135
+
136
+ ---
137
+
138
+ ### Step 1.5: Load Project Specs
139
+
140
+ ```
141
+ specs_content = maestro spec load --category arch
142
+ ```
143
+
144
+ ---
145
+
146
+ ### Step 1.7: External Research — Design Routes (Auto Mode, Optional)
147
+
148
+ **Trigger**: Always in auto mode. Skip if `--skip-questions` and no tech keywords.
149
+
150
+ ```
151
+ // Step 1.7.1: Spawn external researcher for design routes — MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep
152
+ Agent(
153
+ subagent_type="workflow-external-researcher",
154
+ prompt="""
155
+ <objective>
156
+ Research design alternatives and architecture patterns for: {topic}
157
+ Mode: Design Research
158
+ </objective>
159
+
160
+ <context>
161
+ Project specs: {specs_content or "none"}
162
+ Topic keywords: {extracted_keywords}
163
+ </context>
164
+
165
+ <task>
166
+ Search for:
167
+ 1. Reference projects — how 2-3 similar projects/products solve this problem (architecture, key decisions, what worked)
168
+ 2. Extractable patterns — reusable design patterns distilled from those projects, with applicability notes
169
+ 3. Architecture approaches (at least 2-3 alternatives with trade-offs)
170
+ 4. UX/UI patterns if applicable (interaction models, layout strategies)
171
+ 5. Common design pitfalls and anti-patterns to avoid
172
+
173
+ IMPORTANT: Output MUST include "Reference Projects / Implementations" and "Extractable Patterns" sections.
174
+ Focus on design ROUTES — alternative approaches the brainstorm roles can evaluate.
175
+ Be prescriptive where evidence is strong, present alternatives where trade-offs exist.
176
+ Return structured markdown only — do NOT write files.
177
+ </task>
178
+ """,
179
+ run_in_background=false
180
+ )
181
+
182
+ // Step 1.7.2: Store as designResearchContext (in-memory)
183
+ designResearchContext = agent_output
184
+ ```
185
+
186
+ `designResearchContext` → Steps 2, 3, 4. Persisted to `{output_dir}/design-research.md`.
187
+
188
+ W005 on failure: continue without external context; flag role analyses as [LOW CONFIDENCE] (no design research).
189
+
190
+ ---
191
+
192
+ ### Step 1.8: Load Project Context (if `.workflow/` exists)
193
+
194
+ - `project.md`: Validated → already_shipped, Active → current_scope
195
+ - `state.json.accumulated_context`: `deferred[]` → brainstorming seeds, `key_decisions[]` → constraints
196
+
197
+ Pass into Steps 2 and 3.
198
+
199
+ ---
200
+
201
+ ### Step 2: Terminology & Boundary Definition (Auto Mode)
202
+
203
+ 1. Load existing domain terms: read `.workflow/domain/glossary.yaml` 中已注册术语,避免重复定义
204
+ 2. Extract 5-10 core domain terms (merge upstream locked terms + existing glossary terms)
205
+ 3. AskUserQuestion for Non-Goals (multiSelect, include "其他" option)
206
+ 4. Store terminology + non_goals to session
207
+
208
+ 新候选术语仅存入 `context-package.json#domain.terminology[]`,不直接写 glossary.yaml。由 chain 末尾 `manage-harvest --auto` 触发 finish-work Step 3.5 统一提升为正式术语。
209
+
210
+ **Skip if**: `--yes` (auto-generate terms, empty non-goals)
211
+
212
+ ### Step 3: Interactive Framework Generation (Auto Mode)
213
+
214
+ Seven sub-phases producing guidance-specification.md:
215
+
216
+ **Phase 0: Context Collection**
217
+ - Read init outputs directly: `.workflow/project.md` (tech stack, requirements, decisions), `.workflow/state.json` (project state), `.workflow/specs/` (conventions)
218
+ - If `.workflow/` does not exist: continue without project context
219
+
220
+ **Phase 1: Topic Analysis**
221
+ - Load Phase 0 context (tech_stack, modules, conflict_risk)
222
+ - Deep topic analysis (entities, challenges, constraints, metrics)
223
+ - Generate 2-4 context-aware probing questions via AskUserQuestion
224
+ - Questions MUST reference topic keywords (no generic questions)
225
+ - Store to `session.intent_context`
226
+
227
+ **Phase 2: Role Selection**
228
+ - Analyze Phase 1 keywords → recommend count+2 roles with rationale
229
+ - AskUserQuestion (multiSelect=true) for user to select `count` roles
230
+ - If `--yes`: auto-select recommended roles
231
+ - Store to `session.selected_roles`
232
+
233
+ **Phase 3: Role-Specific Questions**
234
+ - FOR each selected role, generate 3-4 deep questions mapping role expertise to Phase 1 challenges
235
+ - AskUserQuestion per role (sequential, one role at a time)
236
+ - Questions must include: implementation depth, trade-offs, edge cases
237
+ - Store to `session.role_decisions[role]`
238
+ - If `--yes`: skip all role questions
239
+
240
+ **Phase 4: Conflict Resolution**
241
+ - Analyze Phase 3 answers for contradictions, missing integrations, implicit dependencies
242
+ - Generate clarification questions referencing SPECIFIC Phase 3 choices
243
+ - AskUserQuestion (max 4 per round)
244
+ - If NO conflicts detected: skip with notification
245
+ - Store to `session.cross_role_decisions`
246
+
247
+ **Phase 4.5: Final Clarification + Feature Decomposition**
248
+ - Ask: "是否有前面未澄清的重点需要补充?" (无需补充 / 需要补充)
249
+ - If "需要补充": progressive questions until resolved
250
+ - Extract candidate features from all Phase 1-4 decisions (max 8)
251
+ - Each feature: F-{3-digit} ID, kebab-case slug, description, related roles, priority
252
+ - Validate: independence, completeness, granularity balance, boundary clarity
253
+ - AskUserQuestion for user to confirm or adjust feature list
254
+ - Store to `session.feature_list`
255
+
256
+ **Phase 5: Generate Specification**
257
+ - Load all decisions + terminology + non_goals + feature_list
258
+ - Transform Q&A to declarative statements (CONFIRMED/SELECTED)
259
+ - Apply RFC 2119 keywords (MUST, SHOULD, MAY, MUST NOT, SHOULD NOT)
260
+ - Write `guidance-specification.md` with sections:
261
+ 1. Project Positioning & Goals
262
+ 2. Concepts & Terminology (table)
263
+ 3. Non-Goals (Out of Scope)
264
+ 4-N. [Role] Decisions (with RFC 2119)
265
+ Cross-Role Integration
266
+ Risks & Constraints
267
+ §10. Feature Decomposition (table)
268
+ §11. Appendix: Decision Tracking
269
+ §12. Cross-Role Resolutions (initially empty — populated by Step 5)
270
+ - Validate: no interrogative sentences, all decisions traceable, RFC keywords applied
271
+
272
+ **Output**: `{output_dir}/guidance-specification.md`, session metadata (workflow-session.json)
273
+
274
+ **GATE Step 3→4**: REQUIRED `guidance-specification.md` written with §10 Feature Decomposition list; BLOCKED if `guidance-specification.md` missing or §10 feature list absent.
275
+
276
+ ### Step 3.5: Visual Style Foundation (Auto Mode, conditional)
277
+
278
+ **Condition**: `ui-designer` selected AND `.workflow/impeccable/DESIGN.md` does not exist. Skip with `--skip-design`.
279
+
280
+ 1. If PRODUCT.md missing: `Skill({ skill: "maestro-impeccable", args: "teach" })`
281
+ 2. `Skill({ skill: "maestro-impeccable", args: "explore" })` → produces DESIGN.md
282
+ 3. Record `design_system_established: true` in session metadata
283
+
284
+ `--yes`: auto-selects variant 1.
285
+
286
+ ### Step 4: Parallel Role Analysis (Auto Mode)
287
+
288
+ Spawn `role-design-author` per role in parallel. ALWAYS use absolute paths. Pass `null` (literal string) for absent optional fields.
289
+
290
+ ```
291
+ // MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep
292
+ Agent({
293
+ subagent_type: "role-design-author",
294
+ prompt: """
295
+ role_name: {role}
296
+ role_template_path: <ABSOLUTE path to planning-roles/{role}.md>
297
+ guidance_path: <ABSOLUTE {output_dir}>/guidance-specification.md
298
+ output_dir: <ABSOLUTE {output_dir}>/{role}/
299
+ feature_list: <F-id + slug + title rows from guidance §10>
300
+ design_research: <ABSOLUTE path>/design-research.md OR null
301
+ project_specs: <specs_content text> OR null
302
+ user_context: <session.role_decisions[role] text> OR null
303
+ style_skill: <ABSOLUTE style-skill SKILL.md path> OR null
304
+
305
+ Follow the Output Contract in `.claude/agents/role-design-author.md` (§1 Role Mandate,
306
+ §2 Decision Digest with 4 tables, §3 Cross-Cutting Foundations, §4 File Index, §5 TODOs)
307
+ — this is authoritative. The role template's "Brainstorming Analysis Structure" section
308
+ is legacy single-file scaffolding; ignore it for file layout. Use the role template ONLY
309
+ for §3 subsection headings (via the "MUST-Have Sections (Brainstorming)" block when present).
310
+
311
+ Reference guidance decisions by ID (e.g., SA-03) — do NOT copy decision text.
312
+ All behavioural statements MUST use RFC 2119 keywords.
313
+
314
+ MUST use the Write tool to persist every file under output_dir/. After all writes, verify
315
+ with Glob that `analysis.md` and each `analysis-F-*.md` exist on disk, then emit the
316
+ `TASK COMPLETE` return protocol. Returning analysis as text without files is failure.
317
+ """,
318
+ run_in_background: false
319
+ })
320
+ ```
321
+
322
+ **Output per role**: `analysis.md` (index), `analysis-F-{id}-{slug}.md` (per feature, <2000 words), `findings-{slug}.md` (optional, <1000 words).
323
+
324
+ **Validation** (read only `analysis.md`):
325
+ - §2: ≥1 decision per feature, RFC 2119 keywords present
326
+ - §4: listed files exist on disk, feature coverage matches
327
+ - system-architect: §3 has "Data Model" and "State Machine" headings
328
+
329
+ **GATE Step 4→4.5**: REQUIRED all `{role}/analysis.md` verified on disk via Glob (per role in selected_roles); BLOCKED if any `analysis.md` missing.
330
+
331
+ ### Step 4.5: Cross-Role Review (Auto Mode)
332
+
333
+ Spawn ONE `cross-role-reviewer` to compare Decision Digests across roles.
334
+
335
+ ```
336
+ // MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep
337
+ Agent({
338
+ subagent_type: "cross-role-reviewer",
339
+ prompt: """
340
+ analysis_indexes:
341
+ - {output_dir}/{role_1}/analysis.md
342
+ - {output_dir}/{role_2}/analysis.md
343
+ - ...
344
+ guidance_path: {output_dir}/guidance-specification.md
345
+ feature_list: <F-id + slug + title rows from guidance §10>
346
+
347
+ Compare Decision Digests (§2) across these role analysis index files.
348
+ Identify conflicts, gaps, and synergy opportunities.
349
+ Use §4 File Index for accurate patch target file paths and headings.
350
+ Return the structured report — do NOT write files.
351
+ """,
352
+ run_in_background: false
353
+ })
354
+ ```
355
+
356
+ **Output**: `conflicts[]`, `gaps[]`, `synergies[]`, `need_deeper_context[]` (optional).
357
+
358
+ If `need_deeper_context`: read specific files, re-invoke reviewer. Skip Step 5 if all arrays empty.
359
+
360
+ `--yes`: auto-apply resolutions (still proceed to Step 5 writeback).
361
+
362
+ ### Step 5: Apply Cross-Role Resolutions (Auto Mode)
363
+
364
+ **5.1: Interactive Confirmation (skip if `--yes`)**
365
+
366
+ AskUserQuestion per finding (max 4 per round). MUST cite exact role folder + `target_heading`.
367
+
368
+ **5.2: Apply Patches to Role Files**
369
+
370
+ Consume `patch_targets[]` per finding. Edit types: `annotate_after_heading` / `annotate_and_strikeout` / `append_to_section`.
371
+
372
+ | Type | Action |
373
+ |------|--------|
374
+ | Conflict (`annotate_and_strikeout`) | Insert resolution blockquote after heading, wrap original in `<!-- superseded -->` |
375
+ | Gap (`annotate_after_heading` + `append_to_section`) | Breadcrumb at reference site, definition at owner site. Both MUST succeed. |
376
+ | Synergy (`annotate_after_heading` × 2) | Cross-reference in BOTH files. Original untouched. |
377
+
378
+ **On heading mismatch**: skip patch, log finding ID, surface in Step 7 report. NEVER invent headings.
379
+
380
+ **5.3: Append to guidance §12**
381
+ ```markdown
382
+ ### Cross-Role Resolutions (added {date})
383
+ | ID | Type | Source(s) | Resolution | Applied to |
384
+ |---|---|---|---|---|
385
+ | C-001 | conflict | system-architect/analysis-F-002-skill-engine.md "## Architecture" / sme/analysis-F-002-skill-engine.md "## Constraints" | {answer} | both files patched |
386
+ | G-001 | gap | ux-expert/analysis.md "### Interfaces" | {answer} | data-architect/analysis.md "### Decisions" |
387
+ | S-001 | synergy | ux-expert/analysis-F-005-tui.md "## Interface Contract" / sme/findings-ndjson.md "## Recommendation" | applied | both annotated |
388
+ ```
389
+
390
+ **5.4: Finalization** — Update session metadata, emit completion report (Step 7).
391
+
392
+ ---
393
+
394
+ ### Step 6: Single Role Analysis
395
+
396
+ **Step 6.1: Detection & Validation**
397
+ - Validate role_name against VALID_ROLES list
398
+ - Detect session (--session or find existing)
399
+ - Check for guidance-specification.md → framework_mode
400
+ - Extract feature list from guidance §10 → feature_mode
401
+ - Check existing `{role}/analysis.md` → update_mode (ask: update/regenerate/cancel)
402
+
403
+ **Step 6.2: Interactive Context Gathering**
404
+ - Skip if `--skip-questions`
405
+ - Force if `--include-questions`
406
+ - Generate 3-5 role-specific questions (Chinese, with business context)
407
+ - AskUserQuestion per batch (max 4 per round)
408
+ - Pass collected answers as `user_context` to the agent (in-memory; not persisted to a separate file)
409
+
410
+ **Step 6.3: Agent Execution**
411
+ - Spawn role-design-author with full Inputs block (see Step 4 schema)
412
+ - Agent writes files under `{output_dir}/{role}/`
413
+
414
+ **Step 6.4: Validation**
415
+ - Read `{role}/analysis.md` — verify exists and non-empty
416
+ - Check §2 Decision Digest tables present
417
+ - Check §4 File Index matches files on disk
418
+ - Check framework reference if framework_mode
419
+ - Update session metadata with completion status
420
+ - Report results with next step suggestions
421
+
422
+ ---
423
+
424
+ ### Step 6.5: Review-Only Mode (`--review-only --session ID`)
425
+
426
+ **Step 6.5.1: Validation**
427
+ - Require `--session ID`. Error E002 if missing.
428
+ - Glob `{output_dir}/*/analysis.md`. Error E006 if zero files found (no role analyses to review).
429
+ - Require `guidance-specification.md` to exist (for decision-ID context). Error E007 if missing.
430
+
431
+ **Step 6.5.2**: Run Step 4.5 + Step 5. Skip 5.1 if `--yes`.
432
+
433
+ **Step 6.5.3**: Report (same as review-only report in Step 7).
434
+
435
+ ---
436
+
437
+ ### Step 7: Final Report
438
+
439
+ **Auto mode report:**
440
+ - Session ID and output directory
441
+ - Roles analyzed (N) — list each `{role}/analysis.md` path
442
+ - Files written per role (from agent return protocol)
443
+ - Features in scope (N, from guidance §10)
444
+ - Cross-role review: conflicts / gaps / synergies counts
445
+ - Resolutions applied: count + a breakdown by type (C/G/S)
446
+ - Next:
447
+ Skill({ skill: "maestro-roadmap", args: "--mode full --from brainstorm:{artifactId}" }) — Generate full spec package
448
+ Skill({ skill: "maestro-analyze", args: "{topic}" }) — Evaluate feasibility + lock decisions
449
+ Skill({ skill: "maestro-analyze", args: "{phase} -q" }) — Quick decision extraction only
450
+ Skill({ skill: "maestro-plan", args: "{phase}" }) — Plan directly (if scope is clear)
451
+
452
+ **Single role mode report:**
453
+ - Role analyzed
454
+ - Framework alignment status (does analysis reference guidance decisions?)
455
+ - Context questions answered (count)
456
+ - Files written: list from §4 File Index
457
+ - Next:
458
+ - Run more roles: `Skill({ skill: "maestro-brainstorm", args: "{another-role} --session {sessionId}" })`
459
+ - When 2+ roles are done, trigger review: `Skill({ skill: "maestro-brainstorm", args: "--review-only --session {sessionId}" })`
460
+
461
+ **Review-only mode report:**
462
+ - Session ID and existing roles found (N)
463
+ - Cross-role review: conflicts / gaps / synergies counts
464
+ - Resolutions applied: count + breakdown by type (C/G/S)
465
+ - Patches skipped due to heading drift: count (if any)
466
+ - Same Next-step routing as auto mode
467
+
468
+ ---
469
+
470
+ ### Step 7.5: Generate Context Package
471
+
472
+ Write `{output_dir}/context-package.json` by extracting from session artifacts:
473
+
474
+ ```jsonc
475
+ {
476
+ "$schema": "context-package/1.0",
477
+ "source": {
478
+ "type": "brainstorm",
479
+ "artifact_id": "{artifact_id}",
480
+ "session_path": "{output_dir relative to .workflow/}",
481
+ "generated_at": "{ISO-8601}"
482
+ },
483
+ "requirements": [], // From guidance-specification.md §10 Feature Decomposition
484
+ "constraints": [], // From guidance-specification.md §4-N MUST/MUST NOT + {role}/analysis.md §2 Decisions[locked]
485
+ "domain": {}, // From guidance-specification.md §1-3 (problem, terminology, audience)
486
+ "non_goals": [], // From guidance-specification.md Non-Goals section
487
+ "insights": [], // From {role}/analysis.md §3 Cross-Cutting subsections
488
+ "open_questions": [], // From guidance-specification.md §4-N SHOULD/MAY items
489
+ "references": [] // List all key files: guidance-specification.md + {role}/analysis.md per role
490
+ }
491
+ ```
492
+
493
+ **Extraction mapping**:
494
+ - `requirements[]`: each row from §10 Feature Decomposition → `{ id: "F-{id}", title, description, priority: "must|should|may" (from RFC 2119 keywords), acceptance, ref: "guidance-specification.md#§10" }`
495
+ - `constraints[]`: each MUST/MUST NOT from §4-N role decisions → `{ id: "C-{NNN}", area, constraint, rationale, status: "locked", ref: "{source}#§{N}" }`; append locked decisions from each `{role}/analysis.md` §2 Decisions table where status=locked
496
+ - `domain.problem_statement`: from §1-3
497
+ - `domain.terminology[]`: from Concepts & Terminology section → `{ term, definition, ref: "guidance-specification.md#§5" }`
498
+ - `domain.audience`, `domain.industry`: from §1-3
499
+ - `non_goals[]`: each Non-Goal → `{ title, rationale, ref: "guidance-specification.md#§6" }`
500
+ - `insights[]`: from each `{role}/analysis.md` §3 Cross-Cutting subsections → `{ role, area, summary, ref: "{role}/analysis.md#§3-{heading}" }`
501
+ - `open_questions[]`: from §4-N SHOULD/MAY items → `{ area, question, options[], ref }`
502
+ - `references[]`: `{ type: "guidance", path: "guidance-specification.md" }` + `{ type: "role-analysis", path: "{role}/analysis.md" }` per role
503
+
504
+ Register artifact in state.json with additional field:
505
+ `context_package: "{output_dir}/context-package.json"` (relative to .workflow/)
506
+
507
+ **GATE Step 7.5→complete**: Glob `{output_dir}/context-package.json` MUST exist before workflow report; BLOCKED if missing.
508
+