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,255 @@
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
+ - Workflow
7
+ - ask_question
8
+ - grep_search
9
+ - replace_file_content
10
+ - run_command
11
+ - view_file
12
+ - write_to_file
13
+ ---
14
+ <purpose>
15
+ Parallel accelerator layer for maestro commands. Routes user intent to pre-built Workflow scripts
16
+ that leverage `parallel()` / `pipeline()` for multi-agent concurrent execution.
17
+
18
+ Complements maestro-ralph (sequential decision chain) — ralph manages state + decisions,
19
+ swarm-workflow provides parallel compute bursts within individual steps.
20
+
21
+ Scripts: `~/.maestro/workflows/swarm/wf-*.js`
22
+
23
+ | Script | Accelerates | Pattern |
24
+ |--------|-------------|---------|
25
+ | `wf-analyze` | maestro-analyze | cli-explore-agent → 6-dimension parallel scoring → synthesis |
26
+ | `wf-brainstorm` | maestro-brainstorm | multi-role parallel analysis → cross-role-reviewer → guidance |
27
+ | `wf-review` | quality-review | 6-dimension workflow-reviewer → adversarial verify → report |
28
+ | `wf-verify` | maestro-verify | 3-layer workflow-verifier + convergence + antipattern → aggregate |
29
+ | `wf-grill` | maestro-grill | cli-explore-agent → parallel branch stress-testing → contradiction synthesis |
30
+ | `wf-plan` | maestro-plan | parallel context exploration → workflow-planner → plan-checker |
31
+ | `wf-execute` | maestro-execute | wave-based parallel workflow-executor (worktree isolation) |
32
+ | `wf-milestone-audit` | maestro-milestone-audit | parallel coverage + execution + integration-checker |
33
+
34
+ Integration modes:
35
+ - **Standalone**: `/maestro-swarm-workflow "analyze auth module"` — direct invocation
36
+ - **Ralph step**: ralph chain 中某个 step 可指定 `swarm-workflow` 作为加速执行器
37
+ - **Chained**: 输出 JSON 可被下游命令通过 `--from` 消费
38
+ </purpose>
39
+
40
+ <context>
41
+ $ARGUMENTS — intent text with optional flags.
42
+
43
+ **Parse:**
44
+ ```
45
+ --script <name> → 强制指定脚本(wf-analyze, wf-brainstorm, wf-review, wf-verify)
46
+ --dims <d1,d2> → 限定分析维度(analyze: architecture,complexity,patterns,risk,testability,performance)
47
+ --roles <r1,r2> → 限定角色(brainstorm: system-architect,product-manager,test-strategist,ux-expert,security-analyst,data-architect)
48
+ --count N → 角色数量(brainstorm 默认 3)
49
+ --tier <level> → review 层级(quick=2 维度, standard=4 维度)
50
+ --resume <runId> → 从之前的 workflow 运行恢复(增量重跑)
51
+ Remaining → intent
52
+ ```
53
+
54
+ **Script inventory** (`~/.maestro/workflows/swarm/`):
55
+
56
+ | Script | args 接口 |
57
+ |--------|-----------|
58
+ | `wf-analyze` | `{ target, scope, context, phase?, dimensions? }` |
59
+ | `wf-brainstorm` | `{ topic, context, count?, roles? }` |
60
+ | `wf-review` | `{ target, scope, specs?, tier?, dimensions? }` |
61
+ | `wf-verify` | `{ goals, plan_dir?, scope?, task_files?, must_haves?, skip_antipattern? }` |
62
+ | `wf-grill` | `{ topic, context?, depth?: "shallow"\|"standard"\|"deep" }` |
63
+ | `wf-plan` | `{ context_dir?, from?, phase?, scope?, specs?, gaps?, quick? }` |
64
+ | `wf-execute` | `{ plan_dir, specs?, codebase_context?, wiki_context?, auto_commit? }` |
65
+ | `wf-milestone-audit` | `{ milestone?, is_adhoc? }` |
66
+ </context>
67
+
68
+ <state_machine>
69
+
70
+ <states>
71
+ S_PARSE — 解析参数和意图 PERSIST: —
72
+ S_ROUTE — 路由到目标脚本 PERSIST: —
73
+ S_CONTEXT — 组装 context payload PERSIST: —
74
+ S_DISPATCH — 调用 Workflow 工具 PERSIST: —
75
+ S_INGEST — 处理返回结果 PERSIST: —
76
+ S_FALLBACK — 无法路由 PERSIST: —
77
+ </states>
78
+
79
+ <transitions>
80
+
81
+ S_PARSE:
82
+ → S_ROUTE WHEN: intent parsed DO: A_PARSE_ARGS
83
+ → S_FALLBACK WHEN: no intent
84
+
85
+ S_ROUTE:
86
+ → S_CONTEXT WHEN: script resolved DO: A_ROUTE_SCRIPT
87
+ → S_FALLBACK WHEN: ambiguous intent DO: ask_question
88
+
89
+ S_CONTEXT:
90
+ → S_DISPATCH DO: A_ASSEMBLE_CONTEXT
91
+
92
+ S_DISPATCH:
93
+ → S_INGEST WHEN: workflow completed DO: A_DISPATCH_WORKFLOW
94
+ → S_FALLBACK WHEN: workflow failed
95
+
96
+ S_INGEST:
97
+ → END DO: A_INGEST_RESULTS
98
+
99
+ S_FALLBACK:
100
+ → S_PARSE WHEN: user provides input
101
+ → END WHEN: user cancels
102
+
103
+ </transitions>
104
+
105
+ <actions>
106
+
107
+ ### A_PARSE_ARGS
108
+
109
+ 1. 提取 flags(--script, --dims, --roles, --count, --tier, --resume)
110
+ 2. 剩余文本作为 intent
111
+ 3. 若有 --resume,记录 resumeRunId
112
+
113
+ ### A_ROUTE_SCRIPT
114
+
115
+ Intent-to-script routing(按关键词匹配,--script 优先级最高):
116
+
117
+ | Keywords | Script |
118
+ |----------|--------|
119
+ | 分析 / analyze / 探索 / explore / 架构 / architecture / 复杂度 / 风险 | `wf-analyze` |
120
+ | 头脑风暴 / brainstorm / 方案 / 设计 / 评估 / evaluate / 多角度 | `wf-brainstorm` |
121
+ | 审查 / review / 代码审查 / code review / 质量 / quality | `wf-review` |
122
+ | 验证 / verify / 检查 / check / 反模式 / antipattern | `wf-verify` |
123
+ | 拷问 / grill / 压力测试 / stress-test / 挑战 / challenge | `wf-grill` |
124
+ | 规划 / plan / 任务分解 / decompose / 分波 / wave | `wf-plan` |
125
+ | 执行 / execute / 实现 / implement / 开发 / develop | `wf-execute` |
126
+ | 里程碑审计 / milestone-audit / 集成检查 / integration | `wf-milestone-audit` |
127
+
128
+ 多命中 → ask_question 让用户选择。
129
+
130
+ ### A_ASSEMBLE_CONTEXT
131
+
132
+ 根据目标脚本组装 args payload:
133
+
134
+ **wf-analyze:**
135
+ 1. Read `.workflow/state.json` 获取当前 phase/milestone 信息
136
+ 2. `target` = intent 中的目标描述
137
+ 3. `scope` = 从 intent 推断文件范围,或读 roadmap 获取 phase scope
138
+ 4. `context` = 拼接相关上下文(上游 artifact 摘要、specs)
139
+ 5. `dimensions` = --dims 解析结果(可选)
140
+
141
+ **wf-brainstorm:**
142
+ 1. `topic` = intent 文本
143
+ 2. `context` = 读取相关代码文件摘要 + 已有 specs
144
+ 3. `count` = --count 或默认 3
145
+ 4. `roles` = --roles 解析结果(可选)
146
+
147
+ **wf-review:**
148
+ 1. `target` = 读 git diff 描述变更范围
149
+ 2. `scope` = 变更文件列表
150
+ 3. `tier` = --tier 或 "standard"
151
+ 4. `dimensions` = --dims 解析结果(可选)
152
+
153
+ **wf-verify:**
154
+ 1. `goals` = 读最近的 plan artifact 提取目标列表
155
+ 2. `plan_dir` = 定位最近的 plan scratch 目录
156
+ 3. `scope` = plan 涉及的文件范围
157
+ 4. `skip_tests` / `skip_antipattern` = 从 flags 提取
158
+
159
+ ### A_DISPATCH_WORKFLOW
160
+
161
+ 1. 确定 scriptPath = `~/.maestro/workflows/swarm/{script}.js`(展开为绝对路径)
162
+ 2. 构建 Workflow 调用:
163
+ ```
164
+ Workflow({
165
+ scriptPath: absoluteScriptPath,
166
+ args: assembledArgs,
167
+ resumeFromRunId: resumeRunId // 若有
168
+ })
169
+ ```
170
+ 3. 等待 Workflow 返回结果
171
+ 4. 记录 runId 用于潜在的后续 resume
172
+
173
+ ### A_INGEST_RESULTS
174
+
175
+ Workflow 返回 JSON 后:
176
+
177
+ 1. **摘要输出**:按脚本类型格式化关键指标
178
+ - analyze: overall_score, scope_verdict, go_no_go, critical findings count
179
+ - brainstorm: role count, conflict/synergy count, top guidance items
180
+ - review: verdict (APPROVE/REQUEST_CHANGES/BLOCK), confirmed vs false-positive count
181
+ - verify: overall_passed, confidence, gap count, antipattern blocker count
182
+
183
+ 2. **Artifact 写入**(可选):
184
+ - 若当前在 ralph session 中(检测 `.workflow/.maestro/ralph-*/status.json` 状态为 running):
185
+ 将结果写入对应 step 的 scratch 目录,格式兼容命令产出
186
+ - 否则写入 `.workflow/scratch/{YYYYMMDD}-swarm-{script}-{slug}/results.json`
187
+
188
+ 3. **Ralph 兼容产出**:
189
+ - analyze → `analysis.md` + `context.md`(decisions)+ `conclusions.json`
190
+ - brainstorm → `guidance-specification.md`
191
+ - review → `review.json`
192
+ - verify → `verification.json`
193
+
194
+ 4. **RunId 提示**:显示 `Resume: /maestro-swarm-workflow --resume {runId}` 用于增量重跑
195
+
196
+ </actions>
197
+
198
+ </state_machine>
199
+
200
+ <invariants>
201
+ 1. **只做并行加速,不做状态决策** — 不修改 ralph status.json,不推进 step
202
+ 2. **args 预编译** — 所有 FS 读取在 A_ASSEMBLE_CONTEXT 完成,脚本内 agent 通过工具自行读取补充
203
+ 3. **产出格式兼容** — 写入的 artifact 格式必须与对应命令(analyze/brainstorm/review/verify)的产出一致
204
+ 4. **resume 透传** — resumeFromRunId 直接透传给 Workflow 工具,利用内置缓存机制
205
+ 5. **脚本只读** — 路由命令不修改 `~/.maestro/workflows/swarm/wf-*.js` 脚本文件
206
+ 6. **结果必须展示** — Workflow 返回后必须向用户展示格式化摘要,不得静默完成
207
+ </invariants>
208
+
209
+ <appendix>
210
+
211
+ ### 与 Ralph 集成
212
+
213
+ Ralph 可以在 A_BUILD_STEPS 中将某些 step 的执行方式标记为 `swarm-workflow`:
214
+
215
+ ```json
216
+ {
217
+ "index": 2,
218
+ "skill": "maestro-swarm-workflow",
219
+ "args": "--script wf-analyze {phase}",
220
+ "stage": "analyze",
221
+ "command_scope": "project",
222
+ "command_path": "<resolved by maestro ralph skills>"
223
+ }
224
+ ```
225
+
226
+ ralph-execute 正常通过 `maestro ralph next` 加载并执行,swarm-workflow 内部再调 Workflow 工具。
227
+
228
+ ### 输出示例
229
+
230
+ ```
231
+ ┌─ wf-analyze ──────────────────────────────────────┐
232
+ │ Explore [████████████████████] 6/6 dimensions │
233
+ │ Synthesize [████████████████] done │
234
+ ├────────────────────────────────────────────────────┤
235
+ │ Score: 7.2/10 Scope: medium Verdict: go │
236
+ │ Findings: 23 total (2 critical, 5 high) │
237
+ │ Cross-cutting: 3 themes │
238
+ │ Decisions: 4 locked, 2 free, 1 deferred │
239
+ ├────────────────────────────────────────────────────┤
240
+ │ Output: .workflow/scratch/20260530-swarm-analyze/ │
241
+ │ Resume: /maestro-swarm-workflow --resume wf_abc123 │
242
+ └────────────────────────────────────────────────────┘
243
+ ```
244
+
245
+ ### Error Codes
246
+
247
+ | Code | Description | Recovery |
248
+ |------|-------------|----------|
249
+ | E001 | No intent and no --script | Prompt for intent |
250
+ | E002 | Ambiguous routing | ask_question |
251
+ | E003 | Script file not found | Check .claude/workflows/ |
252
+ | E004 | Workflow execution failed | Show error, suggest --resume |
253
+ | E005 | Result ingestion failed | Write raw JSON to scratch |
254
+
255
+ </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
@@ -10,8 +10,9 @@ allowed-tools:
10
10
  ---
