maestro-flow 0.4.18 → 0.4.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/.agents/agents/workflow-collab-planner.md +4 -1
  2. package/.agents/agents/workflow-plan-checker.md +11 -1
  3. package/.agents/agents/workflow-planner.md +4 -1
  4. package/.agents/skills/maestro/SKILL.md +8 -5
  5. package/.agents/skills/maestro-analyze/SKILL.md +1 -1
  6. package/.agents/skills/maestro-brainstorm/SKILL.md +2 -1
  7. package/.agents/skills/maestro-companion/SKILL.md +533 -0
  8. package/.agents/skills/maestro-grill/SKILL.md +116 -0
  9. package/.agents/skills/maestro-next/SKILL.md +147 -112
  10. package/.agents/skills/maestro-plan/SKILL.md +4 -0
  11. package/.agents/skills/maestro-ralph/SKILL.md +11 -7
  12. package/.agents/skills/maestro-swarm-workflow/SKILL.md +258 -0
  13. package/.agents/skills/manage-codebase-rebuild/SKILL.md +13 -1
  14. package/.agents/skills/manage-codebase-refresh/SKILL.md +3 -0
  15. package/.agents/skills/spec-setup/SKILL.md +9 -5
  16. package/.agents/skills/team-swarm/SKILL.md +180 -0
  17. package/.agents/skills/team-swarm/roles/analyst/role.md +187 -0
  18. package/.agents/skills/team-swarm/roles/ant/role.md +169 -0
  19. package/.agents/skills/team-swarm/roles/coordinator/commands/converge.md +146 -0
  20. package/.agents/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  21. package/.agents/skills/team-swarm/roles/coordinator/commands/iterate.md +232 -0
  22. package/.agents/skills/team-swarm/roles/coordinator/role.md +211 -0
  23. package/.agents/skills/team-swarm/roles/scorer/role.md +157 -0
  24. package/.agents/skills/team-swarm/scripts/aco.py +473 -0
  25. package/.agents/skills/team-swarm/scripts/pheromone.py +144 -0
  26. package/.agents/skills/team-swarm/scripts/scoring.py +92 -0
  27. package/.agents/skills/team-swarm/scripts/test_aco.py +475 -0
  28. package/.agents/skills/team-swarm/specs/ant-output-schema.md +119 -0
  29. package/.agents/skills/team-swarm/specs/convergence-criteria.md +106 -0
  30. package/.agents/skills/team-swarm/specs/pheromone-schema.md +123 -0
  31. package/.agents/skills/team-swarm/specs/swarm-config-template.json +71 -0
  32. package/.agents/skills/team-swarm/specs/swarm-protocol.md +117 -0
  33. package/.agy/agents/workflow-collab-planner.md +4 -1
  34. package/.agy/agents/workflow-plan-checker.md +11 -1
  35. package/.agy/agents/workflow-planner.md +4 -1
  36. package/.agy/skills/maestro/SKILL.md +8 -5
  37. package/.agy/skills/maestro-analyze/SKILL.md +1 -1
  38. package/.agy/skills/maestro-brainstorm/SKILL.md +2 -1
  39. package/.agy/skills/maestro-companion/SKILL.md +529 -0
  40. package/.agy/skills/maestro-grill/SKILL.md +116 -0
  41. package/.agy/skills/maestro-next/SKILL.md +147 -112
  42. package/.agy/skills/maestro-plan/SKILL.md +4 -0
  43. package/.agy/skills/maestro-ralph/SKILL.md +11 -7
  44. package/.agy/skills/maestro-swarm-workflow/SKILL.md +255 -0
  45. package/.agy/skills/manage-codebase-rebuild/SKILL.md +13 -1
  46. package/.agy/skills/manage-codebase-refresh/SKILL.md +3 -0
  47. package/.agy/skills/spec-setup/SKILL.md +9 -5
  48. package/.agy/skills/team-swarm/SKILL.md +176 -0
  49. package/.agy/skills/team-swarm/roles/analyst/role.md +183 -0
  50. package/.agy/skills/team-swarm/roles/ant/role.md +165 -0
  51. package/.agy/skills/team-swarm/roles/coordinator/commands/converge.md +134 -0
  52. package/.agy/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  53. package/.agy/skills/team-swarm/roles/coordinator/commands/iterate.md +202 -0
  54. package/.agy/skills/team-swarm/roles/coordinator/role.md +209 -0
  55. package/.agy/skills/team-swarm/roles/scorer/role.md +153 -0
  56. package/.agy/skills/team-swarm/scripts/aco.py +473 -0
  57. package/.agy/skills/team-swarm/scripts/pheromone.py +144 -0
  58. package/.agy/skills/team-swarm/scripts/scoring.py +92 -0
  59. package/.agy/skills/team-swarm/scripts/test_aco.py +475 -0
  60. package/.agy/skills/team-swarm/specs/ant-output-schema.md +119 -0
  61. package/.agy/skills/team-swarm/specs/convergence-criteria.md +106 -0
  62. package/.agy/skills/team-swarm/specs/pheromone-schema.md +123 -0
  63. package/.agy/skills/team-swarm/specs/swarm-config-template.json +71 -0
  64. package/.agy/skills/team-swarm/specs/swarm-protocol.md +117 -0
  65. package/.claude/agents/workflow-collab-planner.md +4 -1
  66. package/.claude/agents/workflow-plan-checker.md +11 -1
  67. package/.claude/agents/workflow-planner.md +4 -1
  68. package/.claude/commands/maestro-analyze.md +1 -1
  69. package/.claude/commands/maestro-brainstorm.md +2 -1
  70. package/.claude/commands/maestro-companion.md +531 -0
  71. package/.claude/commands/maestro-grill.md +114 -0
  72. package/.claude/commands/maestro-next.md +147 -112
  73. package/.claude/commands/maestro-plan.md +4 -0
  74. package/.claude/commands/maestro-ralph.md +11 -7
  75. package/.claude/commands/maestro-swarm-workflow.md +256 -0
  76. package/.claude/commands/maestro.md +8 -5
  77. package/.claude/commands/manage-codebase-rebuild.md +13 -1
  78. package/.claude/commands/manage-codebase-refresh.md +3 -0
  79. package/.claude/commands/spec-setup.md +9 -5
  80. package/.claude/skills/team-swarm/SKILL.md +178 -0
  81. package/.claude/skills/team-swarm/roles/analyst/role.md +185 -0
  82. package/.claude/skills/team-swarm/roles/ant/role.md +167 -0
  83. package/.claude/skills/team-swarm/roles/coordinator/commands/converge.md +146 -0
  84. package/.claude/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  85. package/.claude/skills/team-swarm/roles/coordinator/commands/iterate.md +232 -0
  86. package/.claude/skills/team-swarm/roles/coordinator/role.md +209 -0
  87. package/.claude/skills/team-swarm/roles/scorer/role.md +155 -0
  88. package/.claude/skills/team-swarm/scripts/aco.py +473 -0
  89. package/.claude/skills/team-swarm/scripts/pheromone.py +144 -0
  90. package/.claude/skills/team-swarm/scripts/scoring.py +92 -0
  91. package/.claude/skills/team-swarm/scripts/test_aco.py +475 -0
  92. package/.claude/skills/team-swarm/specs/ant-output-schema.md +119 -0
  93. package/.claude/skills/team-swarm/specs/convergence-criteria.md +106 -0
  94. package/.claude/skills/team-swarm/specs/pheromone-schema.md +123 -0
  95. package/.claude/skills/team-swarm/specs/swarm-config-template.json +71 -0
  96. package/.claude/skills/team-swarm/specs/swarm-protocol.md +117 -0
  97. package/.codex/skills/maestro/SKILL.md +7 -2
  98. package/.codex/skills/maestro-companion/SKILL.md +485 -0
  99. package/.codex/skills/maestro-grill/SKILL.md +111 -0
  100. package/.codex/skills/maestro-next/SKILL.md +297 -0
  101. package/.codex/skills/maestro-ralph/SKILL.md +11 -7
  102. package/.codex/skills/manage-codebase-rebuild/SKILL.md +6 -0
  103. package/.codex/skills/manage-codebase-refresh/SKILL.md +6 -0
  104. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.d.ts +36 -0
  105. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.js +138 -2
  106. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.js.map +1 -1
  107. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +13 -0
  108. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  109. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +11 -0
  110. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +178 -0
  111. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  112. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +1 -0
  113. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +39 -23
  114. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  115. package/dist/src/cli.js +1 -0
  116. package/dist/src/cli.js.map +1 -1
  117. package/dist/src/commands/install-backend.d.ts +7 -0
  118. package/dist/src/commands/install-backend.d.ts.map +1 -1
  119. package/dist/src/commands/install-backend.js +14 -0
  120. package/dist/src/commands/install-backend.js.map +1 -1
  121. package/dist/src/commands/install.d.ts.map +1 -1
  122. package/dist/src/commands/install.js +23 -1
  123. package/dist/src/commands/install.js.map +1 -1
  124. package/dist/src/commands/kg.d.ts +11 -0
  125. package/dist/src/commands/kg.d.ts.map +1 -0
  126. package/dist/src/commands/kg.js +515 -0
  127. package/dist/src/commands/kg.js.map +1 -0
  128. package/dist/src/i18n/locales/en.d.ts.map +1 -1
  129. package/dist/src/i18n/locales/en.js +19 -0
  130. package/dist/src/i18n/locales/en.js.map +1 -1
  131. package/dist/src/i18n/locales/zh.d.ts.map +1 -1
  132. package/dist/src/i18n/locales/zh.js +19 -0
  133. package/dist/src/i18n/locales/zh.js.map +1 -1
  134. package/dist/src/i18n/types.d.ts +12 -0
  135. package/dist/src/i18n/types.d.ts.map +1 -1
  136. package/dist/src/tui/install-ui/HooksConfig.d.ts +5 -1
  137. package/dist/src/tui/install-ui/HooksConfig.d.ts.map +1 -1
  138. package/dist/src/tui/install-ui/HooksConfig.js +5 -3
  139. package/dist/src/tui/install-ui/HooksConfig.js.map +1 -1
  140. package/dist/src/tui/install-ui/InstallConfirm.d.ts +3 -0
  141. package/dist/src/tui/install-ui/InstallConfirm.d.ts.map +1 -1
  142. package/dist/src/tui/install-ui/InstallConfirm.js +1 -1
  143. package/dist/src/tui/install-ui/InstallConfirm.js.map +1 -1
  144. package/dist/src/tui/install-ui/InstallExecution.d.ts +2 -0
  145. package/dist/src/tui/install-ui/InstallExecution.d.ts.map +1 -1
  146. package/dist/src/tui/install-ui/InstallExecution.js +48 -3
  147. package/dist/src/tui/install-ui/InstallExecution.js.map +1 -1
  148. package/dist/src/tui/install-ui/InstallFlow.d.ts +1 -1
  149. package/dist/src/tui/install-ui/InstallFlow.d.ts.map +1 -1
  150. package/dist/src/tui/install-ui/InstallFlow.js +95 -17
  151. package/dist/src/tui/install-ui/InstallFlow.js.map +1 -1
  152. package/dist/src/tui/install-ui/InstallHub.d.ts +4 -0
  153. package/dist/src/tui/install-ui/InstallHub.d.ts.map +1 -1
  154. package/dist/src/tui/install-ui/InstallHub.js +14 -0
  155. package/dist/src/tui/install-ui/InstallHub.js.map +1 -1
  156. package/dist/src/tui/install-ui/InstallResult.d.ts.map +1 -1
  157. package/dist/src/tui/install-ui/InstallResult.js +1 -1
  158. package/dist/src/tui/install-ui/InstallResult.js.map +1 -1
  159. package/dist/src/tui/install-ui/KgVendorConfig.d.ts +7 -0
  160. package/dist/src/tui/install-ui/KgVendorConfig.d.ts.map +1 -0
  161. package/dist/src/tui/install-ui/KgVendorConfig.js +9 -0
  162. package/dist/src/tui/install-ui/KgVendorConfig.js.map +1 -0
  163. package/dist/src/utils/update-notices.js +22 -0
  164. package/dist/src/utils/update-notices.js.map +1 -1
  165. package/package.json +1 -1
  166. package/workflows/analyze.md +2 -1
  167. package/workflows/brainstorm.md +24 -1
  168. package/workflows/codebase-rebuild.md +141 -1
  169. package/workflows/codebase-refresh.md +20 -0
  170. package/workflows/finish-work.md +7 -2
  171. package/workflows/grill.md +513 -0
  172. package/workflows/plan.md +7 -4
  173. package/workflows/specs-setup.md +99 -3
  174. package/workflows/swarm/wf-analyze.js +186 -0
  175. package/workflows/swarm/wf-brainstorm.js +284 -0
  176. package/workflows/swarm/wf-execute.js +203 -0
  177. package/workflows/swarm/wf-grill.js +198 -0
  178. package/workflows/swarm/wf-milestone-audit.js +236 -0
  179. package/workflows/swarm/wf-plan.js +233 -0
  180. package/workflows/swarm/wf-review.js +226 -0
  181. package/workflows/swarm/wf-verify.js +298 -0
