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