opencode-swarm-plugin 0.31.0 → 0.31.1

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.
@@ -1,9 +1,9 @@
1
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 812 modules in 119ms
2
+ Bundled 812 modules in 141ms
3
3
 
4
4
  index.js 1.71 MB (entry point)
5
5
 
6
- Bundled 813 modules in 47ms
6
+ Bundled 813 modules in 37ms
7
7
 
8
8
  plugin.js 1.68 MB (entry point)
9
9
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # opencode-swarm-plugin
2
2
 
3
+ ## 0.31.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`19995a6`](https://github.com/joelhooks/swarm-tools/commit/19995a68dd1283de1d13afa6fc028bd1273d1b27) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🐝 Squashed the BigInt Date Bug
8
+
9
+ PGLite returns BIGINT columns as JavaScript `bigint` type. The `Date` constructor throws when given a bigint:
10
+
11
+ ```javascript
12
+ new Date(1734628445371n); // TypeError: Cannot convert a BigInt value to a number
13
+ ```
14
+
15
+ This caused `Invalid Date` errors in all hive operations (`hive_query`, `hive_create`, etc).
16
+
17
+ **Fix:** Wrap timestamps in `Number()` before passing to `Date`:
18
+
19
+ ```typescript
20
+ // Before (broken)
21
+ new Date(cell.created_at);
22
+
23
+ // After (works with both number and bigint)
24
+ new Date(Number(cell.created_at));
25
+ ```
26
+
27
+ **Files fixed:**
28
+
29
+ - `swarm-mail/src/hive/jsonl.ts` - JSONL export functions
30
+ - `opencode-swarm-plugin/src/hive.ts` - `formatCellForOutput()`
31
+
32
+ **Tests added:** 6 new tests covering bigint date handling edge cases.
33
+
34
+ - Updated dependencies [[`19995a6`](https://github.com/joelhooks/swarm-tools/commit/19995a68dd1283de1d13afa6fc028bd1273d1b27)]:
35
+ - swarm-mail@1.1.1
36
+
3
37
  ## 0.31.0
4
38
 
5
39
  ### Minor Changes
package/dist/index.js CHANGED
@@ -28018,9 +28018,9 @@ function formatCellForOutput(adapterCell) {
28018
28018
  status: adapterCell.status,
28019
28019
  priority: adapterCell.priority,
28020
28020
  issue_type: adapterCell.type,
28021
- created_at: new Date(adapterCell.created_at).toISOString(),
28022
- updated_at: new Date(adapterCell.updated_at).toISOString(),
28023
- closed_at: adapterCell.closed_at ? new Date(adapterCell.closed_at).toISOString() : undefined,
28021
+ created_at: new Date(Number(adapterCell.created_at)).toISOString(),
28022
+ updated_at: new Date(Number(adapterCell.updated_at)).toISOString(),
28023
+ closed_at: adapterCell.closed_at ? new Date(Number(adapterCell.closed_at)).toISOString() : undefined,
28024
28024
  parent_id: adapterCell.parent_id || undefined,
28025
28025
  dependencies: [],
28026
28026
  metadata: {}
package/dist/plugin.js CHANGED
@@ -27774,9 +27774,9 @@ function formatCellForOutput(adapterCell) {
27774
27774
  status: adapterCell.status,
27775
27775
  priority: adapterCell.priority,
27776
27776
  issue_type: adapterCell.type,
27777
- created_at: new Date(adapterCell.created_at).toISOString(),
27778
- updated_at: new Date(adapterCell.updated_at).toISOString(),
27779
- closed_at: adapterCell.closed_at ? new Date(adapterCell.closed_at).toISOString() : undefined,
27777
+ created_at: new Date(Number(adapterCell.created_at)).toISOString(),
27778
+ updated_at: new Date(Number(adapterCell.updated_at)).toISOString(),
27779
+ closed_at: adapterCell.closed_at ? new Date(Number(adapterCell.closed_at)).toISOString() : undefined,
27780
27780
  parent_id: adapterCell.parent_id || undefined,
27781
27781
  dependencies: [],
27782
27782
  metadata: {}
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm-plugin",
3
- "version": "0.31.0",
3
+ "version": "0.31.1",
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",
@@ -39,7 +39,7 @@
39
39
  "gray-matter": "^4.0.3",
40
40
  "ioredis": "^5.4.1",
41
41
  "minimatch": "^10.1.1",
42
- "swarm-mail": "1.1.0",
42
+ "swarm-mail": "1.1.1",
43
43
  "zod": "4.1.8"
44
44
  },
45
45
  "devDependencies": {
@@ -1779,4 +1779,95 @@ describe("beads integration", () => {
1779
1779
  }
1780
1780
  });
1781
1781
  });
1782
+
1783
+ describe("bigint to Date conversion", () => {
1784
+ it("should handle PGLite bigint timestamps correctly in hive_query", async () => {
1785
+ const { mkdirSync, rmSync } = await import("node:fs");
1786
+ const { join } = await import("node:path");
1787
+ const { tmpdir } = await import("node:os");
1788
+
1789
+ const tempProject = join(tmpdir(), `hive-bigint-test-${Date.now()}`);
1790
+ const hiveDir = join(tempProject, ".hive");
1791
+ mkdirSync(hiveDir, { recursive: true });
1792
+
1793
+ const originalDir = getHiveWorkingDirectory();
1794
+ setHiveWorkingDirectory(tempProject);
1795
+
1796
+ try {
1797
+ // Create a cell
1798
+ const createResponse = await hive_create.execute(
1799
+ { title: "Test bigint dates", type: "task" },
1800
+ mockContext
1801
+ );
1802
+ const created = parseResponse<Cell>(createResponse);
1803
+
1804
+ // Query it back - this triggers formatCellForOutput with PGLite bigint timestamps
1805
+ const queryResponse = await hive_query.execute({ status: "open" }, mockContext);
1806
+ const queried = parseResponse<Cell[]>(queryResponse);
1807
+
1808
+ expect(queried.length).toBeGreaterThan(0);
1809
+ const cell = queried.find(c => c.id === created.id);
1810
+ expect(cell).toBeDefined();
1811
+
1812
+ // These should be valid ISO date strings, not "Invalid Date"
1813
+ expect(cell!.created_at).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/);
1814
+ expect(cell!.updated_at).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/);
1815
+ expect(cell!.created_at).not.toBe("Invalid Date");
1816
+ expect(cell!.updated_at).not.toBe("Invalid Date");
1817
+
1818
+ // Verify dates are actually valid by parsing
1819
+ const createdDate = new Date(cell!.created_at);
1820
+ const updatedDate = new Date(cell!.updated_at);
1821
+ expect(createdDate.getTime()).toBeGreaterThan(0);
1822
+ expect(updatedDate.getTime()).toBeGreaterThan(0);
1823
+ } finally {
1824
+ setHiveWorkingDirectory(originalDir);
1825
+ rmSync(tempProject, { recursive: true, force: true });
1826
+ }
1827
+ });
1828
+
1829
+ it("should handle closed_at bigint timestamp correctly", async () => {
1830
+ const { mkdirSync, rmSync } = await import("node:fs");
1831
+ const { join } = await import("node:path");
1832
+ const { tmpdir } = await import("node:os");
1833
+
1834
+ const tempProject = join(tmpdir(), `hive-bigint-closed-test-${Date.now()}`);
1835
+ const hiveDir = join(tempProject, ".hive");
1836
+ mkdirSync(hiveDir, { recursive: true });
1837
+
1838
+ const originalDir = getHiveWorkingDirectory();
1839
+ setHiveWorkingDirectory(tempProject);
1840
+
1841
+ try {
1842
+ // Create and close a cell
1843
+ const createResponse = await hive_create.execute(
1844
+ { title: "Test closed bigint date", type: "task" },
1845
+ mockContext
1846
+ );
1847
+ const created = parseResponse<Cell>(createResponse);
1848
+
1849
+ await hive_close.execute(
1850
+ { id: created.id, reason: "Testing bigint closed_at" },
1851
+ mockContext
1852
+ );
1853
+
1854
+ // Query closed cells
1855
+ const queryResponse = await hive_query.execute({ status: "closed" }, mockContext);
1856
+ const queried = parseResponse<Cell[]>(queryResponse);
1857
+
1858
+ const cell = queried.find(c => c.id === created.id);
1859
+ expect(cell).toBeDefined();
1860
+ expect(cell!.closed_at).toBeDefined();
1861
+ expect(cell!.closed_at).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/);
1862
+ expect(cell!.closed_at).not.toBe("Invalid Date");
1863
+
1864
+ // Verify closed_at is valid
1865
+ const closedDate = new Date(cell!.closed_at!);
1866
+ expect(closedDate.getTime()).toBeGreaterThan(0);
1867
+ } finally {
1868
+ setHiveWorkingDirectory(originalDir);
1869
+ rmSync(tempProject, { recursive: true, force: true });
1870
+ }
1871
+ });
1872
+ });
1782
1873
  });
package/src/hive.ts CHANGED
@@ -587,10 +587,10 @@ function formatCellForOutput(adapterCell: AdapterCell): Record<string, unknown>
587
587
  status: adapterCell.status,
588
588
  priority: adapterCell.priority,
589
589
  issue_type: adapterCell.type, // Adapter: type → Schema: issue_type
590
- created_at: new Date(adapterCell.created_at).toISOString(),
591
- updated_at: new Date(adapterCell.updated_at).toISOString(),
590
+ created_at: new Date(Number(adapterCell.created_at)).toISOString(),
591
+ updated_at: new Date(Number(adapterCell.updated_at)).toISOString(),
592
592
  closed_at: adapterCell.closed_at
593
- ? new Date(adapterCell.closed_at).toISOString()
593
+ ? new Date(Number(adapterCell.closed_at)).toISOString()
594
594
  : undefined,
595
595
  parent_id: adapterCell.parent_id || undefined,
596
596
  dependencies: [], // TODO: fetch from adapter if needed