@@ -0,0 +1,258 @@
1
+ ---
2
+ name: maestro-swarm-workflow
3
+ description: Parallel workflow accelerator — route intent to fixed Workflow scripts for multi-agent concurrent execution
4
+ argument-hint: "<intent> [--script <name>] [--dims <d1,d2>] [--roles <r1,r2>] [--count N] [--tier quick|standard] [--resume <runId>]"
5
+ allowed-tools:
6
+ - read_file
7
+ - write_file
8
+ - edit_file
9
+ - shell
10
+ - find_files
11
+ - search
12
+ - workflow
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
+ <purpose>
18
+ Parallel accelerator layer for maestro commands. Routes user intent to pre-built Workflow scripts
19
+ that leverage `parallel()` / `pipeline()` for multi-agent concurrent execution.
20
+
21
+ Complements maestro-ralph (sequential decision chain) — ralph manages state + decisions,
22
+ swarm-workflow provides parallel compute bursts within individual steps.
23
+
24
+ Scripts: `~/.maestro/workflows/swarm/wf-*.js`
25
+
26
+ | Script | Accelerates | Pattern |
27
+ |--------|-------------|---------|
28
+ | `wf-analyze` | maestro-analyze | cli-explore-agent → 6-dimension parallel scoring → synthesis |
29
+ | `wf-brainstorm` | maestro-brainstorm | multi-role parallel analysis → cross-role-reviewer → guidance |
30
+ | `wf-review` | quality-review | 6-dimension workflow-reviewer → adversarial verify → report |
31
+ | `wf-verify` | maestro-verify | 3-layer workflow-verifier + convergence + antipattern → aggregate |
32
+ | `wf-grill` | maestro-grill | cli-explore-agent → parallel branch stress-testing → contradiction synthesis |
33
+ | `wf-plan` | maestro-plan | parallel context exploration → workflow-planner → plan-checker |
34
+ | `wf-execute` | maestro-execute | wave-based parallel workflow-executor (worktree isolation) |
35
+ | `wf-milestone-audit` | maestro-milestone-audit | parallel coverage + execution + integration-checker |
36
+
37
+ Integration modes:
38
+ - **Standalone**: `/maestro-swarm-workflow "analyze auth module"` — direct invocation
39
+ - **Ralph step**: ralph chain 中某个 step 可指定 `swarm-workflow` 作为加速执行器
40
+ - **Chained**: 输出 JSON 可被下游命令通过 `--from` 消费
41
+ </purpose>
42
+
43
+ <context>
44
+ $ARGUMENTS — intent text with optional flags.
45
+
46
+ **Parse:**
47
+ ```
48
+ --script <name> → 强制指定脚本(wf-analyze, wf-brainstorm, wf-review, wf-verify)
49
+ --dims <d1,d2> → 限定分析维度(analyze: architecture,complexity,patterns,risk,testability,performance)
50
+ --roles <r1,r2> → 限定角色(brainstorm: system-architect,product-manager,test-strategist,ux-expert,security-analyst,data-architect)
51
+ --count N → 角色数量(brainstorm 默认 3)
52
+ --tier <level> → review 层级(quick=2 维度, standard=4 维度)
53
+ --resume <runId> → 从之前的 workflow 运行恢复(增量重跑)
54
+ Remaining → intent
55
+ ```
56
+
57
+ **Script inventory** (`~/.maestro/workflows/swarm/`):
58
+
59
+ | Script | args 接口 |
60
+ |--------|-----------|
61
+ | `wf-analyze` | `{ target, scope, context, phase?, dimensions? }` |
62
+ | `wf-brainstorm` | `{ topic, context, count?, roles? }` |
63
+ | `wf-review` | `{ target, scope, specs?, tier?, dimensions? }` |
64
+ | `wf-verify` | `{ goals, plan_dir?, scope?, task_files?, must_haves?, skip_antipattern? }` |
65
+ | `wf-grill` | `{ topic, context?, depth?: "shallow"\|"standard"\|"deep" }` |
66
+ | `wf-plan` | `{ context_dir?, from?, phase?, scope?, specs?, gaps?, quick? }` |
67
+ | `wf-execute` | `{ plan_dir, specs?, codebase_context?, wiki_context?, auto_commit? }` |
68
+ | `wf-milestone-audit` | `{ milestone?, is_adhoc? }` |
69
+ </context>
70
+
71
+ <state_machine>
72
+
73
+ <states>
74
+ S_PARSE — 解析参数和意图 PERSIST: —
75
+ S_ROUTE — 路由到目标脚本 PERSIST: —
76
+ S_CONTEXT — 组装 context payload PERSIST: —
77
+ S_DISPATCH — 调用 Workflow 工具 PERSIST: —
78
+ S_INGEST — 处理返回结果 PERSIST: —
79
+ S_FALLBACK — 无法路由 PERSIST: —
80
+ </states>
81
+
82
+ <transitions>
83
+
84
+ S_PARSE:
85
+ → S_ROUTE WHEN: intent parsed DO: A_PARSE_ARGS
86
+ → S_FALLBACK WHEN: no intent
87
+
88
+ S_ROUTE:
89
+ → S_CONTEXT WHEN: script resolved DO: A_ROUTE_SCRIPT
90
+ → S_FALLBACK WHEN: ambiguous intent DO: ask_user
91
+
92
+ S_CONTEXT:
93
+ → S_DISPATCH DO: A_ASSEMBLE_CONTEXT
94
+
95
+ S_DISPATCH:
96
+ → S_INGEST WHEN: workflow completed DO: A_DISPATCH_WORKFLOW
97
+ → S_FALLBACK WHEN: workflow failed
98
+
99
+ S_INGEST:
100
+ → END DO: A_INGEST_RESULTS
101
+
102
+ S_FALLBACK:
103
+ → S_PARSE WHEN: user provides input
104
+ → END WHEN: user cancels
105
+
106
+ </transitions>
107
+
108
+ <actions>
109
+
110
+ ### A_PARSE_ARGS
111
+
112
+ 1. 提取 flags(--script, --dims, --roles, --count, --tier, --resume)
113
+ 2. 剩余文本作为 intent
114
+ 3. 若有 --resume,记录 resumeRunId
115
+
116
+ ### A_ROUTE_SCRIPT
117
+
118
+ Intent-to-script routing(按关键词匹配,--script 优先级最高):
119
+
120
+ | Keywords | Script |
121
+ |----------|--------|
122
+ | 分析 / analyze / 探索 / explore / 架构 / architecture / 复杂度 / 风险 | `wf-analyze` |
123
+ | 头脑风暴 / brainstorm / 方案 / 设计 / 评估 / evaluate / 多角度 | `wf-brainstorm` |
124
+ | 审查 / review / 代码审查 / code review / 质量 / quality | `wf-review` |
125
+ | 验证 / verify / 检查 / check / 反模式 / antipattern | `wf-verify` |
126
+ | 拷问 / grill / 压力测试 / stress-test / 挑战 / challenge | `wf-grill` |
127
+ | 规划 / plan / 任务分解 / decompose / 分波 / wave | `wf-plan` |
128
+ | 执行 / execute / 实现 / implement / 开发 / develop | `wf-execute` |
129
+ | 里程碑审计 / milestone-audit / 集成检查 / integration | `wf-milestone-audit` |
130
+
131
+ 多命中 → ask_user 让用户选择。
132
+
133
+ ### A_ASSEMBLE_CONTEXT
134
+
135
+ 根据目标脚本组装 args payload:
136
+
137
+ **wf-analyze:**
138
+ 1. Read `.workflow/state.json` 获取当前 phase/milestone 信息
139
+ 2. `target` = intent 中的目标描述
140
+ 3. `scope` = 从 intent 推断文件范围,或读 roadmap 获取 phase scope
141
+ 4. `context` = 拼接相关上下文(上游 artifact 摘要、specs)
142
+ 5. `dimensions` = --dims 解析结果(可选)
143
+
144
+ **wf-brainstorm:**
145
+ 1. `topic` = intent 文本
146
+ 2. `context` = 读取相关代码文件摘要 + 已有 specs
147
+ 3. `count` = --count 或默认 3
148
+ 4. `roles` = --roles 解析结果(可选)
149
+
150
+ **wf-review:**
151
+ 1. `target` = 读 git diff 描述变更范围
152
+ 2. `scope` = 变更文件列表
153
+ 3. `tier` = --tier 或 "standard"
154
+ 4. `dimensions` = --dims 解析结果(可选)
155
+
156
+ **wf-verify:**
157
+ 1. `goals` = 读最近的 plan artifact 提取目标列表
158
+ 2. `plan_dir` = 定位最近的 plan scratch 目录
159
+ 3. `scope` = plan 涉及的文件范围
160
+ 4. `skip_tests` / `skip_antipattern` = 从 flags 提取
161
+
162
+ ### A_DISPATCH_WORKFLOW
163
+
164
+ 1. 确定 scriptPath = `~/.maestro/workflows/swarm/{script}.js`(展开为绝对路径)
165
+ 2. 构建 Workflow 调用:
166
+ ```
167
+ Workflow({
168
+ scriptPath: absoluteScriptPath,
169
+ args: assembledArgs,
170
+ resumeFromRunId: resumeRunId // 若有
171
+ })
172
+ ```
173
+ 3. 等待 Workflow 返回结果
174
+ 4. 记录 runId 用于潜在的后续 resume
175
+
176
+ ### A_INGEST_RESULTS
177
+
178
+ Workflow 返回 JSON 后:
179
+
180
+ 1. **摘要输出**:按脚本类型格式化关键指标
181
+ - analyze: overall_score, scope_verdict, go_no_go, critical findings count
182
+ - brainstorm: role count, conflict/synergy count, top guidance items
183
+ - review: verdict (APPROVE/REQUEST_CHANGES/BLOCK), confirmed vs false-positive count
184
+ - verify: overall_passed, confidence, gap count, antipattern blocker count
185
+
186
+ 2. **Artifact 写入**(可选):
187
+ - 若当前在 ralph session 中(检测 `.workflow/.maestro/ralph-*/status.json` 状态为 running):
188
+ 将结果写入对应 step 的 scratch 目录,格式兼容命令产出
189
+ - 否则写入 `.workflow/scratch/{YYYYMMDD}-swarm-{script}-{slug}/results.json`
190
+
191
+ 3. **Ralph 兼容产出**:
192
+ - analyze → `analysis.md` + `context.md`(decisions)+ `conclusions.json`
193
+ - brainstorm → `guidance-specification.md`
194
+ - review → `review.json`
195
+ - verify → `verification.json`
196
+
197
+ 4. **RunId 提示**:显示 `Resume: /maestro-swarm-workflow --resume {runId}` 用于增量重跑
198
+
199
+ </actions>
200
+
201
+ </state_machine>
202
+
203
+ <invariants>
204
+ 1. **只做并行加速,不做状态决策** — 不修改 ralph status.json,不推进 step
205
+ 2. **args 预编译** — 所有 FS 读取在 A_ASSEMBLE_CONTEXT 完成,脚本内 agent 通过工具自行读取补充
206
+ 3. **产出格式兼容** — 写入的 artifact 格式必须与对应命令(analyze/brainstorm/review/verify)的产出一致
207
+ 4. **resume 透传** — resumeFromRunId 直接透传给 Workflow 工具,利用内置缓存机制
208
+ 5. **脚本只读** — 路由命令不修改 `~/.maestro/workflows/swarm/wf-*.js` 脚本文件
209
+ 6. **结果必须展示** — Workflow 返回后必须向用户展示格式化摘要,不得静默完成
210
+ </invariants>
211
+
212
+ <appendix>
213
+
214
+ ### 与 Ralph 集成
215
+
216
+ Ralph 可以在 A_BUILD_STEPS 中将某些 step 的执行方式标记为 `swarm-workflow`:
217
+
218
+ ```json
219
+ {
220
+ "index": 2,
221
+ "skill": "maestro-swarm-workflow",
222
+ "args": "--script wf-analyze {phase}",
223
+ "stage": "analyze",
224
+ "command_scope": "project",
225
+ "command_path": "<resolved by maestro ralph skills>"
226
+ }
227
+ ```
228
+
229
+ ralph-execute 正常通过 `maestro ralph next` 加载并执行,swarm-workflow 内部再调 Workflow 工具。
230
+
231
+ ### 输出示例
232
+
233
+ ```
234
+ ┌─ wf-analyze ──────────────────────────────────────┐
235
+ │ Explore [████████████████████] 6/6 dimensions │
236
+ │ Synthesize [████████████████] done │
237
+ ├────────────────────────────────────────────────────┤
238
+ │ Score: 7.2/10 Scope: medium Verdict: go │
239
+ │ Findings: 23 total (2 critical, 5 high) │
240
+ │ Cross-cutting: 3 themes │
241
+ │ Decisions: 4 locked, 2 free, 1 deferred │
242
+ ├────────────────────────────────────────────────────┤
243
+ │ Output: .workflow/scratch/20260530-swarm-analyze/ │
244
+ │ Resume: /maestro-swarm-workflow --resume wf_abc123 │
245
+ └────────────────────────────────────────────────────┘
246
+ ```
247
+
248
+ ### Error Codes
249
+
250
+ | Code | Description | Recovery |
251
+ |------|-------------|----------|
252
+ | E001 | No intent and no --script | Prompt for intent |
253
+ | E002 | Ambiguous routing | ask_user |
254
+ | E003 | Script file not found | Check .claude/workflows/ |
255
+ | E004 | Workflow execution failed | Show error, suggest --resume |
256
+ | E005 | Result ingestion failed | Write raw JSON to scratch |
257
+
258
+ </appendix>
@@ -37,7 +37,7 @@ $ARGUMENTS -- optional flags.
37
37
  | Agent | Focus | Output file |
