local-agent-memory 1.0.8 → 1.0.9
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/cli/commands/reindex.js +15 -6
- package/dist/cli/commands/sync.js +3 -3
- package/dist/db/project.d.ts +4 -4
- package/dist/db/project.js +24 -12
- package/package.json +1 -1
|
@@ -22,12 +22,21 @@ async function reindexProject() {
|
|
|
22
22
|
// Check if db exists, then delete to force complete reindex
|
|
23
23
|
if (node_fs_1.default.existsSync(localDbPath)) {
|
|
24
24
|
spinner.text = "Deleting corrupted or existing local index...";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
node_fs_1.default.
|
|
29
|
-
|
|
30
|
-
node_fs_1.default.
|
|
25
|
+
try {
|
|
26
|
+
node_fs_1.default.unlinkSync(localDbPath);
|
|
27
|
+
// Also delete the WAL and SHM files if they exist
|
|
28
|
+
if (node_fs_1.default.existsSync(`${localDbPath}-wal`))
|
|
29
|
+
node_fs_1.default.unlinkSync(`${localDbPath}-wal`);
|
|
30
|
+
if (node_fs_1.default.existsSync(`${localDbPath}-shm`))
|
|
31
|
+
node_fs_1.default.unlinkSync(`${localDbPath}-shm`);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
if (err.code === "EBUSY" || err.code === "EPERM") {
|
|
35
|
+
spinner.fail("Cannot reindex: local.sqlite is currently open and locked by an active process (e.g. MCP server). Please stop the MCP process and try again.");
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
31
40
|
}
|
|
32
41
|
spinner.text = "Rebuilding index from scratch...";
|
|
33
42
|
const { newCount } = await (0, sync_1.doSyncProject)(cwd);
|
|
@@ -20,7 +20,7 @@ async function doSyncProject(cwd) {
|
|
|
20
20
|
const localDbPath = (0, project_1.getLocalDbPath)(cwd);
|
|
21
21
|
const db = (0, project_1.initLocalDb)(localDbPath);
|
|
22
22
|
const _asyncDb = new sync_1.AsyncDatabase(db);
|
|
23
|
-
const manifests = await (0, project_1.getAllManifests)(
|
|
23
|
+
const manifests = await (0, project_1.getAllManifests)(db);
|
|
24
24
|
const manifestMap = new Map(manifests.map((m) => [m.file_path, m]));
|
|
25
25
|
const configPath = node_path_1.default.join(memoryDir, "config.json");
|
|
26
26
|
let includePaths = [".memory"];
|
|
@@ -64,7 +64,7 @@ async function doSyncProject(cwd) {
|
|
|
64
64
|
if (!existing) {
|
|
65
65
|
// New file
|
|
66
66
|
const sha256 = await computeSha256(file);
|
|
67
|
-
await (0, project_1.upsertFileManifest)(
|
|
67
|
+
await (0, project_1.upsertFileManifest)(db, relativePath, mtime, sha256);
|
|
68
68
|
const content = await node_fs_1.default.promises.readFile(file, "utf8");
|
|
69
69
|
await (0, sync_1.syncFile)(relativePath, content, db);
|
|
70
70
|
newCount++;
|
|
@@ -73,7 +73,7 @@ async function doSyncProject(cwd) {
|
|
|
73
73
|
// Potentially modified, check hash
|
|
74
74
|
const sha256 = await computeSha256(file);
|
|
75
75
|
if (sha256 !== existing.sha256) {
|
|
76
|
-
await (0, project_1.upsertFileManifest)(
|
|
76
|
+
await (0, project_1.upsertFileManifest)(db, relativePath, mtime, sha256);
|
|
77
77
|
const content = await node_fs_1.default.promises.readFile(file, "utf8");
|
|
78
78
|
await (0, sync_1.syncFile)(relativePath, content, db);
|
|
79
79
|
modCount++;
|
package/dist/db/project.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface FileManifestRow {
|
|
|
7
7
|
export declare function getVecExtensionPath(): string | null;
|
|
8
8
|
export declare function getLocalDbPath(projectRoot: string): string;
|
|
9
9
|
export declare function initLocalDb(dbPath: string): sqlite3.Database;
|
|
10
|
-
export declare function upsertFileManifest(
|
|
11
|
-
export declare function getFileManifest(
|
|
12
|
-
export declare function getAllManifests(
|
|
13
|
-
export declare function removeFileManifest(
|
|
10
|
+
export declare function upsertFileManifest(dbOrPath: string | sqlite3.Database, file_path: string, mtime: number, sha256: string): Promise<void>;
|
|
11
|
+
export declare function getFileManifest(dbOrPath: string | sqlite3.Database, file_path: string): Promise<FileManifestRow | null>;
|
|
12
|
+
export declare function getAllManifests(dbOrPath: string | sqlite3.Database): Promise<FileManifestRow[]>;
|
|
13
|
+
export declare function removeFileManifest(dbOrPath: string | sqlite3.Database, file_path: string): Promise<void>;
|
package/dist/db/project.js
CHANGED
|
@@ -101,11 +101,14 @@ function initLocalDb(dbPath) {
|
|
|
101
101
|
});
|
|
102
102
|
return db;
|
|
103
103
|
}
|
|
104
|
-
async function upsertFileManifest(
|
|
104
|
+
async function upsertFileManifest(dbOrPath, file_path, mtime, sha256) {
|
|
105
105
|
return new Promise((resolve, reject) => {
|
|
106
|
-
const
|
|
106
|
+
const isDb = typeof dbOrPath !== "string";
|
|
107
|
+
const db = isDb ? dbOrPath : initLocalDb(dbOrPath);
|
|
107
108
|
db.run("INSERT OR REPLACE INTO file_manifest (file_path, mtime, sha256, last_synced) VALUES (?, ?, ?, CURRENT_TIMESTAMP)", [file_path, mtime, sha256], (err) => {
|
|
108
|
-
|
|
109
|
+
if (!isDb) {
|
|
110
|
+
db.close();
|
|
111
|
+
}
|
|
109
112
|
if (err)
|
|
110
113
|
reject(err);
|
|
111
114
|
else
|
|
@@ -113,11 +116,14 @@ async function upsertFileManifest(dbPath, file_path, mtime, sha256) {
|
|
|
113
116
|
});
|
|
114
117
|
});
|
|
115
118
|
}
|
|
116
|
-
async function getFileManifest(
|
|
119
|
+
async function getFileManifest(dbOrPath, file_path) {
|
|
117
120
|
return new Promise((resolve, reject) => {
|
|
118
|
-
const
|
|
121
|
+
const isDb = typeof dbOrPath !== "string";
|
|
122
|
+
const db = isDb ? dbOrPath : initLocalDb(dbOrPath);
|
|
119
123
|
db.get("SELECT file_path, mtime, sha256 FROM file_manifest WHERE file_path = ?", [file_path], (err, row) => {
|
|
120
|
-
|
|
124
|
+
if (!isDb) {
|
|
125
|
+
db.close();
|
|
126
|
+
}
|
|
121
127
|
if (err)
|
|
122
128
|
reject(err);
|
|
123
129
|
else
|
|
@@ -125,11 +131,14 @@ async function getFileManifest(dbPath, file_path) {
|
|
|
125
131
|
});
|
|
126
132
|
});
|
|
127
133
|
}
|
|
128
|
-
async function getAllManifests(
|
|
134
|
+
async function getAllManifests(dbOrPath) {
|
|
129
135
|
return new Promise((resolve, reject) => {
|
|
130
|
-
const
|
|
136
|
+
const isDb = typeof dbOrPath !== "string";
|
|
137
|
+
const db = isDb ? dbOrPath : initLocalDb(dbOrPath);
|
|
131
138
|
db.all("SELECT file_path, mtime, sha256 FROM file_manifest", (err, rows) => {
|
|
132
|
-
|
|
139
|
+
if (!isDb) {
|
|
140
|
+
db.close();
|
|
141
|
+
}
|
|
133
142
|
if (err)
|
|
134
143
|
reject(err);
|
|
135
144
|
else
|
|
@@ -137,11 +146,14 @@ async function getAllManifests(dbPath) {
|
|
|
137
146
|
});
|
|
138
147
|
});
|
|
139
148
|
}
|
|
140
|
-
async function removeFileManifest(
|
|
149
|
+
async function removeFileManifest(dbOrPath, file_path) {
|
|
141
150
|
return new Promise((resolve, reject) => {
|
|
142
|
-
const
|
|
151
|
+
const isDb = typeof dbOrPath !== "string";
|
|
152
|
+
const db = isDb ? dbOrPath : initLocalDb(dbOrPath);
|
|
143
153
|
db.run("DELETE FROM file_manifest WHERE file_path = ?", [file_path], (err) => {
|
|
144
|
-
|
|
154
|
+
if (!isDb) {
|
|
155
|
+
db.close();
|
|
156
|
+
}
|
|
145
157
|
if (err)
|
|
146
158
|
reject(err);
|
|
147
159
|
else
|