@velvetmonkey/flywheel-memory 2.0.63 → 2.0.64

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.
Files changed (2) hide show
  1. package/dist/index.js +17 -2
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -7596,7 +7596,7 @@ function refreshIfStale(vaultPath2, index, excludeTags) {
7596
7596
  }
7597
7597
 
7598
7598
  // src/index.ts
7599
- import { openStateDb, scanVaultEntities as scanVaultEntities3, getSessionId, getAllEntitiesFromDb as getAllEntitiesFromDb3, findEntityMatches as findEntityMatches2, getProtectedZones as getProtectedZones2, rangeOverlapsProtectedZone, detectImplicitEntities as detectImplicitEntities3 } from "@velvetmonkey/vault-core";
7599
+ import { openStateDb, scanVaultEntities as scanVaultEntities3, getSessionId, getAllEntitiesFromDb as getAllEntitiesFromDb3, findEntityMatches as findEntityMatches2, getProtectedZones as getProtectedZones2, rangeOverlapsProtectedZone, detectImplicitEntities as detectImplicitEntities3, loadContentHashes, saveContentHashBatch, renameContentHash } from "@velvetmonkey/vault-core";
7600
7600
 
7601
7601
  // src/tools/read/graph.ts
7602
7602
  import * as fs9 from "fs";
@@ -19635,6 +19635,13 @@ async function runPostIndexWork(index) {
19635
19635
  if (process.env.FLYWHEEL_WATCH !== "false") {
19636
19636
  const config = parseWatcherConfig();
19637
19637
  const lastContentHashes = /* @__PURE__ */ new Map();
19638
+ if (stateDb) {
19639
+ const persisted = loadContentHashes(stateDb);
19640
+ for (const [p, h] of persisted) lastContentHashes.set(p, h);
19641
+ if (persisted.size > 0) {
19642
+ serverLog("watcher", `Loaded ${persisted.size} persisted content hashes`);
19643
+ }
19644
+ }
19638
19645
  serverLog("watcher", `File watcher enabled (debounce: ${config.debounceMs}ms)`);
19639
19646
  const handleBatch = async (batch) => {
19640
19647
  const vaultPrefixes = /* @__PURE__ */ new Set([
@@ -19680,25 +19687,32 @@ async function runPostIndexWork(index) {
19680
19687
  newPath: normalizeEventPath(r.newPath)
19681
19688
  }));
19682
19689
  const filteredEvents = [];
19690
+ const hashUpserts = [];
19691
+ const hashDeletes = [];
19683
19692
  for (const event of batch.events) {
19684
19693
  if (event.type === "delete") {
19685
19694
  filteredEvents.push(event);
19686
19695
  lastContentHashes.delete(event.path);
19696
+ hashDeletes.push(event.path);
19687
19697
  continue;
19688
19698
  }
19689
19699
  try {
19690
19700
  const content = await fs31.readFile(path32.join(vaultPath, event.path), "utf-8");
19691
- const hash = createHash2("md5").update(content).digest("hex");
19701
+ const hash = createHash2("sha256").update(content).digest("hex").slice(0, 16);
19692
19702
  if (lastContentHashes.get(event.path) === hash) {
19693
19703
  serverLog("watcher", `Hash unchanged, skipping: ${event.path}`);
19694
19704
  continue;
19695
19705
  }
19696
19706
  lastContentHashes.set(event.path, hash);
19707
+ hashUpserts.push({ path: event.path, hash });
19697
19708
  filteredEvents.push(event);
19698
19709
  } catch {
19699
19710
  filteredEvents.push(event);
19700
19711
  }
19701
19712
  }
19713
+ if (stateDb && (hashUpserts.length || hashDeletes.length)) {
19714
+ saveContentHashBatch(stateDb, hashUpserts, hashDeletes);
19715
+ }
19702
19716
  if (batchRenames.length > 0 && stateDb) {
19703
19717
  try {
19704
19718
  const insertMove = stateDb.db.prepare(`
@@ -19729,6 +19743,7 @@ async function runPostIndexWork(index) {
19729
19743
  if (oldHash !== void 0) {
19730
19744
  lastContentHashes.set(rename.newPath, oldHash);
19731
19745
  lastContentHashes.delete(rename.oldPath);
19746
+ renameContentHash(stateDb, rename.oldPath, rename.newPath);
19732
19747
  }
19733
19748
  }
19734
19749
  serverLog("watcher", `Renames: recorded ${batchRenames.length} move(s) in note_moves`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velvetmonkey/flywheel-memory",
3
- "version": "2.0.63",
3
+ "version": "2.0.64",
4
4
  "description": "MCP server that gives Claude full read/write access to your Obsidian vault. Select from 42 tools for search, backlinks, graph queries, mutations, and hybrid semantic search.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@modelcontextprotocol/sdk": "^1.25.1",
55
- "@velvetmonkey/vault-core": "2.0.63",
55
+ "@velvetmonkey/vault-core": "2.0.64",
56
56
  "better-sqlite3": "^11.0.0",
57
57
  "chokidar": "^4.0.0",
58
58
  "gray-matter": "^4.0.3",