38
38
  |-------|-------|-------------|
39
39
  | Mapper 1 | **Tech stack** -- languages, frameworks, dependencies, build system | `tech-stack.md` |
40
- | Mapper 2 | **Architecture** -- layers, module boundaries, data flow, entry points | `architecture.md` |
40
+ | Mapper 2 | **Architecture** -- produced by KG pipeline Step 14 (UA architecture-analyzer delegate); layers, module boundaries, data flow, entry points | `architecture.md` |
41
41
  | Mapper 3 | **Features** -- capabilities, API surface, user-facing functionality | `features.md` |
42
42
  | Mapper 4 | **Cross-cutting concerns** -- error handling, logging, auth, config, testing | `concerns.md` |
43
43
 
@@ -45,6 +45,9 @@ $ARGUMENTS -- optional flags.
45
45
  - `.workflow/` -- must be initialized (project.md, state.json exist)
46
46
  - `.workflow/codebase/` -- target directory (will be cleared and rebuilt)
47
47
  - `.workflow/codebase/doc-index.json` -- generated documentation index
48
+ - `.workflow/codebase/knowledge-graph.json` -- Knowledge Graph with nodes, edges, layers, and tour (generated by KG pipeline Steps 10–17 if UA vendor is installed)
49
+
50
+ **UA vendor requirement:** The KG pipeline (Steps 10–17) requires the UA vendor at `~/.maestro/vendor/ua/understand-anything-plugin/`. If not installed, these steps are skipped automatically. Run `scripts/ua-vendor-setup.sh` to install.
48
51
  </context>
