@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
- let count = 0;
1035
- for (const entry of entries) {
1036
- this.run(
1037
- `INSERT INTO memories (
1038
- id, repo, type, title, content, importance, folder, language,
1039
- created_at, updated_at, hit_count, recall_count, last_used_at, expires_at,
1040
- supersedes, status, is_global, tags, metadata, agent, role, model, completed_at
1041
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
1042
- [
1043
- entry.id,
1044
- entry.scope.repo,
1045
- entry.type,
1046
- entry.title || null,
1047
- entry.content,
1048
- entry.importance,
1049
- entry.scope.folder || null,
1050
- entry.scope.language || null,
1051
- entry.created_at,
1052
- entry.updated_at,
1053
- entry.expires_at ?? null,
1054
- entry.supersedes ?? null,
1055
- entry.status || "active",
1056
- entry.is_global ? 1 : 0,
1057
- entry.tags ? JSON.stringify(entry.tags) : null,
1058
- entry.metadata ? JSON.stringify(entry.metadata) : null,
1059
- entry.agent || "unknown",
1060
- entry.role || "unknown",
1061
- entry.model || "unknown",
1062
- entry.completed_at || null
1063
- ]
1064
- );
1065
- count++;
1066
- }
1067
- return count;
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
- let count = 0;
1092
- const chunkSize = 500;
1093
- for (let i = 0; i < ids.length; i += chunkSize) {
1094
- const chunk = ids.slice(i, i + chunkSize);
1095
- const result = this.run(
1096
- `UPDATE memories SET ${fields.join(", ")} WHERE id IN (${chunk.map(() => "?").join(",")})`,
1097
- [...values, ...chunk]
1098
- );
1099
- count += result.changes;
1100
- }
1101
- return count;
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
- let count = 0;
1106
- const chunkSize = 500;
1107
- for (let i = 0; i < ids.length; i += chunkSize) {
1108
- const chunk = ids.slice(i, i + chunkSize);
1109
- const result = this.run(`DELETE FROM memories WHERE id IN (${chunk.map(() => "?").join(",")})`, chunk);
1110
- count += result.changes;
1111
- }
1112
- return count;
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
- let count = 0;
1525
- for (const task of tasks) {
1526
- this.run(
1527
- `INSERT INTO tasks (
1528
- id, repo, task_code, phase, title, description, status, priority,
1529
- agent, role, doc_path, created_at, updated_at, finished_at, canceled_at, tags, metadata, parent_id, depends_on, est_tokens, in_progress_at
1530
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
1531
- [
1532
- task.id,
1533
- task.repo,
1534
- task.task_code,
1535
- task.phase || null,
1536
- task.title,
1537
- task.description || null,
1538
- task.status || "backlog",
1539
- task.priority || 3,
1540
- task.agent || "unknown",
1541
- task.role || "unknown",
1542
- task.doc_path || null,
1543
- task.created_at,
1544
- task.updated_at,
1545
- task.finished_at || null,
1546
- task.canceled_at || null,
1547
- task.tags ? JSON.stringify(task.tags) : null,
1548
- task.metadata ? JSON.stringify(task.metadata) : null,
1549
- task.parent_id || null,
1550
- task.depends_on || null,
1551
- task.est_tokens || 0,
1552
- task.in_progress_at || null
1553
- ]
1554
- );
1555
- count++;
1556
- }
1557
- return count;
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 = NORMAL");
1918
- this.db.pragma("busy_timeout = 5000");
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();
@@ -6,7 +6,7 @@ import {
6
6
  TOOL_DEFINITIONS,
7
7
  listResources,
8
8
  logger
9
- } from "../chunk-CQK2B6SF.js";
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
- app.listen(PORT, () => {
908
- console.log(`${(/* @__PURE__ */ new Date()).toISOString()} DASHBOARD_STARTING v${pkg2.version} on port ${PORT}`);
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();
@@ -42,7 +42,7 @@ import {
42
42
  setLogLevel,
43
43
  updateSessionFromInitialize,
44
44
  updateSessionRoots
45
- } from "../chunk-CQK2B6SF.js";
45
+ } from "../chunk-3JIOCO3K.js";
46
46
 
47
47
  // src/mcp/server.ts
48
48
  import readline from "readline";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vheins/local-memory-mcp",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "MCP Local Memory Service for coding copilot agents",
5
5
  "mcpName": "io.github.vheins/local-memory-mcp",
6
6
  "type": "module",