maestro-flow 0.4.18 → 0.4.20

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 (181) 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-next/SKILL.md +147 -112
  10. package/.agents/skills/maestro-plan/SKILL.md +4 -0
  11. package/.agents/skills/maestro-ralph/SKILL.md +11 -7
  12. package/.agents/skills/maestro-swarm-workflow/SKILL.md +258 -0
  13. package/.agents/skills/manage-codebase-rebuild/SKILL.md +13 -1
  14. package/.agents/skills/manage-codebase-refresh/SKILL.md +3 -0
  15. package/.agents/skills/spec-setup/SKILL.md +9 -5
  16. package/.agents/skills/team-swarm/SKILL.md +180 -0
  17. package/.agents/skills/team-swarm/roles/analyst/role.md +187 -0
  18. package/.agents/skills/team-swarm/roles/ant/role.md +169 -0
  19. package/.agents/skills/team-swarm/roles/coordinator/commands/converge.md +146 -0
  20. package/.agents/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  21. package/.agents/skills/team-swarm/roles/coordinator/commands/iterate.md +232 -0
  22. package/.agents/skills/team-swarm/roles/coordinator/role.md +211 -0
  23. package/.agents/skills/team-swarm/roles/scorer/role.md +157 -0
  24. package/.agents/skills/team-swarm/scripts/aco.py +473 -0
  25. package/.agents/skills/team-swarm/scripts/pheromone.py +144 -0
  26. package/.agents/skills/team-swarm/scripts/scoring.py +92 -0
  27. package/.agents/skills/team-swarm/scripts/test_aco.py +475 -0
  28. package/.agents/skills/team-swarm/specs/ant-output-schema.md +119 -0
  29. package/.agents/skills/team-swarm/specs/convergence-criteria.md +106 -0
  30. package/.agents/skills/team-swarm/specs/pheromone-schema.md +123 -0
  31. package/.agents/skills/team-swarm/specs/swarm-config-template.json +71 -0
  32. package/.agents/skills/team-swarm/specs/swarm-protocol.md +117 -0
  33. package/.agy/agents/workflow-collab-planner.md +4 -1
  34. package/.agy/agents/workflow-plan-checker.md +11 -1
  35. package/.agy/agents/workflow-planner.md +4 -1
  36. package/.agy/skills/maestro/SKILL.md +8 -5
  37. package/.agy/skills/maestro-analyze/SKILL.md +1 -1
  38. package/.agy/skills/maestro-brainstorm/SKILL.md +2 -1
  39. package/.agy/skills/maestro-companion/SKILL.md +529 -0
  40. package/.agy/skills/maestro-grill/SKILL.md +116 -0
  41. package/.agy/skills/maestro-next/SKILL.md +147 -112
  42. package/.agy/skills/maestro-plan/SKILL.md +4 -0
  43. package/.agy/skills/maestro-ralph/SKILL.md +11 -7
  44. package/.agy/skills/maestro-swarm-workflow/SKILL.md +255 -0
  45. package/.agy/skills/manage-codebase-rebuild/SKILL.md +13 -1
  46. package/.agy/skills/manage-codebase-refresh/SKILL.md +3 -0
  47. package/.agy/skills/spec-setup/SKILL.md +9 -5
  48. package/.agy/skills/team-swarm/SKILL.md +176 -0
  49. package/.agy/skills/team-swarm/roles/analyst/role.md +183 -0
  50. package/.agy/skills/team-swarm/roles/ant/role.md +165 -0
  51. package/.agy/skills/team-swarm/roles/coordinator/commands/converge.md +134 -0
  52. package/.agy/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  53. package/.agy/skills/team-swarm/roles/coordinator/commands/iterate.md +202 -0
  54. package/.agy/skills/team-swarm/roles/coordinator/role.md +209 -0
  55. package/.agy/skills/team-swarm/roles/scorer/role.md +153 -0
  56. package/.agy/skills/team-swarm/scripts/aco.py +473 -0
  57. package/.agy/skills/team-swarm/scripts/pheromone.py +144 -0
  58. package/.agy/skills/team-swarm/scripts/scoring.py +92 -0
  59. package/.agy/skills/team-swarm/scripts/test_aco.py +475 -0
  60. package/.agy/skills/team-swarm/specs/ant-output-schema.md +119 -0
  61. package/.agy/skills/team-swarm/specs/convergence-criteria.md +106 -0
  62. package/.agy/skills/team-swarm/specs/pheromone-schema.md +123 -0
  63. package/.agy/skills/team-swarm/specs/swarm-config-template.json +71 -0
  64. package/.agy/skills/team-swarm/specs/swarm-protocol.md +117 -0
  65. package/.claude/agents/workflow-collab-planner.md +4 -1
  66. package/.claude/agents/workflow-plan-checker.md +11 -1
  67. package/.claude/agents/workflow-planner.md +4 -1
  68. package/.claude/commands/maestro-analyze.md +1 -1
  69. package/.claude/commands/maestro-brainstorm.md +2 -1
  70. package/.claude/commands/maestro-companion.md +531 -0
  71. package/.claude/commands/maestro-grill.md +114 -0
  72. package/.claude/commands/maestro-next.md +147 -112
  73. package/.claude/commands/maestro-plan.md +4 -0
  74. package/.claude/commands/maestro-ralph.md +11 -7
  75. package/.claude/commands/maestro-swarm-workflow.md +256 -0
  76. package/.claude/commands/maestro.md +8 -5
  77. package/.claude/commands/manage-codebase-rebuild.md +13 -1
  78. package/.claude/commands/manage-codebase-refresh.md +3 -0
  79. package/.claude/commands/spec-setup.md +9 -5
  80. package/.claude/skills/team-swarm/SKILL.md +178 -0
  81. package/.claude/skills/team-swarm/roles/analyst/role.md +185 -0
  82. package/.claude/skills/team-swarm/roles/ant/role.md +167 -0
  83. package/.claude/skills/team-swarm/roles/coordinator/commands/converge.md +146 -0
  84. package/.claude/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  85. package/.claude/skills/team-swarm/roles/coordinator/commands/iterate.md +232 -0
  86. package/.claude/skills/team-swarm/roles/coordinator/role.md +209 -0
  87. package/.claude/skills/team-swarm/roles/scorer/role.md +155 -0
  88. package/.claude/skills/team-swarm/scripts/aco.py +473 -0
  89. package/.claude/skills/team-swarm/scripts/pheromone.py +144 -0
  90. package/.claude/skills/team-swarm/scripts/scoring.py +92 -0
  91. package/.claude/skills/team-swarm/scripts/test_aco.py +475 -0
  92. package/.claude/skills/team-swarm/specs/ant-output-schema.md +119 -0
  93. package/.claude/skills/team-swarm/specs/convergence-criteria.md +106 -0
  94. package/.claude/skills/team-swarm/specs/pheromone-schema.md +123 -0
  95. package/.claude/skills/team-swarm/specs/swarm-config-template.json +71 -0
  96. package/.claude/skills/team-swarm/specs/swarm-protocol.md +117 -0
  97. package/.codex/skills/maestro/SKILL.md +7 -2
  98. package/.codex/skills/maestro-companion/SKILL.md +485 -0
  99. package/.codex/skills/maestro-grill/SKILL.md +111 -0
  100. package/.codex/skills/maestro-next/SKILL.md +297 -0
  101. package/.codex/skills/maestro-ralph/SKILL.md +11 -7
  102. package/.codex/skills/manage-codebase-rebuild/SKILL.md +6 -0
  103. package/.codex/skills/manage-codebase-refresh/SKILL.md +6 -0
  104. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.d.ts +36 -0
  105. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.js +138 -2
  106. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.js.map +1 -1
  107. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +13 -0
  108. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  109. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +11 -0
  110. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +178 -0
  111. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  112. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +1 -0
  113. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +39 -23
  114. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  115. package/dist/src/cli.js +1 -0
  116. package/dist/src/cli.js.map +1 -1
  117. package/dist/src/commands/install-backend.d.ts +7 -0
  118. package/dist/src/commands/install-backend.d.ts.map +1 -1
  119. package/dist/src/commands/install-backend.js +14 -0
  120. package/dist/src/commands/install-backend.js.map +1 -1
  121. package/dist/src/commands/install.d.ts.map +1 -1
  122. package/dist/src/commands/install.js +23 -1
  123. package/dist/src/commands/install.js.map +1 -1
  124. package/dist/src/commands/kg.d.ts +11 -0
  125. package/dist/src/commands/kg.d.ts.map +1 -0
  126. package/dist/src/commands/kg.js +515 -0
  127. package/dist/src/commands/kg.js.map +1 -0
  128. package/dist/src/i18n/locales/en.d.ts.map +1 -1
  129. package/dist/src/i18n/locales/en.js +19 -0
  130. package/dist/src/i18n/locales/en.js.map +1 -1
  131. package/dist/src/i18n/locales/zh.d.ts.map +1 -1
  132. package/dist/src/i18n/locales/zh.js +19 -0
  133. package/dist/src/i18n/locales/zh.js.map +1 -1
  134. package/dist/src/i18n/types.d.ts +12 -0
  135. package/dist/src/i18n/types.d.ts.map +1 -1
  136. package/dist/src/tui/install-ui/HooksConfig.d.ts +5 -1
  137. package/dist/src/tui/install-ui/HooksConfig.d.ts.map +1 -1
  138. package/dist/src/tui/install-ui/HooksConfig.js +5 -3
  139. package/dist/src/tui/install-ui/HooksConfig.js.map +1 -1
  140. package/dist/src/tui/install-ui/InstallConfirm.d.ts +3 -0
  141. package/dist/src/tui/install-ui/InstallConfirm.d.ts.map +1 -1
  142. package/dist/src/tui/install-ui/InstallConfirm.js +1 -1
  143. package/dist/src/tui/install-ui/InstallConfirm.js.map +1 -1
  144. package/dist/src/tui/install-ui/InstallExecution.d.ts +2 -0
  145. package/dist/src/tui/install-ui/InstallExecution.d.ts.map +1 -1
  146. package/dist/src/tui/install-ui/InstallExecution.js +48 -3
  147. package/dist/src/tui/install-ui/InstallExecution.js.map +1 -1
  148. package/dist/src/tui/install-ui/InstallFlow.d.ts +1 -1
  149. package/dist/src/tui/install-ui/InstallFlow.d.ts.map +1 -1
  150. package/dist/src/tui/install-ui/InstallFlow.js +95 -17
  151. package/dist/src/tui/install-ui/InstallFlow.js.map +1 -1
  152. package/dist/src/tui/install-ui/InstallHub.d.ts +4 -0
  153. package/dist/src/tui/install-ui/InstallHub.d.ts.map +1 -1
  154. package/dist/src/tui/install-ui/InstallHub.js +14 -0
  155. package/dist/src/tui/install-ui/InstallHub.js.map +1 -1
  156. package/dist/src/tui/install-ui/InstallResult.d.ts.map +1 -1
  157. package/dist/src/tui/install-ui/InstallResult.js +1 -1
  158. package/dist/src/tui/install-ui/InstallResult.js.map +1 -1
  159. package/dist/src/tui/install-ui/KgVendorConfig.d.ts +7 -0
  160. package/dist/src/tui/install-ui/KgVendorConfig.d.ts.map +1 -0
  161. package/dist/src/tui/install-ui/KgVendorConfig.js +9 -0
  162. package/dist/src/tui/install-ui/KgVendorConfig.js.map +1 -0
  163. package/dist/src/utils/update-notices.js +22 -0
  164. package/dist/src/utils/update-notices.js.map +1 -1
  165. package/package.json +1 -1
  166. package/workflows/analyze.md +2 -1
  167. package/workflows/brainstorm.md +24 -1
  168. package/workflows/codebase-rebuild.md +141 -1
  169. package/workflows/codebase-refresh.md +20 -0
  170. package/workflows/finish-work.md +7 -2
  171. package/workflows/grill.md +513 -0
  172. package/workflows/plan.md +7 -4
  173. package/workflows/specs-setup.md +99 -3
  174. package/workflows/swarm/wf-analyze.js +186 -0
  175. package/workflows/swarm/wf-brainstorm.js +284 -0
  176. package/workflows/swarm/wf-execute.js +203 -0
  177. package/workflows/swarm/wf-grill.js +198 -0
  178. package/workflows/swarm/wf-milestone-audit.js +236 -0
  179. package/workflows/swarm/wf-plan.js +233 -0
  180. package/workflows/swarm/wf-review.js +226 -0
  181. package/workflows/swarm/wf-verify.js +298 -0
