maestro-flow 0.4.17 → 0.4.19

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 (165) hide show
  1. package/.agents/skills/maestro/SKILL.md +1 -1
  2. package/.agents/skills/maestro-analyze/SKILL.md +5 -0
  3. package/.agents/skills/maestro-blueprint/SKILL.md +5 -0
  4. package/.agents/skills/maestro-brainstorm/SKILL.md +5 -0
  5. package/.agents/skills/maestro-next/SKILL.md +254 -0
  6. package/.agents/skills/team-swarm/SKILL.md +180 -0
  7. package/.agents/skills/team-swarm/roles/analyst/role.md +187 -0
  8. package/.agents/skills/team-swarm/roles/ant/role.md +169 -0
  9. package/.agents/skills/team-swarm/roles/coordinator/commands/converge.md +146 -0
  10. package/.agents/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  11. package/.agents/skills/team-swarm/roles/coordinator/commands/iterate.md +232 -0
  12. package/.agents/skills/team-swarm/roles/coordinator/role.md +211 -0
  13. package/.agents/skills/team-swarm/roles/scorer/role.md +157 -0
  14. package/.agents/skills/team-swarm/scripts/aco.py +473 -0
  15. package/.agents/skills/team-swarm/scripts/pheromone.py +144 -0
  16. package/.agents/skills/team-swarm/scripts/scoring.py +92 -0
  17. package/.agents/skills/team-swarm/scripts/test_aco.py +475 -0
  18. package/.agents/skills/team-swarm/specs/ant-output-schema.md +119 -0
  19. package/.agents/skills/team-swarm/specs/convergence-criteria.md +106 -0
  20. package/.agents/skills/team-swarm/specs/pheromone-schema.md +123 -0
  21. package/.agents/skills/team-swarm/specs/swarm-config-template.json +71 -0
  22. package/.agents/skills/team-swarm/specs/swarm-protocol.md +117 -0
  23. package/.agy/skills/maestro/SKILL.md +1 -1
  24. package/.agy/skills/maestro-analyze/SKILL.md +5 -0
  25. package/.agy/skills/maestro-blueprint/SKILL.md +5 -0
  26. package/.agy/skills/maestro-brainstorm/SKILL.md +5 -0
  27. package/.agy/skills/maestro-next/SKILL.md +250 -0
  28. package/.agy/skills/team-swarm/SKILL.md +176 -0
  29. package/.agy/skills/team-swarm/roles/analyst/role.md +183 -0
  30. package/.agy/skills/team-swarm/roles/ant/role.md +165 -0
  31. package/.agy/skills/team-swarm/roles/coordinator/commands/converge.md +134 -0
  32. package/.agy/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  33. package/.agy/skills/team-swarm/roles/coordinator/commands/iterate.md +202 -0
  34. package/.agy/skills/team-swarm/roles/coordinator/role.md +209 -0
  35. package/.agy/skills/team-swarm/roles/scorer/role.md +153 -0
  36. package/.agy/skills/team-swarm/scripts/aco.py +473 -0
  37. package/.agy/skills/team-swarm/scripts/pheromone.py +144 -0
  38. package/.agy/skills/team-swarm/scripts/scoring.py +92 -0
  39. package/.agy/skills/team-swarm/scripts/test_aco.py +475 -0
  40. package/.agy/skills/team-swarm/specs/ant-output-schema.md +119 -0
  41. package/.agy/skills/team-swarm/specs/convergence-criteria.md +106 -0
  42. package/.agy/skills/team-swarm/specs/pheromone-schema.md +123 -0
  43. package/.agy/skills/team-swarm/specs/swarm-config-template.json +71 -0
  44. package/.agy/skills/team-swarm/specs/swarm-protocol.md +117 -0
  45. package/.claude/commands/maestro-analyze.md +5 -0
  46. package/.claude/commands/maestro-blueprint.md +5 -0
  47. package/.claude/commands/maestro-brainstorm.md +5 -0
  48. package/.claude/commands/maestro-next.md +252 -0
  49. package/.claude/commands/maestro.md +1 -1
  50. package/.claude/skills/team-swarm/SKILL.md +178 -0
  51. package/.claude/skills/team-swarm/roles/analyst/role.md +185 -0
  52. package/.claude/skills/team-swarm/roles/ant/role.md +167 -0
  53. package/.claude/skills/team-swarm/roles/coordinator/commands/converge.md +146 -0
  54. package/.claude/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  55. package/.claude/skills/team-swarm/roles/coordinator/commands/iterate.md +232 -0
  56. package/.claude/skills/team-swarm/roles/coordinator/role.md +209 -0
  57. package/.claude/skills/team-swarm/roles/scorer/role.md +155 -0
  58. package/.claude/skills/team-swarm/scripts/aco.py +473 -0
  59. package/.claude/skills/team-swarm/scripts/pheromone.py +144 -0
  60. package/.claude/skills/team-swarm/scripts/scoring.py +92 -0
  61. package/.claude/skills/team-swarm/scripts/test_aco.py +475 -0
  62. package/.claude/skills/team-swarm/specs/ant-output-schema.md +119 -0
  63. package/.claude/skills/team-swarm/specs/convergence-criteria.md +106 -0
  64. package/.claude/skills/team-swarm/specs/pheromone-schema.md +123 -0
  65. package/.claude/skills/team-swarm/specs/swarm-config-template.json +71 -0
  66. package/.claude/skills/team-swarm/specs/swarm-protocol.md +117 -0
  67. package/.codex/skills/learn-decompose/SKILL.md +34 -3
  68. package/.codex/skills/learn-retro/SKILL.md +31 -1
  69. package/.codex/skills/learn-second-opinion/SKILL.md +34 -4
  70. package/.codex/skills/maestro-analyze/SKILL.md +44 -5
  71. package/.codex/skills/maestro-blueprint/SKILL.md +5 -0
  72. package/.codex/skills/maestro-brainstorm/SKILL.md +46 -0
  73. package/.codex/skills/maestro-execute/SKILL.md +61 -5
  74. package/.codex/skills/maestro-milestone-audit/SKILL.md +64 -13
  75. package/.codex/skills/maestro-milestone-complete/SKILL.md +12 -0
  76. package/.codex/skills/maestro-next/SKILL.md +297 -0
  77. package/.codex/skills/maestro-plan/SKILL.md +36 -1
  78. package/.codex/skills/maestro-player/SKILL.md +25 -6
  79. package/.codex/skills/maestro-ralph/SKILL.md +17 -10
  80. package/.codex/skills/maestro-ralph-execute/SKILL.md +2 -1
  81. package/.codex/skills/maestro-roadmap/SKILL.md +35 -4
  82. package/.codex/skills/maestro-ui-codify/SKILL.md +38 -10
  83. package/.codex/skills/maestro-verify/SKILL.md +40 -5
  84. package/.codex/skills/manage-codebase-rebuild/SKILL.md +52 -5
  85. package/.codex/skills/manage-issue-discover/SKILL.md +106 -15
  86. package/.codex/skills/quality-auto-test/SKILL.md +70 -16
  87. package/.codex/skills/quality-debug/SKILL.md +139 -28
  88. package/.codex/skills/quality-refactor/SKILL.md +61 -11
  89. package/.codex/skills/quality-review/SKILL.md +45 -9
  90. package/.codex/skills/quality-test/SKILL.md +58 -3
  91. package/.codex/skills/security-audit/SKILL.md +38 -0
  92. package/.codex/skills/spec-map/SKILL.md +65 -8
  93. package/.codex/skills/team-coordinate/SKILL.md +28 -11
  94. package/.codex/skills/team-coordinate/specs/role-catalog.md +20 -0
  95. package/.codex/skills/team-lifecycle-v4/SKILL.md +23 -7
  96. package/.codex/skills/team-lifecycle-v4/instructions/agent-instruction.md +20 -0
  97. package/.codex/skills/team-quality-assurance/SKILL.md +40 -2
  98. package/.codex/skills/team-review/SKILL.md +42 -2
  99. package/.codex/skills/team-tech-debt/SKILL.md +45 -2
  100. package/.codex/skills/team-testing/SKILL.md +42 -2
  101. package/dashboard/dist-server/dashboard/src/server/wiki/search.d.ts +6 -4
  102. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +50 -8
  103. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  104. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +32 -0
  105. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +294 -0
  106. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  107. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +1 -0
  108. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +35 -1
  109. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  110. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js +235 -0
  111. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js.map +1 -1
  112. package/dist/src/commands/install.js +5 -1
  113. package/dist/src/commands/install.js.map +1 -1
  114. package/dist/src/i18n/locales/en.d.ts.map +1 -1
  115. package/dist/src/i18n/locales/en.js +9 -0
  116. package/dist/src/i18n/locales/en.js.map +1 -1
  117. package/dist/src/i18n/locales/zh.d.ts.map +1 -1
  118. package/dist/src/i18n/locales/zh.js +9 -0
  119. package/dist/src/i18n/locales/zh.js.map +1 -1
  120. package/dist/src/i18n/types.d.ts +3 -0
  121. package/dist/src/i18n/types.d.ts.map +1 -1
  122. package/dist/src/ralph/cmd-check.js +1 -1
  123. package/dist/src/ralph/cmd-check.js.map +1 -1
  124. package/dist/src/ralph/cmd-complete.js +1 -1
  125. package/dist/src/ralph/cmd-complete.js.map +1 -1
  126. package/dist/src/ralph/cmd-next.d.ts.map +1 -1
  127. package/dist/src/ralph/cmd-next.js +12 -4
  128. package/dist/src/ralph/cmd-next.js.map +1 -1
  129. package/dist/src/ralph/cmd-session.js +2 -2
  130. package/dist/src/ralph/cmd-session.js.map +1 -1
  131. package/dist/src/ralph/status-store.d.ts +8 -1
  132. package/dist/src/ralph/status-store.d.ts.map +1 -1
  133. package/dist/src/ralph/status-store.js +12 -2
  134. package/dist/src/ralph/status-store.js.map +1 -1
  135. package/dist/src/tools/store-knowhow.d.ts.map +1 -1
  136. package/dist/src/tools/store-knowhow.js +51 -64
  137. package/dist/src/tools/store-knowhow.js.map +1 -1
  138. package/dist/src/tui/install-ui/HooksConfig.d.ts +5 -1
  139. package/dist/src/tui/install-ui/HooksConfig.d.ts.map +1 -1
  140. package/dist/src/tui/install-ui/HooksConfig.js +5 -3
  141. package/dist/src/tui/install-ui/HooksConfig.js.map +1 -1
  142. package/dist/src/tui/install-ui/InstallConfirm.d.ts +2 -0
  143. package/dist/src/tui/install-ui/InstallConfirm.d.ts.map +1 -1
  144. package/dist/src/tui/install-ui/InstallConfirm.js +1 -1
  145. package/dist/src/tui/install-ui/InstallConfirm.js.map +1 -1
  146. package/dist/src/tui/install-ui/InstallExecution.d.ts +1 -0
  147. package/dist/src/tui/install-ui/InstallExecution.d.ts.map +1 -1
  148. package/dist/src/tui/install-ui/InstallExecution.js +26 -3
  149. package/dist/src/tui/install-ui/InstallExecution.js.map +1 -1
  150. package/dist/src/tui/install-ui/InstallFlow.d.ts +1 -1
  151. package/dist/src/tui/install-ui/InstallFlow.d.ts.map +1 -1
  152. package/dist/src/tui/install-ui/InstallFlow.js +76 -16
  153. package/dist/src/tui/install-ui/InstallFlow.js.map +1 -1
  154. package/dist/src/tui/install-ui/InstallHub.d.ts +2 -0
  155. package/dist/src/tui/install-ui/InstallHub.d.ts.map +1 -1
  156. package/dist/src/tui/install-ui/InstallHub.js +8 -0
  157. package/dist/src/tui/install-ui/InstallHub.js.map +1 -1
  158. package/dist/src/tui/install-ui/InstallResult.d.ts.map +1 -1
  159. package/dist/src/tui/install-ui/InstallResult.js +1 -1
  160. package/dist/src/tui/install-ui/InstallResult.js.map +1 -1
  161. package/dist/src/utils/update-notices.js +23 -0
  162. package/dist/src/utils/update-notices.js.map +1 -1
  163. package/package.json +1 -1
  164. package/workflows/finish-work.md +119 -0
  165. package/workflows/milestone-complete.md +23 -1
