@vheins/local-memory-mcp 0.8.0 → 0.8.1
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.
|
@@ -783,6 +783,9 @@ var BaseEntity = class {
|
|
|
783
783
|
this.db = db;
|
|
784
784
|
}
|
|
785
785
|
db;
|
|
786
|
+
transaction(fn) {
|
|
787
|
+
return this.db.transaction(fn)();
|
|
788
|
+
}
|
|
786
789
|
run(sql, params = []) {
|
|
787
790
|
const stmt = this.db.prepare(sql);
|
|
788
791
|
const result = stmt.run(...params);
|
|
@@ -1031,40 +1034,42 @@ var MemoryEntity = class extends BaseEntity {
|
|
|
1031
1034
|
return rows.map((row) => this.rowToMemoryEntry(row));
|
|
1032
1035
|
}
|
|
1033
1036
|
bulkInsertMemories(entries) {
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1037
|
+
return this.transaction(() => {
|
|
1038
|
+
let count = 0;
|
|
1039
|
+
for (const entry of entries) {
|
|
1040
|
+
this.run(
|
|
1041
|
+
`INSERT INTO memories (
|
|
1042
|
+
id, repo, type, title, content, importance, folder, language,
|
|
1043
|
+
created_at, updated_at, hit_count, recall_count, last_used_at, expires_at,
|
|
1044
|
+
supersedes, status, is_global, tags, metadata, agent, role, model, completed_at
|
|
1045
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
1046
|
+
[
|
|
1047
|
+
entry.id,
|
|
1048
|
+
entry.scope.repo,
|
|
1049
|
+
entry.type,
|
|
1050
|
+
entry.title || null,
|
|
1051
|
+
entry.content,
|
|
1052
|
+
entry.importance,
|
|
1053
|
+
entry.scope.folder || null,
|
|
1054
|
+
entry.scope.language || null,
|
|
1055
|
+
entry.created_at,
|
|
1056
|
+
entry.updated_at,
|
|
1057
|
+
entry.expires_at ?? null,
|
|
1058
|
+
entry.supersedes ?? null,
|
|
1059
|
+
entry.status || "active",
|
|
1060
|
+
entry.is_global ? 1 : 0,
|
|
1061
|
+
entry.tags ? JSON.stringify(entry.tags) : null,
|
|
1062
|
+
entry.metadata ? JSON.stringify(entry.metadata) : null,
|
|
1063
|
+
entry.agent || "unknown",
|
|
1064
|
+
entry.role || "unknown",
|
|
1065
|
+
entry.model || "unknown",
|
|
1066
|
+
entry.completed_at || null
|
|
1067
|
+
]
|
|
1068
|
+
);
|
|
1069
|
+
count++;
|
|
1070
|
+
}
|
|
1071
|
+
return count;
|
|
1072
|
+
});
|
|
1068
1073
|
}
|
|
1069
1074
|
bulkUpdateMemories(ids, updates) {
|
|
1070
1075
|
if (ids.length === 0) return 0;
|
|
@@ -1088,28 +1093,32 @@ var MemoryEntity = class extends BaseEntity {
|
|
|
1088
1093
|
if (fields.length === 0) return 0;
|
|
1089
1094
|
fields.push("updated_at = ?");
|
|
1090
1095
|
values.push((/* @__PURE__ */ new Date()).toISOString());
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1096
|
+
return this.transaction(() => {
|
|
1097
|
+
let count = 0;
|
|
1098
|
+
const chunkSize = 500;
|
|
1099
|
+
for (let i = 0; i < ids.length; i += chunkSize) {
|
|
1100
|
+
const chunk = ids.slice(i, i + chunkSize);
|
|
1101
|
+
const result = this.run(
|
|
1102
|
+
`UPDATE memories SET ${fields.join(", ")} WHERE id IN (${chunk.map(() => "?").join(",")})`,
|
|
1103
|
+
[...values, ...chunk]
|
|
1104
|
+
);
|
|
1105
|
+
count += result.changes;
|
|
1106
|
+
}
|
|
1107
|
+
return count;
|
|
1108
|
+
});
|
|
1102
1109
|
}
|
|
1103
1110
|
bulkDeleteMemories(ids) {
|
|
1104
1111
|
if (ids.length === 0) return 0;
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1112
|
+
return this.transaction(() => {
|
|
1113
|
+
let count = 0;
|
|
1114
|
+
const chunkSize = 500;
|
|
1115
|
+
for (let i = 0; i < ids.length; i += chunkSize) {
|
|
1116
|
+
const chunk = ids.slice(i, i + chunkSize);
|
|
1117
|
+
const result = this.run(`DELETE FROM memories WHERE id IN (${chunk.map(() => "?").join(",")})`, chunk);
|
|
1118
|
+
count += result.changes;
|
|
1119
|
+
}
|
|
1120
|
+
return count;
|
|
1121
|
+
});
|
|
1113
1122
|
}
|
|
1114
1123
|
getRecentMemories(repo, limit, offset = 0, includeArchived = false, excludeTypes = [], sortOrder = "DESC") {
|
|
1115
1124
|
let query = "SELECT * FROM memories WHERE repo = ?";
|
|
@@ -1521,40 +1530,42 @@ var TaskEntity = class extends BaseEntity {
|
|
|
1521
1530
|
return (row?.count ?? 0) > 0;
|
|
1522
1531
|
}
|
|
1523
1532
|
bulkInsertTasks(tasks) {
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1533
|
+
return this.transaction(() => {
|
|
1534
|
+
let count = 0;
|
|
1535
|
+
for (const task of tasks) {
|
|
1536
|
+
this.run(
|
|
1537
|
+
`INSERT INTO tasks (
|
|
1538
|
+
id, repo, task_code, phase, title, description, status, priority,
|
|
1539
|
+
agent, role, doc_path, created_at, updated_at, finished_at, canceled_at, tags, metadata, parent_id, depends_on, est_tokens, in_progress_at
|
|
1540
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
1541
|
+
[
|
|
1542
|
+
task.id,
|
|
1543
|
+
task.repo,
|
|
1544
|
+
task.task_code,
|
|
1545
|
+
task.phase || null,
|
|
1546
|
+
task.title,
|
|
1547
|
+
task.description || null,
|
|
1548
|
+
task.status || "backlog",
|
|
1549
|
+
task.priority || 3,
|
|
1550
|
+
task.agent || "unknown",
|
|
1551
|
+
task.role || "unknown",
|
|
1552
|
+
task.doc_path || null,
|
|
1553
|
+
task.created_at,
|
|
1554
|
+
task.updated_at,
|
|
1555
|
+
task.finished_at || null,
|
|
1556
|
+
task.canceled_at || null,
|
|
1557
|
+
task.tags ? JSON.stringify(task.tags) : null,
|
|
1558
|
+
task.metadata ? JSON.stringify(task.metadata) : null,
|
|
1559
|
+
task.parent_id || null,
|
|
1560
|
+
task.depends_on || null,
|
|
1561
|
+
task.est_tokens || 0,
|
|
1562
|
+
task.in_progress_at || null
|
|
1563
|
+
]
|
|
1564
|
+
);
|
|
1565
|
+
count++;
|
|
1566
|
+
}
|
|
1567
|
+
return count;
|
|
1568
|
+
});
|
|
1558
1569
|
}
|
|
1559
1570
|
insertTaskComment(comment) {
|
|
1560
1571
|
this.run(
|
|
@@ -1914,9 +1925,10 @@ var SQLiteStore = class _SQLiteStore {
|
|
|
1914
1925
|
}
|
|
1915
1926
|
this.db = new Database(finalPath);
|
|
1916
1927
|
this.db.pragma("journal_mode = WAL");
|
|
1917
|
-
this.db.pragma("synchronous =
|
|
1918
|
-
this.db.pragma("busy_timeout =
|
|
1928
|
+
this.db.pragma("synchronous = FULL");
|
|
1929
|
+
this.db.pragma("busy_timeout = 10000");
|
|
1919
1930
|
this.db.pragma("foreign_keys = ON");
|
|
1931
|
+
this.db.pragma("wal_autocheckpoint = 1000");
|
|
1920
1932
|
const migrator = new MigrationManager(this.db);
|
|
1921
1933
|
migrator.migrate();
|
|
1922
1934
|
migrator.addMemoryCodeColumn();
|
package/dist/dashboard/server.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
TOOL_DEFINITIONS,
|
|
7
7
|
listResources,
|
|
8
8
|
logger
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-3JIOCO3K.js";
|
|
10
10
|
|
|
11
11
|
// src/dashboard/server.ts
|
|
12
12
|
import express from "express";
|
|
@@ -904,9 +904,19 @@ app.use((req, res, next) => {
|
|
|
904
904
|
if (process.env.DASHBOARD_ENABLE_MCP === "true") {
|
|
905
905
|
mcpClient.start().catch((e) => logger.error("MCP Client failed", { error: e.message }));
|
|
906
906
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
});
|
|
907
|
+
function startServer() {
|
|
908
|
+
const server = app.listen(PORT, () => {
|
|
909
|
+
console.log(`${(/* @__PURE__ */ new Date()).toISOString()} DASHBOARD_STARTING v${pkg2.version} on port ${PORT}`);
|
|
910
|
+
});
|
|
911
|
+
server.on("error", (err) => {
|
|
912
|
+
if (err.code === "EADDRINUSE") {
|
|
913
|
+
console.log(`${(/* @__PURE__ */ new Date()).toISOString()} DASHBOARD_ALREADY_RUNNING Dashboard already running on port ${PORT}. Exiting.`);
|
|
914
|
+
process.exit(0);
|
|
915
|
+
}
|
|
916
|
+
throw err;
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
startServer();
|
|
910
920
|
process.on("SIGINT", () => {
|
|
911
921
|
mcpClient.stop();
|
|
912
922
|
db.close();
|
package/dist/mcp/server.js
CHANGED