49
52
 
50
53
  <execution>
@@ -55,6 +58,9 @@ Follow '~/.maestro/workflows/codebase-rebuild.md' completely.
55
58
  **Next-step routing on completion:**
56
59
  - View updated project state → `/manage-status`
57
60
  - Incremental updates later → `/manage-codebase-refresh`
61
+ - Verify KG stats → `maestro kg stats`
62
+ - Verify wiki integration → `maestro wiki list --keyword kg`
63
+ - Future change impact → `maestro kg diff-wiki`
58
64
  </execution>
59
65
 
60
66
  <error_codes>
@@ -63,6 +69,8 @@ Follow '~/.maestro/workflows/codebase-rebuild.md' completely.
63
69
  | E001 | error | .workflow/ not initialized | Run maestro-init first to create .workflow/ |
64
70
  | W001 | warning | A mapper agent failed (partial results) | Retry failed mapper or accept partial results |
65
71
  | W002 | warning | `.workflow/codebase/` already exists -- user prompted for rebuild/skip | check_existing |
72
+ | W003 | warning | KG validation failed (graph written with valid=false) | Review .kg-tmp/ artifacts, re-run KG pipeline |
73
+ | W004 | warning | Wiki index rebuild failed after KG generation | Non-fatal, retries on next wiki access |
66
74
  </error_codes>