@@ -25,7 +25,7 @@ Entry points:
25
25
  - **`/maestro --dry-run "intent"`** — Show chain, no execution
26
26
  - **`/maestro --super "intent"`** — Production-ready mode (read maestro-super.md)
27
27
 
28
- Session: `.workflow/.maestro/{session_id}/status.json`
28
+ **Session**: `.workflow/.maestro/{session_id}/status.json` — 工作流唯一真源。session_id 格式 `maestro-{YYYYMMDD-HHmmss}`(本 command 创建,静态链)或 `ralph-{YYYYMMDD-HHmmss}`(`/maestro-ralph` 创建,自适应链)。两类都由 `/maestro-ralph-execute` 推进;schema 与 ralph 共用(含 `ralph_protocol_version: "1"` + `active_step_index`)。
29
29
  </purpose>
30
30
 
31
31
  <deferred_reading>
@@ -165,4 +165,9 @@ Both modes (full + quick):
165
165
  - [ ] Deferred items auto-created as issues (if any)
166
166
  - [ ] Artifact registered in state.json with correct scope/milestone/phase
167
167
  - [ ] Next step routed (impeccable/plan for Go, brainstorm for No-Go)
168
+ - [ ] Session sealed via finish-work (archive.json written, optional spec/knowhow extraction)
168
169
  </success_criteria>
