opencode-swarm-plugin 0.12.4 → 0.12.7
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 +224 -0
- package/README.md +94 -106
- package/bin/swarm.ts +6 -7
- package/dist/index.js +409 -71
- package/dist/plugin.js +376 -58
- package/examples/commands/swarm.md +51 -216
- package/package.json +1 -1
- package/src/agent-mail.ts +183 -37
- package/src/beads.ts +75 -20
- package/src/learning.ts +277 -0
- 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 +189 -1
- 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,83 +135,72 @@ 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
|
|
140
141
|
|
|
141
|
-
The
|
|
142
|
+
The setup wizard creates two agents with your chosen models:
|
|
142
143
|
|
|
143
|
-
|
|
144
|
+
**@swarm-planner** (`~/.config/opencode/agent/swarm-planner.md`) - Coordinator that decomposes tasks:
|
|
145
|
+
|
|
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
|
-
| [MCP Agent Mail](https://github.com/Dicklesworthstone/mcp_agent_mail)
|
|
196
|
-
| [CASS (Coding Agent Session Search)](https://github.com/Dicklesworthstone/coding_agent_session_search) | Historical context from past sessions
|
|
197
|
-
| [UBS (Ultimate Bug Scanner)](https://github.com/Dicklesworthstone/ultimate_bug_scanner)
|
|
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
|
|
|
203
188
|
### Installing Optional Dependencies
|
|
204
189
|
|
|
205
190
|
**UBS (Ultimate Bug Scanner)** - Scans code for bugs before task completion:
|
|
191
|
+
|
|
206
192
|
```bash
|
|
207
193
|
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/ultimate_bug_scanner/master/install.sh" | bash
|
|
208
194
|
```
|
|
209
195
|
|
|
210
196
|
**CASS (Coding Agent Session Search)** - Indexes and searches AI coding agent history:
|
|
197
|
+
|
|
211
198
|
```bash
|
|
212
199
|
curl -fsSL https://raw.githubusercontent.com/Dicklesworthstone/coding_agent_session_search/main/install.sh | bash -s -- --easy-mode
|
|
213
200
|
```
|
|
214
201
|
|
|
215
202
|
**MCP Agent Mail** - Multi-agent coordination and file reservations:
|
|
203
|
+
|
|
216
204
|
```bash
|
|
217
205
|
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/mcp_agent_mail/main/scripts/install.sh" | bash -s -- --yes
|
|
218
206
|
```
|
|
@@ -221,57 +209,57 @@ curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/mcp_agent_mail/m
|
|
|
221
209
|
|
|
222
210
|
### Swarm
|
|
223
211
|
|
|
224
|
-
| Tool
|
|
225
|
-
|
|
226
|
-
| `swarm_init`
|
|
227
|
-
| `swarm_select_strategy`
|
|
228
|
-
| `swarm_plan_prompt`
|
|
229
|
-
| `swarm_decompose`
|
|
230
|
-
| `swarm_validate_decomposition` | Validate response, detect file conflicts
|
|
231
|
-
| `swarm_spawn_subtask`
|
|
232
|
-
| `swarm_status`
|
|
233
|
-
| `swarm_progress`
|
|
234
|
-
| `swarm_complete`
|
|
235
|
-
| `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) |
|
|
236
224
|
|
|
237
225
|
### Beads
|
|
238
226
|
|
|
239
|
-
| Tool
|
|
240
|
-
|
|
241
|
-
| `beads_create`
|
|
242
|
-
| `beads_create_epic` | Create epic + subtasks atomically
|
|
243
|
-
| `beads_query`
|
|
244
|
-
| `beads_update`
|
|
245
|
-
| `beads_close`
|
|
246
|
-
| `beads_start`
|
|
247
|
-
| `beads_ready`
|
|
248
|
-
| `beads_sync`
|
|
249
|
-
| `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 |
|
|
250
238
|
|
|
251
239
|
### Agent Mail
|
|
252
240
|
|
|
253
|
-
| Tool
|
|
254
|
-
|
|
255
|
-
| `agentmail_init`
|
|
256
|
-
| `agentmail_send`
|
|
257
|
-
| `agentmail_inbox`
|
|
258
|
-
| `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 |
|
|
259
247
|
| `agentmail_summarize_thread` | Summarize thread (preferred over fetching all) |
|
|
260
|
-
| `agentmail_reserve`
|
|
261
|
-
| `agentmail_release`
|
|
262
|
-
| `agentmail_ack`
|
|
263
|
-
| `agentmail_search`
|
|
264
|
-
| `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 |
|
|
265
253
|
|
|
266
254
|
### Structured Output
|
|
267
255
|
|
|
268
|
-
| Tool
|
|
269
|
-
|
|
270
|
-
| `structured_extract_json`
|
|
271
|
-
| `structured_validate`
|
|
272
|
-
| `structured_parse_evaluation`
|
|
273
|
-
| `structured_parse_decomposition` | Parse task decomposition response
|
|
274
|
-
| `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 |
|
|
275
263
|
|
|
276
264
|
## Decomposition Strategies
|
|
277
265
|
|
|
@@ -309,32 +297,32 @@ Best for: bug fixes, security issues
|
|
|
309
297
|
|
|
310
298
|
The plugin learns from outcomes:
|
|
311
299
|
|
|
312
|
-
| Mechanism
|
|
313
|
-
|
|
314
|
-
| Confidence decay
|
|
315
|
-
| Implicit feedback | Fast + success = helpful signal, slow + errors = harmful
|
|
316
|
-
| Pattern maturity
|
|
317
|
-
| 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 |
|
|
318
306
|
|
|
319
307
|
## Context Preservation
|
|
320
308
|
|
|
321
309
|
Hard limits to prevent context exhaustion:
|
|
322
310
|
|
|
323
|
-
| Constraint
|
|
324
|
-
|
|
325
|
-
| Inbox limit
|
|
326
|
-
| Bodies excluded
|
|
327
|
-
| 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 |
|
|
328
316
|
|
|
329
317
|
## Rate Limiting
|
|
330
318
|
|
|
331
319
|
Client-side limits (Redis primary, SQLite fallback):
|
|
332
320
|
|
|
333
321
|
| Endpoint | Per Minute | Per Hour |
|
|
334
|
-
|
|
335
|
-
| send
|
|
336
|
-
| reserve
|
|
337
|
-
| inbox
|
|
322
|
+
| -------- | ---------- | -------- |
|
|
323
|
+
| send | 20 | 200 |
|
|
324
|
+
| reserve | 10 | 100 |
|
|
325
|
+
| inbox | 60 | 600 |
|
|
338
326
|
|
|
339
327
|
Configure via `OPENCODE_RATE_LIMIT_{ENDPOINT}_PER_MIN` env vars.
|
|
340
328
|
|
|
@@ -345,7 +333,7 @@ bun install
|
|
|
345
333
|
bun run typecheck
|
|
346
334
|
bun test
|
|
347
335
|
bun run build
|
|
348
|
-
|
|
336
|
+
```
|
|
349
337
|
|
|
350
338
|
## License
|
|
351
339
|
|
package/bin/swarm.ts
CHANGED
|
@@ -363,7 +363,8 @@ 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
370
|
name: "CASS (Coding Agent Session Search)",
|
|
@@ -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 |
|