67
75
 
68
76
  <success_criteria>
@@ -73,5 +81,9 @@ Follow '~/.maestro/workflows/codebase-rebuild.md' completely.
73
81
  - [ ] All documentation files regenerated
74
82
  - [ ] state.json updated with rebuild timestamp
75
83
  - [ ] project.md Tech Stack section updated if changes detected
84
+ - [ ] KG pipeline executed (if UA vendor installed)
85
+ - [ ] knowledge-graph.json generated in .workflow/codebase/ (if UA vendor installed)
86
+ - [ ] KG nodes indexed as virtual wiki entries (automatic via WikiIndexer on next wiki access)
76
87
  - [ ] Next step routing: `/manage-status` or `/manage-codebase-refresh` for incremental updates later
88
+ - [ ] KG impact check available: `maestro kg diff-wiki` for future change impact analysis
77
89
  </success_criteria>
@@ -34,6 +34,7 @@ $ARGUMENTS -- optional flags.
34
34
  - `.workflow/` -- must be initialized
35
35
  - `.workflow/codebase/` -- must contain existing docs (from prior rebuild)
36
36
  - `.workflow/codebase/doc-index.json` -- documentation index with timestamps
37
+ - `.workflow/codebase/knowledge-graph.json` -- Knowledge Graph (optional, for KG impact analysis)
37
38
  - `.workflow/state.json` -- contains `codebase_last_rebuilt` timestamp
