maestro-flow 0.4.19 → 0.4.21

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 (163) hide show
  1. package/.agents/agents/workflow-collab-planner.md +4 -1
  2. package/.agents/agents/workflow-plan-checker.md +11 -1
  3. package/.agents/agents/workflow-planner.md +4 -1
  4. package/.agents/skills/maestro/SKILL.md +8 -5
  5. package/.agents/skills/maestro-analyze/SKILL.md +1 -1
  6. package/.agents/skills/maestro-brainstorm/SKILL.md +2 -1
  7. package/.agents/skills/maestro-companion/SKILL.md +533 -0
  8. package/.agents/skills/maestro-grill/SKILL.md +116 -0
  9. package/.agents/skills/maestro-plan/SKILL.md +4 -0
  10. package/.agents/skills/maestro-ralph/SKILL.md +11 -7
  11. package/.agents/skills/maestro-ralph-execute/SKILL.md +2 -1
  12. package/.agents/skills/maestro-swarm-workflow/SKILL.md +266 -0
  13. package/.agents/skills/maestro-universal-workflow/SKILL.md +563 -0
  14. package/.agents/skills/manage-codebase-rebuild/SKILL.md +13 -1
  15. package/.agents/skills/manage-codebase-refresh/SKILL.md +3 -0
  16. package/.agents/skills/spec-setup/SKILL.md +9 -5
  17. package/.agents/skills/team-adversarial-swarm/SKILL.md +235 -0
  18. package/.agents/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  19. package/.agents/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  20. package/.agents/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  21. package/.agents/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  22. package/.agents/skills/team-adversarial-swarm/specs/ant-output-schema.md +115 -0
  23. package/.agents/skills/team-adversarial-swarm/specs/convergence-criteria.md +75 -0
  24. package/.agents/skills/team-adversarial-swarm/specs/pheromone-schema.md +90 -0
  25. package/.agents/skills/team-adversarial-swarm/specs/swarm-config-template.json +66 -0
  26. package/.agents/skills/team-adversarial-swarm/specs/swarm-protocol.md +105 -0
  27. package/.agents/skills/team-adversarial-swarm/workflows/wf-swarm-converge.js +197 -0
  28. package/.agents/skills/team-adversarial-swarm/workflows/wf-swarm-explore.js +194 -0
  29. package/.agents/skills/team-adversarial-swarm/workflows/wf-swarm-score.js +188 -0
  30. package/.agents/skills/team-adversarial-swarm/workflows/wf-swarm-synthesize.js +248 -0
  31. package/.agy/agents/workflow-collab-planner.md +4 -1
  32. package/.agy/agents/workflow-plan-checker.md +11 -1
  33. package/.agy/agents/workflow-planner.md +4 -1
  34. package/.agy/skills/maestro/SKILL.md +8 -5
  35. package/.agy/skills/maestro-analyze/SKILL.md +1 -1
  36. package/.agy/skills/maestro-brainstorm/SKILL.md +2 -1
  37. package/.agy/skills/maestro-companion/SKILL.md +529 -0
  38. package/.agy/skills/maestro-grill/SKILL.md +116 -0
  39. package/.agy/skills/maestro-plan/SKILL.md +4 -0
  40. package/.agy/skills/maestro-ralph/SKILL.md +11 -7
  41. package/.agy/skills/maestro-ralph-execute/SKILL.md +2 -1
  42. package/.agy/skills/maestro-swarm-workflow/SKILL.md +263 -0
  43. package/.agy/skills/maestro-universal-workflow/SKILL.md +560 -0
  44. package/.agy/skills/manage-codebase-rebuild/SKILL.md +13 -1
  45. package/.agy/skills/manage-codebase-refresh/SKILL.md +3 -0
  46. package/.agy/skills/spec-setup/SKILL.md +9 -5
  47. package/.agy/skills/team-adversarial-swarm/SKILL.md +244 -0
  48. package/.agy/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  49. package/.agy/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  50. package/.agy/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  51. package/.agy/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  52. package/.agy/skills/team-adversarial-swarm/specs/ant-output-schema.md +115 -0
  53. package/.agy/skills/team-adversarial-swarm/specs/convergence-criteria.md +75 -0
  54. package/.agy/skills/team-adversarial-swarm/specs/pheromone-schema.md +90 -0
  55. package/.agy/skills/team-adversarial-swarm/specs/swarm-config-template.json +66 -0
  56. package/.agy/skills/team-adversarial-swarm/specs/swarm-protocol.md +105 -0
  57. package/.agy/skills/team-adversarial-swarm/workflows/wf-swarm-converge.js +197 -0
  58. package/.agy/skills/team-adversarial-swarm/workflows/wf-swarm-explore.js +194 -0
  59. package/.agy/skills/team-adversarial-swarm/workflows/wf-swarm-score.js +188 -0
  60. package/.agy/skills/team-adversarial-swarm/workflows/wf-swarm-synthesize.js +248 -0
  61. package/.claude/agents/workflow-collab-planner.md +4 -1
  62. package/.claude/agents/workflow-plan-checker.md +11 -1
  63. package/.claude/agents/workflow-planner.md +4 -1
  64. package/.claude/commands/maestro-analyze.md +1 -1
  65. package/.claude/commands/maestro-brainstorm.md +2 -1
  66. package/.claude/commands/maestro-companion.md +531 -0
  67. package/.claude/commands/maestro-grill.md +114 -0
  68. package/.claude/commands/maestro-plan.md +4 -0
  69. package/.claude/commands/maestro-ralph-execute.md +2 -1
  70. package/.claude/commands/maestro-ralph.md +11 -7
  71. package/.claude/commands/maestro-swarm-workflow.md +264 -0
  72. package/.claude/commands/maestro-universal-workflow.md +561 -0
  73. package/.claude/commands/maestro.md +8 -5
  74. package/.claude/commands/manage-codebase-rebuild.md +13 -1
  75. package/.claude/commands/manage-codebase-refresh.md +3 -0
  76. package/.claude/commands/spec-setup.md +9 -5
  77. package/.claude/skills/team-adversarial-swarm/SKILL.md +233 -0
  78. package/.claude/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  79. package/.claude/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  80. package/.claude/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  81. package/.claude/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  82. package/.claude/skills/team-adversarial-swarm/specs/ant-output-schema.md +115 -0
  83. package/.claude/skills/team-adversarial-swarm/specs/convergence-criteria.md +75 -0
  84. package/.claude/skills/team-adversarial-swarm/specs/pheromone-schema.md +90 -0
  85. package/.claude/skills/team-adversarial-swarm/specs/swarm-config-template.json +66 -0
  86. package/.claude/skills/team-adversarial-swarm/specs/swarm-protocol.md +105 -0
  87. package/.claude/skills/team-adversarial-swarm/workflows/wf-swarm-converge.js +197 -0
  88. package/.claude/skills/team-adversarial-swarm/workflows/wf-swarm-explore.js +194 -0
  89. package/.claude/skills/team-adversarial-swarm/workflows/wf-swarm-score.js +188 -0
  90. package/.claude/skills/team-adversarial-swarm/workflows/wf-swarm-synthesize.js +248 -0
  91. package/.codex/skills/maestro/SKILL.md +7 -2
  92. package/.codex/skills/maestro-companion/SKILL.md +485 -0
  93. package/.codex/skills/maestro-grill/SKILL.md +111 -0
  94. package/.codex/skills/maestro-ralph/SKILL.md +11 -7
  95. package/.codex/skills/manage-codebase-rebuild/SKILL.md +6 -0
  96. package/.codex/skills/manage-codebase-refresh/SKILL.md +6 -0
  97. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.d.ts +36 -0
  98. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.js +138 -2
  99. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.js.map +1 -1
  100. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +13 -0
  101. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  102. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +11 -0
  103. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +178 -0
  104. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  105. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +1 -0
  106. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +39 -23
  107. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  108. package/dashboard/dist-server/src/graph/types.d.ts +111 -0
  109. package/dashboard/dist-server/src/graph/types.js +2 -0
  110. package/dashboard/dist-server/src/graph/types.js.map +1 -0
  111. package/dist/src/cli.js +1 -0
  112. package/dist/src/cli.js.map +1 -1
  113. package/dist/src/commands/kg.d.ts +11 -0
  114. package/dist/src/commands/kg.d.ts.map +1 -0
  115. package/dist/src/commands/kg.js +486 -0
  116. package/dist/src/commands/kg.js.map +1 -0
  117. package/dist/src/graph/analyzers/fs-analyzer.d.ts +10 -0
  118. package/dist/src/graph/analyzers/fs-analyzer.d.ts.map +1 -0
  119. package/dist/src/graph/analyzers/fs-analyzer.js +959 -0
  120. package/dist/src/graph/analyzers/fs-analyzer.js.map +1 -0
  121. package/dist/src/graph/index.d.ts +6 -0
  122. package/dist/src/graph/index.d.ts.map +1 -0
  123. package/dist/src/graph/index.js +6 -0
  124. package/dist/src/graph/index.js.map +1 -0
  125. package/dist/src/graph/loader.d.ts +3 -0
  126. package/dist/src/graph/loader.d.ts.map +1 -0
  127. package/dist/src/graph/loader.js +12 -0
  128. package/dist/src/graph/loader.js.map +1 -0
  129. package/dist/src/graph/merger.d.ts +56 -0
  130. package/dist/src/graph/merger.d.ts.map +1 -0
  131. package/dist/src/graph/merger.js +896 -0
  132. package/dist/src/graph/merger.js.map +1 -0
  133. package/dist/src/graph/query.d.ts +7 -0
  134. package/dist/src/graph/query.d.ts.map +1 -0
  135. package/dist/src/graph/query.js +126 -0
  136. package/dist/src/graph/query.js.map +1 -0
  137. package/dist/src/graph/types.d.ts +112 -0
  138. package/dist/src/graph/types.d.ts.map +1 -0
  139. package/dist/src/graph/types.js +2 -0
  140. package/dist/src/graph/types.js.map +1 -0
  141. package/dist/src/tui/install-ui/KgVendorConfig.d.ts +7 -0
  142. package/dist/src/tui/install-ui/KgVendorConfig.d.ts.map +1 -0
  143. package/dist/src/tui/install-ui/KgVendorConfig.js +9 -0
  144. package/dist/src/tui/install-ui/KgVendorConfig.js.map +1 -0
  145. package/dist/src/utils/update-notices.js +23 -0
  146. package/dist/src/utils/update-notices.js.map +1 -1
  147. package/package.json +1 -1
  148. package/workflows/analyze.md +2 -1
  149. package/workflows/brainstorm.md +24 -1
  150. package/workflows/codebase-rebuild.md +141 -1
  151. package/workflows/codebase-refresh.md +20 -0
  152. package/workflows/finish-work.md +7 -2
  153. package/workflows/grill.md +513 -0
  154. package/workflows/plan.md +7 -4
  155. package/workflows/specs-setup.md +99 -3
  156. package/workflows/swarm/wf-analyze.js +347 -0
  157. package/workflows/swarm/wf-brainstorm.js +456 -0
  158. package/workflows/swarm/wf-execute.js +379 -0
  159. package/workflows/swarm/wf-grill.js +359 -0
  160. package/workflows/swarm/wf-milestone-audit.js +385 -0
  161. package/workflows/swarm/wf-plan.js +468 -0
  162. package/workflows/swarm/wf-review.js +341 -0
  163. package/workflows/swarm/wf-verify.js +395 -0
