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
@@ -44,9 +44,10 @@ You are a collaborative planner that works within a pre-allocated task ID range.
44
44
  "type": "feature",
45
45
  "priority": "medium",
46
46
  "effort": "medium",
47
- "action": "Implement",
47
+ "action": "<concrete action with exact values: function signatures, config keys, import paths>",
48
48
  "scope": "<module path>",
49
49
  "focus_paths": [],
50
+ "read_first": ["src/module/existing.ts", "src/types/shared.ts"],
50
51
  "depends_on": [],
51
52
  "parallel_group": null,
52
53
  "convergence": {
@@ -118,6 +119,8 @@ You are a collaborative planner that works within a pre-allocated task ID range.
118
119
  - Task files must use `convergence.criteria` (array of testable strings), not `done_when`
119
120
  - files must use `[{path, action, target, change}]` format, not `["path"]`
120
121
  - Each task must have convergence.criteria with min 2 testable conditions
122
+ - Each task must have `read_first[]` — files the executor MUST read before implementation
123
+ - `action` must contain concrete values (function signatures, config keys, import paths), not just a verb
121
124
  - Task definitions follow the same schema as workflow-planner output
122
125
  - If you discover scope that belongs to another planner's range, note it in plan-note.md
123
126
  - Do not modify other planners' task files
@@ -32,7 +32,9 @@ You validate the quality of execution plans before they proceed to implementatio
32
32
  - Each criterion must reference a concrete artifact, output, or behavior
33
33
  - Criteria should be sufficient to prove the task is complete
34
34
  7. **Check files array** -- Verify each task's `files[]` array is consistent with its description
35
- 8. **Report** -- Write check report with issues or approval
35
+ 8. **Check read_first** -- Verify each task has `read_first[]` containing: the file being modified + source-of-truth files. Missing or empty `read_first` is a critical issue.
36
+ 9. **Check action concreteness** -- Verify each task's `action` contains concrete values (function signatures, config keys, import paths), not vague verbs like "Implement" or references like "align X with Y"
37
+ 10. **Report** -- Write check report with issues or approval
36
38
 
37
39
  ### Revision Loop (max 3 rounds)
38
40
  - If issues found: write report with specific issues and suggested fixes
@@ -74,6 +76,14 @@ Check report written to the output location above:
74
76
  ## Files Array Consistency
75
77
  - TASK-006: description mentions "update config" but files[] does not include any config file
76
78
 
79
+ ## Read First Completeness
80
+ - TASK-001 read_first: Missing — must include src/auth.ts (file being modified) + src/types/auth.ts (type definitions)
81
+ - TASK-003 read_first: Has target file but missing source-of-truth reference
82
+
83
+ ## Action Concreteness
84
+ - TASK-002 action: Too vague ("Implement auth") — should include: "Add verifyToken(token: string): Promise<AuthPayload> to src/auth.ts, import from jsonwebtoken"
85
+ - TASK-005 action: Contains "align with existing pattern" — must specify the exact target state
86
+
77
87
  ## Summary
78
88
  <Overall assessment>
79
89
  ```
@@ -94,9 +94,10 @@ When invoked with `quick` flag:
94
94
  "type": "feature",
95
95
  "priority": "medium",
96
96
  "effort": "medium",
97
- "action": "Implement",
97
+ "action": "<concrete action with exact values: function signatures, config keys, import paths>",
98
98
  "scope": "<module path>",
99
99
  "focus_paths": ["src/tools/"],
100
+ "read_first": ["src/tools/existing-tool.ts", "src/types/tool.ts"],
100
101
  "depends_on": [],
101
102
  "parallel_group": null,
102
103
  "convergence": {
@@ -166,6 +167,8 @@ These rules prevent over-splitting that wastes tokens on unnecessary agent spawn
166
167
  - Each task must be substantial (15-60 min of work); group related changes, avoid file-per-task
167
168
  - Each task must have convergence.criteria (min 2 testable conditions)
168
169
  - convergence.criteria must be specific and testable (not "works correctly")
170
+ - Each task must have `read_first[]` — files the executor MUST read before implementation (the file being modified + source-of-truth files)
171
+ - `action` must contain concrete values (function signatures, config keys, import paths), not just a verb like "Implement"
169
172
  - files must use array format `[{path, action, target, change}]`
170
173
  - Wave ordering must respect dependencies (no task before its dependency)
171
174
  - Task descriptions must be clear enough for the executor to implement without ambiguity
@@ -52,10 +52,11 @@ $ARGUMENTS — user intent text, or special keywords.
52
52
  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`
53
53
  5. **status.json 唯一真源** — 不生成 `goal-checklist.md` 或外部清单
54
54
  6. **执行步骤统一通过 `maestro ralph next` 加载** — `command_scope`/`command_path` 由 `maestro ralph skills --json --quiet` 预校验(project 覆盖 global);decision 节点不走 CLI,走 `invoke_skill("maestro-ralph")` handoff
55
- 7. **Topology awareness** — chain catalog 含 brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / ...;scope_verdict 由 ralph 在 `post-analyze-scope` 决定
56
- 8. **D-007 milestone 反查**数字 phase `milestone_id` `state.json.milestones[].phase_slugs` 反查
57
- 9. **每个 step 必须 `completion_confirmed: true`** `maestro ralph complete N --status DONE|DONE_WITH_CONCERNS` 写入
58
- 10. **schema** `ralph_protocol_version: "1"` 标记 CLI-driven session;新增字段全部可选
55
+ 7. **Topology awareness** — chain catalog 含 grill / brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / ...;scope_verdict 由 ralph 在 `post-analyze-scope` 决定
56
+ 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
57
+ 9. **D-007 milestone 反查** 数字 phase `milestone_id` `state.json.milestones[].phase_slugs` 反查
58
+ 10. **每个 step 必须 `completion_confirmed: true`** — 由 `maestro ralph complete N --status DONE|DONE_WITH_CONCERNS` 写入
59
+ 11. **schema** — `ralph_protocol_version: "1"` 标记 CLI-driven session;新增字段全部可选
59
60
  </invariants>
60
61
 
61
62
  <state_machine>
@@ -134,6 +135,7 @@ S_FALLBACK:
134
135
  1. Read `~/.maestro/workflows/maestro.md` from deferred_reading
135
136
  2. Match intent to task_type via chain catalog (semantic)
136
137
  3. Select chain from chainMap,遵循拓扑约束:
138
+ - 压力测试/拷问/验证假设/grill/stress-test → `grill`(**-y 模式跳过 grill,直接走 brainstorm**)
137
139
  - 头脑风暴/探索 → `brainstorm`
138
140
  - 正式规格/spec-generate/7-phase → `blueprint`
139
141
  - 项目初始化 → `init`
@@ -218,7 +220,8 @@ S_FALLBACK:
218
220
  ### Success Criteria
219
221
 
220
222
  - [ ] Intent classified with task_type, complexity, clarity_score
221
- - [ ] Chain catalog 覆盖 brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / quality pipeline
223
+ - [ ] Chain catalog 覆盖 grill / brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / quality pipeline
224
+ - [ ] `-y` 模式不触发 grill(交互式压力测试不支持自动模式,跳过直接走 brainstorm)
222
225
  - [ ] D-007: 数字 phase 步骤的 `milestone_id` 通过 `state.json.milestones[].phase_slugs` 反查
223
226
  - [ ] macro analyze 后跟 `decision:post-analyze-scope`(由 ralph 评估 scope_verdict 决定下游链路)
224
227
  - [ ] 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 → invoke_skill({ skill: "maestro-blueprint", args: "--from brainstorm:{artifact_id}" })
87
87
  - Project initialized, quick roadmap → invoke_skill({ skill: "maestro-roadmap", args: "--from brainstorm:{artifact_id}" })
88
88
  - Need deeper analysis first → invoke_skill({ skill: "maestro-analyze", args: "{topic} --from brainstorm:{artifact_id}" })
89
+ - Need stress-testing first → invoke_skill({ skill: "maestro-grill", 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,533 @@
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_file
7
+ - write_file
8
+ - edit_file
9
+ - shell
10
+ - find_files
11
+ - search
12
+ - invoke_skill
13
+ - ask_user
14
+ ---
15
+ <!-- Open-standard mirror generated by scripts/build-agents-standard.mjs — do not edit; re-run after editing .claude/ source. -->
16
+
17
+
18
+ <purpose>
19
+ Task companion command — pairs with any task to provide knowledge context loading,
20
+ structured companion document recording, insight capture, and skill routing.
21
+
22
+ Does not create sessions or modify workflow state. Pure side-car utility.
23
+
24
+ Four modes:
25
+ - **before** — Pre-task: load spec + knowhow index + codebase index, create companion doc
26
+ - **note** — Mid-task: append a structured entry to the active companion doc
27
+ - **after** — Post-task: review companion doc, promote entries to spec/knowhow, suggest next steps
28
+ - **route** — Routing: recommend next skill/command based on intent
29
+
30
+ No arguments → auto-detect: uncommitted changes → `after`, else → `before`.
31
+ </purpose>
32
+
33
+ <context>
34
+ $ARGUMENTS — mode + optional flags.
35
+
36
+ **Mode detection priority:**
37
+ 1. Explicit `before` / `note` / `after` / `route`
38
+ 2. Intent text that is not a mode keyword → `route`
39
+ 3. No arguments → auto-detect (`git status` has changes → `after`, else → `before`)
40
+
41
+ **Flags:**
42
+ - `--task <description>` — Current task description (for targeted knowledge loading and doc title)
43
+ - `--type <task_type>` — Task type for field template selection (see task types below)
44
+ - `--category <cat>` — Spec category filter: coding / arch / test / review / debug / learning / ui
45
+
46
+ **Task types** (determines which recording sections are active):
47
+
48
+ | Type | Description | Key sections |
49
+ |------|-------------|--------------|
50
+ | `implement` | Feature development, code writing | working_files, dependencies, decisions, tests_affected |
51
+ | `debug` | Bug investigation, root cause analysis | symptoms, hypotheses, evidence, root_cause, fix_applied |
52
+ | `analyze` | Code/architecture/performance analysis | scope, findings, risks, recommendations |
53
+ | `design` | Architecture/UI/API design | constraints, alternatives, trade_offs, chosen_approach |
54
+ | `plan` | Task decomposition, roadmap planning | goals, breakdown, estimates, dependencies |
55
+ | `review` | Code review, PR review | files_reviewed, findings, severity_counts, verdict |
56
+ | `test` | Test writing, UAT, coverage expansion | coverage_before, coverage_after, gaps, test_files |
57
+ | `refactor` | Code restructuring, tech debt | affected_modules, before_after, breaking_changes |
58
+ | `learn` | Codebase exploration, knowledge building | questions, answers, mental_model, references |
59
+ | `general` | Default / unclassified | (all universal sections) |
60
+
61
+ Auto-detection: if `--type` not provided, infer from `--task` description keywords.
62
+
63
+ **Companion document:**
64
+ - Path: `.workflow/.scratchpad/companion-{YYYYMMDD-HHmmss}.md`
65
+ - Active doc tracking: `.workflow/.scratchpad/.companion-active` (stores path of current companion doc)
66
+ - Format: YAML frontmatter (rich metadata) + typed sections + timestamped entries
67
+ </context>
68
+
69
+ <state_machine>
70
+
71
+ <states>
72
+ S_PARSE — Parse arguments, detect mode, resolve task type
73
+ S_BEFORE — Load knowledge context, create companion doc with typed template
74
+ S_NOTE — Append structured entry to active companion doc
75
+ S_AFTER — Review companion doc, populate outcome, promote entries, suggest next steps
76
+ S_ROUTE — Skill routing via maestro-next
77
+ </states>
78
+
79
+ <transitions>
80
+
81
+ S_PARSE:
82
+ → S_BEFORE WHEN: mode == "before" OR (no args AND no uncommitted changes)
83
+ → S_NOTE WHEN: mode == "note"
84
+ → S_AFTER WHEN: mode == "after" OR (no args AND has uncommitted changes)
85
+ → S_ROUTE WHEN: mode == "route" OR intent text present
86
+
87
+ </transitions>
88
+
89
+ </state_machine>
90
+
91
+ <execution>
92
+
93
+ ## S_BEFORE — Knowledge Loading + Companion Doc Creation
94
+
95
+ Execute in order, skip unavailable steps:
96
+
97
+ ### 1. Load specs
98
+
99
+ ```bash
100
+ # With --category: load by category
101
+ maestro spec load --category <cat>
102
+
103
+ # With --task: load by keyword extracted from task description
104
+ maestro spec load --keyword <extracted_keyword>
105
+
106
+ # No flags: load coding (most universal)
107
+ maestro spec load --category coding
108
+ ```
109
+
110
+ Display loaded rules summary (entry count + key rule names).
111
+
112
+ ### 2. Browse knowhow index
113
+
114
+ ```bash
115
+ # List recent knowhow entries
116
+ maestro knowhow list --store workflow
117
+
118
+ # With --task: search relevant entries
119
+ maestro knowhow search "<task_keyword>"
120
+ ```
121
+
122
+ Display available knowhow entries (ID + title). Hint: `maestro wiki load <id>` for details.
123
+
124
+ ### 3. Check codebase index
125
+
126
+ ```bash
127
+ ls .workflow/codebase/doc-index.json
128
+ ```
129
+
130
+ - Exists → display "Codebase docs ready, last updated: {timestamp}"
131
+ - Missing → suggest `/manage-codebase-rebuild`
132
+ - Stale (>7 days) → suggest `/manage-codebase-refresh`
133
+
134
+ ### 4. Create companion document
135
+
136
+ Create `.workflow/.scratchpad/` if needed. Resolve task type from `--type` flag or infer from `--task` keywords.
137
+
138
+ Write companion doc with the full field template:
139
+
140
+ ```markdown
141
+ ---
142
+ # === Identity ===
143
+ task: "{task_description or 'Untitled task'}"
144
+ task_type: "{resolved type: implement|debug|analyze|design|plan|review|test|refactor|learn|general}"
145
+ created: "{ISO timestamp}"
146
+ status: active
147
+
148
+ # === Context Loaded ===
149
+ specs_loaded: "{category or 'coding'}"
150
+ specs_count: {N}
151
+ knowhow_searched: "{keyword or 'none'}"
152
+ knowhow_available: {M}
153
+ codebase_index: "{ready|missing|stale}"
154
+ branch: "{current git branch}"
155
+ phase: "{current phase from state.json or 'none'}"
156
+ milestone: "{current milestone from state.json or 'none'}"
157
+
158
+ # === Scope ===
159
+ working_files: []
160
+ dependencies: []
161
+ related_artifacts: []
162
+
163
+ # === Outcome (populated by after mode) ===
164
+ outcome: ""
165
+ files_changed: []
166
+ promoted_specs: 0
167
+ promoted_knowhow: 0
168
+ follow_up: []
169
+ completed: ""
170
+ ---
171
+
172
+ # Companion Doc — {task_description}
173
+
174
+ > `/maestro-companion note "<content>"` — add entries
175
+ > `/maestro-companion after` — review, promote, close
176
+
177
+ ## Context
178
+
179
+ {Type-specific context section — see templates below}
180
+
181
+ ## Entries
182
+
183
+ ## Summary
184
+ ```
185
+
186
+ **Type-specific context templates** (written into `## Context`):
187
+
188
+ **implement:**
189
+ ```markdown
190
+ ### Working Files
191
+ | File | Role | Status |
192
+ |------|------|--------|
193
+
194
+ ### Dependencies
195
+ - (modules, APIs, or services this task depends on)
196
+
197
+ ### Decisions
198
+ | # | Decision | Rationale | Alternatives Considered |
199
+ |---|----------|-----------|------------------------|
200
+
201
+ ### Tests Affected
202
+ - (test files that need creation or update)
203
+ ```
204
+
205
+ **debug:**
206
+ ```markdown
207
+ ### Symptoms
208
+ - (observable behavior vs expected behavior)
209
+
210
+ ### Hypotheses
211
+ | # | Hypothesis | Status | Evidence |
212
+ |---|-----------|--------|----------|
213
+
214
+ ### Evidence Trail
215
+ | Time | Source | Type | Finding |
216
+ |------|--------|------|---------|
217
+
218
+ ### Root Cause
219
+ - (populated when identified)
220
+
221
+ ### Fix Applied
222
+ - (description of fix, files changed)
223
+ ```
224
+
225
+ **analyze:**
226
+ ```markdown
227
+ ### Scope
228
+ - (what is being analyzed and boundaries)
229
+
230
+ ### Findings
231
+ | # | Finding | Severity | Location |
232
+ |---|---------|----------|----------|
233
+
234
+ ### Risks
235
+ - (identified risks or concerns)
236
+
237
+ ### Recommendations
238
+ - (actionable recommendations)
239
+ ```
240
+
241
+ **design:**
242
+ ```markdown
243
+ ### Constraints
244
+ - (hard limits, requirements, compatibility needs)
245
+
246
+ ### Alternatives
247
+ | # | Approach | Pros | Cons |
248
+ |---|----------|------|------|
249
+
250
+ ### Trade-offs
251
+ - (key trade-off decisions and rationale)
252
+
253
+ ### Chosen Approach
254
+ - (selected design with justification)
255
+ ```
256
+
257
+ **plan:**
258
+ ```markdown
259
+ ### Goals
260
+ - (what success looks like)
261
+
262
+ ### Breakdown
263
+ | # | Task | Estimate | Depends On | Status |
264
+ |---|------|----------|------------|--------|
265
+
266
+ ### Dependencies
267
+ - (external dependencies, blockers, prerequisites)
268
+ ```
269
+
270
+ **review:**
271
+ ```markdown
272
+ ### Files Reviewed
273
+ | File | Lines | Findings |
274
+ |------|-------|----------|
275
+
276
+ ### Findings
277
+ | # | Severity | Category | File:Line | Description |
278
+ |---|----------|----------|-----------|-------------|
279
+
280
+ ### Verdict
281
+ - (pass / pass-with-concerns / fail)
282
+ ```
283
+
284
+ **test:**
285
+ ```markdown
286
+ ### Coverage
287
+ - Before: {%}
288
+ - After: {%}
289
+ - Target: {%}
290
+
291
+ ### Test Files
292
+ | File | Type | Tests Added | Status |
293
+ |------|------|------------|--------|
294
+
295
+ ### Gaps
296
+ - (uncovered paths or scenarios)
297
+ ```
298
+
299
+ **refactor:**
300
+ ```markdown
301
+ ### Affected Modules
302
+ - (modules being restructured)
303
+
304
+ ### Before / After
305
+ | Aspect | Before | After |
306
+ |--------|--------|-------|
307
+
308
+ ### Breaking Changes
309
+ - (API or behavior changes that affect consumers)
310
+ ```
311
+
312
+ **learn:**
313
+ ```markdown
314
+ ### Questions
315
+ | # | Question | Answered | Source |
316
+ |---|----------|----------|--------|
317
+
318
+ ### Mental Model
319
+ - (evolving understanding of how it works)
320
+
321
+ ### References
322
+ - (files, docs, wiki entries consulted)
323
+ ```
324
+
325
+ **general:**
326
+ ```markdown
327
+ ### Notes
328
+ - (general working notes)
329
+ ```
330
+
331
+ Write the companion doc path to `.workflow/.scratchpad/.companion-active`.
332
+
333
+ ### 5. Output summary card
334
+
335
+ ```
336
+ Knowledge context loaded
337
+ Spec: {N} rules ({category})
338
+ Knowhow: {M} entries available
339
+ Codebase: {status}
340
+ Doc: {companion_doc_path} [{task_type}]
341
+
342
+ Mid-task commands:
343
+ /maestro-companion note "finding or decision"
344
+ /maestro-companion note --file src/auth.ts "changed token validation"
345
+ /spec-load --keyword <keyword>
346
+ maestro wiki search "<query>"
347
+ ```
348
+
349
+ ---
350
+
351
+ ## S_NOTE — Append Structured Entry to Companion Doc
352
+
353
+ ### 1. Locate active companion doc
354
+
355
+ Read `.workflow/.scratchpad/.companion-active` to get the doc path.
356
+ If missing or file not found → create a new companion doc (same as S_BEFORE step 4, minimal — no spec/knowhow loading).
357
+
358
+ ### 2. Parse entry content and flags
359
+
360
+ Parse $ARGUMENTS after `note` keyword:
361
+ - `--file <path>` — associate entry with a specific file (appended to frontmatter `working_files`)
362
+ - `--severity <level>` — for findings: critical / high / medium / low
363
+ - Remaining text = entry content
364
+
365
+ ### 3. Classify entry type
366
+
367
+ Auto-classify from content signals:
368
+
369
+ | Content signal | Type tag |
370
+ |---------------|----------|
371
+ | "decided/decision/chose/picked/went with" | `decision` |
372
+ | "pattern/convention/rule/always/never/must" | `spec-candidate` |
373
+ | "pitfall/gotcha/careful/warning/trap/beware" | `pitfall` |
374
+ | "learned/realized/discovered/understood/turns out" | `insight` |
375
+ | "hypothesis/suspect/might be/could be" | `hypothesis` |
376
+ | "found bug/root cause/because of/caused by" | `evidence` |
377
+ | "risk/concern/worry/might break" | `risk` |
378
+ | "todo/need to/should also/follow up/remaining" | `todo` |
379
+ | "question/why does/how does/unclear" | `question` |
380
+ | "blocked/stuck/can't/impossible" | `blocker` |
381
+ | Default | `note` |
382
+
383
+ ### 4. Append entry
384
+
385
+ Append to the companion doc under `## Entries`:
386
+
387
+ ```markdown
388
+ ### [{type}] {HH:mm} — {first line of content}
389
+
390
+ {full content}
391
+
392
+ {if --file: **File:** `{path}`}
393
+ {if --severity: **Severity:** {level}}
394
+ ```
395
+
396
+ ### 5. Update frontmatter fields
397
+
398
+ - If `--file` provided and not already in `working_files` → append to `working_files`
399
+ - If type is `decision` → also append row to `### Decisions` table (if implement/design type doc)
400
+ - If type is `hypothesis` → also append row to `### Hypotheses` table (if debug type doc)
401
+ - If type is `evidence` → also append row to `### Evidence Trail` table (if debug type doc)
402
+ - If type is `risk` → also append to `### Risks` list (if analyze/design type doc)
403
+ - If type is `question` → also append row to `### Questions` table (if learn type doc)
404
+
405
+ ### 6. Confirm
406
+
407
+ ```
408
+ [{type}] entry added to companion doc
409
+ /maestro-companion note "..." — add more
410
+ /maestro-companion after — review & promote
411
+ ```
412
+
413
+ ---
414
+
415
+ ## S_AFTER — Review Companion Doc + Populate Outcome + Promote Entries + Route
416
+
417
+ ### 1. Load companion doc
418
+
419
+ Read `.workflow/.scratchpad/.companion-active` → read the companion doc.
420
+ If no active doc or doc is empty → skip to step 4 (accumulation reminder).
421
+
422
+ ### 2. Populate outcome fields
423
+
424
+ Collect task outcome data:
425
+
426
+ ```bash
427
+ # Detect files changed since companion doc creation
428
+ git diff --name-only --since="{companion_created_timestamp}"
429
+ ```
430
+
431
+ Update frontmatter:
432
+ - `files_changed` — from git diff
433
+ - `completed` — current ISO timestamp
434
+ - `status` — `completed`
435
+
436
+ Display entry summary:
437
+ ```
438
+ Companion doc review — {task_type}
439
+ Entries: {total} ({by type breakdown})
440
+ Files: {files_changed count} changed
441
+ Duration: {elapsed since created}
442
+
443
+ Promotable entries:
444
+ {list of decision/spec-candidate/pitfall/insight entries}
445
+ ```
446
+
447
+ ### 3. Promote entries
448
+
449
+ If promotable entries exist, ask_user:
450
+
451
+ - Option 1: "Promote to spec" — short coding/arch/test constraint
452
+ - Option 2: "Promote to knowhow" — detailed recipe/template/decision/tip
453
+ - Option 3: "Promote both" — spec index entry + knowhow document
454
+ - Option 4: "Skip — nothing to promote"
455
+
456
+ **Routing by selection:**
457
+
458
+ | Selection | Action |
459
+ |-----------|--------|
460
+ | Spec | `invoke_skill("spec-add", args)` — guide user through category + content |
461
+ | Knowhow | `invoke_skill("manage-knowhow-capture", args)` — guide through type + content |
462
+ | Both | `invoke_skill("spec-add")` first, then `invoke_skill("manage-knowhow-capture")` |
463
+ | Skip | Proceed to step 4 |
464
+
465
+ Update frontmatter: `promoted_specs`, `promoted_knowhow` counts.
466
+
467
+ Extract any `todo` entries → write to `follow_up` in frontmatter.
468
+
469
+ Clear `.workflow/.scratchpad/.companion-active`.
470
+
471
+ ### 4. Output accumulation reminder + routing
472
+
473
+ ```
474
+ Knowledge accumulation reminders:
475
+ Reusable pattern found? /spec-add <category> "title" "content"
476
+ Solved a complex problem? /manage-knowhow-capture recipe "description"
477
+ Made an architecture decision? /manage-knowhow-capture decision "description"
478
+ Discovered a useful trick? /manage-knowhow-capture tip "content"
479
+
480
+ Next steps:
481
+ /maestro-next — recommend next command
482
+ /maestro "<intent>" — route intent to full workflow
483
+ /manage-status — view project dashboard
484
+ ```
485
+
486
+ ---
487
+
488
+ ## S_ROUTE — Skill Routing
489
+
490
+ ### 1. Parse intent
491
+
492
+ Extract intent text from $ARGUMENTS after removing the `route` keyword.
493
+
494
+ ### 2. Delegate to maestro-next
495
+
496
+ ```
497
+ invoke_skill("maestro-next", "<intent_text>")
498
+ ```
499
+
500
+ Reuses maestro-next routing table and scoring logic to recommend the best single command.
501
+
502
+ </execution>
503
+
504
+ <error_codes>
505
+ | Code | Severity | Condition | Recovery |
506
+ |------|----------|-----------|----------|
507
+ | W001 | warning | `.workflow/specs/` not initialized | Suggest `/spec-setup` |
508
+ | W002 | warning | `.workflow/knowhow/` is empty | Normal, skip knowhow index |
509
+ | W003 | warning | `.workflow/codebase/` does not exist | Suggest `/manage-codebase-rebuild` |
510
+ | W004 | warning | No active companion doc found (note/after mode) | Create new doc or skip |
511
+ </error_codes>
512
+
513
+ <success_criteria>
514
+ - [ ] Mode correctly detected (before/note/after/route)
515
+ - [ ] Task type resolved from --type flag or inferred from --task keywords
516
+ - [ ] before: spec + knowhow + codebase indexes loaded or hints given
517
+ - [ ] before: companion doc created with full YAML frontmatter (identity + context + scope + outcome placeholders)
518
+ - [ ] before: type-specific context template written (matching task_type)
519
+ - [ ] before: active doc path written to `.companion-active`
520
+ - [ ] before: summary card output with mid-task command hints
521
+ - [ ] note: active companion doc located and entry appended with type tag
522
+ - [ ] note: entry type auto-classified from content signals (11 type tags)
523
+ - [ ] note: --file flag updates working_files in frontmatter
524
+ - [ ] note: typed entries cross-posted to matching context tables (decisions→Decisions, hypothesis→Hypotheses, etc.)
525
+ - [ ] after: companion doc entries reviewed and promotable items identified
526
+ - [ ] after: outcome fields populated (files_changed, completed, status)
527
+ - [ ] after: ask_user routes to spec-add or manage-knowhow-capture
528
+ - [ ] after: todo entries extracted to follow_up field
529
+ - [ ] after: companion doc marked completed, active pointer cleared
530
+ - [ ] after: accumulation reminder + next-step routing displayed
531
+ - [ ] route: intent correctly forwarded to maestro-next
532
+ - [ ] No session created, no state.json modified
533
+ </success_criteria>