38
39
  </context>
39
40
 
@@ -52,6 +53,8 @@ Follow '~/.maestro/workflows/codebase-refresh.md' completely.
52
53
  <success_criteria>
53
54
  - [ ] Changed files detected via git diff since last refresh
54
55
  - [ ] Affected documentation entries identified from doc-index.json
56
+ - [ ] KG impact analysis run (if knowledge-graph.json exists): `maestro kg diff-wiki --json`
57
+ - [ ] Affected wiki entries flagged with warnings (if any)
55
58
  - [ ] Only affected docs refreshed (selective mapper re-run)
56
59
  - [ ] doc-index.json timestamps updated per affected entry
57
60
  - [ ] state.json updated with codebase_last_refreshed timestamp
@@ -13,8 +13,9 @@ allowed-tools:
13
13
 
14
14
  <purpose>
15
15
  Initialize the project-level specs directory by scanning the codebase for conventions, patterns, and tech stack.
16
- Core files (coding, arch, knowhow) are always created. Optional files (quality, debug, test, review) are created only when relevant signals are detected.
17
- All output lands in `.workflow/specs/`.
16
+ Core files (coding, arch, learnings) are always created. Optional spec files (quality, test, ui) are created only when relevant signals are detected.
17
+ Additionally, generates recipe-type knowhow docs in `.workflow/knowhow/` for detected operational workflows (test / debug / build / dev / lint) — capturing "how to do X in this project" so future agents can find them via `maestro wiki search`.
18
+ Spec output lands in `.workflow/specs/`; recipe output lands in `.workflow/knowhow/`.
18
19
  </purpose>
19
20
 
20
21
  <required_reading>
@@ -39,12 +40,15 @@ Follow '~/.maestro/workflows/specs-setup.md' completely.
39
40
  | E001 | fatal | `.workflow/` directory not initialized -- run `/maestro-init` first | parse_input |