170
+
171
+ <on_complete>
172
+ @~/.maestro/workflows/finish-work.md — SESSION_DIR=OUTPUT_DIR, SESSION_TYPE=analyze, SESSION_ID={artifact_id}, LINKED_MILESTONE={target_milestone or null}
173
+ </on_complete>
@@ -130,4 +130,9 @@ P6 gate: Pass (>=80%) → Handoff | Review (60-79%) → Handoff w/caveats | Fail
130
130
  - [ ] Readiness gate: Pass (>=80%) or Review (>=60%) with documented caveats
131
131
  - [ ] Artifact registered in state.json (type=blueprint)
132
132
  - [ ] context-package.json generated for downstream consumption
133
+ - [ ] On gate Pass/Review: session sealed via finish-work (archive.json + optional spec/knowhow extraction). On Fail: skip — session stays active, excluded from wiki search.
133
134
  </success_criteria>
135
+
136
+ <on_complete>
137
+ @~/.maestro/workflows/finish-work.md — SESSION_DIR={session_dir}, SESSION_TYPE=blueprint, SESSION_ID={session_id}, LINKED_MILESTONE=null
138
+ </on_complete>
@@ -132,4 +132,9 @@ Single role mode:
132
132
  - [ ] `{role}/analysis-F-*.md` written when guidance §10 feature list available