@@ -0,0 +1,485 @@
1
+ ---
2
+ name: maestro-companion
3
+ description: Knowledge companion — load context, record companion doc, capture insights, route to skills
4
+ argument-hint: "[before|note|after|route] [--task <description>] [--type <task_type>] [--category <cat>]"
5
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ <purpose>
9
+ Task companion command — pairs with any task to provide knowledge context loading,
10
+ structured companion document recording, insight capture, and skill routing.
11
+
12
+ Does not create sessions or modify workflow state. Pure side-car utility.
13
+
14
+ Four modes:
15
+ - **before** — Pre-task: load spec + knowhow index + codebase index, create companion doc
16
+ - **note** — Mid-task: append a structured entry to the active companion doc
17
+ - **after** — Post-task: review companion doc, promote entries to spec/knowhow, suggest next steps
18
+ - **route** — Routing: recommend next skill/command based on intent
19
+
20
+ No arguments → auto-detect: uncommitted changes → `after`, else → `before`.
21
+ </purpose>
22
+
23
+ <context>
24
+ $ARGUMENTS — mode + optional flags.
25
+
26
+ ```bash
27
+ $maestro-companion
28
+ $maestro-companion "before --task 'implement auth module' --type implement"
29
+ $maestro-companion "before --task 'fix login bug' --type debug --category coding"
30
+ $maestro-companion "note 'decided to use bcrypt over argon2'"
31
+ $maestro-companion "note --file src/auth.ts 'changed token validation logic'"
32
+ $maestro-companion "after"
33
+ $maestro-companion "route what should I do next"
34
+ ```
35
+
36
+ **Mode detection priority:**
37
+ 1. Explicit `before` / `note` / `after` / `route`
38
+ 2. Intent text that is not a mode keyword → `route`
39
+ 3. No arguments → auto-detect (`git status` has changes → `after`, else → `before`)
40
+
41
+ **Flags:**
42
+ - `--task <description>` — Current task description (for targeted knowledge loading and doc title)
43
+ - `--type <task_type>` — Task type for field template selection (see task types below)
44
+ - `--category <cat>` — Spec category filter: coding / arch / test / review / debug / learning / ui
45
+
46
+ **Task types** (determines which recording sections are active):
47
+
48
+ | Type | Description | Key sections |
49
+ |------|-------------|--------------|
50
+ | `implement` | Feature development, code writing | working_files, dependencies, decisions, tests_affected |
51
+ | `debug` | Bug investigation, root cause analysis | symptoms, hypotheses, evidence, root_cause, fix_applied |
52
+ | `analyze` | Code/architecture/performance analysis | scope, findings, risks, recommendations |
53
+ | `design` | Architecture/UI/API design | constraints, alternatives, trade_offs, chosen_approach |
54
+ | `plan` | Task decomposition, roadmap planning | goals, breakdown, estimates, dependencies |
55
+ | `review` | Code review, PR review | files_reviewed, findings, severity_counts, verdict |
56
+ | `test` | Test writing, UAT, coverage expansion | coverage_before, coverage_after, gaps, test_files |
57
+ | `refactor` | Code restructuring, tech debt | affected_modules, before_after, breaking_changes |
58
+ | `learn` | Codebase exploration, knowledge building | questions, answers, mental_model, references |
59
+ | `general` | Default / unclassified | (all universal sections) |
60
+
61
+ Auto-detection: if `--type` not provided, infer from `--task` description keywords.
62
+
63
+ **Companion document:**
64
+ - Path: `.workflow/.scratchpad/companion-{YYYYMMDD-HHmmss}.md`
65
+ - Active doc tracking: `.workflow/.scratchpad/.companion-active` (stores path of current companion doc)
66
+ - Format: YAML frontmatter (rich metadata) + typed sections + timestamped entries
67
+ </context>
68
+
69
+ <execution>
70
+
71
+ ## S_BEFORE — Knowledge Loading + Companion Doc Creation
72
+
73
+ ### Step 1: Load Specs
74
+
75
+ Run `maestro spec load` with appropriate flags:
76
+ - With `--category`: `maestro spec load --category <cat>`
77
+ - With `--task`: `maestro spec load --keyword <extracted_keyword>`
78
+ - No flags: `maestro spec load --category coding`
79
+
80
+ Display loaded rules summary (entry count + key rule names).
81
+
82
+ ### Step 2: Browse Knowhow Index
83
+
84
+ Run `maestro knowhow list --store workflow`. With `--task`, also run `maestro knowhow search "<task_keyword>"`. Display available entries (ID + title). Hint: `maestro wiki load <id>` for details.
85
+
86
+ ### Step 3: Check Codebase Index
87
+
88
+ Check if `.workflow/codebase/doc-index.json` exists.
89
+ - Exists → display "Codebase docs ready, last updated: {timestamp}"
90
+ - Missing → suggest `$manage-codebase-rebuild`
91
+ - Stale (>7 days) → suggest `$manage-codebase-refresh`
92
+
93
+ ### Step 4: Create Companion Document
94
+
95
+ Create `.workflow/.scratchpad/` if needed. Resolve task type from `--type` flag or infer from `--task` keywords.
96
+
97
+ Write companion doc with full field template:
98
+
99
+ ```markdown
100
+ ---
101
+ # === Identity ===
102
+ task: "{task_description or 'Untitled task'}"
103
+ task_type: "{resolved type}"
104
+ created: "{ISO timestamp}"
105
+ status: active
106
+
107
+ # === Context Loaded ===
108
+ specs_loaded: "{category or 'coding'}"
109
+ specs_count: {N}
110
+ knowhow_searched: "{keyword or 'none'}"
111
+ knowhow_available: {M}
112
+ codebase_index: "{ready|missing|stale}"
113
+ branch: "{current git branch}"
114
+ phase: "{current phase from state.json or 'none'}"
115
+ milestone: "{current milestone from state.json or 'none'}"
116
+
117
+ # === Scope ===
118
+ working_files: []
119
+ dependencies: []
120
+ related_artifacts: []
121
+
122
+ # === Outcome (populated by after mode) ===
123
+ outcome: ""
124
+ files_changed: []
125
+ promoted_specs: 0
126
+ promoted_knowhow: 0
127
+ follow_up: []
128
+ completed: ""
129
+ ---
130
+
131
+ # Companion Doc — {task_description}
132
+
133
+ > `$maestro-companion "note '<content>'"` — add entries
134
+ > `$maestro-companion after` — review, promote, close
135
+
136
+ ## Context
137
+
138
+ {Type-specific context section}
139
+
140
+ ## Entries
141
+
142
+ ## Summary
143
+ ```
144
+
145
+ **Type-specific context templates** (written into `## Context`):
146
+
147
+ **implement:**
148
+ ```markdown
149
+ ### Working Files
150
+ | File | Role | Status |
151
+ |------|------|--------|
152
+
153
+ ### Dependencies
154
+ - (modules, APIs, or services this task depends on)
155
+
156
+ ### Decisions
157
+ | # | Decision | Rationale | Alternatives Considered |
158
+ |---|----------|-----------|------------------------|
159
+
160
+ ### Tests Affected
161
+ - (test files that need creation or update)
162
+ ```
163
+
164
+ **debug:**
165
+ ```markdown
166
+ ### Symptoms
167
+ - (observable behavior vs expected behavior)
168
+
169
+ ### Hypotheses
170
+ | # | Hypothesis | Status | Evidence |
171
+ |---|-----------|--------|----------|
172
+
173
+ ### Evidence Trail
174
+ | Time | Source | Type | Finding |
175
+ |------|--------|------|---------|
176
+
177
+ ### Root Cause
178
+ - (populated when identified)
179
+
180
+ ### Fix Applied
181
+ - (description of fix, files changed)
182
+ ```
183
+
184
+ **analyze:**
185
+ ```markdown
186
+ ### Scope
187
+ - (what is being analyzed and boundaries)
188
+
189
+ ### Findings
190
+ | # | Finding | Severity | Location |
191
+ |---|---------|----------|----------|
192
+
193
+ ### Risks
194
+ - (identified risks or concerns)
195
+
196
+ ### Recommendations
197
+ - (actionable recommendations)
198
+ ```
199
+
200
+ **design:**
201
+ ```markdown
202
+ ### Constraints
203
+ - (hard limits, requirements, compatibility needs)
204
+
205
+ ### Alternatives
206
+ | # | Approach | Pros | Cons |
207
+ |---|----------|------|------|
208
+
209
+ ### Trade-offs
210
+ - (key trade-off decisions and rationale)
211
+
212
+ ### Chosen Approach
213
+ - (selected design with justification)
214
+ ```
215
+
216
+ **plan:**
217
+ ```markdown
218
+ ### Goals
219
+ - (what success looks like)
220
+
221
+ ### Breakdown
222
+ | # | Task | Estimate | Depends On | Status |
223
+ |---|------|----------|------------|--------|
224
+
225
+ ### Dependencies
226
+ - (external dependencies, blockers, prerequisites)
227
+ ```
228
+
229
+ **review:**
230
+ ```markdown
231
+ ### Files Reviewed
232
+ | File | Lines | Findings |
233
+ |------|-------|----------|
234
+
235
+ ### Findings
236
+ | # | Severity | Category | File:Line | Description |
237
+ |---|----------|----------|-----------|-------------|
238
+
239
+ ### Verdict
240
+ - (pass / pass-with-concerns / fail)
241
+ ```
242
+
243
+ **test:**
244
+ ```markdown
245
+ ### Coverage
246
+ - Before: {%}
247
+ - After: {%}
248
+ - Target: {%}
249
+
250
+ ### Test Files
251
+ | File | Type | Tests Added | Status |
252
+ |------|------|------------|--------|
253
+
254
+ ### Gaps
255
+ - (uncovered paths or scenarios)
256
+ ```
257
+
258
+ **refactor:**
259
+ ```markdown
260
+ ### Affected Modules
261
+ - (modules being restructured)
262
+
263
+ ### Before / After
264
+ | Aspect | Before | After |
265
+ |--------|--------|-------|
266
+
267
+ ### Breaking Changes
268
+ - (API or behavior changes that affect consumers)
269
+ ```
270
+
271
+ **learn:**
272
+ ```markdown
273
+ ### Questions
274
+ | # | Question | Answered | Source |
275
+ |---|----------|----------|--------|
276
+
277
+ ### Mental Model
278
+ - (evolving understanding of how it works)
279
+
280
+ ### References
281
+ - (files, docs, wiki entries consulted)
282
+ ```
283
+
284
+ **general:**
285
+ ```markdown
286
+ ### Notes
287
+ - (general working notes)
288
+ ```
289
+
290
+ Write the companion doc path to `.workflow/.scratchpad/.companion-active`.
291
+
292
+ ### Step 5: Output Summary Card
293
+
294
+ ```
295
+ Knowledge context loaded
296
+ Spec: {N} rules ({category})
297
+ Knowhow: {M} entries available
298
+ Codebase: {status}
299
+ Doc: {companion_doc_path} [{task_type}]
300
+
301
+ Mid-task commands:
302
+ $maestro-companion "note 'finding or decision'"
303
+ $maestro-companion "note --file src/auth.ts 'changed validation'"
304
+ $spec-load "--keyword <keyword>"
305
+ ```
306
+
307
+ ---
308
+
309
+ ## S_NOTE — Append Structured Entry to Companion Doc
310
+
311
+ ### Step 1: Locate Active Companion Doc
312
+
313
+ Read `.workflow/.scratchpad/.companion-active` to get the doc path.
314
+ If missing or file not found → create a new companion doc (same as Step 4 above, minimal — no spec/knowhow loading).
315
+
316
+ ### Step 2: Parse Entry Content and Flags
317
+
318
+ Parse $ARGUMENTS after `note` keyword:
319
+ - `--file <path>` — associate entry with a specific file (appended to frontmatter `working_files`)
320
+ - `--severity <level>` — for findings: critical / high / medium / low
321
+ - Remaining text = entry content
322
+
323
+ ### Step 3: Classify Entry Type
324
+
325
+ Auto-classify from content signals:
326
+
327
+ | Content signal | Type tag |
328
+ |---------------|----------|
329
+ | "decided/decision/chose/picked/went with" | `decision` |
330
+ | "pattern/convention/rule/always/never/must" | `spec-candidate` |
331
+ | "pitfall/gotcha/careful/warning/trap/beware" | `pitfall` |
332
+ | "learned/realized/discovered/understood/turns out" | `insight` |
333
+ | "hypothesis/suspect/might be/could be" | `hypothesis` |
334
+ | "found bug/root cause/because of/caused by" | `evidence` |
335
+ | "risk/concern/worry/might break" | `risk` |
336
+ | "todo/need to/should also/follow up/remaining" | `todo` |
337
+ | "question/why does/how does/unclear" | `question` |
338
+ | "blocked/stuck/can't/impossible" | `blocker` |
339
+ | Default | `note` |
340
+
341
+ ### Step 4: Append Entry
342
+
343
+ Append to the companion doc under `## Entries`:
344
+
345
+ ```markdown
346
+ ### [{type}] {HH:mm} — {first line of content}
347
+
348
+ {full content}
349
+
350
+ {if --file: **File:** `{path}`}
351
+ {if --severity: **Severity:** {level}}
352
+ ```
353
+
354
+ ### Step 5: Update Frontmatter and Context Tables
355
+
356
+ - If `--file` provided and not already in `working_files` → append to `working_files`
357
+ - If type is `decision` → also append row to `### Decisions` table (if implement/design type doc)
358
+ - If type is `hypothesis` → also append row to `### Hypotheses` table (if debug type doc)
359
+ - If type is `evidence` → also append row to `### Evidence Trail` table (if debug type doc)
360
+ - If type is `risk` → also append to `### Risks` list (if analyze/design type doc)
361
+ - If type is `question` → also append row to `### Questions` table (if learn type doc)
362
+
363
+ ### Step 6: Confirm
364
+
365
+ ```
366
+ [{type}] entry added to companion doc
367
+ $maestro-companion "note '...'" — add more
368
+ $maestro-companion after — review & promote
369
+ ```
370
+
371
+ ---
372
+
373
+ ## S_AFTER — Review + Populate Outcome + Promote + Route
374
+
375
+ ### Step 1: Load Companion Doc
376
+
377
+ Read `.workflow/.scratchpad/.companion-active` → read the companion doc.
378
+ If no active doc or doc is empty → skip to Step 4 (accumulation reminder).
379
+
380
+ ### Step 2: Populate Outcome Fields
381
+
382
+ Collect task outcome data:
383
+
384
+ ```bash
385
+ git diff --name-only
386
+ ```
387
+
388
+ Update frontmatter:
389
+ - `files_changed` — from git diff
390
+ - `completed` — current ISO timestamp
391
+ - `status` — `completed`
392
+
393
+ Display entry summary:
394
+ ```
395
+ Companion doc review — {task_type}
396
+ Entries: {total} ({by type breakdown})
397
+ Files: {files_changed count} changed
398
+ Duration: {elapsed since created}
399
+
400
+ Promotable entries:
401
+ {list of decision/spec-candidate/pitfall/insight entries}
402
+ ```
403
+
404
+ ### Step 3: Promote Entries
405
+
406
+ If promotable entries exist, ask user:
407
+
408
+ - Option 1: "Promote to spec" — short coding/arch/test constraint
409
+ - Option 2: "Promote to knowhow" — detailed recipe/template/decision/tip
410
+ - Option 3: "Promote both" — spec index entry + knowhow document
411
+ - Option 4: "Skip — nothing to promote"
412
+
413
+ **Routing by selection:**
414
+
415
+ | Selection | Action |
416
+ |-----------|--------|
417
+ | Spec | `Skill({ skill: "spec-add" })` — guide user through category + content |
418
+ | Knowhow | `Skill({ skill: "manage-knowhow-capture" })` — guide through type + content |
419
+ | Both | `spec-add` first, then `manage-knowhow-capture` |
420
+ | Skip | Proceed to Step 4 |
421
+
422
+ Update frontmatter: `promoted_specs`, `promoted_knowhow` counts.
423
+ Extract any `todo` entries → write to `follow_up` in frontmatter.
424
+ Clear `.workflow/.scratchpad/.companion-active`.
425
+
426
+ ### Step 4: Output Accumulation Reminder + Routing
427
+
428
+ ```
429
+ Knowledge accumulation reminders:
430
+ Reusable pattern found? $spec-add "<category> 'title' 'content'"
431
+ Solved a complex problem? $manage-knowhow-capture "recipe 'description'"
432
+ Made an architecture decision? $manage-knowhow-capture "decision 'description'"
433
+ Discovered a useful trick? $manage-knowhow-capture "tip 'content'"
434
+
435
+ Next steps:
436
+ $maestro-next — recommend next command
437
+ $maestro "<intent>" — route intent to full workflow
438
+ $manage-status — view project dashboard
439
+ ```
440
+
441
+ ---
442
+
443
+ ## S_ROUTE — Skill Routing
444
+
445
+ ### Step 1: Parse Intent
446
+
447
+ Extract intent text from $ARGUMENTS after removing the `route` keyword.
448
+
449
+ ### Step 2: Delegate to maestro-next
450
+
451
+ ```
452
+ Skill({ skill: "maestro-next", args: "<intent_text>" })
453
+ ```
454
+
455
+ Reuses maestro-next routing table and scoring logic to recommend the best single command.
456
+
457
+ </execution>
458
+
459
+ <error_codes>
460
+ | Code | Severity | Condition | Recovery |
461
+ |------|----------|-----------|----------|
462
+ | W001 | warning | `.workflow/specs/` not initialized | Suggest `$spec-setup` |
463
+ | W002 | warning | `.workflow/knowhow/` is empty | Normal, skip knowhow index |
464
+ | W003 | warning | `.workflow/codebase/` does not exist | Suggest `$manage-codebase-rebuild` |
465
+ | W004 | warning | No active companion doc found (note/after mode) | Create new doc or skip |
466
+ </error_codes>
467
+
468
+ <success_criteria>
469
+ - [ ] Mode correctly detected (before/note/after/route)
470
+ - [ ] Task type resolved from --type flag or inferred from --task keywords
471
+ - [ ] before: spec + knowhow + codebase indexes loaded or hints given
472
+ - [ ] before: companion doc created with full YAML frontmatter (identity + context + scope + outcome)
473
+ - [ ] before: type-specific context template written (matching task_type)
474
+ - [ ] before: active doc path written to `.companion-active`
475
+ - [ ] note: active companion doc located and entry appended with type tag
476
+ - [ ] note: entry type auto-classified from content signals (11 type tags)
477
+ - [ ] note: --file flag updates working_files in frontmatter
478
+ - [ ] note: typed entries cross-posted to matching context tables
479
+ - [ ] after: outcome fields populated (files_changed, completed, status)
480
+ - [ ] after: promotable entries identified and routed to spec-add or manage-knowhow-capture
481
+ - [ ] after: todo entries extracted to follow_up field
482
+ - [ ] after: companion doc marked completed, active pointer cleared
483
+ - [ ] route: intent correctly forwarded to maestro-next
484
+ - [ ] No session created, no state.json modified
485
+ </success_criteria>
@@ -0,0 +1,111 @@
1
+ ---
2
+ name: maestro-grill
3
+ description: Use when stress-testing a plan, idea, or requirement against codebase reality before brainstorming
4
+ argument-hint: "<topic|plan> [-y] [-c] [--from <source>] [--depth shallow|standard|deep]"
5
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, request_user_input
6
+ ---
7
+ <purpose>
8
+ Socratic stress-testing of a plan, idea, or requirement against codebase reality. Walks every branch of the decision tree one question at a time — challenging vague terminology against existing code, probing edge cases with concrete scenarios, and verifying assumptions with code evidence. Produces a verified context package (grill-report.md + terminology.md + context-package.json) for downstream brainstorm/analyze/roadmap consumption.
9
+
10
+ Positioned BEFORE brainstorm in the pipeline: grill stress-tests and sharpens; brainstorm generates and elaborates.
11
+
12
+ Codex specifics:
13
+ - **No agent spawning** — codebase exploration runs directly via Glob/Grep/Read in coordinator context.
14
+ - **request_user_input** replaces AskUserQuestion for Socratic Q&A.
15
+ - **CLI delegation** for auto mode: `exec_command("maestro delegate ... --role analyze --mode analysis")`.
16
+ </purpose>
17
+
18
+ <required_reading>
19
+ @~/.maestro/workflows/grill.md
20
+ </required_reading>
21
+
22
+ <deferred_reading>
23
+ - [state.json](~/.maestro/templates/state.json) — read when registering artifact
24
+ </deferred_reading>
25
+
26
+ <context>
27
+ $ARGUMENTS -- topic/plan text for interactive mode, or --from source for upstream input.
28
+
29
+ **Mode selection:**
30
+ - **Interactive mode** (default): Topic text triggers full Socratic grilling with user Q&A
31
+ - **Auto mode** (`-y`): Code exploration answers questions instead of the user
32
+ - **Resume mode** (`-c` or `--session ID`): Continue from a previous grill session
33
+
34
+ **Flags:**
35
+ - `-y` / `--yes`: Auto mode — CLI exploration replaces human answers
36
+ - `-c` / `--continue`: Resume from last grill session
37
+ - `--session ID`: Resume specific session
38
+ - `--depth shallow|standard|deep`: Branch count 3/5/8 (default: standard)
39
+ - `--from <source>`: Load upstream material (`blueprint:ID`, `@file`, or path)
40
+
41
+ **Output directory**: `.workflow/scratch/{YYYYMMDD}-grill-{slug}/`
42
+ **Produced files**: `grill-report.md`, `terminology.md`, `context-package.json`
43
+
44
+ ### Role Knowledge
45
+ `maestro wiki search "{topic keywords}"` → load relevant entries before grilling.
46
+ `maestro spec load --category arch` → load architecture constraints.
47
+ </context>
48
+
49
+ <interview_protocol>
50
+ Grill the user relentlessly until every branch of the decision tree is walked. This is NOT a menu-driven interview — it is adversarial Socratic questioning. Active only in interactive mode; skip when `-y/--yes` or `-c/--continue`.
51
+
52
+ Core protocol:
53
+ - **One question per turn**. Each question probes ONE specific aspect. Never ask compound questions.
54
+ - **Code-grounded**: Before asking, search the codebase for evidence. Use findings to sharpen the question or challenge the user's answer. Never ask what code can verify — search first, then confront.
55
+ - **Escalating depth**: Start with scope boundaries, progress to data model, edge cases, failure modes. Each branch goes basic → specific → adversarial.
56
+ - **Immediate writeback**: After each answered question, immediately append the Q&A + decision to `grill-report.md`. Do NOT batch — partial progress must be on disk before the next question.
57
+ - **Challenge contradictions**: If an answer conflicts with code evidence or a prior answer, immediately surface the contradiction and demand resolution.
58
+ - **Terminology enforcement**: When the user uses a term that conflicts with codebase naming, challenge it immediately. Propose the code-consistent alternative. Update `terminology.md` as terms crystallize.
59
+
60
+ Question framing rules:
61
+ - Reference specific code findings: "The codebase uses `{symbol}` at `{file:line}` — your proposal calls it `{term}`. Which wins?"
62
+ - Use concrete scenarios: "What happens when a user does {action} while {condition} is true?"
63
+ - Probe boundaries: "You said {X} is in scope — does that include {edge_case}, or is that separate?"
64
+ - Challenge scale: "This touches `{table}` — at 10x current data volume, which query breaks first?"
65
+
66
+ Branch walking order: Scope & Boundaries → Data Model & State → Edge Cases & Failure Modes → Integration & Dependencies → Scale & Performance → Security & Access Control → Observability & Operations → Migration & Rollback. Number of branches determined by `--depth`.
67
+
68
+ Exit: When all depth-selected branches are fully walked (every question answered or explicitly deferred), finalize the report and generate context-package.json.
69
+ </interview_protocol>
70
+
71
+ <execution>
72
+ Follow '~/.maestro/workflows/grill.md' completely.
73
+
74
+ **Next-step routing on completion:**
75
+
76
+ Standard routing:
77
+ - Need multi-role elaboration → `$maestro-brainstorm "{topic}" --from grill:{artifact_id}`
78
+ - Need deep technical analysis → `$maestro-analyze "{topic}" --from grill:{artifact_id}`
79
+ - Scope is clear, ready for roadmap → `$maestro-roadmap --from grill:{artifact_id}`
80
+ - Need formal spec package → `$maestro-blueprint --from grill:{artifact_id}`
81
+
82
+ Resume routing:
83
+ - More branches to walk → `$maestro-grill "{topic}" -c`
84
+ </execution>
85
+
86
+ <error_codes>
87
+ | Code | Severity | Condition | Recovery |
88
+ |------|----------|-----------|----------|
89
+ | E001 | error | No topic/plan and no --from/--continue flag | Prompt user for topic text |
90
+ | E002 | error | --session ID not found | Show available sessions |
91
+ | W001 | warning | Codebase scan failed or returned empty | Continue without code grounding, note limitation |
92
+ | W002 | warning | CLI exploration timeout in auto mode | Skip question, mark as open |
93
+ | W003 | warning | Max branch depth reached without resolution | Force synthesis, offer continuation |
94
+ </error_codes>
95
+
96
+ <success_criteria>
97
+ - [ ] Interactive mode: all depth-selected branches walked (shallow=3, standard=5, deep=8)
98
+ - [ ] Each branch has >= 2 question-answer pairs with evidence or explicit user input
99
+ - [ ] `grill-report.md` written with Branch Log table, all Q&A entries, synthesis section
100
+ - [ ] `terminology.md` written with >= 5 terms, code references where applicable
101
+ - [ ] Every locked decision has evidence (code reference or explicit user confirmation)
102
+ - [ ] Contradictions between answers and code surfaced and resolved (or logged as risks)
103
+ - [ ] Risk register captures all unresolved tensions
104
+ - [ ] `context-package.json` generated with schema "context-package/1.0"
105
+ - [ ] Artifact registered in state.json (type=grill, id=GRL-xxx)
106
+ - [ ] Session sealed via finish-work
107
+ </success_criteria>
108
+
109
+ <on_complete>
110
+ @~/.maestro/workflows/finish-work.md — SESSION_DIR={output_dir}, SESSION_TYPE=grill, SESSION_ID={artifact_id}, LINKED_MILESTONE=null
111
+ </on_complete>