40
41
  | E002 | fatal | No source files found in project -- nothing to scan | scan_codebase |
41
42
  | W001 | warning | Convention detection uncertain for one or more categories -- marked `[UNCERTAIN]` | generate_specs |
43
+ | W002 | warning | Workflow recipe signals detected but commands ambiguous -- recipe skipped | generate_recipes |
44
+ | W003 | warning | Existing recipe slug found -- new content written as `.proposed.md` for manual diff | generate_recipes |
42
45
  </error_codes>
43
46
 
44
47
  <success_criteria>
45
48
  - [ ] `.workflow/specs/` directory created
46
- - [ ] Core files always created: `coding-conventions.md`, `architecture-constraints.md`, `knowhow.md`
47
- - [ ] Optional files created when detected: `quality-rules.md` (linter/CI), `test-conventions.md` (test framework), `debug-notes.md` (on demand), `review-standards.md` (on demand)
48
- - [ ] Report displayed with summary and next steps
49
+ - [ ] Core spec files always created: `coding-conventions.md`, `architecture-constraints.md`, `learnings.md`
50
+ - [ ] Optional spec files created when detected: `quality-rules.md` (linter/CI), `test-conventions.md` (test framework), `ui-conventions.md` (frontend framework). `debug-notes.md` / `review-standards.md` deferred (on demand via `/spec-add`).
51
+ - [ ] Workflow recipe knowhow created in `.workflow/knowhow/` for each detected operational workflow (test / debug / build / dev / lint). Each recipe matches the `recipe` schema in `~/.maestro/workflows/knowhow.md` Part B and contains at least one runnable command.
52
+ - [ ] Report displayed grouped by destination (specs / recipes / skipped / deferred), with `.proposed.md` files surfaced when an existing recipe slug was preserved.
49
53
  </success_criteria>
50
54
  </output>
