opencode-swarm-plugin 0.31.6 → 0.31.7

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 79ms
2
+ Bundled 812 modules in 41ms
3
3
 
4
4
  index.js 1.71 MB (entry point)
5
5
 
6
- Bundled 813 modules in 41ms
6
+ Bundled 813 modules in 33ms
7
7
 
8
8
  plugin.js 1.68 MB (entry point)
9
9
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # opencode-swarm-plugin
2
2
 
3
+ ## 0.31.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`97e89a6`](https://github.com/joelhooks/swarm-tools/commit/97e89a6d944b70f205eeb83eb3f2c55a42f5dc08) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🐝 Setup Skips Already-Migrated Memories
8
+
9
+ `swarm setup` now detects when semantic memories have already been migrated and skips the migration prompt entirely.
10
+
11
+ **Before:** Setup would prompt "Migrate to swarm-mail database?" even when all memories were already migrated, then hang.
12
+
13
+ **After:** Setup checks if target database has memories first. If already migrated, shows dim "Already migrated to swarm-mail" and moves on.
14
+
15
+ **Changes:**
16
+
17
+ - Added `targetHasMemories(targetDb)` function to swarm-mail
18
+ - Updated setup flow to check target before prompting
19
+ - Fixed connection cleanup in all code paths (try/finally pattern)
20
+ - Suppressed internal PGLite NOTICE messages from user output
21
+
22
+ **Root cause of hang:** PGLite connection wasn't being closed in all paths, keeping the Node.js event loop alive indefinitely.
23
+
24
+ - Updated dependencies [[`97e89a6`](https://github.com/joelhooks/swarm-tools/commit/97e89a6d944b70f205eeb83eb3f2c55a42f5dc08)]:
25
+ - swarm-mail@1.2.2
26
+
3
27
  ## 0.31.6
4
28
 
5
29
  ### Patch Changes
package/bin/swarm.ts CHANGED
@@ -39,6 +39,7 @@ import {
39
39
  legacyDatabaseExists,
40
40
  getMigrationStatus,
41
41
  migrateLegacyMemories,
42
+ targetHasMemories,
42
43
  } from "swarm-mail";
43
44
  import { getSwarmMail } from "swarm-mail";
44
45
 
@@ -1687,69 +1688,109 @@ async function setup() {
1687
1688
  if (legacyDatabaseExists()) {
1688
1689
  p.log.warn("Found legacy semantic-memory database");
1689
1690
 
1690
- const migrationStatus = await getMigrationStatus();
1691
- if (migrationStatus) {
1692
- const { total, withEmbeddings } = migrationStatus;
1693
- p.log.message(dim(` Memories: ${total} total (${withEmbeddings} with embeddings)`));
1694
- p.log.message(dim(` Will migrate to swarm-mail unified database`));
1691
+ // Check if target database already has memories (already migrated)
1692
+ let swarmMail = null;
1693
+ try {
1694
+ swarmMail = await getSwarmMail(cwd);
1695
+ const targetDb = await swarmMail.getDatabase(cwd);
1696
+ const alreadyMigrated = await targetHasMemories(targetDb);
1695
1697
 
1696
- const shouldMigrate = await p.confirm({
1697
- message: "Migrate to swarm-mail database? (recommended)",
1698
- initialValue: true,
1699
- });
1700
-
1701
- if (p.isCancel(shouldMigrate)) {
1702
- p.cancel("Setup cancelled");
1703
- process.exit(0);
1704
- }
1705
-
1706
- if (shouldMigrate) {
1707
- const migrateSpinner = p.spinner();
1708
- migrateSpinner.start("Connecting to target database...");
1698
+ if (alreadyMigrated) {
1699
+ p.log.message(dim(" Already migrated to swarm-mail"));
1700
+ await swarmMail.close();
1701
+ } else {
1702
+ await swarmMail.close();
1703
+ swarmMail = null;
1709
1704
 
1710
- try {
1711
- // Get swarm-mail database for this project
1712
- const swarmMail = await getSwarmMail(cwd);
1713
- const targetDb = await swarmMail.getDatabase(cwd);
1714
- migrateSpinner.message("Migrating memories...");
1705
+ // Target is empty - show migration status and prompt
1706
+ const migrationStatus = await getMigrationStatus();
1707
+ if (migrationStatus) {
1708
+ const { total, withEmbeddings } = migrationStatus;
1709
+ p.log.message(dim(` Memories: ${total} total (${withEmbeddings} with embeddings)`));
1710
+ p.log.message(dim(` Will migrate to swarm-mail unified database`));
1715
1711
 
1716
- // Run migration with progress updates
1717
- const result = await migrateLegacyMemories({
1718
- targetDb,
1719
- onProgress: (msg) => {
1720
- // Update spinner message for key milestones
1721
- if (msg.includes("complete") || msg.includes("Progress:")) {
1722
- migrateSpinner.message(msg.replace("[migrate] ", ""));
1723
- }
1724
- },
1712
+ const shouldMigrate = await p.confirm({
1713
+ message: "Migrate to swarm-mail database? (recommended)",
1714
+ initialValue: true,
1725
1715
  });
1726
-
1727
- migrateSpinner.stop("Semantic memory migration complete");
1728
-
1729
- if (result.migrated > 0) {
1730
- p.log.success(`Migrated ${result.migrated} memories to swarm-mail`);
1731
- }
1732
- if (result.skipped > 0) {
1733
- p.log.message(dim(` Skipped ${result.skipped} (already exist)`));
1716
+
1717
+ if (p.isCancel(shouldMigrate)) {
1718
+ p.cancel("Setup cancelled");
1719
+ process.exit(0);
1734
1720
  }
1735
- if (result.failed > 0) {
1736
- p.log.warn(`Failed to migrate ${result.failed} memories`);
1737
- for (const error of result.errors.slice(0, 3)) {
1738
- p.log.message(dim(` ${error}`));
1739
- }
1740
- if (result.errors.length > 3) {
1741
- p.log.message(dim(` ... and ${result.errors.length - 3} more errors`));
1721
+
1722
+ if (shouldMigrate) {
1723
+ const migrateSpinner = p.spinner();
1724
+ migrateSpinner.start("Connecting to target database...");
1725
+
1726
+ try {
1727
+ // Get swarm-mail database for this project
1728
+ swarmMail = await getSwarmMail(cwd);
1729
+ const targetDb = await swarmMail.getDatabase(cwd);
1730
+ migrateSpinner.message("Migrating memories...");
1731
+
1732
+ // Run migration with progress updates
1733
+ const result = await migrateLegacyMemories({
1734
+ targetDb,
1735
+ onProgress: (msg) => {
1736
+ // Update spinner message for key milestones
1737
+ if (msg.includes("complete") || msg.includes("Progress:")) {
1738
+ migrateSpinner.message(msg.replace("[migrate] ", ""));
1739
+ }
1740
+ },
1741
+ });
1742
+
1743
+ migrateSpinner.stop("Semantic memory migration complete");
1744
+
1745
+ if (result.migrated > 0) {
1746
+ p.log.success(`Migrated ${result.migrated} memories to swarm-mail`);
1747
+ }
1748
+ if (result.skipped > 0) {
1749
+ p.log.message(dim(` Skipped ${result.skipped} (already exist)`));
1750
+ }
1751
+ if (result.failed > 0) {
1752
+ p.log.warn(`Failed to migrate ${result.failed} memories`);
1753
+ for (const error of result.errors.slice(0, 3)) {
1754
+ p.log.message(dim(` ${error}`));
1755
+ }
1756
+ if (result.errors.length > 3) {
1757
+ p.log.message(dim(` ... and ${result.errors.length - 3} more errors`));
1758
+ }
1759
+ }
1760
+
1761
+ // Close the connection to allow process to exit
1762
+ await swarmMail.close();
1763
+ swarmMail = null;
1764
+ } catch (error) {
1765
+ migrateSpinner.stop("Migration failed");
1766
+ const errorMsg = error instanceof Error ? error.message : String(error);
1767
+ // Hide internal PGLite errors, only show user-actionable messages
1768
+ if (!errorMsg.includes("NOTICE") && !errorMsg.includes("PGlite")) {
1769
+ p.log.error(errorMsg);
1770
+ } else {
1771
+ p.log.warn("Migration encountered an error - please try again");
1772
+ }
1773
+ if (swarmMail) {
1774
+ await swarmMail.close();
1775
+ swarmMail = null;
1776
+ }
1742
1777
  }
1778
+ } else {
1779
+ p.log.warn("Skipping migration - legacy semantic-memory will continue to work but is deprecated");
1743
1780
  }
1744
-
1745
- // Close the connection to allow process to exit
1746
- await swarmMail.close();
1747
- } catch (error) {
1748
- migrateSpinner.stop("Migration failed");
1749
- p.log.error(error instanceof Error ? error.message : String(error));
1750
1781
  }
1782
+ }
1783
+ } catch (error) {
1784
+ // Failed to connect to target database - log and skip
1785
+ const errorMsg = error instanceof Error ? error.message : String(error);
1786
+ // Hide internal PGLite errors
1787
+ if (!errorMsg.includes("NOTICE") && !errorMsg.includes("PGlite")) {
1788
+ p.log.message(dim(` Could not check migration status: ${errorMsg}`));
1751
1789
  } else {
1752
- p.log.warn("Skipping migration - legacy semantic-memory will continue to work but is deprecated");
1790
+ p.log.message(dim(" Could not check migration status - skipping"));
1791
+ }
1792
+ if (swarmMail) {
1793
+ await swarmMail.close();
1753
1794
  }
1754
1795
  }
1755
1796
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm-plugin",
3
- "version": "0.31.6",
3
+ "version": "0.31.7",
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.2.1",
42
+ "swarm-mail": "1.2.2",
43
43
  "zod": "4.1.8"
44
44
  },
45
45
  "devDependencies": {