pi-maestro-flow 0.2.0

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 (179) hide show
  1. package/README.md +124 -0
  2. package/agents/aggregator.md +27 -0
  3. package/agents/cli-explore-agent.md +188 -0
  4. package/agents/cross-role-reviewer.md +171 -0
  5. package/agents/delegate.md +19 -0
  6. package/agents/explorer.md +23 -0
  7. package/agents/impeccable-agent.md +99 -0
  8. package/agents/ralph-executor.md +81 -0
  9. package/agents/reference.md +24 -0
  10. package/agents/role-design-author.md +220 -0
  11. package/agents/team-supervisor.md +143 -0
  12. package/agents/team-worker.md +237 -0
  13. package/agents/ui-design-agent.md +270 -0
  14. package/agents/workflow-analyzer.md +116 -0
  15. package/agents/workflow-codebase-mapper.md +77 -0
  16. package/agents/workflow-collab-planner.md +147 -0
  17. package/agents/workflow-debugger.md +104 -0
  18. package/agents/workflow-executor.md +133 -0
  19. package/agents/workflow-external-researcher.md +86 -0
  20. package/agents/workflow-integration-checker.md +83 -0
  21. package/agents/workflow-nyquist-auditor.md +85 -0
  22. package/agents/workflow-phase-researcher.md +85 -0
  23. package/agents/workflow-plan-checker.md +100 -0
  24. package/agents/workflow-planner.md +200 -0
  25. package/agents/workflow-project-researcher.md +74 -0
  26. package/agents/workflow-research-synthesizer.md +70 -0
  27. package/agents/workflow-reviewer.md +82 -0
  28. package/agents/workflow-roadmapper.md +81 -0
  29. package/agents/workflow-verifier.md +120 -0
  30. package/package.json +58 -0
  31. package/skills/codify-to-knowhow/SKILL.md +167 -0
  32. package/skills/delegation-check/SKILL.md +297 -0
  33. package/skills/domain-add/SKILL.md +75 -0
  34. package/skills/insight-challenge/SKILL.md +226 -0
  35. package/skills/learn-decompose/SKILL.md +124 -0
  36. package/skills/learn-follow/SKILL.md +163 -0
  37. package/skills/learn-investigate/SKILL.md +160 -0
  38. package/skills/learn-second-opinion/SKILL.md +128 -0
  39. package/skills/maestro/SKILL.md +239 -0
  40. package/skills/maestro-amend/SKILL.md +169 -0
  41. package/skills/maestro-analyze/SKILL.md +173 -0
  42. package/skills/maestro-blueprint/SKILL.md +159 -0
  43. package/skills/maestro-brainstorm/SKILL.md +193 -0
  44. package/skills/maestro-collab/SKILL.md +181 -0
  45. package/skills/maestro-companion/SKILL.md +536 -0
  46. package/skills/maestro-composer/SKILL.md +192 -0
  47. package/skills/maestro-execute/SKILL.md +193 -0
  48. package/skills/maestro-fork/SKILL.md +104 -0
  49. package/skills/maestro-grill/SKILL.md +151 -0
  50. package/skills/maestro-guard/SKILL.md +124 -0
  51. package/skills/maestro-help/SKILL.md +328 -0
  52. package/skills/maestro-impeccable/SKILL.md +302 -0
  53. package/skills/maestro-init/SKILL.md +151 -0
  54. package/skills/maestro-merge/SKILL.md +90 -0
  55. package/skills/maestro-milestone-audit/SKILL.md +117 -0
  56. package/skills/maestro-milestone-complete/SKILL.md +133 -0
  57. package/skills/maestro-milestone-release/SKILL.md +131 -0
  58. package/skills/maestro-next/SKILL.md +269 -0
  59. package/skills/maestro-overlay/SKILL.md +203 -0
  60. package/skills/maestro-plan/SKILL.md +194 -0
  61. package/skills/maestro-player/SKILL.md +184 -0
  62. package/skills/maestro-quick/SKILL.md +117 -0
  63. package/skills/maestro-ralph/SKILL.md +905 -0
  64. package/skills/maestro-ralph-cli/SKILL.md +976 -0
  65. package/skills/maestro-ralph-cli-execute/SKILL.md +229 -0
  66. package/skills/maestro-ralph-execute/SKILL.md +409 -0
  67. package/skills/maestro-ralph-v2/SKILL.md +1198 -0
  68. package/skills/maestro-roadmap/SKILL.md +157 -0
  69. package/skills/maestro-swarm-workflow/SKILL.md +272 -0
  70. package/skills/maestro-tools-execute/SKILL.md +143 -0
  71. package/skills/maestro-tools-register/SKILL.md +192 -0
  72. package/skills/maestro-ui-codify/SKILL.md +127 -0
  73. package/skills/maestro-universal-workflow/SKILL.md +622 -0
  74. package/skills/maestro-update/SKILL.md +156 -0
  75. package/skills/manage-codebase-rebuild/SKILL.md +111 -0
  76. package/skills/manage-drift-realign/SKILL.md +159 -0
  77. package/skills/manage-harvest/SKILL.md +121 -0
  78. package/skills/manage-issue/SKILL.md +88 -0
  79. package/skills/manage-issue-discover/SKILL.md +104 -0
  80. package/skills/manage-kg-extractors/SKILL.md +147 -0
  81. package/skills/manage-knowhow/SKILL.md +102 -0
  82. package/skills/manage-knowhow-capture/SKILL.md +109 -0
  83. package/skills/manage-knowledge-audit/SKILL.md +147 -0
  84. package/skills/manage-status/SKILL.md +80 -0
  85. package/skills/manage-wiki/SKILL.md +104 -0
  86. package/skills/odyssey-debug/SKILL.md +344 -0
  87. package/skills/odyssey-improve/SKILL.md +423 -0
  88. package/skills/odyssey-planex/SKILL.md +542 -0
  89. package/skills/odyssey-review-test-fix/SKILL.md +392 -0
  90. package/skills/odyssey-ui/SKILL.md +388 -0
  91. package/skills/prompt-generator/SKILL.md +470 -0
  92. package/skills/quality-auto-test/SKILL.md +168 -0
  93. package/skills/quality-debug/SKILL.md +176 -0
  94. package/skills/quality-refactor/SKILL.md +108 -0
  95. package/skills/quality-retrospective/SKILL.md +134 -0
  96. package/skills/quality-review/SKILL.md +169 -0
  97. package/skills/quality-sync/SKILL.md +90 -0
  98. package/skills/quality-test/SKILL.md +183 -0
  99. package/skills/scholar-anti-ai-writing/SKILL.md +173 -0
  100. package/skills/scholar-anti-ai-writing/references/patterns-chinese.md +242 -0
  101. package/skills/scholar-anti-ai-writing/references/patterns-english.md +242 -0
  102. package/skills/scholar-citation-verify/SKILL.md +166 -0
  103. package/skills/scholar-citation-verify/references/api-usage.md +372 -0
  104. package/skills/scholar-citation-verify/references/common-errors.md +384 -0
  105. package/skills/scholar-citation-verify/references/verification-rules.md +399 -0
  106. package/skills/scholar-experiment/SKILL.md +321 -0
  107. package/skills/scholar-ideation/SKILL.md +288 -0
  108. package/skills/scholar-latex-organizer/SKILL.md +186 -0
  109. package/skills/scholar-publish/SKILL.md +220 -0
  110. package/skills/scholar-rebuttal-pro/README.md +313 -0
  111. package/skills/scholar-rebuttal-pro/SKILL.md +511 -0
  112. package/skills/scholar-review/SKILL.md +227 -0
  113. package/skills/scholar-thesis-docx/README.md +111 -0
  114. package/skills/scholar-thesis-docx/README_EN.md +108 -0
  115. package/skills/scholar-thesis-docx/SKILL.md +212 -0
  116. package/skills/scholar-thesis-docx/references/failure-patterns-and-quality-gates.md +178 -0
  117. package/skills/scholar-thesis-docx/references/figure-and-code-rules.md +33 -0
  118. package/skills/scholar-thesis-docx/references/paper-format-workflow.md +68 -0
  119. package/skills/scholar-thesis-docx/references/script-usage.md +157 -0
  120. package/skills/scholar-thesis-docx/scripts/audit_docx_ooxml.py +429 -0
  121. package/skills/scholar-thesis-docx/scripts/check_word_com.ps1 +50 -0
  122. package/skills/scholar-thesis-docx/scripts/export_word_pdf.ps1 +62 -0
  123. package/skills/scholar-thesis-docx/scripts/normalize_word_styles.ps1 +498 -0
  124. package/skills/scholar-thesis-docx/scripts/render_mermaid_figure.ps1 +148 -0
  125. package/skills/scholar-writing/SKILL.md +296 -0
  126. package/skills/security-audit/SKILL.md +244 -0
  127. package/skills/skill-generator/SKILL.md +472 -0
  128. package/skills/skill-iter-tune/SKILL.md +382 -0
  129. package/skills/skill-simplify/SKILL.md +63 -0
  130. package/skills/skill-tuning/SKILL.md +174 -0
  131. package/skills/spec-add/SKILL.md +105 -0
  132. package/skills/spec-load/SKILL.md +98 -0
  133. package/skills/spec-remove/SKILL.md +74 -0
  134. package/skills/spec-setup/SKILL.md +75 -0
  135. package/skills/team-adversarial-swarm/SKILL.md +233 -0
  136. package/skills/team-adversarial-swarm/scripts/__pycache__/pheromone.cpython-313.pyc +0 -0
  137. package/skills/team-adversarial-swarm/scripts/__pycache__/scoring.cpython-313.pyc +0 -0
  138. package/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  139. package/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  140. package/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  141. package/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  142. package/skills/team-arch-opt/SKILL.md +158 -0
  143. package/skills/team-brainstorm/SKILL.md +171 -0
  144. package/skills/team-coordinate/SKILL.md +266 -0
  145. package/skills/team-designer/SKILL.md +160 -0
  146. package/skills/team-executor/SKILL.md +189 -0
  147. package/skills/team-frontend/SKILL.md +136 -0
  148. package/skills/team-frontend-debug/SKILL.md +198 -0
  149. package/skills/team-interactive-craft/SKILL.md +141 -0
  150. package/skills/team-issue/SKILL.md +171 -0
  151. package/skills/team-lifecycle-v4/SKILL.md +209 -0
  152. package/skills/team-motion-design/SKILL.md +142 -0
  153. package/skills/team-perf-opt/SKILL.md +175 -0
  154. package/skills/team-planex/SKILL.md +137 -0
  155. package/skills/team-quality-assurance/SKILL.md +147 -0
  156. package/skills/team-review/SKILL.md +147 -0
  157. package/skills/team-roadmap-dev/SKILL.md +169 -0
  158. package/skills/team-swarm/SKILL.md +178 -0
  159. package/skills/team-swarm/scripts/aco.py +473 -0
  160. package/skills/team-swarm/scripts/pheromone.py +144 -0
  161. package/skills/team-swarm/scripts/scoring.py +92 -0
  162. package/skills/team-swarm/scripts/test_aco.py +475 -0
  163. package/skills/team-tech-debt/SKILL.md +128 -0
  164. package/skills/team-testing/SKILL.md +143 -0
  165. package/skills/team-ui-polish/SKILL.md +141 -0
  166. package/skills/team-uidesign/SKILL.md +144 -0
  167. package/skills/team-ultra-analyze/SKILL.md +173 -0
  168. package/skills/team-ux-improve/SKILL.md +151 -0
  169. package/skills/team-visual-a11y/SKILL.md +156 -0
  170. package/skills/workflow-skill-designer/SKILL.md +496 -0
  171. package/src/extension/index.ts +222 -0
  172. package/src/extension/schemas.ts +131 -0
  173. package/src/providers/cli-tools-loader.ts +74 -0
  174. package/src/providers/provider-registry.ts +130 -0
  175. package/src/tools/delegate.ts +85 -0
  176. package/src/tools/explore.ts +134 -0
  177. package/src/tools/moa.ts +213 -0
  178. package/src/tools/status.ts +99 -0
  179. package/src/tools/wait.ts +166 -0