@@ -0,0 +1,513 @@
1
+ # Workflow: Grill
2
+
3
+ Socratic stress-testing of a plan, idea, or requirement against codebase reality. Walks every branch of the decision tree one question at a time, challenges vague terminology against existing code, probes edge cases with concrete scenarios, and produces a verified context package for downstream brainstorm/analyze/roadmap consumption.
4
+
5
+ ## Architecture
6
+
7
+ ```
8
+ ┌──────────────────────────────────────────────────┐
9
+ │ /maestro-grill │
10
+ │ Entry Point + Interactive Routing │
11
+ └───────────────────────┬──────────────────────────┘
12
+
13
+ Step 1: Parse & Route (mode, depth, upstream)
14
+ Step 2: Discovery (docs + codebase scan)
15
+ Step 3: Terminology Alignment (code vs proposal)
16
+ Step 4: Branch Walking (Socratic grilling loop)
17
+ Step 5: Synthesis (report + terminology)
18
+ Step 6: Context Package (context-package.json)
19
+ Step 7: Register Artifact + finish-work
20
+ ```
21
+
22
+ ## Input
23
+
24
+ - `$ARGUMENTS`: topic/plan text, or `--from <source>` for upstream input
25
+ - All output goes to `.workflow/scratch/{YYYYMMDD}-grill-{slug}/`
26
+ - Registers artifact (type=grill) in state.json on completion
27
+ - **Output boundary**: ALL file writes MUST target `{output_dir}/` or `.workflow/state.json` only.
28
+
29
+ ### Parameters
30
+
31
+ | Parameter | Description | Default |
32
+ |-----------|-------------|---------|
33
+ | `--yes`, `-y` | Auto mode — use code exploration instead of human answers | - |
34
+ | `--depth` | Grilling depth: `shallow` (3 branches), `standard` (5), `deep` (8) | `standard` |
35
+ | `--from <source>` | Load upstream material: `blueprint:ID`, `@file`, or path | - |
36
+ | `--session ID` | Resume existing grill session | - |
37
+ | `-c`, `--continue` | Continue from last grill session | - |
38
+
39
+ ### Produced Files
40
+
41
+ | File | Description |
42
+ |------|-------------|
43
+ | `grill-report.md` | Main output — all grilling branches with decisions, evidence, risks |
44
+ | `terminology.md` | Glossary crystallized during grilling, cross-referenced with code |
45
+ | `context-package.json` | Standardized context package for downstream consumption |
46
+
47
+ ---
48
+
49
+ ## Step 1: Parse & Route
50
+
51
+ Parse $ARGUMENTS to determine execution mode:
52
+
53
+ **Mode Detection (ordered by priority)**:
54
+ 1. `-c` / `--continue` → **Resume Mode** (find latest grill session, continue from last branch)
55
+ 2. `--session ID` → **Resume Mode** (specific session)
56
+ 3. `--yes` / `-y` → **Auto Mode** (code exploration replaces human answers)
57
+ 4. Text provided → **Interactive Mode** (default, full Socratic grilling)
58
+ 5. No args → error E001
59
+
60
+ **Parameter Parsing**:
61
+ - `--depth shallow|standard|deep`: branch count 3/5/8, default `standard` (5)
62
+ - `--from <source>`: upstream material to grill against
63
+ - Missing/empty args without `--from` or `--continue` = error E001
64
+
65
+ **Session Detection**:
66
+ - Check `.workflow/scratch/*-grill-*/` for existing sessions
67
+ - Resume: load `grill-report.md` → find last completed branch → continue from next
68
+ - New: create `.workflow/scratch/{YYYYMMDD}-grill-{slug}/`
69
+
70
+ **Output Directory Resolution**:
71
+ ```
72
+ output_dir = .workflow/scratch/{YYYYMMDD}-grill-{slug}/
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Step 2: Discovery
78
+
79
+ Scan project documentation and codebase to build a grilling context. This grounds all subsequent questions in code reality.
80
+
81
+ ### 2.1: Load Project State
82
+
83
+ ```
84
+ 1. Read .workflow/project.md (if exists) → tech_stack, validated_requirements, active_requirements
85
+ 2. Read .workflow/state.json (if exists) → accumulated_context, artifacts[]
86
+ 3. Read .workflow/roadmap.md (if exists) → phase structure
87
+ 4. specs_content = maestro spec load --category arch
88
+ 5. wiki_hits = maestro wiki search "{topic keywords}"
89
+ ```
90
+
91
+ ### 2.2: Load Upstream Material
92
+
93
+ If `--from` specified:
94
+ - `--from blueprint:ID` → `state.json.artifacts[type=blueprint, id=ID]` → load spec package
95
+ - `--from @file` → read file directly as proposal text
96
+ - `--from path/` → read `path/` directory for markdown files
97
+
98
+ Store as `upstream_material` (in-memory).
99
+
100
+ ### 2.3: Codebase Scan
101
+
102
+ Spawn `Agent(subagent_type: Explore)` to map the codebase surface relevant to the topic:
103
+
104
+ ```
105
+ Agent(
106
+ subagent_type="Explore",
107
+ prompt="""
108
+ Search breadth: medium
109
+ Find code relevant to: {topic}
110
+ Report:
111
+ 1. Existing modules/files that overlap with this topic
112
+ 2. Naming conventions used (variable names, function names, types)
113
+ 3. Patterns already established (error handling, data flow, API style)
114
+ 4. Dependencies and integration points
115
+ Return structured findings — file paths, symbol names, pattern descriptions.
116
+ """,
117
+ description="Codebase scan for grill context"
118
+ )
119
+ ```
120
+
121
+ Store as `codebase_context`.
122
+
123
+ If scan fails (W001): `codebase_context = null`, continue without code grounding.
124
+
125
+ ### 2.4: Initialize Report
126
+
127
+ Write `{output_dir}/grill-report.md` with header:
128
+
129
+ ```markdown
130
+ # Grill Report: {topic}
131
+
132
+ **Session**: {session_id}
133
+ **Depth**: {depth} ({branch_count} branches)
134
+ **Date**: {ISO-8601}
135
+ **Upstream**: {source or "none"}
136
+
137
+ ## Discovery Summary
138
+
139
+ ### Project Context
140
+ {summary from Step 2.1}
141
+
142
+ ### Codebase Surface
143
+ {summary from Step 2.3}
144
+
145
+ ### Upstream Material
146
+ {summary from Step 2.2 or "N/A"}
147
+
148
+ ---
149
+
150
+ ## Branch Log
151
+
152
+ | # | Branch | Status | Decisions | Open Questions |
153
+ |---|--------|--------|-----------|----------------|
154
+
155
+ ---
156
+ ```
157
+
158
+ ---
159
+
160
+ ## Step 3: Terminology Alignment
161
+
162
+ Extract terminology from the proposal/topic and cross-reference with codebase naming.
163
+
164
+ ### 3.1: Extract Candidate Terms
165
+
166
+ From topic text + upstream material, identify 5-15 candidate domain terms:
167
+ - Nouns that appear as entities, concepts, or roles
168
+ - Verbs that describe key operations
169
+ - Adjectives that qualify system properties
170
+
171
+ ### 3.2: Code Name Collision Check
172
+
173
+ For each candidate term, search the codebase:
174
+ ```
175
+ Grep(pattern="{term}", output_mode="files_with_matches")
176
+ ```
177
+
178
+ Build a collision table:
179
+
180
+ | Proposed Term | Code Usage | Conflict? | Resolution |
181
+ |---------------|------------|-----------|------------|
182
+ | "account" | `UserAccount` class (auth module) | Yes — ambiguous | Propose: "Organization" for billing, "UserAccount" for auth |
183
+
184
+ ### 3.3: Challenge Vague Terms
185
+
186
+ For each term with conflict or ambiguity, challenge the user via AskUserQuestion:
187
+
188
+ ```
189
+ AskUserQuestion({
190
+ questions: [{
191
+ question: "You said '{term}' — but the codebase uses '{code_name}' for {code_meaning}. Which do you mean?",
192
+ header: "Terminology",
193
+ options: [
194
+ { label: "Use '{code_name}'", description: "Align with existing codebase naming" },
195
+ { label: "New term: '{proposed}'", description: "Introduce new concept distinct from {code_name}" },
196
+ { label: "Rename existing", description: "The existing code should adopt the new term" }
197
+ ],
198
+ multiSelect: false
199
+ }]
200
+ })
201
+ ```
202
+
203
+ **Auto mode (`-y`)**: Use CLI exploration to resolve — prefer existing code naming unless semantically wrong.
204
+
205
+ ### 3.4: Write Terminology File
206
+
207
+ Write `{output_dir}/terminology.md`:
208
+
209
+ ```markdown
210
+ # Terminology
211
+
212
+ | Term | Definition | Code Reference | Status |
213
+ |------|------------|----------------|--------|
214
+ | {term} | {definition} | `{file:symbol}` or "new" | locked/open |
215
+ ```
216
+
217
+ ---
218
+
219
+ ## Step 4: Branch Walking (Core Grilling Loop)
220
+
221
+ The heart of the grill. Walk the decision tree one branch at a time, one question per turn. Each branch is fully explored before moving to the next.
222
+
223
+ ### Branch Categories
224
+
225
+ Select branches based on `--depth`:
226
+
227
+ | Priority | Branch | Shallow | Standard | Deep |
228
+ |----------|--------|---------|----------|------|
229
+ | 1 | Scope & Boundaries | ✓ | ✓ | ✓ |
230
+ | 2 | Data Model & State | ✓ | ✓ | ✓ |
231
+ | 3 | Edge Cases & Failure Modes | ✓ | ✓ | ✓ |
232
+ | 4 | Integration & Dependencies | | ✓ | ✓ |
233
+ | 5 | Scale & Performance | | ✓ | ✓ |
234
+ | 6 | Security & Access Control | | | ✓ |
235
+ | 7 | Observability & Operations | | | ✓ |
236
+ | 8 | Migration & Rollback | | | ✓ |
237
+
238
+ ### Branch Walking Protocol
239
+
240
+ For EACH selected branch:
241
+
242
+ **4.1: Open the Branch**
243
+
244
+ Append to `grill-report.md`:
245
+ ```markdown
246
+ ## Branch {N}: {branch_name}
247
+
248
+ **Status**: 🔴 In Progress
249
+ **Questions asked**: 0
250
+ **Decisions locked**: 0
251
+ ```
252
+
253
+ **4.2: Generate Probing Questions**
254
+
255
+ Based on the topic + codebase_context + terminology + prior branch decisions, generate 3-5 probing questions for this branch. Questions MUST:
256
+ - Reference specific code findings from Step 2.3 when available
257
+ - Use concrete scenarios, not abstract hypotheticals
258
+ - Challenge assumptions ("You said X, but the code shows Y — how do you reconcile?")
259
+ - Escalate from basic to adversarial
260
+
261
+ Question generation pattern per branch:
262
+
263
+ **Scope & Boundaries**:
264
+ - "What is the smallest version of this that delivers value?"
265
+ - "You mentioned {feature} — does it need {sub-feature}, or is that a separate concern?"
266
+ - "The codebase already has {existing_module} — where does your proposal's boundary end and {existing_module} begin?"
267
+
268
+ **Data Model & State**:
269
+ - "What are the core entities? Walk me through their lifecycle."
270
+ - "The code uses {existing_model} — does your {proposed_entity} extend it, replace it, or coexist?"
271
+ - "What happens to {entity} when {related_entity} is deleted?"
272
+
273
+ **Edge Cases & Failure Modes**:
274
+ - "What happens when {operation} is called with {extreme_input}?"
275
+ - "If {dependency} is unavailable, what does the user see?"
276
+ - "Two users do {action} simultaneously — what wins?"
277
+
278
+ **Integration & Dependencies**:
279
+ - "Which existing modules does this touch? Show me the call chain."
280
+ - "What contract does this establish with {consumer}? What can they NOT assume?"
281
+ - "If {upstream_service} changes its API, how much of this breaks?"
282
+
283
+ **Scale & Performance**:
284
+ - "At 10x current load, which part breaks first?"
285
+ - "This query touches {table} — how many rows at steady state? At peak?"
286
+ - "What's the cache invalidation strategy? What goes stale?"
287
+
288
+ **Security & Access Control**:
289
+ - "Who can perform {action}? Who explicitly cannot?"
290
+ - "What happens if an authenticated user sends a crafted {input}?"
291
+ - "Where does PII flow? Where is it stored? Who can access it?"
292
+
293
+ **Observability & Operations**:
294
+ - "How do you know this is working correctly in production?"
295
+ - "What alert fires first when this breaks? What's the runbook?"
296
+ - "How do you debug a user report of '{symptom}'?"
297
+
298
+ **Migration & Rollback**:
299
+ - "How do you deploy this without downtime?"
300
+ - "If this fails in production, what's the rollback procedure?"
301
+ - "What data migration is needed? Is it reversible?"
302
+
303
+ **4.3: Ask One Question at a Time**
304
+
305
+ For each question in the branch:
306
+
307
+ ```
308
+ AskUserQuestion({
309
+ questions: [{
310
+ question: "{probing_question}",
311
+ header: "{branch_name}",
312
+ options: [
313
+ { label: "{option_a}", description: "{implication_a}" },
314
+ { label: "{option_b}", description: "{implication_b}" },
315
+ { label: "Not applicable", description: "This concern doesn't apply to this proposal" }
316
+ ],
317
+ multiSelect: false
318
+ }]
319
+ })
320
+ ```
321
+
322
+ **Auto mode**: Instead of asking the user, use code exploration to answer:
323
+ ```
324
+ maestro delegate "PURPOSE: Answer '{question}' for the proposal '{topic}'
325
+ TASK: Search codebase for evidence | Analyze existing patterns | Determine most likely answer
326
+ MODE: analysis
327
+ CONTEXT: @**/* | Proposal: {topic_summary}
328
+ EXPECTED: Direct answer with code evidence (file:line references)
329
+ CONSTRAINTS: Answer based on code evidence only, flag uncertainty" --role analyze --mode analysis
330
+ ```
331
+
332
+ **4.4: Validate Answer Against Code**
333
+
334
+ After each answer, verify against codebase when possible:
335
+ - If user says "We'll use X pattern" → Grep for existing X usage, confirm consistency
336
+ - If user says "This won't affect Y" → Explore call chains to verify isolation
337
+ - If contradiction found → immediately challenge:
338
+
339
+ ```
340
+ "You said {answer}, but I found {code_evidence} at {file:line}.
341
+ This suggests {contradiction}. How do you reconcile?"
342
+ ```
343
+
344
+ **4.5: Record Decision**
345
+
346
+ After each question is settled, immediately append to `grill-report.md`:
347
+
348
+ ```markdown
349
+ ### Q{N}.{M}: {question_summary}
350
+
351
+ **Answer**: {user_answer_or_auto_answer}
352
+ **Evidence**: {code_references_or_reasoning}
353
+ **Decision**: {locked|open|deferred}
354
+ **Constraint**: {if locked, the RFC 2119 statement — e.g., "MUST use event sourcing for audit trail"}
355
+ ```
356
+
357
+ Update the branch header: increment questions/decisions counts.
358
+
359
+ **4.6: Branch Completion**
360
+
361
+ When all questions in a branch are asked (or user signals "enough"):
362
+ - Update branch status to ✅ Completed
363
+ - Update Branch Log table in report header
364
+ - Move to next branch
365
+
366
+ ---
367
+
368
+ ## Step 5: Synthesis
369
+
370
+ After all branches are walked (or max rounds reached):
371
+
372
+ ### 5.1: Decision Summary
373
+
374
+ Read all branch decisions from `grill-report.md`. Classify:
375
+
376
+ | Classification | Criteria | Downstream Use |
377
+ |----------------|----------|----------------|
378
+ | **Locked** | User confirmed + code-verified | → `constraints[]` in context-package |
379
+ | **Open** | User answered but unverified or uncertain | → `open_questions[]` in context-package |
380
+ | **Deferred** | Explicitly postponed or "not applicable" | → `non_goals[]` or future work |
381
+
382
+ ### 5.2: Risk Register
383
+
384
+ Extract unresolved tensions, contradictions found during grilling, and branches not fully explored:
385
+
386
+ ```markdown
387
+ ## Risk Register
388
+
389
+ | # | Risk | Branch | Severity | Mitigation |
390
+ |---|------|--------|----------|------------|
391
+ ```
392
+
393
+ ### 5.3: Finalize Report
394
+
395
+ Append to `grill-report.md`:
396
+
397
+ ```markdown
398
+ ## Synthesis
399
+
400
+ ### Decision Summary
401
+ | # | Decision | Status | Branch | RFC 2119 |
402
+ |---|----------|--------|--------|----------|
403
+
404
+ ### Verified Constraints
405
+ {locked decisions with code evidence}
406
+
407
+ ### Open Questions
408
+ {decisions needing further exploration}
409
+
410
+ ### Risk Register
411
+ {from 5.2}
412
+
413
+ ### Recommended Next Step
414
+ {routing based on findings}
415
+ ```
416
+
417
+ ### 5.4: Finalize Terminology
418
+
419
+ Update `{output_dir}/terminology.md` — mark all terms as locked/open based on grilling outcomes. Add any new terms surfaced during branch walking.
420
+
421
+ ---
422
+
423
+ ## Step 6: Generate Context Package
424
+
425
+ Write `{output_dir}/context-package.json`:
426
+
427
+ ```jsonc
428
+ {
429
+ "$schema": "context-package/1.0",
430
+ "source": {
431
+ "type": "grill",
432
+ "artifact_id": "{artifact_id}",
433
+ "session_path": "{output_dir relative to .workflow/}",
434
+ "generated_at": "{ISO-8601}"
435
+ },
436
+ "requirements": [],
437
+ "constraints": [],
438
+ "domain": {
439
+ "problem_statement": "",
440
+ "terminology": [],
441
+ "audience": "",
442
+ "industry": ""
443
+ },
444
+ "non_goals": [],
445
+ "insights": [],
446
+ "open_questions": [],
447
+ "references": []
448
+ }
449
+ ```
450
+
451
+ **Extraction mapping**:
452
+ - `requirements[]`: locked scope decisions from Branch 1 → `{ id: "R-{NNN}", title, description, priority: "must|should|may", ref: "grill-report.md#Branch-1" }`
453
+ - `constraints[]`: all locked decisions with RFC 2119 keywords → `{ id: "C-{NNN}", area, constraint, rationale, status: "locked", ref: "grill-report.md#Q{N}.{M}" }`
454
+ - `domain.problem_statement`: from topic + synthesis
455
+ - `domain.terminology[]`: from `terminology.md` → `{ term, definition, code_ref, status: "locked|open" }`
456
+ - `non_goals[]`: deferred decisions + explicit exclusions → `{ title, rationale, ref }`
457
+ - `insights[]`: code findings that contradicted or enriched the proposal → `{ area, summary, evidence, ref }`
458
+ - `open_questions[]`: open decisions needing brainstorm/analyze exploration → `{ area, question, options[], ref }`
459
+ - `references[]`: `{ type: "grill-report", path: "grill-report.md" }`, `{ type: "terminology", path: "terminology.md" }`
460
+
461
+ ---
462
+
463
+ ## Step 7: Register Artifact
464
+
465
+ ### 7.1: Register in state.json
466
+
467
+ ```jsonc
468
+ {
469
+ "id": "GRL-{NNN}",
470
+ "type": "grill",
471
+ "scope": "standalone",
472
+ "path": "{output_dir relative to .workflow/}",
473
+ "status": "completed",
474
+ "context_package": "{output_dir}/context-package.json",
475
+ "created_at": "{ISO-8601}",
476
+ "metadata": {
477
+ "topic": "{topic}",
478
+ "depth": "{depth}",
479
+ "branches_completed": {N},
480
+ "decisions_locked": {N},
481
+ "decisions_open": {N},
482
+ "terms_defined": {N}
483
+ }
484
+ }
485
+ ```
486
+
487
+ ### 7.2: Completion Report
488
+
489
+ ```
490
+ Grill session {artifact_id} completed.
491
+ - Branches walked: {N}/{total}
492
+ - Decisions locked: {N}
493
+ - Open questions: {N}
494
+ - Terms defined: {N}
495
+ - Risk items: {N}
496
+
497
+ Next steps:
498
+ /maestro-brainstorm "{topic}" --from grill:{artifact_id} — Multi-role brainstorm with grilled context
499
+ /maestro-analyze "{topic}" --from grill:{artifact_id} — Deep analysis with grilled constraints
500
+ /maestro-roadmap --from grill:{artifact_id} — Direct to roadmap (if scope is clear)
501
+ ```
502
+
503
+ ---
504
+
505
+ ## Quality Criteria
506
+
507
+ - grill-report.md has at least `{depth_branch_count}` completed branches
508
+ - Each branch has ≥ 2 question-answer pairs with evidence
509
+ - terminology.md has ≥ 5 terms with code references where applicable
510
+ - context-package.json passes schema validation (all required fields present)
511
+ - No locked decision lacks evidence (code reference or explicit user confirmation)
512
+ - Risk register captures all unresolved contradictions found during grilling
513
+ - Branch Log table in report header is fully populated with final status
package/workflows/plan.md CHANGED
@@ -231,11 +231,14 @@ When `--tdd` is active:
231
231
 
232
232
  **Purpose:** Generate the execution plan.
233
233
 
234
- **Rule:** Main flow MUST NOT create/modify TASK files. All planning delegated to planner agent. Upstream analyze results (conclusions.json / implementation_scope) MUST be passed into planner spawn as `explorationContext` in the same step.
234
+ **Rules:**
235
+ - Main flow **MUST** spawn a planner agent (Agent tool) for P3 — inline planning is FORBIDDEN
236
+ - Agent produces both `plan.json` and `.task/TASK-{NNN}.json` — main flow MUST NOT create/modify these files
237
+ - Upstream analyze results (conclusions.json / implementation_scope) MUST be passed into planner spawn as `explorationContext` in the same step
235
238
 
236
239
  ### Standard Mode (default)
237
240
 
238
- Spawn `workflow-planner` agent with: context.md, spec-ref, doc-index.json, explorationContext (incl. implementationScope from P1 Step 5), clarificationContext, phase goal + success_criteria, templates (plan.json, task.json).
241
+ MUST spawn `workflow-planner` agent with: context.md, spec-ref, doc-index.json, explorationContext (incl. implementationScope from P1 Step 5), clarificationContext, phase goal + success_criteria, templates (plan.json, task.json).
239
242
 
240
243
  **Task count guard**: Before spawning, assess scope complexity:
241
244
  - Single feature / simple change → expect **1-2 tasks** max
@@ -293,12 +296,12 @@ Every TASK-*.json MUST include these fields — they are NOT optional:
293
296
 
294
297
  - Pre-allocate TASK ID ranges per planner (2-5 planners based on scope): TASK-001..010, TASK-011..020, etc.
295
298
  - Create `plan-note.md` for coordination (shared context, ID ranges, no-overlap rules)
296
- - Spawn N `workflow-collab-planner` agents in parallel, each writing `.task/TASK-{NNN}.json` within assigned range
299
+ - MUST spawn N `workflow-collab-planner` agents in parallel, each writing `.task/TASK-{NNN}.json` within assigned range
297
300
  - Merge: collect all task files, build unified plan.json with merged waves, resolve cross-planner dependencies
298
301
 
299
302
  ### Gap Mode (`--gaps`)
300
303
 
301
- Spawn `workflow-planner` agent with: explorationContext (gap list from P1 Step 7), spec-ref, doc-index.json, phase goal + success_criteria, templates, mode = `gap-fix`.
304
+ MUST spawn `workflow-planner` agent with: explorationContext (gap list from P1 Step 7), spec-ref, doc-index.json, phase goal + success_criteria, templates, mode = `gap-fix`.
302
305
 
303
306
  Planner: for each gap emit one task — `type: "fix"`, `description`, `action` (concrete fix_direction), `read_first` (affected files), `convergence.criteria` (grep-verifiable), `issue_id` (if source == "issue"); assign IDs and waves; build plan.json.
304
307
 
@@ -209,10 +209,106 @@ Auto-generated from project analysis. Update manually as patterns evolve.
209
209
 
210
210
  These are NOT created during setup. They are created on demand when `spec-add debug` or `spec-add review` is first used.
211
211
 
212
- ### Step 6: Summary
212
+ ### Step 6: Generate Workflow Knowhow Recipes (when signals detected)
213
213
 
214
- Display list of created files with categories. Note that `debug-notes.md` and `review-standards.md` are created on demand via `/spec-add`.
214
+ Spec files in Step 4-5 capture *conventions*. This step captures *operational workflows* — "how to do X in this project" — as **recipe-type knowhow** so future agents can discover them via `maestro wiki search` and `maestro knowhow list --type recipe`.
215
+
216
+ Output directory: `.workflow/knowhow/` (knowhow store, NOT `.workflow/specs/`).
217
+ Schema: matches `recipe` type defined in `~/.maestro/workflows/knowhow.md` Part B.
218
+
219
+ **Detection → recipe matrix:**
220
+
221
+ | Recipe slug | Trigger signals | Step extraction source |
222
+ |-------------|----------------|------------------------|
223
+ | `test-workflow` | Test framework detected in Step 5b (jest/vitest/pytest/mocha/go test/cargo test) | `package.json` `scripts.test*`, `pytest.ini`/`pyproject.toml [tool.pytest]`, `go test ./...`, test layout from Step 5b |
224
+ | `debug-workflow` | `.vscode/launch.json` OR logging lib import (pino/winston/loguru/zap/log) OR error tracker SDK (sentry/bugsnag/rollbar) OR `DEBUG=` env usage in code | launch.json entries, `--inspect` flags in scripts, logger config files, observed `log.debug(...)` / `logger.info(...)` patterns |
225
+ | `build-workflow` | `scripts.build` in package.json OR Makefile `build:` target OR `cargo build` OR `gradle build` OR `go build` | Verbatim script chain; multi-step pipelines noted explicitly |
226
+ | `dev-workflow` | `scripts.dev`/`scripts.start` OR `manage.py runserver` OR `air`/`reflex` config OR docker-compose dev override | Dev command + detected port from config + hot-reload flag |
227
+ | `lint-workflow` | Linter+formatter pair detected: eslint+prettier / ruff+black / golangci-lint+gofmt / rustfmt+clippy | Configured commands, pre-commit hooks from `.pre-commit-config.yaml` or `husky/`, CI lint job |
228
+
229
+ **Skip rule:** If signals are missing, skip the recipe — do NOT generate placeholders.
230
+
231
+ **Idempotency rule:** Before writing, glob `.workflow/knowhow/RCP-*-{slug}.md`. If a file matching the slug exists, do NOT overwrite — write `.workflow/knowhow/RCP-{YYYYMMDD-HHMM}-{slug}.proposed.md` instead and mention it in Step 7 summary so the user can diff and merge manually.
232
+
233
+ **Filename:** `.workflow/knowhow/RCP-{YYYYMMDD-HHMM}-{slug}.md` (timestamp aligns with rest of knowhow store, slug disambiguates).
234
+
235
+ **Tags rule:** Match content language (English codebase → English tags). Always include `workflow`, the slug, and the detected framework (e.g. `vitest`, `pytest`). Add `auto-generated` so users can identify spec-setup output for later pruning.
236
+
237
+ **Recipe template** (one file per detected workflow):
238
+
239
+ ```markdown
240
+ ---
241
+ title: "{Project name} — {Workflow name}"
242
+ type: recipe
243
+ tags: [workflow, {slug}, {framework}, auto-generated]
244
+ created: {ISO timestamp}
245
+ source: spec-setup
246
+ ---
247
+
248
+ # {title}
249
+
250
+ ## Goal
251
+ {One sentence stating the operational outcome — "Run the test suite locally and in CI", "Reproduce and inspect a runtime bug with full stack context", etc.}
252
+
253
+ ## Prerequisites
254
+ - {Required runtime/version from manifest, e.g. "Node.js >= 18"}
255
+ - {Required env vars detected in .env.example or code}
256
+ - {Required services if docker-compose detected}
257
+
258
+ ## Steps
259
+ 1. {Copy-paste-ready command 1 — derived from detected scripts}
260
+ 2. {Command 2}
261
+ 3. ...
262
+
263
+ ## Expected Outcome
264
+ {Concrete success signal — "All tests green, coverage report at coverage/index.html" / "Dev server reachable at http://localhost:PORT with HMR active"}
265
+
266
+ ## Common Pitfalls
267
+ - {Inferred from detected patterns — e.g. "Vitest watch mode locks DB if integration suite is selected"}
268
+ - {Generic gotchas: port conflicts, missing env, stale dist/}
269
+
270
+ ## Related
271
+ - [[test-conventions]] / [[architecture-constraints]] — convention specs (link when they exist)
272
+ ```
273
+
274
+ **Per-recipe extraction guides:**
275
+
276
+ - **`test-workflow`** — Steps must list: (a) install command if first run, (b) full-suite command, (c) watch/filter command, (d) coverage command. For pytest, include marker selection if `pytest.ini` declares markers. For Go, document `-race` and `-tags` flags if used in CI.
277
+ - **`debug-workflow`** — Steps must cover: (a) attach/launch via debugger (cite the exact `launch.json` configuration name), (b) increase log verbosity (cite the env var or config flag actually used in code), (c) reproduce-and-capture pattern (point at the project's logging entry pattern with one file:line example). Mention error-tracker DSN env if Sentry/Bugsnag SDK is wired.
278
+ - **`build-workflow`** — Reproduce the `scripts.build` chain verbatim; if it spans multiple commands, number them. Note the output directory (`dist/`, `build/`, `target/`) and any required `prepublishOnly`/`postbuild` side effects.
279
+ - **`dev-workflow`** — Dev server command, detected default port, hot-reload flag, and any companion process (e.g. `npm run dev` + `npm run mcp` if both are typically run together — detect this when both appear under `scripts` and one is `dev`).
280
+ - **`lint-workflow`** — Linter command, formatter command, fix command (`--fix` / `--write`), pre-commit hook trigger if `husky/_/pre-commit` or `.pre-commit-config.yaml` exists.
281
+
282
+ **Quality bar:** Every generated recipe must contain at least one runnable command. If signals are present but no concrete command can be extracted with confidence, do NOT write the file — emit `W002: <slug> signals detected but commands ambiguous, skipped` and continue.
283
+
284
+ **Wiki indexing:** Files in `.workflow/knowhow/` are auto-indexed by WikiIndexer (`type=knowhow`). No separate index step required — they appear in `maestro wiki list --type knowhow` after the next index pass.
285
+
286
+ ### Step 7: Summary
287
+
288
+ Display list of all created files grouped by destination:
289
+
290
+ ```
291
+ ## Specs (.workflow/specs/)
292
+ - coding-conventions.md
293
+ - architecture-constraints.md
294
+ - learnings.md
295
+ - {optional spec files created}
296
+
297
+ ## Workflow Recipes (.workflow/knowhow/)
298
+ - RCP-{ts}-test-workflow.md (vitest detected)
299
+ - RCP-{ts}-debug-workflow.md (pino + .vscode/launch.json detected)
300
+ - {other recipes}
301
+
302
+ ## Skipped (signals missing)
303
+ - build-workflow — no build script detected
304
+ - {other skips}
305
+
306
+ ## Deferred (created on demand)
307
+ - debug-notes.md, review-standards.md — use /spec-add when needed
308
+ ```
309
+
310
+ Note that `debug-notes.md` and `review-standards.md` are created on demand via `/spec-add`, and any `.proposed.md` files indicate an existing recipe was not overwritten — review and merge manually.
215
311
 
216
312
  ## Output
217
313
 
218
- All files listed above under `.workflow/`.
314
+ All files listed above under `.workflow/specs/` and `.workflow/knowhow/`.