mnemosyne-core 2.1.4 → 2.1.5

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/index.js CHANGED
@@ -3635,7 +3635,7 @@ function getVersion() {
3635
3635
  const pkg = JSON.parse(readFileSync8(resolve14(process.cwd(), "package.json"), "utf-8"));
3636
3636
  return pkg.version;
3637
3637
  } catch {
3638
- return "2.1.4";
3638
+ return "2.1.5";
3639
3639
  }
3640
3640
  }
3641
3641
  }
@@ -7599,7 +7599,7 @@ var require_package = __commonJS({
7599
7599
  "package.json"(exports2, module2) {
7600
7600
  module2.exports = {
7601
7601
  name: "mnemosyne-core",
7602
- version: "2.1.4",
7602
+ version: "2.1.5",
7603
7603
  description: "Unified memory engine for AI agents \u2014 graph atoms, semantic search, and collaborative memory",
7604
7604
  logo: "logo.png",
7605
7605
  author: "Arman Aslanyan <aslanyanarman88@gmail.com> (https://www.linkedin.com/in/arman-aslanyan/)",
@@ -8144,7 +8144,14 @@ var Store = class extends EventEmitter {
8144
8144
  vals.push(this.now());
8145
8145
  sets.push("version = version + 1");
8146
8146
  vals.push(id);
8147
- this.stmt(`UPDATE atoms SET ${sets.join(", ")} WHERE id = ?`).run(...vals);
8147
+ try {
8148
+ this.stmt(`UPDATE atoms SET ${sets.join(", ")} WHERE id = ?`).run(...vals);
8149
+ } catch (err) {
8150
+ if (err.message?.includes("malformed") || err.message?.includes("corrupt")) {
8151
+ throw new Error(`Database appears corrupted. Run "mnemosyne doctor --data-dir ./data" or delete the data directory and run "mnemosyne init" again.`);
8152
+ }
8153
+ throw err;
8154
+ }
8148
8155
  const updated = this.getAtom(id);
8149
8156
  this.emit("atom.updated", { atom: updated, projectId: atom.project_id, changes });
8150
8157
  this.logEvent("atom.updated", updatedBy, "assistant", atom.project_id, id, void 0, { fields: changes });
@@ -8399,7 +8406,6 @@ var Store = class extends EventEmitter {
8399
8406
  // ═══════════════════════════════════════════════════════════
8400
8407
  search(projectId, q, limit) {
8401
8408
  const results = [];
8402
- const seenAtoms = /* @__PURE__ */ new Set();
8403
8409
  const matchExpr = q.trim().split(/\s+/).filter(Boolean).map((t) => `"${t.replace(/"/g, "")}"`).join(" ");
8404
8410
  if (!matchExpr) return results;
8405
8411
  const projectFilter = projectId ? "AND a.project_id = ?" : "";
@@ -8414,26 +8420,9 @@ var Store = class extends EventEmitter {
8414
8420
  `).all(...paramsAtoms);
8415
8421
  for (const a of atoms) {
8416
8422
  if (results.length >= limit) break;
8417
- seenAtoms.add(a.id);
8423
+ if (a.title === "__INDEX__") continue;
8418
8424
  results.push({ kind: "atom", ...a, metadata: this.parseMeta(a) });
8419
8425
  }
8420
- const paramsBlocks = projectId ? [matchExpr, projectId, limit] : [matchExpr, limit];
8421
- const blocks = this.stmt(`
8422
- SELECT b.*, a.title as atom_title, a.id as atom_id, bm25(search_blocks) as rank
8423
- FROM search_blocks
8424
- JOIN blocks b ON b.rowid = search_blocks.rowid
8425
- JOIN atoms a ON b.atom_id = a.id
8426
- WHERE search_blocks MATCH ? ${projectFilter}
8427
- ORDER BY rank
8428
- LIMIT ?
8429
- `).all(...paramsBlocks);
8430
- for (const b of blocks) {
8431
- if (results.length >= limit) break;
8432
- if (!seenAtoms.has(b.atom_id)) {
8433
- seenAtoms.add(b.atom_id);
8434
- results.push({ kind: "block", ...b, metadata: this.parseMeta(b) });
8435
- }
8436
- }
8437
8426
  return results;
8438
8427
  }
8439
8428
  // ─── Semantic Search ──────────────────────────────────────
@@ -8484,7 +8473,7 @@ var Store = class extends EventEmitter {
8484
8473
  ORDER BY v.distance
8485
8474
  LIMIT ${limit}
8486
8475
  `).all(...params);
8487
- return rows.map((r) => ({ kind: "atom", ...r, metadata: this.parseMeta(r) }));
8476
+ return rows.filter((r) => r.title !== "__INDEX__").map((r) => ({ kind: "atom", ...r, metadata: this.parseMeta(r) }));
8488
8477
  } catch (err) {
8489
8478
  console.error("[Store] Semantic search failed:", err.message);
8490
8479
  return [];
@@ -8947,7 +8936,7 @@ function getVersion2() {
8947
8936
  const pkg = JSON.parse(readFileSync8(resolve14(process.cwd(), "package.json"), "utf-8"));
8948
8937
  return pkg.version;
8949
8938
  } catch {
8950
- return "2.1.4";
8939
+ return "2.1.5";
8951
8940
  }
8952
8941
  }
8953
8942
  }
@@ -9238,6 +9227,10 @@ var Mnemosyne = class {
9238
9227
  this.db.pragma("journal_mode = WAL");
9239
9228
  this.db.pragma("foreign_keys = ON");
9240
9229
  this.db.pragma("synchronous = NORMAL");
9230
+ try {
9231
+ this.db.pragma("wal_checkpoint(TRUNCATE)");
9232
+ } catch {
9233
+ }
9241
9234
  this.vecEnabled = false;
9242
9235
  try {
9243
9236
  let vecPath;
@@ -9545,7 +9538,7 @@ function getVersion3() {
9545
9538
  const pkg = JSON.parse(readFileSync8(resolve14(process.cwd(), "package.json"), "utf-8"));
9546
9539
  return pkg.version;
9547
9540
  } catch {
9548
- return "2.1.4";
9541
+ return "2.1.5";
9549
9542
  }
9550
9543
  }
9551
9544
  }
@@ -10470,8 +10463,7 @@ async function handleSearch(store, pathname, method, res, searchParams) {
10470
10463
  } else {
10471
10464
  results = store.search(projectId, q, limit);
10472
10465
  }
10473
- const filtered = results.filter((r) => r.title !== "__INDEX__");
10474
- json(res, 200, { query: q, semantic, count: filtered.length, results: filtered });
10466
+ json(res, 200, { query: q, semantic, count: results.length, results });
10475
10467
  return true;
10476
10468
  }
10477
10469
  return false;
@@ -10681,7 +10673,7 @@ var PKG_VERSION = (() => {
10681
10673
  const pkg = JSON.parse(require("fs").readFileSync(require("path").resolve(__dirname, "../../package.json"), "utf-8"));
10682
10674
  return pkg.version;
10683
10675
  } catch {
10684
- return "2.1.4";
10676
+ return "2.1.5";
10685
10677
  }
10686
10678
  })();
10687
10679
  function handleHealth(store, pathname, method, res) {
@@ -11005,7 +10997,7 @@ var MnemosyneServer = class {
11005
10997
  const wss = new import_websocket_server.default({ server: this.httpServer });
11006
10998
  this.wsHandler = new WebSocketHandler(wss, this.store);
11007
10999
  }
11008
- const version = cfg?.server?.version || "2.1.4";
11000
+ const version = cfg?.server?.version || "2.1.5";
11009
11001
  this.httpServer.listen(port, () => {
11010
11002
  console.log(`Mnemosyne v${version} \u2014 port ${port}`);
11011
11003
  console.log(`Dashboard: http://${host}:${port}/dashboard`);
@@ -11063,7 +11055,7 @@ function getVersion4() {
11063
11055
  const { resolve: resolve14 } = require("path");
11064
11056
  return JSON.parse(readFileSync8(resolve14(__dirname, "../../package.json"), "utf-8")).version;
11065
11057
  } catch {
11066
- return "2.1.4";
11058
+ return "2.1.5";
11067
11059
  }
11068
11060
  }
11069
11061
  async function startCommand(options) {
@@ -11355,7 +11347,7 @@ program2.name("mnemosyne").description("Mnemosyne \u2014 Your exocortex").versio
11355
11347
  try {
11356
11348
  return require_package().version;
11357
11349
  } catch {
11358
- return "2.1.4";
11350
+ return "2.1.5";
11359
11351
  }
11360
11352
  })());
11361
11353
  program2.command("init").description("Initialize a new Mnemosyne workspace").option("-d, --data-dir <path>", "Data directory", "./data").option("-c, --config <path>", "Config file path").action(initCommand);