@@ -0,0 +1,180 @@
1
+ ---
2
+ name: team-swarm
3
+ description: Swarm intelligence team skill — ACO-driven multi-agent exploration with hybrid LLM coordinator + Python optimization controller. Coordinator generates swarm-config from user task, then runs K iterations of N parallel ants guided by pheromone state. Universal task space via config (nodes + scoring rule). Triggers on "team swarm", "swarm intelligence", "蚁群".
4
+ allowed-tools: team_create(*), team_delete(*), send_message(*), task_create(*), task_update(*), task_list(*), task_get(*), agent(*), ask_user_question(*), read(*), write(*), edit(*), bash(*), glob(*), grep(*), mcp__ccw-tools__team_msg(*)
5
+ ---
6
+ <!-- Open-standard mirror generated by scripts/build-agents-standard.mjs — do not edit; re-run after editing .claude/ source. -->
7
+
8
+
9
+ # Team Swarm
10
+
11
+ Orchestrate ant-colony-style exploration over a user-defined task space. **Hybrid coordinator**: LLM handles task translation + worker spawning; Python script owns all numeric decisions (selection / pheromone update / convergence). Universal — task space and scoring rule come from `swarm-config.json`.
12
+
13
+ ## Architecture
14
+
15
+ ```
16
+ invoke_skill(skill="team-swarm", args="task description")
17
+ |
18
+ SKILL.md (this file) = Router
19
+ |
20
+ +--------------+--------------+
21
+ | |
22
+ no --role flag --role <name>
23
+ | |
24
+ Coordinator Worker
25
+ roles/coordinator/role.md roles/<name>/role.md
26
+ |
27
+ +-- Phase 1: gen swarm-config
28
+ +-- Phase 2: init --> Bash: scripts/aco.py init
29
+ +-- Phase 3: iterate (K rounds, each = spawn-and-stop)
30
+ | |
31
+ | +-- Bash: aco.py select --iter k -> N assignments
32
+ | +-- Spawn N x team-worker(ant)
33
+ | +-- [callback when all ants done]
34
+ | +-- (optional) Spawn team-worker(scorer)
35
+ | +-- Bash: aco.py update --iter k
36
+ | +-- Bash: aco.py converged
37
+ | +-- branch: loop k+1 OR Phase 4
38
+ |
39
+ +-- Phase 4: converge --> Bash: aco.py report -> Spawn team-worker(analyst)
40
+ -> best-solution.md
41
+ ```
42
+
43
+ ## Role Registry
44
+
45
+ | Role | Path | Prefix | Inner Loop |
46
+ |------|------|--------|------------|
47
+ | coordinator | [roles/coordinator/role.md](roles/coordinator/role.md) | — | — |
48
+ | ant | [roles/ant/role.md](roles/ant/role.md) | ANT-* | false |
49
+ | scorer | [roles/scorer/role.md](roles/scorer/role.md) | SCORE-* | false |
50
+ | analyst | [roles/analyst/role.md](roles/analyst/role.md) | ANALYST-* | false |
51
+
52
+ ## Role Router
53
+
54
+ Parse `$ARGUMENTS`:
55
+ - Has `--role <name>` -> Read `roles/<name>/role.md`, execute Phase 2-4
56
+ - No `--role` -> `@roles/coordinator/role.md`, execute entry router
57
+
58
+ ## Shared Constants
59
+
60
+ - **Session prefix**: `TS`
61
+ - **Session path**: `.workflow/.team/TS-<slug>-<date>/`
62
+ - **Team name**: `swarm`
63
+ - **Script root**: `<skill_root>/scripts/aco.py` (Python 3.10+)
64
+ - **Message bus**: `mcp__ccw-tools__team_msg(session_id=<session-id>, ...)`
65
+
66
+ ## Worker Spawn Template
67
+
68
+ Coordinator spawns workers using this template:
69
+
70
+ ```
71
+ delegate_subagent({
72
+ subagent_type: "team-worker",
73
+ description: "Spawn <role> worker",
74
+ team_name: "swarm",
75
+ name: "<role>",
76
+ run_in_background: true,
77
+ prompt: `## Role Assignment
78
+ role: <role>
79
+ role_spec: <skill_root>/roles/<role>/role.md
80
+ session: <session-folder>
81
+ session_id: <session-id>
82
+ team_name: swarm
83
+ requirement: <task-description>
84
+ inner_loop: false
85
+
86
+ ## Assignment (ant only)
87
+ <assignment JSON from aco.py select>
88
+
89
+ ## Progress Milestones
90
+ session_id: <session-id>
91
+ Report progress via team_msg at natural phase boundaries.
92
+ Report blockers immediately via team_msg type="blocker".
93
+ Report completion via team_msg type="task_complete" after final send_message.
94
+
95
+ Read role_spec file (@<skill_root>/roles/<role>/role.md) to load Phase 2-4 domain instructions.
96
+ Execute built-in Phase 1 (task discovery) -> role Phase 2-4 -> built-in Phase 5 (report).`
97
+ })
98
+ ```
99
+
100
+ ## User Commands
101
+
102
+ | Command | Action |
103
+ |---------|--------|
104
+ | `check` / `status` | View iteration progress + convergence curve |
105
+ | `resume` / `continue` | Resume interrupted iteration |
106
+ | `feedback <text>` | Inject feedback into wisdom; applies at next iteration |
107
+ | `revise <ITER>` | Re-run a specific iteration (rare) |
108
+
109
+ ## Specs Reference
110
+
111
+ | Spec | Purpose |
112
+ |------|---------|
113
+ | [specs/swarm-protocol.md](specs/swarm-protocol.md) | Master protocol: script <-> coordinator interface, data flow |
114
+ | [specs/pheromone-schema.md](specs/pheromone-schema.md) | Pheromone JSON structure, update formula, evaporation |
115
+ | [specs/ant-output-schema.md](specs/ant-output-schema.md) | Critical contract for ant JSON artifacts |
116
+ | [specs/convergence-criteria.md](specs/convergence-criteria.md) | Stop conditions, multi-criterion logic |
117
+ | [specs/swarm-config-template.json](specs/swarm-config-template.json) | User-facing config template with all knobs |
118
+
119
+ ## Scripts
120
+
121
+ | Script | Purpose | Invocation |
122
+ |--------|---------|------------|
123
+ | `scripts/aco.py` | Main CLI: init / select / update / converged / report | `python aco.py --session <path> <cmd>` |
124
+ | `scripts/pheromone.py` | Pheromone matrix module (imported by aco.py) | — |
125
+ | `scripts/scoring.py` | Pluggable scorer (script + fallback modes) | — |
126
+
127
+ ## Session Directory
128
+
129
+ ```
130
+ .workflow/.team/TS-<slug>-<date>/
131
+ ├── team-session.json # Session state
132
+ ├── swarm-config.json # User-facing config (Phase 1 output)
133
+ ├── role-binding.json # Worker role_spec path map
134
+ ├── task-space.json # Resolved nodes list
135
+ ├── pheromone/
136
+ │ ├── current.json # Latest pheromone (each iter overwrites)
137
+ │ ├── init.json # Frozen initial state
138
+ │ └── history/<iter>.json # Per-iter snapshot
139
+ ├── trails/<iter>.jsonl # Per-iter all-ant paths + scores
140
+ ├── scores/iter-<iter>-scores.json # Scorer output (if mode == llm)
141
+ ├── artifacts/
142
+ │ ├── ant-<iter>-<id>.json # Per-ant schema-locked output
143
+ │ ├── swarm-report.json # Phase 4 full report dump
144
+ │ └── best-solution.md # Analyst final synthesis
145
+ ├── best.json # Canonical best solution
146
+ ├── wisdom/ # learnings / decisions / issues
147
+ └── .msg/ # Message bus
148
+ ```
149
+
150
+ ## Completion Action
151
+
152
+ When swarm converges, coordinator presents:
153
+
154
+ ```
155
+ ask_user({
156
+ questions: [{
157
+ question: "Swarm pipeline complete. What would you like to do?",
158
+ header: "Completion",
159
+ multiSelect: false,
160
+ options: [
161
+ { label: "Archive & Clean (Recommended)", description: "Archive session, delete team" },
162
+ { label: "Keep Active", description: "Preserve for follow-up" },
163
+ { label: "Export Best Solution", description: "Copy best-solution.md to target" },
164
+ { label: "Run Another Round", description: "Reset convergence, K more iterations" }
165
+ ]
166
+ }]
167
+ })
168
+ ```
169
+
170
+ ## Error Handling
171
+
172
+ | Scenario | Resolution |
173
+ |----------|------------|
174
+ | `aco.py` not found | Verify `<skill_root>/scripts/aco.py`; check Python install |
175
+ | Python version < 3.10 | Use `python3` or report dependency error |
176
+ | Config validation fails | ask_user to fix, regenerate, retry |
177
+ | All ants fail in iteration | Halt, ask_user (retry / abort / refine config) |
178
+ | Hallucination cluster (>50%) | Pause, ask_user (continue / refine scoring) |
179
+ | Convergence never trips | `max_iterations` safety net always fires |
180
+ | Session corruption | Phase 0 reconciliation; archive if irrecoverable |