opencode-swarm-plugin 0.12.31 → 0.13.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 (47) hide show
  1. package/.beads/issues.jsonl +204 -10
  2. package/.opencode/skills/tdd/SKILL.md +182 -0
  3. package/README.md +165 -17
  4. package/bun.lock +23 -0
  5. package/dist/index.js +4020 -438
  6. package/dist/pglite.data +0 -0
  7. package/dist/pglite.wasm +0 -0
  8. package/dist/plugin.js +4008 -514
  9. package/examples/commands/swarm.md +51 -7
  10. package/examples/skills/beads-workflow/SKILL.md +75 -28
  11. package/examples/skills/swarm-coordination/SKILL.md +92 -1
  12. package/global-skills/testing-patterns/SKILL.md +430 -0
  13. package/global-skills/testing-patterns/references/dependency-breaking-catalog.md +586 -0
  14. package/package.json +11 -5
  15. package/src/index.ts +44 -5
  16. package/src/streams/agent-mail.test.ts +777 -0
  17. package/src/streams/agent-mail.ts +535 -0
  18. package/src/streams/debug.test.ts +500 -0
  19. package/src/streams/debug.ts +629 -0
  20. package/src/streams/effect/ask.integration.test.ts +314 -0
  21. package/src/streams/effect/ask.ts +202 -0
  22. package/src/streams/effect/cursor.integration.test.ts +418 -0
  23. package/src/streams/effect/cursor.ts +288 -0
  24. package/src/streams/effect/deferred.test.ts +357 -0
  25. package/src/streams/effect/deferred.ts +445 -0
  26. package/src/streams/effect/index.ts +17 -0
  27. package/src/streams/effect/layers.ts +73 -0
  28. package/src/streams/effect/lock.test.ts +385 -0
  29. package/src/streams/effect/lock.ts +399 -0
  30. package/src/streams/effect/mailbox.test.ts +260 -0
  31. package/src/streams/effect/mailbox.ts +318 -0
  32. package/src/streams/events.test.ts +628 -0
  33. package/src/streams/events.ts +214 -0
  34. package/src/streams/index.test.ts +229 -0
  35. package/src/streams/index.ts +492 -0
  36. package/src/streams/migrations.test.ts +355 -0
  37. package/src/streams/migrations.ts +269 -0
  38. package/src/streams/projections.test.ts +611 -0
  39. package/src/streams/projections.ts +302 -0
  40. package/src/streams/store.integration.test.ts +548 -0
  41. package/src/streams/store.ts +546 -0
  42. package/src/streams/swarm-mail.ts +552 -0
  43. package/src/swarm-mail.integration.test.ts +970 -0
  44. package/src/swarm-mail.ts +739 -0
  45. package/src/swarm.ts +84 -59
  46. package/src/tool-availability.ts +35 -2
  47. package/global-skills/mcp-tool-authoring/SKILL.md +0 -695
package/src/index.ts CHANGED
@@ -17,7 +17,7 @@
17
17
  * @example
18
18
  * ```typescript
19
19
  * // Programmatic usage
20
- * import { beadsTools, agentMailTools } from "opencode-swarm-plugin"
20
+ * import { beadsTools, agentMailTools, swarmMailTools } from "opencode-swarm-plugin"
21
21
  * ```
22
22
  */
23
23
  import type { Plugin, PluginInput, Hooks } from "@opencode-ai/plugin";
@@ -29,6 +29,11 @@ import {
29
29
  type AgentMailState,
30
30
  AGENT_MAIL_URL,
31
31
  } from "./agent-mail";
32
+ import {
33
+ swarmMailTools,
34
+ setSwarmMailProjectDirectory,
35
+ type SwarmMailState,
36
+ } from "./swarm-mail";
32
37
  import { structuredTools } from "./structured";
33
38
  import { swarmTools } from "./swarm";
34
39
  import { repoCrawlTools } from "./repo-crawl";
@@ -39,7 +44,8 @@ import { skillsTools, setSkillsProjectDirectory } from "./skills";
39
44
  *
40
45
  * Registers all swarm coordination tools:
41
46
  * - beads:* - Type-safe beads issue tracker wrappers
42
- * - agent-mail:* - Multi-agent coordination via Agent Mail MCP
47
+ * - agent-mail:* - Multi-agent coordination via Agent Mail MCP (legacy)
48
+ * - swarm-mail:* - Multi-agent coordination with embedded event sourcing (recommended)
43
49
  * - structured:* - Structured output parsing and validation
