maestro-flow 0.4.19 → 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 (122) 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-swarm-workflow/SKILL.md +258 -0
  12. package/.agents/skills/manage-codebase-rebuild/SKILL.md +13 -1
  13. package/.agents/skills/manage-codebase-refresh/SKILL.md +3 -0
  14. package/.agents/skills/spec-setup/SKILL.md +9 -5
  15. package/.agy/agents/workflow-collab-planner.md +4 -1
  16. package/.agy/agents/workflow-plan-checker.md +11 -1
  17. package/.agy/agents/workflow-planner.md +4 -1
  18. package/.agy/skills/maestro/SKILL.md +8 -5
  19. package/.agy/skills/maestro-analyze/SKILL.md +1 -1
  20. package/.agy/skills/maestro-brainstorm/SKILL.md +2 -1
  21. package/.agy/skills/maestro-companion/SKILL.md +529 -0
  22. package/.agy/skills/maestro-grill/SKILL.md +116 -0
  23. package/.agy/skills/maestro-plan/SKILL.md +4 -0
  24. package/.agy/skills/maestro-ralph/SKILL.md +11 -7
  25. package/.agy/skills/maestro-swarm-workflow/SKILL.md +255 -0
  26. package/.agy/skills/manage-codebase-rebuild/SKILL.md +13 -1
  27. package/.agy/skills/manage-codebase-refresh/SKILL.md +3 -0
  28. package/.agy/skills/spec-setup/SKILL.md +9 -5
  29. package/.claude/agents/workflow-collab-planner.md +4 -1
  30. package/.claude/agents/workflow-plan-checker.md +11 -1
  31. package/.claude/agents/workflow-planner.md +4 -1
  32. package/.claude/commands/maestro-analyze.md +1 -1
  33. package/.claude/commands/maestro-brainstorm.md +2 -1
  34. package/.claude/commands/maestro-companion.md +531 -0
  35. package/.claude/commands/maestro-grill.md +114 -0
  36. package/.claude/commands/maestro-plan.md +4 -0
  37. package/.claude/commands/maestro-ralph.md +11 -7
  38. package/.claude/commands/maestro-swarm-workflow.md +256 -0
  39. package/.claude/commands/maestro.md +8 -5
  40. package/.claude/commands/manage-codebase-rebuild.md +13 -1
  41. package/.claude/commands/manage-codebase-refresh.md +3 -0
  42. package/.claude/commands/spec-setup.md +9 -5
  43. package/.codex/skills/maestro/SKILL.md +7 -2
  44. package/.codex/skills/maestro-companion/SKILL.md +485 -0
  45. package/.codex/skills/maestro-grill/SKILL.md +111 -0
  46. package/.codex/skills/maestro-ralph/SKILL.md +11 -7
  47. package/.codex/skills/manage-codebase-rebuild/SKILL.md +6 -0
  48. package/.codex/skills/manage-codebase-refresh/SKILL.md +6 -0
  49. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.d.ts +36 -0
  50. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.js +138 -2
  51. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.js.map +1 -1
  52. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +13 -0
  53. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  54. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +11 -0
  55. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +178 -0
  56. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  57. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +1 -0
  58. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +39 -23
  59. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  60. package/dist/src/cli.js +1 -0
  61. package/dist/src/cli.js.map +1 -1
  62. package/dist/src/commands/install-backend.d.ts +7 -0
  63. package/dist/src/commands/install-backend.d.ts.map +1 -1
  64. package/dist/src/commands/install-backend.js +14 -0
  65. package/dist/src/commands/install-backend.js.map +1 -1
  66. package/dist/src/commands/install.d.ts.map +1 -1
  67. package/dist/src/commands/install.js +18 -0
  68. package/dist/src/commands/install.js.map +1 -1
  69. package/dist/src/commands/kg.d.ts +11 -0
  70. package/dist/src/commands/kg.d.ts.map +1 -0
  71. package/dist/src/commands/kg.js +515 -0
  72. package/dist/src/commands/kg.js.map +1 -0
  73. package/dist/src/i18n/locales/en.d.ts.map +1 -1
  74. package/dist/src/i18n/locales/en.js +10 -0
  75. package/dist/src/i18n/locales/en.js.map +1 -1
  76. package/dist/src/i18n/locales/zh.d.ts.map +1 -1
  77. package/dist/src/i18n/locales/zh.js +10 -0
  78. package/dist/src/i18n/locales/zh.js.map +1 -1
  79. package/dist/src/i18n/types.d.ts +9 -0
  80. package/dist/src/i18n/types.d.ts.map +1 -1
  81. package/dist/src/tui/install-ui/InstallConfirm.d.ts +1 -0
  82. package/dist/src/tui/install-ui/InstallConfirm.d.ts.map +1 -1
  83. package/dist/src/tui/install-ui/InstallConfirm.js +1 -1
  84. package/dist/src/tui/install-ui/InstallConfirm.js.map +1 -1
  85. package/dist/src/tui/install-ui/InstallExecution.d.ts +1 -0
  86. package/dist/src/tui/install-ui/InstallExecution.d.ts.map +1 -1
  87. package/dist/src/tui/install-ui/InstallExecution.js +22 -0
  88. package/dist/src/tui/install-ui/InstallExecution.js.map +1 -1
  89. package/dist/src/tui/install-ui/InstallFlow.d.ts +1 -1
  90. package/dist/src/tui/install-ui/InstallFlow.d.ts.map +1 -1
  91. package/dist/src/tui/install-ui/InstallFlow.js +23 -5
  92. package/dist/src/tui/install-ui/InstallFlow.js.map +1 -1
  93. package/dist/src/tui/install-ui/InstallHub.d.ts +2 -0
  94. package/dist/src/tui/install-ui/InstallHub.d.ts.map +1 -1
  95. package/dist/src/tui/install-ui/InstallHub.js +6 -0
  96. package/dist/src/tui/install-ui/InstallHub.js.map +1 -1
  97. package/dist/src/tui/install-ui/InstallResult.d.ts.map +1 -1
  98. package/dist/src/tui/install-ui/InstallResult.js +1 -1
  99. package/dist/src/tui/install-ui/InstallResult.js.map +1 -1
  100. package/dist/src/tui/install-ui/KgVendorConfig.d.ts +7 -0
  101. package/dist/src/tui/install-ui/KgVendorConfig.d.ts.map +1 -0
  102. package/dist/src/tui/install-ui/KgVendorConfig.js +9 -0
  103. package/dist/src/tui/install-ui/KgVendorConfig.js.map +1 -0
  104. package/dist/src/utils/update-notices.js +11 -0
  105. package/dist/src/utils/update-notices.js.map +1 -1
  106. package/package.json +1 -1
  107. package/workflows/analyze.md +2 -1
  108. package/workflows/brainstorm.md +24 -1
  109. package/workflows/codebase-rebuild.md +141 -1
  110. package/workflows/codebase-refresh.md +20 -0
  111. package/workflows/finish-work.md +7 -2
  112. package/workflows/grill.md +513 -0
  113. package/workflows/plan.md +7 -4
  114. package/workflows/specs-setup.md +99 -3
  115. package/workflows/swarm/wf-analyze.js +186 -0
  116. package/workflows/swarm/wf-brainstorm.js +284 -0
  117. package/workflows/swarm/wf-execute.js +203 -0
  118. package/workflows/swarm/wf-grill.js +198 -0
  119. package/workflows/swarm/wf-milestone-audit.js +236 -0
  120. package/workflows/swarm/wf-plan.js +233 -0
  121. package/workflows/swarm/wf-review.js +226 -0
  122. package/workflows/swarm/wf-verify.js +298 -0
