maestro-flow 0.4.11 → 0.4.12

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 (166) hide show
  1. package/.agents/agents/cli-explore-agent.md +1 -3
  2. package/.agents/agents/cross-role-reviewer.md +173 -0
  3. package/.agents/agents/role-design-author.md +218 -0
  4. package/.agents/agents/ui-design-agent.md +1 -18
  5. package/.agents/agents/workflow-analyzer.md +1 -1
  6. package/.agents/agents/workflow-external-researcher.md +1 -1
  7. package/.agents/skills/maestro/SKILL.md +61 -27
  8. package/.agents/skills/maestro-analyze/SKILL.md +30 -4
  9. package/.agents/skills/maestro-blueprint/SKILL.md +132 -0
  10. package/.agents/skills/maestro-brainstorm/SKILL.md +119 -103
  11. package/.agents/skills/maestro-help/SKILL.md +48 -14
  12. package/.agents/skills/maestro-help/index/catalog.json +29 -11
  13. package/.agents/skills/maestro-help/phases/01-parse-intent.md +1 -1
  14. package/.agents/skills/maestro-help/phases/02-search-present.md +6 -4
  15. package/.agents/skills/maestro-help/phases/03-workflow-guide.md +60 -33
  16. package/.agents/skills/maestro-init/SKILL.md +3 -3
  17. package/.agents/skills/maestro-milestone-audit/SKILL.md +5 -3
  18. package/.agents/skills/maestro-milestone-complete/SKILL.md +7 -5
  19. package/.agents/skills/maestro-plan/SKILL.md +14 -4
  20. package/.agents/skills/maestro-ralph/SKILL.md +297 -226
  21. package/.agents/skills/maestro-ralph-execute/SKILL.md +81 -67
  22. package/.agents/skills/maestro-roadmap/SKILL.md +42 -81
  23. package/.agents/skills/quality-auto-test/SKILL.md +1 -1
  24. package/.agents/skills/team-lifecycle-v4/roles/analyst/role.md +1 -1
  25. package/.agents/skills/team-lifecycle-v4/roles/reviewer/commands/review-spec.md +2 -2
  26. package/.agents/skills/team-lifecycle-v4/roles/writer/role.md +1 -1
  27. package/.agents/skills/team-lifecycle-v4/templates/architecture.md +3 -3
  28. package/.agents/skills/team-lifecycle-v4/templates/epics.md +2 -2
  29. package/.agents/skills/team-lifecycle-v4/templates/product-brief.md +3 -3
  30. package/.agents/skills/team-lifecycle-v4/templates/requirements.md +2 -2
  31. package/.agy/agents/cli-explore-agent.md +1 -3
  32. package/.agy/agents/cross-role-reviewer.md +170 -0
  33. package/.agy/agents/role-design-author.md +215 -0
  34. package/.agy/agents/ui-design-agent.md +1 -18
  35. package/.agy/agents/workflow-analyzer.md +1 -1
  36. package/.agy/agents/workflow-external-researcher.md +1 -1
  37. package/.agy/skills/maestro/SKILL.md +61 -27
  38. package/.agy/skills/maestro-analyze/SKILL.md +30 -4
  39. package/.agy/skills/maestro-blueprint/SKILL.md +132 -0
  40. package/.agy/skills/maestro-brainstorm/SKILL.md +119 -103
  41. package/.agy/skills/maestro-help/SKILL.md +48 -14
  42. package/.agy/skills/maestro-help/index/catalog.json +29 -11
  43. package/.agy/skills/maestro-help/phases/01-parse-intent.md +1 -1
  44. package/.agy/skills/maestro-help/phases/02-search-present.md +6 -4
  45. package/.agy/skills/maestro-help/phases/03-workflow-guide.md +60 -33
  46. package/.agy/skills/maestro-init/SKILL.md +3 -3
  47. package/.agy/skills/maestro-milestone-audit/SKILL.md +5 -3
  48. package/.agy/skills/maestro-milestone-complete/SKILL.md +7 -5
  49. package/.agy/skills/maestro-plan/SKILL.md +14 -4
  50. package/.agy/skills/maestro-ralph/SKILL.md +297 -226
  51. package/.agy/skills/maestro-ralph-execute/SKILL.md +81 -67
  52. package/.agy/skills/maestro-roadmap/SKILL.md +42 -81
  53. package/.agy/skills/quality-auto-test/SKILL.md +1 -1
  54. package/.agy/skills/team-lifecycle-v4/roles/analyst/role.md +1 -1
  55. package/.agy/skills/team-lifecycle-v4/roles/reviewer/commands/review-spec.md +2 -2
  56. package/.agy/skills/team-lifecycle-v4/roles/writer/role.md +1 -1
  57. package/.agy/skills/team-lifecycle-v4/templates/architecture.md +3 -3
  58. package/.agy/skills/team-lifecycle-v4/templates/epics.md +2 -2
  59. package/.agy/skills/team-lifecycle-v4/templates/product-brief.md +3 -3
  60. package/.agy/skills/team-lifecycle-v4/templates/requirements.md +2 -2
  61. package/.claude/agents/cli-explore-agent.md +1 -3
  62. package/.claude/agents/cross-role-reviewer.md +171 -0
  63. package/.claude/agents/role-design-author.md +216 -0
  64. package/.claude/agents/ui-design-agent.md +1 -18
  65. package/.claude/agents/workflow-analyzer.md +1 -1
  66. package/.claude/agents/workflow-external-researcher.md +1 -1
  67. package/.claude/commands/maestro-analyze.md +30 -4
  68. package/.claude/commands/maestro-blueprint.md +130 -0
  69. package/.claude/commands/maestro-brainstorm.md +132 -116
  70. package/.claude/commands/maestro-init.md +3 -3
  71. package/.claude/commands/maestro-milestone-audit.md +5 -3
  72. package/.claude/commands/maestro-milestone-complete.md +7 -5
  73. package/.claude/commands/maestro-plan.md +14 -4
  74. package/.claude/commands/maestro-ralph-execute.md +81 -67
  75. package/.claude/commands/maestro-ralph.md +297 -226
  76. package/.claude/commands/maestro-roadmap.md +42 -81
  77. package/.claude/commands/maestro.md +61 -27
  78. package/.claude/commands/quality-auto-test.md +1 -1
  79. package/.claude/skills/maestro-help/SKILL.md +48 -14
  80. package/.claude/skills/maestro-help/index/catalog.json +29 -11
  81. package/.claude/skills/maestro-help/phases/01-parse-intent.md +1 -1
  82. package/.claude/skills/maestro-help/phases/02-search-present.md +6 -4
  83. package/.claude/skills/maestro-help/phases/03-workflow-guide.md +60 -33
  84. package/.claude/skills/team-lifecycle-v4/roles/analyst/role.md +1 -1
  85. package/.claude/skills/team-lifecycle-v4/roles/reviewer/commands/review-spec.md +2 -2
  86. package/.claude/skills/team-lifecycle-v4/roles/writer/role.md +1 -1
  87. package/.claude/skills/team-lifecycle-v4/templates/architecture.md +3 -3
  88. package/.claude/skills/team-lifecycle-v4/templates/epics.md +2 -2
  89. package/.claude/skills/team-lifecycle-v4/templates/product-brief.md +3 -3
  90. package/.claude/skills/team-lifecycle-v4/templates/requirements.md +2 -2
  91. package/.codex/skills/maestro/SKILL.md +75 -38
  92. package/.codex/skills/maestro-amend/SKILL.md +157 -0
  93. package/.codex/skills/maestro-analyze/SKILL.md +71 -23
  94. package/.codex/skills/maestro-blueprint/SKILL.md +122 -0
  95. package/.codex/skills/maestro-brainstorm/SKILL.md +135 -45
  96. package/.codex/skills/maestro-composer/SKILL.md +1 -1
  97. package/.codex/skills/maestro-execute/SKILL.md +13 -4
  98. package/.codex/skills/maestro-help/SKILL.md +28 -18
  99. package/.codex/skills/maestro-help/catalog.json +29 -11
  100. package/.codex/skills/maestro-init/SKILL.md +7 -7
  101. package/.codex/skills/maestro-plan/SKILL.md +27 -9
  102. package/.codex/skills/maestro-ralph/SKILL.md +740 -601
  103. package/.codex/skills/maestro-roadmap/SKILL.md +55 -72
  104. package/.codex/skills/maestro-update/SKILL.md +169 -0
  105. package/.codex/skills/maestro-verify/SKILL.md +11 -2
  106. package/.codex/skills/manage-codebase-rebuild/SKILL.md +2 -2
  107. package/.codex/skills/manage-harvest/SKILL.md +10 -2
  108. package/.codex/skills/quality-retrospective/SKILL.md +9 -2
  109. package/.codex/skills/team-lifecycle-v4/roles/analyst/role.md +2 -2
  110. package/.codex/skills/team-lifecycle-v4/roles/reviewer/commands/review-spec.md +2 -2
  111. package/.codex/skills/team-lifecycle-v4/roles/writer/role.md +1 -1
  112. package/.codex/skills/team-lifecycle-v4/templates/architecture.md +3 -3
  113. package/.codex/skills/team-lifecycle-v4/templates/epics.md +2 -2
  114. package/.codex/skills/team-lifecycle-v4/templates/product-brief.md +3 -3
  115. package/.codex/skills/team-lifecycle-v4/templates/requirements.md +2 -2
  116. package/README.md +8 -8
  117. package/README.zh-CN.md +8 -8
  118. package/dashboard/dist-server/dashboard/src/server/routes/settings.js +3 -3
  119. package/dashboard/dist-server/dashboard/src/server/routes/settings.js.map +1 -1
  120. package/dist/src/agents/cli-agent-runner.d.ts.map +1 -1
  121. package/dist/src/agents/cli-agent-runner.js +13 -7
  122. package/dist/src/agents/cli-agent-runner.js.map +1 -1
  123. package/dist/src/commands/spec.d.ts.map +1 -1
  124. package/dist/src/commands/spec.js +8 -1
  125. package/dist/src/commands/spec.js.map +1 -1
  126. package/dist/src/tools/spec-init.d.ts +16 -2
  127. package/dist/src/tools/spec-init.d.ts.map +1 -1
  128. package/dist/src/tools/spec-init.js +58 -187
  129. package/dist/src/tools/spec-init.js.map +1 -1
  130. package/dist/src/tools/spec-loader.d.ts.map +1 -1
  131. package/dist/src/tools/spec-loader.js +16 -16
  132. package/dist/src/tools/spec-loader.js.map +1 -1
  133. package/dist/src/tools/spec-seeds.d.ts +33 -0
  134. package/dist/src/tools/spec-seeds.d.ts.map +1 -0
  135. package/dist/src/tools/spec-seeds.js +200 -0
  136. package/dist/src/tools/spec-seeds.js.map +1 -0
  137. package/dist/src/tools/spec-writer.d.ts.map +1 -1
  138. package/dist/src/tools/spec-writer.js +7 -9
  139. package/dist/src/tools/spec-writer.js.map +1 -1
  140. package/dist/src/utils/update-notices.js +12 -0
  141. package/dist/src/utils/update-notices.js.map +1 -1
  142. package/package.json +1 -1
  143. package/templates/business-test-report.json +1 -1
  144. package/templates/index.json +1 -1
  145. package/templates/roadmap.md +15 -9
  146. package/templates/state.json +18 -17
  147. package/workflows/analyze.md +79 -11
  148. package/workflows/auto-test.md +6 -6
  149. package/workflows/blueprint.md +431 -0
  150. package/workflows/brainstorm.md +603 -496
  151. package/workflows/business-test.md +7 -7
  152. package/workflows/codebase-rebuild.md +4 -4
  153. package/workflows/harvest.md +184 -10
  154. package/workflows/init.md +9 -8
  155. package/workflows/maestro.md +1 -1
  156. package/workflows/milestone-audit.md +12 -4
  157. package/workflows/milestone-complete.md +11 -6
  158. package/workflows/plan.md +88 -22
  159. package/workflows/roadmap-common.md +1 -1
  160. package/workflows/roadmap.md +13 -3
  161. package/workflows/spec-generate.md +24 -13
  162. package/workflows/ui-design.md +2 -2
  163. package/workflows/ui-style.md +1 -1
  164. package/.agents/agents/conceptual-planning-agent.md +0 -247
  165. package/.agy/agents/conceptual-planning-agent.md +0 -244
  166. package/.claude/agents/conceptual-planning-agent.md +0 -245
