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