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.
@@ -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.4";
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.4";
4371
+ return "2.1.5";
4372
4372
  }
4373
4373
  }
4374
4374
  }
@@ -5290,8 +5290,7 @@ async function handleSearch(store, pathname, method, res, searchParams) {
5290
5290
  } else {
5291
5291
  results = store.search(projectId, q, limit);
5292
5292
  }
5293
- const filtered = results.filter((r) => r.title !== "__INDEX__");
5294
- json(res, 200, { query: q, semantic, count: filtered.length, results: filtered });
5293
+ json(res, 200, { query: q, semantic, count: results.length, results });
5295
5294
  return true;
5296
5295
  }
5297
5296
  return false;
@@ -5501,7 +5500,7 @@ var PKG_VERSION = (() => {
5501
5500
  const pkg = JSON.parse(require("fs").readFileSync(require("path").resolve(__dirname, "../../package.json"), "utf-8"));
5502
5501
  return pkg.version;
5503
5502
  } catch {
5504
- return "2.1.4";
5503
+ return "2.1.5";
5505
5504
  }
5506
5505
  })();
5507
5506
  function handleHealth(store, pathname, method, res) {
@@ -6174,7 +6173,14 @@ var Store = class extends EventEmitter {
6174
6173
  vals.push(this.now());
6175
6174
  sets.push("version = version + 1");
6176
6175
  vals.push(id);
6177
- 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
+ }
6178
6184
  const updated = this.getAtom(id);
6179
6185
  this.emit("atom.updated", { atom: updated, projectId: atom.project_id, changes });
6180
6186
  this.logEvent("atom.updated", updatedBy, "assistant", atom.project_id, id, void 0, { fields: changes });
@@ -6429,7 +6435,6 @@ var Store = class extends EventEmitter {
6429
6435
  // ═══════════════════════════════════════════════════════════
6430
6436
  search(projectId, q, limit) {
6431
6437
  const results = [];
6432
- const seenAtoms = /* @__PURE__ */ new Set();
6433
6438
  const matchExpr = q.trim().split(/\s+/).filter(Boolean).map((t) => `"${t.replace(/"/g, "")}"`).join(" ");
6434
6439
  if (!matchExpr) return results;
6435
6440
  const projectFilter = projectId ? "AND a.project_id = ?" : "";
@@ -6444,26 +6449,9 @@ var Store = class extends EventEmitter {
6444
6449
  `).all(...paramsAtoms);
6445
6450
  for (const a of atoms) {
6446
6451
  if (results.length >= limit) break;
6447
- seenAtoms.add(a.id);
6452
+ if (a.title === "__INDEX__") continue;
6448
6453
  results.push({ kind: "atom", ...a, metadata: this.parseMeta(a) });
6449
6454
  }
6450
- const paramsBlocks = projectId ? [matchExpr, projectId, limit] : [matchExpr, limit];
6451
- const blocks = this.stmt(`
6452
- SELECT b.*, a.title as atom_title, a.id as atom_id, bm25(search_blocks) as rank
6453
- FROM search_blocks
6454
- JOIN blocks b ON b.rowid = search_blocks.rowid
6455
- JOIN atoms a ON b.atom_id = a.id
6456
- WHERE search_blocks MATCH ? ${projectFilter}
6457
- ORDER BY rank
6458
- LIMIT ?
6459
- `).all(...paramsBlocks);
6460
- for (const b of blocks) {
6461
- if (results.length >= limit) break;
6462
- if (!seenAtoms.has(b.atom_id)) {
6463
- seenAtoms.add(b.atom_id);
6464
- results.push({ kind: "block", ...b, metadata: this.parseMeta(b) });
6465
- }
6466
- }
6467
6455
  return results;
6468
6456
  }
6469
6457
  // ─── Semantic Search ──────────────────────────────────────
@@ -6514,7 +6502,7 @@ var Store = class extends EventEmitter {
6514
6502
  ORDER BY v.distance
6515
6503
  LIMIT ${limit}
6516
6504
  `).all(...params);
6517
- 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) }));
6518
6506
  } catch (err) {
6519
6507
  console.error("[Store] Semantic search failed:", err.message);
6520
6508
  return [];
@@ -7207,7 +7195,7 @@ var MnemosyneServer = class {
7207
7195
  const wss = new import_websocket_server.default({ server: this.httpServer });
7208
7196
  this.wsHandler = new WebSocketHandler(wss, this.store);
7209
7197
  }
7210
- const version = cfg?.server?.version || "2.1.4";
7198
+ const version = cfg?.server?.version || "2.1.5";
7211
7199
  this.httpServer.listen(port, () => {
7212
7200
  console.log(`Mnemosyne v${version} \u2014 port ${port}`);
7213
7201
  console.log(`Dashboard: http://${host}:${port}/dashboard`);