opencode-mem 2.8.9 → 2.9.0
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/README.md +1 -1
- package/dist/config.d.ts +0 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -19
- package/dist/services/sqlite/connection-manager.d.ts.map +1 -1
- package/dist/services/sqlite/connection-manager.js +1 -2
- package/dist/services/sqlite/sqlite-bootstrap.d.ts +2 -2
- package/dist/services/sqlite/sqlite-bootstrap.d.ts.map +1 -1
- package/dist/services/sqlite/sqlite-bootstrap.js +4 -57
- package/native/darwin-arm64/.gitkeep +0 -0
- package/native/darwin-x64/.gitkeep +0 -0
- package/package.json +4 -2
- package/scripts/download-sqlite.ts +62 -0
- package/native/darwin-arm64/libsqlite3.dylib +0 -0
- package/native/darwin-x64/libsqlite3.dylib +0 -0
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Add to your OpenCode configuration at `~/.config/opencode/opencode.json`:
|
|
|
32
32
|
}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
The plugin downloads automatically on next startup. macOS
|
|
35
|
+
The plugin downloads automatically on next startup. On macOS, the plugin automatically downloads a compatible SQLite library during installation. If the download fails, install Homebrew SQLite as fallback: `brew install sqlite`
|
|
36
36
|
|
|
37
37
|
## Usage Examples
|
|
38
38
|
|
package/dist/config.d.ts
CHANGED
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAiaA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;oBAwBb,aAAa,GACb,kBAAkB,GAClB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAwCT,OAAO,GACP,QAAQ;;CAEf,CAAC;AAEF,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
|
package/dist/config.js
CHANGED
|
@@ -91,22 +91,6 @@ const CONFIG_TEMPLATE = `{
|
|
|
91
91
|
"userEmailOverride": "",
|
|
92
92
|
"userNameOverride": "",
|
|
93
93
|
|
|
94
|
-
// ============================================
|
|
95
|
-
// macOS SQLite Extension Loading (REQUIRED FOR macOS)
|
|
96
|
-
// ============================================
|
|
97
|
-
|
|
98
|
-
// macOS users MUST set this to use Homebrew SQLite instead of Apple's SQLite
|
|
99
|
-
// Apple's SQLite disables extension loading which breaks sqlite-vec
|
|
100
|
-
//
|
|
101
|
-
// Common paths:
|
|
102
|
-
// - Homebrew (Intel): "/usr/local/opt/sqlite/lib/libsqlite3.dylib"
|
|
103
|
-
// - Homebrew (Apple Silicon): "/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib"
|
|
104
|
-
//
|
|
105
|
-
// To install: brew install sqlite
|
|
106
|
-
// To find path: brew --prefix sqlite
|
|
107
|
-
//
|
|
108
|
-
// "customSqlitePath": "/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib",
|
|
109
|
-
|
|
110
94
|
// ============================================
|
|
111
95
|
// Embedding Model (for similarity search)
|
|
112
96
|
// ============================================
|
|
@@ -340,9 +324,6 @@ function getEmbeddingDimensions(model) {
|
|
|
340
324
|
}
|
|
341
325
|
export const CONFIG = {
|
|
342
326
|
storagePath: expandPath(fileConfig.storagePath ?? DEFAULTS.storagePath),
|
|
343
|
-
customSqlitePath: fileConfig.customSqlitePath
|
|
344
|
-
? expandPath(fileConfig.customSqlitePath)
|
|
345
|
-
: undefined,
|
|
346
327
|
userEmailOverride: fileConfig.userEmailOverride,
|
|
347
328
|
userNameOverride: fileConfig.userNameOverride,
|
|
348
329
|
embeddingModel: fileConfig.embeddingModel ?? DEFAULTS.embeddingModel,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../../src/services/sqlite/connection-manager.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,QAAQ,sCAAgB,CAAC;AAE/B,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,WAAW,CAAqD;IAExE,OAAO,CAAC,YAAY;
|
|
1
|
+
{"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../../src/services/sqlite/connection-manager.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,QAAQ,sCAAgB,CAAC;AAE/B,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,WAAW,CAAqD;IAExE,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,aAAa;IAoBrB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,QAAQ,CAAC,SAAS;IAiBxD,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IASrC,QAAQ,IAAI,IAAI;IAYhB,aAAa,IAAI,IAAI;CAStB;AAED,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"}
|
|
@@ -22,8 +22,7 @@ export class ConnectionManager {
|
|
|
22
22
|
`This usually means SQLite extension loading is disabled.\n` +
|
|
23
23
|
`On macOS, you must use Homebrew SQLite instead of Apple's SQLite.\n\n` +
|
|
24
24
|
`Solution:\n` +
|
|
25
|
-
`
|
|
26
|
-
`2. Configure customSqlitePath in ~/.config/opencode/opencode-mem.jsonc`);
|
|
25
|
+
` brew install sqlite`);
|
|
27
26
|
}
|
|
28
27
|
this.migrateSchema(db);
|
|
29
28
|
}
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* instantiated, which is required for custom SQLite paths to work on macOS.
|
|
7
7
|
*
|
|
8
8
|
* Issue: https://github.com/tickernelz/opencode-mem/issues/34
|
|
9
|
+
* Issue: https://github.com/tickernelz/opencode-mem/issues/37
|
|
9
10
|
*
|
|
10
11
|
* Loading priority:
|
|
11
|
-
* 1. Bundled dylib (native/darwin-{arch}/libsqlite3.dylib)
|
|
12
|
+
* 1. Bundled dylib (native/darwin-{arch}/libsqlite3.dylib) - downloaded via postinstall
|
|
12
13
|
* 2. Homebrew SQLite (auto-detected common paths)
|
|
13
|
-
* 3. Custom path from config (customSqlitePath)
|
|
14
14
|
*/
|
|
15
15
|
export declare function configureSqlite(): void;
|
|
16
16
|
export declare function getDatabase(): typeof import("bun:sqlite").Database;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/services/sqlite/sqlite-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"sqlite-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/services/sqlite/sqlite-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAwDH,wBAAgB,eAAe,IAAI,IAAI,CAmDtC;AAED,wBAAgB,WAAW,IAAI,cAAc,YAAY,EAAE,QAAQ,CAGlE;AAED,wBAAgB,eAAe,IAAI,MAAM,GAAG,IAAI,CAE/C"}
|
|
@@ -6,25 +6,18 @@
|
|
|
6
6
|
* instantiated, which is required for custom SQLite paths to work on macOS.
|
|
7
7
|
*
|
|
8
8
|
* Issue: https://github.com/tickernelz/opencode-mem/issues/34
|
|
9
|
+
* Issue: https://github.com/tickernelz/opencode-mem/issues/37
|
|
9
10
|
*
|
|
10
11
|
* Loading priority:
|
|
11
|
-
* 1. Bundled dylib (native/darwin-{arch}/libsqlite3.dylib)
|
|
12
|
+
* 1. Bundled dylib (native/darwin-{arch}/libsqlite3.dylib) - downloaded via postinstall
|
|
12
13
|
* 2. Homebrew SQLite (auto-detected common paths)
|
|
13
|
-
* 3. Custom path from config (customSqlitePath)
|
|
14
14
|
*/
|
|
15
15
|
import { existsSync } from "node:fs";
|
|
16
|
-
import { homedir } from "node:os";
|
|
17
16
|
import { join, dirname } from "node:path";
|
|
18
17
|
import { fileURLToPath } from "node:url";
|
|
19
|
-
import { stripJsoncComments } from "../jsonc.js";
|
|
20
18
|
let Database;
|
|
21
19
|
let sqliteConfigured = false;
|
|
22
20
|
let sqliteSource = null;
|
|
23
|
-
const CONFIG_DIR = join(homedir(), ".config", "opencode");
|
|
24
|
-
const CONFIG_FILES = [
|
|
25
|
-
join(CONFIG_DIR, "opencode-mem.jsonc"),
|
|
26
|
-
join(CONFIG_DIR, "opencode-mem.json"),
|
|
27
|
-
];
|
|
28
21
|
function getBundledSqlitePath() {
|
|
29
22
|
if (process.platform !== "darwin")
|
|
30
23
|
return null;
|
|
@@ -41,28 +34,6 @@ function getBundledSqlitePath() {
|
|
|
41
34
|
catch { }
|
|
42
35
|
return null;
|
|
43
36
|
}
|
|
44
|
-
function loadSqliteConfig() {
|
|
45
|
-
for (const path of CONFIG_FILES) {
|
|
46
|
-
if (existsSync(path)) {
|
|
47
|
-
try {
|
|
48
|
-
const content = require("node:fs").readFileSync(path, "utf-8");
|
|
49
|
-
const json = stripJsoncComments(content);
|
|
50
|
-
return JSON.parse(json);
|
|
51
|
-
}
|
|
52
|
-
catch { }
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return {};
|
|
56
|
-
}
|
|
57
|
-
function expandPath(path) {
|
|
58
|
-
if (path.startsWith("~/")) {
|
|
59
|
-
return join(homedir(), path.slice(2));
|
|
60
|
-
}
|
|
61
|
-
if (path === "~") {
|
|
62
|
-
return homedir();
|
|
63
|
-
}
|
|
64
|
-
return path;
|
|
65
|
-
}
|
|
66
37
|
function getHomebrewSqlitePath() {
|
|
67
38
|
const arch = process.arch;
|
|
68
39
|
const paths = arch === "arm64"
|
|
@@ -87,8 +58,6 @@ export function configureSqlite() {
|
|
|
87
58
|
sqliteConfigured = true;
|
|
88
59
|
return;
|
|
89
60
|
}
|
|
90
|
-
const config = loadSqliteConfig();
|
|
91
|
-
const customPath = config.customSqlitePath ? expandPath(config.customSqlitePath) : undefined;
|
|
92
61
|
const trySetCustomSQLite = (path, source) => {
|
|
93
62
|
try {
|
|
94
63
|
Database.setCustomSQLite(path);
|
|
@@ -103,7 +72,6 @@ export function configureSqlite() {
|
|
|
103
72
|
return false;
|
|
104
73
|
}
|
|
105
74
|
};
|
|
106
|
-
// Priority 1: Bundled dylib
|
|
107
75
|
const bundledPath = getBundledSqlitePath();
|
|
108
76
|
if (bundledPath) {
|
|
109
77
|
if (trySetCustomSQLite(bundledPath, "bundled")) {
|
|
@@ -111,20 +79,6 @@ export function configureSqlite() {
|
|
|
111
79
|
return;
|
|
112
80
|
}
|
|
113
81
|
}
|
|
114
|
-
// Priority 2: Custom path from config
|
|
115
|
-
if (customPath) {
|
|
116
|
-
if (!existsSync(customPath)) {
|
|
117
|
-
throw new Error(`Custom SQLite library not found at: ${customPath}\n` +
|
|
118
|
-
`Please verify the path or install Homebrew SQLite:\n` +
|
|
119
|
-
` brew install sqlite\n` +
|
|
120
|
-
` brew --prefix sqlite`);
|
|
121
|
-
}
|
|
122
|
-
if (trySetCustomSQLite(customPath, "custom")) {
|
|
123
|
-
sqliteConfigured = true;
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
// Priority 3: Homebrew SQLite
|
|
128
82
|
const homebrewPath = getHomebrewSqlitePath();
|
|
129
83
|
if (homebrewPath) {
|
|
130
84
|
if (trySetCustomSQLite(homebrewPath, "homebrew")) {
|
|
@@ -132,18 +86,11 @@ export function configureSqlite() {
|
|
|
132
86
|
return;
|
|
133
87
|
}
|
|
134
88
|
}
|
|
135
|
-
// No compatible SQLite found
|
|
136
89
|
throw new Error(`macOS detected but no compatible SQLite library found.\n\n` +
|
|
137
90
|
`Apple's default SQLite does not support extension loading.\n` +
|
|
138
|
-
`
|
|
139
|
-
`
|
|
91
|
+
`Solution:\n\n` +
|
|
92
|
+
`Install Homebrew SQLite:\n` +
|
|
140
93
|
` brew install sqlite\n\n` +
|
|
141
|
-
`Option 2 - Download manually and configure:\n` +
|
|
142
|
-
` 1. Download SQLite with extension support\n` +
|
|
143
|
-
` 2. Add to ~/.config/opencode/opencode-mem.jsonc:\n` +
|
|
144
|
-
` {\n` +
|
|
145
|
-
` "customSqlitePath": "/path/to/libsqlite3.dylib"\n` +
|
|
146
|
-
` }\n\n` +
|
|
147
94
|
`Common Homebrew paths:\n` +
|
|
148
95
|
` - Apple Silicon: /opt/homebrew/opt/sqlite/lib/libsqlite3.dylib\n` +
|
|
149
96
|
` - Intel Mac: /usr/local/opt/sqlite/lib/libsqlite3.dylib`);
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-mem",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "OpenCode plugin that gives coding agents persistent memory using local vector database",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/plugin.js",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"typecheck": "tsc --noEmit",
|
|
12
12
|
"format": "prettier --write \"src/**/*.{ts,js,css,html}\"",
|
|
13
13
|
"format:check": "prettier --check \"src/**/*.{ts,js,css,html}\"",
|
|
14
|
-
"prepare": "husky"
|
|
14
|
+
"prepare": "husky",
|
|
15
|
+
"postinstall": "bun run scripts/download-sqlite.ts"
|
|
15
16
|
},
|
|
16
17
|
"keywords": [
|
|
17
18
|
"opencode",
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
"files": [
|
|
57
58
|
"dist",
|
|
58
59
|
"native",
|
|
60
|
+
"scripts",
|
|
59
61
|
"package.json"
|
|
60
62
|
],
|
|
61
63
|
"lint-staged": {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const GITHUB_REPO = "tickernelz/opencode-mem";
|
|
7
|
+
|
|
8
|
+
function getNativeDir(): string {
|
|
9
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
return join(currentDir, "..", "native");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function downloadDylib(arch: string): boolean {
|
|
14
|
+
const nativeDir = getNativeDir();
|
|
15
|
+
const targetDir = join(nativeDir, `darwin-${arch}`);
|
|
16
|
+
const targetFile = join(targetDir, "libsqlite3.dylib");
|
|
17
|
+
|
|
18
|
+
if (existsSync(targetFile)) {
|
|
19
|
+
console.log(`[opencode-mem] SQLite dylib already exists: ${targetFile}`);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
mkdirSync(targetDir, { recursive: true });
|
|
24
|
+
|
|
25
|
+
const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/latest/download/libsqlite3-darwin-${arch}.dylib`;
|
|
26
|
+
|
|
27
|
+
console.log(`[opencode-mem] Downloading SQLite dylib for darwin-${arch}...`);
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
execSync(`curl -fsSL "${downloadUrl}" -o "${targetFile}"`, {
|
|
31
|
+
timeout: 60000,
|
|
32
|
+
stdio: "pipe",
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (existsSync(targetFile)) {
|
|
36
|
+
console.log(`[opencode-mem] Downloaded SQLite dylib: ${targetFile}`);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.log(`[opencode-mem] Failed to download SQLite dylib: ${error}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log(`[opencode-mem] Will fallback to Homebrew SQLite if available.`);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function main(): void {
|
|
48
|
+
if (process.platform !== "darwin") {
|
|
49
|
+
console.log("[opencode-mem] Skipping SQLite dylib download (not macOS)");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const arch = process.arch;
|
|
54
|
+
if (arch !== "arm64" && arch !== "x64") {
|
|
55
|
+
console.log(`[opencode-mem] Unsupported architecture: ${arch}`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
downloadDylib(arch);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
main();
|
|
Binary file
|
|
Binary file
|