opencode-swarm-plugin 0.31.7 → 0.33.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.
Files changed (62) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/.turbo/turbo-test.log +324 -316
  3. package/CHANGELOG.md +394 -0
  4. package/README.md +129 -181
  5. package/bin/swarm.test.ts +31 -0
  6. package/bin/swarm.ts +635 -140
  7. package/dist/compaction-hook.d.ts +1 -1
  8. package/dist/compaction-hook.d.ts.map +1 -1
  9. package/dist/hive.d.ts.map +1 -1
  10. package/dist/index.d.ts +17 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +653 -139
  13. package/dist/memory-tools.d.ts.map +1 -1
  14. package/dist/memory.d.ts +5 -4
  15. package/dist/memory.d.ts.map +1 -1
  16. package/dist/observability-tools.d.ts +116 -0
  17. package/dist/observability-tools.d.ts.map +1 -0
  18. package/dist/plugin.js +648 -136
  19. package/dist/skills.d.ts.map +1 -1
  20. package/dist/swarm-orchestrate.d.ts +29 -5
  21. package/dist/swarm-orchestrate.d.ts.map +1 -1
  22. package/dist/swarm-prompts.d.ts +66 -0
  23. package/dist/swarm-prompts.d.ts.map +1 -1
  24. package/dist/swarm.d.ts +17 -2
  25. package/dist/swarm.d.ts.map +1 -1
  26. package/evals/lib/{data-loader.test.ts → data-loader.evalite-test.ts} +7 -6
  27. package/evals/lib/data-loader.ts +1 -1
  28. package/evals/scorers/{outcome-scorers.test.ts → outcome-scorers.evalite-test.ts} +1 -1
  29. package/examples/plugin-wrapper-template.ts +316 -12
  30. package/global-skills/swarm-coordination/SKILL.md +118 -8
  31. package/package.json +3 -2
  32. package/src/compaction-hook.ts +5 -3
  33. package/src/hive.integration.test.ts +83 -1
  34. package/src/hive.ts +37 -12
  35. package/src/index.ts +25 -1
  36. package/src/mandate-storage.integration.test.ts +601 -0
  37. package/src/memory-tools.ts +6 -4
  38. package/src/memory.integration.test.ts +117 -49
  39. package/src/memory.test.ts +41 -217
  40. package/src/memory.ts +12 -8
  41. package/src/observability-tools.test.ts +346 -0
  42. package/src/observability-tools.ts +594 -0
  43. package/src/repo-crawl.integration.test.ts +441 -0
  44. package/src/skills.integration.test.ts +1192 -0
  45. package/src/skills.test.ts +42 -1
  46. package/src/skills.ts +8 -4
  47. package/src/structured.integration.test.ts +817 -0
  48. package/src/swarm-deferred.integration.test.ts +157 -0
  49. package/src/swarm-deferred.test.ts +38 -0
  50. package/src/swarm-mail.integration.test.ts +15 -19
  51. package/src/swarm-orchestrate.integration.test.ts +282 -0
  52. package/src/swarm-orchestrate.test.ts +123 -0
  53. package/src/swarm-orchestrate.ts +279 -201
  54. package/src/swarm-prompts.test.ts +481 -0
  55. package/src/swarm-prompts.ts +297 -0
  56. package/src/swarm-research.integration.test.ts +544 -0
  57. package/src/swarm-research.test.ts +698 -0
  58. package/src/swarm-research.ts +472 -0
  59. package/src/swarm-review.integration.test.ts +290 -0
  60. package/src/swarm.integration.test.ts +23 -20
  61. package/src/swarm.ts +6 -3
  62. package/src/tool-adapter.integration.test.ts +1221 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,399 @@
1
1
  # opencode-swarm-plugin
2
2
 
