opencode-swarm-plugin 0.31.1 → 0.31.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # opencode-swarm-plugin
2
2
 
3
+ ## 0.31.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`fdddd27`](https://github.com/joelhooks/swarm-tools/commit/fdddd27f9c8627f7de2b9f108827c66c7040b049) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🐝 Short Hashes Now Welcome
8
+
9
+ The WorkerHandoff schema was too strict - it rejected short project names and partial hashes.
10
+
11
+ **Before:** Required 3+ hyphen-separated segments (regex nightmare)
12
+
13
+ ```
14
+ /^[a-z0-9]+(-[a-z0-9]+){2,}(\.[\w-]+)?$/
15
+ ```
16
+
17
+ **After:** Any non-empty string, validated at runtime via `resolvePartialId()`
18
+
19
+ Now you can use:
20
+
21
+ - Full IDs: `opencode-swarm-monorepo-lf2p4u-mjd4pjujc7e`
22
+ - Short hashes: `mjd4pjujc7e`
23
+ - Partial hashes: `mjd4pjuj`
24
+
25
+ The hive tools already had smart ID resolution - we just needed to stop blocking it at the schema level.
26
+
27
+ ## 0.31.2
28
+
29
+ ### Patch Changes
30
+
31
+ - [`d5ec86e`](https://github.com/joelhooks/swarm-tools/commit/d5ec86e77bdb1cd06cf168946aaaff91208dfac1) Thanks [@joelhooks](https://github.com/joelhooks)! - Rebuild with fixed swarm-mail dependency (bigint date fix)
32
+
3
33
  ## 0.31.1
4
34
 
5
35
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm-plugin",
3
- "version": "0.31.1",
3
+ "version": "0.31.3",
4
4
  "description": "Multi-agent swarm coordination for OpenCode with learning capabilities, beads integration, and Agent Mail",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -662,6 +662,39 @@ describe("beads integration", () => {
662
662
  }
663
663
  });
664
664
 
665
+ it("short hashes work with all ID-taking tools", async () => {
666
+ // Use last 6-8 chars of hash (or full hash if short)
667
+ const shortHash = hash.substring(Math.max(0, hash.length - 8));
668
+
669
+ try {
670
+ // Test hive_update
671
+ await hive_update.execute(
672
+ { id: shortHash, description: "Updated via short hash" },
673
+ mockContext,
674
+ );
675
+
676
+ // Test hive_start
677
+ await hive_start.execute({ id: shortHash }, mockContext);
678
+
679
+ // Test hive_close
680
+ const result = await hive_close.execute(
681
+ { id: shortHash, reason: "Closed via short hash" },
682
+ mockContext,
683
+ );
684
+
685
+ expect(result).toContain("Closed");
686
+ expect(result).toContain(fullId);
687
+ } catch (error) {
688
+ // If ambiguous, verify error message is helpful
689
+ if (error instanceof Error && error.message.includes("Ambiguous")) {
690
+ expect(error.message).toMatch(/ambiguous.*multiple/i);
691
+ expect(error.message).toContain(shortHash);
692
+ } else {
693
+ throw error;
694
+ }
695
+ }
696
+ });
697
+
665
698
  describe("hive_update", () => {
666
699
  it("accepts full cell ID (no resolution needed)", async () => {
667
700
  const result = await hive_update.execute(
@@ -81,9 +81,9 @@ describe("WorkerHandoffContractSchema", () => {
81
81
  }
82
82
  });
83
83
 
84
- test("invalid task_id format fails", () => {
84
+ test("empty task_id fails", () => {
85
85
  const invalidContract = {
86
- task_id: "invalid-format", // Missing hash component
86
+ task_id: "", // Empty string not allowed
87
87
  files_owned: ["src/auth.ts"],
88
88
  files_readonly: [],
89
89
  dependencies_completed: [],
@@ -92,6 +92,37 @@ describe("WorkerHandoffContractSchema", () => {
92
92
 
93
93
  const result = WorkerHandoffContractSchema.safeParse(invalidContract);
94
94
  expect(result.success).toBe(false);
95
+ if (!result.success) {
96
+ expect(result.error.issues[0].message).toContain("cannot be empty");
97
+ }
98
+ });
99
+
100
+ test("short project name with hash is valid", () => {
101
+ // Regression test: single-word project names like "swarm-lf2p4u-abc123" should work
102
+ const shortProjectContract = {
103
+ task_id: "swarm-lf2p4u-abc123", // Only 2 segments before timestamp
104
+ files_owned: ["src/auth.ts"],
105
+ files_readonly: [],
106
+ dependencies_completed: [],
107
+ success_criteria: ["Auth works"],
108
+ };
109
+
110
+ const result = WorkerHandoffContractSchema.safeParse(shortProjectContract);
111
+ expect(result.success).toBe(true);
112
+ });
113
+
114
+ test("partial hash is valid (resolvePartialId will expand it)", () => {
115
+ // Partial hashes should be accepted - resolvePartialId will expand them
116
+ const partialHashContract = {
117
+ task_id: "mjd4pjuj", // Short hash only
118
+ files_owned: ["src/auth.ts"],
119
+ files_readonly: [],
120
+ dependencies_completed: [],
121
+ success_criteria: ["Auth works"],
122
+ };
123
+
124
+ const result = WorkerHandoffContractSchema.safeParse(partialHashContract);
125
+ expect(result.success).toBe(true);
95
126
  });
96
127
  });
97
128
 
@@ -18,17 +18,17 @@ import { z } from "zod";
18
18
  export const WorkerHandoffContractSchema = z.object({
19
19
  /**
20
20
  * Cell ID for this subtask.
21
- * Format: `{project}-{hash}` or `{project}-{hash}.{index}`
22
- * Example: `opencode-swarm-monorepo-lf2p4u-abc123`
21
+ * Can be a full cell ID, hash, or partial hash.
22
+ * Examples:
23
+ * - Full ID: `opencode-swarm-monorepo-lf2p4u-abc123`
24
+ * - Hash only: `lf2p4u`
25
+ * - Partial hash: `mjd4pjuj`
23
26
  *
24
- * Requires at least 3 segments (project can be multi-word, must have hash).
27
+ * The hive tools use resolvePartialId() to expand short IDs before lookup.
25
28
  */
26
29
  task_id: z
27
30
  .string()
28
- .regex(
29
- /^[a-z0-9]+(-[a-z0-9]+){2,}(\.[\w-]+)?$/,
30
- "Invalid task ID format (expected: project-slug-hash with minimum 3 segments)",
31
- ),
31
+ .min(1, "Task ID cannot be empty"),
32
32
 
33
33
  /**
34
34
  * Files this worker owns (exclusive write access).