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,106 @@
1
+ # Convergence Criteria
2
+
3
+ When does the swarm stop iterating? Defines stop conditions computed by `aco.py converged`.
4
+
5
+ ## Stop Conditions (any-of)
6
+
7
+ The swarm stops when **any** of the configured criteria triggers:
8
+
9
+ | Criterion | Default | Description |
10
+ |-----------|---------|-------------|
11
+ | `max_iterations` | 5 | Hard cap on iteration count |
12
+ | `stagnation` | patience = 2 | Best score unchanged for N iterations |
13
+ | `entropy_floor` | 0.5 | Pheromone Shannon entropy drops below threshold (matrix highly concentrated) |
14
+ | `budget_tokens` | 100000 | Total token cost exceeds budget |
15
+ | `target_score` | 0.95 | Best verified_score crosses target |
16
+
17
+ ## Configuration
18
+
19
+ ```json
20
+ {
21
+ "convergence": {
22
+ "max_iterations": 5,
23
+ "stagnation": { "enabled": true, "patience": 2, "min_delta": 0.01 },
24
+ "entropy_floor": { "enabled": true, "threshold": 0.5 },
25
+ "budget_tokens": { "enabled": false, "max": 100000 },
26
+ "target_score": { "enabled": true, "value": 0.95 }
27
+ }
28
+ }
29
+ ```
30
+
31
+ ## Output Schema (aco.py converged)
32
+
33
+ ```json
34
+ {
35
+ "converged": true,
36
+ "iteration": 4,
37
+ "reason": "stagnation",
38
+ "metrics": {
39
+ "best_score": 0.78,
40
+ "mean_score": 0.62,
41
+ "entropy": 1.85,
42
+ "iterations_completed": 4,
43
+ "iterations_since_best_change": 2,
44
+ "total_tokens_used": 42000
45
+ },
46
+ "triggered_by": ["stagnation"],
47
+ "recommendation": "best solution is stable; recommend report"
48
+ }
49
+ ```
50
+
51
+ ## Selection Logic
52
+
53
+ ```
54
+ def check_convergence(history, config):
55
+ triggered = []
56
+
57
+ if iteration >= config.max_iterations:
58
+ triggered.append("max_iterations")
59
+
60
+ if config.stagnation.enabled:
61
+ recent = history[-config.stagnation.patience-1:]
62
+ if len(recent) > config.stagnation.patience:
63
+ deltas = [abs(recent[i].best - recent[i-1].best)
64
+ for i in range(1, len(recent))]
65
+ if all(d < config.stagnation.min_delta for d in deltas):
66
+ triggered.append("stagnation")
67
+
68
+ if config.entropy_floor.enabled and current_entropy < threshold:
69
+ triggered.append("entropy_floor")
70
+
71
+ if config.budget_tokens.enabled and total_tokens > config.budget_tokens.max:
72
+ triggered.append("budget_tokens")
73
+
74
+ if config.target_score.enabled and best_score >= config.target_score.value:
75
+ triggered.append("target_score")
76
+
77
+ return {"converged": len(triggered) > 0, "triggered_by": triggered}
78
+ ```
79
+
80
+ ## Entropy Calculation
81
+
82
+ Shannon entropy of normalized pheromone distribution:
83
+
84
+ ```
85
+ p_i = tau_i / sum(tau) for each active edge
86
+ H = -sum(p_i * log2(p_i))
87
+ ```
88
+
89
+ - High H → diverse exploration (early stage)
90
+ - Low H → concentrated on few paths (converging)
91
+ - H < threshold + best score plateau → safe to stop
92
+
93
+ ## Why Multi-Criterion
94
+
95
+ Single criterion is fragile:
96
+ - `max_iterations` alone wastes budget if converged early
97
+ - `stagnation` alone may stop too early on noisy scoring
98
+ - `entropy_floor` alone may trigger before useful solutions emerge
99
+
100
+ Combination = early termination when safe, but always bounded by `max_iterations`.
101
+
102
+ ## Anti-Patterns
103
+
104
+ - DO NOT use `stagnation` with `patience < 2` — noise will trigger false stops
105
+ - DO NOT disable `max_iterations` — runaway risk
106
+ - DO NOT set `target_score` without verified scoring — self_score is too optimistic
@@ -0,0 +1,123 @@
1
+ # Pheromone Schema
2
+
3
+ Pheromone matrix structure, update formula, evaporation rule. Authoritative spec for `pheromone/current.json` and history snapshots.
4
+
5
+ ## File Layout
6
+
7
+ ```
8
+ <session>/pheromone/
9
+ ├── current.json # latest state, overwritten each iteration
10
+ ├── history/
11
+ │ ├── 1.json # snapshot after iteration 1
12
+ │ ├── 2.json
13
+ │ └── ...
14
+ └── init.json # snapshot of initial state (immutable)
15
+ ```
16
+
17
+ ## Schema (pheromone/current.json)
18
+
19
+ ```json
20
+ {
21
+ "version": "1.0",
22
+ "iteration": 3,
23
+ "n_nodes": 42,
24
+ "matrix_type": "edge_weighted_sparse",
25
+ "tau": {
26
+ "<node_a>::<node_b>": 0.85,
27
+ "<node_a>::<node_c>": 1.20,
28
+ "<node_x>::<node_y>": 0.13
29
+ },
30
+ "node_tau": {
31
+ "<node_a>": 0.92,
32
+ "<node_b>": 1.05
33
+ },
34
+ "metadata": {
35
+ "alpha": 1.0,
36
+ "beta": 2.0,
37
+ "rho": 0.2,
38
+ "q": 1.0,
39
+ "tau_init": 1.0,
40
+ "tau_min": 0.01,
41
+ "tau_max": 10.0
42
+ },
43
+ "stats": {
44
+ "mean": 0.91,
45
+ "max": 2.34,
46
+ "min": 0.05,
47
+ "entropy": 3.21,
48
+ "n_edges_active": 87
49
+ }
50
+ }
51
+ ```
52
+
53
+ ### Field Semantics
54
+
55
+ | Field | Type | Meaning |
56
+ |-------|------|---------|
57
+ | `matrix_type` | enum | `edge_weighted_sparse` (default), `node_weighted`, `full_dense` |
58
+ | `tau` | dict | Edge pheromone, key `"a::b"` (undirected uses lexical order) |
59
+ | `node_tau` | dict | Node-level pheromone (used when matrix_type = node_weighted) |
60
+ | `metadata.alpha` | float | Pheromone weight in selection probability |
61
+ | `metadata.beta` | float | Heuristic weight in selection probability |
62
+ | `metadata.rho` | float | Evaporation rate (0..1), applied each iteration |
63
+ | `metadata.q` | float | Deposit constant |
64
+ | `metadata.tau_min/max` | float | MMAS bounds — prevents premature convergence/explosion |
65
+ | `stats.entropy` | float | Shannon entropy of normalized tau — convergence signal |
66
+
67
+ ## Update Formula
68
+
69
+ After iteration k completes, for each ant a in iteration:
70
+
71
+ ```
72
+ delta_tau_a(edge) = q * verified_score_a if edge in path_a, else 0
73
+ ```
74
+
75
+ Then:
76
+
77
+ ```
78
+ tau(edge) = (1 - rho) * tau(edge) + sum_over_ants(delta_tau_a(edge))
79
+ tau(edge) = clip(tau(edge), tau_min, tau_max)
80
+ ```
81
+
82
+ **Elitist strategy** (always on): the best path of all time deposits extra `q * best_score` on its edges before clipping.
83
+
84
+ ## Selection Probability (used in `aco.py select`)
85
+
86
+ For ant at node i choosing neighbor j from candidate set N(i):
87
+
88
+ ```
89
+ p(i -> j) = (tau(i,j)^alpha * eta(i,j)^beta) / sum_{k in N(i)}(tau(i,k)^alpha * eta(i,k)^beta)
90
+ ```
91
+
92
+ where `eta` is a heuristic value from config (e.g., inverse-distance, prior knowledge). Default `eta = 1.0` if not provided.
93
+
94
+ ## Path-Hints vs Full-Path
95
+
96
+ `aco.py select` does NOT prescribe a complete path — it returns **path-hints**: weighted starting nodes + edge probabilities. The ant (LLM) then makes the actual node-by-node choices, with freedom to deviate based on its own evidence. This preserves LLM judgment while keeping search guided.
97
+
98
+ ```json
99
+ {
100
+ "ant_id": "ANT-3-2",
101
+ "start_node": "node_a",
102
+ "edge_preferences": {
103
+ "node_a::node_b": 0.45,
104
+ "node_a::node_c": 0.30,
105
+ "node_a::node_d": 0.25
106
+ },
107
+ "max_path_length": 5
108
+ }
109
+ ```
110
+
111
+ ## Initialization
112
+
113
+ ```
114
+ tau_init for all edges = config.aco.tau_init (default 1.0)
115
+ ```
116
+
117
+ If `task_space.nodes` is `auto_discover_from: <glob>`, init.py discovers nodes by globbing and initializes a full uniform matrix.
118
+
119
+ ## History & Reproducibility
120
+
121
+ - `init.json` — frozen snapshot of initial state (never overwritten)
122
+ - `history/k.json` — full pheromone state after iteration k (for convergence-curve analysis)
123
+ - All updates are deterministic given (prior state + ant artifacts + config)
@@ -0,0 +1,71 @@
1
+ {
2
+ "_comment": "User-facing config template. Coordinator generates this from task description in Phase 1. Fields prefixed with _ are documentation, omit from real config.",
3
+
4
+ "swarm": {
5
+ "_comment": "Top-level swarm parameters",
6
+ "n_ants": 5,
7
+ "max_iterations": 5,
8
+ "elite_keep": 3
9
+ },
10
+
11
+ "aco": {
12
+ "_comment": "ACO algorithm hyperparameters - defaults are sane",
13
+ "alpha": 1.0,
14
+ "beta": 2.0,
15
+ "rho": 0.2,
16
+ "q": 1.0,
17
+ "tau_init": 1.0,
18
+ "tau_min": 0.01,
19
+ "tau_max": 10.0
20
+ },
21
+
22
+ "task_space": {
23
+ "_comment": "Define the search space. Use EITHER 'nodes' (explicit) OR 'auto_discover_from' (glob).",
24
+ "type": "graph",
25
+ "nodes": ["node_a", "node_b", "node_c"],
26
+ "_alt_auto_discover": "auto_discover_from: 'src/**/*.ts'",
27
+ "max_path_length": 5,
28
+ "start_nodes": "any",
29
+ "edges": "complete"
30
+ },
31
+
32
+ "scoring": {
33
+ "_comment": "How verified_score is computed. mode = script | llm | fallback",
34
+ "mode": "fallback",
35
+ "_alt_script": "script_path: '../my-scoring-rule.py' (file must define def score(ant_artifact) -> float)",
36
+ "_alt_llm": "rubric: 'custom scoring rubric text for scorer role'",
37
+ "self_score_discount": 0.5
38
+ },
39
+
40
+ "ant_prompt": {
41
+ "_comment": "What the ant actually tries to achieve. This is the bridge between task semantics and ACO mechanics.",
42
+ "objective": "Find the file with the highest density of suspicious code patterns",
43
+ "evidence_requirements": [
44
+ "At least 1 file:line reference per node visited",
45
+ "Concrete code snippet showing the suspicious pattern"
46
+ ],
47
+ "tools_hint": "Use Grep + Read for code-based exploration"
48
+ },
49
+
50
+ "convergence": {
51
+ "_comment": "Stop conditions - any-of triggers convergence",
52
+ "max_iterations": 5,
53
+ "stagnation": {
54
+ "enabled": true,
55
+ "patience": 2,
56
+ "min_delta": 0.01
57
+ },
58
+ "entropy_floor": {
59
+ "enabled": true,
60
+ "threshold": 0.5
61
+ },
62
+ "budget_tokens": {
63
+ "enabled": false,
64
+ "max": 100000
65
+ },
66
+ "target_score": {
67
+ "enabled": true,
68
+ "value": 0.95
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,117 @@
1
+ # Swarm Protocol
2
+
3
+ Master protocol document for team-swarm: defines how the LLM coordinator and Python ACO controller interface, how ants explore the task space, and how exploration results flow back to update pheromone state.
4
+
5
+ ## Design Philosophy
6
+
7
+ | Principle | Rationale |
8
+ |-----------|-----------|
9
+ | **Outer loop = script, inner loop = LLM** | Optimization math is cheap and deterministic; LLM evaluation is expensive and noisy. Separate them. |
10
+ | **Coordinator is a hybrid** | LLM coordinator translates user intent + dispatches workers; Python script makes all numeric decisions (selection, update, convergence). |
11
+ | **Schema-locked ant output** | LLM output → algorithm input bridge demands strict JSON contract. Free-text outputs cannot feed pheromone updates. |
12
+ | **Two-layer scoring** | `self_score` (LLM self-report) is fast but optimistic. `verified_score` (script or LLM scorer) is the only authoritative input to pheromone update. |
13
+ | **Universal task space** | Coordinator does not bake in any domain. User provides `swarm-config.json` with task space + scoring rule. |
14
+
15
+ ## Three-Component Architecture
16
+
17
+ ```
18
+ +-----------------------------------------------------+
19
+ | LLM Coordinator (roles/coordinator/role.md) |
20
+ | - Parses user task → emits swarm-config.json |
21
+ | - Phase 3 main loop: calls script, spawns workers |
22
+ | - Translates worker callbacks back into script ops |
23
+ +--------+--------------------------------------------+
24
+ | Bash subprocess
25
+ v
26
+ +-----------------------------------------------------+
27
+ | Python ACO Controller (scripts/aco.py) |
28
+ | - CLI subcommands: init/select/update/converged |
29
+ | - Owns pheromone matrix + elite tracker |
30
+ | - Pure functions of session state files |
31
+ +-----------------------------------------------------+
32
+ ^ |
33
+ | reads artifacts/ant-*.json | writes pheromone/*.json
34
+ | v
35
+ +-----------------------------------------------------+
36
+ | LLM Workers (team-worker agents) |
37
+ | - ant: explores assigned path, writes JSON |
38
+ | - scorer: assigns verified_score (optional) |
39
+ | - analyst: final synthesis of elite solutions |
40
+ +-----------------------------------------------------+
41
+ ```
42
+
43
+ ## Iteration Lifecycle
44
+
45
+ ```
46
+ [Coordinator] init phase
47
+ └─> python aco.py init --config <session>/swarm-config.json
48
+ └─> writes pheromone/current.json + task-space.json
49
+
50
+ [Coordinator] iteration k (k = 1..K):
51
+ ├─> python aco.py select --iter k
52
+ │ └─> returns N ant assignments (paths to explore)
53
+ ├─> create_task × N ant tasks
54
+ ├─> spawn N × team-worker(ant) in background
55
+ └─> STOP (await all callbacks)
56
+
57
+ [Callback] all ants done → handleIterationComplete
58
+ ├─> (optional) spawn scorer worker → verified_scores.json
59
+ ├─> python aco.py update --iter k
60
+ │ └─> reads artifacts/ant-k-*.json + verified_scores
61
+ │ └─> updates pheromone + elite + history
62
+ ├─> python aco.py converged
63
+ │ └─> {converged: true|false, reason: ...}
64
+ └─> converged → Phase 4; else → iteration k+1
65
+
66
+ [Coordinator] Phase 4: converge
67
+ ├─> python aco.py report → best.json
68
+ ├─> spawn analyst worker → best-solution.md
69
+ └─> completion action (Archive/Keep/Export)
70
+ ```
71
+
72
+ ## Script ↔ Coordinator Contract
73
+
74
+ All scripts MUST:
75
+ - Read from `<session>/...` (session path passed via `--session` flag)
76
+ - Write JSON to stdout for coordinator parsing (no prose)
77
+ - Use exit code 0 = success, 1 = error, 2 = config invalid
78
+ - Be idempotent: calling `update` twice for same iteration is safe
79
+
80
+ | Subcommand | Input | Output (stdout JSON) | Side effects |
81
+ |------------|-------|---------------------|--------------|
82
+ | `init` | swarm-config.json | `{status, pheromone_path, n_nodes}` | writes pheromone/current.json, task-space.json |
83
+ | `select --iter k` | pheromone/current.json, swarm-config.json | `{iteration, assignments: [{ant_id, path_hints, ...}]}` | none |
84
+ | `update --iter k` | artifacts/ant-k-*.json, optional verified_scores.json | `{iteration, mean_score, best_score, delta, elite_updated}` | writes pheromone/current.json (overwrite) + pheromone/history/k.json + trails/k.jsonl + best.json |
85
+ | `converged` | history/, best.json, config | `{converged: bool, reason: str, metrics: {...}}` | none |
86
+ | `report` | best.json, history/ | full JSON: `{best, top_k, convergence_curve, ...}` | none |
87
+
88
+ ## Data Flow Boundaries
89
+
90
+ | Boundary | Owner | Format |
91
+ |----------|-------|--------|
92
+ | User intent → config | LLM coordinator | swarm-config.json |
93
+ | Pheromone state | Python script | pheromone/current.json |
94
+ | Ant assignment → ant prompt | LLM coordinator (templated) | injected into role-spec at spawn |
95
+ | Ant exploration → artifact | LLM ant | artifacts/ant-k-id.json (schema-locked) |
96
+ | Artifact → pheromone update | Python script | reads artifacts, computes delta tau |
97
+ | Elite solutions → human report | LLM analyst | artifacts/best-solution.md |
98
+
99
+ ## Why Hybrid Coordinator (Not Pure Script)
100
+
101
+ - User input is natural language → needs LLM to map to swarm-config
102
+ - Worker spawning, message routing, session management → all framework-bound to LLM coordinator
103
+ - Script as a sub-tool keeps the same team-* lifecycle (spawn-and-stop, callback-driven)
104
+ - Same pattern as `maestro delegate` — Bash-callable subprocess from inside an LLM role
105
+
106
+ ## Universality
107
+
108
+ `team-swarm` is task-agnostic. Specialization happens via:
109
+ 1. `swarm-config.json#task_space` — defines what nodes/edges/paths mean
110
+ 2. `swarm-config.json#scoring` — defines how to compute verified_score
111
+ 3. `swarm-config.json#ant_prompt` — defines what ant should actually do at each node
112
+
113
+ Example domains the same skill handles:
114
+ - Code exploration (nodes = files/modules, score = suspicious code density)
115
+ - Test case generation (nodes = code paths, score = coverage delta)
116
+ - Refactor strategy search (nodes = refactor moves, score = complexity reduction)
117
+ - Hyperparameter tuning (nodes = param choices, score = metric improvement)
@@ -41,9 +41,10 @@ You are a collaborative planner that works within a pre-allocated task ID range.
41
41
  "type": "feature",
42
42
  "priority": "medium",
43
43
  "effort": "medium",
44
- "action": "Implement",
44
+ "action": "<concrete action with exact values: function signatures, config keys, import paths>",
45
45
  "scope": "<module path>",
46
46
  "focus_paths": [],
47
+ "read_first": ["src/module/existing.ts", "src/types/shared.ts"],
47
48
  "depends_on": [],
48
49
  "parallel_group": null,
49
50
  "convergence": {
@@ -115,6 +116,8 @@ You are a collaborative planner that works within a pre-allocated task ID range.
115
116
  - Task files must use `convergence.criteria` (array of testable strings), not `done_when`
116
117
  - files must use `[{path, action, target, change}]` format, not `["path"]`
117
118
  - Each task must have convergence.criteria with min 2 testable conditions
119
+ - Each task must have `read_first[]` — files the executor MUST read before implementation
120
+ - `action` must contain concrete values (function signatures, config keys, import paths), not just a verb
118
121
  - Task definitions follow the same schema as workflow-planner output
119
122
  - If you discover scope that belongs to another planner's range, note it in plan-note.md
120
123
  - Do not modify other planners' task files
@@ -29,7 +29,9 @@ You validate the quality of execution plans before they proceed to implementatio
29
29
  - Each criterion must reference a concrete artifact, output, or behavior
30
30
  - Criteria should be sufficient to prove the task is complete
31
31
  7. **Check files array** -- Verify each task's `files[]` array is consistent with its description
32
- 8. **Report** -- Write check report with issues or approval
32
+ 8. **Check read_first** -- Verify each task has `read_first[]` containing: the file being modified + source-of-truth files. Missing or empty `read_first` is a critical issue.
33
+ 9. **Check action concreteness** -- Verify each task's `action` contains concrete values (function signatures, config keys, import paths), not vague verbs like "Implement" or references like "align X with Y"
34
+ 10. **Report** -- Write check report with issues or approval
33
35
 
34
36
  ### Revision Loop (max 3 rounds)
35
37
  - If issues found: write report with specific issues and suggested fixes
@@ -71,6 +73,14 @@ Check report written to the output location above:
71
73
  ## Files Array Consistency
72
74
  - TASK-006: description mentions "update config" but files[] does not include any config file
73
75
 
76
+ ## Read First Completeness
77
+ - TASK-001 read_first: Missing — must include src/auth.ts (file being modified) + src/types/auth.ts (type definitions)
78
+ - TASK-003 read_first: Has target file but missing source-of-truth reference
79
+
80
+ ## Action Concreteness
81
+ - TASK-002 action: Too vague ("Implement auth") — should include: "Add verifyToken(token: string): Promise<AuthPayload> to src/auth.ts, import from jsonwebtoken"
82
+ - TASK-005 action: Contains "align with existing pattern" — must specify the exact target state
83
+
74
84
  ## Summary
75
85
  <Overall assessment>
76
86
  ```
@@ -91,9 +91,10 @@ When invoked with `quick` flag:
91
91
  "type": "feature",
92
92
  "priority": "medium",
93
93
  "effort": "medium",
94
- "action": "Implement",
94
+ "action": "<concrete action with exact values: function signatures, config keys, import paths>",
95
95
  "scope": "<module path>",
96
96
  "focus_paths": ["src/tools/"],
97
+ "read_first": ["src/tools/existing-tool.ts", "src/types/tool.ts"],
97
98
  "depends_on": [],
98
99
  "parallel_group": null,
99
100
  "convergence": {
@@ -163,6 +164,8 @@ These rules prevent over-splitting that wastes tokens on unnecessary agent spawn
163
164
  - Each task must be substantial (15-60 min of work); group related changes, avoid file-per-task
164
165
  - Each task must have convergence.criteria (min 2 testable conditions)
165
166
  - convergence.criteria must be specific and testable (not "works correctly")
167
+ - Each task must have `read_first[]` — files the executor MUST read before implementation (the file being modified + source-of-truth files)
168
+ - `action` must contain concrete values (function signatures, config keys, import paths), not just a verb like "Implement"
166
169
  - files must use array format `[{path, action, target, change}]`
167
170
  - Wave ordering must respect dependencies (no task before its dependency)
168
171
  - Task descriptions must be clear enough for the executor to implement without ambiguity
@@ -51,10 +51,11 @@ $ARGUMENTS — user intent text, or special keywords.
51
51
  4. **Decomposition contract shared with maestro-ralph** — broad/lifecycle intents run S_DECOMPOSE producing the SAME additive block (`boundary_contract`, `execution_criteria`, `task_decomposition`)。Reference maestro-ralph `A_DECOMPOSE_TASKS`
52
52
  5. **status.json 唯一真源** — 不生成 `goal-checklist.md` 或外部清单
53
53
  6. **执行步骤统一通过 `maestro ralph next` 加载** — `command_scope`/`command_path` 由 `maestro ralph skills --json --quiet` 预校验(project 覆盖 global);decision 节点不走 CLI,走 `Skill("maestro-ralph")` handoff
54
- 7. **Topology awareness** — chain catalog 含 brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / ...;scope_verdict 由 ralph 在 `post-analyze-scope` 决定
55
- 8. **D-007 milestone 反查**数字 phase `milestone_id` `state.json.milestones[].phase_slugs` 反查
56
- 9. **每个 step 必须 `completion_confirmed: true`** `maestro ralph complete N --status DONE|DONE_WITH_CONCERNS` 写入
57
- 10. **schema** `ralph_protocol_version: "1"` 标记 CLI-driven session;新增字段全部可选
54
+ 7. **Topology awareness** — chain catalog 含 grill / brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / ...;scope_verdict 由 ralph 在 `post-analyze-scope` 决定
55
+ 8. **Grill is interactive-only**`-y` auto mode MUST skip grill stage and route directly to brainstorm; grill requires Socratic Q&A with the user
56
+ 9. **D-007 milestone 反查** 数字 phase `milestone_id` `state.json.milestones[].phase_slugs` 反查
57
+ 10. **每个 step 必须 `completion_confirmed: true`** — 由 `maestro ralph complete N --status DONE|DONE_WITH_CONCERNS` 写入
58
+ 11. **schema** — `ralph_protocol_version: "1"` 标记 CLI-driven session;新增字段全部可选
58
59
  </invariants>
59
60
 
60
61
  <state_machine>
@@ -133,6 +134,7 @@ S_FALLBACK:
133
134
  1. Read `~/.maestro/workflows/maestro.md` from deferred_reading
134
135
  2. Match intent to task_type via chain catalog (semantic)
135
136
  3. Select chain from chainMap,遵循拓扑约束:
137
+ - 压力测试/拷问/验证假设/grill/stress-test → `grill`(**-y 模式跳过 grill,直接走 brainstorm**)
136
138
  - 头脑风暴/探索 → `brainstorm`
137
139
  - 正式规格/spec-generate/7-phase → `blueprint`
138
140
  - 项目初始化 → `init`
@@ -217,7 +219,8 @@ S_FALLBACK:
217
219
  ### Success Criteria
218
220
 
219
221
  - [ ] Intent classified with task_type, complexity, clarity_score
220
- - [ ] Chain catalog 覆盖 brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / quality pipeline
222
+ - [ ] Chain catalog 覆盖 grill / brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / quality pipeline
223
+ - [ ] `-y` 模式不触发 grill(交互式压力测试不支持自动模式,跳过直接走 brainstorm)
221
224
  - [ ] D-007: 数字 phase 步骤的 `milestone_id` 通过 `state.json.milestones[].phase_slugs` 反查
222
225
  - [ ] macro analyze 后跟 `decision:post-analyze-scope`(由 ralph 评估 scope_verdict 决定下游链路)
223
226
  - [ ] plan 支持 `{phase}` / `--from analyze:{ANL_ID}` / `--from blueprint:{BLP_ID}` 三路径;`source_artifact_ref` 写入 step
@@ -50,7 +50,7 @@ $ARGUMENTS -- phase number for micro mode, topic text for macro/adhoc mode, no a
50
50
  - `-y` / `--yes`: Auto mode — skip interactive scoping, use recommended defaults, auto-deepen
51
51
  - `-c` / `--continue`: Resume from existing session (auto-detect session folder + discussion.md)
52
52
  - `-q` / `--quick`: Quick mode — skip exploration + scoring, go straight to decision extraction (context.md only)
53
- - `--from <source>`: Load upstream context package (brainstorm:ID, blueprint:BLP-xxx, @file, or path)
53
+ - `--from <source>`: Load upstream context package (grill:ID, brainstorm:ID, blueprint:BLP-xxx, @file, or path)
54
54
  - `--gaps [ISS-ID]`: Issue root cause analysis mode. If ISS-ID provided, analyze single issue. If omitted, analyze all open/registered issues from issues.jsonl.
55
55
 
56
56
  Scope routing, output directory format, artifact registration schema, and output artifact listing are defined in workflow analyze.md (Scope Routing and Output Structure sections).
@@ -70,7 +70,7 @@ Interview the user relentlessly until shared understanding is reached. Active on
70
70
  - Branch jumps allowed: the user may switch freely between mode / role / upstream / sub-pipeline branches; sequence is not enforced, but every decision point must end with a definite answer.
71
71
  - Scope guard: only ask about decisions owned by `brainstorm`. Do not pre-resolve roadmap/plan choices.
72
72
 
73
- Decision points: mode (auto / single-role / review-only) / role selection and `--count` / `--from` upstream source / whether to enable design-research and the DESIGN.md sub-pipeline.
73
+ Decision points: mode (auto / single-role / review-only) / role selection and `--count` / `--from` upstream source (grill:ID, blueprint:ID, @file, path) / whether to enable design-research and the DESIGN.md sub-pipeline.
74
74
 
75
75
  Exit: on consensus or explicit user signal to proceed, finalize session metadata. The §11 table (already populated incrementally) uses this schema:
76
76
  `| # | Decision | Choice | Source (user / code / default) |`
@@ -86,6 +86,7 @@ Auto mode:
86
86
  - Project initialized, need formal spec package → view_file(AbsolutePath="<agy-skills-dir>/maestro-blueprint/SKILL.md") + execute inline (args: "--from brainstorm:{artifact_id}")
87
87
  - Project initialized, quick roadmap → view_file(AbsolutePath="<agy-skills-dir>/maestro-roadmap/SKILL.md") + execute inline (args: "--from brainstorm:{artifact_id}")
88
88
  - Need deeper analysis first → view_file(AbsolutePath="<agy-skills-dir>/maestro-analyze/SKILL.md") + execute inline (args: "{topic} --from brainstorm:{artifact_id}")
89
+ - Need stress-testing first → view_file(AbsolutePath="<agy-skills-dir>/maestro-grill/SKILL.md") + execute inline (args: "{topic}")
89
90
  - `html-prototypes/` produced with 2+ files and user wants to browse → load `~/.maestro/workflows/brainstorm-visualize.md` and launch visualizer server (optional, user-triggered)
90
91
  - DESIGN.md established during Step 3.5 → suggest: "Run `/maestro-impeccable build <feature-description>` to build with the established design system"
91
92