opencode-swarm-plugin 0.22.0 → 0.23.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/.turbo/turbo-build.log +9 -0
- package/CHANGELOG.md +12 -0
- package/README.md +109 -429
- package/dist/agent-mail.d.ts +480 -0
- package/dist/agent-mail.d.ts.map +1 -0
- package/dist/anti-patterns.d.ts +257 -0
- package/dist/anti-patterns.d.ts.map +1 -0
- package/dist/beads.d.ts +377 -0
- package/dist/beads.d.ts.map +1 -0
- package/dist/eval-capture.d.ts +206 -0
- package/dist/eval-capture.d.ts.map +1 -0
- package/dist/index.d.ts +1299 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +498 -4246
- package/dist/learning.d.ts +670 -0
- package/dist/learning.d.ts.map +1 -0
- package/dist/mandate-promotion.d.ts +93 -0
- package/dist/mandate-promotion.d.ts.map +1 -0
- package/dist/mandate-storage.d.ts +209 -0
- package/dist/mandate-storage.d.ts.map +1 -0
- package/dist/mandates.d.ts +230 -0
- package/dist/mandates.d.ts.map +1 -0
- package/dist/output-guardrails.d.ts +125 -0
- package/dist/output-guardrails.d.ts.map +1 -0
- package/dist/pattern-maturity.d.ts +246 -0
- package/dist/pattern-maturity.d.ts.map +1 -0
- package/dist/plugin.d.ts +22 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +493 -4241
- package/dist/rate-limiter.d.ts +218 -0
- package/dist/rate-limiter.d.ts.map +1 -0
- package/dist/repo-crawl.d.ts +146 -0
- package/dist/repo-crawl.d.ts.map +1 -0
- package/dist/schemas/bead.d.ts +255 -0
- package/dist/schemas/bead.d.ts.map +1 -0
- package/dist/schemas/evaluation.d.ts +161 -0
- package/dist/schemas/evaluation.d.ts.map +1 -0
- package/dist/schemas/index.d.ts +34 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/mandate.d.ts +336 -0
- package/dist/schemas/mandate.d.ts.map +1 -0
- package/dist/schemas/swarm-context.d.ts +131 -0
- package/dist/schemas/swarm-context.d.ts.map +1 -0
- package/dist/schemas/task.d.ts +188 -0
- package/dist/schemas/task.d.ts.map +1 -0
- package/dist/skills.d.ts +471 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/storage.d.ts +260 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/structured.d.ts +196 -0
- package/dist/structured.d.ts.map +1 -0
- package/dist/swarm-decompose.d.ts +201 -0
- package/dist/swarm-decompose.d.ts.map +1 -0
- package/dist/swarm-mail.d.ts +240 -0
- package/dist/swarm-mail.d.ts.map +1 -0
- package/dist/swarm-orchestrate.d.ts +708 -0
- package/dist/swarm-orchestrate.d.ts.map +1 -0
- package/dist/swarm-prompts.d.ts +292 -0
- package/dist/swarm-prompts.d.ts.map +1 -0
- package/dist/swarm-strategies.d.ts +100 -0
- package/dist/swarm-strategies.d.ts.map +1 -0
- package/dist/swarm.d.ts +455 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/tool-availability.d.ts +91 -0
- package/dist/tool-availability.d.ts.map +1 -0
- package/docs/planning/ADR-001-monorepo-structure.md +171 -0
- package/docs/planning/ADR-002-package-extraction.md +393 -0
- package/docs/planning/ADR-003-performance-improvements.md +451 -0
- package/docs/planning/ADR-004-message-queue-features.md +187 -0
- package/docs/planning/ADR-005-devtools-observability.md +202 -0
- package/docs/planning/ROADMAP.md +368 -0
- package/package.json +13 -24
- package/src/agent-mail.ts +1 -1
- package/src/beads.ts +1 -2
- package/src/index.ts +2 -2
- package/src/learning.integration.test.ts +66 -11
- package/src/mandate-storage.test.ts +3 -3
- package/src/storage.ts +78 -10
- package/src/swarm-mail.ts +3 -3
- package/src/swarm-orchestrate.ts +7 -7
- package/src/tool-availability.ts +1 -1
- package/tsconfig.json +1 -1
- package/.beads/.local_version +0 -1
- package/.beads/README.md +0 -81
- package/.beads/analysis/skill-architecture-meta-skills.md +0 -1562
- package/.beads/config.yaml +0 -62
- package/.beads/issues.jsonl +0 -2197
- package/.beads/metadata.json +0 -4
- package/.gitattributes +0 -3
- package/.github/workflows/ci.yml +0 -30
- package/.github/workflows/opencode.yml +0 -31
- package/.opencode/skills/tdd/SKILL.md +0 -182
- package/INTEGRATION_EXAMPLE.md +0 -66
- package/VERIFICATION_QUALITY_PATTERNS.md +0 -565
- package/bun.lock +0 -286
- package/dist/pglite.data +0 -0
- package/dist/pglite.wasm +0 -0
- package/src/streams/agent-mail.test.ts +0 -777
- package/src/streams/agent-mail.ts +0 -535
- package/src/streams/debug.test.ts +0 -500
- package/src/streams/debug.ts +0 -727
- package/src/streams/effect/ask.integration.test.ts +0 -314
- package/src/streams/effect/ask.ts +0 -202
- package/src/streams/effect/cursor.integration.test.ts +0 -418
- package/src/streams/effect/cursor.ts +0 -288
- package/src/streams/effect/deferred.test.ts +0 -357
- package/src/streams/effect/deferred.ts +0 -445
- package/src/streams/effect/index.ts +0 -17
- package/src/streams/effect/layers.ts +0 -73
- package/src/streams/effect/lock.test.ts +0 -385
- package/src/streams/effect/lock.ts +0 -399
- package/src/streams/effect/mailbox.test.ts +0 -260
- package/src/streams/effect/mailbox.ts +0 -318
- package/src/streams/events.test.ts +0 -924
- package/src/streams/events.ts +0 -329
- package/src/streams/index.test.ts +0 -229
- package/src/streams/index.ts +0 -578
- package/src/streams/migrations.test.ts +0 -359
- package/src/streams/migrations.ts +0 -362
- package/src/streams/projections.test.ts +0 -611
- package/src/streams/projections.ts +0 -504
- package/src/streams/store.integration.test.ts +0 -658
- package/src/streams/store.ts +0 -1075
- package/src/streams/swarm-mail.ts +0 -552
- package/test-bug-fixes.ts +0 -86
- package/vitest.integration.config.ts +0 -19
- package/vitest.integration.setup.ts +0 -48
- package/workflow-integration-analysis.md +0 -876
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
$ bun build ./src/index.ts --outdir ./dist --target node --external @electric-sql/pglite --external swarm-mail && bun build ./src/plugin.ts --outfile ./dist/plugin.js --target node --external @electric-sql/pglite --external swarm-mail && tsc
|
|
2
|
+
Bundled 195 modules in 33ms
|
|
3
|
+
|
|
4
|
+
index.js 1.14 MB (entry point)
|
|
5
|
+
|
|
6
|
+
Bundled 196 modules in 32ms
|
|
7
|
+
|
|
8
|
+
plugin.js 1.12 MB (entry point)
|
|
9
|
+
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# opencode-swarm-plugin
|
|
2
|
+
|
|
3
|
+
## 0.23.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`b66d77e`](https://github.com/joelhooks/opencode-swarm-plugin/commit/b66d77e484e9b7021b3264d1a7e8f54a16ea5204) Thanks [@joelhooks](https://github.com/joelhooks)! - Add changesets workflow and semantic memory test isolation
|
|
8
|
+
|
|
9
|
+
- OIDC publish workflow with GitHub Actions
|
|
10
|
+
- Changesets for independent package versioning
|
|
11
|
+
- TEST_SEMANTIC_MEMORY_COLLECTION env var for test isolation
|
|
12
|
+
- Prevents test pollution of production semantic-memory
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# opencode-swarm-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
OpenCode plugin for multi-agent swarm coordination with learning capabilities.
|
|
4
4
|
|
|
5
5
|
```
|
|
6
6
|
███████╗██╗ ██╗ █████╗ ██████╗ ███╗ ███╗
|
|
@@ -9,341 +9,16 @@
|
|
|
9
9
|
╚════██║██║███╗██║██╔══██║██╔══██╗██║╚██╔╝██║
|
|
10
10
|
███████║╚███╔███╔╝██║ ██║██║ ██║██║ ╚═╝ ██║
|
|
11
11
|
╚══════╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝
|
|
12
|
-
|
|
13
|
-
\ ` - ' /
|
|
14
|
-
- .(o o). -
|
|
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):
|
|
102
|
-
|
|
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/)
|
|
108
|
-
```
|
|
109
|
-
|
|
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%
|
|
114
|
-
|
|
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
|
|
119
|
-
|
|
120
|
-
## What Makes It Different
|
|
121
|
-
|
|
122
|
-
### It Survives Context Death
|
|
123
|
-
|
|
124
|
-
OpenCode compacts context when it gets too long. Swarms used to die when this happened. Not anymore.
|
|
125
|
-
|
|
126
|
-
```
|
|
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
|
-
└─────────────────┘ └─────────────────┘
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
**Checkpoints capture:**
|
|
139
|
-
|
|
140
|
-
- Which subtasks are done/in-progress/pending
|
|
141
|
-
- File reservations (who owns what)
|
|
142
|
-
- Shared context for workers
|
|
143
|
-
- Progress percentage
|
|
144
|
-
|
|
145
|
-
**Recovery restores:**
|
|
146
|
-
|
|
147
|
-
- Swarm state from last checkpoint
|
|
148
|
-
- File locks (prevents conflicts)
|
|
149
|
-
- Worker context (what they were doing)
|
|
150
|
-
|
|
151
|
-
All stored in PGLite (embedded Postgres) - no external servers, survives across sessions.
|
|
152
|
-
|
|
153
|
-
### It Learns From Outcomes
|
|
154
|
-
|
|
155
|
-
Every swarm completion records:
|
|
156
|
-
|
|
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?)
|
|
161
|
-
|
|
162
|
-
This feeds back into the decomposition strategy:
|
|
163
|
-
|
|
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
|
-
└───────────────┘
|
|
182
|
-
|
|
183
|
-
Confidence decays over 90 days
|
|
184
|
-
unless patterns are revalidated
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
**Pattern maturity lifecycle:**
|
|
188
|
-
|
|
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)
|
|
193
|
-
|
|
194
|
-
**Confidence decay:** Patterns fade over 90 days unless revalidated. Prevents stale knowledge from dominating.
|
|
195
|
-
|
|
196
|
-
### Swarm Mail: Actor-Model Coordination
|
|
197
|
-
|
|
198
|
-
Workers don't just run in parallel - they coordinate via **Swarm Mail**, an event-sourced actor model built on local-first primitives.
|
|
199
|
-
|
|
200
|
-
**What makes Swarm Mail different from traditional agent messaging:**
|
|
201
|
-
|
|
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
|
|
206
|
-
|
|
207
|
-
```
|
|
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
|
-
└──────────────────────────────────────────────────────────────┘
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
**File reservations** prevent conflicts:
|
|
226
|
-
|
|
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
|
|
230
|
-
|
|
231
|
-
**Inbox limits** prevent context bloat:
|
|
232
|
-
|
|
233
|
-
- Max 5 messages per fetch (headers only)
|
|
234
|
-
- Read individual message bodies on demand
|
|
235
|
-
- Thread summarization for long conversations
|
|
236
|
-
|
|
237
|
-
All coordination state survives context compaction and session restarts.
|
|
238
|
-
|
|
239
|
-
#### Architecture: 3-Tier Stack
|
|
240
|
-
|
|
241
|
-
Swarm Mail is built on **Durable Streams primitives** (inspired by Kyle Matthews' [Electric SQL patterns](https://x.com/kylemathews/status/1999896667030700098)):
|
|
242
|
-
|
|
243
|
-
```
|
|
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
|
-
└─────────────────────────────────────────────────────────────┘
|
|
272
12
|
```
|
|
273
13
|
|
|
274
|
-
|
|
275
|
-
|
|
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)
|
|
14
|
+
## Features
|
|
279
15
|
|
|
280
|
-
**
|
|
281
|
-
|
|
282
|
-
- **
|
|
283
|
-
-
|
|
284
|
-
|
|
285
|
-
**
|
|
286
|
-
|
|
287
|
-
- **ask()** pattern - Synchronous-style RPC over async streams (creates DurableDeferred, appends to mailbox, returns promise)
|
|
288
|
-
|
|
289
|
-
#### Message Flow Example
|
|
290
|
-
|
|
291
|
-
```
|
|
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
|
-
│ │ │
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
**Why this matters:**
|
|
310
|
-
|
|
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
|
|
315
|
-
|
|
316
|
-
> **Architecture deep-dive:** See [Swarm Mail Architecture](docs/swarm-mail-architecture.md) for complete implementation details, database schemas, and Effect-TS patterns.
|
|
317
|
-
|
|
318
|
-
### It Has Skills
|
|
319
|
-
|
|
320
|
-
Skills are knowledge packages agents can load. Teach once, use everywhere.
|
|
321
|
-
|
|
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
|
-
```
|
|
326
|
-
|
|
327
|
-
**Bundled skills:**
|
|
328
|
-
|
|
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
|
|
334
|
-
|
|
335
|
-
**Create your own:**
|
|
336
|
-
|
|
337
|
-
```bash
|
|
338
|
-
swarm init # Creates .opencode/skills/ in project
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
Skills can include:
|
|
342
|
-
|
|
343
|
-
- Step-by-step workflows
|
|
344
|
-
- Code examples
|
|
345
|
-
- Reference documentation
|
|
346
|
-
- Executable scripts
|
|
16
|
+
- **Swarm Coordination** - Break tasks into parallel subtasks, spawn worker agents
|
|
17
|
+
- **Beads Integration** - Git-backed issue tracking with atomic epic creation
|
|
18
|
+
- **Agent Mail** - Inter-agent messaging with file reservations
|
|
19
|
+
- **Learning System** - Pattern maturity, anti-pattern detection, confidence decay
|
|
20
|
+
- **Skills System** - Knowledge injection with bundled and custom skills
|
|
21
|
+
- **Checkpointing** - Survive context compaction, resume from last checkpoint
|
|
347
22
|
|
|
348
23
|
## Install
|
|
349
24
|
|
|
@@ -358,94 +33,117 @@ swarm setup
|
|
|
358
33
|
/swarm "Add user authentication with OAuth"
|
|
359
34
|
```
|
|
360
35
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
36
|
+
## Tools Provided
|
|
37
|
+
|
|
38
|
+
### Beads (Issue Tracking)
|
|
39
|
+
|
|
40
|
+
| Tool | Purpose |
|
|
41
|
+
| ------------------- | ------------------------------------- |
|
|
42
|
+
| `beads_create` | Create bead with type-safe validation |
|
|
43
|
+
| `beads_create_epic` | Atomic epic + subtasks creation |
|
|
44
|
+
| `beads_query` | Query with filters |
|
|
45
|
+
| `beads_update` | Update status/description/priority |
|
|
46
|
+
| `beads_close` | Close with reason |
|
|
47
|
+
| `beads_start` | Mark in-progress |
|
|
48
|
+
| `beads_ready` | Get next unblocked bead |
|
|
49
|
+
| `beads_sync` | Sync to git |
|
|
50
|
+
|
|
51
|
+
### Swarm Mail (Agent Coordination)
|
|
52
|
+
|
|
53
|
+
| Tool | Purpose |
|
|
54
|
+
| ------------------------ | -------------------------------- |
|
|
55
|
+
| `swarmmail_init` | Initialize session |
|
|
56
|
+
| `swarmmail_send` | Send message to agents |
|
|
57
|
+
| `swarmmail_inbox` | Fetch inbox (context-safe) |
|
|
58
|
+
| `swarmmail_read_message` | Fetch one message body |
|
|
59
|
+
| `swarmmail_reserve` | Reserve files for exclusive edit |
|
|
60
|
+
| `swarmmail_release` | Release reservations |
|
|
61
|
+
|
|
62
|
+
### Swarm (Task Orchestration)
|
|
63
|
+
|
|
64
|
+
| Tool | Purpose |
|
|
65
|
+
| ------------------------------ | ----------------------------------------------- |
|
|
66
|
+
| `swarm_select_strategy` | Analyze task, recommend strategy |
|
|
67
|
+
| `swarm_decompose` | Generate decomposition prompt (queries CASS) |
|
|
68
|
+
| `swarm_delegate_planning` | Delegate planning to planner subagent |
|
|
69
|
+
| `swarm_validate_decomposition` | Validate response, detect conflicts |
|
|
70
|
+
| `swarm_plan_prompt` | Generate strategy-specific decomposition prompt |
|
|
71
|
+
| `swarm_subtask_prompt` | Generate worker agent prompt |
|
|
72
|
+
| `swarm_spawn_subtask` | Prepare subtask for Task tool spawning |
|
|
73
|
+
| `swarm_evaluation_prompt` | Generate self-evaluation prompt |
|
|
74
|
+
| `swarm_init` | Initialize swarm session |
|
|
75
|
+
| `swarm_status` | Get swarm progress by epic ID |
|
|
76
|
+
| `swarm_progress` | Report subtask progress to coordinator |
|
|
77
|
+
| `swarm_complete` | Complete subtask (runs UBS scan, releases) |
|
|
78
|
+
| `swarm_record_outcome` | Record outcome for learning |
|
|
79
|
+
| `swarm_checkpoint` | Save progress snapshot |
|
|
80
|
+
| `swarm_recover` | Resume from checkpoint |
|
|
81
|
+
| `swarm_learn` | Extract learnings from outcome |
|
|
82
|
+
| `swarm_broadcast` | Send message to all active agents |
|
|
83
|
+
| `swarm_accumulate_error` | Track recurring errors (3-strike system) |
|
|
84
|
+
| `swarm_check_strikes` | Check if error threshold reached |
|
|
85
|
+
| `swarm_get_error_context` | Get context for error pattern |
|
|
86
|
+
| `swarm_resolve_error` | Mark error pattern as resolved |
|
|
87
|
+
|
|
88
|
+
### Skills (Knowledge Injection)
|
|
89
|
+
|
|
90
|
+
| Tool | Purpose |
|
|
91
|
+
| --------------- | ----------------------- |
|
|
92
|
+
| `skills_list` | List available skills |
|
|
93
|
+
| `skills_use` | Load skill into context |
|
|
94
|
+
| `skills_read` | Read skill content |
|
|
95
|
+
| `skills_create` | Create new skill |
|
|
96
|
+
|
|
97
|
+
## Bundled Skills
|
|
98
|
+
|
|
99
|
+
Located in `global-skills/`:
|
|
100
|
+
|
|
101
|
+
- **testing-patterns** - 25 dependency-breaking techniques, characterization tests
|
|
102
|
+
- **swarm-coordination** - Multi-agent decomposition, file reservations
|
|
103
|
+
- **cli-builder** - Argument parsing, help text, subcommands
|
|
104
|
+
- **system-design** - Architecture decisions, module boundaries
|
|
105
|
+
- **learning-systems** - Confidence decay, pattern maturity
|
|
106
|
+
- **skill-creator** - Meta-skill for creating new skills
|
|
369
107
|
|
|
370
108
|
## Architecture
|
|
371
109
|
|
|
372
|
-
Everything runs in-process. No external servers.
|
|
373
|
-
|
|
374
110
|
```
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
390
|
-
│
|
|
391
|
-
▼
|
|
392
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
393
|
-
│ SWARM MAIL actor-model coordination (local-first) │
|
|
394
|
-
│ (DurableMailbox, DurableLock, PGlite) │
|
|
395
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
396
|
-
│
|
|
397
|
-
▼
|
|
398
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
399
|
-
│ PGLITE embedded postgres, event-sourced state │
|
|
400
|
-
│ (append-only log, materialized views) │
|
|
401
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
402
|
-
│
|
|
403
|
-
▼
|
|
404
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
405
|
-
│ LEARNING outcomes feed back into decomposition │
|
|
406
|
-
│ (confidence decay, pattern maturity) │
|
|
407
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
111
|
+
src/
|
|
112
|
+
├── beads.ts # Beads integration
|
|
113
|
+
├── agent-mail.ts # Agent Mail tools (legacy MCP wrapper)
|
|
114
|
+
├── swarm-mail.ts # Swarm Mail tools (new, uses swarm-mail package)
|
|
115
|
+
├── swarm.ts # Swarm orchestration tools
|
|
116
|
+
├── swarm-orchestrate.ts # Coordinator logic
|
|
117
|
+
├── swarm-decompose.ts # Decomposition strategies
|
|
118
|
+
├── swarm-strategies.ts # Strategy selection
|
|
119
|
+
├── skills.ts # Skills system
|
|
120
|
+
├── learning.ts # Pattern maturity, outcomes
|
|
121
|
+
├── anti-patterns.ts # Anti-pattern detection
|
|
122
|
+
├── structured.ts # JSON parsing utilities
|
|
123
|
+
├── mandates.ts # Mandate system
|
|
124
|
+
└── schemas/ # Zod schemas
|
|
408
125
|
```
|
|
409
126
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
All state is stored as an append-only event log:
|
|
413
|
-
|
|
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
|
|
423
|
-
|
|
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
|
-
```
|
|
430
|
-
|
|
431
|
-
**Why event sourcing?**
|
|
432
|
-
|
|
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
|
|
127
|
+
## Dependencies
|
|
437
128
|
|
|
438
|
-
|
|
129
|
+
- [swarm-mail](../swarm-mail) - Event sourcing primitives (workspace dependency)
|
|
130
|
+
- [@opencode-ai/plugin](https://www.npmjs.com/package/@opencode-ai/plugin) - OpenCode plugin API
|
|
131
|
+
- [effect](https://effect.website) - Effect-TS for type-safe composition
|
|
132
|
+
- [zod](https://zod.dev) - Schema validation
|
|
439
133
|
|
|
440
|
-
##
|
|
134
|
+
## Development
|
|
441
135
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
136
|
+
```bash
|
|
137
|
+
# From monorepo root
|
|
138
|
+
bun turbo build --filter=opencode-swarm-plugin
|
|
139
|
+
bun turbo test --filter=opencode-swarm-plugin
|
|
140
|
+
bun turbo typecheck --filter=opencode-swarm-plugin
|
|
447
141
|
|
|
448
|
-
|
|
142
|
+
# Or from this directory
|
|
143
|
+
bun run build
|
|
144
|
+
bun test
|
|
145
|
+
bun run typecheck
|
|
146
|
+
```
|
|
449
147
|
|
|
450
148
|
## CLI
|
|
451
149
|
|
|
@@ -456,24 +154,6 @@ swarm init # Initialize beads in project
|
|
|
456
154
|
swarm config # Show config file paths
|
|
457
155
|
```
|
|
458
156
|
|
|
459
|
-
## Development
|
|
460
|
-
|
|
461
|
-
```bash
|
|
462
|
-
bun install
|
|
463
|
-
bun test # Unit tests (230 tests)
|
|
464
|
-
bun run test:integration # Integration tests
|
|
465
|
-
bun run build
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
## Credits
|
|
469
|
-
|
|
470
|
-
**Inspiration & Core Ideas:**
|
|
471
|
-
|
|
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
|
|
476
|
-
|
|
477
157
|
## License
|
|
478
158
|
|
|
479
159
|
MIT
|