maestro-flow 0.4.18 → 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.
- package/.agents/skills/maestro-next/SKILL.md +147 -112
- package/.agents/skills/team-swarm/SKILL.md +180 -0
- package/.agents/skills/team-swarm/roles/analyst/role.md +187 -0
- package/.agents/skills/team-swarm/roles/ant/role.md +169 -0
- package/.agents/skills/team-swarm/roles/coordinator/commands/converge.md +146 -0
- package/.agents/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
- package/.agents/skills/team-swarm/roles/coordinator/commands/iterate.md +232 -0
- package/.agents/skills/team-swarm/roles/coordinator/role.md +211 -0
- package/.agents/skills/team-swarm/roles/scorer/role.md +157 -0
- package/.agents/skills/team-swarm/scripts/aco.py +473 -0
- package/.agents/skills/team-swarm/scripts/pheromone.py +144 -0
- package/.agents/skills/team-swarm/scripts/scoring.py +92 -0
- package/.agents/skills/team-swarm/scripts/test_aco.py +475 -0
- package/.agents/skills/team-swarm/specs/ant-output-schema.md +119 -0
- package/.agents/skills/team-swarm/specs/convergence-criteria.md +106 -0
- package/.agents/skills/team-swarm/specs/pheromone-schema.md +123 -0
- package/.agents/skills/team-swarm/specs/swarm-config-template.json +71 -0
- package/.agents/skills/team-swarm/specs/swarm-protocol.md +117 -0
- package/.agy/skills/maestro-next/SKILL.md +147 -112
- package/.agy/skills/team-swarm/SKILL.md +176 -0
- package/.agy/skills/team-swarm/roles/analyst/role.md +183 -0
- package/.agy/skills/team-swarm/roles/ant/role.md +165 -0
- package/.agy/skills/team-swarm/roles/coordinator/commands/converge.md +134 -0
- package/.agy/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
- package/.agy/skills/team-swarm/roles/coordinator/commands/iterate.md +202 -0
- package/.agy/skills/team-swarm/roles/coordinator/role.md +209 -0
- package/.agy/skills/team-swarm/roles/scorer/role.md +153 -0
- package/.agy/skills/team-swarm/scripts/aco.py +473 -0
- package/.agy/skills/team-swarm/scripts/pheromone.py +144 -0
- package/.agy/skills/team-swarm/scripts/scoring.py +92 -0
- package/.agy/skills/team-swarm/scripts/test_aco.py +475 -0
- package/.agy/skills/team-swarm/specs/ant-output-schema.md +119 -0
- package/.agy/skills/team-swarm/specs/convergence-criteria.md +106 -0
- package/.agy/skills/team-swarm/specs/pheromone-schema.md +123 -0
- package/.agy/skills/team-swarm/specs/swarm-config-template.json +71 -0
- package/.agy/skills/team-swarm/specs/swarm-protocol.md +117 -0
- package/.claude/commands/maestro-next.md +147 -112
- package/.claude/skills/team-swarm/SKILL.md +178 -0
- package/.claude/skills/team-swarm/roles/analyst/role.md +185 -0
- package/.claude/skills/team-swarm/roles/ant/role.md +167 -0
- package/.claude/skills/team-swarm/roles/coordinator/commands/converge.md +146 -0
- package/.claude/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
- package/.claude/skills/team-swarm/roles/coordinator/commands/iterate.md +232 -0
- package/.claude/skills/team-swarm/roles/coordinator/role.md +209 -0
- package/.claude/skills/team-swarm/roles/scorer/role.md +155 -0
- package/.claude/skills/team-swarm/scripts/aco.py +473 -0
- package/.claude/skills/team-swarm/scripts/pheromone.py +144 -0
- package/.claude/skills/team-swarm/scripts/scoring.py +92 -0
- package/.claude/skills/team-swarm/scripts/test_aco.py +475 -0
- package/.claude/skills/team-swarm/specs/ant-output-schema.md +119 -0
- package/.claude/skills/team-swarm/specs/convergence-criteria.md +106 -0
- package/.claude/skills/team-swarm/specs/pheromone-schema.md +123 -0
- package/.claude/skills/team-swarm/specs/swarm-config-template.json +71 -0
- package/.claude/skills/team-swarm/specs/swarm-protocol.md +117 -0
- package/.codex/skills/maestro-next/SKILL.md +297 -0
- package/dist/src/commands/install.js +5 -1
- package/dist/src/commands/install.js.map +1 -1
- package/dist/src/i18n/locales/en.d.ts.map +1 -1
- package/dist/src/i18n/locales/en.js +9 -0
- package/dist/src/i18n/locales/en.js.map +1 -1
- package/dist/src/i18n/locales/zh.d.ts.map +1 -1
- package/dist/src/i18n/locales/zh.js +9 -0
- package/dist/src/i18n/locales/zh.js.map +1 -1
- package/dist/src/i18n/types.d.ts +3 -0
- package/dist/src/i18n/types.d.ts.map +1 -1
- package/dist/src/tui/install-ui/HooksConfig.d.ts +5 -1
- package/dist/src/tui/install-ui/HooksConfig.d.ts.map +1 -1
- package/dist/src/tui/install-ui/HooksConfig.js +5 -3
- package/dist/src/tui/install-ui/HooksConfig.js.map +1 -1
- package/dist/src/tui/install-ui/InstallConfirm.d.ts +2 -0
- package/dist/src/tui/install-ui/InstallConfirm.d.ts.map +1 -1
- package/dist/src/tui/install-ui/InstallConfirm.js +1 -1
- package/dist/src/tui/install-ui/InstallConfirm.js.map +1 -1
- package/dist/src/tui/install-ui/InstallExecution.d.ts +1 -0
- package/dist/src/tui/install-ui/InstallExecution.d.ts.map +1 -1
- package/dist/src/tui/install-ui/InstallExecution.js +26 -3
- package/dist/src/tui/install-ui/InstallExecution.js.map +1 -1
- package/dist/src/tui/install-ui/InstallFlow.d.ts +1 -1
- package/dist/src/tui/install-ui/InstallFlow.d.ts.map +1 -1
- package/dist/src/tui/install-ui/InstallFlow.js +76 -16
- package/dist/src/tui/install-ui/InstallFlow.js.map +1 -1
- package/dist/src/tui/install-ui/InstallHub.d.ts +2 -0
- package/dist/src/tui/install-ui/InstallHub.d.ts.map +1 -1
- package/dist/src/tui/install-ui/InstallHub.js +8 -0
- package/dist/src/tui/install-ui/InstallHub.js.map +1 -1
- package/dist/src/tui/install-ui/InstallResult.d.ts.map +1 -1
- package/dist/src/tui/install-ui/InstallResult.js +1 -1
- package/dist/src/tui/install-ui/InstallResult.js.map +1 -1
- package/dist/src/utils/update-notices.js +11 -0
- package/dist/src/utils/update-notices.js.map +1 -1
- package/package.json +1 -1
|
@@ -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 |
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
role: ant
|
|
3
|
+
prefix: ANT
|
|
4
|
+
inner_loop: false
|
|
5
|
+
output_tag: "[ant]"
|
|
6
|
+
message_types:
|
|
7
|
+
success: ant_complete
|
|
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
|
+
# Ant Role — Phase 2-4
|
|
14
|
+
|
|
15
|
+
Tag: `[ant]` | Prefix: `ANT-*`
|
|
16
|
+
Responsibility: Receive path-hints from ACO controller, explore the task space starting from assigned node, produce schema-locked JSON artifact with self-evaluation.
|
|
17
|
+
|
|
18
|
+
## Boundaries
|
|
19
|
+
|
|
20
|
+
### MUST
|
|
21
|
+
- Read assignment JSON from task description (start_node, edge_preferences, max_path_length)
|
|
22
|
+
- Load swarm-config.json to understand objective + task semantics
|
|
23
|
+
- Build a path of length 1..max_path_length starting from start_node
|
|
24
|
+
- Bias choices using `edge_preferences` (pheromone-derived) BUT may deviate when evidence supports it
|
|
25
|
+
- Output strict-schema JSON to `<session>/artifacts/ant-<iter>-<id>.json` (see specs/ant-output-schema.md)
|
|
26
|
+
- Self-validate output before reporting (JSON parses + required fields + node validity)
|
|
27
|
+
- Provide ≥ 1 evidence anchor per path
|
|
28
|
+
|
|
29
|
+
### MUST NOT
|
|
30
|
+
- Modify pheromone state, best.json, trails/, or other ants' artifacts
|
|
31
|
+
- Skip path_decisions array (one entry per edge traversed)
|
|
32
|
+
- Report self_score > 0.9 without strong evidence (≥ 3 evidence anchors)
|
|
33
|
+
- Visit a node outside the task-space.json nodes list
|
|
34
|
+
- Loop back to a previously visited node in the same path (no cycles)
|
|
35
|
+
|
|
36
|
+
## Phase 2: Context Loading
|
|
37
|
+
|
|
38
|
+
| Input | Source | Required |
|
|
39
|
+
|-------|--------|----------|
|
|
40
|
+
| Assignment | Task description (parse JSON block) | Yes |
|
|
41
|
+
| Objective | `<session>/swarm-config.json#ant_prompt.objective` | Yes |
|
|
42
|
+
| Task semantics | `<session>/swarm-config.json#ant_prompt` (full block) | Yes |
|
|
43
|
+
| Task space | `<session>/task-space.json` (valid nodes list) | Yes |
|
|
44
|
+
| Pheromone hints | `assignment.edge_preferences` (already passed in) | Yes |
|
|
45
|
+
| Wisdom from prior iters | `<session>/wisdom/learnings.md` (if exists) | Optional |
|
|
46
|
+
|
|
47
|
+
Workflow:
|
|
48
|
+
1. Extract session path from task description
|
|
49
|
+
2. Parse assignment JSON block from task description
|
|
50
|
+
3. Read swarm-config.json -> capture `ant_prompt.objective`, `ant_prompt.evidence_requirements`, `task_space.max_path_length`
|
|
51
|
+
4. Read task-space.json -> build valid_nodes set
|
|
52
|
+
5. If `<session>/wisdom/learnings.md` exists -> read for prior-iteration insights
|
|
53
|
+
|
|
54
|
+
## Phase 3: Exploration
|
|
55
|
+
|
|
56
|
+
**Goal**: Build a path of nodes that maximizes likelihood of achieving the objective. The objective is task-defined (find buggy code, find best refactor target, etc.); ant is task-agnostic infrastructure.
|
|
57
|
+
|
|
58
|
+
Workflow:
|
|
59
|
+
|
|
60
|
+
### 3.1 Initialize path
|
|
61
|
+
- `path = [assignment.start_node]`
|
|
62
|
+
- `path_decisions = []`
|
|
63
|
+
- `visited = {start_node}`
|
|
64
|
+
- `current = start_node`
|
|
65
|
+
|
|
66
|
+
### 3.2 Per-step exploration loop (until len(path) reaches max_path_length OR ant decides to stop early)
|
|
67
|
+
|
|
68
|
+
For each step:
|
|
69
|
+
|
|
70
|
+
1. **Compute candidate neighbors**: all nodes in task_space NOT in `visited`
|
|
71
|
+
2. **Build choice weights**:
|
|
72
|
+
- For each candidate c: `weight = edge_preferences.get("<current>::<c>", baseline) * heuristic(c)`
|
|
73
|
+
- `heuristic(c)` = ant's own evidence-based judgment (1.0 if no opinion)
|
|
74
|
+
3. **Investigate top candidates** using available tools:
|
|
75
|
+
- Tool selection: Read, Grep, Glob for code-based task spaces; or CLI delegate `--mode analysis` for richer analysis
|
|
76
|
+
- Gather evidence about each top candidate before committing
|
|
77
|
+
4. **Choose next node**: weighted-random OR argmax (when high confidence)
|
|
78
|
+
5. **Record decision**:
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"from": "<current>",
|
|
82
|
+
"to": "<chosen>",
|
|
83
|
+
"rationale": "<one-line>",
|
|
84
|
+
"guided_by": "pheromone | heuristic | evidence",
|
|
85
|
+
"pheromone_weight": <edge_preferences value>,
|
|
86
|
+
"deviation_from_hint": <bool — true if chosen != argmax(edge_preferences)>
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
6. **Append to path**, update `visited`, `current = chosen`
|
|
90
|
+
7. **Early-stop check**: if evidence shows objective achieved OR no productive next step exists -> stop
|
|
91
|
+
|
|
92
|
+
### 3.3 Self-evaluate
|
|
93
|
+
|
|
94
|
+
After path is built:
|
|
95
|
+
|
|
96
|
+
1. **self_score** (0..1): how well does this path satisfy the objective?
|
|
97
|
+
- Use `ant_prompt.evidence_requirements` as rubric
|
|
98
|
+
- Be conservative — penalize for missing evidence, weak rationale
|
|
99
|
+
2. **self_confidence** (0..1): how sure of the self_score?
|
|
100
|
+
- Low confidence if evidence is sparse or contradictory
|
|
101
|
+
3. **candidate_solution**: extract the actual deliverable along the path
|
|
102
|
+
- `type` ∈ {string, object, file_ref}
|
|
103
|
+
- `summary` — one-line
|
|
104
|
+
- `content` — actual artifact OR a path to a file written by the ant
|
|
105
|
+
|
|
106
|
+
### 3.4 Compose artifact JSON
|
|
107
|
+
|
|
108
|
+
Build the full artifact matching specs/ant-output-schema.md. All required fields populated.
|
|
109
|
+
|
|
110
|
+
## Phase 4: Verify + Publish
|
|
111
|
+
|
|
112
|
+
### Behavioral Traits
|
|
113
|
+
|
|
114
|
+
#### Accuracy — outputs must be verifiable
|
|
115
|
+
- Every node in `path` MUST exist in task-space.json
|
|
116
|
+
- Every `path_decisions[i].from` MUST equal `path[i]` and `to` MUST equal `path[i+1]`
|
|
117
|
+
- Evidence references (e.g., `file:line`) MUST be valid (Read to confirm if file_ref)
|
|
118
|
+
|
|
119
|
+
#### Feedback Contract
|
|
120
|
+
| Field | Required | Content |
|
|
121
|
+
|-------|----------|---------|
|
|
122
|
+
| files_produced | If ant wrote any | `[artifact_path]` at minimum |
|
|
123
|
+
| artifacts_written | Always | `<session>/artifacts/ant-<iter>-<id>.json` |
|
|
124
|
+
| verification_method | Always | "schema_validated + node_validity_checked" |
|
|
125
|
+
|
|
126
|
+
#### Quality Gate
|
|
127
|
+
- Schema validation pass = REQUIRED before reporting completed
|
|
128
|
+
- Fails -> retry Phase 3 once (max 1 retry to bound cost)
|
|
129
|
+
- Still fails -> report `partial_completion` with `validation_errors` in state data
|
|
130
|
+
|
|
131
|
+
### Verification Steps
|
|
132
|
+
|
|
133
|
+
1. **Schema validation**:
|
|
134
|
+
- Parse the JSON via Read
|
|
135
|
+
- Confirm all required fields from specs/ant-output-schema.md
|
|
136
|
+
- Confirm numeric ranges (self_score, self_confidence ∈ [0,1])
|
|
137
|
+
- Confirm `len(path_decisions) == len(path) - 1`
|
|
138
|
+
2. **Node validity**: every node in path ∈ task_space.json#nodes
|
|
139
|
+
3. **Evidence check**: at least 1 evidence anchor present; if file_ref, Read to confirm existence
|
|
140
|
+
4. **Write artifact**: `write_file(<session>/artifacts/ant-<iter>-<id>.json, <json_string>)`
|
|
141
|
+
5. **Re-read to confirm write**: Read it back, parse, sanity check
|
|
142
|
+
|
|
143
|
+
### State Update
|
|
144
|
+
|
|
145
|
+
Set Phase 5 `team_msg.log` data:
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"task_id": "ANT-<k>-<i>",
|
|
149
|
+
"role": "ant",
|
|
150
|
+
"status": "completed",
|
|
151
|
+
"iteration": <k>,
|
|
152
|
+
"self_score": <float>,
|
|
153
|
+
"self_confidence": <float>,
|
|
154
|
+
"path_length": <int>,
|
|
155
|
+
"artifact_path": "<session>/artifacts/ant-<k>-<i>.json",
|
|
156
|
+
"verification": "schema_pass + node_valid + evidence_present"
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Error Handling
|
|
161
|
+
|
|
162
|
+
| Scenario | Resolution |
|
|
163
|
+
|----------|------------|
|
|
164
|
+
| Assignment JSON malformed | Report error to coordinator via send_message, STOP |
|
|
165
|
+
| start_node not in task_space | Report error (config mismatch), STOP |
|
|
166
|
+
| No valid neighbors at step 1 | Build single-node path, self_score = 0, report |
|
|
167
|
+
| Schema validation fails twice | Report `partial_completion` with errors list |
|
|
168
|
+
| Evidence requirements unsatisfiable | Lower self_score; document blocker in artifact `notes` field |
|
|
169
|
+
| Tool calls fail (Read/Grep) | Note in artifact `notes`; reduce self_confidence; proceed with available info |
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Command: converge
|
|
2
|
+
|
|
3
|
+
Phase 4 execution guide. Run after `aco.py converged` returns `true`.
|
|
4
|
+
|
|
5
|
+
## Workflow
|
|
6
|
+
|
|
7
|
+
### Step 1: Call aco.py report
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Bash: python <skill_root>/scripts/aco.py --session <session> report
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Parse stdout JSON. Expected:
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"status": "ok",
|
|
17
|
+
"best": { ant_id, iteration, path, score, candidate_solution, evidence, ... },
|
|
18
|
+
"top_k": [<top 5 trails>],
|
|
19
|
+
"convergence_curve": [{iteration, entropy, tau_max, tau_mean}, ...],
|
|
20
|
+
"final_pheromone_stats": {...},
|
|
21
|
+
"iterations_completed": <int>
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Save full report to `<session>/artifacts/swarm-report.json` (raw data for analyst).
|
|
26
|
+
|
|
27
|
+
### Step 2: Spawn analyst worker
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
delegate_subagent({
|
|
31
|
+
subagent_type: "team-worker",
|
|
32
|
+
description: "Spawn analyst for swarm synthesis",
|
|
33
|
+
team_name: "swarm",
|
|
34
|
+
name: "analyst",
|
|
35
|
+
run_in_background: true,
|
|
36
|
+
prompt: `## Role Assignment
|
|
37
|
+
role: analyst
|
|
38
|
+
role_spec: <skill_root>/roles/analyst/role.md
|
|
39
|
+
session: <session_path>
|
|
40
|
+
session_id: <session_id>
|
|
41
|
+
team_name: swarm
|
|
42
|
+
requirement: synthesize swarm results into human-readable best-solution.md
|
|
43
|
+
inner_loop: false
|
|
44
|
+
|
|
45
|
+
## Context
|
|
46
|
+
Report data: <session>/artifacts/swarm-report.json
|
|
47
|
+
Best solution: <session>/best.json
|
|
48
|
+
All trails: <session>/trails/*.jsonl
|
|
49
|
+
Original objective: <config.ant_prompt.objective>
|
|
50
|
+
|
|
51
|
+
## Progress Milestones
|
|
52
|
+
Report via team_msg at: report loaded -> synthesis done -> verification done.
|
|
53
|
+
Report completion via team_msg type="task_complete" after final send_message.`
|
|
54
|
+
})
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
STOP. Resume on analyst callback.
|
|
58
|
+
|
|
59
|
+
### Step 3: On analyst callback
|
|
60
|
+
|
|
61
|
+
Verify `<session>/artifacts/best-solution.md` exists.
|
|
62
|
+
|
|
63
|
+
If missing -> ask_user (skip synthesis / retry analyst).
|
|
64
|
+
|
|
65
|
+
### Step 4: Build completion summary
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
[coordinator] ============================================
|
|
69
|
+
[coordinator] SWARM CONVERGED
|
|
70
|
+
[coordinator]
|
|
71
|
+
[coordinator] Iterations: <iterations_completed> / <max_iterations>
|
|
72
|
+
[coordinator] Trigger: <triggered_by[0]>
|
|
73
|
+
[coordinator] Total ants spawned: <iterations * n_ants>
|
|
74
|
+
[coordinator]
|
|
75
|
+
[coordinator] Best Solution:
|
|
76
|
+
[coordinator] ant_id: <best.ant_id>
|
|
77
|
+
[coordinator] iteration: <best.iteration>
|
|
78
|
+
[coordinator] path: <best.path joined with " -> ">
|
|
79
|
+
[coordinator] verified_score: <best.score>
|
|
80
|
+
[coordinator] summary: <best.candidate_solution.summary>
|
|
81
|
+
[coordinator]
|
|
82
|
+
[coordinator] Convergence curve (entropy):
|
|
83
|
+
[coordinator] iter 1: <e1> iter 2: <e2> iter 3: <e3> ...
|
|
84
|
+
[coordinator]
|
|
85
|
+
[coordinator] Deliverables:
|
|
86
|
+
[coordinator] - artifacts/best-solution.md (analyst synthesis)
|
|
87
|
+
[coordinator] - artifacts/swarm-report.json (raw data)
|
|
88
|
+
[coordinator] - best.json (canonical best)
|
|
89
|
+
[coordinator] - trails/*.jsonl (full exploration log)
|
|
90
|
+
[coordinator]
|
|
91
|
+
[coordinator] Session: <session_path>
|
|
92
|
+
[coordinator] ============================================
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Step 5: Update session state
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
session.status = "completed"
|
|
99
|
+
session.converged_at = <iso8601>
|
|
100
|
+
session.convergence_reason = <triggered_by>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Log state_update:
|
|
104
|
+
```
|
|
105
|
+
team_msg.log({
|
|
106
|
+
type: "state_update",
|
|
107
|
+
summary: "Swarm pipeline complete: <iterations_completed> iters, best=<score>",
|
|
108
|
+
data: { ... }
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Step 6: Completion action (interactive)
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
ask_user({
|
|
116
|
+
questions: [{
|
|
117
|
+
question: "Swarm pipeline complete. What would you like to do?",
|
|
118
|
+
header: "Completion",
|
|
119
|
+
multiSelect: false,
|
|
120
|
+
options: [
|
|
121
|
+
{ label: "Archive & Clean (Recommended)", description: "Archive session, delete team" },
|
|
122
|
+
{ label: "Keep Active", description: "Preserve for follow-up iteration" },
|
|
123
|
+
{ label: "Export Best Solution", description: "Copy best-solution.md to target path" },
|
|
124
|
+
{ label: "Run Another Round", description: "Reset convergence, run K more iterations from current pheromone" }
|
|
125
|
+
]
|
|
126
|
+
}]
|
|
127
|
+
})
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Action Handlers
|
|
131
|
+
|
|
132
|
+
| Choice | Steps |
|
|
133
|
+
|--------|-------|
|
|
134
|
+
| Archive & Clean | session.status = "completed"; delete_team; output final summary |
|
|
135
|
+
| Keep Active | session.status = "paused"; output resume instructions |
|
|
136
|
+
| Export Best Solution | ask_user(target path); copy best-solution.md + best.json; then Archive & Clean |
|
|
137
|
+
| Run Another Round | ask_user(additional K); reset convergence counters; re-enter Phase 3 iterate.md |
|
|
138
|
+
|
|
139
|
+
## Failure Cases
|
|
140
|
+
|
|
141
|
+
| Failure | Action |
|
|
142
|
+
|---------|--------|
|
|
143
|
+
| `aco.py report` fails | Read best.json directly + manual top-K from trails/ |
|
|
144
|
+
| Analyst worker crashes | Generate minimal best-solution.md from best.json template |
|
|
145
|
+
| best.json missing | Pipeline ran but no successful ant - report failure, keep session for inspection |
|
|
146
|
+
| Run Another Round chosen but max_iterations already at limit | ask_user to raise the cap before continuing |
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Command: init-swarm
|
|
2
|
+
|
|
3
|
+
Phase 2 execution guide for coordinator. Initializes swarm session and pheromone state.
|
|
4
|
+
|
|
5
|
+
## Inputs
|
|
6
|
+
|
|
7
|
+
- `swarm-config.json` from Phase 1 (in-memory or already written to candidate session path)
|
|
8
|
+
- `session_id` already computed (`TS-<slug>-<date>`)
|
|
9
|
+
- `skill_root` = `<project>/.claude/skills/team-swarm`
|
|
10
|
+
|
|
11
|
+
## Workflow
|
|
12
|
+
|
|
13
|
+
### Step 1: Resolve paths
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
project_root = shell("pwd")
|
|
17
|
+
skill_root = "<project_root>/.claude/skills/team-swarm"
|
|
18
|
+
session_path = "<project_root>/.workflow/.team/<session_id>"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Step 2: Create session directory tree
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
mkdir -p <session_path>/{pheromone/history,trails,scores,artifacts,wisdom,.msg}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Step 3: Write swarm-config.json
|
|
28
|
+
|
|
29
|
+
Write the Phase 1-generated config to `<session_path>/swarm-config.json`.
|
|
30
|
+
|
|
31
|
+
Validate before write:
|
|
32
|
+
- `task_space.nodes` OR `task_space.auto_discover_from` present
|
|
33
|
+
- `swarm.n_ants` >= 2 (single-ant defeats swarm purpose)
|
|
34
|
+
- `convergence.max_iterations` >= 1
|
|
35
|
+
|
|
36
|
+
### Step 4: Create team
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
create_team({ name: "swarm" })
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Step 5: Write role-binding.json
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"ant": "<skill_root>/roles/ant/role.md",
|
|
47
|
+
"scorer": "<skill_root>/roles/scorer/role.md",
|
|
48
|
+
"analyst": "<skill_root>/roles/analyst/role.md"
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Saved at `<session_path>/role-binding.json` — workers resolve their role.md from this file.
|
|
53
|
+
|
|
54
|
+
### Step 6: Call aco.py init
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
Bash: python <skill_root>/scripts/aco.py --session <session_path> init
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Parse stdout JSON. On `status: "error"`:
|
|
61
|
+
- exit_code 2 -> config validation error -> ask_user to fix
|
|
62
|
+
- exit_code 1 -> runtime error -> log to issues.md + retry once
|
|
63
|
+
|
|
64
|
+
On success, capture:
|
|
65
|
+
- `n_nodes` — search space size
|
|
66
|
+
- `n_edges` — initial edge count
|
|
67
|
+
- `pheromone_path` — confirm written
|
|
68
|
+
|
|
69
|
+
### Step 7: Initialize team-session.json
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"session_id": "<session-id>",
|
|
74
|
+
"task_description": "<user task>",
|
|
75
|
+
"status": "active",
|
|
76
|
+
"team_name": "swarm",
|
|
77
|
+
"skill": "team-swarm",
|
|
78
|
+
"iteration": 0,
|
|
79
|
+
"max_iterations": <config.convergence.max_iterations>,
|
|
80
|
+
"n_ants_per_iter": <config.swarm.n_ants>,
|
|
81
|
+
"config_path": "swarm-config.json",
|
|
82
|
+
"pheromone_path": "pheromone/current.json",
|
|
83
|
+
"roles": ["coordinator", "ant", "scorer", "analyst"],
|
|
84
|
+
"scoring_mode": "<config.scoring.mode>",
|
|
85
|
+
"active_workers": [],
|
|
86
|
+
"completed_iterations": [],
|
|
87
|
+
"completion_action": "interactive",
|
|
88
|
+
"created_at": "<iso8601>"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Step 8: Initialize wisdom files
|
|
93
|
+
|
|
94
|
+
Create empty wisdom files with headers:
|
|
95
|
+
- `wisdom/learnings.md` — cross-iteration insights
|
|
96
|
+
- `wisdom/decisions.md` — config refinements made mid-pipeline
|
|
97
|
+
- `wisdom/issues.md` — errors and hallucinations log
|
|
98
|
+
|
|
99
|
+
### Step 9: Log initialization state_update
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
team_msg({
|
|
103
|
+
operation: "log",
|
|
104
|
+
session_id: "<session-id>",
|
|
105
|
+
from: "coordinator",
|
|
106
|
+
type: "state_update",
|
|
107
|
+
summary: "Swarm initialized: <n_nodes> nodes, <n_ants> ants/iter, max <K> iterations",
|
|
108
|
+
data: {
|
|
109
|
+
iteration: 0,
|
|
110
|
+
n_nodes: <n>,
|
|
111
|
+
n_ants: <n>,
|
|
112
|
+
max_iterations: <K>,
|
|
113
|
+
scoring_mode: "<mode>"
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Step 10: Proceed to Phase 3 (iterate.md)
|
|
119
|
+
|
|
120
|
+
Do NOT spawn any workers in this command. First spawn happens in iterate.md step 4.
|
|
121
|
+
|
|
122
|
+
## Success Criteria
|
|
123
|
+
|
|
124
|
+
- `<session>/swarm-config.json` exists and validates
|
|
125
|
+
- `<session>/pheromone/current.json` exists with `iteration: 0`
|
|
126
|
+
- `<session>/task-space.json` exists with `n_nodes > 0`
|
|
127
|
+
- team-session.json initialized with `iteration: 0`
|
|
128
|
+
|
|
129
|
+
## Failure Recovery
|
|
130
|
+
|
|
131
|
+
| Failure | Action |
|
|
132
|
+
|---------|--------|
|
|
133
|
+
| Config invalid | ask_user, regenerate, retry |
|
|
134
|
+
| `aco.py init` runtime error | Log to issues.md, retry once, then ask_user (abort/refine) |
|
|
135
|
+
| Directory creation fails | Check disk space / permissions, retry |
|
|
136
|
+
| create_team fails | Check team name conflict (existing swarm session), prompt to clean or resume |
|