mnemosyne-core 2.1.3 → 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.
@@ -3817,7 +3817,7 @@ function getVersion2() {
3817
3817
  const pkg = JSON.parse(readFileSync5(resolve7(process.cwd(), "package.json"), "utf-8"));
3818
3818
  return pkg.version;
3819
3819
  } catch {
3820
- return "2.1.3";
3820
+ return "2.1.5";
3821
3821
  }
3822
3822
  }
3823
3823
  }
@@ -4368,7 +4368,7 @@ function getVersion() {
4368
4368
  const pkg = JSON.parse(readFileSync5(resolve7(process.cwd(), "package.json"), "utf-8"));
4369
4369
  return pkg.version;
4370
4370
  } catch {
4371
- return "2.1.3";
4371
+ return "2.1.5";
4372
4372
  }
4373
4373
  }
4374
4374
  }
@@ -5500,7 +5500,7 @@ var PKG_VERSION = (() => {
5500
5500
  const pkg = JSON.parse(require("fs").readFileSync(require("path").resolve(__dirname, "../../package.json"), "utf-8"));
5501
5501
  return pkg.version;
5502
5502
  } catch {
5503
- return "2.1.3";
5503
+ return "2.1.5";
5504
5504
  }
5505
5505
  })();
5506
5506
  function handleHealth(store, pathname, method, res) {
@@ -6173,7 +6173,14 @@ var Store = class extends EventEmitter {
6173
6173
  vals.push(this.now());
6174
6174
  sets.push("version = version + 1");
6175
6175
  vals.push(id);
6176
- this.stmt(`UPDATE atoms SET ${sets.join(", ")} WHERE id = ?`).run(...vals);
6176
+ try {
6177
+ this.stmt(`UPDATE atoms SET ${sets.join(", ")} WHERE id = ?`).run(...vals);
6178
+ } catch (err) {
6179
+ if (err.message?.includes("malformed") || err.message?.includes("corrupt")) {
6180
+ throw new Error(`Database appears corrupted. Run "mnemosyne doctor --data-dir ./data" or delete the data directory and run "mnemosyne init" again.`);
6181
+ }
6182
+ throw err;
6183
+ }
6177
6184
  const updated = this.getAtom(id);
6178
6185
  this.emit("atom.updated", { atom: updated, projectId: atom.project_id, changes });
6179
6186
  this.logEvent("atom.updated", updatedBy, "assistant", atom.project_id, id, void 0, { fields: changes });
@@ -6428,7 +6435,6 @@ var Store = class extends EventEmitter {
6428
6435
  // ═══════════════════════════════════════════════════════════
6429
6436
  search(projectId, q, limit) {
6430
6437
  const results = [];
6431
- const seenAtoms = /* @__PURE__ */ new Set();
6432
6438
  const matchExpr = q.trim().split(/\s+/).filter(Boolean).map((t) => `"${t.replace(/"/g, "")}"`).join(" ");
6433
6439
  if (!matchExpr) return results;
6434
6440
  const projectFilter = projectId ? "AND a.project_id = ?" : "";
@@ -6443,26 +6449,9 @@ var Store = class extends EventEmitter {
6443
6449
  `).all(...paramsAtoms);
6444
6450
  for (const a of atoms) {
6445
6451
  if (results.length >= limit) break;
6446
- seenAtoms.add(a.id);
6452
+ if (a.title === "__INDEX__") continue;
6447
6453
  results.push({ kind: "atom", ...a, metadata: this.parseMeta(a) });
6448
6454
  }
6449
- const paramsBlocks = projectId ? [matchExpr, projectId, limit] : [matchExpr, limit];
6450
- const blocks = this.stmt(`
6451
- SELECT b.*, a.title as atom_title, a.id as atom_id, bm25(search_blocks) as rank
6452
- FROM search_blocks
6453
- JOIN blocks b ON b.rowid = search_blocks.rowid
6454
- JOIN atoms a ON b.atom_id = a.id
6455
- WHERE search_blocks MATCH ? ${projectFilter}
6456
- ORDER BY rank
6457
- LIMIT ?
6458
- `).all(...paramsBlocks);
6459
- for (const b of blocks) {
6460
- if (results.length >= limit) break;
6461
- if (!seenAtoms.has(b.atom_id)) {
6462
- seenAtoms.add(b.atom_id);
6463
- results.push({ kind: "block", ...b, metadata: this.parseMeta(b) });
6464
- }
6465
- }
6466
6455
  return results;
6467
6456
  }
6468
6457
  // ─── Semantic Search ──────────────────────────────────────
@@ -6513,7 +6502,7 @@ var Store = class extends EventEmitter {
6513
6502
  ORDER BY v.distance
6514
6503
  LIMIT ${limit}
6515
6504
  `).all(...params);
6516
- return rows.map((r) => ({ kind: "atom", ...r, metadata: this.parseMeta(r) }));
6505
+ return rows.filter((r) => r.title !== "__INDEX__").map((r) => ({ kind: "atom", ...r, metadata: this.parseMeta(r) }));
6517
6506
  } catch (err) {
6518
6507
  console.error("[Store] Semantic search failed:", err.message);
6519
6508
  return [];
@@ -7206,7 +7195,7 @@ var MnemosyneServer = class {
7206
7195
  const wss = new import_websocket_server.default({ server: this.httpServer });
7207
7196
  this.wsHandler = new WebSocketHandler(wss, this.store);
7208
7197
  }
7209
- const version = cfg?.server?.version || "2.1.3";
7198
+ const version = cfg?.server?.version || "2.1.5";
7210
7199
  this.httpServer.listen(port, () => {
7211
7200
  console.log(`Mnemosyne v${version} \u2014 port ${port}`);
7212
7201
  console.log(`Dashboard: http://${host}:${port}/dashboard`);