opencode-swarm-plugin 0.20.0 → 0.22.0
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 +213 -0
- package/INTEGRATION_EXAMPLE.md +66 -0
- package/README.md +352 -522
- package/dist/index.js +2046 -984
- package/dist/plugin.js +2051 -1017
- package/docs/analysis/subagent-coordination-patterns.md +2 -0
- package/docs/semantic-memory-cli-syntax.md +123 -0
- package/docs/swarm-mail-architecture.md +1147 -0
- package/evals/README.md +116 -0
- package/evals/evalite.config.ts +15 -0
- package/evals/example.eval.ts +32 -0
- package/evals/fixtures/decomposition-cases.ts +105 -0
- package/evals/lib/data-loader.test.ts +288 -0
- package/evals/lib/data-loader.ts +111 -0
- package/evals/lib/llm.ts +115 -0
- package/evals/scorers/index.ts +200 -0
- package/evals/scorers/outcome-scorers.test.ts +27 -0
- package/evals/scorers/outcome-scorers.ts +349 -0
- package/evals/swarm-decomposition.eval.ts +112 -0
- package/package.json +8 -1
- package/scripts/cleanup-test-memories.ts +346 -0
- package/src/beads.ts +49 -0
- package/src/eval-capture.ts +487 -0
- package/src/index.ts +45 -3
- package/src/learning.integration.test.ts +19 -4
- package/src/output-guardrails.test.ts +438 -0
- package/src/output-guardrails.ts +381 -0
- package/src/schemas/index.ts +18 -0
- package/src/schemas/swarm-context.ts +115 -0
- package/src/storage.ts +117 -5
- package/src/streams/events.test.ts +296 -0
- package/src/streams/events.ts +93 -0
- package/src/streams/migrations.test.ts +24 -20
- package/src/streams/migrations.ts +51 -0
- package/src/streams/projections.ts +187 -0
- package/src/streams/store.ts +275 -0
- package/src/swarm-orchestrate.ts +771 -189
- package/src/swarm-prompts.ts +84 -12
- package/src/swarm.integration.test.ts +124 -0
- package/vitest.integration.config.ts +6 -0
- package/vitest.integration.setup.ts +48 -0
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# opencode-swarm-plugin
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/opencode-swarm-plugin)
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
4
|
|
|
6
5
|
```
|
|
7
6
|
███████╗██╗ ██╗ █████╗ ██████╗ ███╗ ███╗
|
|
@@ -13,636 +12,467 @@
|
|
|
13
12
|
|
|
14
13
|
\ ` - ' /
|
|
15
14
|
- .(o o). -
|
|
16
|
-
( >.< )
|
|
17
|
-
/| |\
|
|
18
|
-
(_| |_)
|
|
19
|
-
bzzzz...
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
##
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
│
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
│
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
15
|
+
( >.< ) Break big tasks into small ones.
|
|
16
|
+
/| |\ Spawn agents to work in parallel.
|
|
17
|
+
(_| |_) Learn from what works.
|
|
18
|
+
bzzzz...
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## The Problem
|
|
22
|
+
|
|
23
|
+
You're working with an AI coding agent. You ask it to "add OAuth authentication." It starts writing code. Five minutes later, you realize it's going down the wrong path. Or it's touching files it shouldn't. Or it's making changes that conflict with what you just did in another session.
|
|
24
|
+
|
|
25
|
+
**The fundamental issue:** AI agents are single-threaded, context-limited, and have no memory of what worked before.
|
|
26
|
+
|
|
27
|
+
## The Solution
|
|
28
|
+
|
|
29
|
+
What if the agent could:
|
|
30
|
+
|
|
31
|
+
- **Break the task into pieces** that can be worked on simultaneously
|
|
32
|
+
- **Spawn parallel workers** that don't step on each other
|
|
33
|
+
- **Remember what worked** and avoid patterns that failed
|
|
34
|
+
- **Survive context compaction** without losing progress
|
|
35
|
+
|
|
36
|
+
That's what Swarm does.
|
|
37
|
+
|
|
38
|
+
## How It Works
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
"Add OAuth"
|
|
42
|
+
│
|
|
43
|
+
▼
|
|
44
|
+
┌────────────────────────┐
|
|
45
|
+
│ COORDINATOR │
|
|
46
|
+
│ │
|
|
47
|
+
│ 1. Query CASS: │
|
|
48
|
+
│ "How did we solve │
|
|
49
|
+
│ this before?" │
|
|
50
|
+
│ │
|
|
51
|
+
│ 2. Pick strategy: │
|
|
52
|
+
│ file-based? │
|
|
53
|
+
│ feature-based? │
|
|
54
|
+
│ risk-based? │
|
|
55
|
+
│ │
|
|
56
|
+
│ 3. Break into pieces │
|
|
57
|
+
└────────────────────────┘
|
|
58
|
+
│
|
|
59
|
+
┌─────────────────────┼─────────────────────┐
|
|
60
|
+
▼ ▼ ▼
|
|
61
|
+
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
62
|
+
│ Worker A │ │ Worker B │ │ Worker C │
|
|
63
|
+
│ │ │ │ │ │
|
|
64
|
+
│ auth/oauth │ │ auth/session│ │ auth/tests │
|
|
65
|
+
│ 🔒 files │ │ 🔒 files │ │ 🔒 files │
|
|
66
|
+
│ │ │ │ │ │
|
|
67
|
+
│ "I need │──────►│ "Got it, │ │ "Running │
|
|
68
|
+
│ session │ │ here's the │ │ tests..." │
|
|
69
|
+
│ types" │ │ interface" │ │ │
|
|
70
|
+
└─────────────┘ └─────────────┘ └─────────────┘
|
|
71
|
+
│ │ │
|
|
72
|
+
│ │ │
|
|
73
|
+
└─────────────────────┼─────────────────────┘
|
|
74
|
+
│
|
|
75
|
+
▼
|
|
76
|
+
┌────────────────────────┐
|
|
77
|
+
│ LEARNING SYSTEM │
|
|
78
|
+
│ │
|
|
79
|
+
│ "File-based split │
|
|
80
|
+
│ worked well for │
|
|
81
|
+
│ auth - 3 workers, │
|
|
82
|
+
│ 15 min, 0 conflicts" │
|
|
83
|
+
│ │
|
|
84
|
+
│ Next time: use this │
|
|
85
|
+
│ pattern again │
|
|
86
|
+
└────────────────────────┘
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### The Flow
|
|
90
|
+
|
|
91
|
+
1. **You give it a task**: `/swarm "Add OAuth authentication"`
|
|
92
|
+
|
|
93
|
+
2. **It queries history**: "Have we done something like this before?" (via CASS - cross-agent session search)
|
|
94
|
+
|
|
95
|
+
3. **It picks a strategy**:
|
|
96
|
+
- **File-based**: "Split by directory structure" (good for refactoring)
|
|
97
|
+
- **Feature-based**: "Split by vertical slices" (good for new features)
|
|
98
|
+
- **Risk-based**: "Tests first, then implementation" (good for bug fixes)
|
|
99
|
+
- **Research-based**: "Explore before committing" (good for unknowns)
|
|
100
|
+
|
|
101
|
+
4. **It breaks the work into beads** (git-backed issues):
|
|
63
102
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
1. **Update the plugin:**
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
npm install -g opencode-swarm-plugin@latest
|
|
103
|
+
```
|
|
104
|
+
Epic: Add OAuth
|
|
105
|
+
├─ Bead 1: OAuth provider integration (src/auth/oauth.ts)
|
|
106
|
+
├─ Bead 2: Session management (src/auth/session.ts)
|
|
107
|
+
└─ Bead 3: Integration tests (tests/auth/)
|
|
73
108
|
```
|
|
74
109
|
|
|
75
|
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
|
|
79
|
-
3. **Data Migration:**
|
|
80
|
-
- Previous MCP data is NOT automatically migrated
|
|
81
|
-
- For most users, starting fresh is recommended (swarm state is ephemeral)
|
|
82
|
-
- If you need historical data, export from MCP before upgrading
|
|
83
|
-
|
|
84
|
-
### Breaking Changes
|
|
110
|
+
5. **It spawns parallel workers**:
|
|
111
|
+
- Each worker reserves its files (no conflicts)
|
|
112
|
+
- Workers coordinate via Swarm Mail (actor-model messaging)
|
|
113
|
+
- Progress is checkpointed at 25%, 50%, 75%
|
|
85
114
|
|
|
86
|
-
|
|
87
|
-
-
|
|
88
|
-
-
|
|
115
|
+
6. **It learns from the outcome**:
|
|
116
|
+
- Fast + success = good signal
|
|
117
|
+
- Slow + errors = bad signal
|
|
118
|
+
- Patterns that fail >60% of the time get auto-inverted
|
|
89
119
|
|
|
90
|
-
|
|
120
|
+
## What Makes It Different
|
|
91
121
|
|
|
92
|
-
|
|
122
|
+
### It Survives Context Death
|
|
93
123
|
|
|
94
|
-
|
|
95
|
-
npm install -g opencode-swarm-plugin@0.14.x
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
And restore your MCP configuration.
|
|
99
|
-
|
|
100
|
-
## CLI
|
|
124
|
+
OpenCode compacts context when it gets too long. Swarms used to die when this happened. Not anymore.
|
|
101
125
|
|
|
102
126
|
```
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
swarm
|
|
108
|
-
|
|
127
|
+
Session 1 Context Session 2
|
|
128
|
+
│ Compacts │
|
|
129
|
+
▼ 💥 ▼
|
|
130
|
+
┌─────────────────┐ ┌─────────────────┐
|
|
131
|
+
│ swarm running │ │ swarm_recover() │
|
|
132
|
+
│ ├─ 25% ✓ saved │ │ │ │
|
|
133
|
+
│ ├─ 50% ✓ saved │ ─────────────────────────────────►│ ▼ │
|
|
134
|
+
│ └─ 75% ✓ saved │ checkpoints survive │ resume at 75% │
|
|
135
|
+
└─────────────────┘ └─────────────────┘
|
|
109
136
|
```
|
|
110
137
|
|
|
111
|
-
|
|
138
|
+
**Checkpoints capture:**
|
|
112
139
|
|
|
113
|
-
|
|
140
|
+
- Which subtasks are done/in-progress/pending
|
|
141
|
+
- File reservations (who owns what)
|
|
142
|
+
- Shared context for workers
|
|
143
|
+
- Progress percentage
|
|
114
144
|
|
|
115
|
-
|
|
116
|
-
/swarm "Add user authentication with OAuth"
|
|
117
|
-
```
|
|
145
|
+
**Recovery restores:**
|
|
118
146
|
|
|
119
|
-
|
|
147
|
+
- Swarm state from last checkpoint
|
|
148
|
+
- File locks (prevents conflicts)
|
|
149
|
+
- Worker context (what they were doing)
|
|
120
150
|
|
|
121
|
-
|
|
122
|
-
@swarm-planner "Refactor all components to use hooks"
|
|
123
|
-
```
|
|
151
|
+
All stored in PGLite (embedded Postgres) - no external servers, survives across sessions.
|
|
124
152
|
|
|
125
|
-
|
|
153
|
+
### It Learns From Outcomes
|
|
126
154
|
|
|
127
|
-
|
|
155
|
+
Every swarm completion records:
|
|
128
156
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
157
|
+
- Duration (how long did it take?)
|
|
158
|
+
- Errors (how many retries?)
|
|
159
|
+
- Files touched (did scope match prediction?)
|
|
160
|
+
- Success (did tests pass? were changes accepted?)
|
|
132
161
|
|
|
133
|
-
|
|
134
|
-
~/.config/opencode/command/swarm.md
|
|
162
|
+
This feeds back into the decomposition strategy:
|
|
135
163
|
|
|
136
|
-
🤖 @swarm-planner agent
|
|
137
|
-
~/.config/opencode/agent/swarm-planner.md
|
|
138
164
|
```
|
|
165
|
+
┌─────────────────────────────────┐
|
|
166
|
+
│ LEARNING LOOP │
|
|
167
|
+
└─────────────────────────────────┘
|
|
168
|
+
│
|
|
169
|
+
┌───────────────────────────┼───────────────────────────┐
|
|
170
|
+
▼ ▼ ▼
|
|
171
|
+
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
|
|
172
|
+
│ OUTCOMES │ │ PATTERNS │ │ ANTI-PATTERNS │
|
|
173
|
+
│ │ │ │ │ │
|
|
174
|
+
│ fast+success │ │ candidate │ │ >60% failure │
|
|
175
|
+
│ = good signal │──────────►│ ↓ │──────────►│ = auto-invert │
|
|
176
|
+
│ │ │ established │ │ │
|
|
177
|
+
│ slow+errors │ │ ↓ │ │ "split by X" │
|
|
178
|
+
│ = bad signal │ │ proven │ │ becomes │
|
|
179
|
+
│ │ │ │ │ "DON'T split │
|
|
180
|
+
└───────────────┘ └───────────────┘ │ by X" │
|
|
181
|
+
└───────────────┘
|
|
139
182
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
```markdown
|
|
145
|
-
---
|
|
146
|
-
description: Decompose task into parallel subtasks and coordinate agents
|
|
147
|
-
---
|
|
183
|
+
Confidence decays over 90 days
|
|
184
|
+
unless patterns are revalidated
|
|
185
|
+
```
|
|
148
186
|
|
|
149
|
-
|
|
187
|
+
**Pattern maturity lifecycle:**
|
|
150
188
|
|
|
151
|
-
|
|
189
|
+
- `candidate` → new pattern, low confidence
|
|
190
|
+
- `established` → validated 3+ times
|
|
191
|
+
- `proven` → 10+ successes (gets 1.5x weight in future decompositions)
|
|
192
|
+
- `deprecated` → >60% failure rate (auto-inverted to anti-pattern)
|
|
152
193
|
|
|
153
|
-
|
|
194
|
+
**Confidence decay:** Patterns fade over 90 days unless revalidated. Prevents stale knowledge from dominating.
|
|
154
195
|
|
|
155
|
-
|
|
196
|
+
### Swarm Mail: Actor-Model Coordination
|
|
156
197
|
|
|
157
|
-
|
|
158
|
-
2. **Decompose**: Use `swarm_select_strategy` then `swarm_plan_prompt`
|
|
159
|
-
3. **Create beads**: `beads_create_epic` with subtasks and file assignments
|
|
160
|
-
4. **Reserve files**: `swarmmail_reserve` for each subtask's files
|
|
161
|
-
5. **Spawn agents**: Use Task tool with `swarm_spawn_subtask` prompts
|
|
162
|
-
6. **Monitor**: Check `swarmmail_inbox` for progress
|
|
163
|
-
7. **Complete**: `swarm_complete` when done, then `beads_sync` to push
|
|
198
|
+
Workers don't just run in parallel - they coordinate via **Swarm Mail**, an event-sourced actor model built on local-first primitives.
|
|
164
199
|
|
|
165
|
-
|
|
200
|
+
**What makes Swarm Mail different from traditional agent messaging:**
|
|
166
201
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
| risk-based | Bug fixes, security | fix, bug, security, critical, urgent |
|
|
202
|
+
- **Actor model over durable streams** - DurableMailbox, DurableLock, DurableDeferred (inspired by Electric SQL patterns)
|
|
203
|
+
- **Local-first with PGlite** - embedded Postgres, no external servers, survives across sessions
|
|
204
|
+
- **Event-sourced coordination** - append-only log, materialized views, full audit trail
|
|
205
|
+
- **Context-safe by design** - hard caps on inbox (max 5 messages), thread summarization, body-on-demand
|
|
172
206
|
|
|
173
|
-
Begin decomposition now.
|
|
174
207
|
```
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
208
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
209
|
+
│ SWARM MAIL │
|
|
210
|
+
│ │
|
|
211
|
+
│ Worker A: "I need the SessionUser type" │
|
|
212
|
+
│ ↓ │
|
|
213
|
+
│ Worker B: "Here's the interface:" │
|
|
214
|
+
│ interface SessionUser { │
|
|
215
|
+
│ id: string │
|
|
216
|
+
│ email: string │
|
|
217
|
+
│ roles: string[] │
|
|
218
|
+
│ } │
|
|
219
|
+
│ ↓ │
|
|
220
|
+
│ Worker A: "Got it, implementing OAuth flow now" │
|
|
221
|
+
│ │
|
|
222
|
+
└──────────────────────────────────────────────────────────────┘
|
|
190
223
|
```
|
|
191
224
|
|
|
192
|
-
|
|
225
|
+
**File reservations** prevent conflicts:
|
|
193
226
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
description: Executes subtasks in a swarm - fast, focused, cost-effective
|
|
198
|
-
model: anthropic/claude-haiku-4-5 # Your chosen worker model
|
|
199
|
-
---
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Decomposition Rules
|
|
203
|
-
|
|
204
|
-
- **2-7 subtasks** - Too few = not parallel, too many = coordination overhead
|
|
205
|
-
- **No file overlap** - Each file appears in exactly one subtask
|
|
206
|
-
- **Include tests** - Put test files with the code they test
|
|
207
|
-
- **Order by dependency** - If B needs A's output, A comes first (lower index)
|
|
208
|
-
|
|
209
|
-
Edit these files to customize behavior. Run `swarm setup` to regenerate defaults.
|
|
227
|
+
- Worker A reserves `src/auth/oauth.ts` (exclusive via DurableLock)
|
|
228
|
+
- Worker B tries to reserve it → blocked
|
|
229
|
+
- Worker B waits or works on something else
|
|
210
230
|
|
|
211
|
-
|
|
231
|
+
**Inbox limits** prevent context bloat:
|
|
212
232
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
```bash
|
|
218
|
-
# List available skills
|
|
219
|
-
swarm tool skills_list
|
|
233
|
+
- Max 5 messages per fetch (headers only)
|
|
234
|
+
- Read individual message bodies on demand
|
|
235
|
+
- Thread summarization for long conversations
|
|
220
236
|
|
|
221
|
-
|
|
222
|
-
swarm tool skills_read --json '{"name": "debugging"}'
|
|
237
|
+
All coordination state survives context compaction and session restarts.
|
|
223
238
|
|
|
224
|
-
|
|
225
|
-
swarm tool skills_use --json '{"name": "code-review", "context": "reviewing a PR"}'
|
|
226
|
-
```
|
|
239
|
+
#### Architecture: 3-Tier Stack
|
|
227
240
|
|
|
228
|
-
|
|
241
|
+
Swarm Mail is built on **Durable Streams primitives** (inspired by Kyle Matthews' [Electric SQL patterns](https://x.com/kylemathews/status/1999896667030700098)):
|
|
229
242
|
|
|
230
243
|
```
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
244
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
245
|
+
│ SWARM MAIL STACK │
|
|
246
|
+
├─────────────────────────────────────────────────────────────┤
|
|
247
|
+
│ │
|
|
248
|
+
│ TIER 3: COORDINATION │
|
|
249
|
+
│ ┌───────────────────────────────────────────────────────┐ │
|
|
250
|
+
│ │ ask<Req, Res>() - Request/Response (RPC-style) │ │
|
|
251
|
+
│ └───────────────────────────────────────────────────────┘ │
|
|
252
|
+
│ │ │
|
|
253
|
+
│ TIER 2: PATTERNS ▼ │
|
|
254
|
+
│ ┌─────────────────┐ ┌─────────────────┐ │
|
|
255
|
+
│ │ DurableMailbox │ │ DurableLock │ │
|
|
256
|
+
│ │ Actor Inbox │ │ File Mutex │ │
|
|
257
|
+
│ └─────────────────┘ └─────────────────┘ │
|
|
258
|
+
│ │ │ │
|
|
259
|
+
│ TIER 1: PRIMITIVES ▼ │
|
|
260
|
+
│ ┌─────────────────┐ ┌─────────────────┐ │
|
|
261
|
+
│ │ DurableCursor │ │ DurableDeferred │ │
|
|
262
|
+
│ │ Checkpointed │ │ Distributed │ │
|
|
263
|
+
│ │ Reader │ │ Promise │ │
|
|
264
|
+
│ └─────────────────┘ └─────────────────┘ │
|
|
265
|
+
│ │ │
|
|
266
|
+
│ STORAGE ▼ │
|
|
267
|
+
│ ┌───────────────────────────────────────────────────────┐ │
|
|
268
|
+
│ │ PGLite (Embedded Postgres) + Migrations │ │
|
|
269
|
+
│ └───────────────────────────────────────────────────────┘ │
|
|
270
|
+
│ │
|
|
271
|
+
└─────────────────────────────────────────────────────────────┘
|
|
234
272
|
```
|
|
235
273
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
| Skill | Tags | Description |
|
|
239
|
-
| -------------------- | -------------------- | ------------------------------------------------------------------------------------ |
|
|
240
|
-
| `cli-builder` | cli, typescript, bun | Building TypeScript CLIs with Bun - argument parsing, subcommands, output formatting |
|
|
241
|
-
| `learning-systems` | learning, feedback | Implicit feedback scoring, confidence decay, anti-pattern detection |
|
|
242
|
-
| `mcp-tool-authoring` | mcp, tools | Building MCP tools - schema definition, context passing, error handling |
|
|
243
|
-
| `skill-creator` | meta, skills | Guide for creating effective skills |
|
|
244
|
-
| `swarm-coordination` | swarm, multi-agent | Complete swarm playbook - strategies, coordinator patterns, failure recovery |
|
|
245
|
-
| `system-design` | design, architecture | Building reusable systems - deep modules, complexity management, design red flags |
|
|
246
|
-
|
|
247
|
-
### Skill Locations
|
|
248
|
-
|
|
249
|
-
Skills are loaded from three locations (in order):
|
|
274
|
+
**Tier 1 - Primitives:**
|
|
250
275
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
276
|
+
- **DurableCursor** - Positioned event stream consumption with checkpointing (exactly-once)
|
|
277
|
+
- **DurableDeferred** - URL-addressable distributed promises for async coordination
|
|
278
|
+
- **DurableLock** - CAS-based mutual exclusion for file reservations (TTL + retry/backoff)
|
|
254
279
|
|
|
255
|
-
|
|
280
|
+
**Tier 2 - Patterns:**
|
|
256
281
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
swarm tool skills_init
|
|
260
|
-
|
|
261
|
-
# Create a new skill
|
|
262
|
-
swarm tool skills_create --json '{"name": "my-skill", "description": "What it does", "tags": ["tag1", "tag2"]}'
|
|
263
|
-
```
|
|
282
|
+
- **DurableMailbox** - Actor inbox with typed envelopes (sender, replyTo, payload)
|
|
283
|
+
- File reservation protocol built on DurableLock
|
|
264
284
|
|
|
265
|
-
|
|
285
|
+
**Tier 3 - Coordination:**
|
|
266
286
|
|
|
267
|
-
|
|
268
|
-
skills_use(name="skill-creator")
|
|
269
|
-
```
|
|
287
|
+
- **ask()** pattern - Synchronous-style RPC over async streams (creates DurableDeferred, appends to mailbox, returns promise)
|
|
270
288
|
|
|
271
|
-
|
|
289
|
+
#### Message Flow Example
|
|
272
290
|
|
|
273
291
|
```
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
292
|
+
Agent A Event Stream Agent B
|
|
293
|
+
│ │ │
|
|
294
|
+
│ ask("get SessionUser") │ │
|
|
295
|
+
├───────────────────────────>│ │
|
|
296
|
+
│ (creates deferred) │ │
|
|
297
|
+
│ │ consume event │
|
|
298
|
+
│ ├────────────────────────>│
|
|
299
|
+
│ │ │
|
|
300
|
+
│ │ reply to deferred │
|
|
301
|
+
│ │<────────────────────────┤
|
|
302
|
+
│ await deferred.value │ │
|
|
303
|
+
│<───────────────────────────┤ │
|
|
304
|
+
│ │ │
|
|
305
|
+
│ SessionUser interface │ │
|
|
306
|
+
│ │ │
|
|
279
307
|
```
|
|
280
308
|
|
|
281
|
-
|
|
309
|
+
**Why this matters:**
|
|
282
310
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
tags:
|
|
288
|
-
- tag1
|
|
289
|
-
- tag2
|
|
290
|
-
---
|
|
311
|
+
- No external servers (Redis, Kafka, NATS) - just PGlite
|
|
312
|
+
- Full audit trail - every message is an event
|
|
313
|
+
- Resumable - cursors checkpoint position, survive crashes
|
|
314
|
+
- Type-safe - Effect-TS with full inference
|
|
291
315
|
|
|
292
|
-
|
|
316
|
+
> **Architecture deep-dive:** See [Swarm Mail Architecture](docs/swarm-mail-architecture.md) for complete implementation details, database schemas, and Effect-TS patterns.
|
|
293
317
|
|
|
294
|
-
|
|
318
|
+
### It Has Skills
|
|
295
319
|
|
|
296
|
-
|
|
297
|
-
- Trigger condition 2
|
|
320
|
+
Skills are knowledge packages agents can load. Teach once, use everywhere.
|
|
298
321
|
|
|
299
|
-
|
|
322
|
+
```typescript
|
|
323
|
+
skills_use((name = "testing-patterns")); // Load Feathers seams + Beck's 4 rules
|
|
324
|
+
skills_use((name = "swarm-coordination")); // Load swarm workflow patterns
|
|
325
|
+
```
|
|
300
326
|
|
|
301
|
-
|
|
327
|
+
**Bundled skills:**
|
|
302
328
|
|
|
303
|
-
|
|
329
|
+
- `testing-patterns` - 25 dependency-breaking techniques, characterization tests
|
|
330
|
+
- `swarm-coordination` - Multi-agent decomposition, file reservations
|
|
331
|
+
- `cli-builder` - Argument parsing, help text, subcommands
|
|
332
|
+
- `system-design` - Architecture decisions, module boundaries
|
|
333
|
+
- `learning-systems` - Confidence decay, pattern maturity
|
|
304
334
|
|
|
305
|
-
|
|
335
|
+
**Create your own:**
|
|
306
336
|
|
|
307
|
-
|
|
337
|
+
```bash
|
|
338
|
+
swarm init # Creates .opencode/skills/ in project
|
|
308
339
|
```
|
|
309
340
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
| Dependency | Purpose | Required |
|
|
313
|
-
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ | -------- |
|
|
314
|
-
| [OpenCode](https://opencode.ai) | Plugin host | Yes |
|
|
315
|
-
| [Beads](https://github.com/steveyegge/beads) | Git-backed issue tracking | Yes |
|
|
316
|
-
| [CASS (Coding Agent Session Search)](https://github.com/Dicklesworthstone/coding_agent_session_search) | Historical context from past sessions | No |
|
|
317
|
-
| [UBS (Ultimate Bug Scanner)](https://github.com/Dicklesworthstone/ultimate_bug_scanner) | Pre-completion bug scanning using AI-powered static analysis | No |
|
|
318
|
-
| [semantic-memory](https://github.com/joelhooks/semantic-memory) | Learning persistence | No |
|
|
319
|
-
| [Redis](https://redis.io) | Rate limiting (SQLite fallback available) | No |
|
|
341
|
+
Skills can include:
|
|
320
342
|
|
|
321
|
-
|
|
343
|
+
- Step-by-step workflows
|
|
344
|
+
- Code examples
|
|
345
|
+
- Reference documentation
|
|
346
|
+
- Executable scripts
|
|
322
347
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
**UBS (Ultimate Bug Scanner)** - Scans code for bugs before task completion:
|
|
348
|
+
## Install
|
|
326
349
|
|
|
327
350
|
```bash
|
|
328
|
-
|
|
351
|
+
npm install -g opencode-swarm-plugin@latest
|
|
352
|
+
swarm setup
|
|
329
353
|
```
|
|
330
354
|
|
|
331
|
-
|
|
355
|
+
## Usage
|
|
332
356
|
|
|
333
357
|
```bash
|
|
334
|
-
|
|
358
|
+
/swarm "Add user authentication with OAuth"
|
|
335
359
|
```
|
|
336
360
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
## Tools Reference
|
|
340
|
-
|
|
341
|
-
### Swarm
|
|
342
|
-
|
|
343
|
-
| Tool | Description |
|
|
344
|
-
| ------------------------------ | ------------------------------------------------------------------------- |
|
|
345
|
-
| `swarm_init` | Initialize swarm session |
|
|
346
|
-
| `swarm_select_strategy` | Analyze task, recommend decomposition strategy (file/feature/risk-based) |
|
|
347
|
-
| `swarm_plan_prompt` | Generate strategy-specific planning prompt with CASS history |
|
|
348
|
-
| `swarm_decompose` | Generate decomposition prompt |
|
|
349
|
-
| `swarm_validate_decomposition` | Validate response, detect file conflicts |
|
|
350
|
-
| `swarm_spawn_subtask` | Generate worker agent prompt with Swarm Mail/beads instructions |
|
|
351
|
-
| `swarm_status` | Get swarm progress by epic ID |
|
|
352
|
-
| `swarm_progress` | Report subtask progress to coordinator |
|
|
353
|
-
| `swarm_complete` | Complete subtask - runs UBS (Ultimate Bug Scanner), releases reservations |
|
|
354
|
-
| `swarm_record_outcome` | Record outcome for learning (duration, errors, retries) |
|
|
355
|
-
|
|
356
|
-
### Beads
|
|
357
|
-
|
|
358
|
-
| Tool | Description |
|
|
359
|
-
| ------------------- | ---------------------------------------------- |
|
|
360
|
-
| `beads_create` | Create bead with type-safe validation |
|
|
361
|
-
| `beads_create_epic` | Create epic + subtasks atomically |
|
|
362
|
-
| `beads_query` | Query beads with filters (status, type, ready) |
|
|
363
|
-
| `beads_update` | Update status/description/priority |
|
|
364
|
-
| `beads_close` | Close bead with reason |
|
|
365
|
-
| `beads_start` | Mark bead as in-progress |
|
|
366
|
-
| `beads_ready` | Get next unblocked bead |
|
|
367
|
-
| `beads_sync` | Sync to git and push |
|
|
368
|
-
| `beads_link_thread` | Link bead to Swarm Mail thread |
|
|
369
|
-
|
|
370
|
-
### Swarm Mail (Embedded - Primary)
|
|
371
|
-
|
|
372
|
-
| Tool | Description |
|
|
373
|
-
| ------------------------ | --------------------------------------------- |
|
|
374
|
-
| `swarmmail_init` | Initialize session, register agent |
|
|
375
|
-
| `swarmmail_send` | Send message to agents |
|
|
376
|
-
| `swarmmail_inbox` | Fetch inbox (max 5, no bodies - context safe) |
|
|
377
|
-
| `swarmmail_read_message` | Fetch single message body by ID |
|
|
378
|
-
| `swarmmail_reserve` | Reserve file paths for exclusive editing |
|
|
379
|
-
| `swarmmail_release` | Release file reservations |
|
|
380
|
-
| `swarmmail_ack` | Acknowledge message |
|
|
381
|
-
| `swarmmail_health` | Check embedded database health |
|
|
382
|
-
|
|
383
|
-
### Agent Mail (Deprecated - MCP-based)
|
|
384
|
-
|
|
385
|
-
> **Note:** The MCP-based `agentmail_*` tools in `src/agent-mail.ts` are **deprecated** as of v0.14.0. They remain for backward compatibility but will be removed in v1.0.0.
|
|
386
|
-
>
|
|
387
|
-
> **Use `swarmmail_*` tools instead** - embedded PGLite implementation with no external server required. See [Migrating from MCP Agent Mail](#migrating-from-mcp-agent-mail) for migration guide.
|
|
388
|
-
|
|
389
|
-
## Event-Sourced Architecture (Embedded)
|
|
390
|
-
|
|
391
|
-
> **🙏 Built on the shoulders of giants**
|
|
392
|
-
>
|
|
393
|
-
> The Swarm Mail system is deeply inspired by and builds upon [**MCP Agent Mail**](https://github.com/Dicklesworthstone/mcp_agent_mail) by [@Dicklesworthstone](https://github.com/Dicklesworthstone). The original MCP Agent Mail pioneered multi-agent coordination patterns including file reservations, thread-based messaging, and agent registration - concepts that form the foundation of this embedded implementation.
|
|
394
|
-
>
|
|
395
|
-
> If you need a production-ready, battle-tested solution with a full Go server, **use MCP Agent Mail directly**. This embedded version is an experimental alternative that trades the external server for in-process PGLite, optimized for single-machine development workflows.
|
|
396
|
-
>
|
|
397
|
-
> **Key contributions from MCP Agent Mail:**
|
|
398
|
-
>
|
|
399
|
-
> - File reservation protocol with conflict detection
|
|
400
|
-
> - Agent registration and heartbeat patterns
|
|
401
|
-
> - Thread-based message organization
|
|
402
|
-
> - Importance levels and acknowledgment tracking
|
|
403
|
-
>
|
|
404
|
-
> Thank you to the MCP Agent Mail team for open-sourcing such a well-designed system.
|
|
405
|
-
|
|
406
|
-
> **🎯 Quality Patterns from Superpowers**
|
|
407
|
-
>
|
|
408
|
-
> Several verification and debugging patterns in this plugin are inspired by [**Superpowers**](https://github.com/obra/superpowers) by [@obra](https://github.com/obra) (Jesse Vincent). Superpowers is a complete software development workflow for coding agents built on composable "skills".
|
|
409
|
-
>
|
|
410
|
-
> **Key patterns adopted:**
|
|
411
|
-
>
|
|
412
|
-
> - **Verification Gate** - The Gate Function (IDENTIFY → RUN → READ → VERIFY → CLAIM) ensures no completion claims without fresh verification evidence
|
|
413
|
-
> - **3-Strike Architecture Rule** - After 3 failed fixes, question the architecture, not the bug
|
|
414
|
-
> - **CSO (Claude Search Optimization)** - Skill descriptions that answer "Should I read this right now?"
|
|
415
|
-
> - **Defense-in-Depth** - Validate at every layer data passes through
|
|
416
|
-
>
|
|
417
|
-
> Thank you Jesse for open-sourcing such a thoughtfully designed system.
|
|
418
|
-
|
|
419
|
-
The plugin includes an embedded event-sourced Swarm Mail implementation as an alternative to the external MCP server. This provides the same multi-agent coordination capabilities without requiring a separate server process.
|
|
420
|
-
|
|
421
|
-
### Architecture Comparison
|
|
422
|
-
|
|
423
|
-
**MCP-based (deprecated, external):**
|
|
424
|
-
|
|
425
|
-
```
|
|
426
|
-
plugin tools → HTTP → MCP Server (Go process) → SQLite
|
|
427
|
-
```
|
|
361
|
+
The coordinator will:
|
|
428
362
|
|
|
429
|
-
|
|
363
|
+
1. Query CASS for similar past tasks
|
|
364
|
+
2. Select decomposition strategy
|
|
365
|
+
3. Break into subtasks (beads)
|
|
366
|
+
4. Spawn parallel workers
|
|
367
|
+
5. Track progress with checkpoints
|
|
368
|
+
6. Record outcome for learning
|
|
430
369
|
|
|
431
|
-
|
|
432
|
-
plugin tools → streams/agent-mail.ts → streams/store.ts → PGLite (in-process)
|
|
433
|
-
↓
|
|
434
|
-
streams/projections.ts
|
|
435
|
-
↓
|
|
436
|
-
Materialized views (agents, messages, reservations)
|
|
437
|
-
↓
|
|
438
|
-
Fast reads
|
|
439
|
-
```
|
|
370
|
+
## Architecture
|
|
440
371
|
|
|
441
|
-
|
|
372
|
+
Everything runs in-process. No external servers.
|
|
442
373
|
|
|
443
374
|
```
|
|
444
375
|
┌─────────────────────────────────────────────────────────────────┐
|
|
445
|
-
│
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
▼
|
|
376
|
+
│ YOUR TASK │
|
|
377
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
378
|
+
│
|
|
379
|
+
▼
|
|
450
380
|
┌─────────────────────────────────────────────────────────────────┐
|
|
451
|
-
│
|
|
452
|
-
│
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
381
|
+
│ DECOMPOSITION strategy selection, subtask creation │
|
|
382
|
+
│ (queries CASS, semantic memory) │
|
|
383
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
384
|
+
│
|
|
385
|
+
▼
|
|
456
386
|
┌─────────────────────────────────────────────────────────────────┐
|
|
457
|
-
│
|
|
458
|
-
│
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
▼
|
|
387
|
+
│ BEADS git-backed issues for each subtask │
|
|
388
|
+
│ (atomic epic + subtasks creation) │
|
|
389
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
390
|
+
│
|
|
391
|
+
▼
|
|
463
392
|
┌─────────────────────────────────────────────────────────────────┐
|
|
464
|
-
│
|
|
465
|
-
│
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
▼
|
|
393
|
+
│ SWARM MAIL actor-model coordination (local-first) │
|
|
394
|
+
│ (DurableMailbox, DurableLock, PGlite) │
|
|
395
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
396
|
+
│
|
|
397
|
+
▼
|
|
470
398
|
┌─────────────────────────────────────────────────────────────────┐
|
|
471
|
-
│
|
|
472
|
-
│
|
|
473
|
-
|
|
474
|
-
│
|
|
475
|
-
|
|
476
|
-
│
|
|
477
|
-
▼
|
|
399
|
+
│ PGLITE embedded postgres, event-sourced state │
|
|
400
|
+
│ (append-only log, materialized views) │
|
|
401
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
402
|
+
│
|
|
403
|
+
▼
|
|
478
404
|
┌─────────────────────────────────────────────────────────────────┐
|
|
479
|
-
│
|
|
480
|
-
│
|
|
481
|
-
│ (Rebuilt by replaying event log) │
|
|
405
|
+
│ LEARNING outcomes feed back into decomposition │
|
|
406
|
+
│ (confidence decay, pattern maturity) │
|
|
482
407
|
└─────────────────────────────────────────────────────────────────┘
|
|
483
408
|
```
|
|
484
409
|
|
|
485
|
-
###
|
|
486
|
-
|
|
487
|
-
| Module | Responsibility |
|
|
488
|
-
| -------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
489
|
-
| **streams/events.ts** | Zod schemas for 11 event types (agent_registered, message_sent, file_reserved, task_progress, etc) |
|
|
490
|
-
| **streams/store.ts** | Append-only event log with PGLite backend (appendEvent, readEvents, replayEvents) |
|
|
491
|
-
| **streams/projections.ts** | Materialize views from events (getAgents, getInbox, checkConflicts, threadStats) |
|
|
492
|
-
| **streams/agent-mail.ts** | High-level API matching MCP interface (initAgent, sendAgentMessage, reserveAgentFiles) |
|
|
493
|
-
| **streams/debug.ts** | Debugging utilities (debugEvents, debugAgent, debugMessage, inspectState) |
|
|
494
|
-
|
|
495
|
-
### Key Benefits
|
|
496
|
-
|
|
497
|
-
- **No external dependencies** - Runs in-process with PGLite (Postgres compiled to WASM)
|
|
498
|
-
- **Full audit trail** - Every state change is an immutable event
|
|
499
|
-
- **Crash recovery** - Rebuild state by replaying events from log
|
|
500
|
-
- **Time-travel debugging** - Replay events up to any point in time
|
|
501
|
-
- **Testability** - 127 tests passing across streams module
|
|
502
|
-
- **Durable Streams protocol** - Inspired by Electric SQL's event sourcing patterns
|
|
503
|
-
|
|
504
|
-
### Event Types
|
|
505
|
-
|
|
506
|
-
The system emits 11 event types tracked in `streams/events.ts`:
|
|
507
|
-
|
|
508
|
-
| Event | Triggered By |
|
|
509
|
-
| ------------------ | ------------------------------------- |
|
|
510
|
-
| `agent_registered` | Agent initialization |
|
|
511
|
-
| `message_sent` | Sending inter-agent message |
|
|
512
|
-
| `file_reserved` | Reserving files for exclusive editing |
|
|
513
|
-
| `file_released` | Releasing file reservations |
|
|
514
|
-
| `message_read` | Reading a message |
|
|
515
|
-
| `message_acked` | Acknowledging a message |
|
|
516
|
-
| `task_started` | Starting work on a bead |
|
|
517
|
-
| `task_progress` | Reporting progress update |
|
|
518
|
-
| `task_completed` | Completing a bead |
|
|
519
|
-
| `task_blocked` | Marking a task as blocked |
|
|
520
|
-
| `agent_active` | Agent heartbeat/keep-alive |
|
|
521
|
-
|
|
522
|
-
### Materialized Views
|
|
523
|
-
|
|
524
|
-
Projections build these derived tables from the event log:
|
|
410
|
+
### Event Sourcing
|
|
525
411
|
|
|
526
|
-
|
|
527
|
-
| --------------- | ------------------------------------------------------ |
|
|
528
|
-
| `agents` | Registered agents with metadata and last activity |
|
|
529
|
-
| `messages` | All inter-agent messages with thread/importance |
|
|
530
|
-
| `reservations` | Active file reservations with TTL and exclusivity flag |
|
|
531
|
-
| `message_reads` | Read receipts for message tracking |
|
|
412
|
+
All state is stored as an append-only event log:
|
|
532
413
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
| `structured_parse_decomposition` | Parse task decomposition response |
|
|
543
|
-
| `structured_parse_bead_tree` | Parse bead tree for epic creation |
|
|
544
|
-
|
|
545
|
-
## Decomposition Strategies
|
|
546
|
-
|
|
547
|
-
### File-Based
|
|
548
|
-
|
|
549
|
-
Best for: refactoring, migrations, pattern changes
|
|
550
|
-
|
|
551
|
-
- Group files by directory or type
|
|
552
|
-
- Handle shared types/utilities first
|
|
553
|
-
- Minimize cross-directory dependencies
|
|
554
|
-
|
|
555
|
-
**Keywords**: refactor, migrate, rename, update all, replace
|
|
556
|
-
|
|
557
|
-
### Feature-Based
|
|
558
|
-
|
|
559
|
-
Best for: new features, adding functionality
|
|
560
|
-
|
|
561
|
-
- Each subtask is a complete vertical slice
|
|
562
|
-
- Start with data layer, then logic, then UI
|
|
563
|
-
- Keep related components together
|
|
564
|
-
|
|
565
|
-
**Keywords**: add, implement, build, create, feature
|
|
566
|
-
|
|
567
|
-
### Risk-Based
|
|
568
|
-
|
|
569
|
-
Best for: bug fixes, security issues
|
|
570
|
-
|
|
571
|
-
- Write tests FIRST
|
|
572
|
-
- Isolate risky changes
|
|
573
|
-
- Audit similar code for same issue
|
|
574
|
-
|
|
575
|
-
**Keywords**: fix, bug, security, critical, urgent
|
|
576
|
-
|
|
577
|
-
## Learning
|
|
414
|
+
```
|
|
415
|
+
Event Log (PGLite)
|
|
416
|
+
├─ agent_registered → Agent joins swarm
|
|
417
|
+
├─ message_sent → Agent-to-agent communication
|
|
418
|
+
├─ file_reserved → Exclusive file lock acquired
|
|
419
|
+
├─ file_released → Lock released
|
|
420
|
+
├─ swarm_checkpointed → Progress snapshot saved
|
|
421
|
+
├─ decomposition_generated → Task broken into subtasks
|
|
422
|
+
└─ subtask_outcome → Worker completion result
|
|
578
423
|
|
|
579
|
-
|
|
424
|
+
Materialized Views (derived from events)
|
|
425
|
+
├─ agents → Active agents per project
|
|
426
|
+
├─ messages → Agent inbox/outbox
|
|
427
|
+
├─ file_reservations → Current file locks
|
|
428
|
+
└─ eval_records → Outcome data for learning
|
|
429
|
+
```
|
|
580
430
|
|
|
581
|
-
|
|
582
|
-
| ----------------- | ----------------------------------------------------------- |
|
|
583
|
-
| Confidence decay | Criteria weights fade unless revalidated (90-day half-life) |
|
|
584
|
-
| Implicit feedback | Fast + success = helpful signal, slow + errors = harmful |
|
|
585
|
-
| Pattern maturity | candidate → established → proven (or deprecated) |
|
|
586
|
-
| Anti-patterns | Patterns with >60% failure rate auto-invert |
|
|
431
|
+
**Why event sourcing?**
|
|
587
432
|
|
|
588
|
-
|
|
433
|
+
- **Audit trail** - full history of what happened
|
|
434
|
+
- **Replay** - reconstruct state from events
|
|
435
|
+
- **Debugging** - see exactly what went wrong
|
|
436
|
+
- **Learning** - analyze outcomes over time
|
|
589
437
|
|
|
590
|
-
|
|
438
|
+
See the [Swarm Mail Architecture](docs/swarm-mail-architecture.md) section above for details on the durable primitives (DurableCursor, DurableDeferred, DurableLock, DurableMailbox) and how they enable exactly-once processing, request/response patterns, and actor coordination.
|
|
591
439
|
|
|
592
|
-
|
|
593
|
-
| ------------------- | ---------- | ------------------------------ |
|
|
594
|
-
| Inbox limit | 5 messages | Prevents token burn |
|
|
595
|
-
| Bodies excluded | Always | Fetch individually when needed |
|
|
596
|
-
| Summarize preferred | Yes | Key points, not raw dump |
|
|
440
|
+
## Dependencies
|
|
597
441
|
|
|
598
|
-
|
|
442
|
+
| Required | Optional |
|
|
443
|
+
| -------------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
444
|
+
| [OpenCode](https://opencode.ai) | [CASS](https://github.com/Dicklesworthstone/coding_agent_session_search) - historical context |
|
|
445
|
+
| [Beads](https://github.com/steveyegge/beads) | [UBS](https://github.com/Dicklesworthstone/ultimate_bug_scanner) - bug scanning |
|
|
446
|
+
| | [semantic-memory](https://github.com/joelhooks/semantic-memory) - learning persistence |
|
|
599
447
|
|
|
600
|
-
|
|
448
|
+
Run `swarm doctor` to check status.
|
|
601
449
|
|
|
602
|
-
|
|
603
|
-
| -------- | ---------- | -------- |
|
|
604
|
-
| send | 20 | 200 |
|
|
605
|
-
| reserve | 10 | 100 |
|
|
606
|
-
| inbox | 60 | 600 |
|
|
450
|
+
## CLI
|
|
607
451
|
|
|
608
|
-
|
|
452
|
+
```bash
|
|
453
|
+
swarm setup # Install and configure
|
|
454
|
+
swarm doctor # Check dependencies
|
|
455
|
+
swarm init # Initialize beads in project
|
|
456
|
+
swarm config # Show config file paths
|
|
457
|
+
```
|
|
609
458
|
|
|
610
459
|
## Development
|
|
611
460
|
|
|
612
461
|
```bash
|
|
613
462
|
bun install
|
|
614
|
-
bun
|
|
615
|
-
bun test
|
|
463
|
+
bun test # Unit tests (230 tests)
|
|
464
|
+
bun run test:integration # Integration tests
|
|
616
465
|
bun run build
|
|
617
466
|
```
|
|
618
467
|
|
|
619
|
-
##
|
|
620
|
-
|
|
621
|
-
### 1. First Step: Run Doctor
|
|
622
|
-
|
|
623
|
-
```bash
|
|
624
|
-
swarm doctor
|
|
625
|
-
```
|
|
626
|
-
|
|
627
|
-
This checks all dependencies and shows their installation status.
|
|
628
|
-
|
|
629
|
-
### 2. Common Issues
|
|
630
|
-
|
|
631
|
-
| Issue | Cause | Solution |
|
|
632
|
-
| --------------------------- | ---------------------------------- | ------------------------------------------------- |
|
|
633
|
-
| `beads: command not found` | Beads CLI not installed | `npm install -g @joelhooks/beads` |
|
|
634
|
-
| `bd: command not found` | Same as above | `npm install -g @joelhooks/beads` |
|
|
635
|
-
| Verification Gate fails | TypeScript errors or test failures | Fix errors shown, or use `skip_verification=true` |
|
|
636
|
-
| File reservation conflict | Another agent has the file | Wait for release, or check `swarmmail_inbox` |
|
|
637
|
-
| `Mandate not found` | ID doesn't exist | Use `mandate_list` to see available mandates |
|
|
638
|
-
| Swarm Mail connection error | Database not initialized | Run `swarm setup` again |
|
|
639
|
-
| `Agent not registered` | Session not initialized | Call `swarmmail_init` first |
|
|
468
|
+
## Credits
|
|
640
469
|
|
|
641
|
-
|
|
470
|
+
**Inspiration & Core Ideas:**
|
|
642
471
|
|
|
643
|
-
-
|
|
644
|
-
-
|
|
645
|
-
-
|
|
472
|
+
- [MCP Agent Mail](https://github.com/Dicklesworthstone/mcp_agent_mail) - **THE INSPIRATION** for multi-agent coordination. Swarm Mail is our implementation built on actor-model primitives (DurableMailbox, DurableLock) with local-first PGlite and event sourcing.
|
|
473
|
+
- [Superpowers](https://github.com/obra/superpowers) - verification patterns, Socratic planning, skill architecture
|
|
474
|
+
- [Electric SQL](https://electric-sql.com) - durable streams and event sourcing patterns that power Swarm Mail
|
|
475
|
+
- [Evalite](https://evalite.dev) - outcome-based evaluation framework for learning systems
|
|
646
476
|
|
|
647
477
|
## License
|
|
648
478
|
|