opencode-swarm-plugin 0.12.31 → 0.13.1
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/.beads/issues.jsonl +204 -10
- package/.opencode/skills/tdd/SKILL.md +182 -0
- package/README.md +165 -17
- package/bun.lock +23 -0
- package/dist/index.js +4082 -457
- package/dist/pglite.data +0 -0
- package/dist/pglite.wasm +0 -0
- package/dist/plugin.js +4070 -533
- package/examples/commands/swarm.md +100 -28
- package/examples/skills/beads-workflow/SKILL.md +75 -28
- package/examples/skills/swarm-coordination/SKILL.md +165 -21
- package/global-skills/swarm-coordination/SKILL.md +116 -58
- package/global-skills/testing-patterns/SKILL.md +430 -0
- package/global-skills/testing-patterns/references/dependency-breaking-catalog.md +586 -0
- package/package.json +11 -5
- package/src/index.ts +44 -5
- package/src/streams/agent-mail.test.ts +777 -0
- package/src/streams/agent-mail.ts +535 -0
- package/src/streams/debug.test.ts +500 -0
- package/src/streams/debug.ts +629 -0
- package/src/streams/effect/ask.integration.test.ts +314 -0
- package/src/streams/effect/ask.ts +202 -0
- package/src/streams/effect/cursor.integration.test.ts +418 -0
- package/src/streams/effect/cursor.ts +288 -0
- package/src/streams/effect/deferred.test.ts +357 -0
- package/src/streams/effect/deferred.ts +445 -0
- package/src/streams/effect/index.ts +17 -0
- package/src/streams/effect/layers.ts +73 -0
- package/src/streams/effect/lock.test.ts +385 -0
- package/src/streams/effect/lock.ts +399 -0
- package/src/streams/effect/mailbox.test.ts +260 -0
- package/src/streams/effect/mailbox.ts +318 -0
- package/src/streams/events.test.ts +628 -0
- package/src/streams/events.ts +214 -0
- package/src/streams/index.test.ts +229 -0
- package/src/streams/index.ts +492 -0
- package/src/streams/migrations.test.ts +355 -0
- package/src/streams/migrations.ts +269 -0
- package/src/streams/projections.test.ts +611 -0
- package/src/streams/projections.ts +302 -0
- package/src/streams/store.integration.test.ts +548 -0
- package/src/streams/store.ts +546 -0
- package/src/streams/swarm-mail.ts +552 -0
- package/src/swarm-mail.integration.test.ts +970 -0
- package/src/swarm-mail.ts +739 -0
- package/src/swarm.integration.test.ts +16 -10
- package/src/swarm.ts +146 -78
- package/src/tool-availability.ts +35 -2
- package/global-skills/mcp-tool-authoring/SKILL.md +0 -695
|
@@ -8,23 +8,47 @@ tags:
|
|
|
8
8
|
tools:
|
|
9
9
|
- swarm_decompose
|
|
10
10
|
- swarm_complete
|
|
11
|
-
-
|
|
12
|
-
-
|
|
11
|
+
- swarmmail_init
|
|
12
|
+
- swarmmail_send
|
|
13
|
+
- swarmmail_inbox
|
|
14
|
+
- swarmmail_read_message
|
|
15
|
+
- swarmmail_reserve
|
|
16
|
+
- swarmmail_release
|
|
17
|
+
- skills_use
|
|
18
|
+
- skills_list
|
|
19
|
+
related_skills:
|
|
20
|
+
- testing-patterns
|
|
21
|
+
- system-design
|
|
22
|
+
- cli-builder
|
|
13
23
|
---
|
|
14
24
|
|
|
15
25
|
# Swarm Coordination Skill
|
|
16
26
|
|
|
17
27
|
This skill provides guidance for effective multi-agent coordination in OpenCode swarm workflows.
|
|
18
28
|
|
|
29
|
+
**IMPORTANT:** This skill references global skills in `global-skills/`. Workers should load domain-specific skills based on their subtask type.
|
|
30
|
+
|
|
31
|
+
## MANDATORY: Swarm Mail
|
|
32
|
+
|
|
33
|
+
**ALL coordination MUST use `swarmmail_*` tools.** This is non-negotiable.
|
|
34
|
+
|
|
35
|
+
Swarm Mail is embedded (no external server needed) and provides:
|
|
36
|
+
|
|
37
|
+
- File reservations to prevent conflicts
|
|
38
|
+
- Message passing between agents
|
|
39
|
+
- Thread-based coordination tied to beads
|
|
40
|
+
|
|
19
41
|
## When to Use Swarm Coordination
|
|
20
42
|
|
|
21
43
|
Use swarm coordination when:
|
|
44
|
+
|
|
22
45
|
- A task has multiple independent subtasks that can run in parallel
|
|
23
46
|
- The task requires different specializations (e.g., frontend + backend + tests)
|
|
24
47
|
- Work can be divided by file/module boundaries
|
|
25
48
|
- Time-to-completion matters and parallelization helps
|
|
26
49
|
|
|
27
50
|
Do NOT use swarm coordination when:
|
|
51
|
+
|
|
28
52
|
- The task is simple and can be done by one agent
|
|
29
53
|
- Subtasks have heavy dependencies on each other
|
|
30
54
|
- The overhead of coordination exceeds the benefit
|
|
@@ -34,6 +58,7 @@ Do NOT use swarm coordination when:
|
|
|
34
58
|
### 1. Analyze the Task
|
|
35
59
|
|
|
36
60
|
Before decomposing, understand:
|
|
61
|
+
|
|
37
62
|
- What are the distinct units of work?
|
|
38
63
|
- Which parts can run in parallel vs sequentially?
|
|
39
64
|
- What are the file/module boundaries?
|
|
@@ -42,7 +67,8 @@ Before decomposing, understand:
|
|
|
42
67
|
### 2. Choose a Decomposition Strategy
|
|
43
68
|
|
|
44
69
|
**Parallel Strategy** - For independent subtasks:
|
|
45
|
-
|
|
70
|
+
|
|
71
|
+
```text
|
|
46
72
|
Parent Task: "Add user authentication"
|
|
47
73
|
├── Subtask 1: "Create auth API endpoints" (backend)
|
|
48
74
|
├── Subtask 2: "Build login/signup forms" (frontend)
|
|
@@ -51,7 +77,8 @@ Parent Task: "Add user authentication"
|
|
|
51
77
|
```
|
|
52
78
|
|
|
53
79
|
**Sequential Strategy** - When order matters:
|
|
54
|
-
|
|
80
|
+
|
|
81
|
+
```text
|
|
55
82
|
Parent Task: "Migrate database schema"
|
|
56
83
|
├── Step 1: "Create migration files"
|
|
57
84
|
├── Step 2: "Update model definitions"
|
|
@@ -60,7 +87,8 @@ Parent Task: "Migrate database schema"
|
|
|
60
87
|
```
|
|
61
88
|
|
|
62
89
|
**Hybrid Strategy** - Mixed dependencies:
|
|
63
|
-
|
|
90
|
+
|
|
91
|
+
```text
|
|
64
92
|
Parent Task: "Add feature X"
|
|
65
93
|
├── Phase 1 (parallel):
|
|
66
94
|
│ ├── Subtask A: "Design API"
|
|
@@ -76,73 +104,189 @@ Parent Task: "Add feature X"
|
|
|
76
104
|
|
|
77
105
|
When multiple agents work on the same codebase:
|
|
78
106
|
|
|
79
|
-
1. **
|
|
80
|
-
2. **
|
|
81
|
-
3. **
|
|
82
|
-
4. **
|
|
107
|
+
1. **Initialize Swarm Mail first** - Use `swarmmail_init` before any work
|
|
108
|
+
2. **Reserve files before editing** - Use `swarmmail_reserve` to claim files
|
|
109
|
+
3. **Respect reservations** - Don't edit files reserved by other agents
|
|
110
|
+
4. **Release when done** - Use `swarmmail_release` or let `swarm_complete` handle it
|
|
111
|
+
5. **Coordinate on shared files** - If you must edit a reserved file, send a message to the owning agent
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
// Initialize first
|
|
115
|
+
await swarmmail_init({
|
|
116
|
+
project_path: "$PWD",
|
|
117
|
+
task_description: "Working on auth feature",
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Reserve files
|
|
121
|
+
await swarmmail_reserve({
|
|
122
|
+
paths: ["src/auth/**"],
|
|
123
|
+
reason: "bd-123: Auth implementation",
|
|
124
|
+
ttl_seconds: 3600,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Work...
|
|
128
|
+
|
|
129
|
+
// Release when done
|
|
130
|
+
await swarmmail_release();
|
|
131
|
+
```
|
|
83
132
|
|
|
84
133
|
## Communication Patterns
|
|
85
134
|
|
|
86
135
|
### Broadcasting Updates
|
|
87
|
-
|
|
88
|
-
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
swarmmail_send({
|
|
139
|
+
to: ["*"],
|
|
140
|
+
subject: "API Complete",
|
|
141
|
+
body: "Completed API endpoints, ready for frontend integration",
|
|
142
|
+
thread_id: epic_id,
|
|
143
|
+
});
|
|
89
144
|
```
|
|
90
145
|
|
|
91
146
|
### Direct Coordination
|
|
92
|
-
|
|
93
|
-
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
swarmmail_send({
|
|
150
|
+
to: ["frontend-agent"],
|
|
151
|
+
subject: "Auth API Spec",
|
|
152
|
+
body: "Auth API is at /api/auth/*, here's the spec...",
|
|
153
|
+
thread_id: epic_id,
|
|
154
|
+
});
|
|
94
155
|
```
|
|
95
156
|
|
|
96
|
-
###
|
|
157
|
+
### Checking for Messages
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
// Check inbox (max 5, no bodies for context safety)
|
|
161
|
+
const inbox = await swarmmail_inbox();
|
|
162
|
+
|
|
163
|
+
// Read specific message body
|
|
164
|
+
const message = await swarmmail_read_message({ message_id: N });
|
|
97
165
|
```
|
|
98
|
-
|
|
99
|
-
|
|
166
|
+
|
|
167
|
+
### Reporting Blockers
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
swarmmail_send({
|
|
171
|
+
to: ["coordinator"],
|
|
172
|
+
subject: "BLOCKED: Need DB schema",
|
|
173
|
+
body: "Can't proceed without users table",
|
|
174
|
+
thread_id: epic_id,
|
|
175
|
+
importance: "urgent",
|
|
176
|
+
});
|
|
100
177
|
```
|
|
101
178
|
|
|
102
179
|
## Best Practices
|
|
103
180
|
|
|
104
|
-
1. **
|
|
105
|
-
2. **
|
|
106
|
-
3. **
|
|
107
|
-
4. **
|
|
108
|
-
5. **
|
|
181
|
+
1. **Initialize Swarm Mail first** - Always call `swarmmail_init` before any work
|
|
182
|
+
2. **Small, focused subtasks** - Each subtask should be completable in one agent session
|
|
183
|
+
3. **Clear boundaries** - Define exactly what files/modules each subtask touches
|
|
184
|
+
4. **Explicit handoffs** - When one task enables another, communicate clearly
|
|
185
|
+
5. **Graceful failures** - If a subtask fails, don't block the whole swarm
|
|
186
|
+
6. **Progress updates** - Use beads to track subtask status
|
|
187
|
+
7. **Load relevant skills** - Workers should call `skills_use()` based on their task type:
|
|
188
|
+
- Testing work → `skills_use(name="testing-patterns")`
|
|
189
|
+
- Architecture decisions → `skills_use(name="system-design")`
|
|
190
|
+
- CLI development → `skills_use(name="cli-builder")`
|
|
191
|
+
- Multi-agent coordination → `skills_use(name="swarm-coordination")`
|
|
109
192
|
|
|
110
193
|
## Common Patterns
|
|
111
194
|
|
|
112
195
|
### Feature Development
|
|
196
|
+
|
|
113
197
|
```yaml
|
|
114
198
|
decomposition:
|
|
115
199
|
strategy: hybrid
|
|
200
|
+
skills: [system-design, swarm-coordination]
|
|
116
201
|
phases:
|
|
117
202
|
- name: design
|
|
118
203
|
parallel: true
|
|
119
204
|
subtasks: [api-design, ui-design]
|
|
205
|
+
recommended_skills: [system-design]
|
|
120
206
|
- name: implement
|
|
121
207
|
parallel: true
|
|
122
208
|
subtasks: [backend, frontend]
|
|
209
|
+
recommended_skills: [system-design]
|
|
123
210
|
- name: validate
|
|
124
211
|
parallel: true
|
|
125
212
|
subtasks: [tests, docs, review]
|
|
213
|
+
recommended_skills: [testing-patterns]
|
|
126
214
|
```
|
|
127
215
|
|
|
128
216
|
### Bug Fix Swarm
|
|
217
|
+
|
|
129
218
|
```yaml
|
|
130
219
|
decomposition:
|
|
131
220
|
strategy: sequential
|
|
221
|
+
skills: [testing-patterns]
|
|
132
222
|
subtasks:
|
|
133
223
|
- reproduce-bug
|
|
134
224
|
- identify-root-cause
|
|
135
225
|
- implement-fix
|
|
136
226
|
- add-regression-test
|
|
227
|
+
recommended_skills: [testing-patterns]
|
|
137
228
|
```
|
|
138
229
|
|
|
139
230
|
### Refactoring
|
|
231
|
+
|
|
140
232
|
```yaml
|
|
141
233
|
decomposition:
|
|
142
234
|
strategy: parallel
|
|
235
|
+
skills: [testing-patterns, system-design]
|
|
143
236
|
subtasks:
|
|
144
237
|
- refactor-module-a
|
|
145
238
|
- refactor-module-b
|
|
146
239
|
- update-imports
|
|
147
240
|
- run-full-test-suite
|
|
241
|
+
recommended_skills: [testing-patterns, system-design]
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Skill Integration Workflow
|
|
245
|
+
|
|
246
|
+
**For Coordinators:**
|
|
247
|
+
|
|
248
|
+
1. Initialize Swarm Mail with `swarmmail_init`
|
|
249
|
+
2. Load `swarm-coordination` skill
|
|
250
|
+
3. Analyze task type
|
|
251
|
+
4. Load additional skills based on domain (testing, design, CLI)
|
|
252
|
+
5. Include skill recommendations in `shared_context` for workers
|
|
253
|
+
|
|
254
|
+
**For Workers:**
|
|
255
|
+
|
|
256
|
+
1. Initialize Swarm Mail with `swarmmail_init`
|
|
257
|
+
2. Read `shared_context` from coordinator
|
|
258
|
+
3. Load recommended skills with `skills_use(name="skill-name")`
|
|
259
|
+
4. Apply skill knowledge to subtask
|
|
260
|
+
5. Report progress via `swarmmail_send`
|
|
261
|
+
6. Complete with `swarm_complete`
|
|
262
|
+
|
|
263
|
+
**Example shared_context:**
|
|
264
|
+
|
|
265
|
+
```markdown
|
|
266
|
+
## Context from Coordinator
|
|
267
|
+
|
|
268
|
+
Past similar tasks: [CASS results]
|
|
269
|
+
Project learnings: [semantic-memory results]
|
|
270
|
+
|
|
271
|
+
## Recommended Skills
|
|
272
|
+
|
|
273
|
+
- skills_use(name="testing-patterns") - for test creation
|
|
274
|
+
- skills_use(name="system-design") - for module boundaries
|
|
275
|
+
|
|
276
|
+
## Task-Specific Notes
|
|
277
|
+
|
|
278
|
+
[Domain knowledge from coordinator]
|
|
148
279
|
```
|
|
280
|
+
|
|
281
|
+
## Swarm Mail Quick Reference
|
|
282
|
+
|
|
283
|
+
| Tool | Purpose |
|
|
284
|
+
| ------------------------ | ----------------------------------- |
|
|
285
|
+
| `swarmmail_init` | Initialize session (REQUIRED FIRST) |
|
|
286
|
+
| `swarmmail_send` | Send message to agents |
|
|
287
|
+
| `swarmmail_inbox` | Check inbox (max 5, no bodies) |
|
|
288
|
+
| `swarmmail_read_message` | Read specific message body |
|
|
289
|
+
| `swarmmail_reserve` | Reserve files for exclusive editing |
|
|
290
|
+
| `swarmmail_release` | Release file reservations |
|
|
291
|
+
| `swarmmail_ack` | Acknowledge message |
|
|
292
|
+
| `swarmmail_health` | Check database health |
|
|
@@ -15,11 +15,13 @@ tools:
|
|
|
15
15
|
- swarm_progress
|
|
16
16
|
- beads_create_epic
|
|
17
17
|
- beads_query
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
18
|
+
- swarmmail_init
|
|
19
|
+
- swarmmail_send
|
|
20
|
+
- swarmmail_inbox
|
|
21
|
+
- swarmmail_read_message
|
|
22
|
+
- swarmmail_reserve
|
|
23
|
+
- swarmmail_release
|
|
24
|
+
- swarmmail_health
|
|
23
25
|
- semantic-memory_find
|
|
24
26
|
- cass_search
|
|
25
27
|
- pdf-brain_search
|
|
@@ -33,6 +35,16 @@ references:
|
|
|
33
35
|
|
|
34
36
|
Multi-agent orchestration for parallel task execution. The coordinator breaks work into subtasks, spawns worker agents, monitors progress, and aggregates results.
|
|
35
37
|
|
|
38
|
+
## MANDATORY: Swarm Mail
|
|
39
|
+
|
|
40
|
+
**ALL coordination MUST use `swarmmail_*` tools.** This is non-negotiable.
|
|
41
|
+
|
|
42
|
+
Swarm Mail is embedded (no external server needed) and provides:
|
|
43
|
+
|
|
44
|
+
- File reservations to prevent conflicts
|
|
45
|
+
- Message passing between agents
|
|
46
|
+
- Thread-based coordination tied to beads
|
|
47
|
+
|
|
36
48
|
## When to Swarm
|
|
37
49
|
|
|
38
50
|
**DO swarm when:**
|
|
@@ -53,19 +65,29 @@ Multi-agent orchestration for parallel task execution. The coordinator breaks wo
|
|
|
53
65
|
|
|
54
66
|
## Coordinator Workflow
|
|
55
67
|
|
|
56
|
-
### Phase 1:
|
|
68
|
+
### Phase 1: Initialize Swarm Mail (FIRST)
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// ALWAYS initialize first - registers you as coordinator
|
|
72
|
+
await swarmmail_init({
|
|
73
|
+
project_path: "$PWD",
|
|
74
|
+
task_description: "Swarm: <task summary>",
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Phase 2: Knowledge Gathering (MANDATORY)
|
|
57
79
|
|
|
58
80
|
Before decomposing, query ALL knowledge sources:
|
|
59
81
|
|
|
60
82
|
```typescript
|
|
61
83
|
// 1. Past learnings from this project
|
|
62
|
-
|
|
84
|
+
semantic_memory_find({ query: "<task keywords>", limit: 5 });
|
|
63
85
|
|
|
64
86
|
// 2. How similar tasks were solved before
|
|
65
87
|
cass_search({ query: "<task description>", limit: 5 });
|
|
66
88
|
|
|
67
89
|
// 3. Design patterns and prior art
|
|
68
|
-
|
|
90
|
+
pdf_brain_search({ query: "<domain concepts>", limit: 5 });
|
|
69
91
|
|
|
70
92
|
// 4. Available skills to inject into workers
|
|
71
93
|
skills_list();
|
|
@@ -73,7 +95,7 @@ skills_list();
|
|
|
73
95
|
|
|
74
96
|
Synthesize findings into `shared_context` for workers.
|
|
75
97
|
|
|
76
|
-
### Phase
|
|
98
|
+
### Phase 3: Decomposition
|
|
77
99
|
|
|
78
100
|
```typescript
|
|
79
101
|
// Auto-select strategy and generate decomposition prompt
|
|
@@ -97,7 +119,25 @@ await beads_create_epic({
|
|
|
97
119
|
});
|
|
98
120
|
```
|
|
99
121
|
|
|
100
|
-
### Phase
|
|
122
|
+
### Phase 4: Reserve Files (via Swarm Mail)
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
// Reserve files for each subtask BEFORE spawning workers
|
|
126
|
+
await swarmmail_reserve({
|
|
127
|
+
paths: ["src/auth/**"],
|
|
128
|
+
reason: "bd-123: Auth service implementation",
|
|
129
|
+
ttl_seconds: 3600,
|
|
130
|
+
exclusive: true,
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Rules:**
|
|
135
|
+
|
|
136
|
+
- No file overlap between subtasks
|
|
137
|
+
- Coordinator mediates conflicts
|
|
138
|
+
- `swarm_complete` auto-releases
|
|
139
|
+
|
|
140
|
+
### Phase 5: Spawn Workers
|
|
101
141
|
|
|
102
142
|
```typescript
|
|
103
143
|
for (const subtask of subtasks) {
|
|
@@ -118,25 +158,41 @@ for (const subtask of subtasks) {
|
|
|
118
158
|
}
|
|
119
159
|
```
|
|
120
160
|
|
|
121
|
-
### Phase
|
|
161
|
+
### Phase 6: Monitor & Intervene
|
|
122
162
|
|
|
123
163
|
```typescript
|
|
124
164
|
// Check progress
|
|
125
165
|
const status = await swarm_status({ epic_id, project_key });
|
|
126
166
|
|
|
127
|
-
// Check for messages
|
|
128
|
-
const inbox = await
|
|
167
|
+
// Check for messages from workers
|
|
168
|
+
const inbox = await swarmmail_inbox({ limit: 5 });
|
|
169
|
+
|
|
170
|
+
// Read specific message if needed
|
|
171
|
+
const message = await swarmmail_read_message({ message_id: N });
|
|
129
172
|
|
|
130
173
|
// Intervene if needed (see Intervention Patterns)
|
|
131
174
|
```
|
|
132
175
|
|
|
133
|
-
### Phase
|
|
176
|
+
### Phase 7: Aggregate & Complete
|
|
134
177
|
|
|
135
178
|
- Verify all subtasks completed
|
|
136
179
|
- Run final verification (typecheck, tests)
|
|
137
180
|
- Close epic with summary
|
|
181
|
+
- Release any remaining reservations
|
|
138
182
|
- Record outcomes for learning
|
|
139
183
|
|
|
184
|
+
```typescript
|
|
185
|
+
await swarm_complete({
|
|
186
|
+
project_key: "$PWD",
|
|
187
|
+
agent_name: "coordinator",
|
|
188
|
+
bead_id: epic_id,
|
|
189
|
+
summary: "All subtasks complete",
|
|
190
|
+
files_touched: [...],
|
|
191
|
+
});
|
|
192
|
+
await swarmmail_release(); // Release any remaining reservations
|
|
193
|
+
await beads_sync();
|
|
194
|
+
```
|
|
195
|
+
|
|
140
196
|
## Decomposition Strategies
|
|
141
197
|
|
|
142
198
|
Four strategies, auto-selected by task keywords:
|
|
@@ -150,37 +206,13 @@ Four strategies, auto-selected by task keywords:
|
|
|
150
206
|
|
|
151
207
|
See `references/strategies.md` for full details.
|
|
152
208
|
|
|
153
|
-
## File Reservation Protocol
|
|
154
|
-
|
|
155
|
-
Workers MUST reserve files before editing:
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
// Reserve (exclusive by default)
|
|
159
|
-
await agentmail_reserve({
|
|
160
|
-
paths: ["src/auth/**"],
|
|
161
|
-
reason: "bd-123: Auth service implementation",
|
|
162
|
-
ttl_seconds: 3600,
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// Work...
|
|
166
|
-
|
|
167
|
-
// Release (or let swarm_complete handle it)
|
|
168
|
-
await agentmail_release({ paths: ["src/auth/**"] });
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
**Rules:**
|
|
172
|
-
|
|
173
|
-
- No file overlap between subtasks
|
|
174
|
-
- Coordinator mediates conflicts
|
|
175
|
-
- `swarm_complete` auto-releases
|
|
176
|
-
|
|
177
209
|
## Communication Protocol
|
|
178
210
|
|
|
179
|
-
Workers communicate via
|
|
211
|
+
Workers communicate via Swarm Mail with epic ID as thread:
|
|
180
212
|
|
|
181
213
|
```typescript
|
|
182
214
|
// Progress update
|
|
183
|
-
|
|
215
|
+
swarmmail_send({
|
|
184
216
|
to: ["coordinator"],
|
|
185
217
|
subject: "Auth API complete",
|
|
186
218
|
body: "Endpoints ready at /api/auth/*",
|
|
@@ -188,7 +220,7 @@ agentmail_send({
|
|
|
188
220
|
});
|
|
189
221
|
|
|
190
222
|
// Blocker
|
|
191
|
-
|
|
223
|
+
swarmmail_send({
|
|
192
224
|
to: ["coordinator"],
|
|
193
225
|
subject: "BLOCKED: Need DB schema",
|
|
194
226
|
body: "Can't proceed without users table",
|
|
@@ -265,25 +297,51 @@ One blocker affects multiple subtasks.
|
|
|
265
297
|
- Thread: {epic_id}
|
|
266
298
|
```
|
|
267
299
|
|
|
268
|
-
## Quick Reference
|
|
300
|
+
## Swarm Mail Quick Reference
|
|
301
|
+
|
|
302
|
+
| Tool | Purpose |
|
|
303
|
+
| ------------------------ | ----------------------------------- |
|
|
304
|
+
| `swarmmail_init` | Initialize session (REQUIRED FIRST) |
|
|
305
|
+
| `swarmmail_send` | Send message to agents |
|
|
306
|
+
| `swarmmail_inbox` | Check inbox (max 5, no bodies) |
|
|
307
|
+
| `swarmmail_read_message` | Read specific message body |
|
|
308
|
+
| `swarmmail_reserve` | Reserve files for exclusive editing |
|
|
309
|
+
| `swarmmail_release` | Release file reservations |
|
|
310
|
+
| `swarmmail_ack` | Acknowledge message |
|
|
311
|
+
| `swarmmail_health` | Check database health |
|
|
312
|
+
|
|
313
|
+
## Full Swarm Flow
|
|
269
314
|
|
|
270
315
|
```typescript
|
|
271
|
-
//
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
//
|
|
286
|
-
|
|
316
|
+
// 1. Initialize Swarm Mail FIRST
|
|
317
|
+
swarmmail_init({ project_path: "$PWD", task_description: "..." });
|
|
318
|
+
|
|
319
|
+
// 2. Gather knowledge
|
|
320
|
+
semantic_memory_find({ query });
|
|
321
|
+
cass_search({ query });
|
|
322
|
+
pdf_brain_search({ query });
|
|
323
|
+
skills_list();
|
|
324
|
+
|
|
325
|
+
// 3. Decompose
|
|
326
|
+
swarm_plan_prompt({ task });
|
|
327
|
+
swarm_validate_decomposition();
|
|
328
|
+
beads_create_epic();
|
|
329
|
+
|
|
330
|
+
// 4. Reserve files
|
|
331
|
+
swarmmail_reserve({ paths, reason, ttl_seconds });
|
|
332
|
+
|
|
333
|
+
// 5. Spawn workers (loop)
|
|
334
|
+
swarm_spawn_subtask();
|
|
335
|
+
|
|
336
|
+
// 6. Monitor
|
|
337
|
+
swarm_status();
|
|
338
|
+
swarmmail_inbox();
|
|
339
|
+
swarmmail_read_message({ message_id });
|
|
340
|
+
|
|
341
|
+
// 7. Complete
|
|
342
|
+
swarm_complete();
|
|
343
|
+
swarmmail_release();
|
|
344
|
+
beads_sync();
|
|
287
345
|
```
|
|
288
346
|
|
|
289
347
|
See `references/coordinator-patterns.md` for detailed patterns.
|