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
+ ├─> TaskCreate × 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)
@@ -42,9 +42,10 @@ You are a collaborative planner that works within a pre-allocated task ID range.
42
42
  "type": "feature",
43
43
  "priority": "medium",
44
44
  "effort": "medium",
45
- "action": "Implement",
45
+ "action": "<concrete action with exact values: function signatures, config keys, import paths>",
46
46
  "scope": "<module path>",
47
47
  "focus_paths": [],
48
+ "read_first": ["src/module/existing.ts", "src/types/shared.ts"],
48
49
  "depends_on": [],
49
50
  "parallel_group": null,
50
51
  "convergence": {
@@ -116,6 +117,8 @@ You are a collaborative planner that works within a pre-allocated task ID range.
116
117
  - Task files must use `convergence.criteria` (array of testable strings), not `done_when`
117
118
  - files must use `[{path, action, target, change}]` format, not `["path"]`
118
119
  - Each task must have convergence.criteria with min 2 testable conditions
120
+ - Each task must have `read_first[]` — files the executor MUST read before implementation
121
+ - `action` must contain concrete values (function signatures, config keys, import paths), not just a verb
119
122
  - Task definitions follow the same schema as workflow-planner output
120
123
  - If you discover scope that belongs to another planner's range, note it in plan-note.md
121
124
  - Do not modify other planners' task files
@@ -30,7 +30,9 @@ You validate the quality of execution plans before they proceed to implementatio
30
30
  - Each criterion must reference a concrete artifact, output, or behavior
31
31
  - Criteria should be sufficient to prove the task is complete
32
32
  7. **Check files array** -- Verify each task's `files[]` array is consistent with its description
33
- 8. **Report** -- Write check report with issues or approval
33
+ 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.
34
+ 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"
35
+ 10. **Report** -- Write check report with issues or approval
34
36
 
35
37
  ### Revision Loop (max 3 rounds)
36
38
  - If issues found: write report with specific issues and suggested fixes
@@ -72,6 +74,14 @@ Check report written to the output location above:
72
74
  ## Files Array Consistency
73
75
  - TASK-006: description mentions "update config" but files[] does not include any config file
74
76
 
77
+ ## Read First Completeness
78
+ - TASK-001 read_first: Missing — must include src/auth.ts (file being modified) + src/types/auth.ts (type definitions)
79
+ - TASK-003 read_first: Has target file but missing source-of-truth reference
80
+
81
+ ## Action Concreteness
82
+ - TASK-002 action: Too vague ("Implement auth") — should include: "Add verifyToken(token: string): Promise<AuthPayload> to src/auth.ts, import from jsonwebtoken"
83
+ - TASK-005 action: Contains "align with existing pattern" — must specify the exact target state
84
+
75
85
  ## Summary
76
86
  <Overall assessment>
77
87
  ```
@@ -92,9 +92,10 @@ When invoked with `quick` flag:
92
92
  "type": "feature",
93
93
  "priority": "medium",
94
94
  "effort": "medium",
95
- "action": "Implement",
95
+ "action": "<concrete action with exact values: function signatures, config keys, import paths>",
96
96
  "scope": "<module path>",
97
97
  "focus_paths": ["src/tools/"],
98
+ "read_first": ["src/tools/existing-tool.ts", "src/types/tool.ts"],
98
99
  "depends_on": [],
99
100
  "parallel_group": null,
100
101
  "convergence": {
@@ -164,6 +165,8 @@ These rules prevent over-splitting that wastes tokens on unnecessary agent spawn
164
165
  - Each task must be substantial (15-60 min of work); group related changes, avoid file-per-task
165
166
  - Each task must have convergence.criteria (min 2 testable conditions)
166
167
  - convergence.criteria must be specific and testable (not "works correctly")
168
+ - Each task must have `read_first[]` — files the executor MUST read before implementation (the file being modified + source-of-truth files)
169
+ - `action` must contain concrete values (function signatures, config keys, import paths), not just a verb like "Implement"
167
170
  - files must use array format `[{path, action, target, change}]`
168
171
  - Wave ordering must respect dependencies (no task before its dependency)
169
172
  - Task descriptions must be clear enough for the executor to implement without ambiguity
@@ -48,7 +48,7 @@ $ARGUMENTS -- phase number for micro mode, topic text for macro/adhoc mode, no a
48
48
  - `-y` / `--yes`: Auto mode — skip interactive scoping, use recommended defaults, auto-deepen
49
49
  - `-c` / `--continue`: Resume from existing session (auto-detect session folder + discussion.md)
50
50
  - `-q` / `--quick`: Quick mode — skip exploration + scoring, go straight to decision extraction (context.md only)
51
- - `--from <source>`: Load upstream context package (brainstorm:ID, blueprint:BLP-xxx, @file, or path)
51
+ - `--from <source>`: Load upstream context package (grill:ID, brainstorm:ID, blueprint:BLP-xxx, @file, or path)
52
52
  - `--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.
53
53
 
54
54
  Scope routing, output directory format, artifact registration schema, and output artifact listing are defined in workflow analyze.md (Scope Routing and Output Structure sections).
@@ -68,7 +68,7 @@ Interview the user relentlessly until shared understanding is reached. Active on
68
68
  - 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.
69
69
  - Scope guard: only ask about decisions owned by `brainstorm`. Do not pre-resolve roadmap/plan choices.
70
70
 
71
- 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.
71
+ 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.
72
72
 
73
73
  Exit: on consensus or explicit user signal to proceed, finalize session metadata. The §11 table (already populated incrementally) uses this schema:
74
74
  `| # | Decision | Choice | Source (user / code / default) |`
@@ -84,6 +84,7 @@ Auto mode:
84
84
  - Project initialized, need formal spec package → Skill({ skill: "maestro-blueprint", args: "--from brainstorm:{artifact_id}" })
85
85
  - Project initialized, quick roadmap → Skill({ skill: "maestro-roadmap", args: "--from brainstorm:{artifact_id}" })
86
86
  - Need deeper analysis first → Skill({ skill: "maestro-analyze", args: "{topic} --from brainstorm:{artifact_id}" })
87
+ - Need stress-testing first → Skill({ skill: "maestro-grill", args: "{topic}" })
87
88
  - `html-prototypes/` produced with 2+ files and user wants to browse → load `~/.maestro/workflows/brainstorm-visualize.md` and launch visualizer server (optional, user-triggered)
88
89
  - DESIGN.md established during Step 3.5 → suggest: "Run `/maestro-impeccable build <feature-description>` to build with the established design system"
89
90