opencode-swarm-plugin 0.26.1 → 0.27.2

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 (77) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +38 -0
  3. package/README.md +43 -46
  4. package/bin/swarm.ts +10 -54
  5. package/dist/compaction-hook.d.ts +57 -0
  6. package/dist/compaction-hook.d.ts.map +1 -0
  7. package/dist/hive.d.ts +741 -0
  8. package/dist/hive.d.ts.map +1 -0
  9. package/dist/index.d.ts +139 -23
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1353 -350
  12. package/dist/learning.d.ts +9 -9
  13. package/dist/plugin.js +1176 -350
  14. package/dist/schemas/cell-events.d.ts +1352 -0
  15. package/dist/schemas/{bead-events.d.ts.map → cell-events.d.ts.map} +1 -1
  16. package/dist/schemas/{bead.d.ts → cell.d.ts} +173 -29
  17. package/dist/schemas/cell.d.ts.map +1 -0
  18. package/dist/schemas/index.d.ts +11 -7
  19. package/dist/schemas/index.d.ts.map +1 -1
  20. package/dist/structured.d.ts +17 -7
  21. package/dist/structured.d.ts.map +1 -1
  22. package/dist/swarm-decompose.d.ts +5 -5
  23. package/dist/swarm-orchestrate.d.ts +16 -2
  24. package/dist/swarm-orchestrate.d.ts.map +1 -1
  25. package/dist/swarm-prompts.d.ts +9 -9
  26. package/dist/swarm-prompts.d.ts.map +1 -1
  27. package/dist/swarm-review.d.ts +210 -0
  28. package/dist/swarm-review.d.ts.map +1 -0
  29. package/dist/swarm-worktree.d.ts +185 -0
  30. package/dist/swarm-worktree.d.ts.map +1 -0
  31. package/dist/swarm.d.ts +7 -0
  32. package/dist/swarm.d.ts.map +1 -1
  33. package/dist/tool-availability.d.ts +3 -2
  34. package/dist/tool-availability.d.ts.map +1 -1
  35. package/docs/analysis-socratic-planner-pattern.md +1 -1
  36. package/docs/planning/ADR-007-swarm-enhancements-worktree-review.md +168 -0
  37. package/docs/testing/context-recovery-test.md +2 -2
  38. package/evals/README.md +2 -2
  39. package/evals/scorers/index.ts +7 -7
  40. package/examples/commands/swarm.md +21 -23
  41. package/examples/plugin-wrapper-template.ts +310 -44
  42. package/examples/skills/{beads-workflow → hive-workflow}/SKILL.md +40 -40
  43. package/examples/skills/swarm-coordination/SKILL.md +1 -1
  44. package/global-skills/swarm-coordination/SKILL.md +14 -14
  45. package/global-skills/swarm-coordination/references/coordinator-patterns.md +3 -3
  46. package/package.json +2 -2
  47. package/src/compaction-hook.ts +161 -0
  48. package/src/{beads.integration.test.ts → hive.integration.test.ts} +92 -80
  49. package/src/{beads.ts → hive.ts} +378 -219
  50. package/src/index.ts +57 -20
  51. package/src/learning.ts +9 -9
  52. package/src/output-guardrails.test.ts +4 -4
  53. package/src/output-guardrails.ts +9 -9
  54. package/src/planning-guardrails.test.ts +1 -1
  55. package/src/planning-guardrails.ts +1 -1
  56. package/src/schemas/{bead-events.test.ts → cell-events.test.ts} +83 -77
  57. package/src/schemas/cell-events.ts +807 -0
  58. package/src/schemas/{bead.ts → cell.ts} +95 -41
  59. package/src/schemas/evaluation.ts +1 -1
  60. package/src/schemas/index.ts +90 -18
  61. package/src/schemas/swarm-context.ts +2 -2
  62. package/src/structured.test.ts +15 -15
  63. package/src/structured.ts +18 -11
  64. package/src/swarm-decompose.ts +23 -23
  65. package/src/swarm-orchestrate.ts +135 -21
  66. package/src/swarm-prompts.ts +43 -43
  67. package/src/swarm-review.test.ts +702 -0
  68. package/src/swarm-review.ts +696 -0
  69. package/src/swarm-worktree.test.ts +501 -0
  70. package/src/swarm-worktree.ts +575 -0
  71. package/src/swarm.integration.test.ts +12 -12
  72. package/src/tool-availability.ts +36 -3
  73. package/dist/beads.d.ts +0 -386
  74. package/dist/beads.d.ts.map +0 -1
  75. package/dist/schemas/bead-events.d.ts +0 -698
  76. package/dist/schemas/bead.d.ts.map +0 -1
  77. package/src/schemas/bead-events.ts +0 -583
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * OpenCode Swarm Plugin
3
3
  *