@@ -0,0 +1,536 @@
1
+ ---
2
+ name: maestro-companion
3
+ description: "Knowledge companion — load context, record companion doc, capture insights, route to skills Arguments: [before|note|after|route] [--task <description>] [--type <task_type>] [--category <cat>]"
4
+ allowed-tools: Read Write Edit Bash Glob Grep Skill AskUserQuestion
5
+ ---
6
+
7
+ <purpose>
8
+ Side-car utility for any task: load knowledge context (before), record structured entries (note),
9
+ promote insights to spec/knowhow (after), or route to next command (route).
10
+ </purpose>
11
+
12
+ <context>
13
+ $ARGUMENTS — mode + optional flags.
14
+
15
+ **Mode detection priority:**
16
+ 1. Explicit `before` / `note` / `after` / `route`
17
+ 2. Intent text that is not a mode keyword → `route`
18
+ 3. No arguments → auto-detect (`git status` has changes → `after`, else → `before`)
19
+
20
+ **Flags:**
21
+ - `--task <description>` — Current task description (for targeted knowledge loading and doc title)
22
+ - `--type <task_type>` — Task type for field template selection (see task types below)
23
+ - `--category <cat>` — Spec category filter: coding / arch / test / review / debug / learning / ui
24
+
25
+ **Task types** (determines which recording sections are active):
26
+
27
+ | Type | Description | Key sections |
28
+ |------|-------------|--------------|
29
+ | `implement` | Feature development, code writing | working_files, dependencies, decisions, tests_affected |
30
+ | `debug` | Bug investigation, root cause analysis | symptoms, hypotheses, evidence, root_cause, fix_applied |
31
+ | `analyze` | Code/architecture/performance analysis | scope, findings, risks, recommendations |
32
+ | `design` | Architecture/UI/API design | constraints, alternatives, trade_offs, chosen_approach |
33
+ | `plan` | Task decomposition, roadmap planning | goals, breakdown, estimates, dependencies |
34
+ | `review` | Code review, PR review | files_reviewed, findings, severity_counts, verdict |
35
+ | `test` | Test writing, UAT, coverage expansion | coverage_before, coverage_after, gaps, test_files |
36
+ | `refactor` | Code restructuring, tech debt | affected_modules, before_after, breaking_changes |
37
+ | `learn` | Codebase exploration, knowledge building | questions, answers, mental_model, references |
38
+ | `general` | Default / unclassified | (all universal sections) |
39
+
40
+ Auto-detection: if `--type` not provided, infer from `--task` description keywords.
41
+
42
+ **Output boundary**: ALL file writes MUST target `.workflow/.scratchpad/` (companion docs + `.companion-active` pointer) only. Promotion writes (spec/knowhow) are delegated to `spec-add` / `manage-knowhow-capture` skills. NEVER modify source code, `.workflow/state.json`, or files outside `.workflow/.scratchpad/`.
43
+
44
+ **Companion document:**
45
+ - Path: `.workflow/.scratchpad/companion-{YYYYMMDD-HHmmss}.md`
46
+ - Active doc tracking: `.workflow/.scratchpad/.companion-active` (stores path of current companion doc)
47
+ - Format: YAML frontmatter (rich metadata) + typed sections + timestamped entries
48
+ </context>
49
+
50
+ <invariants>
51
+ 1. **No session creation** — companion NEVER creates workflow sessions, NEVER writes to state.json
52
+ 2. **Side-car only** — companion MUST NOT modify source code or execute implementation tasks; it is strictly a knowledge loading + recording utility
53
+ 3. **One active doc** — only one `.companion-active` pointer SHALL exist at a time; creating a new companion doc MUST clear any stale pointer
54
+ 4. **Append-only entries** — note mode MUST append entries; NEVER overwrite or reorder existing entries
55
+ 5. **Promotion via delegation** — spec/knowhow promotion MUST route through `spec-add` / `manage-knowhow-capture` skills; companion NEVER writes directly to `.workflow/specs/` or `.workflow/knowhow/`
56
+ 6. **Type-template integrity** — context template sections MUST match the resolved `task_type`; NEVER mix templates from different types
57
+ </invariants>
58
+
59
+ <state_machine>
60
+
61
+ <states>
62
+ S_PARSE — Parse arguments, detect mode, resolve task type
63
+ S_BEFORE — Load knowledge context, create companion doc with typed template
64
+ S_NOTE — Append structured entry to active companion doc
65
+ S_AFTER — Review companion doc, populate outcome, promote entries, suggest next steps
66
+ S_ROUTE — Skill routing via maestro-next
67
+ </states>
68
+
69
+ <transitions>
70
+
71
+ S_PARSE:
72
+ → S_BEFORE WHEN: mode == "before" OR (no args AND no uncommitted changes)
73
+ → S_NOTE WHEN: mode == "note"
74
+ → S_AFTER WHEN: mode == "after" OR (no args AND has uncommitted changes)
75
+ → S_ROUTE WHEN: mode == "route" OR intent text present
76
+
77
+ </transitions>
78
+
79
+ </state_machine>
80
+
81
+ <execution>
82
+
83
+ ## S_BEFORE — Knowledge Loading + Companion Doc Creation
84
+
85
+ Execute in order, skip unavailable steps:
86
+
87
+ ### 1. Load specs
88
+
89
+ ```bash
90
+ # With --category: load by category
91
+ maestro load --type spec --category <cat>
92
+
93
+ # With --task: load by keyword extracted from task description
94
+ maestro load --type spec --keyword <extracted_keyword>
95
+
96
+ # No flags: load coding (most universal)
97
+ maestro load --type spec --category coding
98
+ ```
99
+
100
+ Display loaded rules summary (entry count + key rule names).
101
+
102
+ ### 2. Browse knowhow index
103
+
104
+ ```bash
105
+ # List recent knowhow entries
106
+ maestro knowhow list --store workflow
107
+
108
+ # With --task: search relevant entries
109
+ maestro search --type knowhow "<task_keyword>"
110
+ ```
111
+
112
+ Display available knowhow entries (ID + title). Hint: `maestro load --type knowhow --id <id>` for details.
113
+
114
+ ### 3. Check codebase index
115
+
116
+ ```bash
117
+ ls .workflow/codebase/doc-index.json
118
+ ```
119
+
120
+ - Exists → display "Codebase docs ready, last updated: {timestamp}"
121
+ - Missing → suggest `/manage-codebase-rebuild`
122
+ - Stale (>7 days) → suggest `/quality-sync`
123
+
124
+ ### 4. Create companion document
125
+
126
+ Create `.workflow/.scratchpad/` if needed. Resolve task type from `--type` flag or infer from `--task` keywords.
127
+
128
+ Write companion doc with the full field template:
129
+
130
+ ```markdown
131
+ ---
132
+ # === Identity ===
133
+ task: "{task_description or 'Untitled task'}"
134
+ task_type: "{resolved type: implement|debug|analyze|design|plan|review|test|refactor|learn|general}"
135
+ created: "{ISO timestamp}"
136
+ status: active
137
+
138
+ # === Context Loaded ===
139
+ specs_loaded: "{category or 'coding'}"
140
+ specs_count: {N}
141
+ knowhow_searched: "{keyword or 'none'}"
142
+ knowhow_available: {M}
143
+ codebase_index: "{ready|missing|stale}"
144
+ branch: "{current git branch}"
145
+ phase: "{current phase from state.json or 'none'}"
146
+ milestone: "{current milestone from state.json or 'none'}"
147
+
148
+ # === Scope ===
149
+ working_files: []
150
+ dependencies: []
151
+ related_artifacts: []
152
+
153
+ # === Outcome (populated by after mode) ===
154
+ outcome: ""
155
+ files_changed: []
156
+ promoted_specs: 0
157
+ promoted_knowhow: 0
158
+ follow_up: []
159
+ completed: ""
160
+ ---
161
+
162
+ # Companion Doc — {task_description}
163
+
164
+ > `/maestro-companion note "<content>"` — add entries
165
+ > `/maestro-companion after` — review, promote, close
166
+
167
+ ## Context
168
+
169
+ {Type-specific context section — see templates below}
170
+
171
+ ## Entries
172
+
173
+ ## Summary
174
+ ```
175
+
176
+ **Type-specific context templates** (written into `## Context`):
177
+
178
+ **implement:**
179
+ ```markdown
180
+ ### Working Files
181
+ | File | Role | Status |
182
+ |------|------|--------|
183
+
184
+ ### Dependencies
185
+ - (modules, APIs, or services this task depends on)
186
+
187
+ ### Decisions
188
+ | # | Decision | Rationale | Alternatives Considered |
189
+ |---|----------|-----------|------------------------|
190
+
191
+ ### Tests Affected
192
+ - (test files that need creation or update)
193
+ ```
194
+
195
+ **debug:**
196
+ ```markdown
197
+ ### Symptoms
198
+ - (observable behavior vs expected behavior)
199
+
200
+ ### Hypotheses
201
+ | # | Hypothesis | Status | Evidence |
202
+ |---|-----------|--------|----------|
203
+
204
+ ### Evidence Trail
205
+ | Time | Source | Type | Finding |
206
+ |------|--------|------|---------|
207
+
208
+ ### Root Cause
209
+ - (populated when identified)
210
+
211
+ ### Fix Applied
212
+ - (description of fix, files changed)
213
+ ```
214
+
215
+ **analyze:**
216
+ ```markdown
217
+ ### Scope
218
+ - (what is being analyzed and boundaries)
219
+
220
+ ### Findings
221
+ | # | Finding | Severity | Location |
222
+ |---|---------|----------|----------|
223
+
224
+ ### Risks
225
+ - (identified risks or concerns)
226
+
227
+ ### Recommendations
228
+ - (actionable recommendations)
229
+ ```
230
+
231
+ **design:**
232
+ ```markdown
233
+ ### Constraints
234
+ - (hard limits, requirements, compatibility needs)
235
+
236
+ ### Alternatives
237
+ | # | Approach | Pros | Cons |
238
+ |---|----------|------|------|
239
+
240
+ ### Trade-offs
241
+ - (key trade-off decisions and rationale)
242
+
243
+ ### Chosen Approach
244
+ - (selected design with justification)
245
+ ```
246
+
247
+ **plan:**
248
+ ```markdown
249
+ ### Goals
250
+ - (what success looks like)
251
+
252
+ ### Breakdown
253
+ | # | Task | Estimate | Depends On | Status |
254
+ |---|------|----------|------------|--------|
255
+
256
+ ### Dependencies
257
+ - (external dependencies, blockers, prerequisites)
258
+ ```
259
+
260
+ **review:**
261
+ ```markdown
262
+ ### Files Reviewed
263
+ | File | Lines | Findings |
264
+ |------|-------|----------|
265
+
266
+ ### Findings
267
+ | # | Severity | Category | File:Line | Description |
268
+ |---|----------|----------|-----------|-------------|
269
+
270
+ ### Verdict
271
+ - (pass / pass-with-concerns / fail)
272
+ ```
273
+
274
+ **test:**
275
+ ```markdown
276
+ ### Coverage
277
+ - Before: {%}
278
+ - After: {%}
279
+ - Target: {%}
280
+
281
+ ### Test Files
282
+ | File | Type | Tests Added | Status |
283
+ |------|------|------------|--------|
284
+
285
+ ### Gaps
286
+ - (uncovered paths or scenarios)
287
+ ```
288
+
289
+ **refactor:**
290
+ ```markdown
291
+ ### Affected Modules
292
+ - (modules being restructured)
293
+
294
+ ### Before / After
295
+ | Aspect | Before | After |
296
+ |--------|--------|-------|
297
+
298
+ ### Breaking Changes
299
+ - (API or behavior changes that affect consumers)
300
+ ```
301
+
302
+ **learn:**
303
+ ```markdown
304
+ ### Questions
305
+ | # | Question | Answered | Source |
306
+ |---|----------|----------|--------|
307
+
308
+ ### Mental Model
309
+ - (evolving understanding of how it works)
310
+
311
+ ### References
312
+ - (files, docs, wiki entries consulted)
313
+ ```
314
+
315
+ **general:**
316
+ ```markdown
317
+ ### Notes
318
+ - (general working notes)
319
+ ```
320
+
321
+ Write the companion doc path to `.workflow/.scratchpad/.companion-active`.
322
+
323
+ ### 5. Output summary card
324
+
325
+ ```
326
+ Knowledge context loaded
327
+ Spec: {N} rules ({category})
328
+ Knowhow: {M} entries available
329
+ Codebase: {status}
330
+ Doc: {companion_doc_path} [{task_type}]
331
+
332
+ Mid-task commands:
333
+ /maestro-companion note "finding or decision"
334
+ /maestro-companion note --file src/auth.ts "changed token validation"
335
+ /spec-load --keyword <keyword>
336
+ maestro search "<query>"
337
+ ```
338
+
339
+ ---
340
+
341
+ ## S_NOTE — Append Structured Entry to Companion Doc
342
+
343
+ ### 1. Locate active companion doc
344
+
345
+ Read `.workflow/.scratchpad/.companion-active` to get the doc path.
346
+ If missing or file not found → create a new companion doc (same as S_BEFORE step 4, minimal — no spec/knowhow loading).
347
+
348
+ ### 2. Parse entry content and flags
349
+
350
+ Parse $ARGUMENTS after `note` keyword:
351
+ - `--file <path>` — associate entry with a specific file (appended to frontmatter `working_files`)
352
+ - `--severity <level>` — for findings: critical / high / medium / low
353
+ - Remaining text = entry content
354
+
355
+ ### 3. Classify entry type
356
+
357
+ Auto-classify from content signals:
358
+
359
+ | Content signal | Type tag |
360
+ |---------------|----------|
361
+ | "decided/decision/chose/picked/went with" | `decision` |
362
+ | "pattern/convention/rule/always/never/must" | `spec-candidate` |
363
+ | "pitfall/gotcha/careful/warning/trap/beware" | `pitfall` |
364
+ | "learned/realized/discovered/understood/turns out" | `insight` |
365
+ | "hypothesis/suspect/might be/could be" | `hypothesis` |
366
+ | "found bug/root cause/because of/caused by" | `evidence` |
367
+ | "risk/concern/worry/might break" | `risk` |
368
+ | "todo/need to/should also/follow up/remaining" | `todo` |
369
+ | "question/why does/how does/unclear" | `question` |
370
+ | "blocked/stuck/can't/impossible" | `blocker` |
371
+ | Default | `note` |
372
+
373
+ ### 4. Append entry
374
+
375
+ Append to the companion doc under `## Entries`:
376
+
377
+ ```markdown
378
+ ### [{type}] {HH:mm} — {first line of content}
379
+
380
+ {full content}
381
+
382
+ {if --file: **File:** `{path}`}
383
+ {if --severity: **Severity:** {level}}
384
+ ```
385
+
386
+ ### 5. Update frontmatter fields
387
+
388
+ - If `--file` provided and not already in `working_files` → append to `working_files`
389
+ - If type is `decision` → also append row to `### Decisions` table (if implement/design type doc)
390
+ - If type is `hypothesis` → also append row to `### Hypotheses` table (if debug type doc)
391
+ - If type is `evidence` → also append row to `### Evidence Trail` table (if debug type doc)
392
+ - If type is `risk` → also append to `### Risks` list (if analyze/design type doc)
393
+ - If type is `question` → also append row to `### Questions` table (if learn type doc)
394
+
395
+ ### 6. Confirm
396
+
397
+ ```
398
+ [{type}] entry added to companion doc
399
+ /maestro-companion note "..." — add more
400
+ /maestro-companion after — review & promote
401
+ ```
402
+
403
+ ---
404
+
405
+ ## S_AFTER — Review Companion Doc + Populate Outcome + Promote Entries + Route
406
+
407
+ ### 1. Load companion doc
408
+
409
+ Read `.workflow/.scratchpad/.companion-active` → read the companion doc.
410
+ If no active doc or doc is empty → skip to step 4 (accumulation reminder).
411
+
412
+ ### 2. Populate outcome fields
413
+
414
+ Collect task outcome data:
415
+
416
+ ```bash
417
+ # Detect files changed since companion doc creation
418
+ # Use git log --since for time-based filtering, then git diff for the range
419
+ git log --since="{companion_created_timestamp}" --format="%H" -1 # get oldest commit in range
420
+ git diff --name-only {oldest_commit}..HEAD # diff from that commit to HEAD
421
+ # Fallback if no commits since timestamp: git diff --name-only HEAD
422
+ ```
423
+
424
+ Update frontmatter:
425
+ - `files_changed` — from git diff
426
+ - `completed` — current ISO timestamp
427
+ - `status` — `completed`
428
+
429
+ Display entry summary:
430
+ ```
431
+ Companion doc review — {task_type}
432
+ Entries: {total} ({by type breakdown})
433
+ Files: {files_changed count} changed
434
+ Duration: {elapsed since created}
435
+
436
+ Promotable entries:
437
+ {list of decision/spec-candidate/pitfall/insight entries}
438
+ ```
439
+
440
+ ### 3. Promote entries
441
+
442
+ If promotable entries exist, AskUserQuestion:
443
+
444
+ - Option 1: "Promote to spec" — short coding/arch/test constraint
445
+ - Option 2: "Promote to knowhow" — detailed recipe/template/decision/tip
446
+ - Option 3: "Promote both" — spec index entry + knowhow document
447
+ - Option 4: "Skip — nothing to promote"
448
+
449
+ **Routing by selection:**
450
+
451
+ | Selection | Action |
452
+ |-----------|--------|
453
+ | Spec | `Skill("spec-add", args)` — guide user through category + content |
454
+ | Knowhow | `Skill("manage-knowhow-capture", args)` — guide through type + content |
455
+ | Both | `Skill("spec-add")` first, then `Skill("manage-knowhow-capture")` |
456
+ | Skip | Proceed to step 4 |
457
+
458
+ Update frontmatter: `promoted_specs`, `promoted_knowhow` counts.
459
+
460
+ Extract any `todo` entries → write to `follow_up` in frontmatter.
461
+
462
+ Clear `.workflow/.scratchpad/.companion-active`.
463
+
464
+ ### 4. Output accumulation reminder + routing
465
+
466
+ ```
467
+ Knowledge accumulation reminders:
468
+ Reusable pattern found? /spec-add <category> "title" "content" --description "summary"
469
+ Solved a complex problem? /manage-knowhow-capture recipe "description"
470
+ Made an architecture decision? /manage-knowhow-capture decision "description"
471
+ Discovered a useful trick? /manage-knowhow-capture tip "content"
472
+
473
+ Next steps:
474
+ /maestro-next — recommend next command
475
+ /maestro "<intent>" — route intent to full workflow
476
+ /manage-status — view project dashboard
477
+ ```
478
+
479
+ ---
480
+
481
+ ## S_ROUTE — Skill Routing
482
+
483
+ ### 1. Parse intent
484
+
485
+ Extract intent text from $ARGUMENTS after removing the `route` keyword.
486
+
487
+ ### 2. Delegate to maestro-next
488
+
489
+ ```
490
+ Skill("maestro-next", "<intent_text>")
491
+ ```
492
+
493
+ Delegates intent routing to maestro-next, which recommends the best single command.
494
+
495
+ </execution>
496
+
497
+ <error_codes>
498
+ | Code | Severity | Condition | Recovery |
499
+ |------|----------|-----------|----------|
500
+ | W001 | warning | `.workflow/specs/` not initialized | Suggest `/spec-setup` |
501
+ | W002 | warning | `.workflow/knowhow/` is empty | Normal, skip knowhow index |
502
+ | W003 | warning | `.workflow/codebase/` does not exist | Suggest `/manage-codebase-rebuild` |
503
+ | W004 | warning | No active companion doc found (note/after mode) | Create new doc or skip |
504
+ </error_codes>
505
+
506
+ <success_criteria>
507
+ - [ ] Mode correctly detected (before/note/after/route)
508
+ - [ ] Task type resolved from --type flag or inferred from --task keywords
509
+ - [ ] before: spec + knowhow + codebase indexes loaded or hints given
510
+ - [ ] before: companion doc created with full YAML frontmatter (identity + context + scope + outcome placeholders)
511
+ - [ ] before: type-specific context template written (matching task_type)
512
+ - [ ] before: active doc path written to `.companion-active`
513
+ - [ ] before: summary card output with mid-task command hints
514
+ - [ ] note: active companion doc located and entry appended with type tag
515
+ - [ ] note: entry type auto-classified from content signals (11 type tags)
516
+ - [ ] note: --file flag updates working_files in frontmatter
517
+ - [ ] note: typed entries cross-posted to matching context tables (decisions→Decisions, hypothesis→Hypotheses, etc.)
518
+ - [ ] after: companion doc entries reviewed and promotable items identified
519
+ - [ ] after: outcome fields populated (files_changed, completed, status)
520
+ - [ ] after: AskUserQuestion routes to spec-add or manage-knowhow-capture
521
+ - [ ] after: todo entries extracted to follow_up field
522
+ - [ ] after: companion doc marked completed, active pointer cleared
523
+ - [ ] after: accumulation reminder + next-step routing displayed
524
+ - [ ] route: intent correctly forwarded to maestro-next
525
+ - [ ] No session created, no state.json modified
526
+ </success_criteria>
527
+
528
+ <completion>
529
+ ### Next-step routing
530
+ | Condition | Suggestion |
531
+ |-----------|-----------|
532
+ | Reusable pattern found | `/spec-add <category> "title" "content"` |
533
+ | Solved complex problem | `/manage-knowhow-capture recipe "description"` |
534
+ | Architecture decision made | `/manage-knowhow-capture decision "description"` |
535
+ | Want next command recommendation | `/maestro-next` |
536
+ </completion>