maestro-flow 0.4.17 → 0.4.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/maestro/SKILL.md +1 -1
- package/.agents/skills/maestro-analyze/SKILL.md +5 -0
- package/.agents/skills/maestro-blueprint/SKILL.md +5 -0
- package/.agents/skills/maestro-brainstorm/SKILL.md +5 -0
- package/.agents/skills/maestro-next/SKILL.md +254 -0
- 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/SKILL.md +1 -1
- package/.agy/skills/maestro-analyze/SKILL.md +5 -0
- package/.agy/skills/maestro-blueprint/SKILL.md +5 -0
- package/.agy/skills/maestro-brainstorm/SKILL.md +5 -0
- package/.agy/skills/maestro-next/SKILL.md +250 -0
- 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-analyze.md +5 -0
- package/.claude/commands/maestro-blueprint.md +5 -0
- package/.claude/commands/maestro-brainstorm.md +5 -0
- package/.claude/commands/maestro-next.md +252 -0
- package/.claude/commands/maestro.md +1 -1
- 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/learn-decompose/SKILL.md +34 -3
- package/.codex/skills/learn-retro/SKILL.md +31 -1
- package/.codex/skills/learn-second-opinion/SKILL.md +34 -4
- package/.codex/skills/maestro-analyze/SKILL.md +44 -5
- package/.codex/skills/maestro-blueprint/SKILL.md +5 -0
- package/.codex/skills/maestro-brainstorm/SKILL.md +46 -0
- package/.codex/skills/maestro-execute/SKILL.md +61 -5
- package/.codex/skills/maestro-milestone-audit/SKILL.md +64 -13
- package/.codex/skills/maestro-milestone-complete/SKILL.md +12 -0
- package/.codex/skills/maestro-next/SKILL.md +297 -0
- package/.codex/skills/maestro-plan/SKILL.md +36 -1
- package/.codex/skills/maestro-player/SKILL.md +25 -6
- package/.codex/skills/maestro-ralph/SKILL.md +17 -10
- package/.codex/skills/maestro-ralph-execute/SKILL.md +2 -1
- package/.codex/skills/maestro-roadmap/SKILL.md +35 -4
- package/.codex/skills/maestro-ui-codify/SKILL.md +38 -10
- package/.codex/skills/maestro-verify/SKILL.md +40 -5
- package/.codex/skills/manage-codebase-rebuild/SKILL.md +52 -5
- package/.codex/skills/manage-issue-discover/SKILL.md +106 -15
- package/.codex/skills/quality-auto-test/SKILL.md +70 -16
- package/.codex/skills/quality-debug/SKILL.md +139 -28
- package/.codex/skills/quality-refactor/SKILL.md +61 -11
- package/.codex/skills/quality-review/SKILL.md +45 -9
- package/.codex/skills/quality-test/SKILL.md +58 -3
- package/.codex/skills/security-audit/SKILL.md +38 -0
- package/.codex/skills/spec-map/SKILL.md +65 -8
- package/.codex/skills/team-coordinate/SKILL.md +28 -11
- package/.codex/skills/team-coordinate/specs/role-catalog.md +20 -0
- package/.codex/skills/team-lifecycle-v4/SKILL.md +23 -7
- package/.codex/skills/team-lifecycle-v4/instructions/agent-instruction.md +20 -0
- package/.codex/skills/team-quality-assurance/SKILL.md +40 -2
- package/.codex/skills/team-review/SKILL.md +42 -2
- package/.codex/skills/team-tech-debt/SKILL.md +45 -2
- package/.codex/skills/team-testing/SKILL.md +42 -2
- package/dashboard/dist-server/dashboard/src/server/wiki/search.d.ts +6 -4
- package/dashboard/dist-server/dashboard/src/server/wiki/search.js +50 -8
- package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +32 -0
- package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +294 -0
- package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +1 -0
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +35 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js +235 -0
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js.map +1 -1
- 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/ralph/cmd-check.js +1 -1
- package/dist/src/ralph/cmd-check.js.map +1 -1
- package/dist/src/ralph/cmd-complete.js +1 -1
- package/dist/src/ralph/cmd-complete.js.map +1 -1
- package/dist/src/ralph/cmd-next.d.ts.map +1 -1
- package/dist/src/ralph/cmd-next.js +12 -4
- package/dist/src/ralph/cmd-next.js.map +1 -1
- package/dist/src/ralph/cmd-session.js +2 -2
- package/dist/src/ralph/cmd-session.js.map +1 -1
- package/dist/src/ralph/status-store.d.ts +8 -1
- package/dist/src/ralph/status-store.d.ts.map +1 -1
- package/dist/src/ralph/status-store.js +12 -2
- package/dist/src/ralph/status-store.js.map +1 -1
- package/dist/src/tools/store-knowhow.d.ts.map +1 -1
- package/dist/src/tools/store-knowhow.js +51 -64
- package/dist/src/tools/store-knowhow.js.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 +23 -0
- package/dist/src/utils/update-notices.js.map +1 -1
- package/package.json +1 -1
- package/workflows/finish-work.md +119 -0
- package/workflows/milestone-complete.md +23 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
---
|
|
2
|
+
role: ant
|
|
3
|
+
prefix: ANT
|
|
4
|
+
inner_loop: false
|
|
5
|
+
output_tag: [ant]
|
|
6
|
+
message_types:
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Ant Role — Phase 2-4
|
|
10
|
+
|
|
11
|
+
Tag: `[ant]` | Prefix: `ANT-*`
|
|
12
|
+
Responsibility: Receive path-hints from ACO controller, explore the task space starting from assigned node, produce schema-locked JSON artifact with self-evaluation.
|
|
13
|
+
|
|
14
|
+
## Boundaries
|
|
15
|
+
|
|
16
|
+
### MUST
|
|
17
|
+
- Read assignment JSON from task description (start_node, edge_preferences, max_path_length)
|
|
18
|
+
- Load swarm-config.json to understand objective + task semantics
|
|
19
|
+
- Build a path of length 1..max_path_length starting from start_node
|
|
20
|
+
- Bias choices using `edge_preferences` (pheromone-derived) BUT may deviate when evidence supports it
|
|
21
|
+
- Output strict-schema JSON to `<session>/artifacts/ant-<iter>-<id>.json` (see specs/ant-output-schema.md)
|
|
22
|
+
- Self-validate output before reporting (JSON parses + required fields + node validity)
|
|
23
|
+
- Provide ≥ 1 evidence anchor per path
|
|
24
|
+
|
|
25
|
+
### MUST NOT
|
|
26
|
+
- Modify pheromone state, best.json, trails/, or other ants' artifacts
|
|
27
|
+
- Skip path_decisions array (one entry per edge traversed)
|
|
28
|
+
- Report self_score > 0.9 without strong evidence (≥ 3 evidence anchors)
|
|
29
|
+
- Visit a node outside the task-space.json nodes list
|
|
30
|
+
- Loop back to a previously visited node in the same path (no cycles)
|
|
31
|
+
|
|
32
|
+
## Phase 2: Context Loading
|
|
33
|
+
|
|
34
|
+
| Input | Source | Required |
|
|
35
|
+
|-------|--------|----------|
|
|
36
|
+
| Assignment | Task description (parse JSON block) | Yes |
|
|
37
|
+
| Objective | `<session>/swarm-config.json#ant_prompt.objective` | Yes |
|
|
38
|
+
| Task semantics | `<session>/swarm-config.json#ant_prompt` (full block) | Yes |
|
|
39
|
+
| Task space | `<session>/task-space.json` (valid nodes list) | Yes |
|
|
40
|
+
| Pheromone hints | `assignment.edge_preferences` (already passed in) | Yes |
|
|
41
|
+
| Wisdom from prior iters | `<session>/wisdom/learnings.md` (if exists) | Optional |
|
|
42
|
+
|
|
43
|
+
Workflow:
|
|
44
|
+
1. Extract session path from task description
|
|
45
|
+
2. Parse assignment JSON block from task description
|
|
46
|
+
3. Read swarm-config.json -> capture `ant_prompt.objective`, `ant_prompt.evidence_requirements`, `task_space.max_path_length`
|
|
47
|
+
4. Read task-space.json -> build valid_nodes set
|
|
48
|
+
5. If `<session>/wisdom/learnings.md` exists -> read for prior-iteration insights
|
|
49
|
+
|
|
50
|
+
## Phase 3: Exploration
|
|
51
|
+
|
|
52
|
+
**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.
|
|
53
|
+
|
|
54
|
+
Workflow:
|
|
55
|
+
|
|
56
|
+
### 3.1 Initialize path
|
|
57
|
+
- `path = [assignment.start_node]`
|
|
58
|
+
- `path_decisions = []`
|
|
59
|
+
- `visited = {start_node}`
|
|
60
|
+
- `current = start_node`
|
|
61
|
+
|
|
62
|
+
### 3.2 Per-step exploration loop (until len(path) reaches max_path_length OR ant decides to stop early)
|
|
63
|
+
|
|
64
|
+
For each step:
|
|
65
|
+
|
|
66
|
+
1. **Compute candidate neighbors**: all nodes in task_space NOT in `visited`
|
|
67
|
+
2. **Build choice weights**:
|
|
68
|
+
- For each candidate c: `weight = edge_preferences.get("<current>::<c>", baseline) * heuristic(c)`
|
|
69
|
+
- `heuristic(c)` = ant's own evidence-based judgment (1.0 if no opinion)
|
|
70
|
+
3. **Investigate top candidates** using available tools:
|
|
71
|
+
- Tool selection: Read, Grep, Glob for code-based task spaces; or CLI delegate `--mode analysis` for richer analysis
|
|
72
|
+
- Gather evidence about each top candidate before committing
|
|
73
|
+
4. **Choose next node**: weighted-random OR argmax (when high confidence)
|
|
74
|
+
5. **Record decision**:
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"from": "<current>",
|
|
78
|
+
"to": "<chosen>",
|
|
79
|
+
"rationale": "<one-line>",
|
|
80
|
+
"guided_by": "pheromone | heuristic | evidence",
|
|
81
|
+
"pheromone_weight": <edge_preferences value>,
|
|
82
|
+
"deviation_from_hint": <bool — true if chosen != argmax(edge_preferences)>
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
6. **Append to path**, update `visited`, `current = chosen`
|
|
86
|
+
7. **Early-stop check**: if evidence shows objective achieved OR no productive next step exists -> stop
|
|
87
|
+
|
|
88
|
+
### 3.3 Self-evaluate
|
|
89
|
+
|
|
90
|
+
After path is built:
|
|
91
|
+
|
|
92
|
+
1. **self_score** (0..1): how well does this path satisfy the objective?
|
|
93
|
+
- Use `ant_prompt.evidence_requirements` as rubric
|
|
94
|
+
- Be conservative — penalize for missing evidence, weak rationale
|
|
95
|
+
2. **self_confidence** (0..1): how sure of the self_score?
|
|
96
|
+
- Low confidence if evidence is sparse or contradictory
|
|
97
|
+
3. **candidate_solution**: extract the actual deliverable along the path
|
|
98
|
+
- `type` ∈ {string, object, file_ref}
|
|
99
|
+
- `summary` — one-line
|
|
100
|
+
- `content` — actual artifact OR a path to a file written by the ant
|
|
101
|
+
|
|
102
|
+
### 3.4 Compose artifact JSON
|
|
103
|
+
|
|
104
|
+
Build the full artifact matching specs/ant-output-schema.md. All required fields populated.
|
|
105
|
+
|
|
106
|
+
## Phase 4: Verify + Publish
|
|
107
|
+
|
|
108
|
+
### Behavioral Traits
|
|
109
|
+
|
|
110
|
+
#### Accuracy — outputs must be verifiable
|
|
111
|
+
- Every node in `path` MUST exist in task-space.json
|
|
112
|
+
- Every `path_decisions[i].from` MUST equal `path[i]` and `to` MUST equal `path[i+1]`
|
|
113
|
+
- Evidence references (e.g., `file:line`) MUST be valid (Read to confirm if file_ref)
|
|
114
|
+
|
|
115
|
+
#### Feedback Contract
|
|
116
|
+
| Field | Required | Content |
|
|
117
|
+
|-------|----------|---------|
|
|
118
|
+
| files_produced | If ant wrote any | `[artifact_path]` at minimum |
|
|
119
|
+
| artifacts_written | Always | `<session>/artifacts/ant-<iter>-<id>.json` |
|
|
120
|
+
| verification_method | Always | "schema_validated + node_validity_checked" |
|
|
121
|
+
|
|
122
|
+
#### Quality Gate
|
|
123
|
+
- Schema validation pass = REQUIRED before reporting completed
|
|
124
|
+
- Fails -> retry Phase 3 once (max 1 retry to bound cost)
|
|
125
|
+
- Still fails -> report `partial_completion` with `validation_errors` in state data
|
|
126
|
+
|
|
127
|
+
### Verification Steps
|
|
128
|
+
|
|
129
|
+
1. **Schema validation**:
|
|
130
|
+
- Parse the JSON via Read
|
|
131
|
+
- Confirm all required fields from specs/ant-output-schema.md
|
|
132
|
+
- Confirm numeric ranges (self_score, self_confidence ∈ [0,1])
|
|
133
|
+
- Confirm `len(path_decisions) == len(path) - 1`
|
|
134
|
+
2. **Node validity**: every node in path ∈ task_space.json#nodes
|
|
135
|
+
3. **Evidence check**: at least 1 evidence anchor present; if file_ref, Read to confirm existence
|
|
136
|
+
4. **Write artifact**: `write_to_file(<session>/artifacts/ant-<iter>-<id>.json, <json_string>)`
|
|
137
|
+
5. **Re-read to confirm write**: Read it back, parse, sanity check
|
|
138
|
+
|
|
139
|
+
### State Update
|
|
140
|
+
|
|
141
|
+
Set Phase 5 `team_msg.log` data:
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"task_id": "ANT-<k>-<i>",
|
|
145
|
+
"role": "ant",
|
|
146
|
+
"status": "completed",
|
|
147
|
+
"iteration": <k>,
|
|
148
|
+
"self_score": <float>,
|
|
149
|
+
"self_confidence": <float>,
|
|
150
|
+
"path_length": <int>,
|
|
151
|
+
"artifact_path": "<session>/artifacts/ant-<k>-<i>.json",
|
|
152
|
+
"verification": "schema_pass + node_valid + evidence_present"
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Error Handling
|
|
157
|
+
|
|
158
|
+
| Scenario | Resolution |
|
|
159
|
+
|----------|------------|
|
|
160
|
+
| Assignment JSON malformed | Report error to coordinator via send_message, STOP |
|
|
161
|
+
| start_node not in task_space | Report error (config mismatch), STOP |
|
|
162
|
+
| No valid neighbors at step 1 | Build single-node path, self_score = 0, report |
|
|
163
|
+
| Schema validation fails twice | Report `partial_completion` with errors list |
|
|
164
|
+
| Evidence requirements unsatisfiable | Lower self_score; document blocker in artifact `notes` field |
|
|
165
|
+
| Tool calls fail (Read/Grep) | Note in artifact `notes`; reduce self_confidence; proceed with available info |
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
|
|
2
|
+
## Sub-Agent Registration (Antigravity)
|
|
3
|
+
|
|
4
|
+
Before any `invoke_subagent` call below, register each sub-agent type once per session by reading the system_prompt from `<agy-agents-dir>/<name>.md` and passing it to `define_subagent`. The `<agy-agents-dir>` is:
|
|
5
|
+
- global install: `~/.gemini/antigravity-cli/agents/`
|
|
6
|
+
- workspace install: `<project>/.agents/agents/`
|
|
7
|
+
|
|
8
|
+
- `define_subagent(name="team-worker", description="<from agents/team-worker.md frontmatter>", system_prompt=<contents of agents/team-worker.md body>, enable_write_tools=true, enable_mcp_tools=true, enable_subagent_tools=false)`
|
|
9
|
+
|
|
10
|
+
**ConversationId tracking**: `invoke_subagent` returns a ConversationId per spawned instance. Subsequent `send_message(Recipient=<ConversationId>, Message=...)` calls require that ConversationId — never use the role name as the recipient.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
# Command: converge
|
|
14
|
+
|
|
15
|
+
Phase 4 execution guide. Run after `aco.py converged` returns `true`.
|
|
16
|
+
|
|
17
|
+
## Workflow
|
|
18
|
+
|
|
19
|
+
### Step 1: Call aco.py report
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
Bash: python <skill_root>/scripts/aco.py --session <session> report
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Parse stdout JSON. Expected:
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"status": "ok",
|
|
29
|
+
"best": { ant_id, iteration, path, score, candidate_solution, evidence, ... },
|
|
30
|
+
"top_k": [<top 5 trails>],
|
|
31
|
+
"convergence_curve": [{iteration, entropy, tau_max, tau_mean}, ...],
|
|
32
|
+
"final_pheromone_stats": {...},
|
|
33
|
+
"iterations_completed": <int>
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Save full report to `<session>/artifacts/swarm-report.json` (raw data for analyst).
|
|
38
|
+
|
|
39
|
+
### Step 2: Spawn analyst worker
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
invoke_subagent([{ TypeName: "team-worker", Role: "analyst", Prompt: "<Prompt>", Workspace: "inherit" }])
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
STOP. Resume on analyst callback.
|
|
46
|
+
|
|
47
|
+
### Step 3: On analyst callback
|
|
48
|
+
|
|
49
|
+
Verify `<session>/artifacts/best-solution.md` exists.
|
|
50
|
+
|
|
51
|
+
If missing -> ask_question (skip synthesis / retry analyst).
|
|
52
|
+
|
|
53
|
+
### Step 4: Build completion summary
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
[coordinator] ============================================
|
|
57
|
+
[coordinator] SWARM CONVERGED
|
|
58
|
+
[coordinator]
|
|
59
|
+
[coordinator] Iterations: <iterations_completed> / <max_iterations>
|
|
60
|
+
[coordinator] Trigger: <triggered_by[0]>
|
|
61
|
+
[coordinator] Total ants spawned: <iterations * n_ants>
|
|
62
|
+
[coordinator]
|
|
63
|
+
[coordinator] Best Solution:
|
|
64
|
+
[coordinator] ant_id: <best.ant_id>
|
|
65
|
+
[coordinator] iteration: <best.iteration>
|
|
66
|
+
[coordinator] path: <best.path joined with " -> ">
|
|
67
|
+
[coordinator] verified_score: <best.score>
|
|
68
|
+
[coordinator] summary: <best.candidate_solution.summary>
|
|
69
|
+
[coordinator]
|
|
70
|
+
[coordinator] Convergence curve (entropy):
|
|
71
|
+
[coordinator] iter 1: <e1> iter 2: <e2> iter 3: <e3> ...
|
|
72
|
+
[coordinator]
|
|
73
|
+
[coordinator] Deliverables:
|
|
74
|
+
[coordinator] - artifacts/best-solution.md (analyst synthesis)
|
|
75
|
+
[coordinator] - artifacts/swarm-report.json (raw data)
|
|
76
|
+
[coordinator] - best.json (canonical best)
|
|
77
|
+
[coordinator] - trails/*.jsonl (full exploration log)
|
|
78
|
+
[coordinator]
|
|
79
|
+
[coordinator] Session: <session_path>
|
|
80
|
+
[coordinator] ============================================
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Step 5: Update session state
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
session.status = "completed"
|
|
87
|
+
session.converged_at = <iso8601>
|
|
88
|
+
session.convergence_reason = <triggered_by>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Log state_update:
|
|
92
|
+
```
|
|
93
|
+
team_msg.log({
|
|
94
|
+
type: "state_update",
|
|
95
|
+
summary: "Swarm pipeline complete: <iterations_completed> iters, best=<score>",
|
|
96
|
+
data: { ... }
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Step 6: Completion action (interactive)
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
ask_question({
|
|
104
|
+
questions: [{
|
|
105
|
+
question: "Swarm pipeline complete. What would you like to do?",
|
|
106
|
+
header: "Completion",
|
|
107
|
+
multiSelect: false,
|
|
108
|
+
options: [
|
|
109
|
+
{ label: "Archive & Clean (Recommended)", description: "Archive session, delete team" },
|
|
110
|
+
{ label: "Keep Active", description: "Preserve for follow-up iteration" },
|
|
111
|
+
{ label: "Export Best Solution", description: "Copy best-solution.md to target path" },
|
|
112
|
+
{ label: "Run Another Round", description: "Reset convergence, run K more iterations from current pheromone" }
|
|
113
|
+
]
|
|
114
|
+
}]
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Action Handlers
|
|
119
|
+
|
|
120
|
+
| Choice | Steps |
|
|
121
|
+
|--------|-------|
|
|
122
|
+
| Archive & Clean | session.status = "completed"; TeamDelete; output final summary |
|
|
123
|
+
| Keep Active | session.status = "paused"; output resume instructions |
|
|
124
|
+
| Export Best Solution | ask_question(target path); copy best-solution.md + best.json; then Archive & Clean |
|
|
125
|
+
| Run Another Round | ask_question(additional K); reset convergence counters; re-enter Phase 3 iterate.md |
|
|
126
|
+
|
|
127
|
+
## Failure Cases
|
|
128
|
+
|
|
129
|
+
| Failure | Action |
|
|
130
|
+
|---------|--------|
|
|
131
|
+
| `aco.py report` fails | Read best.json directly + manual top-K from trails/ |
|
|
132
|
+
| Analyst worker crashes | Generate minimal best-solution.md from best.json template |
|
|
133
|
+
| best.json missing | Pipeline ran but no successful ant - report failure, keep session for inspection |
|
|
134
|
+
| Run Another Round chosen but max_iterations already at limit | ask_question 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 = run_command("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
|
+
TeamCreate({ 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_question 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_question, regenerate, retry |
|
|
134
|
+
| `aco.py init` runtime error | Log to issues.md, retry once, then ask_question (abort/refine) |
|
|
135
|
+
| Directory creation fails | Check disk space / permissions, retry |
|
|
136
|
+
| TeamCreate fails | Check team name conflict (existing swarm session), prompt to clean or resume |
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
## Sub-Agent Registration (Antigravity)
|
|
3
|
+
|
|
4
|
+
Before any `invoke_subagent` call below, register each sub-agent type once per session by reading the system_prompt from `<agy-agents-dir>/<name>.md` and passing it to `define_subagent`. The `<agy-agents-dir>` is:
|
|
5
|
+
- global install: `~/.gemini/antigravity-cli/agents/`
|
|
6
|
+
- workspace install: `<project>/.agents/agents/`
|
|
7
|
+
|
|
8
|
+
- `define_subagent(name="team-worker", description="<from agents/team-worker.md frontmatter>", system_prompt=<contents of agents/team-worker.md body>, enable_write_tools=true, enable_mcp_tools=true, enable_subagent_tools=false)`
|
|
9
|
+
|
|
10
|
+
**ConversationId tracking**: `invoke_subagent` returns a ConversationId per spawned instance. Subsequent `send_message(Recipient=<ConversationId>, Message=...)` calls require that ConversationId — never use the role name as the recipient.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
# Command: iterate
|
|
14
|
+
|
|
15
|
+
Phase 3 execution guide. ONE iteration body. Loop is driven by callback re-entry — each iteration is spawn-and-stop.
|
|
16
|
+
|
|
17
|
+
## Two Entry Points
|
|
18
|
+
|
|
19
|
+
| Entry | Trigger | Action |
|
|
20
|
+
|-------|---------|--------|
|
|
21
|
+
| **Iteration start** | Phase 3 invoked OR previous iteration converged=false | Run "Iteration Start" workflow |
|
|
22
|
+
| **Iteration end** | All ants of current iter reported via callback | Run "Iteration End" workflow |
|
|
23
|
+
|
|
24
|
+
## Iteration Start Workflow
|
|
25
|
+
|
|
26
|
+
### Step 1: Determine iteration number
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
k = session.iteration + 1
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
If `k > session.max_iterations`: force converge to Phase 4 (safety net).
|
|
33
|
+
|
|
34
|
+
### Step 2: Call aco.py select
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
Bash: python <skill_root>/scripts/aco.py --session <session> select --iter <k>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Parse stdout JSON. Expected:
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"status": "ok",
|
|
44
|
+
"iteration": <k>,
|
|
45
|
+
"n_assignments": <N>,
|
|
46
|
+
"assignments": [
|
|
47
|
+
{
|
|
48
|
+
"ant_id": "ANT-<k>-<i>",
|
|
49
|
+
"start_node": "<node>",
|
|
50
|
+
"edge_preferences": {"a::b": 0.4, ...},
|
|
51
|
+
"max_path_length": <int>,
|
|
52
|
+
"iteration": <k>
|
|
53
|
+
}, ...
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
On error -> log to issues.md, ask_question (retry / abort).
|
|
59
|
+
|
|
60
|
+
### Step 3: Create ant tasks
|
|
61
|
+
|
|
62
|
+
For each assignment:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
TaskCreate({
|
|
66
|
+
subject: "ANT-<k>-<i>: explore from <start_node>",
|
|
67
|
+
description: "Session: <session_path>\nAssignment: <assignment JSON>\nObjective: <config.ant_prompt.objective>"
|
|
68
|
+
})
|
|
69
|
+
TaskUpdate({ taskId: <new>, owner: "ant" })
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Set the task ID to match `ANT-<k>-<i>` (or record mapping in `.msg/meta.json` if framework auto-assigns IDs).
|
|
73
|
+
|
|
74
|
+
### Step 4: Spawn N ant workers in parallel
|
|
75
|
+
|
|
76
|
+
For each assignment, spawn one team-worker:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
invoke_subagent([{ TypeName: "team-worker", Role: "ant-<k>-<i>", Prompt: "<Prompt>", Workspace: "inherit" }])
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
All N spawns in a single message (parallel).
|
|
83
|
+
|
|
84
|
+
### Step 5: Update session state
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
session.iteration = <k> (mark "in progress")
|
|
88
|
+
session.active_workers = [<list of ant IDs>]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Log state_update:
|
|
92
|
+
```
|
|
93
|
+
team_msg.log({
|
|
94
|
+
type: "state_update",
|
|
95
|
+
summary: "Iteration <k> dispatched: <N> ants",
|
|
96
|
+
data: { iteration: <k>, n_ants: <N>, status: "ants_running" }
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Step 6: STOP
|
|
101
|
+
|
|
102
|
+
Wait for ant callbacks. Each ant reports via team_msg(type="task_complete"). When ALL N reported, callback handler invokes "Iteration End" workflow.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Iteration End Workflow
|
|
107
|
+
|
|
108
|
+
### Step 1: Verify completion
|
|
109
|
+
|
|
110
|
+
Check `ANT-<k>-*` task statuses. If any still in_progress: not yet complete, do nothing.
|
|
111
|
+
|
|
112
|
+
If all completed -> proceed.
|
|
113
|
+
|
|
114
|
+
### Step 2: (Conditional) Spawn scorer
|
|
115
|
+
|
|
116
|
+
If `config.scoring.mode == "llm"`:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
invoke_subagent([{ TypeName: "team-worker", Role: "scorer-<k>", Prompt: "<Prompt>", Workspace: "inherit" }])
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
STOP and await scorer callback. On callback resume at Step 3.
|
|
123
|
+
|
|
124
|
+
If `scoring.mode == "script"` or `"fallback"` -> proceed directly to Step 3.
|
|
125
|
+
|
|
126
|
+
### Step 3: Call aco.py update
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
Bash: python <skill_root>/scripts/aco.py --session <session> update --iter <k>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Parse stdout JSON. Expected:
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"status": "ok",
|
|
136
|
+
"iteration": <k>,
|
|
137
|
+
"n_ants_processed": <N>,
|
|
138
|
+
"mean_score": <float>,
|
|
139
|
+
"best_score": <float>,
|
|
140
|
+
"delta": <float>,
|
|
141
|
+
"elite_updated": <bool>,
|
|
142
|
+
"hallucinations_flagged": [<ant_ids>],
|
|
143
|
+
"stats": {<pheromone stats>}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Step 4: Log iteration result
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
team_msg.log({
|
|
151
|
+
type: "state_update",
|
|
152
|
+
summary: "Iter <k> done: best=<X>, mean=<Y>, delta=<Z>",
|
|
153
|
+
data: { iteration: <k>, best_score, mean_score, delta, elite_updated, hallucinations_flagged }
|
|
154
|
+
})
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
If `hallucinations_flagged.length > N/2`: append warning to wisdom/issues.md (high-noise iteration).
|
|
158
|
+
|
|
159
|
+
### Step 5: Call aco.py converged
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
Bash: python <skill_root>/scripts/aco.py --session <session> converged
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Parse:
|
|
166
|
+
```json
|
|
167
|
+
{ "converged": <bool>, "triggered_by": [...], "reason": "...", "metrics": {...} }
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Step 6: Branch on convergence
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
if converged:
|
|
174
|
+
update session: completed_iterations.push(k), status = "converging"
|
|
175
|
+
-> proceed to Phase 4 (converge.md)
|
|
176
|
+
else:
|
|
177
|
+
update session: completed_iterations.push(k), active_workers = []
|
|
178
|
+
-> re-enter "Iteration Start" workflow with k+1
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Step 7: Output progress to user
|
|
182
|
+
|
|
183
|
+
After each iteration:
|
|
184
|
+
```
|
|
185
|
+
[coordinator] Iteration <k>/<max> complete.
|
|
186
|
+
[coordinator] best=<best_score> mean=<mean_score> delta=<delta>
|
|
187
|
+
[coordinator] entropy=<entropy> hallucinations=<count>
|
|
188
|
+
[coordinator] Status: <converged | continuing to iter k+1>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Edge Cases
|
|
194
|
+
|
|
195
|
+
| Condition | Handling |
|
|
196
|
+
|-----------|----------|
|
|
197
|
+
| Ant task failed | Mark task failed; if >50% failed in iter -> halt, ask_question |
|
|
198
|
+
| Ant produced no artifact | Script's update will skip it; if all skipped -> error -> halt |
|
|
199
|
+
| `aco.py update` fails | Retry once; if persistent -> halt with error report |
|
|
200
|
+
| Scorer worker fails | Fall back to `script` or `fallback` mode for this iter, log warning |
|
|
201
|
+
| Iteration takes too long | After timeout (configurable), check `team_msg` for blockers |
|
|
202
|
+
| User sends `feedback <text>` mid-iteration | Append to wisdom/learnings.md; apply at next iteration start (not mid-iter) |
|