@@ -51,10 +51,11 @@ $ARGUMENTS — user intent text, or special keywords.
51
51
  4. **Decomposition contract shared with maestro-ralph** — broad/lifecycle intents run S_DECOMPOSE producing the SAME additive block (`boundary_contract`, `execution_criteria`, `task_decomposition`)。Reference maestro-ralph `A_DECOMPOSE_TASKS`
52
52
  5. **status.json 唯一真源** — 不生成 `goal-checklist.md` 或外部清单
53
53
  6. **执行步骤统一通过 `maestro ralph next` 加载** — `command_scope`/`command_path` 由 `maestro ralph skills --json --quiet` 预校验(project 覆盖 global);decision 节点不走 CLI,走 `Skill("maestro-ralph")` handoff
54
- 7. **Topology awareness** — chain catalog 含 brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / ...;scope_verdict 由 ralph 在 `post-analyze-scope` 决定
55
- 8. **D-007 milestone 反查**数字 phase `milestone_id` `state.json.milestones[].phase_slugs` 反查
56
- 9. **每个 step 必须 `completion_confirmed: true`** `maestro ralph complete N --status DONE|DONE_WITH_CONCERNS` 写入
57
- 10. **schema** `ralph_protocol_version: "1"` 标记 CLI-driven session;新增字段全部可选
54
+ 7. **Topology awareness** — chain catalog 含 grill / brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / ...;scope_verdict 由 ralph 在 `post-analyze-scope` 决定
55
+ 8. **Grill is interactive-only**`-y` auto mode MUST skip grill stage and route directly to brainstorm; grill requires Socratic Q&A with the user
56
+ 9. **D-007 milestone 反查** 数字 phase `milestone_id` `state.json.milestones[].phase_slugs` 反查
57
+ 10. **每个 step 必须 `completion_confirmed: true`** — 由 `maestro ralph complete N --status DONE|DONE_WITH_CONCERNS` 写入
58
+ 11. **schema** — `ralph_protocol_version: "1"` 标记 CLI-driven session;新增字段全部可选
58
59
  </invariants>
