opencode-swarm-plugin 0.12.2 → 0.12.6
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 +215 -0
- package/README.md +111 -106
- package/bin/swarm.ts +13 -14
- package/dist/index.js +100 -46
- package/dist/plugin.js +68 -33
- package/examples/commands/swarm.md +51 -210
- package/package.json +1 -1
- package/src/agent-mail.ts +26 -11
- package/src/beads.ts +75 -20
- package/src/rate-limiter.ts +12 -6
- package/src/schemas/bead.ts +4 -4
- package/src/schemas/evaluation.ts +2 -2
- package/src/schemas/task.ts +3 -3
- package/src/storage.ts +37 -15
- package/src/swarm.ts +13 -0
- package/examples/agents/swarm-planner.md +0 -138
package/README.md
CHANGED
|
@@ -108,12 +108,11 @@ The `/swarm` command is defined in `~/.config/opencode/command/swarm.md`:
|
|
|
108
108
|
description: Decompose task into parallel subtasks and coordinate agents
|
|
109
109
|
---
|
|
110
110
|
|
|
111
|
-
You are a swarm coordinator.
|
|
112
|
-
and unleash parallel agents.
|
|
111
|
+
You are a swarm coordinator. Decompose the task into beads and spawn parallel agents.
|
|
113
112
|
|
|
114
|
-
##
|
|
113
|
+
## Task
|
|
115
114
|
|
|
116
|
-
|
|
115
|
+
$ARGUMENTS
|
|
117
116
|
|
|
118
117
|
## Workflow
|
|
119
118
|
|
|
@@ -136,125 +135,131 @@ and unleash parallel agents.
|
|
|
136
135
|
Begin decomposition now.
|
|
137
136
|
```
|
|
138
137
|
|
|
139
|
-
|
|
138
|
+
> **Note**: The `$ARGUMENTS` placeholder captures everything you type after `/swarm`. This is how your task description gets passed to the agent.
|
|
139
|
+
|
|
140
|
+
### Agents
|
|
141
|
+
|
|
142
|
+
The setup wizard creates two agents with your chosen models:
|
|
140
143
|
|
|
141
|
-
|
|
144
|
+
**@swarm-planner** (`~/.config/opencode/agent/swarm-planner.md`) - Coordinator that decomposes tasks:
|
|
142
145
|
|
|
143
|
-
|
|
146
|
+
```yaml
|
|
144
147
|
---
|
|
145
148
|
name: swarm-planner
|
|
146
149
|
description: Strategic task decomposition for swarm coordination
|
|
147
|
-
model: claude-sonnet-4-5
|
|
150
|
+
model: anthropic/claude-sonnet-4-5 # Your chosen coordinator model
|
|
148
151
|
---
|
|
152
|
+
```
|
|
149
153
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
## Workflow
|
|
154
|
+
**@swarm-worker** (`~/.config/opencode/agent/swarm-worker.md`) - Fast executor for subtasks:
|
|
153
155
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
```json
|
|
162
|
-
{
|
|
163
|
-
"epic": { "title": "...", "description": "..." },
|
|
164
|
-
"subtasks": [
|
|
165
|
-
{
|
|
166
|
-
"title": "...",
|
|
167
|
-
"description": "...",
|
|
168
|
-
"files": ["src/..."],
|
|
169
|
-
"dependencies": [],
|
|
170
|
-
"estimated_complexity": 2
|
|
171
|
-
}
|
|
172
|
-
]
|
|
173
|
-
}
|
|
156
|
+
```yaml
|
|
157
|
+
---
|
|
158
|
+
name: swarm-worker
|
|
159
|
+
description: Executes subtasks in a swarm - fast, focused, cost-effective
|
|
160
|
+
model: anthropic/claude-haiku-4-5 # Your chosen worker model
|
|
161
|
+
---
|
|
174
162
|
```
|
|
175
|
-
````
|
|
176
|
-
|
|
177
|
-
## Rules
|
|
178
163
|
|
|
179
|
-
|
|
180
|
-
- No file overlap between subtasks
|
|
181
|
-
- Include tests with the code they test
|
|
182
|
-
- Order by dependency (if B needs A, A comes first)
|
|
164
|
+
### Decomposition Rules
|
|
183
165
|
|
|
184
|
-
|
|
166
|
+
- **2-7 subtasks** - Too few = not parallel, too many = coordination overhead
|
|
167
|
+
- **No file overlap** - Each file appears in exactly one subtask
|
|
168
|
+
- **Include tests** - Put test files with the code they test
|
|
169
|
+
- **Order by dependency** - If B needs A's output, A comes first (lower index)
|
|
185
170
|
|
|
186
171
|
Edit these files to customize behavior. Run `swarm setup` to regenerate defaults.
|
|
187
172
|
|
|
188
173
|
## Dependencies
|
|
189
174
|
|
|
190
|
-
| Dependency
|
|
191
|
-
|
|
192
|
-
| [OpenCode](https://opencode.ai)
|
|
193
|
-
| [Beads](https://github.com/steveyegge/beads)
|
|
194
|
-
| [Go](https://go.dev)
|
|
195
|
-
| [Agent Mail](https://github.com/
|
|
196
|
-
| [CASS](https://github.com/Dicklesworthstone/
|
|
197
|
-
| [UBS](https://github.com/
|
|
198
|
-
| [semantic-memory](https://github.com/joelhooks/semantic-memory)
|
|
199
|
-
| [Redis](https://redis.io)
|
|
175
|
+
| Dependency | Purpose | Required |
|
|
176
|
+
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ | -------- |
|
|
177
|
+
| [OpenCode](https://opencode.ai) | Plugin host | Yes |
|
|
178
|
+
| [Beads](https://github.com/steveyegge/beads) | Git-backed issue tracking | Yes |
|
|
179
|
+
| [Go](https://go.dev) | Required for Agent Mail | No |
|
|
180
|
+
| [MCP Agent Mail](https://github.com/Dicklesworthstone/mcp_agent_mail) | Multi-agent coordination, file reservations | No |
|
|
181
|
+
| [CASS (Coding Agent Session Search)](https://github.com/Dicklesworthstone/coding_agent_session_search) | Historical context from past sessions | No |
|
|
182
|
+
| [UBS (Ultimate Bug Scanner)](https://github.com/Dicklesworthstone/ultimate_bug_scanner) | Pre-completion bug scanning using AI-powered static analysis | No |
|
|
183
|
+
| [semantic-memory](https://github.com/joelhooks/semantic-memory) | Learning persistence | No |
|
|
184
|
+
| [Redis](https://redis.io) | Rate limiting (SQLite fallback available) | No |
|
|
200
185
|
|
|
201
186
|
All dependencies are checked and can be installed via `swarm setup`.
|
|
202
187
|
|
|
188
|
+
### Installing Optional Dependencies
|
|
189
|
+
|
|
190
|
+
**UBS (Ultimate Bug Scanner)** - Scans code for bugs before task completion:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/ultimate_bug_scanner/master/install.sh" | bash
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**CASS (Coding Agent Session Search)** - Indexes and searches AI coding agent history:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
curl -fsSL https://raw.githubusercontent.com/Dicklesworthstone/coding_agent_session_search/main/install.sh | bash -s -- --easy-mode
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**MCP Agent Mail** - Multi-agent coordination and file reservations:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/mcp_agent_mail/main/scripts/install.sh" | bash -s -- --yes
|
|
206
|
+
```
|
|
207
|
+
|
|
203
208
|
## Tools Reference
|
|
204
209
|
|
|
205
210
|
### Swarm
|
|
206
211
|
|
|
207
|
-
| Tool
|
|
208
|
-
|
|
209
|
-
| `swarm_init`
|
|
210
|
-
| `swarm_select_strategy`
|
|
211
|
-
| `swarm_plan_prompt`
|
|
212
|
-
| `swarm_decompose`
|
|
213
|
-
| `swarm_validate_decomposition` | Validate response, detect file conflicts
|
|
214
|
-
| `swarm_spawn_subtask`
|
|
215
|
-
| `swarm_status`
|
|
216
|
-
| `swarm_progress`
|
|
217
|
-
| `swarm_complete`
|
|
218
|
-
| `swarm_record_outcome`
|
|
212
|
+
| Tool | Description |
|
|
213
|
+
| ------------------------------ | ------------------------------------------------------------------------- |
|
|
214
|
+
| `swarm_init` | Initialize swarm session |
|
|
215
|
+
| `swarm_select_strategy` | Analyze task, recommend decomposition strategy (file/feature/risk-based) |
|
|
216
|
+
| `swarm_plan_prompt` | Generate strategy-specific planning prompt with CASS history |
|
|
217
|
+
| `swarm_decompose` | Generate decomposition prompt |
|
|
218
|
+
| `swarm_validate_decomposition` | Validate response, detect file conflicts |
|
|
219
|
+
| `swarm_spawn_subtask` | Generate worker agent prompt with Agent Mail/beads instructions |
|
|
220
|
+
| `swarm_status` | Get swarm progress by epic ID |
|
|
221
|
+
| `swarm_progress` | Report subtask progress to coordinator |
|
|
222
|
+
| `swarm_complete` | Complete subtask - runs UBS (Ultimate Bug Scanner), releases reservations |
|
|
223
|
+
| `swarm_record_outcome` | Record outcome for learning (duration, errors, retries) |
|
|
219
224
|
|
|
220
225
|
### Beads
|
|
221
226
|
|
|
222
|
-
| Tool
|
|
223
|
-
|
|
224
|
-
| `beads_create`
|
|
225
|
-
| `beads_create_epic` | Create epic + subtasks atomically
|
|
226
|
-
| `beads_query`
|
|
227
|
-
| `beads_update`
|
|
228
|
-
| `beads_close`
|
|
229
|
-
| `beads_start`
|
|
230
|
-
| `beads_ready`
|
|
231
|
-
| `beads_sync`
|
|
232
|
-
| `beads_link_thread` | Link bead to Agent Mail thread
|
|
227
|
+
| Tool | Description |
|
|
228
|
+
| ------------------- | ---------------------------------------------- |
|
|
229
|
+
| `beads_create` | Create bead with type-safe validation |
|
|
230
|
+
| `beads_create_epic` | Create epic + subtasks atomically |
|
|
231
|
+
| `beads_query` | Query beads with filters (status, type, ready) |
|
|
232
|
+
| `beads_update` | Update status/description/priority |
|
|
233
|
+
| `beads_close` | Close bead with reason |
|
|
234
|
+
| `beads_start` | Mark bead as in-progress |
|
|
235
|
+
| `beads_ready` | Get next unblocked bead |
|
|
236
|
+
| `beads_sync` | Sync to git and push |
|
|
237
|
+
| `beads_link_thread` | Link bead to Agent Mail thread |
|
|
233
238
|
|
|
234
239
|
### Agent Mail
|
|
235
240
|
|
|
236
|
-
| Tool
|
|
237
|
-
|
|
238
|
-
| `agentmail_init`
|
|
239
|
-
| `agentmail_send`
|
|
240
|
-
| `agentmail_inbox`
|
|
241
|
-
| `agentmail_read_message`
|
|
241
|
+
| Tool | Description |
|
|
242
|
+
| ---------------------------- | ---------------------------------------------- |
|
|
243
|
+
| `agentmail_init` | Initialize session, register agent |
|
|
244
|
+
| `agentmail_send` | Send message to agents |
|
|
245
|
+
| `agentmail_inbox` | Fetch inbox (max 5, no bodies - context safe) |
|
|
246
|
+
| `agentmail_read_message` | Fetch single message body by ID |
|
|
242
247
|
| `agentmail_summarize_thread` | Summarize thread (preferred over fetching all) |
|
|
243
|
-
| `agentmail_reserve`
|
|
244
|
-
| `agentmail_release`
|
|
245
|
-
| `agentmail_ack`
|
|
246
|
-
| `agentmail_search`
|
|
247
|
-
| `agentmail_health`
|
|
248
|
+
| `agentmail_reserve` | Reserve file paths for exclusive editing |
|
|
249
|
+
| `agentmail_release` | Release file reservations |
|
|
250
|
+
| `agentmail_ack` | Acknowledge message |
|
|
251
|
+
| `agentmail_search` | Search messages by keyword |
|
|
252
|
+
| `agentmail_health` | Check if Agent Mail server is running |
|
|
248
253
|
|
|
249
254
|
### Structured Output
|
|
250
255
|
|
|
251
|
-
| Tool
|
|
252
|
-
|
|
253
|
-
| `structured_extract_json`
|
|
254
|
-
| `structured_validate`
|
|
255
|
-
| `structured_parse_evaluation`
|
|
256
|
-
| `structured_parse_decomposition` | Parse task decomposition response
|
|
257
|
-
| `structured_parse_bead_tree`
|
|
256
|
+
| Tool | Description |
|
|
257
|
+
| -------------------------------- | ----------------------------------------------------- |
|
|
258
|
+
| `structured_extract_json` | Extract JSON from markdown/text (multiple strategies) |
|
|
259
|
+
| `structured_validate` | Validate response against schema |
|
|
260
|
+
| `structured_parse_evaluation` | Parse self-evaluation response |
|
|
261
|
+
| `structured_parse_decomposition` | Parse task decomposition response |
|
|
262
|
+
| `structured_parse_bead_tree` | Parse bead tree for epic creation |
|
|
258
263
|
|
|
259
264
|
## Decomposition Strategies
|
|
260
265
|
|
|
@@ -292,32 +297,32 @@ Best for: bug fixes, security issues
|
|
|
292
297
|
|
|
293
298
|
The plugin learns from outcomes:
|
|
294
299
|
|
|
295
|
-
| Mechanism
|
|
296
|
-
|
|
297
|
-
| Confidence decay
|
|
298
|
-
| Implicit feedback | Fast + success = helpful signal, slow + errors = harmful
|
|
299
|
-
| Pattern maturity
|
|
300
|
-
| Anti-patterns
|
|
300
|
+
| Mechanism | How It Works |
|
|
301
|
+
| ----------------- | ----------------------------------------------------------- |
|
|
302
|
+
| Confidence decay | Criteria weights fade unless revalidated (90-day half-life) |
|
|
303
|
+
| Implicit feedback | Fast + success = helpful signal, slow + errors = harmful |
|
|
304
|
+
| Pattern maturity | candidate → established → proven (or deprecated) |
|
|
305
|
+
| Anti-patterns | Patterns with >60% failure rate auto-invert |
|
|
301
306
|
|
|
302
307
|
## Context Preservation
|
|
303
308
|
|
|
304
309
|
Hard limits to prevent context exhaustion:
|
|
305
310
|
|
|
306
|
-
| Constraint
|
|
307
|
-
|
|
308
|
-
| Inbox limit
|
|
309
|
-
| Bodies excluded
|
|
310
|
-
| Summarize preferred | Yes
|
|
311
|
+
| Constraint | Default | Reason |
|
|
312
|
+
| ------------------- | ---------- | ------------------------------ |
|
|
313
|
+
| Inbox limit | 5 messages | Prevents token burn |
|
|
314
|
+
| Bodies excluded | Always | Fetch individually when needed |
|
|
315
|
+
| Summarize preferred | Yes | Key points, not raw dump |
|
|
311
316
|
|
|
312
317
|
## Rate Limiting
|
|
313
318
|
|
|
314
319
|
Client-side limits (Redis primary, SQLite fallback):
|
|
315
320
|
|
|
316
321
|
| Endpoint | Per Minute | Per Hour |
|
|
317
|
-
|
|
318
|
-
| send
|
|
319
|
-
| reserve
|
|
320
|
-
| inbox
|
|
322
|
+
| -------- | ---------- | -------- |
|
|
323
|
+
| send | 20 | 200 |
|
|
324
|
+
| reserve | 10 | 100 |
|
|
325
|
+
| inbox | 60 | 600 |
|
|
321
326
|
|
|
322
327
|
Configure via `OPENCODE_RATE_LIMIT_{ENDPOINT}_PER_MIN` env vars.
|
|
323
328
|
|
|
@@ -328,7 +333,7 @@ bun install
|
|
|
328
333
|
bun run typecheck
|
|
329
334
|
bun test
|
|
330
335
|
bun run build
|
|
331
|
-
|
|
336
|
+
```
|
|
332
337
|
|
|
333
338
|
## License
|
|
334
339
|
|
package/bin/swarm.ts
CHANGED
|
@@ -346,7 +346,7 @@ const DEPENDENCIES: Dependency[] = [
|
|
|
346
346
|
description: "Required for Agent Mail",
|
|
347
347
|
},
|
|
348
348
|
{
|
|
349
|
-
name: "Agent Mail",
|
|
349
|
+
name: "MCP Agent Mail",
|
|
350
350
|
command: "curl",
|
|
351
351
|
checkArgs: [
|
|
352
352
|
"-s",
|
|
@@ -363,25 +363,26 @@ const DEPENDENCIES: Dependency[] = [
|
|
|
363
363
|
required: false,
|
|
364
364
|
install: "https://github.com/Dicklesworthstone/mcp_agent_mail",
|
|
365
365
|
installType: "manual",
|
|
366
|
-
description:
|
|
366
|
+
description:
|
|
367
|
+
"Multi-agent coordination & file reservations (like Gmail for coding agents)",
|
|
367
368
|
},
|
|
368
369
|
{
|
|
369
|
-
name: "CASS",
|
|
370
|
+
name: "CASS (Coding Agent Session Search)",
|
|
370
371
|
command: "cass",
|
|
371
372
|
checkArgs: ["--help"],
|
|
372
373
|
required: false,
|
|
373
|
-
install: "https://github.com/Dicklesworthstone/
|
|
374
|
+
install: "https://github.com/Dicklesworthstone/coding_agent_session_search",
|
|
374
375
|
installType: "manual",
|
|
375
|
-
description: "
|
|
376
|
+
description: "Indexes and searches AI coding agent history for context",
|
|
376
377
|
},
|
|
377
378
|
{
|
|
378
|
-
name: "UBS",
|
|
379
|
+
name: "UBS (Ultimate Bug Scanner)",
|
|
379
380
|
command: "ubs",
|
|
380
381
|
checkArgs: ["--help"],
|
|
381
382
|
required: false,
|
|
382
|
-
install: "https://github.com/
|
|
383
|
+
install: "https://github.com/Dicklesworthstone/ultimate_bug_scanner",
|
|
383
384
|
installType: "manual",
|
|
384
|
-
description: "
|
|
385
|
+
description: "AI-powered static analysis for pre-completion bug scanning",
|
|
385
386
|
},
|
|
386
387
|
{
|
|
387
388
|
name: "semantic-memory",
|
|
@@ -488,11 +489,11 @@ const SWARM_COMMAND = `---
|
|
|
488
489
|
description: Decompose task into parallel subtasks and coordinate agents
|
|
489
490
|
---
|
|
490
491
|
|
|
491
|
-
You are a swarm coordinator.
|
|
492
|
+
You are a swarm coordinator. Decompose the task into beads and spawn parallel agents.
|
|
492
493
|
|
|
493
|
-
##
|
|
494
|
+
## Task
|
|
494
495
|
|
|
495
|
-
|
|
496
|
+
$ARGUMENTS
|
|
496
497
|
|
|
497
498
|
## Workflow
|
|
498
499
|
|
|
@@ -500,14 +501,12 @@ You are a swarm coordinator. Take a complex task, break it into beads, and unlea
|
|
|
500
501
|
2. **Decompose**: Use \`swarm_select_strategy\` then \`swarm_plan_prompt\` to break down the task
|
|
501
502
|
3. **Create beads**: \`beads_create_epic\` with subtasks and file assignments
|
|
502
503
|
4. **Reserve files**: \`agentmail_reserve\` for each subtask's files
|
|
503
|
-
5. **Spawn agents**: Use Task tool with \`swarm_spawn_subtask\` prompts
|
|
504
|
+
5. **Spawn agents**: Use Task tool with \`swarm_spawn_subtask\` prompts
|
|
504
505
|
6. **Monitor**: Check \`agentmail_inbox\` for progress, use \`agentmail_summarize_thread\` for overview
|
|
505
506
|
7. **Complete**: \`swarm_complete\` when done, then \`beads_sync\` to push
|
|
506
507
|
|
|
507
508
|
## Strategy Selection
|
|
508
509
|
|
|
509
|
-
The plugin auto-selects decomposition strategy based on task keywords:
|
|
510
|
-
|
|
511
510
|
| Strategy | Best For | Keywords |
|
|
512
511
|
| ------------- | ----------------------- | -------------------------------------- |
|
|
513
512
|
| file-based | Refactoring, migrations | refactor, migrate, rename, update all |
|