@velvetmonkey/vault-core 2.12.8 → 2.12.10

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/queries.js +22 -10
  2. package/package.json +1 -1
package/dist/queries.js CHANGED
@@ -45,7 +45,10 @@ export function searchEntities(stateDb, query, limit = 20) {
45
45
  * @param limit - Maximum results to return
46
46
  */
47
47
  export function searchEntitiesPrefix(stateDb, prefix, limit = 20) {
48
- return searchEntities(stateDb, `${escapeFts5Query(prefix)}*`, limit);
48
+ // Append `*` BEFORE escaping so the suffix-aware quoter places it correctly
49
+ // (quoted phrase + outer `*` for prefix search). Pre-escaping here would
50
+ // produce already-quoted input that the second escape pass cannot reuse.
51
+ return searchEntities(stateDb, `${prefix}*`, limit);
49
52
  }
50
53
  /**
51
54
  * Get entity by exact name (case-insensitive)
@@ -341,20 +344,29 @@ export function escapeFts5Query(query) {
341
344
  phrases.push(`"${phrase.replace(/"/g, '""')}"`);
342
345
  return '';
343
346
  });
344
- // Clean remaining tokens
347
+ // Clean remaining tokens. Strips FTS5 syntax punctuation (`:` and `-` previously
348
+ // tripped queries like `2026-05-08` → SQLite parsed `05` as a column reference,
349
+ // returning `no such column: 05`). `+`, `.`, `_` were also unhandled — see
350
+ // 2026-05-08 morning-briefing failure.
345
351
  const cleaned = withoutPhrases
346
- .replace(/[(){}[\]^~:-]/g, ' ')
352
+ .replace(/[(){}[\]^~:+._-]/g, ' ')
347
353
  .replace(/\s+/g, ' ')
348
354
  .trim();
349
- // Split into tokens, skip explicit AND/OR/NOT operators
350
- const tokens = cleaned.split(' ').filter(t => t && t !== 'AND' && t !== 'OR' && t !== 'NOT');
351
- // Combine: quoted phrases + OR-joined tokens
355
+ // Split into tokens, skip explicit FTS5 operators (AND/OR/NOT/NEAR).
356
+ const tokens = cleaned
357
+ .split(' ')
358
+ .filter(t => t && t !== 'AND' && t !== 'OR' && t !== 'NOT' && t !== 'NEAR');
359
+ // Wrap each token as an FTS5 phrase literal so bareword reserved keywords and
360
+ // numeric tokens cannot be parsed as column references. Preserve trailing `*`
361
+ // for prefix search by placing it OUTSIDE the quotes (`"foo"*` not `"foo*"`).
362
+ const safeTokens = tokens.map(t => t.endsWith('*') ? `"${t.slice(0, -1)}"*` : `"${t}"`);
363
+ // Combine: quoted phrases + OR-joined safe tokens
352
364
  const parts = [...phrases];
353
- if (tokens.length === 1) {
354
- parts.push(tokens[0]);
365
+ if (safeTokens.length === 1) {
366
+ parts.push(safeTokens[0]);
355
367
  }
356
- else if (tokens.length > 1) {
357
- parts.push(tokens.join(' OR '));
368
+ else if (safeTokens.length > 1) {
369
+ parts.push(safeTokens.join(' OR '));
358
370
  }
359
371
  return parts.join(' ') || '';
360
372
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velvetmonkey/vault-core",
3
- "version": "2.12.8",
3
+ "version": "2.12.10",
4
4
  "description": "Shared vault utilities for Flywheel ecosystem (entity scanning, wikilinks, protected zones)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",