Skip to content

Commit 302b088

Browse files
committed
refactor: remove obsolete sqlite3 native-binding self-heal
@cursor/sdk@1.0.19 (#28) drops the sqlite3 native addon in favor of Node's built-in node:sqlite, so the self-heal that rebuilt sqlite3's binding under Bun is no longer needed. - Remove src/native-binding.ts and its tests - Drop ensureSqliteBinding() from cursor-runtime loadCursorSdk and the sidecar agent backend (direct SDK import / client delegation) - Remove the now-obsolete sqlite troubleshooting note from README Verified: clean npm ci has no sqlite3, @cursor/sdk@1.0.19 imports cleanly, and the opencode integration smoke test lists Cursor models.
1 parent bff8ccd commit 302b088

6 files changed

Lines changed: 11 additions & 364 deletions

File tree

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,6 @@ Override with `OPENCODE_CURSOR_SIDECAR=1` (always sidecar) or `OPENCODE_CURSOR_S
267267
on your `PATH`. Install Node.js 22+, or force the sidecar with `OPENCODE_CURSOR_SIDECAR=1`.
268268
- **"Running under Bun without a usable Node sidecar" warning.** Install Node.js 22+, or set
269269
`OPENCODE_CURSOR_SIDECAR=0` to accept in-process behavior and silence the warning.
270-
- **"Could not locate the bindings file" / `node_sqlite3.node` not found.** The `@cursor/sdk`
271-
native sqlite3 addon was skipped during Bun install. The plugin self-heals on first load (needs
272-
Node on `PATH`). If that fails, `cd` into the printed sqlite3 directory and run
273-
`npx prebuild-install -r napi`.
274270
- **Plugin enabled but no `cursor` provider/models appear.** Stale opencode plugin cache. Pin an
275271
exact version (`@stablekernel/opencode-cursor@<version>`) or delete
276272
`~/.cache/opencode/packages/` and restart.

src/cursor-runtime.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,21 @@
66
* dependency is missing) degrades gracefully into a clear error instead of
77
* crashing opencode at startup.
88
*/
9-
import { ensureSqliteBinding } from "./native-binding.js";
10-
119
export type CursorSdkModule = typeof import("@cursor/sdk");
1210

1311
let cached: Promise<CursorSdkModule> | undefined;
1412

1513
export async function loadCursorSdk(): Promise<CursorSdkModule> {
1614
if (!cached) {
17-
// @cursor/sdk eagerly requires sqlite3 (native addon); opencode's Bun
18-
// install skips its build script, so repair the binding first if missing.
19-
cached = ensureSqliteBinding()
20-
.then(() => import("@cursor/sdk"))
21-
.catch((err: unknown) => {
22-
// Allow a later retry if the failure was transient.
23-
cached = undefined;
24-
const detail = err instanceof Error ? err.message : String(err);
25-
throw new Error(
26-
`[opencode-cursor] Failed to load "@cursor/sdk". Make sure it is installed ` +
27-
`(\`npm install @cursor/sdk\`). Original error: ${detail}`,
28-
);
29-
});
15+
cached = import("@cursor/sdk").catch((err: unknown) => {
16+
// Allow a later retry if the failure was transient.
17+
cached = undefined;
18+
const detail = err instanceof Error ? err.message : String(err);
19+
throw new Error(
20+
`[opencode-cursor] Failed to load "@cursor/sdk". Make sure it is installed ` +
21+
`(\`npm install @cursor/sdk\`). Original error: ${detail}`,
22+
);
23+
});
3024
}
3125
return cached;
3226
}

src/native-binding.ts

Lines changed: 0 additions & 172 deletions
This file was deleted.

src/provider/agent-backend.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { execSync } from "node:child_process";
1414
import { existsSync } from "node:fs";
1515
import { fileURLToPath } from "node:url";
1616
import { loadCursorSdk } from "../cursor-runtime.js";
17-
import { ensureSqliteBinding } from "../native-binding.js";
1817
import { SidecarClient, type AgentLike } from "./sidecar-client.js";
1918

2019
export type { AgentLike, AgentRunLike, AgentSendOptions } from "./sidecar-client.js";
@@ -94,18 +93,10 @@ export function resolveSidecarScript(): string | undefined {
9493

9594
function sidecarBackend(nodePath: string, scriptPath: string): AgentBackend {
9695
const client = new SidecarClient({ scriptPath, nodePath });
97-
// The sidecar imports @cursor/sdk (which eagerly requires sqlite3's native
98-
// binding) in the child process; repair the binding before first use.
9996
return {
10097
kind: "sidecar",
101-
createAgent: async (options) => {
102-
await ensureSqliteBinding();
103-
return client.createAgent(options);
104-
},
105-
resumeAgent: async (agentId, options) => {
106-
await ensureSqliteBinding();
107-
return client.resumeAgent(agentId, options);
108-
},
98+
createAgent: (options) => client.createAgent(options),
99+
resumeAgent: (agentId, options) => client.resumeAgent(agentId, options),
109100
};
110101
}
111102

test/native-binding-wiring.test.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)