59
60
 
60
61
  <state_machine>
@@ -133,6 +134,7 @@ S_FALLBACK:
133
134
  1. Read `~/.maestro/workflows/maestro.md` from deferred_reading
134
135
  2. Match intent to task_type via chain catalog (semantic)
135
136
  3. Select chain from chainMap,遵循拓扑约束:
137
+ - 压力测试/拷问/验证假设/grill/stress-test → `grill`(**-y 模式跳过 grill,直接走 brainstorm**)
136
138
  - 头脑风暴/探索 → `brainstorm`
137
139
  - 正式规格/spec-generate/7-phase → `blueprint`
138
140
  - 项目初始化 → `init`
@@ -217,7 +219,8 @@ S_FALLBACK:
217
219
  ### Success Criteria
218
220
 
219
221
  - [ ] Intent classified with task_type, complexity, clarity_score
220
- - [ ] Chain catalog 覆盖 brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / quality pipeline
222
+ - [ ] Chain catalog 覆盖 grill / brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / quality pipeline
223
+ - [ ] `-y` 模式不触发 grill(交互式压力测试不支持自动模式,跳过直接走 brainstorm)
221
224
  - [ ] D-007: 数字 phase 步骤的 `milestone_id` 通过 `state.json.milestones[].phase_slugs` 反查
222
225
  - [ ] macro analyze 后跟 `decision:post-analyze-scope`(由 ralph 评估 scope_verdict 决定下游链路)
223
226
  - [ ] plan 支持 `{phase}` / `--from analyze:{ANL_ID}` / `--from blueprint:{BLP_ID}` 三路径;`source_artifact_ref` 写入 step
@@ -50,7 +50,7 @@ $ARGUMENTS -- phase number for micro mode, topic text for macro/adhoc mode, no a
50
50
  - `-y` / `--yes`: Auto mode — skip interactive scoping, use recommended defaults, auto-deepen
51
51
  - `-c` / `--continue`: Resume from existing session (auto-detect session folder + discussion.md)
52
52
  - `-q` / `--quick`: Quick mode — skip exploration + scoring, go straight to decision extraction (context.md only)
53
- - `--from <source>`: Load upstream context package (brainstorm:ID, blueprint:BLP-xxx, @file, or path)
53
+ - `--from <source>`: Load upstream context package (grill:ID, brainstorm:ID, blueprint:BLP-xxx, @file, or path)
54
54
  - `--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.
55
55
 
56
56
  Scope routing, output directory format, artifact registration schema, and output artifact listing are defined in workflow analyze.md (Scope Routing and Output Structure sections).
@@ -70,7 +70,7 @@ Interview the user relentlessly until shared understanding is reached. Active on
70
70
  - 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.
71
71
  - Scope guard: only ask about decisions owned by `brainstorm`. Do not pre-resolve roadmap/plan choices.
72
72
 
73
- 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.
73
+ 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.
74
74
 
75
75
  Exit: on consensus or explicit user signal to proceed, finalize session metadata. The §11 table (already populated incrementally) uses this schema:
76
76
  `| # | Decision | Choice | Source (user / code / default) |`
@@ -86,6 +86,7 @@ Auto mode:
86
86
  - Project initialized, need formal spec package → view_file(AbsolutePath="<agy-skills-dir>/maestro-blueprint/SKILL.md") + execute inline (args: "--from brainstorm:{artifact_id}")
87
87
  - Project initialized, quick roadmap → view_file(AbsolutePath="<agy-skills-dir>/maestro-roadmap/SKILL.md") + execute inline (args: "--from brainstorm:{artifact_id}")
88
88
  - Need deeper analysis first → view_file(AbsolutePath="<agy-skills-dir>/maestro-analyze/SKILL.md") + execute inline (args: "{topic} --from brainstorm:{artifact_id}")
89
+ - Need stress-testing first → view_file(AbsolutePath="<agy-skills-dir>/maestro-grill/SKILL.md") + execute inline (args: "{topic}")
89
90
  - `html-prototypes/` produced with 2+ files and user wants to browse → load `~/.maestro/workflows/brainstorm-visualize.md` and launch visualizer server (optional, user-triggered)
90
91
  - DESIGN.md established during Step 3.5 → suggest: "Run `/maestro-impeccable build <feature-description>` to build with the established design system"
91
92
 
@@ -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>