@oomkapwn/enquire-mcp 3.8.8 → 3.9.0-rc.2

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/watcher.d.ts CHANGED
@@ -1,7 +1,23 @@
1
1
  import type { EmbedDb } from "./embed-db.js";
2
2
  import type { loadEmbedder } from "./embeddings.js";
3
3
  import type { FtsIndex } from "./fts5.js";
4
+ import type { HnswIndex } from "./hnsw.js";
4
5
  import type { Vault } from "./vault.js";
6
+ /**
7
+ * v3.9.0-rc.2 — shape of the row-metadata entries the HNSW index keeps
8
+ * alongside each label. Mirrors `HnswPersistedMeta["rowsByLabel"][k]`
9
+ * but defined here so the watcher's TypeScript surface stays
10
+ * self-contained (no circular imports between watcher.ts and hnsw.ts's
11
+ * persistence types).
12
+ */
13
+ export interface HnswRowMeta {
14
+ rel_path: string;
15
+ chunk_index: number;
16
+ line_start: number;
17
+ line_end: number;
18
+ text_preview: string;
19
+ kind: "md" | "pdf";
20
+ }
5
21
  export interface WatcherOptions {
6
22
  /** Vault to watch — must already be ensureExists()'d. */
7
23
  vault: Vault;
@@ -51,6 +67,37 @@ export interface WatcherOptions {
51
67
  * vector space and search recall would drift over the session.
52
68
  */
53
69
  lateChunkContext?: number;
70
+ /**
71
+ * v3.9.0-rc.1 — when true, the watcher runs Tesseract OCR on
72
+ * image-only / scanned PDFs that pdfjs can't extract text from, then
73
+ * pipes the OCR-derived text through the standard embed pipeline so
74
+ * the embed-db keeps OCR'd PDFs in sync with edits during a long
75
+ * serve session. Off by default (OCR is slow: ~1-2s per page on M1
76
+ * CPU; a 100-page paper takes minutes and blocks the event loop).
77
+ *
78
+ * Requires `tesseract.js` + `@napi-rs/canvas` optional dependencies
79
+ * + the requested language trained-data files pre-installed via
80
+ * `enquire-mcp install-ocr-lang <code>` (see v3.7.16 P1-1 offline
81
+ * enforcement). If those aren't available, OCR fails-soft — the
82
+ * watcher still updates FTS5 + clears any stale embed-db rows.
83
+ *
84
+ * Recommended pairing: `--ocr-pdfs` + `--watch` + `--include-pdfs`
85
+ * for users with scanned-document vaults that change during sessions.
86
+ */
87
+ ocrPdfs?: boolean;
88
+ /**
89
+ * v3.9.0-rc.1 — language pack(s) passed to `extractPdfWithOcr`.
90
+ * Default `'eng'`. Multi-lang via `'+'`, e.g. `'eng+rus'`. See
91
+ * `src/ocr.ts` for the full language model.
92
+ */
93
+ ocrLangs?: string;
94
+ /**
95
+ * v3.9.0-rc.1 — page cap for OCR runs. Mirrors `DEFAULT_OCR_MAX_PAGES`
96
+ * (200) — image-only PDFs that exceed this won't be embed-sync'd
97
+ * (the watcher logs the skip + still updates FTS5). Operators can
98
+ * lift the cap when they trust their PDF set.
99
+ */
100
+ ocrMaxPages?: number;
54
101
  }
55
102
  export declare class VaultWatcher {
56
103
  private watcher;
@@ -61,8 +108,28 @@ export declare class VaultWatcher {
61
108
  private embedDb;
62
109
  private embedder;
63
110
  private lateChunkContext;
111
+ private ocrPdfs;
112
+ private ocrLangs;
113
+ private ocrMaxPages;
114
+ private hnsw;
115
+ private hnswRowsByLabel;
64
116
  private closed;
65
117
  constructor(opts: WatcherOptions);
118
+ /**
119
+ * v3.9.0-rc.1 — enable / configure OCR-on-watch after construction.
120
+ * Called by server.ts after attachEmbed() runs (since OCR fallback
121
+ * only makes sense once embed-db is wired). Fails loud if includePdfs
122
+ * is off — without it, PDF events are filtered before the OCR
123
+ * codepath runs.
124
+ *
125
+ * @param enabled - When true, image-only PDFs that pdfjs can't read
126
+ * trigger a Tesseract OCR pass; the OCR-derived text feeds the
127
+ * normal embed pipeline via embedSinglePdf's preExtractedPages path.
128
+ * @param langs - Tesseract language pack (default "eng"). Multi-lang
129
+ * via `+`, e.g. "eng+rus".
130
+ * @param maxPages - Page cap for OCR runs. Default 200 (DEFAULT_OCR_MAX_PAGES).
131
+ */
132
+ setOcrPdfs(enabled: boolean, langs?: string, maxPages?: number): void;
66
133
  /**
67
134
  * v3.8.0-rc.2 R-7 — attach an embed-db handle + embedder after the
68
135
  * watcher has started. Used by `prepareServerDeps` when HNSW context
@@ -75,6 +142,34 @@ export declare class VaultWatcher {
75
142
  * detach (the FTS5-only sync continues).
76
143
  */
77
144
  attachEmbed(embedDb: EmbedDb | null, embedder: Awaited<ReturnType<typeof loadEmbedder>> | null, lateChunkContext?: number): void;
145
+ /**
146
+ * v3.9.0-rc.2 — wire an in-memory HNSW index for live updates. After
147
+ * this call, every md/pdf event that mutates embed-db ALSO updates
148
+ * the HNSW graph via `hnsw.applyDiff(oldIds, newPoints)` so search
149
+ * results reflect the change immediately. Pre-3.9.0, the HNSW index
150
+ * was rebuilt from embed-db only at serve startup; vault edits during
151
+ * the session left the HNSW stale until restart, and `--use-hnsw`
152
+ * users saw new content omitted from semantic-search results.
153
+ *
154
+ * Must be called AFTER `attachEmbed` (the HNSW + embed-db handles
155
+ * share a lifecycle — server.ts opens both during HNSW init).
156
+ *
157
+ * @param hnsw - the in-memory HNSW index built by server.ts.
158
+ * @param rowsByLabel - the mutable label→row map shared with
159
+ * `searchHybrid` (the live update writes into it so subsequent
160
+ * searches see the new chunks).
161
+ */
162
+ attachHnsw(hnsw: HnswIndex, rowsByLabel: Map<number, HnswRowMeta>): void;
163
+ /**
164
+ * v3.9.0-rc.2 — internal helper. Apply an embed-db {oldIds, newIds}
165
+ * diff to the wired HNSW index + rowsByLabel map. Called by both the
166
+ * md and pdf event handlers after upsertNote / deleteNote returns.
167
+ * Fail-soft: on any error, logs to stderr and returns — the embed-db
168
+ * is already updated, so the next serve restart will rebuild HNSW
169
+ * from the correct state. (Same posture as the watcher's existing
170
+ * embed-db fail-soft.)
171
+ */
172
+ private syncHnswForFile;
78
173
  /** Start watching. Resolves once the watcher has reported `ready`. */
79
174
  start(): Promise<void>;
80
175
  private handle;
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../src/watcher.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,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,MAAM;IAwPd,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ7B"}
package/dist/watcher.js CHANGED
@@ -31,6 +31,22 @@ export class VaultWatcher {
31
31
  embedDb;
32
32
  embedder;
33
33
  lateChunkContext;
34
+ // v3.9.0-rc.1 — OCR-on-watch options. Mutable so server.ts can wire
35
+ // them via setOcrPdfs() AFTER attachEmbed() runs — the embed-db opens
36
+ // late, but the watcher boots early so file events from boot-time
37
+ // edits are captured.
38
+ ocrPdfs;
39
+ ocrLangs;
40
+ ocrMaxPages;
41
+ // v3.9.0-rc.2 — HNSW in-memory live update wiring. The watcher
42
+ // boots before HNSW initializes (similar pattern to embedDb above),
43
+ // so attachHnsw() is the late-binding entry point. When wired, every
44
+ // md/pdf event that mutates embed-db also calls
45
+ // `hnsw.applyDiff(oldIds, newPoints)` so search reflects the change
46
+ // immediately (pre-3.9.0 the in-memory HNSW went stale until the
47
+ // next serve restart rebuilt from the freshly-upserted embed-db).
48
+ hnsw = null;
49
+ hnswRowsByLabel = null;
34
50
  closed = false;
35
51
  constructor(opts) {
36
52
  this.vault = opts.vault;
@@ -40,12 +56,48 @@ export class VaultWatcher {
40
56
  this.embedDb = opts.embedDb ?? null;
41
57
  this.embedder = opts.embedder ?? null;
42
58
  this.lateChunkContext = opts.lateChunkContext ?? 0;
59
+ // v3.9.0-rc.1 — OCR-on-watch wiring. Constructor accepts the flags
60
+ // but defers validation: when the watcher is built BEFORE attachEmbed
61
+ // runs (the normal startup order in server.ts), ocrPdfs would fail
62
+ // the embedDb-required check. Instead, the PDF event handler checks
63
+ // `ocrPdfs && embedDb && includePdfs` at runtime and skips the OCR
64
+ // codepath silently if any leg is missing.
65
+ this.ocrPdfs = opts.ocrPdfs ?? false;
66
+ this.ocrLangs = opts.ocrLangs ?? "eng";
67
+ this.ocrMaxPages = opts.ocrMaxPages;
43
68
  // v3.8.0-rc.2 R-7 — fail loud if embedDb is wired without embedder.
44
69
  // Pre-flight check vs silently no-op'ing the embed sync.
45
70
  if (this.embedDb && !this.embedder) {
46
71
  throw new Error("VaultWatcher: embedDb wired without embedder — both must be set together");
47
72
  }
48
73
  }
74
+ /**
75
+ * v3.9.0-rc.1 — enable / configure OCR-on-watch after construction.
76
+ * Called by server.ts after attachEmbed() runs (since OCR fallback
77
+ * only makes sense once embed-db is wired). Fails loud if includePdfs
78
+ * is off — without it, PDF events are filtered before the OCR
79
+ * codepath runs.
80
+ *
81
+ * @param enabled - When true, image-only PDFs that pdfjs can't read
82
+ * trigger a Tesseract OCR pass; the OCR-derived text feeds the
83
+ * normal embed pipeline via embedSinglePdf's preExtractedPages path.
84
+ * @param langs - Tesseract language pack (default "eng"). Multi-lang
85
+ * via `+`, e.g. "eng+rus".
86
+ * @param maxPages - Page cap for OCR runs. Default 200 (DEFAULT_OCR_MAX_PAGES).
87
+ */
88
+ setOcrPdfs(enabled, langs, maxPages) {
89
+ if (enabled && !this.includePdfs) {
90
+ throw new Error("VaultWatcher.setOcrPdfs: enabling OCR requires includePdfs=true at construction time");
91
+ }
92
+ if (enabled && !this.embedDb) {
93
+ throw new Error("VaultWatcher.setOcrPdfs: enabling OCR requires embedDb (call attachEmbed first)");
94
+ }
95
+ this.ocrPdfs = enabled;
96
+ if (langs !== undefined)
97
+ this.ocrLangs = langs;
98
+ if (maxPages !== undefined)
99
+ this.ocrMaxPages = maxPages;
100
+ }
49
101
  /**
50
102
  * v3.8.0-rc.2 R-7 — attach an embed-db handle + embedder after the
51
103
  * watcher has started. Used by `prepareServerDeps` when HNSW context
@@ -65,6 +117,67 @@ export class VaultWatcher {
65
117
  this.embedder = embedder;
66
118
  this.lateChunkContext = lateChunkContext;
67
119
  }
120
+ /**
121
+ * v3.9.0-rc.2 — wire an in-memory HNSW index for live updates. After
122
+ * this call, every md/pdf event that mutates embed-db ALSO updates
123
+ * the HNSW graph via `hnsw.applyDiff(oldIds, newPoints)` so search
124
+ * results reflect the change immediately. Pre-3.9.0, the HNSW index
125
+ * was rebuilt from embed-db only at serve startup; vault edits during
126
+ * the session left the HNSW stale until restart, and `--use-hnsw`
127
+ * users saw new content omitted from semantic-search results.
128
+ *
129
+ * Must be called AFTER `attachEmbed` (the HNSW + embed-db handles
130
+ * share a lifecycle — server.ts opens both during HNSW init).
131
+ *
132
+ * @param hnsw - the in-memory HNSW index built by server.ts.
133
+ * @param rowsByLabel - the mutable label→row map shared with
134
+ * `searchHybrid` (the live update writes into it so subsequent
135
+ * searches see the new chunks).
136
+ */
137
+ attachHnsw(hnsw, rowsByLabel) {
138
+ if (!this.embedDb) {
139
+ throw new Error("VaultWatcher.attachHnsw: embedDb not attached — call attachEmbed first (HNSW live update requires it)");
140
+ }
141
+ this.hnsw = hnsw;
142
+ this.hnswRowsByLabel = rowsByLabel;
143
+ }
144
+ /**
145
+ * v3.9.0-rc.2 — internal helper. Apply an embed-db {oldIds, newIds}
146
+ * diff to the wired HNSW index + rowsByLabel map. Called by both the
147
+ * md and pdf event handlers after upsertNote / deleteNote returns.
148
+ * Fail-soft: on any error, logs to stderr and returns — the embed-db
149
+ * is already updated, so the next serve restart will rebuild HNSW
150
+ * from the correct state. (Same posture as the watcher's existing
151
+ * embed-db fail-soft.)
152
+ */
153
+ syncHnswForFile(relPath, kind, oldIds, newRows) {
154
+ if (!this.hnsw || !this.hnswRowsByLabel)
155
+ return null;
156
+ try {
157
+ const result = this.hnsw.applyDiff(oldIds, newRows.map((r) => ({ label: r.id, vector: r.vector })));
158
+ // Update the rowsByLabel map: drop old, add new. The map is shared
159
+ // with searchHybrid via reference; mutations are visible immediately.
160
+ for (const oldId of oldIds)
161
+ this.hnswRowsByLabel.delete(oldId);
162
+ for (const r of newRows) {
163
+ this.hnswRowsByLabel.set(r.id, {
164
+ rel_path: relPath,
165
+ chunk_index: r.chunkIndex,
166
+ line_start: r.lineStart,
167
+ line_end: r.lineEnd,
168
+ text_preview: r.textPreview,
169
+ kind
170
+ });
171
+ }
172
+ return result;
173
+ }
174
+ catch (err) {
175
+ if (!this.silent) {
176
+ process.stderr.write(`enquire: watcher HNSW live-update failed for ${relPath} — ${err instanceof Error ? err.message : String(err)} (search results may be stale until next serve restart)\n`);
177
+ }
178
+ return null;
179
+ }
180
+ }
68
181
  /** Start watching. Resolves once the watcher has reported `ready`. */
69
182
  async start() {
70
183
  const root = this.vault.root;
@@ -146,9 +259,20 @@ export class VaultWatcher {
146
259
  // v3.8.0-rc.2 R-7 — also drop embed-db rows so search results
147
260
  // don't surface vectors for deleted notes.
148
261
  // v3.8.0-rc.3 R-7 — extended to PDFs (rc.2 was md-only).
262
+ // v3.9.0-rc.2 — propagate the deletion to the in-memory HNSW
263
+ // index too via syncHnswForFile (with empty newRows = pure-delete
264
+ // diff). Pre-3.9.0 HNSW retained deleted-file labels until next
265
+ // serve restart; semantic-search results would surface vectors
266
+ // for files no longer in the vault.
267
+ let unlinkHnswNote = "";
149
268
  if (this.embedDb) {
150
269
  try {
151
- this.embedDb.deleteNote(relPath);
270
+ const deletedIds = this.embedDb.deleteNote(relPath);
271
+ if (deletedIds.length > 0 && this.hnsw) {
272
+ const result = this.syncHnswForFile(relPath, "md", deletedIds, []);
273
+ if (result)
274
+ unlinkHnswNote = ` + hnsw -${result.removed}`;
275
+ }
152
276
  }
153
277
  catch (err) {
154
278
  if (!this.silent) {
@@ -158,7 +282,7 @@ export class VaultWatcher {
158
282
  }
159
283
  if (!this.silent) {
160
284
  const embedNote = this.embedDb ? " + embed-db dropped" : "";
161
- process.stderr.write(`enquire: watcher unlink ${relPath} (fts5 dropped${embedNote})\n`);
285
+ process.stderr.write(`enquire: watcher unlink ${relPath} (fts5 dropped${embedNote}${unlinkHnswNote})\n`);
162
286
  }
163
287
  return;
164
288
  }
@@ -180,19 +304,87 @@ export class VaultWatcher {
180
304
  // because they have no useful embedding content (same v3.7.6 H-4
181
305
  // staleness fix as bulk sync). Fail-soft: embed-db errors don't
182
306
  // fail the watcher event.
307
+ //
308
+ // v3.9.0-rc.1 — when `ocrPdfs` is on AND the cheap pdfjs path
309
+ // returns hasText=false, fall back to Tesseract OCR + feed
310
+ // OCR-derived pages through embedSinglePdf's new preExtractedPages
311
+ // mode. Without this, scanned PDFs that change during a serve
312
+ // session lose their embed rows + slowly degrade hybrid recall
313
+ // until the next manual `enquire-mcp build-embeddings` run.
183
314
  let pdfEmbedNote = "";
184
315
  if (this.embedDb && this.embedder) {
185
316
  try {
317
+ let preExtractedPages;
318
+ // OCR fallback path. The cheap pdfjs result already lives in
319
+ // `result` (from the FTS5 reindex above); if it's image-only,
320
+ // we run Tesseract + use the OCR pages directly.
321
+ if (this.ocrPdfs && !result.hasText) {
322
+ try {
323
+ const { extractPdfWithOcr } = await import("./ocr.js");
324
+ const ocrResult = await extractPdfWithOcr(buf, {
325
+ langs: this.ocrLangs,
326
+ ...(this.ocrMaxPages !== undefined ? { maxPages: this.ocrMaxPages } : {})
327
+ });
328
+ // Filter empty pages so we don't emit `[page: N]\n` blocks
329
+ // that the chunker would otherwise group with surrounding
330
+ // text. (Tesseract returns isEmpty=true for blank pages.)
331
+ preExtractedPages = ocrResult.pages
332
+ .filter((p) => !p.isEmpty)
333
+ .map((p) => ({ pageNumber: p.pageNumber, text: p.text }));
334
+ if (preExtractedPages.length === 0) {
335
+ // OCR returned zero pages with text — treat as image-only
336
+ // (drop rows). Don't pass empty preExtractedPages; that
337
+ // would short-circuit to null on the embed-pipeline side.
338
+ preExtractedPages = undefined;
339
+ }
340
+ }
341
+ catch (ocrErr) {
342
+ // OCR fails-soft. Log, then fall through to the default
343
+ // path (which will treat the PDF as image-only and drop
344
+ // stale rows). Common failure: tesseract.js / canvas not
345
+ // installed, or language file missing.
346
+ if (!this.silent) {
347
+ process.stderr.write(`enquire: watcher PDF OCR failed for ${relPath} — ${ocrErr instanceof Error ? ocrErr.message : String(ocrErr)}\n`);
348
+ }
349
+ }
350
+ }
186
351
  const { embedSinglePdf } = await import("./embed-pipeline.js");
187
- const pdfResult = await embedSinglePdf(this.vault, this.embedder, { relPath, absPath, mtimeMs: stat.mtimeMs }, { lateChunkContext: this.lateChunkContext });
352
+ const pdfResult = await embedSinglePdf(this.vault, this.embedder, { relPath, absPath, mtimeMs: stat.mtimeMs }, {
353
+ lateChunkContext: this.lateChunkContext,
354
+ ...(preExtractedPages ? { preExtractedPages } : {})
355
+ });
188
356
  if (pdfResult === null) {
189
357
  // Image-only or zero chunks — drop any stale embed-db rows.
190
- this.embedDb.deleteNote(relPath);
191
- pdfEmbedNote = " + embed-db cleared (image-only or empty)";
358
+ const deletedIds = this.embedDb.deleteNote(relPath);
359
+ pdfEmbedNote = preExtractedPages
360
+ ? " + embed-db cleared (OCR also empty)"
361
+ : " + embed-db cleared (image-only or empty)";
362
+ // v3.9.0-rc.2 — propagate cleared rows to HNSW live update.
363
+ if (deletedIds.length > 0 && this.hnsw) {
364
+ const hnswResult = this.syncHnswForFile(relPath, "pdf", deletedIds, []);
365
+ if (hnswResult)
366
+ pdfEmbedNote += ` + hnsw -${hnswResult.removed}`;
367
+ }
192
368
  }
193
369
  else {
194
- this.embedDb.upsertNote(relPath, stat.mtimeMs, pdfResult.rows, "pdf");
195
- pdfEmbedNote = ` + embed-db upserted (${pdfResult.chunks} chunks, kind=pdf)`;
370
+ const { oldIds, newIds } = this.embedDb.upsertNote(relPath, stat.mtimeMs, pdfResult.rows, "pdf");
371
+ const sourceLabel = preExtractedPages ? "OCR" : "pdfjs";
372
+ pdfEmbedNote = ` + embed-db upserted (${pdfResult.chunks} chunks, kind=pdf, src=${sourceLabel})`;
373
+ // v3.9.0-rc.2 — keep HNSW in sync with the embed-db change.
374
+ // The newIds array runs parallel to pdfResult.rows (same order)
375
+ // so we can zip them into HNSW add-points by index.
376
+ if (this.hnsw) {
377
+ const hnswResult = this.syncHnswForFile(relPath, "pdf", oldIds, pdfResult.rows.map((r, i) => ({
378
+ id: newIds[i] ?? -1,
379
+ vector: r.vector,
380
+ chunkIndex: r.chunkIndex,
381
+ lineStart: r.lineStart,
382
+ lineEnd: r.lineEnd,
383
+ textPreview: r.textPreview
384
+ })));
385
+ if (hnswResult)
386
+ pdfEmbedNote += ` + hnsw -${hnswResult.removed}/+${hnswResult.added}`;
387
+ }
196
388
  }
197
389
  }
198
390
  catch (err) {
@@ -220,12 +412,32 @@ export class VaultWatcher {
220
412
  const { embedSingleNote } = await import("./embed-pipeline.js");
221
413
  const result = await embedSingleNote(this.vault, this.embedder, { relPath, absPath, mtimeMs: stat.mtimeMs }, { lateChunkContext: this.lateChunkContext });
222
414
  if (result === null) {
223
- this.embedDb.deleteNote(relPath);
415
+ const deletedIds = this.embedDb.deleteNote(relPath);
224
416
  embedNote = " + embed-db cleared (empty note)";
417
+ // v3.9.0-rc.2 — propagate cleared rows to HNSW live update.
418
+ if (deletedIds.length > 0 && this.hnsw) {
419
+ const hnswResult = this.syncHnswForFile(relPath, "md", deletedIds, []);
420
+ if (hnswResult)
421
+ embedNote += ` + hnsw -${hnswResult.removed}`;
422
+ }
225
423
  }
226
424
  else {
227
- this.embedDb.upsertNote(relPath, stat.mtimeMs, result.rows);
425
+ const { oldIds, newIds } = this.embedDb.upsertNote(relPath, stat.mtimeMs, result.rows);
228
426
  embedNote = ` + embed-db upserted (${result.chunks} chunks)`;
427
+ // v3.9.0-rc.2 — keep HNSW in sync. newIds and result.rows run
428
+ // parallel (same order), so we zip them into HNSW add-points.
429
+ if (this.hnsw) {
430
+ const hnswResult = this.syncHnswForFile(relPath, "md", oldIds, result.rows.map((r, i) => ({
431
+ id: newIds[i] ?? -1,
432
+ vector: r.vector,
433
+ chunkIndex: r.chunkIndex,
434
+ lineStart: r.lineStart,
435
+ lineEnd: r.lineEnd,
436
+ textPreview: r.textPreview
437
+ })));
438
+ if (hnswResult)
439
+ embedNote += ` + hnsw -${hnswResult.removed}/+${hnswResult.added}`;
440
+ }
229
441
  }
230
442
  }
231
443
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.js","sourceRoot":"","sources":["../src/watcher.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,mEAAmE;AACnE,2BAA2B;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IAAI,IAAI,OAAO,mBAAmB,SAAS,KAAK,CAAC,CAAC;YAC7F,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,mEAAmE;YACnE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,yBAAyB,OAAO,KAAK,IAAI,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CACrG,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;CACF"}
@@ -43,7 +43,7 @@ The four axes the external audit (#3, 2026-05) called out as decisive — **REST
43
43
  | Read open editor state, active note, etc. | **No** | **Yes** | Limited | No | No |
44
44
  | Zero outbound network calls in serve mode | **Yes** (default) | Local-only (REST)| Local-only (REST)| Yes | Yes |
45
45
  | SLSA-3 build provenance on releases | **Yes** | No | No | No | No |
46
- | Test count (public) | **893** | (varies) | (varies) | (varies) | (varies) |
46
+ | Test count (public) | **911** | (varies) | (varies) | (varies) | (varies) |
47
47
  | Tool count | 44 | ~25 | ~8 | ~10 | 3–5 |
48
48
  | MCP prompt count | 19 | 0 | 0 | 0 | 0 |
49
49
  | License | MIT | Apache-2.0 | MIT | MIT | (varies) |
package/docs/api.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **enquire is the most advanced Obsidian MCP — a long-term memory layer for AI agents, built on your Obsidian vault.** Open-source, MCP-native, vendor-neutral persistence: agents (Claude Code / Claude Desktop / Cursor / ChatGPT / Codex / OpenClaw / any MCP client) get durable, queryable recall across sessions, models, and providers — your knowledge lives in plain markdown you own, not a vendor cloud. 44 MCP tools (33 always-on read + 4 opt-in read + 7 opt-in write); the 4 opt-ins are: 1 via `--persistent-index` + `--diagnostic-search-tools` (`obsidian_full_text_search` — needs BOTH flags: persistent-index for the FTS5 index, diagnostic-search-tools to surface it as a single-ranker tool alongside the hybrid default `obsidian_search`) + 3 via `--diagnostic-search-tools` (the single-ranker `obsidian_search_text` / `obsidian_semantic_search` / `obsidian_embeddings_search` — gated by default in v2.0+ since `obsidian_search` auto-detects + fuses signals). 2 + 1 opt-in MCP resources, 19 MCP prompts. **v3.1.0+ adds `obsidian_hyde_search`** (HyDE-augmented retrieval, Gao et al 2023; agent supplies a synthetic answer, server embeds it for retrieval) plus the `vault_research` (sub-question decomposition) and `vault_synthesis_page` (Karpathy LLM-Wiki synthesis loop) prompts. v2.6.0+ also speaks Streamable HTTP via `serve-http` (bearer auth + rate-limit + CORS). v2.7.0+ indexes PDFs as a separate read tool surface; **v2.8.0+ blends PDF chunks into `obsidian_search` hybrid retrieval** with `--include-pdfs` — every hit carries a `kind: "md" | "pdf"` flag and PDF snippets include `[page: N]` markers for citation. **v2.9.0+ adds BGE cross-encoder reranking** on top of RRF with `--enable-reranker` — typical +5-10 NDCG@10 retrieval-quality boost. **v2.10.0+ adds Tesseract OCR for image-only / scanned PDFs** via `obsidian_ocr_pdf` — completes the PDF retrieval story.
4
4
 
5
- > **Channels:** stable v3.8.x (`@latest` on npm) ships 44 tools including `obsidian_search` (hybrid BM25 + TF-IDF + ML embeddings, RRF-fused) with optional BGE cross-encoder reranking, `obsidian_embeddings_search`, `obsidian_hyde_search`, plus the `install-model` / `build-embeddings` / `clear-embeddings` / `setup` / `doctor` / `eval` subcommands. The `@rc` dist-tag carries the most recent release candidate. Benchmarks live behind `npm run bench:retrieval` (not a CLI subcommand). This document covers the **v3.8.x stable** surface — see [CHANGELOG.md](../CHANGELOG.md) for the v3.8.0 minor (K-3 readOnlyHint invariant, R-7 watcher embed-db sync, Tier A/B AI/LLM discoverability, 8 new structural invariants) and v3.8.1 retraction (overclaim instance #11 — incorrectly-attributed external audit).
5
+ > **Channels:** stable since v3.8.x (`@latest` on npm) ships 44 tools including `obsidian_search` (hybrid BM25 + TF-IDF + ML embeddings, RRF-fused) with optional BGE cross-encoder reranking, `obsidian_embeddings_search`, `obsidian_hyde_search`, plus the `install-model` / `build-embeddings` / `clear-embeddings` / `setup` / `doctor` / `eval` subcommands. The `@rc` dist-tag carries the most recent release candidate (currently v3.9.0-rc.1 — OCR'd PDF watcher embed-sync). Benchmarks live behind `npm run bench:retrieval` (not a CLI subcommand). This document covers the **stable v3.8.x** surface plus what the upcoming v3.9.0 will add — see [CHANGELOG.md](../CHANGELOG.md) for the v3.8.x release series and the in-flight v3.9.0-rc.1.
6
6
 
7
7
  > Versioned dynamically — see [`CHANGELOG.md`](../CHANGELOG.md) for the current release.
8
8
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@oomkapwn/enquire-mcp",
4
- "version": "3.8.8",
4
+ "version": "3.9.0-rc.2",
5
5
  "mcpName": "io.github.oomkapwn/enquire-mcp",
6
- "description": "MCP server giving AI agents (Claude Code, Claude Desktop, Cursor, ChatGPT, Codex, OpenClaw) persistent long-term memory backed by your local Obsidian markdown vault. Hybrid retrieval (BM25 + ML embeddings + BGE reranker, RRF-fused), HNSW + int8 quantization, agentic RAG (HyDE + sub-question decomposition), GraphRAG-light (Louvain), standalone Obsidian Bases, PDFs + Tesseract OCR. Vendor-neutral memory layer for any MCP-compatible agent. 44 tools, 19 MCP prompts, 893 tests, SLSA-3, semver-bound, MIT, zero cloud calls during serve.",
6
+ "description": "MCP server giving AI agents (Claude Code, Claude Desktop, Cursor, ChatGPT, Codex, OpenClaw) persistent long-term memory backed by your local Obsidian markdown vault. Hybrid retrieval (BM25 + ML embeddings + BGE reranker, RRF-fused), HNSW + int8 quantization, agentic RAG (HyDE + sub-question decomposition), GraphRAG-light (Louvain), standalone Obsidian Bases, PDFs + Tesseract OCR. Vendor-neutral memory layer for any MCP-compatible agent. 44 tools, 19 MCP prompts, 911 tests, SLSA-3, semver-bound, MIT, zero cloud calls during serve.",
7
7
  "type": "module",
8
8
  "bin": {
9
9
  "enquire-mcp": "dist/index.js"