opencode-mem 2.8.7 → 2.8.8
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/dist/services/ai/session/ai-session-manager.d.ts.map +1 -1
- package/dist/services/ai/session/ai-session-manager.js +2 -1
- package/dist/services/sqlite/connection-manager.d.ts +3 -4
- package/dist/services/sqlite/connection-manager.d.ts.map +1 -1
- package/dist/services/sqlite/connection-manager.js +2 -72
- package/dist/services/sqlite/shard-manager.d.ts.map +1 -1
- package/dist/services/sqlite/shard-manager.js +2 -1
- package/dist/services/sqlite/sqlite-bootstrap.d.ts +18 -0
- package/dist/services/sqlite/sqlite-bootstrap.d.ts.map +1 -0
- package/dist/services/sqlite/sqlite-bootstrap.js +158 -0
- package/dist/services/sqlite/vector-search.d.ts +15 -13
- package/dist/services/sqlite/vector-search.d.ts.map +1 -1
- package/dist/services/sqlite/vector-search.js +2 -1
- package/dist/services/user-profile/user-profile-manager.d.ts.map +1 -1
- package/dist/services/user-profile/user-profile-manager.js +2 -1
- package/dist/services/user-prompt/user-prompt-manager.d.ts.map +1 -1
- package/dist/services/user-prompt/user-prompt-manager.js +2 -1
- package/native/darwin-arm64/libsqlite3.dylib +0 -0
- package/native/darwin-x64/libsqlite3.dylib +0 -0
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-session-manager.d.ts","sourceRoot":"","sources":["../../../../src/services/ai/session/ai-session-manager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACV,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-session-manager.d.ts","sourceRoot":"","sources":["../../../../src/services/ai/session/ai-session-manager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACV,MAAM,oBAAoB,CAAC;AAS5B,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,EAAE,CAAe;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAS;;IAS5C,OAAO,CAAC,YAAY;IAyCpB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,SAAS,GAAG,IAAI;IAYzE,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS;IA2BrD,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI;IA8B9F,sBAAsB,IAAI,MAAM;IAKhC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI;IAOhE,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,IAAI;IAmB9D,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE;IAS7C,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAS5C,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAIxC,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,YAAY;CAarB;AAED,eAAO,MAAM,gBAAgB,kBAAyB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getDatabase } from "../../sqlite/sqlite-bootstrap.js";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { connectionManager } from "../../sqlite/connection-manager.js";
|
|
4
4
|
import { CONFIG } from "../../../config.js";
|
|
5
|
+
const Database = getDatabase();
|
|
5
6
|
const AI_SESSIONS_DB_NAME = "ai-sessions.db";
|
|
6
7
|
export class AISessionManager {
|
|
7
8
|
db;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
declare const Database: typeof import("bun:sqlite").Database;
|
|
2
2
|
export declare class ConnectionManager {
|
|
3
3
|
private connections;
|
|
4
|
-
private sqliteConfigured;
|
|
5
|
-
private configureSqlite;
|
|
6
4
|
private initDatabase;
|
|
7
5
|
private migrateSchema;
|
|
8
|
-
getConnection(dbPath: string): Database;
|
|
6
|
+
getConnection(dbPath: string): typeof Database.prototype;
|
|
9
7
|
closeConnection(dbPath: string): void;
|
|
10
8
|
closeAll(): void;
|
|
11
9
|
checkpointAll(): void;
|
|
12
10
|
}
|
|
13
11
|
export declare const connectionManager: ConnectionManager;
|
|
12
|
+
export {};
|
|
14
13
|
//# sourceMappingURL=connection-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../../src/services/sqlite/connection-manager.ts"],"names":[],"mappings":"
|
|
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;IAwBpB,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"}
|
|
@@ -1,81 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getDatabase } from "./sqlite-bootstrap.js";
|
|
2
2
|
import * as sqliteVec from "sqlite-vec";
|
|
3
3
|
import { existsSync, mkdirSync } from "node:fs";
|
|
4
4
|
import { dirname } from "node:path";
|
|
5
5
|
import { log } from "../logger.js";
|
|
6
6
|
import { CONFIG } from "../../config.js";
|
|
7
|
+
const Database = getDatabase();
|
|
7
8
|
export class ConnectionManager {
|
|
8
9
|
connections = new Map();
|
|
9
|
-
sqliteConfigured = false;
|
|
10
|
-
configureSqlite() {
|
|
11
|
-
if (this.sqliteConfigured)
|
|
12
|
-
return;
|
|
13
|
-
if (process.platform === "darwin") {
|
|
14
|
-
const customPath = CONFIG.customSqlitePath;
|
|
15
|
-
if (customPath) {
|
|
16
|
-
if (!existsSync(customPath)) {
|
|
17
|
-
throw new Error(`Custom SQLite library not found at: ${customPath}\n` +
|
|
18
|
-
`Please verify the path or install Homebrew SQLite:\n` +
|
|
19
|
-
` brew install sqlite\n` +
|
|
20
|
-
` brew --prefix sqlite`);
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
Database.setCustomSQLite(customPath);
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
const errorStr = String(error);
|
|
27
|
-
if (errorStr.includes("SQLite already loaded")) {
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
throw new Error(`Failed to load custom SQLite library: ${error}\n` + `Path: ${customPath}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
const commonPaths = [
|
|
36
|
-
"/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib",
|
|
37
|
-
"/usr/local/opt/sqlite/lib/libsqlite3.dylib",
|
|
38
|
-
];
|
|
39
|
-
let foundPath = null;
|
|
40
|
-
for (const path of commonPaths) {
|
|
41
|
-
if (existsSync(path)) {
|
|
42
|
-
foundPath = path;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (foundPath) {
|
|
47
|
-
try {
|
|
48
|
-
Database.setCustomSQLite(foundPath);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
const errorStr = String(error);
|
|
52
|
-
if (errorStr.includes("SQLite already loaded")) {
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
throw new Error(`Failed to load Homebrew SQLite: ${error}\n` + `Path: ${foundPath}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
throw new Error(`macOS detected but no compatible SQLite library found.\n\n` +
|
|
61
|
-
`Apple's default SQLite does not support extension loading.\n` +
|
|
62
|
-
`Please install Homebrew SQLite and configure the path:\n\n` +
|
|
63
|
-
`1. Install Homebrew SQLite:\n` +
|
|
64
|
-
` brew install sqlite\n\n` +
|
|
65
|
-
`2. Find the library path:\n` +
|
|
66
|
-
` brew --prefix sqlite\n\n` +
|
|
67
|
-
`3. Add to ~/.config/opencode/opencode-mem.jsonc:\n` +
|
|
68
|
-
` {\n` +
|
|
69
|
-
` "customSqlitePath": "/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib"\n` +
|
|
70
|
-
` }\n\n` +
|
|
71
|
-
`Common paths:\n` +
|
|
72
|
-
` - Apple Silicon: /opt/homebrew/opt/sqlite/lib/libsqlite3.dylib\n` +
|
|
73
|
-
` - Intel Mac: /usr/local/opt/sqlite/lib/libsqlite3.dylib`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
this.sqliteConfigured = true;
|
|
78
|
-
}
|
|
79
10
|
initDatabase(db) {
|
|
80
11
|
db.run("PRAGMA busy_timeout = 5000");
|
|
81
12
|
db.run("PRAGMA journal_mode = WAL");
|
|
@@ -118,7 +49,6 @@ export class ConnectionManager {
|
|
|
118
49
|
if (this.connections.has(dbPath)) {
|
|
119
50
|
return this.connections.get(dbPath);
|
|
120
51
|
}
|
|
121
|
-
this.configureSqlite();
|
|
122
52
|
const dir = dirname(dbPath);
|
|
123
53
|
if (!existsSync(dir)) {
|
|
124
54
|
mkdirSync(dir, { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shard-manager.d.ts","sourceRoot":"","sources":["../../../src/services/sqlite/shard-manager.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"shard-manager.d.ts","sourceRoot":"","sources":["../../../src/services/sqlite/shard-manager.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAO5C,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAe;IACjC,OAAO,CAAC,YAAY,CAAS;;IAQ7B,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,iBAAiB;IAKzB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAsB9E,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE;IAgCvE,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS;IA2BxF,OAAO,CAAC,WAAW;IA2DnB;;;OAGG;IACH,OAAO,CAAC,YAAY;IA4BpB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAYzB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS;IAmCtE,OAAO,CAAC,iBAAiB;IAOzB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAO3C,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAO3C,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAkBhD,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAwBnC;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getDatabase } from "./sqlite-bootstrap.js";
|
|
2
2
|
import { join, basename, isAbsolute } from "node:path";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { CONFIG } from "../../config.js";
|
|
5
5
|
import { connectionManager } from "./connection-manager.js";
|
|
6
6
|
import { log } from "../logger.js";
|
|
7
|
+
const Database = getDatabase();
|
|
7
8
|
const METADATA_DB_NAME = "metadata.db";
|
|
8
9
|
export class ShardManager {
|
|
9
10
|
metadataDb;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite Bootstrap Module
|
|
3
|
+
*
|
|
4
|
+
* This module MUST be imported before any other module that uses bun:sqlite.
|
|
5
|
+
* It ensures that setCustomSQLite() is called BEFORE the Database class is
|
|
6
|
+
* instantiated, which is required for custom SQLite paths to work on macOS.
|
|
7
|
+
*
|
|
8
|
+
* Issue: https://github.com/tickernelz/opencode-mem/issues/34
|
|
9
|
+
*
|
|
10
|
+
* Loading priority:
|
|
11
|
+
* 1. Bundled dylib (native/darwin-{arch}/libsqlite3.dylib)
|
|
12
|
+
* 2. Homebrew SQLite (auto-detected common paths)
|
|
13
|
+
* 3. Custom path from config (customSqlitePath)
|
|
14
|
+
*/
|
|
15
|
+
export declare function configureSqlite(): void;
|
|
16
|
+
export declare function getDatabase(): typeof import("bun:sqlite").Database;
|
|
17
|
+
export declare function getSqliteSource(): string | null;
|
|
18
|
+
//# sourceMappingURL=sqlite-bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/services/sqlite/sqlite-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA2FH,wBAAgB,eAAe,IAAI,IAAI,CAgFtC;AAED,wBAAgB,WAAW,IAAI,cAAc,YAAY,EAAE,QAAQ,CAGlE;AAED,wBAAgB,eAAe,IAAI,MAAM,GAAG,IAAI,CAE/C"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite Bootstrap Module
|
|
3
|
+
*
|
|
4
|
+
* This module MUST be imported before any other module that uses bun:sqlite.
|
|
5
|
+
* It ensures that setCustomSQLite() is called BEFORE the Database class is
|
|
6
|
+
* instantiated, which is required for custom SQLite paths to work on macOS.
|
|
7
|
+
*
|
|
8
|
+
* Issue: https://github.com/tickernelz/opencode-mem/issues/34
|
|
9
|
+
*
|
|
10
|
+
* Loading priority:
|
|
11
|
+
* 1. Bundled dylib (native/darwin-{arch}/libsqlite3.dylib)
|
|
12
|
+
* 2. Homebrew SQLite (auto-detected common paths)
|
|
13
|
+
* 3. Custom path from config (customSqlitePath)
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync } from "node:fs";
|
|
16
|
+
import { homedir } from "node:os";
|
|
17
|
+
import { join, dirname } from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
import { stripJsoncComments } from "../jsonc.js";
|
|
20
|
+
let Database;
|
|
21
|
+
let sqliteConfigured = false;
|
|
22
|
+
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
|
+
function getBundledSqlitePath() {
|
|
29
|
+
if (process.platform !== "darwin")
|
|
30
|
+
return null;
|
|
31
|
+
const arch = process.arch;
|
|
32
|
+
if (arch !== "x64" && arch !== "arm64")
|
|
33
|
+
return null;
|
|
34
|
+
try {
|
|
35
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
36
|
+
const bundledPath = join(currentDir, "..", "..", "..", "native", `darwin-${arch}`, "libsqlite3.dylib");
|
|
37
|
+
if (existsSync(bundledPath)) {
|
|
38
|
+
return bundledPath;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch { }
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
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
|
+
function getHomebrewSqlitePath() {
|
|
67
|
+
const arch = process.arch;
|
|
68
|
+
const paths = arch === "arm64"
|
|
69
|
+
? ["/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib"]
|
|
70
|
+
: [
|
|
71
|
+
"/usr/local/opt/sqlite/lib/libsqlite3.dylib",
|
|
72
|
+
"/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib",
|
|
73
|
+
];
|
|
74
|
+
for (const path of paths) {
|
|
75
|
+
if (existsSync(path)) {
|
|
76
|
+
return path;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
export function configureSqlite() {
|
|
82
|
+
if (sqliteConfigured)
|
|
83
|
+
return;
|
|
84
|
+
const bunSqlite = require("bun:sqlite");
|
|
85
|
+
Database = bunSqlite.Database;
|
|
86
|
+
if (process.platform !== "darwin") {
|
|
87
|
+
sqliteConfigured = true;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const config = loadSqliteConfig();
|
|
91
|
+
const customPath = config.customSqlitePath ? expandPath(config.customSqlitePath) : undefined;
|
|
92
|
+
const trySetCustomSQLite = (path, source) => {
|
|
93
|
+
try {
|
|
94
|
+
Database.setCustomSQLite(path);
|
|
95
|
+
sqliteSource = source;
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
const errorStr = String(error);
|
|
100
|
+
if (errorStr.includes("SQLite already loaded")) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
// Priority 1: Bundled dylib
|
|
107
|
+
const bundledPath = getBundledSqlitePath();
|
|
108
|
+
if (bundledPath) {
|
|
109
|
+
if (trySetCustomSQLite(bundledPath, "bundled")) {
|
|
110
|
+
sqliteConfigured = true;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
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
|
+
const homebrewPath = getHomebrewSqlitePath();
|
|
129
|
+
if (homebrewPath) {
|
|
130
|
+
if (trySetCustomSQLite(homebrewPath, "homebrew")) {
|
|
131
|
+
sqliteConfigured = true;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// No compatible SQLite found
|
|
136
|
+
throw new Error(`macOS detected but no compatible SQLite library found.\n\n` +
|
|
137
|
+
`Apple's default SQLite does not support extension loading.\n` +
|
|
138
|
+
`Solutions:\n\n` +
|
|
139
|
+
`Option 1 - Install Homebrew SQLite (recommended):\n` +
|
|
140
|
+
` 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
|
+
`Common Homebrew paths:\n` +
|
|
148
|
+
` - Apple Silicon: /opt/homebrew/opt/sqlite/lib/libsqlite3.dylib\n` +
|
|
149
|
+
` - Intel Mac: /usr/local/opt/sqlite/lib/libsqlite3.dylib`);
|
|
150
|
+
}
|
|
151
|
+
export function getDatabase() {
|
|
152
|
+
configureSqlite();
|
|
153
|
+
return Database;
|
|
154
|
+
}
|
|
155
|
+
export function getSqliteSource() {
|
|
156
|
+
return sqliteSource;
|
|
157
|
+
}
|
|
158
|
+
configureSqlite();
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { Database } from "bun:sqlite";
|
|
2
1
|
import type { MemoryRecord, SearchResult, ShardInfo } from "./types.js";
|
|
2
|
+
declare const Database: typeof import("bun:sqlite").Database;
|
|
3
|
+
type DatabaseType = typeof Database.prototype;
|
|
3
4
|
export declare class VectorSearch {
|
|
4
|
-
insertVector(db:
|
|
5
|
+
insertVector(db: DatabaseType, record: MemoryRecord): void;
|
|
5
6
|
searchInShard(shard: ShardInfo, queryVector: Float32Array, containerTag: string, limit: number, queryText?: string): SearchResult[];
|
|
6
7
|
searchAcrossShards(shards: ShardInfo[], queryVector: Float32Array, containerTag: string, limit: number, similarityThreshold: number, queryText?: string): Promise<SearchResult[]>;
|
|
7
|
-
deleteVector(db:
|
|
8
|
-
updateVector(db:
|
|
9
|
-
listMemories(db:
|
|
10
|
-
getAllMemories(db:
|
|
11
|
-
getMemoryById(db:
|
|
12
|
-
getMemoriesBySessionID(db:
|
|
13
|
-
countVectors(db:
|
|
14
|
-
countAllVectors(db:
|
|
15
|
-
getDistinctTags(db:
|
|
16
|
-
pinMemory(db:
|
|
17
|
-
unpinMemory(db:
|
|
8
|
+
deleteVector(db: DatabaseType, memoryId: string): void;
|
|
9
|
+
updateVector(db: DatabaseType, memoryId: string, vector: Float32Array, tagsVector?: Float32Array): void;
|
|
10
|
+
listMemories(db: DatabaseType, containerTag: string, limit: number): any[];
|
|
11
|
+
getAllMemories(db: DatabaseType): any[];
|
|
12
|
+
getMemoryById(db: DatabaseType, memoryId: string): any | null;
|
|
13
|
+
getMemoriesBySessionID(db: DatabaseType, sessionID: string): any[];
|
|
14
|
+
countVectors(db: DatabaseType, containerTag: string): number;
|
|
15
|
+
countAllVectors(db: DatabaseType): number;
|
|
16
|
+
getDistinctTags(db: DatabaseType): any[];
|
|
17
|
+
pinMemory(db: DatabaseType, memoryId: string): void;
|
|
18
|
+
unpinMemory(db: DatabaseType, memoryId: string): void;
|
|
18
19
|
}
|
|
19
20
|
export declare const vectorSearch: VectorSearch;
|
|
21
|
+
export {};
|
|
20
22
|
//# sourceMappingURL=vector-search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-search.d.ts","sourceRoot":"","sources":["../../../src/services/sqlite/vector-search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vector-search.d.ts","sourceRoot":"","sources":["../../../src/services/sqlite/vector-search.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAExE,QAAA,MAAM,QAAQ,sCAAgB,CAAC;AAC/B,KAAK,YAAY,GAAG,OAAO,QAAQ,CAAC,SAAS,CAAC;AAE9C,qBAAa,YAAY;IACvB,YAAY,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IA0C1D,aAAa,CACX,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,YAAY,EACzB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EA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2
|
import { connectionManager } from "./connection-manager.js";
|
|
3
3
|
import { log } from "../logger.js";
|
|
4
|
+
const Database = getDatabase();
|
|
4
5
|
export class VectorSearch {
|
|
5
6
|
insertVector(db, record) {
|
|
6
7
|
const insertMemory = db.prepare(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-profile-manager.d.ts","sourceRoot":"","sources":["../../../src/services/user-profile/user-profile-manager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"user-profile-manager.d.ts","sourceRoot":"","sources":["../../../src/services/user-profile/user-profile-manager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAQrF,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,EAAE,CAAe;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;IAQhC,OAAO,CAAC,YAAY;IA0CpB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAapD,aAAa,CACX,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,eAAe,EAC5B,eAAe,EAAE,MAAM,GACtB,MAAM;IAoCT,aAAa,CACX,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,eAAe,EAC5B,yBAAyB,EAAE,MAAM,EACjC,aAAa,EAAE,MAAM,GACpB,IAAI;IAmCP,OAAO,CAAC,YAAY;IAqBpB,OAAO,CAAC,oBAAoB;IAiB5B,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,oBAAoB,EAAE;IAYnF,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IA2B7C,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKtC,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAOrD,oBAAoB,IAAI,WAAW,EAAE;IAMrC,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,cAAc;IAYtB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe;IA0F/F,OAAO,CAAC,WAAW;CAWpB;AAED,eAAO,MAAM,kBAAkB,oBAA2B,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getDatabase } from "../sqlite/sqlite-bootstrap.js";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { connectionManager } from "../sqlite/connection-manager.js";
|
|
4
4
|
import { CONFIG } from "../../config.js";
|
|
5
5
|
import { safeArray, safeObject } from "./profile-utils.js";
|
|
6
|
+
const Database = getDatabase();
|
|
6
7
|
const USER_PROFILES_DB_NAME = "user-profiles.db";
|
|
7
8
|
export class UserProfileManager {
|
|
8
9
|
db;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-prompt-manager.d.ts","sourceRoot":"","sources":["../../../src/services/user-prompt/user-prompt-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-prompt-manager.d.ts","sourceRoot":"","sources":["../../../src/services/user-prompt/user-prompt-manager.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,cAAc,EAAE,MAAM,GAAG,IAAI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AG,UAAU,EAAE;IAiBpF,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE;IAQ5C,OAAO,CAAC,WAAW;CAapB;AAED,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getDatabase } from "../sqlite/sqlite-bootstrap.js";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { connectionManager } from "../sqlite/connection-manager.js";
|
|
4
4
|
import { CONFIG } from "../../config.js";
|
|
5
|
+
const Database = getDatabase();
|
|
5
6
|
const USER_PROMPTS_DB_NAME = "user-prompts.db";
|
|
6
7
|
export class UserPromptManager {
|
|
7
8
|
db;
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-mem",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.8",
|
|
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",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"files": [
|
|
57
57
|
"dist",
|
|
58
|
+
"native",
|
|
58
59
|
"package.json"
|
|
59
60
|
],
|
|
60
61
|
"lint-staged": {
|