@@ -1,496 +1,603 @@
1
- # Workflow: Brainstorm
2
-
3
- Unified brainstorming workflow with dual-mode operation: auto pipeline (full multi-role analysis) and single role analysis mode.
4
-
5
- ## Architecture
6
-
7
- ```
8
- ┌─────────────────────────────────────────────────────────┐
9
- │ /maestro-brainstorm │
10
- │ Unified Entry Point + Interactive Routing │
11
- └───────────────────────┬─────────────────────────────────┘
12
-
13
- ┌─────────┴─────────┐
14
- ↓ ↓
15
- ┌─────────────────┐ ┌──────────────────┐
16
- │ Auto Mode │ │ Single Role Mode │
17
- └────────┬────────┘ └────────┬─────────┘
18
- │ │
19
- ┌────────┼────────┐
20
- ↓ ↓
21
- Phase 2 Phase 3 Phase 4 Phase 3
22
- Artifacts N×Role Synthesis 1×Role
23
- 并行 Analysis
24
- ```
25
-
26
- ## Dual-Mode Routing
27
-
28
- ### Auto Mode (full pipeline)
29
- Triggered by `--yes`/`-y` flag or user selection.
30
-
31
- ```
32
- Phase 1: Mode Detection → Parse args, detect mode
33
- Phase 1.5: Terminology & Boundary → Extract terms, collect Non-Goals
34
- Phase 2: Interactive Framework7 sub-phases (context → topic → roles → questions → conflicts → check → spec)
35
- Phase 3: Parallel Role AnalysisN concurrent role analyses via conceptual-planning-agent
36
- Phase 4: Synthesis IntegrationCross-role analysisuser clarification → spec generation
37
- ```
38
-
39
- ### Single Role Mode
40
- Triggered when first arg is a valid role name.
41
-
42
- ```
43
- Phase 1: Mode Detection Parse args, detect mode
44
- Phase 3: Single Role Analysis → Detection → Context → Agent → Validation
45
- ```
46
-
47
- ## Input
48
-
49
- - `$ARGUMENTS`: topic text (auto mode) or role name (single role mode)
50
- - All output goes to `.workflow/scratch/brainstorm-{slug}-{date}/`
51
- - Registers artifact (type=brainstorm) in state.json on completion
52
-
53
- ### Parameters
54
-
55
- | Parameter | Description | Default |
56
- |-----------|-------------|---------|
57
- | `--yes`, `-y` | Auto mode, skip all questions | - |
58
- | `--count N` | Number of roles to select | 3 |
59
- | `--session ID` | Use existing session | - |
60
- | `--update` | Update existing analysis | - |
61
- | `--include-questions` | Interactive context gathering | - |
62
- | `--skip-questions` | Use default answers | - |
63
- | `--style-skill PKG` | Style package for ui-designer | - |
64
-
65
- ### Available Roles
66
-
67
- | Role ID | Title | Focus Area |
68
- |---------|-------|------------|
69
- | `data-architect` | 数据架构师 | Data models, storage strategies, data flow |
70
- | `product-manager` | 产品经理 | Product strategy, roadmap, prioritization |
71
- | `product-owner` | 产品负责人 | Backlog management, user stories, acceptance criteria |
72
- | `scrum-master` | 敏捷教练 | Process facilitation, impediment removal |
73
- | `subject-matter-expert` | 领域专家 | Domain knowledge, business rules, compliance |
74
- | `system-architect` | 系统架构师 | Technical architecture, scalability, integration |
75
- | `test-strategist` | 测试策略师 | Test strategy, quality assurance |
76
- | `ui-designer` | UI设计师 | Visual design, mockups, design systems |
77
- | `ux-expert` | UX专家 | User research, information architecture, journey |
78
-
79
- ## Output
80
-
81
- ### Directory Structure
82
-
83
- All brainstorm output goes to scratch:
84
- ```
85
- .workflow/scratch/brainstorm-{slug}-{date}/
86
- ├── guidance-specification.md # Phase 2 output
87
- ├── feature-index.json # Phase 4 output
88
- ├── synthesis-changelog.md # Phase 4 audit trail
89
- ├── feature-specs/ # Phase 4 feature specs
90
- ├── F-001-{slug}.md
91
- │ └── F-00N-{slug}.md
92
- ├── {role}/ # Phase 3 role analyses (immutable)
93
- │ ├── {role}-context.md
94
- │ ├── analysis.md
95
- │ ├── analysis-cross-cutting.md
96
- │ └── analysis-F-{id}-{slug}.md
97
- └── synthesis-specification.md # Non-feature mode fallback
98
- ```
99
-
100
- ---
101
-
102
- ## Process
103
-
104
- ### Step 1: Parse & Route (Mode Detection)
105
-
106
- Parse $ARGUMENTS to determine execution mode:
107
-
108
- **Mode Detection (ordered by priority)**:
109
- 1. `--yes` or `-y` flag → **Auto Mode** (no question asked)
110
- 2. First non-flag arg matches valid role name → **Single Role Mode**
111
- 3. First non-flag arg is a number → **Phase Mode** (resolve phase dir, then auto)
112
- 4. Text provided without flags → Ask user via AskUserQuestion:
113
- - "自动模式 (推荐)" 完整流程:框架生成 → 多角色并行分析 → 跨角色综合
114
- - "单角色分析" — 为单个角色生成分析文档
115
-
116
- **Parameter Parsing**:
117
- - `--count N`: cap at 9, default 3
118
- - `--session ID`: target specific session
119
- - `--style-skill PKG`: validate `.claude/skills/style-{PKG}/SKILL.md` exists
120
- - Missing/empty args without flags = error E001
121
-
122
- **Session Detection**:
123
- - Check `.workflow/scratch/brainstorm-*/` for existing sessions
124
- - Multiple → AskUserQuestion to select | Single → use it
125
- - None + auto mode → will create new session
126
- - None + single role mode error E002
127
-
128
- **Output Directory Resolution**:
129
- - Phase mode (number): resolve `state.json.artifacts[phase == phaseNum].path` → `.workflow/{path}/.brainstorming/` (ERROR if phase not found)
130
- - All output: `.workflow/scratch/brainstorm-{slug}-{date}/`
131
- - Existing session: use existing session directory
132
-
133
- ---
134
-
135
- ### Step 1.5: Load Project Specs
136
-
137
- ```
138
- specs_content = maestro spec load --category arch
139
- ```
140
-
141
- Pass to conceptual-planning-agent in Step 4 for architecture-aware role analysis.
142
-
143
- ---
144
-
145
- ### Auto Mode Steps (Phase 1.5 → Phase 1.7 → Phase 2 → Phase 3 → Phase 4)
146
-
147
- ### Step 1.7: External Research Design Routes (Auto Mode, Optional)
148
-
149
- Spawn `workflow-external-researcher` agent to discover design alternatives, architecture patterns, and competitive approaches for the brainstorm topic. This enriches the framework generation and role analyses with external knowledge.
150
-
151
- **Trigger**: Always in auto mode. Skip if `--skip-questions` and no tech keywords detected.
152
-
153
- **Auto-suggest when**: Topic contains technology keywords, architecture terms, or "design" / "pattern" / "alternative" in the description.
154
-
155
- ```
156
- // Step 1.7.1: Spawn external researcher for design routes
157
- Agent(
158
- subagent_type="workflow-external-researcher",
159
- prompt="""
160
- <objective>
161
- Research design alternatives and architecture patterns for: {topic}
162
- Mode: Design Research
163
- </objective>
164
-
165
- <context>
166
- Project specs: {specs_content or "none"}
167
- Topic keywords: {extracted_keywords}
168
- </context>
169
-
170
- <task>
171
- Search for:
172
- 1. Reference projects — how 2-3 similar projects/products solve this problem (architecture, key decisions, what worked)
173
- 2. Extractable patterns — reusable design patterns distilled from those projects, with applicability notes
174
- 3. Architecture approaches (at least 2-3 alternatives with trade-offs)
175
- 4. UX/UI patterns if applicable (interaction models, layout strategies)
176
- 5. Common design pitfalls and anti-patterns to avoid
177
-
178
- IMPORTANT: Output MUST include "Reference Projects / Implementations" and "Extractable Patterns" sections.
179
- Focus on design ROUTES — alternative approaches the brainstorm roles can evaluate.
180
- Be prescriptive where evidence is strong, present alternatives where trade-offs exist.
181
- Return structured markdown only do NOT write files.
182
- </task>
183
- """,
184
- run_in_background=false
185
- )
186
-
187
- // Step 1.7.2: Store as designResearchContext (in-memory)
188
- designResearchContext = agent_output
189
- ```
190
-
191
- `designResearchContext` is passed into:
192
- - Step 2 (Terminology): enriches domain term extraction
193
- - Step 3 Phase 1 (Topic Analysis): provides external design alternatives
194
- - Step 4 (Parallel Role Analysis): each role agent receives design research as additional context
195
-
196
- If research fails (W005): `designResearchContext = null`, continue without external context.
197
-
198
- ---
199
-
200
- ### Step 1.8: Load Project Context (if `.workflow/` exists)
201
-
202
- Load existing project history to ground brainstorming in what's already been built:
203
-
204
- - From `.workflow/project.md`: `### Validated` → already_shipped, `### Active` → current_scope, `## Context` → project_history
205
- - From `.workflow/state.json.accumulated_context`: `deferred[]` deferred_items, `key_decisions[]` → existing_constraints
206
-
207
- Pass `project_context` into Step 2 (terminology) and Step 3 (framework generation):
208
- - `already_shipped` informs what exists — brainstorm should explore extensions, not re-invent
209
- - `deferred_items` are high-value brainstorming seeds
210
- - `lessons_learned` surface pitfalls to avoid
211
-
212
- ---
213
-
214
- ### Step 2: Terminology & Boundary Definition (Auto Mode)
215
-
216
- Extract core terminology and define scope boundaries before framework generation.
217
-
218
- 1. Analyze topic description and any project context (project.md, roadmap.md, project_context from Step 1.8)
219
- 2. Extract 5-10 core domain terms:
220
- - term (canonical), definition, aliases, category (core|technical|business)
221
- 3. AskUserQuestion for Non-Goals (multiSelect=true):
222
- - Generate 4-5 context-aware exclusion candidates based on topic
223
- - Include "其他(请补充)" option for custom exclusions
224
- - If user selects "其他", follow up with free-text question
225
- 4. Store terminology table and non_goals to session state
226
-
227
- **Skip if**: `--yes` flag (use auto-generated terms, empty non-goals)
228
-
229
- ### Step 3: Interactive Framework Generation (Auto Mode)
230
-
231
- Seven sub-phases producing guidance-specification.md:
232
-
233
- **Phase 0: Context Collection**
234
- - Read init outputs directly: `.workflow/project.md` (tech stack, requirements, decisions), `.workflow/state.json` (project state), `.workflow/specs/` (conventions)
235
- - If `.workflow/` does not exist: continue without project context
236
-
237
- **Phase 1: Topic Analysis**
238
- - Load Phase 0 context (tech_stack, modules, conflict_risk)
239
- - Deep topic analysis (entities, challenges, constraints, metrics)
240
- - Generate 2-4 context-aware probing questions via AskUserQuestion
241
- - Questions MUST reference topic keywords (no generic questions)
242
- - Store to `session.intent_context`
243
-
244
- **Phase 2: Role Selection**
245
- - Analyze Phase 1 keywords recommend count+2 roles with rationale
246
- - AskUserQuestion (multiSelect=true) for user to select `count` roles
247
- - If `--yes`: auto-select recommended roles
248
- - Store to `session.selected_roles`
249
-
250
- **Phase 3: Role-Specific Questions**
251
- - FOR each selected role, generate 3-4 deep questions mapping role expertise to Phase 1 challenges
252
- - AskUserQuestion per role (sequential, one role at a time)
253
- - Questions must include: implementation depth, trade-offs, edge cases
254
- - Store to `session.role_decisions[role]`
255
- - If `--yes`: skip all role questions
256
-
257
- **Phase 4: Conflict Resolution**
258
- - Analyze Phase 3 answers for contradictions, missing integrations, implicit dependencies
259
- - Generate clarification questions referencing SPECIFIC Phase 3 choices
260
- - AskUserQuestion (max 4 per round)
261
- - If NO conflicts detected: skip with notification
262
- - Store to `session.cross_role_decisions`
263
-
264
- **Phase 4.5: Final Clarification + Feature Decomposition**
265
- - Ask: "是否有前面未澄清的重点需要补充?" (无需补充 / 需要补充)
266
- - If "需要补充": progressive questions until resolved
267
- - Extract candidate features from all Phase 1-4 decisions (max 8)
268
- - Each feature: F-{3-digit} ID, kebab-case slug, description, related roles, priority
269
- - Validate: independence, completeness, granularity balance, boundary clarity
270
- - AskUserQuestion for user to confirm or adjust feature list
271
- - Store to `session.feature_list`
272
-
273
- **Phase 5: Generate Specification**
274
- - Load all decisions + terminology + non_goals + feature_list
275
- - Transform Q&A to declarative statements (CONFIRMED/SELECTED)
276
- - Apply RFC 2119 keywords (MUST, SHOULD, MAY, MUST NOT, SHOULD NOT)
277
- - Write `guidance-specification.md` with sections:
278
- 1. Project Positioning & Goals
279
- 2. Concepts & Terminology (table)
280
- 3. Non-Goals (Out of Scope)
281
- 4-N. [Role] Decisions (with RFC 2119)
282
- Cross-Role Integration
283
- Risks & Constraints
284
- Feature Decomposition (table)
285
- Appendix: Decision Tracking
286
- - Validate: no interrogative sentences, all decisions traceable, RFC keywords applied
287
-
288
- **Output**: `{output_dir}/guidance-specification.md`, session metadata (workflow-session.json)
289
-
290
- ### Step 3.5: Visual Style Foundation (Auto Mode, conditional)
291
-
292
- When `ui-designer` is among the selected roles, establish the project's visual direction before role analysis begins. This ensures all downstream UX analysis works within a confirmed design system.
293
-
294
- **Condition**: Skip if `.workflow/impeccable/DESIGN.md` already exists (visual direction already locked).
295
-
296
- **Execution** (sequential):
297
-
298
- 1. **Product context** if `.workflow/impeccable/PRODUCT.md` missing:
299
- ```
300
- Skill({ skill: "maestro-impeccable", args: "teach" })
301
- ```
302
- This runs the teach interview to establish brand, users, personality, anti-references.
303
-
304
- 2. **Visual exploration** multi-style comparison and selection:
305
- ```
306
- Skill({ skill: "maestro-impeccable", args: "explore" })
307
- ```
308
- This generates multiple design system variants as HTML prototypes, launches visual comparison, and lets the user select/mix. Produces DESIGN.md on completion.
309
-
310
- 3. Record in session metadata: `design_system_established: true`, `design_md_path: ".workflow/impeccable/DESIGN.md"`
311
-
312
- **`--yes` mode**: `explore` auto-selects variant 1 without visual comparison. `teach` still requires minimal input if PRODUCT.md is missing.
313
-
314
- **Skip mode**: If user explicitly passes `--skip-design` to brainstorm, skip this step entirely. ui-designer role will generate its own independent theme in Phase 2.
315
-
316
- ### Step 4: Parallel Role Analysis (Auto Mode)
317
-
318
- For EACH selected role, spawn a conceptual-planning-agent in parallel:
319
-
320
- ```
321
- Agent({
322
- subagent_type: "conceptual-planning-agent",
323
- prompt: "[role analysis prompt with framework + role template]",
324
- run_in_background: false
325
- })
326
- ```
327
-
328
- Each agent receives:
329
- - `guidance-specification.md` for framework context
330
- - Role-specific template from `~/.maestro/templates/planning-roles/{role}.md`
331
- - Feature list for feature-point organization
332
- - `--skip-questions` flag (context already gathered in Phase 2)
333
- - For ui-designer: `--style-skill {package}` if provided
334
- - If `designResearchContext` is set: include as "External Design Research" section in agent prompt (design alternatives, patterns, competitive analysis for the role to evaluate and reference)
335
-
336
- **Feature-Point Organization** (when feature list available):
337
- - `analysis.md` — Role overview INDEX only (< 1500 words)
338
- - `analysis-cross-cutting.md` — Cross-feature decisions (< 2000 words)
339
- - `analysis-F-{id}-{slug}.md` — Per-feature analysis (< 2000 words each)
340
-
341
- **Fallback Organization** (no feature list):
342
- - `analysis.md` Main analysis (< 3000 words)
343
- - Optional `analysis-{slug}.md` sub-documents (max 5)
344
-
345
- **system-architect specific requirements**:
346
- - MUST include: Data Model (3-5 entities), State Machine (ASCII + transition table), Error Handling, Observability (5+ metrics), Configuration Model, Boundary Scenarios
347
- - All constraints MUST use RFC 2119 keywords
348
-
349
- **Quality Validation** (after each role completes, orchestrator self-check):
350
- - Verify `analysis.md` exists and is non-empty
351
- - Feature mode: verify `analysis-cross-cutting.md` + `analysis-F-*.md` files match feature list
352
- - Grep for RFC 2119 keywords (MUST/SHOULD/MAY) — warn if < 5 occurrences
353
- - Check word count (wc -w) against limits — warn if exceeded
354
- - system-architect: verify Data Model and State Machine sections exist
355
-
356
- **Parallel Safety**: Each role operates on its own directory. No cross-agent dependencies.
357
-
358
- ### Step 5: Synthesis Integration (Auto Mode)
359
-
360
- Seven sub-phases producing feature specs from cross-role analysis:
361
-
362
- **Sub-phase 1: Discovery**
363
- - Detect session, validate analysis files exist
364
- - Load user intent from session metadata
365
- - Detect feature mode (feature decomposition table + analysis-F-*.md files)
366
-
367
- **Sub-phase 2: File Discovery**
368
- - Glob `{output_dir}/{role}/analysis*.md`
369
- - Extract role_analysis_paths and participating_roles
370
- - Feature mode optimization: read only analysis.md index files (~4.5K total) not sub-documents
371
-
372
- **Sub-phase 3A: Cross-Role Analysis Agent**
373
- - Spawn conceptual-planning-agent for cross-role analysis
374
- - Input: analysis index files (feature mode) or all analysis files (fallback)
375
- - Output: `enhancement_recommendations` (EP-001, EP-002, ...) + `feature_conflict_map` (per-feature consensus/conflicts/cross_refs)
376
- - Conflict resolution quality: actionable, justified ("because...tradeoff:..."), scoped, confidence-tagged ([RESOLVED]|[SUGGESTED]|[UNRESOLVED])
377
-
378
- **Sub-phase 3B: Brainstorm Confidence Scoring**
379
-
380
- Compute after cross-role analysis, before user interaction. Dimensions (5): role_coverage, cross_role_consistency, feature_completeness, spec_quality, design_feasibility. Factors (weights): analysis_depth(.30), evidence_strength(.25), coverage_breadth(.20), user_validation(.15), consistency(.10).
381
-
382
- Scoring points: per-role completion → `role_coverage`; after cross-role → `cross_role_consistency`; after user interaction → `user_validation`.
383
-
384
- **Quality mechanisms**: Pressure Pass (before spec gen) — verify claims backed by ≥2 role analyses. Devil's Advocate — challenge when dimension > 0.7. Conflict Detection (replaces stall) — >3 `[UNRESOLVED]` conflicts → challenge.
385
-
386
- **Readiness Gate** (before Sub-phase 4): Block if role_coverage < 100% | cross_role_consistency < 40% | feature_completeness below intent count | no pressure pass. If blocked → AskUserQuestion: fill gaps or proceed with residual risks. Append confidence summary to synthesis-changelog.md.
387
-
388
- **Sub-phase 4: User Interaction**
389
- - Enhancement selection: AskUserQuestion (multiSelect=true, batched by 4)
390
- - Clarification questions: 9-category taxonomy scan, AskUserQuestion (single-select, multi-round)
391
- - Build spec_context: selected_enhancements + clarification_answers + original_user_intent
392
- - If `--yes`: auto-select all enhancements, skip clarifications
393
-
394
- **Sub-phase 5: Spec Generation + Conditional Review**
395
- - Single conceptual-planning-agent generates all specs sequentially:
396
- - Feature mode: one `feature-specs/F-{id}-{slug}.md` per feature (7 sections, 1500-2500 words)
397
- - Fallback mode: single `synthesis-specification.md`
398
- - `feature-index.json` (feature mode only)
399
- - `synthesis-changelog.md` (enhancements applied, clarifications resolved, conflicts resolved)
400
- - Self-evaluate complexity_score (0-8 scale: feature count, unresolved conflicts, roles, cross-deps)
401
- - If complexity_score >= 4: trigger review agent for cross-feature consistency check
402
- - Minor fixes applied directly, major issues flagged with [REVIEW-FLAG]
403
-
404
- **Feature Spec Template (7 Sections)**:
405
- 1. Requirements Summary (RFC 2119 keywords)
406
- 2. Design Decisions [CORE — 40%+ word count]
407
- 3. Interface Contract
408
- 4. Constraints & Risks
409
- 5. Acceptance Criteria
410
- 6. Detailed Analysis References (@-links)
411
- 7. Cross-Feature Dependencies
412
-
413
- **Four-Layer Aggregation Rules**:
414
- - Layer 1: Direct Reference (consensusquote roles)
415
- - Layer 2: Structured Extraction (complementary merge, de-duplicate)
416
- - Layer 3: Conflict Distillation ([RESOLVED] decision, [SUGGESTED] recommended, [UNRESOLVED] [DECISION NEEDED])
417
- - Layer 4: Cross-Feature Annotation (dependency notes, integration points)
418
-
419
- **Sub-phase 6: Finalization**
420
- - Update context-package.json with spec paths
421
- - Update session metadata (enhancements_applied, questions_asked, complexity_score, review results)
422
- - Completion report with next step suggestion
423
-
424
- ---
425
-
426
- ### Single Role Mode Steps
427
-
428
- ### Step 6: Single Role Analysis
429
-
430
- Execute analysis for ONE specified role with optional interactive context gathering.
431
-
432
- **Step 6.1: Detection & Validation**
433
- - Validate role_name against VALID_ROLES list
434
- - Detect session (--session or find existing)
435
- - Check for guidance-specification.md framework_mode
436
- - Extract feature list feature_mode
437
- - Check existing analysis → update_mode (ask: update/regenerate/cancel)
438
-
439
- **Step 6.2: Interactive Context Gathering**
440
- - Skip if `--skip-questions`
441
- - Force if `--include-questions`
442
- - Generate 3-5 role-specific questions (Chinese, with business context)
443
- - AskUserQuestion per batch (max 4 per round)
444
- - Save context to `{role}/{role}-context.md`
445
-
446
- **Step 6.3: Agent Execution**
447
- - Spawn conceptual-planning-agent with:
448
- - Role name, framework (if exists), feature list (if exists)
449
- - User context (if gathered), session metadata
450
- - Role-specific template
451
- - For ui-designer: style-skill package
452
- - Agent generates analysis files in `{output_dir}/{role}/`
453
-
454
- **Step 6.4: Validation**
455
- - Verify `analysis.md` exists
456
- - Check framework reference if framework_mode
457
- - Update session metadata with completion status
458
- - Report results with next step suggestions
459
-
460
- ---
461
-
462
- ### Step 7: Final Report
463
-
464
- **Auto mode report:**
465
- - Session ID and output directory
466
- - Roles analyzed (N)
467
- - Features specified (N)
468
- - Enhancements applied (EP-IDs)
469
- - Complexity score and review status
470
- - Next:
471
- Skill({ skill: "maestro-roadmap", args: "--mode full --from-brainstorm {sessionId}" }) — Generate full spec package
472
- Skill({ skill: "maestro-analyze", args: "{topic}" }) — Evaluate feasibility + lock decisions
473
- Skill({ skill: "maestro-analyze", args: "{phase} -q" }) — Quick decision extraction only
474
- Skill({ skill: "maestro-plan", args: "{phase}" }) — Plan directly (if scope is clear)
475
-
476
- **Single role mode report:**
477
- - Role analyzed
478
- - Framework alignment status
479
- - Context questions answered
480
- - Output file location
481
- - Next: run more roles or Skill({ skill: "maestro-brainstorm", args: "--session {sessionId}" }) for synthesis
482
-
483
- ---
484
-
485
- ## Quality Criteria
486
-
487
- - If `designResearchContext` is set: guidance-specification.md references external design findings
488
- - guidance-specification.md uses RFC 2119 keywords (MUST/SHOULD/MAY)
489
- - Concepts & Terminology section with 5-10 core terms
490
- - Non-Goals section with rationale
491
- - Feature Decomposition table (max 8 features, independently implementable)
492
- - Role analyses follow role-specific templates
493
- - system-architect includes: Data Model, State Machine, Error Handling, Observability
494
- - Feature specs have 7 sections, Section 2 (Design Decisions) is 40%+ of content
495
- - All conflicts resolved or marked [DECISION NEEDED]
496
- - synthesis-changelog.md records all synthesis decisions as audit trail
1
+ # Workflow: Brainstorm
2
+
3
+ Unified brainstorming workflow with dual-mode operation: auto pipeline (full multi-role analysis) and single role analysis mode.
4
+
5
+ ## Architecture
6
+
7
+ ```
8
+ ┌─────────────────────────────────────────────────────────┐
9
+ │ /maestro-brainstorm │
10
+ │ Unified Entry Point + Interactive Routing │
11
+ └───────────────────────┬─────────────────────────────────┘
12
+
13
+ ┌─────────┴─────────┐
14
+ ↓ ↓
15
+ ┌─────────────────┐ ┌──────────────────┐
16
+ │ Auto Mode │ │ Single Role Mode │
17
+ └────────┬────────┘ └────────┬─────────┘
18
+ │ │
19
+ ┌────────┬──────────┬───────┐
20
+ ↓ ↓ ↓ ↓ ↓
21
+ Phase 2 Phase 3 Phase 4 Phase 5 Phase 3
22
+ Artifacts N×Role Cross- Apply 1×Role
23
+ Analysis Role Resol. Analysis
24
+ (multi- Review
25
+ file) (digest)
26
+ ```
27
+
28
+ ## Dual-Mode Routing
29
+
30
+ ### Auto Mode (full pipeline)
31
+ Triggered by `--yes`/`-y` flag or user selection.
32
+
33
+ ```
34
+ Phase 1: Mode DetectionParse args, detect mode
35
+ Phase 1.5: Terminology & BoundaryExtract terms, collect Non-Goals
36
+ Phase 2: Interactive Framework7 sub-phases (contexttopic roles questions → conflicts → check → spec)
37
+ Phase 3: Parallel Role Analysis → N concurrent {role}/ multi-file via role-design-author
38
+ Phase 4: Cross-Role Review → cross-role-reviewer compares Decision Digests (read-only)
39
+ Phase 5: Apply Resolutions → AskUserQuestion per finding → patch role files + guidance §12
40
+ ```
41
+
42
+ ### Single Role Mode
43
+ Triggered when first arg is a valid role name.
44
+
45
+ ```
46
+ Phase 1: Mode Detection → Parse args, detect mode
47
+ Phase 3: Single Role Analysis → Detection → Context → Agent → Validation
48
+ ```
49
+
50
+ ## Input
51
+
52
+ - `$ARGUMENTS`: topic text (auto mode) or role name (single role mode)
53
+ - All output goes to `.workflow/scratch/brainstorm-{slug}-{date}/`
54
+ - Registers artifact (type=brainstorm) in state.json on completion
55
+
56
+ ### Parameters
57
+
58
+ | Parameter | Description | Default |
59
+ |-----------|-------------|---------|
60
+ | `--yes`, `-y` | Auto mode, skip all questions | - |
61
+ | `--count N` | Number of roles to select | 3 |
62
+ | `--session ID` | Use existing session | - |
63
+ | `--update` | Update existing analysis | - |
64
+ | `--include-questions` | Interactive context gathering | - |
65
+ | `--skip-questions` | Use default answers | - |
66
+ | `--style-skill PKG` | Style package for ui-designer | - |
67
+ | `--review-only` | Skip Phase 3 (role analysis); run only Step 4.5 + Step 5 on existing role analyses | - |
68
+
69
+ ### Available Roles
70
+
71
+ | Role ID | Title | Focus Area |
72
+ |---------|-------|------------|
73
+ | `data-architect` | 数据架构师 | Data models, storage strategies, data flow |
74
+ | `product-manager` | 产品经理 | Product strategy, roadmap, prioritization |
75
+ | `product-owner` | 产品负责人 | Backlog management, user stories, acceptance criteria |
76
+ | `scrum-master` | 敏捷教练 | Process facilitation, impediment removal |
77
+ | `subject-matter-expert` | 领域专家 | Domain knowledge, business rules, compliance |
78
+ | `system-architect` | 系统架构师 | Technical architecture, scalability, integration |
79
+ | `test-strategist` | 测试策略师 | Test strategy, quality assurance |
80
+ | `ui-designer` | UI设计师 | Visual design, mockups, design systems |
81
+ | `ux-expert` | UX专家 | User research, information architecture, journey |
82
+
83
+ ## Output
84
+
85
+ ### Directory Structure
86
+
87
+ All brainstorm output goes to scratch:
88
+ ```
89
+ .workflow/scratch/brainstorm-{slug}-{date}/
90
+ ├── guidance-specification.md # Phase 2 output — machine contract (downstream consumes this)
91
+ ├── design-research.md # Optional Step 1.7 output
92
+ ├── system-architect/ # Phase 3 per-role analysis (one folder per selected role)
93
+ │ ├── analysis.md # INDEX — digest + cross-cutting foundations + file index
94
+ │ ├── analysis-F-001-agent-loop.md # per-feature analysis
95
+ │ ├── analysis-F-002-skill-engine.md
96
+ │ └── findings-perf-risk.md # additional discoveries
97
+ ├── ux-expert/
98
+ │ ├── analysis.md
99
+ │ ├── analysis-F-001-agent-loop.md
100
+ │ └── analysis-F-003-tui-frontend.md
101
+ └── {role}/
102
+ └── ...
103
+ ```
104
+
105
+ Clarifications and audit trail live in `guidance-specification.md` §11 Appendix. Cross-Role Resolutions in §12.
106
+
107
+ ---
108
+
109
+ ## Process
110
+
111
+ ### Step 1: Parse & Route (Mode Detection)
112
+
113
+ Parse $ARGUMENTS to determine execution mode:
114
+
115
+ **Mode Detection (ordered by priority)**:
116
+ 1. `--review-only` flag → **Review-Only Mode** (requires `--session ID`; runs Step 4.5 + Step 5 only)
117
+ 2. `--yes` or `-y` flag **Auto Mode** (no question asked)
118
+ 3. First non-flag arg matches valid role name → **Single Role Mode**
119
+ 4. First non-flag arg is a number → **Phase Mode** (resolve phase dir, then auto)
120
+ 5. Text provided without flags Ask user via AskUserQuestion:
121
+ - "自动模式 (推荐)" — 完整流程:框架生成 → 多角色并行分析 → 跨角色复审 → 决议回流
122
+ - "单角色分析" — 为单个角色生成 {role}/ 分析文件
123
+ - "跨角色复审" 已有多个角色分析,仅运行复审与决议回流
124
+
125
+ **Parameter Parsing**:
126
+ - `--count N`: cap at 9, default 3
127
+ - `--session ID`: target specific session
128
+ - `--style-skill PKG`: validate `.claude/skills/style-{PKG}/SKILL.md` exists
129
+ - Missing/empty args without flags = error E001
130
+
131
+ **Session Detection**:
132
+ - Check `.workflow/scratch/brainstorm-*/` for existing sessions
133
+ - Multiple → AskUserQuestion to select | Single → use it
134
+ - None + auto mode → will create new session
135
+ - None + single role mode → error E002
136
+
137
+ **Output Directory Resolution**:
138
+ - Phase mode (number): resolve `state.json.artifacts[phase == phaseNum].path` → `.workflow/{path}/.brainstorming/` (ERROR if phase not found)
139
+ - All output: `.workflow/scratch/brainstorm-{slug}-{date}/`
140
+ - Existing session: use existing session directory
141
+
142
+ ---
143
+
144
+ ### Step 1.5: Load Project Specs
145
+
146
+ ```
147
+ specs_content = maestro spec load --category arch
148
+ ```
149
+
150
+ Pass to role-design-author in Step 4 for architecture-aware role analysis.
151
+
152
+ ---
153
+
154
+ ### Auto Mode Steps (Phase 1.5 → Phase 1.7 → Phase 2 → Phase 3 → Phase 4)
155
+
156
+ ### Step 1.7: External Research Design Routes (Auto Mode, Optional)
157
+
158
+ Spawn `workflow-external-researcher` agent to discover design alternatives, architecture patterns, and competitive approaches for the brainstorm topic. This enriches the framework generation and role analyses with external knowledge.
159
+
160
+ **Trigger**: Always in auto mode. Skip if `--skip-questions` and no tech keywords detected.
161
+
162
+ **Auto-suggest when**: Topic contains technology keywords, architecture terms, or "design" / "pattern" / "alternative" in the description.
163
+
164
+ ```
165
+ // Step 1.7.1: Spawn external researcher for design routes
166
+ Agent(
167
+ subagent_type="workflow-external-researcher",
168
+ prompt="""
169
+ <objective>
170
+ Research design alternatives and architecture patterns for: {topic}
171
+ Mode: Design Research
172
+ </objective>
173
+
174
+ <context>
175
+ Project specs: {specs_content or "none"}
176
+ Topic keywords: {extracted_keywords}
177
+ </context>
178
+
179
+ <task>
180
+ Search for:
181
+ 1. Reference projectshow 2-3 similar projects/products solve this problem (architecture, key decisions, what worked)
182
+ 2. Extractable patterns — reusable design patterns distilled from those projects, with applicability notes
183
+ 3. Architecture approaches (at least 2-3 alternatives with trade-offs)
184
+ 4. UX/UI patterns if applicable (interaction models, layout strategies)
185
+ 5. Common design pitfalls and anti-patterns to avoid
186
+
187
+ IMPORTANT: Output MUST include "Reference Projects / Implementations" and "Extractable Patterns" sections.
188
+ Focus on design ROUTES — alternative approaches the brainstorm roles can evaluate.
189
+ Be prescriptive where evidence is strong, present alternatives where trade-offs exist.
190
+ Return structured markdown only — do NOT write files.
191
+ </task>
192
+ """,
193
+ run_in_background=false
194
+ )
195
+
196
+ // Step 1.7.2: Store as designResearchContext (in-memory)
197
+ designResearchContext = agent_output
198
+ ```
199
+
200
+ `designResearchContext` is passed into:
201
+ - Step 2 (Terminology): enriches domain term extraction
202
+ - Step 3 Phase 1 (Topic Analysis): provides external design alternatives
203
+ - Step 4 (Parallel Role Analysis): each role-design-author receives design research as additional context
204
+
205
+ Also persisted to `{output_dir}/design-research.md` for future reference.
206
+
207
+ If research fails (W005): `designResearchContext = null`, continue without external context.
208
+
209
+ ---
210
+
211
+ ### Step 1.8: Load Project Context (if `.workflow/` exists)
212
+
213
+ Load existing project history to ground brainstorming in what's already been built:
214
+
215
+ - From `.workflow/project.md`: `### Validated` → already_shipped, `### Active` → current_scope, `## Context` → project_history
216
+ - From `.workflow/state.json.accumulated_context`: `deferred[]` deferred_items, `key_decisions[]` existing_constraints
217
+
218
+ Pass `project_context` into Step 2 (terminology) and Step 3 (framework generation):
219
+ - `already_shipped` informs what exists — brainstorm should explore extensions, not re-invent
220
+ - `deferred_items` are high-value brainstorming seeds
221
+ - `lessons_learned` surface pitfalls to avoid
222
+
223
+ ---
224
+
225
+ ### Step 2: Terminology & Boundary Definition (Auto Mode)
226
+
227
+ Extract core terminology and define scope boundaries before framework generation.
228
+
229
+ 1. Analyze topic description and any project context (project.md, roadmap.md, project_context from Step 1.8)
230
+ 2. Extract 5-10 core domain terms:
231
+ - term (canonical), definition, aliases, category (core|technical|business)
232
+ 3. AskUserQuestion for Non-Goals (multiSelect=true):
233
+ - Generate 4-5 context-aware exclusion candidates based on topic
234
+ - Include "其他(请补充)" option for custom exclusions
235
+ - If user selects "其他", follow up with free-text question
236
+ 4. Store terminology table and non_goals to session state
237
+
238
+ **Skip if**: `--yes` flag (use auto-generated terms, empty non-goals)
239
+
240
+ ### Step 3: Interactive Framework Generation (Auto Mode)
241
+
242
+ Seven sub-phases producing guidance-specification.md:
243
+
244
+ **Phase 0: Context Collection**
245
+ - Read init outputs directly: `.workflow/project.md` (tech stack, requirements, decisions), `.workflow/state.json` (project state), `.workflow/specs/` (conventions)
246
+ - If `.workflow/` does not exist: continue without project context
247
+
248
+ **Phase 1: Topic Analysis**
249
+ - Load Phase 0 context (tech_stack, modules, conflict_risk)
250
+ - Deep topic analysis (entities, challenges, constraints, metrics)
251
+ - Generate 2-4 context-aware probing questions via AskUserQuestion
252
+ - Questions MUST reference topic keywords (no generic questions)
253
+ - Store to `session.intent_context`
254
+
255
+ **Phase 2: Role Selection**
256
+ - Analyze Phase 1 keywords → recommend count+2 roles with rationale
257
+ - AskUserQuestion (multiSelect=true) for user to select `count` roles
258
+ - If `--yes`: auto-select recommended roles
259
+ - Store to `session.selected_roles`
260
+
261
+ **Phase 3: Role-Specific Questions**
262
+ - FOR each selected role, generate 3-4 deep questions mapping role expertise to Phase 1 challenges
263
+ - AskUserQuestion per role (sequential, one role at a time)
264
+ - Questions must include: implementation depth, trade-offs, edge cases
265
+ - Store to `session.role_decisions[role]`
266
+ - If `--yes`: skip all role questions
267
+
268
+ **Phase 4: Conflict Resolution**
269
+ - Analyze Phase 3 answers for contradictions, missing integrations, implicit dependencies
270
+ - Generate clarification questions referencing SPECIFIC Phase 3 choices
271
+ - AskUserQuestion (max 4 per round)
272
+ - If NO conflicts detected: skip with notification
273
+ - Store to `session.cross_role_decisions`
274
+
275
+ **Phase 4.5: Final Clarification + Feature Decomposition**
276
+ - Ask: "是否有前面未澄清的重点需要补充?" (无需补充 / 需要补充)
277
+ - If "需要补充": progressive questions until resolved
278
+ - Extract candidate features from all Phase 1-4 decisions (max 8)
279
+ - Each feature: F-{3-digit} ID, kebab-case slug, description, related roles, priority
280
+ - Validate: independence, completeness, granularity balance, boundary clarity
281
+ - AskUserQuestion for user to confirm or adjust feature list
282
+ - Store to `session.feature_list`
283
+
284
+ **Phase 5: Generate Specification**
285
+ - Load all decisions + terminology + non_goals + feature_list
286
+ - Transform Q&A to declarative statements (CONFIRMED/SELECTED)
287
+ - Apply RFC 2119 keywords (MUST, SHOULD, MAY, MUST NOT, SHOULD NOT)
288
+ - Write `guidance-specification.md` with sections:
289
+ 1. Project Positioning & Goals
290
+ 2. Concepts & Terminology (table)
291
+ 3. Non-Goals (Out of Scope)
292
+ 4-N. [Role] Decisions (with RFC 2119)
293
+ Cross-Role Integration
294
+ Risks & Constraints
295
+ §10. Feature Decomposition (table)
296
+ §11. Appendix: Decision Tracking
297
+ §12. Cross-Role Resolutions (initially empty — populated by Step 5)
298
+ - Validate: no interrogative sentences, all decisions traceable, RFC keywords applied
299
+
300
+ **Output**: `{output_dir}/guidance-specification.md`, session metadata (workflow-session.json)
301
+
302
+ ### Step 3.5: Visual Style Foundation (Auto Mode, conditional)
303
+
304
+ When `ui-designer` is among the selected roles, establish the project's visual direction before role analysis begins. This ensures all downstream UX analysis works within a confirmed design system.
305
+
306
+ **Condition**: Skip if `.workflow/impeccable/DESIGN.md` already exists (visual direction already locked).
307
+
308
+ **Execution** (sequential):
309
+
310
+ 1. **Product context** if `.workflow/impeccable/PRODUCT.md` missing:
311
+ ```
312
+ Skill({ skill: "maestro-impeccable", args: "teach" })
313
+ ```
314
+ This runs the teach interview to establish brand, users, personality, anti-references.
315
+
316
+ 2. **Visual exploration** multi-style comparison and selection:
317
+ ```
318
+ Skill({ skill: "maestro-impeccable", args: "explore" })
319
+ ```
320
+ This generates multiple design system variants as HTML prototypes, launches visual comparison, and lets the user select/mix. Produces DESIGN.md on completion.
321
+
322
+ 3. Record in session metadata: `design_system_established: true`, `design_md_path: ".workflow/impeccable/DESIGN.md"`
323
+
324
+ **`--yes` mode**: `explore` auto-selects variant 1 without visual comparison. `teach` still requires minimal input if PRODUCT.md is missing.
325
+
326
+ **Skip mode**: If user explicitly passes `--skip-design` to brainstorm, skip this step entirely. ui-designer role will generate its own independent theme in Phase 2.
327
+
328
+ ### Step 4: Parallel Role Analysis (Auto Mode)
329
+
330
+ For EACH selected role, spawn a `role-design-author` agent in parallel. Each agent produces a multi-file analysis under `{output_dir}/{role}/`.
331
+
332
+ ```
333
+ Agent({
334
+ subagent_type: "role-design-author",
335
+ prompt: """
336
+ role_name: {role}
337
+ role_template_path: ~/.maestro/templates/planning-roles/{role}.md
338
+ guidance_path: {output_dir}/guidance-specification.md
339
+ output_dir: {output_dir}/{role}/
340
+ feature_list: <F-id + slug + title rows from guidance §10>
341
+ design_research: {output_dir}/design-research.md if exists, else null
342
+ project_specs: {specs_content or null}
343
+ user_context: {session.role_decisions[role] if any}
344
+ style_skill: {style_skill_path if role == ui-designer and provided}
345
+
346
+ Write the analysis files per the role template's "Brainstorming Analysis Structure".
347
+ Reference guidance decisions by ID (e.g., SA-03) do NOT copy decision text.
348
+ All behavioural statements MUST use RFC 2119 keywords.
349
+ """,
350
+ run_in_background: false
351
+ })
352
+ ```
353
+
354
+ **Output Contract**: each agent writes files under `{output_dir}/{role}/`:
355
+ - `analysis.md` — INDEX document containing §1 Role Mandate, §2 Decision Digest (4 tables), §3 Cross-Cutting Foundations, §4 File Index, §5 Outstanding TODOs
356
+ - `analysis-F-{id}-{slug}.md` one per feature (< 2000 words each)
357
+ - `findings-{slug}.md` — additional discoveries (0 or more, < 1000 words each)
358
+
359
+ See `.claude/agents/role-design-author.md` for the full output contract.
360
+
361
+ **Digest-Based Validation** (orchestrator reads ONLY `analysis.md` per role, not sub-files):
362
+ - Read `{role}/analysis.md` §2 Decision Digest:
363
+ - Decisions table: verify 1 row per feature in feature_list → feature coverage check
364
+ - RFC 2119 keywords in Constraints column → keyword count check
365
+ - Read `{role}/analysis.md` §4 File Index:
366
+ - Verify listed files actually exist on disk (glob check)
367
+ - Verify feature coverage matches feature_list
368
+ - system-architect specifically: verify §3 contains "Data Model" and "State Machine" headings
369
+ - Warn if any analysis-F-*.md > 2000 words (from agent's return protocol `total_lines`)
370
+
371
+ **Parallel Safety**: Each agent writes only to its own `{role}/` directory. No shared output, no cross-agent dependencies.
372
+
373
+ ### Step 4.5: Cross-Role Review (Auto Mode)
374
+
375
+ After all role analyses are produced, spawn ONE `cross-role-reviewer` agent. The agent compares Decision Digests from each role's `analysis.md` — it does NOT read per-feature sub-files unless it needs deeper context.
376
+
377
+ ```
378
+ Agent({
379
+ subagent_type: "cross-role-reviewer",
380
+ prompt: """
381
+ analysis_indexes:
382
+ - {output_dir}/{role_1}/analysis.md
383
+ - {output_dir}/{role_2}/analysis.md
384
+ - ...
385
+ guidance_path: {output_dir}/guidance-specification.md
386
+ feature_list: <F-id + slug + title rows from guidance §10>
387
+
388
+ Compare Decision Digests (§2) across these role analysis index files.
389
+ Identify conflicts, gaps, and synergy opportunities.
390
+ Use §4 File Index for accurate patch target file paths and headings.
391
+ Return the structured report do NOT write files.
392
+ """,
393
+ run_in_background: false
394
+ })
395
+ ```
396
+
397
+ **Agent output** (parsed by orchestrator):
398
+ - `conflicts[]` C-IDs with role-A vs role-B contradictions from §2 Decisions/Positions comparison
399
+ - `gaps[]` G-IDs from §2 Interfaces consumer references without matching definitions
400
+ - `synergies[]` S-IDs from §2 Findings Summary with concrete patch suggestions
401
+ - `need_deeper_context[]` (optional) specific sub-files the reviewer needs to read for ambiguous cases
402
+
403
+ **Deeper context handling**: If the reviewer returns `need_deeper_context` entries, the orchestrator reads those specific files and re-invokes the reviewer via SendMessage with the injected content. Expected to happen in < 10% of reviews.
404
+
405
+ Store as `review_findings` in session memory. Skip Step 5 entirely if all three arrays are empty.
406
+
407
+ If `--yes` flag set: auto-apply each finding's suggested resolution without AskUserQuestion (still proceed to Step 5 writeback).
408
+
409
+ ### Step 5: Apply Cross-Role Resolutions (Auto Mode)
410
+
411
+ Consume `review_findings` from Step 4.5 and apply user-confirmed resolutions to the relevant role analysis files and `guidance-specification.md`.
412
+
413
+ **Sub-phase 5.1: Interactive Confirmation (skip if `--yes`)**
414
+ - For each finding (conflictsgaps → synergies, in that order), call AskUserQuestion (max 4 per round):
415
+ - **Conflict question** options: "Accept suggested resolution" (recommended) / "Pick role A's stance" / "Pick role B's stance" / "Defer to TODO"
416
+ - **Gap question** options: "Accept suggested addition" (recommended) / "Skip this gap" / "Defer to TODO"
417
+ - **Synergy question** options: "Apply patch" (recommended) / "Skip"
418
+ - Question text MUST cite the exact role folder + `target_heading` from the agent output (heading text, not section number).
419
+ - Store user choices as `resolutions[]`.
420
+
421
+ **Sub-phase 5.2: Apply Patches to Role Files**
422
+
423
+ The reviewer's output includes a `patch_targets[]` block per finding with closed-vocabulary `edit_type` (`annotate_after_heading` / `annotate_and_strikeout` / `append_to_section`). The orchestrator consumes these directly — do NOT re-parse the prose.
424
+
425
+ For each accepted finding, iterate over its `patch_targets[]`:
426
+
427
+ **Conflict patches** (edit_type usually `annotate_and_strikeout`):
428
+ - Locate `target_heading` in `target_file` (e.g., `system-architect/analysis-F-002-skill-engine.md`) via Edit string match (heading text MUST match verbatim).
429
+ - Insert `edit_content` (a `> blockquote` Cross-Role Resolution line) immediately after the matched heading.
430
+ - Wrap the original paragraph below the heading in `<!-- superseded by C-XXX -->` … `<!-- /superseded -->` HTML comments so the original text stays readable but downstream tooling treats it as non-authoritative.
431
+ - If the user chose "Pick role A's stance" → strikeout role B's site only; vice versa. If "Accept suggested resolution" → strikeout BOTH role-A and role-B sites (both supersede to the new resolution).
432
+
433
+ **Gap patches** (edit_type pair: `annotate_after_heading` at reference site + `append_to_section` at owner site):
434
+ - At reference site: insert the breadcrumb annotation pointing to the owner site.
435
+ - At owner site: append the actual definition content (1-3 lines from `edit_content`).
436
+ - Both edits MUST succeed; if owner-site append fails, roll back reference-site annotation.
437
+
438
+ **Synergy patches** (edit_type `annotate_after_heading` × 2):
439
+ - Insert cross-reference annotations in BOTH role files. Synergy is symmetric — alignment must be visible from either entry point.
440
+ - Original content untouched.
441
+
442
+ **Edit failure handling**:
443
+ - If `target_heading` does not match verbatim, log the finding ID and target, skip the patch, and surface to the user in Step 7 final report ("3 patches skipped — heading drift").
444
+ - Never invent the heading; refusal to patch is safer than wrong patch.
445
+
446
+ **Sub-phase 5.3: Append to guidance §12**
447
+ Append a new subsection to `guidance-specification.md` §12 Cross-Role Resolutions capturing the audit trail:
448
+ ```markdown
449
+ ### Cross-Role Resolutions (added {date})
450
+ | ID | Type | Source(s) | Resolution | Applied to |
451
+ |---|---|---|---|---|
452
+ | C-001 | conflict | system-architect/analysis-F-002-skill-engine.md "## Architecture" / sme/analysis-F-002-skill-engine.md "## Constraints" | {answer} | both files patched |
453
+ | G-001 | gap | ux-expert/analysis.md "### Interfaces" | {answer} | data-architect/analysis.md "### Decisions" |
454
+ | S-001 | synergy | ux-expert/analysis-F-005-tui.md "## Interface Contract" / sme/findings-ndjson.md "## Recommendation" | applied | both annotated |
455
+ ```
456
+
457
+ **Sub-phase 5.4: Finalization**
458
+ - Update session metadata (`review_findings_count`, `resolutions_applied`, `completion_status`).
459
+ - Emit completion report (see Step 7).
460
+
461
+ ---
462
+
463
+ ### Single Role Mode Steps
464
+
465
+ ### Step 6: Single Role Analysis
466
+
467
+ Execute analysis for ONE specified role with optional interactive context gathering.
468
+
469
+ **Step 6.1: Detection & Validation**
470
+ - Validate role_name against VALID_ROLES list
471
+ - Detect session (--session or find existing)
472
+ - Check for guidance-specification.md framework_mode
473
+ - Extract feature list from guidance §10 feature_mode
474
+ - Check existing `{role}/analysis.md` update_mode (ask: update/regenerate/cancel)
475
+
476
+ **Step 6.2: Interactive Context Gathering**
477
+ - Skip if `--skip-questions`
478
+ - Force if `--include-questions`
479
+ - Generate 3-5 role-specific questions (Chinese, with business context)
480
+ - AskUserQuestion per batch (max 4 per round)
481
+ - Pass collected answers as `user_context` to the agent (in-memory; not persisted to a separate file)
482
+
483
+ **Step 6.3: Agent Execution**
484
+ - Spawn role-design-author with full Inputs block (see Step 4 schema)
485
+ - Agent writes files under `{output_dir}/{role}/`
486
+
487
+ **Step 6.4: Validation**
488
+ - Read `{role}/analysis.md` verify exists and non-empty
489
+ - Check §2 Decision Digest tables present
490
+ - Check §4 File Index matches files on disk
491
+ - Check framework reference if framework_mode
492
+ - Update session metadata with completion status
493
+ - Report results with next step suggestions
494
+
495
+ ---
496
+
497
+ ### Review-Only Mode Steps
498
+
499
+ ### Step 6.5: Review-Only Mode
500
+
501
+ Triggered by `--review-only --session ID`. Skips Phase 3 entirely; runs only Step 4.5 + Step 5 against the existing role analysis files.
502
+
503
+ **Step 6.5.1: Validation**
504
+ - Require `--session ID`. Error E002 if missing.
505
+ - Glob `{output_dir}/*/analysis.md`. Error E006 if zero files found (no role analyses to review).
506
+ - Require `guidance-specification.md` to exist (for decision-ID context). Error E007 if missing.
507
+
508
+ **Step 6.5.2: Execute Step 4.5 + Step 5**
509
+ - Reuse the exact same logic as auto mode Step 4.5 (spawn cross-role-reviewer with analysis indexes) and Step 5 (interactive confirmation + patch application + guidance §12 audit).
510
+ - Skip Step 5.1 interactive confirmation if `--yes` also passed.
511
+
512
+ **Step 6.5.3: Report**
513
+ - Same as review-only mode report in Step 7.
514
+
515
+ ---
516
+
517
+ ### Step 7: Final Report
518
+
519
+ **Auto mode report:**
520
+ - Session ID and output directory
521
+ - Roles analyzed (N) — list each `{role}/analysis.md` path
522
+ - Files written per role (from agent return protocol)
523
+ - Features in scope (N, from guidance §10)
524
+ - Cross-role review: conflicts / gaps / synergies counts
525
+ - Resolutions applied: count + a breakdown by type (C/G/S)
526
+ - Next:
527
+ Skill({ skill: "maestro-roadmap", args: "--mode full --from brainstorm:{artifactId}" }) — Generate full spec package
528
+ Skill({ skill: "maestro-analyze", args: "{topic}" }) — Evaluate feasibility + lock decisions
529
+ Skill({ skill: "maestro-analyze", args: "{phase} -q" }) — Quick decision extraction only
530
+ Skill({ skill: "maestro-plan", args: "{phase}" }) — Plan directly (if scope is clear)
531
+
532
+ **Single role mode report:**
533
+ - Role analyzed
534
+ - Framework alignment status (does analysis reference guidance decisions?)
535
+ - Context questions answered (count)
536
+ - Files written: list from §4 File Index
537
+ - Next:
538
+ - Run more roles: `Skill({ skill: "maestro-brainstorm", args: "{another-role} --session {sessionId}" })`
539
+ - When 2+ roles are done, trigger review: `Skill({ skill: "maestro-brainstorm", args: "--review-only --session {sessionId}" })`
540
+
541
+ **Review-only mode report:**
542
+ - Session ID and existing roles found (N)
543
+ - Cross-role review: conflicts / gaps / synergies counts
544
+ - Resolutions applied: count + breakdown by type (C/G/S)
545
+ - Patches skipped due to heading drift: count (if any)
546
+ - Same Next-step routing as auto mode
547
+
548
+ ---
549
+
550
+ ### Step 7.5: Generate Context Package
551
+
552
+ Write `{output_dir}/context-package.json` by extracting from session artifacts:
553
+
554
+ ```jsonc
555
+ {
556
+ "$schema": "context-package/1.0",
557
+ "source": {
558
+ "type": "brainstorm",
559
+ "artifact_id": "{artifact_id}",
560
+ "session_path": "{output_dir relative to .workflow/}",
561
+ "generated_at": "{ISO-8601}"
562
+ },
563
+ "requirements": [], // From guidance-specification.md §10 Feature Decomposition
564
+ "constraints": [], // From guidance-specification.md §4-N MUST/MUST NOT + {role}/analysis.md §2 Decisions[locked]
565
+ "domain": {}, // From guidance-specification.md §1-3 (problem, terminology, audience)
566
+ "non_goals": [], // From guidance-specification.md Non-Goals section
567
+ "insights": [], // From {role}/analysis.md §3 Cross-Cutting subsections
568
+ "open_questions": [], // From guidance-specification.md §4-N SHOULD/MAY items
569
+ "references": [] // List all key files: guidance-specification.md + {role}/analysis.md per role
570
+ }
571
+ ```
572
+
573
+ **Extraction mapping**:
574
+ - `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" }`
575
+ - `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
576
+ - `domain.problem_statement`: from §1-3
577
+ - `domain.terminology[]`: from Concepts & Terminology section → `{ term, definition, ref: "guidance-specification.md#§5" }`
578
+ - `domain.audience`, `domain.industry`: from §1-3
579
+ - `non_goals[]`: each Non-Goal → `{ title, rationale, ref: "guidance-specification.md#§6" }`
580
+ - `insights[]`: from each `{role}/analysis.md` §3 Cross-Cutting subsections → `{ role, area, summary, ref: "{role}/analysis.md#§3-{heading}" }`
581
+ - `open_questions[]`: from §4-N SHOULD/MAY items → `{ area, question, options[], ref }`
582
+ - `references[]`: `{ type: "guidance", path: "guidance-specification.md" }` + `{ type: "role-analysis", path: "{role}/analysis.md" }` per role
583
+
584
+ Register artifact in state.json with additional field:
585
+ `context_package: "{output_dir}/context-package.json"` (relative to .workflow/)
586
+
587
+ ---
588
+
589
+ ## Quality Criteria
590
+
591
+ - If `designResearchContext` is set: guidance-specification.md references external design findings
592
+ - guidance-specification.md uses RFC 2119 keywords (MUST/SHOULD/MAY)
593
+ - Concepts & Terminology section with 5-10 core terms
594
+ - Non-Goals section with rationale
595
+ - Feature Decomposition table (max 8 features, independently implementable)
596
+ - Each `{role}/analysis.md` contains §2 Decision Digest with all four tables (Decisions, Interfaces, Cross-Cutting Positions, Findings Summary)
597
+ - Each `{role}/analysis.md` §4 File Index accurately lists all written files with headings
598
+ - Each `{role}/analysis-F-*.md` < 2000 words, each `findings-*.md` < 1000 words
599
+ - system-architect's `analysis.md` §3 includes: Data Model, State Machine, Error Handling, Observability
600
+ - Cross-role review runs (Step 4.5) and produces structured findings from §2 Digest comparison with `patch_targets[]` blocks
601
+ - **If review yielded findings**: each accepted resolution is annotated in the affected role analysis file AND logged in guidance §12 "Cross-Role Resolutions"
602
+ - **If review yielded zero findings**: guidance §12 unchanged; final report explicitly notes "No cross-role issues detected"
603
+ - Heading-drift patch failures (if any) are surfaced in the final report, not silently dropped