11
11
  <purpose>
12
12
  Initialize the project-level specs directory by scanning the codebase for conventions, patterns, and tech stack.
13
- Core files (coding, arch, knowhow) are always created. Optional files (quality, debug, test, review) are created only when relevant signals are detected.
14
- All output lands in `.workflow/specs/`.
13
+ Core files (coding, arch, learnings) are always created. Optional spec files (quality, test, ui) are created only when relevant signals are detected.
14
+ 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`.
15
+ Spec output lands in `.workflow/specs/`; recipe output lands in `.workflow/knowhow/`.
15
16
  </purpose>
16
17
 
17
18
  <required_reading>
@@ -36,12 +37,15 @@ Follow '~/.maestro/workflows/specs-setup.md' completely.
36
37
  | E001 | fatal | `.workflow/` directory not initialized -- run `/maestro-init` first | parse_input |
37
38
  | E002 | fatal | No source files found in project -- nothing to scan | scan_codebase |
38
39
  | W001 | warning | Convention detection uncertain for one or more categories -- marked `[UNCERTAIN]` | generate_specs |
40
+ | W002 | warning | Workflow recipe signals detected but commands ambiguous -- recipe skipped | generate_recipes |
41
+ | W003 | warning | Existing recipe slug found -- new content written as `.proposed.md` for manual diff | generate_recipes |
39
42
  </error_codes>
40
43
 
41
44
  <success_criteria>
42
45
  - [ ] `.workflow/specs/` directory created
43
- - [ ] Core files always created: `coding-conventions.md`, `architecture-constraints.md`, `knowhow.md`
44
- - [ ] 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)
45
- - [ ] Report displayed with summary and next steps
46
+ - [ ] Core spec files always created: `coding-conventions.md`, `architecture-constraints.md`, `learnings.md`
47
+ - [ ] 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`).
48
+ - [ ] 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.
49
+ - [ ] Report displayed grouped by destination (specs / recipes / skipped / deferred), with `.proposed.md` files surfaced when an existing recipe slug was preserved.
46
50
  </success_criteria>