4
- * A type-safe plugin for multi-agent coordination with beads issue tracking
4
+ * A type-safe plugin for multi-agent coordination with hive issue tracking
5
5
  * and Agent Mail integration. Provides structured tools for swarm operations.
6
6
  *
7
7
  * @module opencode-swarm-plugin
@@ -16,13 +16,18 @@
16
16
  *
17
17
  * @example
18
18
  * ```typescript
19
- * // Programmatic usage
20
- * import { beadsTools, agentMailTools, swarmMailTools } from "opencode-swarm-plugin"
19
+ * // Programmatic usage (hive is the new name, beads is deprecated)
20
+ * import { hiveTools, beadsTools, agentMailTools, swarmMailTools } from "opencode-swarm-plugin"
21
21
  * ```
22
22
  */
23
23
  import type { Plugin, PluginInput, Hooks } from "@opencode-ai/plugin";
24
24
 
25
- import { beadsTools, setBeadsWorkingDirectory } from "./beads";
25
+ import {
26
+ hiveTools,
27
+ beadsTools,
28
+ setHiveWorkingDirectory,
29
+ setBeadsWorkingDirectory,
30
+ } from "./hive";
26
31
  import {
27
32
  agentMailTools,
28
33
  setAgentMailProjectDirectory,
@@ -36,6 +41,8 @@ import {
36
41
  } from "./swarm-mail";
37
42
  import { structuredTools } from "./structured";
38
43
  import { swarmTools } from "./swarm";
44
+ import { worktreeTools } from "./swarm-worktree";
45
+ import { reviewTools } from "./swarm-review";
39
46
  import { repoCrawlTools } from "./repo-crawl";
40
47
  import { skillsTools, setSkillsProjectDirectory } from "./skills";
41
48
  import { mandateTools } from "./mandates";
@@ -53,7 +60,8 @@ import {
53
60
  * OpenCode Swarm Plugin
54
61
  *
55
62
  * Registers all swarm coordination tools:
56
- * - beads:* - Type-safe beads issue tracker wrappers
63
+ * - hive:* - Type-safe hive issue tracker wrappers (primary)
64
+ * - beads:* - Legacy aliases for hive tools (deprecated, use hive:* instead)
57
65
  * - agent-mail:* - Multi-agent coordination via Agent Mail MCP (legacy)
58
66
  * - swarm-mail:* - Multi-agent coordination with embedded event sourcing (recommended)
59
67
  * - structured:* - Structured output parsing and validation
@@ -70,9 +78,9 @@ export const SwarmPlugin: Plugin = async (
70
78
  ): Promise<Hooks> => {
71
79
  const { $, directory } = input;
72
80
 
73
- // Set the working directory for beads commands
74
- // This ensures bd runs in the project directory, not ~/.config/opencode
75
- setBeadsWorkingDirectory(directory);
81
+ // Set the working directory for hive commands
82
+ // This ensures hive operations run in the project directory, not ~/.config/opencode
83
+ setHiveWorkingDirectory(directory);
76
84
 
77
85
  // Set the project directory for skills discovery
78
86
  // Skills are discovered from .opencode/skills/, .claude/skills/, or skills/
@@ -136,17 +144,20 @@ export const SwarmPlugin: Plugin = async (
136
144
  * Register all tools from modules
137
145
  *
138
146
  * Tools are namespaced by module:
139
- * - beads:create, beads:query, beads:update, etc.
147
+ * - hive:create, hive:query, hive:update, etc. (primary)
148
+ * - beads:* - Legacy aliases (deprecated, use hive:* instead)
140
149
  * - agent-mail:init, agent-mail:send, agent-mail:reserve, etc. (legacy MCP)
141
150
  * - swarm-mail:init, swarm-mail:send, swarm-mail:reserve, etc. (embedded)
142
151
  * - repo-crawl:readme, repo-crawl:structure, etc.
143
152
  * - mandate:file, mandate:vote, mandate:query, etc.
144
153
  */
145
154
  tool: {
146
- ...beadsTools,
155
+ ...hiveTools,
147
156
  ...swarmMailTools,
148
157
  ...structuredTools,
149
158
  ...swarmTools,
159
+ ...worktreeTools,
160
+ ...reviewTools,
150
161
  ...repoCrawlTools,
151
162
  ...skillsTools,
152
163
  ...mandateTools,
@@ -187,8 +198,8 @@ export const SwarmPlugin: Plugin = async (
187
198
  * Hook after tool execution for automatic cleanup and guardrails
188
199
  *
189
200
  * - Applies output guardrails to prevent context blowout from MCP tools
190
- * - Auto-releases file reservations after swarm:complete or beads:close
191
- * - Auto-syncs beads after closing
201
+ * - Auto-releases file reservations after swarm:complete or hive:close
202
+ * - Auto-syncs cells after closing
192
203
  */
193
204
  "tool.execute.after": async (input, output) => {
194
205
  const toolName = input.tool;
@@ -238,8 +249,8 @@ export const SwarmPlugin: Plugin = async (
238
249
  await releaseReservations();
239
250
  }
240
251
 
241
- // Auto-sync beads after closing
242
- if (toolName === "beads_close") {
252
+ // Auto-sync hive after closing (supports both hive_close and legacy hive_close)
253
+ if (toolName === "hive_close" || toolName === "hive_close") {
243
254
  // Trigger async sync without blocking - fire and forget
244
255
  void $`bd sync`.quiet().nothrow();
245
256
  }
@@ -267,14 +278,18 @@ export default SwarmPlugin;
267
278
  export * from "./schemas";
268
279
 
269
280
  /**
270
- * Re-export beads module
281
+ * Re-export hive module (primary) and beads module (deprecated aliases)
271
282
  *
272
283
  * Includes:
273
- * - beadsTools - All bead tool definitions
274
- * - Individual tool exports (beads_create, beads_query, etc.)
275
- * - BeadError, BeadValidationError - Error classes
284
+ * - hiveTools - All hive tool definitions (primary)
285
+ * - beadsTools - Legacy aliases for backward compatibility (deprecated)
286
+ * - Individual tool exports (hive_create, hive_query, etc.)
287
+ * - Legacy aliases (hive_create, hive_query, etc.)
288
+ * - HiveError, HiveValidationError (and BeadError, BeadValidationError aliases)
289
+ *
290
+ * DEPRECATED: Use hive_* tools instead of beads_* tools
276
291
  */
277
- export * from "./beads";
292
+ export * from "./hive";
278
293
 
279
294
  /**
280
295
  * Re-export agent-mail module (legacy MCP-based)
@@ -391,12 +406,16 @@ export {
391
406
  *
392
407
  * This is used by `swarm tool <name>` command to dynamically execute tools.
393
408
  * Each tool has an `execute` function that takes (args, ctx) and returns a string.
409
+ *
410
+ * Note: hiveTools includes both hive_* and beads_* (legacy aliases)
394
411
  */
395
412
  export const allTools = {
396
- ...beadsTools,
413
+ ...hiveTools,
397
414
  ...swarmMailTools,
398
415
  ...structuredTools,
399
416
  ...swarmTools,
417
+ ...worktreeTools,
418
+ ...reviewTools,
400
419
  ...repoCrawlTools,
401
420
  ...skillsTools,
402
421
  ...mandateTools,
@@ -609,3 +628,21 @@ export {
609
628
  type GuardrailResult,
610
629
  type GuardrailMetrics,
611
630
  } from "./output-guardrails";
631
+
632
+ /**
633
+ * Re-export compaction-hook module
634
+ *
635
+ * Includes:
636
+ * - SWARM_COMPACTION_CONTEXT - Prompt text for swarm state preservation
637
+ * - createCompactionHook - Factory function for the compaction hook
638
+ *
639
+ * Usage:
640
+ * ```typescript
641
+ * import { createCompactionHook } from "opencode-swarm-plugin";
642
+ *
643
+ * const hooks = {
644
+ * "experimental.session.compacting": createCompactionHook(),
645
+ * };
646
+ * ```
647
+ */
648
+ export { SWARM_COMPACTION_CONTEXT, createCompactionHook } from "./compaction-hook";
package/src/learning.ts CHANGED
@@ -599,7 +599,7 @@ export class InMemoryStrikeStorage implements StrikeStorage {
599
599
  *
600
600
  * Records a failure attempt and increments the strike count.
601
601
  *
602
- * @param beadId - Bead ID
602
+ * @param beadId - Cell ID
603
603
  * @param attempt - Description of what was attempted
604
604
  * @param reason - Why it failed
605
605
  * @param storage - Strike storage (defaults to in-memory)
@@ -635,7 +635,7 @@ export async function addStrike(
635
635
  /**
636
636
  * Get strike count for a bead
637
637
  *
638
- * @param beadId - Bead ID
638
+ * @param beadId - Cell ID
639
639
  * @param storage - Strike storage
640
640
  * @returns Strike count (0-3)
641
641
  */
@@ -650,7 +650,7 @@ export async function getStrikes(
650
650
  /**
651
651
  * Check if a bead has struck out (3 strikes)
652
652
  *
653
- * @param beadId - Bead ID
653
+ * @param beadId - Cell ID
654
654
  * @param storage - Strike storage
655
655
  * @returns True if bead has 3 strikes
656
656
  */
@@ -668,7 +668,7 @@ export async function isStrikedOut(
668
668
  * When a bead hits 3 strikes, this generates a prompt that forces
669
669
  * the human to question the architecture instead of attempting Fix #4.
670
670
  *
671
- * @param beadId - Bead ID
671
+ * @param beadId - Cell ID
672
672
  * @param storage - Strike storage
673
673
  * @returns Architecture review prompt
674
674
  */
@@ -711,7 +711,7 @@ This pattern suggests an **architectural problem**, not a bug.
711
711
  /**
712
712
  * Clear strikes for a bead (e.g., after successful fix)
713
713
  *
714
- * @param beadId - Bead ID
714
+ * @param beadId - Cell ID
715
715
  * @param storage - Strike storage
716
716
  */
717
717
  export async function clearStrikes(
@@ -793,7 +793,7 @@ export class ErrorAccumulator {
793
793
  /**
794
794
  * Record an error during subtask execution
795
795
  *
796
- * @param beadId - Bead ID where error occurred
796
+ * @param beadId - Cell ID where error occurred
797
797
  * @param errorType - Category of error
798
798
  * @param message - Human-readable error message
799
799
  * @param options - Additional context (stack trace, tool name, etc.)
@@ -963,7 +963,7 @@ export class ErrorAccumulator {
963
963
  /**
964
964
  * Format memory store instruction for successful task completion
965
965
  *
966
- * @param beadId - Bead ID that completed
966
+ * @param beadId - Cell ID that completed
967
967
  * @param summary - Completion summary
968
968
  * @param filesTouched - Files modified
969
969
  * @param strategy - Decomposition strategy used (if applicable)
@@ -994,7 +994,7 @@ Files touched: ${filesTouched.join(", ") || "none"}`,
994
994
  /**
995
995
  * Format memory store instruction for architectural problems (3-strike)
996
996
  *
997
- * @param beadId - Bead ID that struck out
997
+ * @param beadId - Cell ID that struck out
998
998
  * @param failures - Array of failure attempts
999
999
  * @returns Memory store instruction object
1000
1000
  */
@@ -1048,7 +1048,7 @@ export function formatMemoryQueryForDecomposition(
1048
1048
  /**
1049
1049
  * Format memory validation hint when CASS history helped
1050
1050
  *
1051
- * @param beadId - Bead ID that benefited from CASS
1051
+ * @param beadId - Cell ID that benefited from CASS
1052
1052
  * @returns Memory validation hint
1053
1053
  */
1054
1054
  export function formatMemoryValidationHint(beadId: string): {
@@ -203,7 +203,7 @@ describe("guardrailOutput", () => {
203
203
  const longOutput = "a".repeat(50000);
204
204
 
205
205
  // Beads tools should never be truncated
206
- const result = guardrailOutput("beads_create", longOutput);
206
+ const result = guardrailOutput("hive_create", longOutput);
207
207
 
208
208
  expect(result.truncated).toBe(false);
209
209
  expect(result.output).toBe(longOutput);
@@ -281,7 +281,7 @@ describe("guardrailOutput", () => {
281
281
 
282
282
  // Test a sample of skip tools
283
283
  const samplesToTest = [
284
- "beads_create",
284
+ "hive_create",
285
285
  "agentmail_send",
286
286
  "swarmmail_inbox",
287
287
  "structured_validate",
@@ -361,8 +361,8 @@ describe("DEFAULT_GUARDRAIL_CONFIG", () => {
361
361
 
362
362
  // Sample of tools that should be in skipTools
363
363
  const expectedSkips = [
364
- "beads_create",
365
- "beads_sync",
364
+ "hive_create",
365
+ "hive_sync",
366
366
  "agentmail_init",
367
367
  "swarmmail_send",
368
368
  "structured_parse_evaluation",
@@ -109,14 +109,14 @@ export const DEFAULT_GUARDRAIL_CONFIG: GuardrailConfig = {
109
109
 
110
110
  skipTools: [
111
111
  // Beads tools - always return full output
112
- "beads_create",
113
- "beads_create_epic",
114
- "beads_query",
115
- "beads_update",
116
- "beads_close",
117
- "beads_start",
118
- "beads_ready",
119
- "beads_sync",
112
+ "hive_create",
113
+ "hive_create_epic",
114
+ "hive_query",
115
+ "hive_update",
116
+ "hive_close",
117
+ "hive_start",
118
+ "hive_ready",
119
+ "hive_sync",
120
120
 
121
121
  // Agent Mail tools - always return full output
122
122
  "agentmail_init",
@@ -142,7 +142,7 @@ export const DEFAULT_GUARDRAIL_CONFIG: GuardrailConfig = {
142
142
  "structured_validate",
143
143
  "structured_parse_evaluation",
144
144
  "structured_parse_decomposition",
145
- "structured_parse_bead_tree",
145
+ "structured_parse_cell_tree",
146
146
 
147
147
  // Swarm orchestration tools - always return full output
148
148
  "swarm_select_strategy",
@@ -9,7 +9,7 @@ describe("planning-guardrails", () => {
9
9
  });
10
10
 
11
11
  it("returns false for other tools", () => {
12
- expect(shouldAnalyzeTool("beads_create")).toBe(false);
12
+ expect(shouldAnalyzeTool("hive_create")).toBe(false);
13
13
  expect(shouldAnalyzeTool("swarm_decompose")).toBe(false);
14
14
  expect(shouldAnalyzeTool("read")).toBe(false);
15
15
  });
@@ -122,7 +122,7 @@ export function analyzeTodoWrite(args: { todos?: unknown[] }): TodoWriteAnalysis
122
122
  warning: `⚠️ This looks like a multi-file implementation plan (${fileModificationCount}/${todos.length} items are file modifications).
123
123
 
124
124
  Consider using swarm instead:
125
- swarm_decompose → beads_create_epic → parallel task spawns
125
+ swarm_decompose → hive_create_epic → parallel task spawns
126
126
 
127
127
  TodoWrite is for tracking progress, not parallelizable implementation work.
128
128
  Swarm workers can complete these ${fileModificationCount} tasks in parallel.