44
50
  * - swarm:* - Swarm orchestration and task decomposition
45
51
  * - repo-crawl:* - GitHub API tools for repository research
@@ -61,11 +67,15 @@ export const SwarmPlugin: Plugin = async (
61
67
  // Skills are discovered from .opencode/skills/, .claude/skills/, or skills/
62
68
  setSkillsProjectDirectory(directory);
63
69
 
64
- // Set the project directory for Agent Mail
70
+ // Set the project directory for Agent Mail (legacy MCP-based)
65
71
  // This ensures agentmail_init uses the correct project path by default
66
72
  // (prevents using plugin directory when working in a different project)
67
73
  setAgentMailProjectDirectory(directory);
68
74
 
75
+ // Set the project directory for Swarm Mail (embedded event-sourced)
76
+ // This ensures swarmmail_init uses the correct project path by default
77
+ setSwarmMailProjectDirectory(directory);
78
+
69
79
  /** Track active sessions for cleanup */
70
80
  let activeAgentMailState: AgentMailState | null = null;
71
81
 
@@ -119,12 +129,14 @@ export const SwarmPlugin: Plugin = async (
119
129
  *
120
130
  * Tools are namespaced by module:
121
131
  * - beads:create, beads:query, beads:update, etc.
122
- * - agent-mail:init, agent-mail:send, agent-mail:reserve, etc.
132
+ * - agent-mail:init, agent-mail:send, agent-mail:reserve, etc. (legacy MCP)
133
+ * - swarm-mail:init, swarm-mail:send, swarm-mail:reserve, etc. (embedded)
123
134
  * - repo-crawl:readme, repo-crawl:structure, etc.
124
135
  */
125
136
  tool: {
126
137
  ...beadsTools,
127
138
  ...agentMailTools,
139
+ ...swarmMailTools,
128
140
  ...structuredTools,
129
141
  ...swarmTools,
130
142
  ...repoCrawlTools,
@@ -236,7 +248,7 @@ export * from "./schemas";
236
248
  export * from "./beads";
237
249
 
238
250
  /**
239
- * Re-export agent-mail module
251
+ * Re-export agent-mail module (legacy MCP-based)
240
252
  *
241
253
  * Includes:
242
254
  * - agentMailTools - All agent mail tool definitions
@@ -245,6 +257,8 @@ export * from "./beads";
245
257
  *
246
258
  * NOTE: For OpenCode plugin usage, import from "opencode-swarm-plugin/plugin" instead
247
259
  * to avoid the plugin loader trying to call these classes as functions.
260
+ *
261
+ * DEPRECATED: Use swarm-mail module instead for embedded event-sourced implementation.
248
262
  */
249
263
  export {
250
264
  agentMailTools,
@@ -260,6 +274,30 @@ export {
260
274
  type AgentMailState,
261
275
  } from "./agent-mail";
262
276
 
277
+ /**
278
+ * Re-export swarm-mail module (embedded event-sourced)
279
+ *
280
+ * Includes:
281
+ * - swarmMailTools - All swarm mail tool definitions
282
+ * - setSwarmMailProjectDirectory, getSwarmMailProjectDirectory - Directory management
283
+ * - clearSessionState - Session cleanup
284
+ * - SwarmMailState - Session state type
285
+ *
286
+ * Features:
287
+ * - Embedded PGLite storage (no external server dependency)
288
+ * - Event sourcing for full audit trail
289
+ * - Offset-based resumability
290
+ * - Materialized views for fast queries
291
+ * - File reservation with conflict detection
292
+ */
293
+ export {
294
+ swarmMailTools,
295
+ setSwarmMailProjectDirectory,
296
+ getSwarmMailProjectDirectory,
297
+ clearSessionState,
298
+ type SwarmMailState,
299
+ } from "./swarm-mail";
300
+
263
301
  /**
264
302
  * Re-export structured module
265
303
  *
@@ -320,6 +358,7 @@ export {
320
358
  export const allTools = {
321
359
  ...beadsTools,
322
360
  ...agentMailTools,
361
+ ...swarmMailTools,
323
362
  ...structuredTools,
324
363
  ...swarmTools,
325
364
  ...repoCrawlTools,