47
51
  </output>
@@ -0,0 +1,176 @@
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:
5
+ - ask_question
6
+ - define_subagent
7
+ - grep_search
8
+ - invoke_subagent
9
+ - manage_subagents
10
+ - replace_file_content
11
+ - run_command
12
+ - send_message
13
+ - view_file
14
+ - write_to_file
15
+ agy-subagents:
16
+ - team-worker
17
+ ---
18
+
19
+ ## Sub-Agent Registration (Antigravity)
20
+
21
+ Before any `invoke_subagent` call below, register each sub-agent type once per session by reading the system_prompt from `<agy-agents-dir>/<name>.md` and passing it to `define_subagent`. The `<agy-agents-dir>` is:
22
+ - global install: `~/.gemini/antigravity-cli/agents/`
23
+ - workspace install: `<project>/.agents/agents/`
24
+
25
+ - `define_subagent(name="team-worker", description="<from agents/team-worker.md frontmatter>", system_prompt=<contents of agents/team-worker.md body>, enable_write_tools=true, enable_mcp_tools=true, enable_subagent_tools=false)`
26
+
27
+ **ConversationId tracking**: `invoke_subagent` returns a ConversationId per spawned instance. Subsequent `send_message(Recipient=<ConversationId>, Message=...)` calls require that ConversationId — never use the role name as the recipient.
28
+
29
+ ---
30
+
31
+ # Team Swarm
32
+
33
+ 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`.
34
+
35
+ ## Architecture
36
+
37
+ ```
38
+ view_file(AbsolutePath="<agy-skills-dir>/team-swarm/SKILL.md") + execute inline (args: "task description")
39
+ |
40
+ SKILL.md (this file) = Router
41
+ |
42
+ +--------------+--------------+
43
+ | |
44
+ no --role flag --role <name>
45
+ | |
46
+ Coordinator Worker
47
+ roles/coordinator/role.md roles/<name>/role.md
48
+ |
49
+ +-- Phase 1: gen swarm-config
50
+ +-- Phase 2: init --> Bash: scripts/aco.py init
51
+ +-- Phase 3: iterate (K rounds, each = spawn-and-stop)
52
+ | |
53
+ | +-- Bash: aco.py select --iter k -> N assignments
54
+ | +-- Spawn N x team-worker(ant)
55
+ | +-- [callback when all ants done]
56
+ | +-- (optional) Spawn team-worker(scorer)
57
+ | +-- Bash: aco.py update --iter k
58
+ | +-- Bash: aco.py converged
59
+ | +-- branch: loop k+1 OR Phase 4
60
+ |
61
+ +-- Phase 4: converge --> Bash: aco.py report -> Spawn team-worker(analyst)
62
+ -> best-solution.md
63
+ ```
64
+
65
+ ## Role Registry
66
+
67
+ | Role | Path | Prefix | Inner Loop |
68
+ |------|------|--------|------------|
69
+ | coordinator | [roles/coordinator/role.md](roles/coordinator/role.md) | — | — |
70
+ | ant | [roles/ant/role.md](roles/ant/role.md) | ANT-* | false |
71
+ | scorer | [roles/scorer/role.md](roles/scorer/role.md) | SCORE-* | false |
72
+ | analyst | [roles/analyst/role.md](roles/analyst/role.md) | ANALYST-* | false |
73
+
74
+ ## Role Router
75
+
76
+ Parse `$ARGUMENTS`:
77
+ - Has `--role <name>` -> Read `roles/<name>/role.md`, execute Phase 2-4
78
+ - No `--role` -> `@roles/coordinator/role.md`, execute entry router
79
+
80
+ ## Shared Constants
81
+
82
+ - **Session prefix**: `TS`
83
+ - **Session path**: `.workflow/.team/TS-<slug>-<date>/`
84
+ - **Team name**: `swarm`
85
+ - **Script root**: `<skill_root>/scripts/aco.py` (Python 3.10+)
86
+ - **Message bus**: `mcp__ccw-tools__team_msg(session_id=<session-id>, ...)`
87
+
88
+ ## Worker Spawn Template
89
+
90
+ Coordinator spawns workers using this template:
91
+
92
+ ```
93
+ invoke_subagent([{ TypeName: "team-worker", Role: "<role>", Prompt: "<Prompt>", Workspace: "inherit" }])
94
+ ```
95
+
96
+ ## User Commands
97
+
98
+ | Command | Action |
99
+ |---------|--------|
100
+ | `check` / `status` | View iteration progress + convergence curve |
101
+ | `resume` / `continue` | Resume interrupted iteration |
102
+ | `feedback <text>` | Inject feedback into wisdom; applies at next iteration |
103
+ | `revise <ITER>` | Re-run a specific iteration (rare) |
104
+
105
+ ## Specs Reference
106
+
107
+ | Spec | Purpose |
108
+ |------|---------|
109
+ | [specs/swarm-protocol.md](specs/swarm-protocol.md) | Master protocol: script <-> coordinator interface, data flow |
110
+ | [specs/pheromone-schema.md](specs/pheromone-schema.md) | Pheromone JSON structure, update formula, evaporation |
111
+ | [specs/ant-output-schema.md](specs/ant-output-schema.md) | Critical contract for ant JSON artifacts |
112
+ | [specs/convergence-criteria.md](specs/convergence-criteria.md) | Stop conditions, multi-criterion logic |
113
+ | [specs/swarm-config-template.json](specs/swarm-config-template.json) | User-facing config template with all knobs |
114
+
115
+ ## Scripts
116
+
117
+ | Script | Purpose | Invocation |
118
+ |--------|---------|------------|
119
+ | `scripts/aco.py` | Main CLI: init / select / update / converged / report | `python aco.py --session <path> <cmd>` |
120
+ | `scripts/pheromone.py` | Pheromone matrix module (imported by aco.py) | — |
121
+ | `scripts/scoring.py` | Pluggable scorer (script + fallback modes) | — |
122
+
123
+ ## Session Directory
124
+
125
+ ```
126
+ .workflow/.team/TS-<slug>-<date>/
127
+ ├── team-session.json # Session state
128
+ ├── swarm-config.json # User-facing config (Phase 1 output)
129
+ ├── role-binding.json # Worker role_spec path map
130
+ ├── task-space.json # Resolved nodes list
131
+ ├── pheromone/
132
+ │ ├── current.json # Latest pheromone (each iter overwrites)
133
+ │ ├── init.json # Frozen initial state
134
+ │ └── history/<iter>.json # Per-iter snapshot
135
+ ├── trails/<iter>.jsonl # Per-iter all-ant paths + scores
136
+ ├── scores/iter-<iter>-scores.json # Scorer output (if mode == llm)
137
+ ├── artifacts/
138
+ │ ├── ant-<iter>-<id>.json # Per-ant schema-locked output
139
+ │ ├── swarm-report.json # Phase 4 full report dump
140
+ │ └── best-solution.md # Analyst final synthesis
141
+ ├── best.json # Canonical best solution
142
+ ├── wisdom/ # learnings / decisions / issues
143
+ └── .msg/ # Message bus
144
+ ```
145
+
146
+ ## Completion Action
147
+
148
+ When swarm converges, coordinator presents:
149
+
150
+ ```
151
+ ask_question({
152
+ questions: [{
153
+ question: "Swarm pipeline complete. What would you like to do?",
154
+ header: "Completion",
155
+ multiSelect: false,
156
+ options: [
157
+ { label: "Archive & Clean (Recommended)", description: "Archive session, delete team" },
158
+ { label: "Keep Active", description: "Preserve for follow-up" },
159
+ { label: "Export Best Solution", description: "Copy best-solution.md to target" },
160
+ { label: "Run Another Round", description: "Reset convergence, K more iterations" }
161
+ ]
162
+ }]
163
+ })
164
+ ```
165
+
166
+ ## Error Handling
167
+
168
+ | Scenario | Resolution |
169
+ |----------|------------|
170
+ | `aco.py` not found | Verify `<skill_root>/scripts/aco.py`; check Python install |
171
+ | Python version < 3.10 | Use `python3` or report dependency error |
172
+ | Config validation fails | ask_question to fix, regenerate, retry |
173
+ | All ants fail in iteration | Halt, ask_question (retry / abort / refine config) |
174
+ | Hallucination cluster (>50%) | Pause, ask_question (continue / refine scoring) |
175
+ | Convergence never trips | `max_iterations` safety net always fires |
176
+ | Session corruption | Phase 0 reconciliation; archive if irrecoverable |