133
133
  - [ ] §2 Decisions table references guidance decision IDs
134
134
  - [ ] Session metadata updated
135
+ - [ ] Session sealed via finish-work (auto mode only)
135
136
  </success_criteria>
137
+
138
+ <on_complete>
139
+ @~/.maestro/workflows/finish-work.md — SESSION_DIR={output_dir}, SESSION_TYPE=brainstorm, SESSION_ID={artifact_id}, LINKED_MILESTONE=null
140
+ </on_complete>
@@ -0,0 +1,254 @@
1
+ ---
2
+ name: maestro-next
3
+ description: Single-command recommendation — pick the best next command from the pool and execute it
4
+ argument-hint: "<intent> [-y] [--dry-run] [--top N] [--list]"
5
+ allowed-tools:
6
+ - read_file
7
+ - shell
8
+ - find_files
9
+ - search
10
+ - invoke_skill
11
+ - ask_user
12
+ ---
13
+ <!-- Open-standard mirror generated by scripts/build-agents-standard.mjs — do not edit; re-run after editing .claude/ source. -->
14
+
15
+
16
+ <purpose>
17
+ 单链推荐:解析 intent + project state → 路由表评分 → 推荐**单个原子命令** → 确认后通过 `invoke_skill()` 执行。
18
+
19
+ 与 `/maestro` / `/maestro-ralph` 区别:
20
+ - 不创建 session、不构建 chain、不写 status.json
21
+ - 始终只推 1 个 top pick,最多列 2-3 个备选
22
+ - 适用场景:意图清晰且单步即可完成;或需要定向推荐时
23
+ </purpose>
24
+
25
+ <context>
26
+ $ARGUMENTS — 意图文本 + 可选 flags。
27
+
28
+ **Flags:**
29
+ - `-y` / `--yes` — 跳过确认,直接执行 top pick
30
+ - `--dry-run` — 仅显示推荐结果,不执行
31
+ - `--top N` — 显示前 N 个候选(默认 3)
32
+ - `--list` — 仅列出可推荐命令池,不做推荐
33
+
34
+ **候选池:** 仅 A_SCORE_CANDIDATES 路由表中列出的命令。管线编排器(`maestro` / `maestro-ralph*` / `maestro-player` / `maestro-composer`)**永远不在候选池**。
35
+ </context>
36
+
37
+ <invariants>
38
+ 1. **不创建 session / 不写 status.json / 不触发后续 chain** — 单次原子执行,产出由目标命令自行管理
39
+ 2. **管线编排器不在候选池** — 仅推荐原子命令
40
+ 3. **空 intent 或 "继续/下一步/next/接下来"** → 直接采用 lifecycle_position 推断的自然下一步
41
+ 4. **字面命中路由表优先** — lifecycle 仅作加分;命中失败时 lifecycle 上升为决定性信号
42
+ 5. **参数传递** — 默认 intent 原文作为第一个 arg;用户可在确认环节修改;`-y` 仅当用户传入时透传到 skill args
43
+ 6. **`--list` 模式跳过 lifecycle 推断与评分**,仅按 workflow 簇分组列出全部候选
44
+ </invariants>
45
+
46
+ <state_machine>
47
+
48
+ <states>
49
+ S_PARSE — 解析 ARGUMENTS、提取 flags PERSIST: —
50
+ S_STATE — 读 project state、推断 lifecycle_position PERSIST: —
51
+ S_RANK — 路由表评分、生成 top-N candidates PERSIST: —
52
+ S_LIST — `--list` 模式:分组展示候选池 PERSIST: —
53
+ S_PRESENT — 显示 top pick + 备选 + 推荐理由 + 执行参数 PERSIST: —
54
+ S_CONFIRM — ask_user 选择/修改参数(auto_mode 跳过) PERSIST: —
55
+ S_EXECUTE — `invoke_skill({ skill, args })` 单次调用 PERSIST: —
56
+ S_FALLBACK — intent 空且 clarification 失败 PERSIST: —
57
+ </states>
58
+
59
+ <transitions>
60
+
61
+ S_PARSE:
62
+ → S_LIST WHEN: --list flag
63
+ → S_STATE WHEN: intent text present
64
+ → S_STATE WHEN: keyword "continue"/"next"/"go"/"继续"/"下一步"/"接下来"
65
+ → S_PARSE WHEN: no intent (max 1 clarify round) DO: ask_user
66
+ → S_FALLBACK WHEN: clarification empty
67
+
68
+ S_STATE:
69
+ → S_RANK DO: A_INFER_LIFECYCLE
70
+
71
+ S_RANK:
72
+ → S_PRESENT DO: A_SCORE_CANDIDATES
73
+
74
+ S_LIST:
75
+ → END DO: 按 workflow 簇分组列出全部候选 + description
76
+
77
+ S_PRESENT:
78
+ → END WHEN: --dry-run
79
+ → S_EXECUTE WHEN: -y / --yes
80
+ → S_CONFIRM WHEN: not auto_mode
81
+
82
+ S_CONFIRM:
83
+ → S_EXECUTE WHEN: 用户确认 top pick / 选备选 / 改参数
84
+ → END WHEN: 用户取消
85
+
86
+ S_EXECUTE:
87
+ → END DO: invoke_skill({ skill: <chosen>, args: <args> }) → 输出 "✅ 已执行 /<command>"
88
+
89
+ S_FALLBACK:
90
+ → END DO: raise E001
91
+
92
+ </transitions>
93
+
94
+ <actions>
95
+
96
+ ### A_INFER_LIFECYCLE
97
+
98
+ 读 project state 推断 `lifecycle_position`(核心信号):
99
+
100
+ ```bash
101
+ cat .workflow/state.json 2>$null # phase / milestone / artifacts
102
+ ls -la .workflow/scratch/ 2>$null | head -10 # 最近 artifact (mtime DESC)
103
+ ls -la .workflow/.maestro/ 2>$null | head -5 # 进行中的 session
104
+ ```
105
+
106
+ **项目状态 → lifecycle_position → 自然下一步:**
107
+
108
+ | 项目状态 | lifecycle_position | 自然下一步 |
109
+ |---------|-------------------|-----------|
110
+ | 无 `.workflow/` + 无源码 | brainstorm | `maestro-brainstorm` |
111
+ | 无 `.workflow/` + 有源码 | init | `maestro-init` |
112
+ | 有 state.json,无 roadmap,无 milestones | analyze-macro | `maestro-analyze` (宏观调研) |
113
+ | 有 macro analyze artifact,无 roadmap | roadmap | `maestro-roadmap` |
114
+ | 有 roadmap,未启动 phase | analyze | `maestro-analyze {phase}` |
115
+ | 最新 artifact = analyze | plan | `maestro-plan {phase}` |
116
+ | 最新 artifact = plan | execute | `maestro-execute {phase}` |
117
+ | 最新 artifact = execute | verify | `maestro-verify {phase}` |
118
+ | verify passed | review | `quality-review {phase}` |
119
+ | review verdict=PASS | test-gen | `quality-auto-test {phase}` |
120
+ | 测试全绿 | milestone-audit | `maestro-milestone-audit` |
121
+ | 当前 milestone 全 phase 完成 | milestone-complete | `maestro-milestone-complete` |
122
+ | 任一 stage 产物含 gaps/failed | debug | `quality-debug {gap}` |
123
+
124
+ **Maestro Lifecycle 主线:**
125
+ ```
126
+ brainstorm → blueprint → init → analyze-macro → roadmap
127
+ → [per phase] analyze → plan → execute → verify
128
+ → [quality gate] review → auto-test → test
129
+ → milestone-audit → milestone-complete → milestone-release
130
+ ```
131
+
132
+ ### A_SCORE_CANDIDATES
133
+
134
+ **评分信号**(高→低):
135
+
136
+ | 信号 | 权重 | 说明 |
137
+ |------|------|------|
138
+ | intent 命中路由表关键词 | 高 | 字面匹配主依据 |
139
+ | **lifecycle 自然下一步** | **高** | 空 intent / "继续" / "next" 时为决定性 |
140
+ | `name` 关键词命中 intent | 中 | intent 含 "test" → quality-test/quality-auto-test 加分 |
141
+ | Workflow 簇匹配 | 中 | intent 涉及学习/知识/issue 等场景触发对应簇 |
142
+ | Recent activity 反向避免 | 低 | 刚完成的 stage 短期内降权 |
143
+
144
+ **特殊意图处理:**
145
+
146
+ | Intent 模式 | top pick |
147
+ |------------|---------|
148
+ | 空 / "继续" / "下一步" / "next" / "接下来" | lifecycle 自然下一步 |
149
+ | "什么状态" / "现在到哪了" / "status" | `manage-status` |
150
+ | 字面命中路由表 | 路由表优先(lifecycle 仅加分) |
151
+ | 无任何匹配 | lifecycle 下一步 + raise W002 |
152
+
153
+ **意图 → 命令路由表**(候选池):
154
+
155
+ | 意图关键词 | 推荐命令 |
156
+ |-----------|---------|
157
+ | 头脑风暴 / 探索 / brainstorm / ideate | `maestro-brainstorm` |
158
+ | 规格 / 正式文档 / spec-generate / blueprint | `maestro-blueprint` |
159
+ | 分析 / analyze / 多维度调研 | `maestro-analyze` |
160
+ | 规划 / plan / 任务分解 | `maestro-plan` |
161
+ | 实现 / 执行 / execute | `maestro-execute` |
162
+ | 验证 / verify / 验收 | `maestro-verify` |
163
+ | 调试 / debug / 排查 / bug | `quality-debug` |
164
+ | 审查 / review / 代码审查 | `quality-review` |
165
+ | 测试 / test / UAT | `quality-test` / `quality-auto-test` |
166
+ | 重构 / refactor / 技术债 | `quality-refactor` |
167
+ | 同步文档 / sync docs | `quality-sync` |
168
+ | 回顾 / retro | `quality-retrospective` / `learn-retro` |
169
+ | issue / 缺陷管理 | `manage-issue` / `manage-issue-discover` |
170
+ | wiki / 知识图谱 | `manage-wiki` / `wiki-connect` / `wiki-digest` |
171
+ | spec / 规则 / 约束 | `spec-load` / `spec-add` / `spec-setup` |
172
+ | 项目初始化 / init | `maestro-init` |
173
+ | 状态 / status / 仪表盘 | `manage-status` |
174
+ | 文档重建 / codebase 文档 | `manage-codebase-rebuild` / `manage-codebase-refresh` |
175
+ | 安全 / security / OWASP | `security-audit` |
176
+ | 跟读 / 学习 / 阅读源码 | `learn-follow` / `learn-investigate` |
177
+ | 第二意见 / challenge / consult | `learn-second-opinion` |
178
+ | 提取知识 / harvest | `manage-harvest` / `manage-knowhow-capture` |
179
+ | 设计 / UI / 前端打磨 | `maestro-impeccable` |
180
+ | 里程碑 / milestone | `maestro-milestone-audit` / `maestro-milestone-release` / `maestro-milestone-complete` |
181
+ | fork / 分支 / 并行开发 | `maestro-fork` / `maestro-merge` |
182
+ | 覆盖层 / overlay / amend | `maestro-overlay` / `maestro-amend` |
183
+
184
+ **辅助 workflow 簇**(场景触发,非主线):
185
+
186
+ | 簇 | 触发 | 主推链路 |
187
+ |----|------|---------|
188
+ | Learning | 接触新代码/未知模块 | `learn-follow` → `learn-decompose` → `learn-second-opinion` |
189
+ | Knowledge | 提炼经验 / 沉淀知识 | `manage-harvest` → `manage-knowhow-capture` → `spec-add` |
190
+ | Wiki | 知识图谱整理 | `manage-wiki` → `wiki-connect` → `wiki-digest` |
191
+ | Issue | 缺陷管理 | `manage-issue-discover` → `manage-issue` |
192
+ | 文档同步 | 代码大改后 | `quality-sync` → `manage-codebase-refresh` |
193
+ | 重构 | 技术债积累 | `quality-refactor` → `quality-review` |
194
+ | 发布 | 里程碑结束 | `maestro-milestone-audit` → `maestro-milestone-release` |
195
+ | 并行开发 | 多 milestone 并行 | `maestro-fork` → ... → `maestro-merge` |
196
+
197
+ 输出 ranked candidates,取 top N(默认 3)。
198
+
199
+ </actions>
200
+
201
+ </state_machine>
202
+
203
+ <presentation>
204
+
205
+ ### `--list` 模式
206
+
207
+ 按 workflow 簇(主线 / Learning / Knowledge / Wiki / Issue / 文档 / 重构 / 发布 / 并行)分组展示全部候选 + description,结束。
208
+
209
+ ### 正常模式
210
+
211
+ ```
212
+ 🎯 推荐 (top pick): /<command-name>
213
+ <description>
214
+ 推荐理由: <命中规则 + lifecycle 位置一句话>
215
+
216
+ 备选:
217
+ 2. /<alt-1> — <description>
218
+ 3. /<alt-2> — <description>
219
+
220
+ 执行参数: <args>
221
+ ```
222
+
223
+ `--dry-run` 展示后结束;`-y` 直接 S_EXECUTE;否则 ask_user 提供:执行 top pick / 选备选 / 修改参数 / 取消。
224
+
225
+ </presentation>
226
+
227
+ <appendix>
228
+
229
+ ### Error Codes
230
+
231
+ | Code | Severity | Condition | Recovery |
232
+ |------|----------|-----------|----------|
233
+ | E001 | error | intent 空且 clarification 后仍空 | 提供意图描述或使用 `--list` 浏览 |
234
+ | E002 | error | 候选池为空(`.claude/commands/` 缺失或无 .md) | 检查 commands 目录 |
235
+ | E003 | error | 选定命令名无法解析为有效 skill | 列出有效命令重选 |
236
+ | W001 | warning | top1 与 top2 得分差距 < 阈值 | 强制展示前 3 让用户裁决 |
237
+ | W002 | warning | intent 与所有候选匹配度均低 | 提示考虑 `/maestro` 或 `/maestro-ralph` 走管线 |
238
+
239
+ ### Success Criteria
240
+
241
+ - [ ] Intent 解析 + flags 提取完成
242
+ - [ ] 读取 `.workflow/state.json` + scratch artifacts 推断 lifecycle_position
243
+ - [ ] 候选池等于路由表(管线编排器不在)
244
+ - [ ] 评分综合:intent 字面匹配 + lifecycle 下一步 + workflow 簇 + recent activity
245
+ - [ ] 空 intent / "继续" / "下一步" → 直接采用 lifecycle 推断的下一步
246
+ - [ ] top pick 展示附"推荐理由"(命中规则 + lifecycle 位置)
247
+ - [ ] `--dry-run` 仅展示,不执行
248
+ - [ ] `-y` 自动执行 top pick;用户传入时透传到 skill args
249
+ - [ ] 非自动模式通过 ask_user 确认或选备选
250
+ - [ ] 选定命令通过单次 `invoke_skill()` 调用执行
251
+ - [ ] 不创建 session / 不生成 status.json / 不触发后续 chain
252
+ - [ ] `--list` 模式按 workflow 簇分组展示
253
+
254
+ </appendix>
@@ -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 |
@@ -0,0 +1,187 @@
1
+ ---
2
+ role: analyst
3
+ prefix: ANALYST
4
+ inner_loop: false
5
+ output_tag: "[analyst]"
6
+ message_types:
7
+ success: analysis_ready
8
+ error: error
9
+ ---
10
+ <!-- Open-standard mirror generated by scripts/build-agents-standard.mjs — do not edit; re-run after editing .claude/ source. -->
11
+
12
+
13
+ # Analyst Role — Phase 2-4
14
+
15
+ Tag: `[analyst]` | Prefix: `ANALYST-*`
16
+ Responsibility: After swarm converges, synthesize the best solution + top trails + convergence curve into a human-readable `best-solution.md` report. Provides interpretation, not just data dump.
17
+
18
+ ## Boundaries
19
+
20
+ ### MUST
21
+ - Read `<session>/best.json`, `<session>/artifacts/swarm-report.json`, all `<session>/trails/*.jsonl`
22
+ - Produce `<session>/artifacts/best-solution.md` as the final deliverable
23
+ - Explain WHY the best path won (which decisions mattered, evidence chain)
24
+ - Compare best vs runner-ups to surface stability vs luck
25
+ - Document convergence story (entropy curve, when stagnation hit)
26
+
27
+ ### MUST NOT
28
+ - Re-score solutions (that is scorer's job — analyst takes verified_score as given)
29
+ - Modify best.json, trails, or pheromone state
30
+ - Generate solutions of its own — analyst synthesizes existing ant outputs
31
+ - Exceed ~150 lines in best-solution.md (be sharp, not verbose)
32
+
33
+ ## Phase 2: Context Loading
34
+
35
+ | Input | Source | Required |
36
+ |-------|--------|----------|
37
+ | Original objective | `<session>/swarm-config.json#ant_prompt.objective` | Yes |
38
+ | Best solution | `<session>/best.json` | Yes |
39
+ | Full swarm report | `<session>/artifacts/swarm-report.json` | Yes |
40
+ | All trails | `<session>/trails/*.jsonl` | Yes |
41
+ | Convergence reason | swarm-report.json or `aco.py converged` output | Yes |
42
+ | Best ant artifact | `<session>/artifacts/ant-<best.iteration>-<best.id>.json` (full evidence) | Yes |
43
+ | Issues log | `<session>/wisdom/issues.md` | Optional |
44
+
45
+ Workflow:
46
+ 1. Extract session path from task description
47
+ 2. Read swarm-config.json -> capture objective
48
+ 3. Read best.json -> identify best ant
49
+ 4. Read full swarm-report.json -> get top_k + convergence_curve
50
+ 5. Read the best ant's full artifact for evidence chain
51
+ 6. Read all trails/*.jsonl into a list (chronological)
52
+
53
+ ## Phase 3: Synthesis
54
+
55
+ ### 3.1 Structure the report
56
+
57
+ Layout for `best-solution.md`:
58
+
59
+ ```markdown
60
+ # Swarm Result — <objective_short_form>
61
+
62
+ ## Best Solution
63
+
64
+ **Path**: node_a → node_c → node_f
65
+ **Verified Score**: 0.82
66
+ **Iteration**: 3 of 5
67
+ **Ant**: ANT-3-2
68
+
69
+ ### Summary
70
+ <one paragraph — what the best solution proposes and why it answers the objective>
71
+
72
+ ### Evidence Chain
73
+ - `src/foo.ts:42` — <how this evidence supports the decision>
74
+ - `tests/foo.spec.ts:18` — <...>
75
+
76
+ ### Candidate Artifact
77
+ <extract from best.candidate_solution — quote or summarize, link to file if file_ref>
78
+
79
+ ## Why This Path Won
80
+
81
+ | Decision | Pheromone-guided? | Why it mattered |
82
+ |----------|-------------------|-----------------|
83
+ | start = node_a | weighted | <reason> |
84
+ | a → c | yes (0.45 hint) | <reason> |
85
+ | c → f | NO (deviation) | <reason> — this was the key call |
86
+
87
+ ## Runner-Up Solutions
88
+
89
+ | Rank | Ant | Path | Score | Diff from best |
90
+ |------|-----|------|-------|----------------|
91
+ | 2 | ANT-2-1 | a → b → e | 0.74 | -0.08; weaker evidence at e |
92
+ | 3 | ANT-4-3 | a → c → g | 0.71 | -0.11; valid but less specific |
93
+
94
+ ## Convergence Story
95
+
96
+ Iterations: 4 of 5 max
97
+ Trigger: stagnation (best unchanged for 2 iterations)
98
+
99
+ Entropy curve:
100
+ - iter 1: 3.21 (broad exploration)
101
+ - iter 2: 2.45 (narrowing on node_a region)
102
+ - iter 3: 1.85 (best emerges at ANT-3-2)
103
+ - iter 4: 1.72 (consensus around best, no improvement)
104
+
105
+ Interpretation: <2-3 sentences on whether the swarm converged on a genuine optimum or got stuck>
106
+
107
+ ## Caveats
108
+
109
+ - <e.g., 40% of ants in iter 2 flagged as hallucinations>
110
+ - <e.g., evidence for node_f is single-source — recommend manual verification>
111
+ - <e.g., search space had only N nodes — larger space may surface better solutions>
112
+
113
+ ## Reproducibility
114
+
115
+ - Config: `swarm-config.json` (pinned)
116
+ - Best path: `best.json`
117
+ - Full trails: `trails/<iter>.jsonl`
118
+ - Random seed: <if used>
119
+ ```
120
+
121
+ ### 3.2 Interpretation rules
122
+
123
+ - **Why-it-won analysis** is the highest-value content. Don't just describe the path — explain which decisions were pivotal.
124
+ - **Pheromone vs deviation**: track which steps followed pheromone hints vs deviated. Deviations that produced higher scores are the most interesting signal.
125
+ - **Runner-up diff**: surface why #2 lost — was it a weaker path or just unlucky evidence?
126
+ - **Caveats are mandatory**: every swarm result has limitations. List them honestly.
127
+
128
+ ### 3.3 Constraints
129
+
130
+ - Target ≤ 150 lines
131
+ - No prose padding — every section earns its place
132
+ - Quote evidence verbatim where possible (file:line refs)
133
+ - Don't editorialize beyond what evidence supports
134
+
135
+ ## Phase 4: Verify + Publish
136
+
137
+ ### Behavioral Traits
138
+
139
+ #### Accuracy
140
+ - Every cited path/score MUST match best.json or trails source
141
+ - Every evidence reference MUST be verifiable (Read to confirm if file_ref)
142
+ - Convergence curve numbers MUST match swarm-report.json#convergence_curve
143
+
144
+ #### Feedback Contract
145
+ | Field | Required | Content |
146
+ |-------|----------|---------|
147
+ | artifacts_written | Always | `<session>/artifacts/best-solution.md` |
148
+ | line_count | Always | int (target ≤ 150) |
149
+ | verification_method | Always | "cross_ref_with_best.json + evidence_verified" |
150
+
151
+ #### Quality Gate
152
+ - Final report file exists and parses as markdown
153
+ - All sections present (Best Solution / Why Won / Runner-Ups / Convergence / Caveats / Reproducibility)
154
+ - Line count ≤ 200 (hard cap — fail if exceeded, retry with sharper edit)
155
+
156
+ ### Verification Steps
157
+
158
+ 1. Read written best-solution.md back
159
+ 2. Cross-check best.score against best.json
160
+ 3. Confirm runner-up scores against trails
161
+ 4. If file_ref evidence in best.candidate_solution -> Read to confirm file exists
162
+ 5. Count lines — if > 200, condense and rewrite
163
+
164
+ ### State Update
165
+
166
+ ```json
167
+ {
168
+ "task_id": "ANALYST-1",
169
+ "role": "analyst",
170
+ "status": "completed",
171
+ "artifact_path": "<session>/artifacts/best-solution.md",
172
+ "best_score": <float>,
173
+ "best_ant_id": "<id>",
174
+ "line_count": <int>,
175
+ "verification": "cross_ref_pass + evidence_verified"
176
+ }
177
+ ```
178
+
179
+ ## Error Handling
180
+
181
+ | Scenario | Resolution |
182
+ |----------|------------|
183
+ | best.json missing | Pipeline produced no valid ant — write minimal report with `status: no_solution` |
184
+ | Trails empty | Same as above — no exploration data to analyze |
185
+ | Best ant artifact missing | Use only best.json fields; note as caveat |
186
+ | Cross-ref mismatch (score discrepancy) | Trust best.json; note discrepancy in caveats |
187
+ | Line count > 200 after rewrite | Hard-fail report; coordinator decides retry vs accept |