3
+ ## 0.33.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`c41abcf`](https://github.com/joelhooks/swarm-tools/commit/c41abcfa37292b72fe41e0cf9d25c6612ae75fa2) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🎓 Skills Grow Up: Discovery Moves to OpenCode
8
+
9
+ > _"The best code is no code at all. Every new line of code you willingly bring into the world is code that has to be debugged, code that has to be read and understood, code that has to be supported."_
10
+ > — Jeff Atwood
11
+
12
+ Skills outgrew the nest. OpenCode is shipping native skills support following the [Agent Skills spec](https://spec.agentskills.com/), and our discovery tools are now redundant. Time to deprecate the scaffolding and let the platform handle what it does best.
13
+
14
+ ### What Changed
15
+
16
+ **Deprecated Tools** (soft deprecation with console warnings):
17
+
18
+ - `skills_list` - OpenCode will handle discovery natively
19
+ - `skills_use` - OpenCode will handle loading via `use skill <name>` syntax
20
+ - `skills_read` - OpenCode will handle resource access transparently
21
+ - `skills_execute` - OpenCode will handle script execution in skill context
22
+
23
+ **Authoring Tools Kept** (fully functional, no changes):
24
+
25
+ - `skills_create` - Create new skills with SKILL.md template
26
+ - `skills_update` - Update existing skill content
27
+ - `skills_init` - Initialize skills directory in projects
28
+ - `skills_add_script` - Add executable scripts to skills
29
+ - `skills_delete` - Remove project skills
30
+
31
+ **Bundled Skills** - All 6 global skills remain intact and spec-compliant:
32
+
33
+ - `testing-patterns` - Feathers seams + Beck's 4 rules
34
+ - `swarm-coordination` - Multi-agent task orchestration
35
+ - `cli-builder` - Command-line interface patterns
36
+ - `learning-systems` - Confidence decay, pattern maturity
37
+ - `skill-creator` - Meta-skill for authoring new skills
38
+ - `system-design` - Architecture decision frameworks
39
+
40
+ ### Why It Matters
41
+
42
+ **Before:** Two overlapping skill systems causing confusion. Agents could use plugin tools OR OpenCode's native syntax, with different behavior and semantics.
43
+
44
+ **After:** One canonical path. OpenCode owns discovery and loading. Plugin owns authoring and validation. Clean separation of concerns.
45
+
46
+ **Benefits:**
47
+
48
+ - No tool conflicts between plugin and platform
49
+ - Native OpenCode syntax (`use skill testing-patterns`) works seamlessly
50
+ - Simpler mental model for users
51
+ - Authoring tools remain for creating spec-compliant skills
52
+
53
+ ### Migration Path
54
+
55
+ **For Discovery/Loading:**
56
+
57
+ ```typescript
58
+ // OLD (deprecated, still works but warns)
59
+ skills_list()
60
+ skills_use(name="testing-patterns")
61
+
62
+ // NEW (OpenCode native syntax)
63
+ use skill testing-patterns
64
+ use skill cli-builder with "building argument parser"
65
+ ```
66
+
67
+ **For Authoring (no change needed):**
68
+
69
+ ```typescript
70
+ // Still fully supported
71
+ skills_create((name = "my-skill"), (description = "Domain expertise"));
72
+ skills_update((name = "my-skill"), (content = "Updated SKILL.md"));
73
+ skills_add_script(
74
+ (skill_name = "my-skill"),
75
+ (script_name = "validate.ts"),
76
+ (content = "...")
77
+ );
78
+ ```
79
+
80
+ ### Backward Compatibility
81
+
82
+ **Yes, with warnings.** Deprecated tools continue to function but emit console warnings directing users to OpenCode's native syntax. No breaking changes in this release.
83
+
84
+ Future major version (v1.0) will remove deprecated discovery tools entirely. Authoring tools remain permanent.
85
+
86
+ ### What This Means for Bundled Skills
87
+
88
+ Nothing changes. All 6 global skills ship with the plugin and are accessible via OpenCode's native `use skill <name>` syntax. They follow the Agent Skills spec and work identically whether loaded via deprecated plugin tools or native OpenCode.
89
+
90
+ The `global-skills/` directory remains the canonical source for our curated skill library.
91
+
92
+ - [`4feebaf`](https://github.com/joelhooks/swarm-tools/commit/4feebafed61caa8e2e8729b44bd415d71afd6834) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🐝 LLM-Powered Compaction: The Swarm Remembers
93
+
94
+ > "The best way to predict the future is to invent it." — Alan Kay
95
+
96
+ Compaction just got smarter. Instead of static "here's what to preserve" instructions, the swarm now **generates dynamic continuation prompts** with actual state data.
97
+
98
+ **What changed:**
99
+
100
+ The `experimental.session.compacting` hook now uses a three-level fallback chain:
101
+
102
+ 1. **LLM-Generated Prompt** (NEW) - Queries actual swarm state (cells, epics, subtasks), shells out to `opencode run -m <liteModel>` to generate a structured continuation prompt with real IDs, real status, real next actions
103
+ 2. **Static Context** - Falls back to `SWARM_COMPACTION_CONTEXT` if LLM fails
104
+ 3. **Detection Fallback** - For low-confidence swarm detection, injects `SWARM_DETECTION_FALLBACK`
105
+ 4. **None** - No injection if no swarm evidence
106
+
107
+ **Progressive Enhancement:**
108
+
109
+ Uses OpenCode PR #5907's new `output.prompt` API when available:
110
+
111
+ ```typescript
112
+ if ("prompt" in output) {
113
+ output.prompt = llmGeneratedPrompt; // Replaces entire compaction prompt
114
+ } else {
115
+ output.context.push(llmGeneratedPrompt); // Old API fallback
116
+ }
117
+ ```
118
+
119
+ **New interfaces:**
120
+
121
+ - `SwarmStateSnapshot` - Structured state for LLM input
122
+ - `querySwarmState()` - Queries cells via swarm CLI
123
+ - `generateCompactionPrompt()` - Shells out to lite model (30s timeout)
124
+
125
+ **Why it matters:**
126
+
127
+ Before: "Hey, you should preserve swarm state" (agent has to figure out what that means)
128
+ After: "Here's epic bd-xyz with 3/5 subtasks done, bd-xyz.2 is blocked on auth, spawn bd-xyz.4 next"
129
+
130
+ The coordinator wakes up from compaction with **concrete data**, not instructions to go find data.
131
+
132
+ **Backward compatible:** Falls back gracefully on older OpenCode versions or LLM failures.
133
+
134
+ - [`652fd16`](https://github.com/joelhooks/swarm-tools/commit/652fd16ff424eff92ebb3f5da0599caf676de2ce) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🔭 Observability Stack MVP: See What Your Swarm Is Doing
135
+
136
+ > "You can't improve what you can't measure." — Peter Drucker
137
+
138
+ The swarm just got eyes. This release adds comprehensive observability for multi-agent coordination, answering the eternal question: "Why did my epic fail?"
139
+
140
+ ### What's New
141
+
142
+ **Structured Error Classes** (swarm-mail)
143
+
144
+ - `BaseSwarmError` with rich context: agent, bead_id, epic_id, timestamp, recent events
145
+ - Specialized errors: `ReservationError`, `CheckpointError`, `ValidationError`, `DecompositionError`
146
+ - Every error includes actionable suggestions for resolution
147
+ - Full `toJSON()` serialization for logging and debugging
148
+
149
+ **DEBUG Logging** (swarm-mail)
150
+
151
+ - `DEBUG=swarm:*` environment variable filtering
152
+ - 4 subsystems: `swarm:events`, `swarm:reservations`, `swarm:messages`, `swarm:checkpoints`
153
+ - Zero overhead when disabled
154
+
155
+ **swarm-db CLI** (swarm-mail)
156
+
157
+ ```bash
158
+ # Raw SQL queries (SELECT only, max 1000 rows)
159
+ swarm-db query "SELECT type, COUNT(*) FROM events GROUP BY type"
160
+
161
+ # Pre-built analytics
162
+ swarm-db analytics failed-decompositions --since 7d --format json
163
+
164
+ # List available analytics
165
+ swarm-db list
166
+ ```
167
+
168
+ **10 Pre-built Analytics Queries** (Four Golden Signals mapped)
169
+ | Query | What It Answers |
170
+ |-------|-----------------|
171
+ | `failed-decompositions` | Which strategies are failing? |
172
+ | `strategy-success-rates` | What's working? |
173
+ | `lock-contention` | Where are agents fighting over files? |
174
+ | `agent-activity` | Who's doing what? |
175
+ | `message-latency` | How fast is coordination? |
176
+ | `scope-violations` | Who's touching files they shouldn't? |
177
+ | `task-duration` | How long do tasks take? |
178
+ | `checkpoint-frequency` | Are agents checkpointing enough? |
179
+ | `recovery-success` | Do checkpoints actually help? |
180
+ | `human-feedback` | What are reviewers rejecting? |
181
+
182
+ **Agent-Facing Tools** (opencode-swarm-plugin)
183
+
184
+ ```typescript
185
+ // Query analytics programmatically
186
+ swarm_analytics({
187
+ query: "failed-decompositions",
188
+ since: "7d",
189
+ format: "summary",
190
+ });
191
+
192
+ // Raw SQL for power users (max 50 rows, context-safe)
193
+ swarm_query({ sql: "SELECT * FROM events WHERE type = 'task_blocked'" });
194
+
195
+ // Auto-diagnosis for debugging
196
+ swarm_diagnose({
197
+ epic_id: "bd-123",
198
+ include: ["blockers", "errors", "timeline"],
199
+ });
200
+
201
+ // Learning insights for feedback loops
202
+ swarm_insights({ scope: "epic", metrics: ["success_rate", "avg_duration"] });
203
+ ```
204
+
205
+ ### Why This Matters
206
+
207
+ Before: "The swarm failed. No idea why."
208
+ After: "Strategy X failed 80% of the time due to file conflicts. Switching to Y."
209
+
210
+ Event sourcing was already 80% of the solution. This release adds the diagnostic views to make that data actionable.
211
+
212
+ ### Test Coverage
213
+
214
+ - 588 tests passing
215
+ - 1214 assertions
216
+ - Full TDD: every feature started with a failing test
217
+
218
+ - [`ca9936d`](https://github.com/joelhooks/swarm-tools/commit/ca9936d09b749449ef3c88fd3ec8b937f6ed7c29) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🔬 Research Phase: Docs Before Decomposition
219
+
220
+ Swarm coordinators now gather documentation BEFORE breaking down tasks. No more workers fumbling through outdated API assumptions.
221
+
222
+ **What's New:**
223
+
224
+ - **swarm/researcher agent** - READ-ONLY doc gatherer that discovers tools, reads lockfiles, fetches version-specific docs, and stores findings in semantic-memory
225
+ - **Pre-decomposition research** - Coordinator analyzes task → identifies tech stack → spawns researchers → injects findings into shared_context
226
+ - **On-demand research for workers** - Workers can spawn researchers when hitting unknowns mid-task
227
+ - **`--check-upgrades` flag** - Compare installed vs latest versions from npm registry
228
+
229
+ **New Tools:**
230
+
231
+ | Tool | Purpose |
232
+ | ------------------------ | ----------------------------------------------------------- |
233
+ | `swarm_discover_tools` | Runtime discovery of available doc tools (MCP, CLI, skills) |
234
+ | `swarm_get_versions` | Parse lockfiles (npm/pnpm/yarn/bun) for installed versions |
235
+ | `swarm_spawn_researcher` | Generate researcher prompt for Task tool |
236
+ | `swarm_research_phase` | Manual trigger for research orchestration |
237
+
238
+ **Architecture:**
239
+
240
+ ```
241
+ Coordinator receives task
242
+
243
+ runResearchPhase(task, projectPath)
244
+
245
+ extractTechStack() → identify technologies
246
+ discoverDocTools() → find available tools
247
+ getInstalledVersions() → read lockfiles
248
+ Spawn researchers (parallel)
249
+ Collect summaries → shared_context
250
+
251
+ Normal decomposition with enriched context
252
+ ```
253
+
254
+ **Why This Matters:**
255
+
256
+ Workers now start with version-specific documentation instead of hallucinating APIs. Researchers store detailed findings in semantic-memory, so future agents don't repeat the research.
257
+
258
+ ### Patch Changes
259
+
260
+ - Updated dependencies [[`652fd16`](https://github.com/joelhooks/swarm-tools/commit/652fd16ff424eff92ebb3f5da0599caf676de2ce)]:
261
+ - swarm-mail@1.4.0
262
+
263
+ ## 0.32.0
264
+
265
+ ### Minor Changes
266
+
267
+ - [#54](https://github.com/joelhooks/swarm-tools/pull/54) [`358e18f`](https://github.com/joelhooks/swarm-tools/commit/358e18f0f7f18d03492ef16c2c1d3edd85c00101) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🔍 Coordinator Review Gate + UBS Removal
268
+
269
+ > _"This asynchronous back and forth between submitter and reviewer can add days to the process of getting changes made. Do Code Reviews Promptly!"_
270
+ > — Sam Newman, _Building Microservices_
271
+
272
+ Two changes that make swarm coordination tighter:
273
+
274
+ ### Coordinator Review Tools
275
+
276
+ New tools for coordinators to review worker output before approval:
277
+
278
+ ```
279
+ ┌─────────────────────────────────────────────────────┐
280
+ │ COORDINATOR REVIEW FLOW │
281
+ ├─────────────────────────────────────────────────────┤
282
+ │ 1. Worker completes → sends completion message │
283
+ │ 2. Coordinator: swarm_review(task_id, files) │
284
+ │ → Gets diff + epic context + review prompt │
285
+ │ 3. Coordinator reviews against epic goals │
286
+ │ 4. swarm_review_feedback(status, issues) │
287
+ │ → approved: worker can finalize │
288
+ │ → needs_changes: worker gets feedback │
289
+ │ 5. 3-strike rule: 3 rejections = blocked │
290
+ └─────────────────────────────────────────────────────┘
291
+ ```
292
+
293
+ **New tools:**
294
+
295
+ - `swarm_review` - Generate review prompt with epic context + git diff
296
+ - `swarm_review_feedback` - Send approval/rejection with structured issues
297
+
298
+ **Updated prompts:**
299
+
300
+ - Coordinator prompt now includes review checklist
301
+ - Worker prompt explains the review gate
302
+ - Skills updated with review patterns
303
+
304
+ ### UBS Scan Removed from swarm_complete
305
+
306
+ The `skip_ubs_scan` parameter is gone. UBS was already disabled in v0.31 for performance - this cleans up the vestigial code.
307
+
308
+ **Removed:**
309
+
310
+ - `skip_ubs_scan` parameter from schema
311
+ - `ubs_scan` deprecation object from output
312
+ - All UBS-related helper functions
313
+ - ~100 lines of dead code
314
+
315
+ **If you need UBS scanning:** Run it manually before commit:
316
+
317
+ ```bash
318
+ ubs scan src/
319
+ ```
320
+
321
+ ### CLI Improvements
322
+
323
+ The `swarm` CLI got smarter:
324
+
325
+ - Better error messages for missing dependencies
326
+ - Cleaner output formatting
327
+ - Improved help text
328
+
329
+ ### Patch Changes
330
+
331
+ - [#54](https://github.com/joelhooks/swarm-tools/pull/54) [`358e18f`](https://github.com/joelhooks/swarm-tools/commit/358e18f0f7f18d03492ef16c2c1d3edd85c00101) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🧪 Integration Test Coverage: 0% → 95%
332
+
333
+ > _"Many characterization tests look like 'sunny day' tests. They don't test many special conditions; they just verify that particular behaviors are present. From their presence, we can infer that refactoring hasn't broken anything."_
334
+ > — Michael Feathers, _Working Effectively with Legacy Code_
335
+
336
+ We had a bug that broke ALL swarm tools:
337
+
338
+ ```
339
+ Error: [streams/store] dbOverride parameter is required for this function.
340
+ PGlite getDatabase() has been removed.
341
+ ```
342
+
343
+ **Why didn't tests catch it?** No integration tests exercised the full tool → store → DB path.
344
+
345
+ **Now they do.**
346
+
347
+ ```
348
+ ┌─────────────────────────────────────────────────────────────────┐
349
+ │ tool-adapter.integration.test.ts │
350
+ ├─────────────────────────────────────────────────────────────────┤
351
+ │ 20 tests | 75 assertions | 1.3s │
352
+ │ │
353
+ │ ✅ swarmmail_* tools (6 tests) │
354
+ │ ✅ hive_* tools (7 tests) │
355
+ │ ✅ swarm_progress, swarm_status (2 tests) │
356
+ │ ✅ swarm_broadcast, swarm_checkpoint (2 tests) │
357
+ │ ✅ semantic_memory_store, semantic_memory_find (2 tests) │
358
+ │ ✅ Smoke test - 9 tools in sequence (1 test) │
359
+ └─────────────────────────────────────────────────────────────────┘
360
+ ```
361
+
362
+ ### What's Tested
363
+
364
+ Each test calls `tool.execute()` and verifies:
365
+
366
+ 1. No "dbOverride required" error (the bug symptom)
367
+ 2. Tool returns expected structure
368
+ 3. Full path works: tool → store → DB → response
369
+
370
+ ### The Smoke Test
371
+
372
+ Runs 9 tools in sequence to catch interaction bugs:
373
+
374
+ ```
375
+ swarmmail_init → hive_create → swarmmail_reserve → swarm_progress
376
+ → semantic_memory_store → semantic_memory_find → swarmmail_send
377
+ → hive_close → swarmmail_release
378
+ ```
379
+
380
+ If ANY step throws "dbOverride required", the test fails.
381
+
382
+ ### Also Fixed
383
+
384
+ - **Auto-adapter creation** in store.ts - functions now auto-create adapters when not provided
385
+ - **Exported `clearAdapterCache()`** for test isolation
386
+ - **Migrated test files** from old `getDatabase()` to adapter pattern
387
+
388
+ ### Mandatory Coordinator Review Loop
389
+
390
+ Added `COORDINATOR_POST_WORKER_CHECKLIST` constant and `post_completion_instructions` field to `swarm_spawn_subtask`. Coordinators now get explicit instructions to review worker output before spawning the next worker.
391
+
392
+ The "dbOverride required" bug **cannot recur undetected**.
393
+
394
+ - Updated dependencies [[`358e18f`](https://github.com/joelhooks/swarm-tools/commit/358e18f0f7f18d03492ef16c2c1d3edd85c00101), [`358e18f`](https://github.com/joelhooks/swarm-tools/commit/358e18f0f7f18d03492ef16c2c1d3edd85c00101), [`358e18f`](https://github.com/joelhooks/swarm-tools/commit/358e18f0f7f18d03492ef16c2c1d3edd85c00101), [`358e18f`](https://github.com/joelhooks/swarm-tools/commit/358e18f0f7f18d03492ef16c2c1d3edd85c00101)]:
395
+ - swarm-mail@1.3.0
396
+
3
397
  ## 0.31.7
4
398
 
5
399
  ### Patch Changes