sensemaking 0.7.2 → 0.9.0
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/README.md +90 -61
- package/dist/cjs/cli/check.js +367 -0
- package/dist/cjs/cli/check.js.map +1 -0
- package/dist/cjs/{commands → cli}/index.js +2 -2
- package/dist/cjs/cli/index.js.map +1 -0
- package/dist/cjs/{commands → cli}/init.js +3 -0
- package/dist/cjs/cli/init.js.map +1 -0
- package/dist/cjs/{commands → cli}/map.js +2 -2
- package/dist/cjs/cli/map.js.map +1 -0
- package/dist/cjs/{commands → cli}/named.d.cts +1 -1
- package/dist/cjs/{commands → cli}/named.d.ts +1 -1
- package/dist/cjs/cli/named.js +219 -0
- package/dist/cjs/cli/named.js.map +1 -0
- package/dist/cjs/{commands → cli}/peek.js +2 -2
- package/dist/cjs/cli/peek.js.map +1 -0
- package/dist/cjs/cli/query.js.map +1 -0
- package/dist/cjs/cli/rebuild.js.map +1 -0
- package/dist/cjs/cli/search.d.cts +3 -0
- package/dist/cjs/cli/search.d.ts +3 -0
- package/dist/cjs/{commands/find.js → cli/search.js} +9 -8
- package/dist/cjs/cli/search.js.map +1 -0
- package/dist/cjs/{commands → cli}/shared.d.cts +1 -0
- package/dist/{esm/commands → cjs/cli}/shared.d.ts +1 -0
- package/dist/cjs/{commands → cli}/shared.js +9 -0
- package/dist/cjs/cli/shared.js.map +1 -0
- package/dist/cjs/{commands → cli}/status.js +36 -13
- package/dist/cjs/cli/status.js.map +1 -0
- package/dist/cjs/{commands → cli}/types.d.cts +3 -1
- package/dist/{esm/commands → cjs/cli}/types.d.ts +3 -1
- package/dist/cjs/cli/watch.js.map +1 -0
- package/dist/cjs/cli.js +42 -17
- package/dist/cjs/cli.js.map +1 -1
- package/dist/{esm/verbs.d.ts → cjs/commands.d.cts} +15 -5
- package/dist/cjs/{verbs.d.cts → commands.d.ts} +15 -5
- package/dist/cjs/{verbs.js → commands.js} +329 -39
- package/dist/cjs/commands.js.map +1 -0
- package/dist/cjs/config.d.cts +45 -12
- package/dist/cjs/config.d.ts +45 -12
- package/dist/cjs/config.js +464 -125
- package/dist/cjs/config.js.map +1 -1
- package/dist/cjs/db.d.cts +1 -1
- package/dist/cjs/db.d.ts +1 -1
- package/dist/cjs/db.js +293 -76
- package/dist/cjs/db.js.map +1 -1
- package/dist/cjs/errors.d.cts +1 -1
- package/dist/cjs/errors.d.ts +1 -1
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/features/embed.js +19 -3
- package/dist/cjs/features/embed.js.map +1 -1
- package/dist/cjs/features/links.js +201 -24
- package/dist/cjs/features/links.js.map +1 -1
- package/dist/cjs/features/rank.js +8 -1
- package/dist/cjs/features/rank.js.map +1 -1
- package/dist/cjs/features/types.d.cts +12 -4
- package/dist/cjs/features/types.d.ts +12 -4
- package/dist/cjs/index.d.cts +3 -3
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +9 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/output.d.cts +16 -0
- package/dist/cjs/output.d.ts +16 -0
- package/dist/cjs/output.js +27 -5
- package/dist/cjs/output.js.map +1 -1
- package/dist/cjs/progress.d.cts +5 -0
- package/dist/cjs/progress.d.ts +5 -0
- package/dist/cjs/progress.js +54 -0
- package/dist/cjs/progress.js.map +1 -0
- package/dist/cjs/scan.d.cts +4 -0
- package/dist/cjs/scan.d.ts +4 -0
- package/dist/cjs/scan.js +87 -6
- package/dist/cjs/scan.js.map +1 -1
- package/dist/esm/{commands → cli}/check.js +41 -22
- package/dist/esm/cli/check.js.map +1 -0
- package/dist/esm/{commands → cli}/index.js +1 -1
- package/dist/esm/cli/index.js.map +1 -0
- package/dist/esm/{commands → cli}/init.js +3 -0
- package/dist/esm/cli/init.js.map +1 -0
- package/dist/esm/{commands → cli}/map.js +1 -1
- package/dist/esm/cli/map.js.map +1 -0
- package/dist/esm/{commands → cli}/named.d.ts +1 -1
- package/dist/esm/cli/named.js +41 -0
- package/dist/esm/cli/named.js.map +1 -0
- package/dist/esm/{commands → cli}/peek.js +1 -1
- package/dist/esm/cli/peek.js.map +1 -0
- package/dist/esm/cli/query.js.map +1 -0
- package/dist/esm/cli/rebuild.js.map +1 -0
- package/dist/esm/cli/search.d.ts +3 -0
- package/dist/esm/cli/search.js +16 -0
- package/dist/esm/cli/search.js.map +1 -0
- package/dist/{cjs/commands → esm/cli}/shared.d.ts +1 -0
- package/dist/esm/{commands → cli}/shared.js +9 -0
- package/dist/esm/cli/shared.js.map +1 -0
- package/dist/esm/{commands → cli}/status.js +17 -11
- package/dist/esm/cli/status.js.map +1 -0
- package/dist/{cjs/commands → esm/cli}/types.d.ts +3 -1
- package/dist/esm/cli/types.js.map +1 -0
- package/dist/esm/cli/watch.js.map +1 -0
- package/dist/esm/cli.js +24 -6
- package/dist/esm/cli.js.map +1 -1
- package/dist/{cjs/verbs.d.ts → esm/commands.d.ts} +15 -5
- package/dist/esm/commands.js +386 -0
- package/dist/esm/commands.js.map +1 -0
- package/dist/esm/config.d.ts +45 -12
- package/dist/esm/config.js +367 -93
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/db.d.ts +1 -1
- package/dist/esm/db.js +126 -17
- package/dist/esm/db.js.map +1 -1
- package/dist/esm/errors.d.ts +1 -1
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/features/embed.js +18 -2
- package/dist/esm/features/embed.js.map +1 -1
- package/dist/esm/features/links.js +130 -20
- package/dist/esm/features/links.js.map +1 -1
- package/dist/esm/features/rank.js +8 -1
- package/dist/esm/features/rank.js.map +1 -1
- package/dist/esm/features/types.d.ts +12 -4
- package/dist/esm/features/types.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/output.d.ts +16 -0
- package/dist/esm/output.js +20 -5
- package/dist/esm/output.js.map +1 -1
- package/dist/esm/progress.d.ts +5 -0
- package/dist/esm/progress.js +44 -0
- package/dist/esm/progress.js.map +1 -0
- package/dist/esm/scan.d.ts +4 -0
- package/dist/esm/scan.js +37 -6
- package/dist/esm/scan.js.map +1 -1
- package/package.json +12 -2
- package/schema.json +85 -50
- package/skills/sense/EXAMPLES.md +16 -12
- package/skills/sense/SKILL.md +74 -55
- package/skills/sense-setup/EXAMPLES.md +121 -0
- package/skills/sense-setup/SKILL.md +73 -54
- package/dist/cjs/commands/check.js +0 -143
- package/dist/cjs/commands/check.js.map +0 -1
- package/dist/cjs/commands/find.d.cts +0 -3
- package/dist/cjs/commands/find.d.ts +0 -3
- package/dist/cjs/commands/find.js.map +0 -1
- package/dist/cjs/commands/index.js.map +0 -1
- package/dist/cjs/commands/init.js.map +0 -1
- package/dist/cjs/commands/map.js.map +0 -1
- package/dist/cjs/commands/named.js +0 -23
- package/dist/cjs/commands/named.js.map +0 -1
- package/dist/cjs/commands/peek.js.map +0 -1
- package/dist/cjs/commands/query.js.map +0 -1
- package/dist/cjs/commands/rebuild.js.map +0 -1
- package/dist/cjs/commands/shared.js.map +0 -1
- package/dist/cjs/commands/status.js.map +0 -1
- package/dist/cjs/commands/watch.js.map +0 -1
- package/dist/cjs/verbs.js.map +0 -1
- package/dist/esm/commands/check.js.map +0 -1
- package/dist/esm/commands/find.d.ts +0 -3
- package/dist/esm/commands/find.js +0 -15
- package/dist/esm/commands/find.js.map +0 -1
- package/dist/esm/commands/index.js.map +0 -1
- package/dist/esm/commands/init.js.map +0 -1
- package/dist/esm/commands/map.js.map +0 -1
- package/dist/esm/commands/named.js +0 -12
- package/dist/esm/commands/named.js.map +0 -1
- package/dist/esm/commands/peek.js.map +0 -1
- package/dist/esm/commands/query.js.map +0 -1
- package/dist/esm/commands/rebuild.js.map +0 -1
- package/dist/esm/commands/shared.js.map +0 -1
- package/dist/esm/commands/status.js.map +0 -1
- package/dist/esm/commands/types.js.map +0 -1
- package/dist/esm/commands/watch.js.map +0 -1
- package/dist/esm/verbs.js +0 -190
- package/dist/esm/verbs.js.map +0 -1
- /package/dist/cjs/{commands → cli}/check.d.cts +0 -0
- /package/dist/cjs/{commands → cli}/check.d.ts +0 -0
- /package/dist/cjs/{commands → cli}/index.d.cts +0 -0
- /package/dist/cjs/{commands → cli}/index.d.ts +0 -0
- /package/dist/cjs/{commands → cli}/init.d.cts +0 -0
- /package/dist/cjs/{commands → cli}/init.d.ts +0 -0
- /package/dist/cjs/{commands → cli}/map.d.cts +0 -0
- /package/dist/cjs/{commands → cli}/map.d.ts +0 -0
- /package/dist/cjs/{commands → cli}/peek.d.cts +0 -0
- /package/dist/cjs/{commands → cli}/peek.d.ts +0 -0
- /package/dist/cjs/{commands → cli}/query.d.cts +0 -0
- /package/dist/cjs/{commands → cli}/query.d.ts +0 -0
- /package/dist/cjs/{commands → cli}/query.js +0 -0
- /package/dist/cjs/{commands → cli}/rebuild.d.cts +0 -0
- /package/dist/cjs/{commands → cli}/rebuild.d.ts +0 -0
- /package/dist/cjs/{commands → cli}/rebuild.js +0 -0
- /package/dist/cjs/{commands → cli}/status.d.cts +0 -0
- /package/dist/cjs/{commands → cli}/status.d.ts +0 -0
- /package/dist/cjs/{commands → cli}/types.js +0 -0
- /package/dist/cjs/{commands → cli}/types.js.map +0 -0
- /package/dist/cjs/{commands → cli}/watch.d.cts +0 -0
- /package/dist/cjs/{commands → cli}/watch.d.ts +0 -0
- /package/dist/cjs/{commands → cli}/watch.js +0 -0
- /package/dist/esm/{commands → cli}/check.d.ts +0 -0
- /package/dist/esm/{commands → cli}/index.d.ts +0 -0
- /package/dist/esm/{commands → cli}/init.d.ts +0 -0
- /package/dist/esm/{commands → cli}/map.d.ts +0 -0
- /package/dist/esm/{commands → cli}/peek.d.ts +0 -0
- /package/dist/esm/{commands → cli}/query.d.ts +0 -0
- /package/dist/esm/{commands → cli}/query.js +0 -0
- /package/dist/esm/{commands → cli}/rebuild.d.ts +0 -0
- /package/dist/esm/{commands → cli}/rebuild.js +0 -0
- /package/dist/esm/{commands → cli}/status.d.ts +0 -0
- /package/dist/esm/{commands → cli}/types.js +0 -0
- /package/dist/esm/{commands → cli}/watch.d.ts +0 -0
- /package/dist/esm/{commands → cli}/watch.js +0 -0
|
@@ -9,16 +9,21 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
get find () {
|
|
13
|
-
return find;
|
|
14
|
-
},
|
|
15
12
|
get mapTree () {
|
|
16
13
|
return mapTree;
|
|
17
14
|
},
|
|
18
15
|
get peek () {
|
|
19
16
|
return peek;
|
|
17
|
+
},
|
|
18
|
+
get presetCoverage () {
|
|
19
|
+
return presetCoverage;
|
|
20
|
+
},
|
|
21
|
+
get search () {
|
|
22
|
+
return search;
|
|
20
23
|
}
|
|
21
24
|
});
|
|
25
|
+
var _nodefs = require("node:fs");
|
|
26
|
+
var _nodepath = require("node:path");
|
|
22
27
|
var _posix = /*#__PURE__*/ _interop_require_default(require("node:path/posix"));
|
|
23
28
|
var _configts = require("./config.js");
|
|
24
29
|
var _errorsts = require("./errors.js");
|
|
@@ -217,41 +222,236 @@ function _ts_generator(thisArg, body) {
|
|
|
217
222
|
};
|
|
218
223
|
}
|
|
219
224
|
}
|
|
220
|
-
// The three
|
|
225
|
+
// The three commands: mapTree (orient), search (locate), peek (structure).
|
|
221
226
|
// Each returns data; cli.ts renders. All of them degrade when a feature is off.
|
|
222
227
|
var WEIGHTED_BM25 = 'bm25(content, 10.0, 5.0, 1.0)';
|
|
223
228
|
var RRF_K = 60;
|
|
224
|
-
|
|
229
|
+
// FTS5 snippet() re-tokenizes the whole doc per candidate row, superlinearly: measured
|
|
230
|
+
// 2ms at 4KB docs but 189ms at 64KB for one query's pool, and ~10s for a single 1MB doc
|
|
231
|
+
// (plans/performance-findings.md finding A). 16KB keeps the whole pool's snippet cost in
|
|
232
|
+
// the low-ms range; bigger docs get the JS-computed excerpt, linear and only for the rows
|
|
233
|
+
// actually returned.
|
|
234
|
+
var SNIPPET_BOUND = 16384;
|
|
235
|
+
var EXCERPT_WINDOW = 160;
|
|
236
|
+
// Bare terms from an FTS5 query string: strips operators/quoting so the oversized-doc excerpt
|
|
237
|
+
// scan matches the same words the query matched on, not FTS5 syntax.
|
|
238
|
+
function extractBareTerms(query) {
|
|
239
|
+
var cleaned = query.replace(/"/g, ' ').replace(/[()*]/g, ' ').replace(/\b(AND|OR|NOT|NEAR)\b(\/\d+)?/gi, ' ');
|
|
240
|
+
return cleaned.split(/\s+/).map(function(tok) {
|
|
241
|
+
return tok.replace(/^[A-Za-z_]\w*:/, '');
|
|
242
|
+
}) // column filter, e.g. title:term
|
|
243
|
+
.map(function(tok) {
|
|
244
|
+
return tok.toLowerCase().trim();
|
|
245
|
+
}).filter(function(tok) {
|
|
246
|
+
return tok.length > 0;
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function findOccurrences(haystackLower, terms) {
|
|
250
|
+
var occ = [];
|
|
251
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
252
|
+
try {
|
|
253
|
+
for(var _iterator = terms[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
254
|
+
var term = _step.value;
|
|
255
|
+
var idx = 0;
|
|
256
|
+
for(;;){
|
|
257
|
+
var found = haystackLower.indexOf(term, idx);
|
|
258
|
+
if (found === -1) break;
|
|
259
|
+
occ.push({
|
|
260
|
+
start: found,
|
|
261
|
+
end: found + term.length,
|
|
262
|
+
term: term
|
|
263
|
+
});
|
|
264
|
+
idx = found + term.length;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
} catch (err) {
|
|
268
|
+
_didIteratorError = true;
|
|
269
|
+
_iteratorError = err;
|
|
270
|
+
} finally{
|
|
271
|
+
try {
|
|
272
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
273
|
+
_iterator.return();
|
|
274
|
+
}
|
|
275
|
+
} finally{
|
|
276
|
+
if (_didIteratorError) {
|
|
277
|
+
throw _iteratorError;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Longest span first at equal start, so "tests" beats its substring "test" and the
|
|
282
|
+
// whole word gets highlighted; the emit loop then absorbs the shorter overlap.
|
|
283
|
+
return occ.sort(function(a, b) {
|
|
284
|
+
return a.start - b.start || b.end - a.end;
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
// Slides a window over the sorted occurrences, same semantics as FTS5's own best-window
|
|
288
|
+
// pick: most distinct terms, ties broken by most total hits.
|
|
289
|
+
function bestWindowStart(occ, windowSize) {
|
|
290
|
+
var best = occ[0].start;
|
|
291
|
+
var bestDistinct = 0;
|
|
292
|
+
var bestCount = 0;
|
|
293
|
+
for(var i = 0; i < occ.length; i++){
|
|
294
|
+
var winEnd = occ[i].start + windowSize;
|
|
295
|
+
var seen = new Set();
|
|
296
|
+
var count = 0;
|
|
297
|
+
for(var j = i; j < occ.length && occ[j].start < winEnd; j++){
|
|
298
|
+
seen.add(occ[j].term);
|
|
299
|
+
count++;
|
|
300
|
+
}
|
|
301
|
+
if (seen.size > bestDistinct || seen.size === bestDistinct && count > bestCount) {
|
|
302
|
+
best = occ[i].start;
|
|
303
|
+
bestDistinct = seen.size;
|
|
304
|
+
bestCount = count;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return best;
|
|
308
|
+
}
|
|
309
|
+
// snippet()-shaped excerpt: matched terms wrapped in «», … at cut edges. Linear in doc
|
|
310
|
+
// length, only run for rows actually returned (<= k), unlike snippet()'s per-row cost.
|
|
311
|
+
function computeExcerpt(text, terms) {
|
|
312
|
+
var occ = findOccurrences(text.toLowerCase(), terms);
|
|
313
|
+
if (occ.length === 0) {
|
|
314
|
+
// This is a raw substring scan, not porter-stemmed: a doc matched only through a
|
|
315
|
+
// stemmed variant (query "negotiate" vs doc "negotiating") finds no occurrence here.
|
|
316
|
+
// Fall back to the doc's start, unmarked, rather than claim a match that isn't there.
|
|
317
|
+
var end = Math.min(text.length, EXCERPT_WINDOW);
|
|
318
|
+
return {
|
|
319
|
+
excerpt: "".concat(text.slice(0, end).replace(/\s+/g, ' ').trim()).concat(end < text.length ? '…' : ''),
|
|
320
|
+
offset: 0
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
var start = bestWindowStart(occ, EXCERPT_WINDOW);
|
|
324
|
+
var end1 = Math.min(text.length, start + EXCERPT_WINDOW);
|
|
325
|
+
var out = '';
|
|
326
|
+
var cursor = start;
|
|
327
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
328
|
+
try {
|
|
329
|
+
for(var _iterator = occ[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
330
|
+
var o = _step.value;
|
|
331
|
+
if (o.start < start || o.end > end1) continue;
|
|
332
|
+
// Occurrences of duplicate or substring-overlapping terms ("test tests") can overlap;
|
|
333
|
+
// emitting each would duplicate document text. Keep the first, absorb the rest.
|
|
334
|
+
if (o.start < cursor) continue;
|
|
335
|
+
out += "".concat(text.slice(cursor, o.start), "\xab").concat(text.slice(o.start, o.end), "\xbb");
|
|
336
|
+
cursor = o.end;
|
|
337
|
+
}
|
|
338
|
+
} catch (err) {
|
|
339
|
+
_didIteratorError = true;
|
|
340
|
+
_iteratorError = err;
|
|
341
|
+
} finally{
|
|
342
|
+
try {
|
|
343
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
344
|
+
_iterator.return();
|
|
345
|
+
}
|
|
346
|
+
} finally{
|
|
347
|
+
if (_didIteratorError) {
|
|
348
|
+
throw _iteratorError;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
out += text.slice(cursor, end1);
|
|
353
|
+
var prefix = start > 0 ? '…' : '';
|
|
354
|
+
var suffix = end1 < text.length ? '…' : '';
|
|
355
|
+
return {
|
|
356
|
+
excerpt: "".concat(prefix).concat(out.replace(/\s+/g, ' ')).concat(suffix),
|
|
357
|
+
offset: start
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
function lineNumberAt(text, offset) {
|
|
361
|
+
var line = 1;
|
|
362
|
+
for(var i = 0; i < offset; i++)if (text.charCodeAt(i) === 10) line++;
|
|
363
|
+
return line;
|
|
364
|
+
}
|
|
365
|
+
function lineRangeFor(db, path, line) {
|
|
366
|
+
var row = db.prepare('SELECT start_line, end_line FROM sections WHERE "path" = ? AND start_line <= ? AND end_line >= ? ORDER BY start_line DESC LIMIT 1').get(path, line, line);
|
|
367
|
+
return row ? "L".concat(row.start_line, "-").concat(row.end_line) : null;
|
|
368
|
+
}
|
|
369
|
+
// node:path's matchesGlob is experimental (stable behind an unstable-API flag) as of the
|
|
370
|
+
// engines floor (Node >=22.16); scope filtering only ever needs single-pattern matching, so
|
|
371
|
+
// it's used here in JS rather than pulling fast-glob's directory walk into the query path.
|
|
372
|
+
function inScope(path, include, exclude) {
|
|
373
|
+
if (!include.some(function(g) {
|
|
374
|
+
return (0, _nodepath.matchesGlob)(path, g);
|
|
375
|
+
})) return false;
|
|
376
|
+
if (exclude === null || exclude === void 0 ? void 0 : exclude.some(function(g) {
|
|
377
|
+
return (0, _nodepath.matchesGlob)(path, g);
|
|
378
|
+
})) return false;
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
function scopeHasEmbeddings(db, cfg, scopedPaths) {
|
|
382
|
+
if (!(0, _configts.anyPresetEmbeds)(cfg)) return false; // the embeddings table doesn't exist at all in this case
|
|
383
|
+
var rows = db.prepare('SELECT DISTINCT "path" FROM embeddings').all();
|
|
384
|
+
return rows.some(function(r) {
|
|
385
|
+
return scopedPaths.has(r.path);
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
function search(_0, _1, _2) {
|
|
225
389
|
return _async_to_generator(function(db, cfg, terms) {
|
|
226
|
-
var opts,
|
|
390
|
+
var opts, _hits_get, _chunkLines_get, _chunkSimilarity_get, effective, k, include, exclude, allPaths, scopedPaths, scopeActive, fetch, semanticEnabled, scope, whereJoin, whereCond, matchSql, matchRows, hits, oversized, candidates, edges, linked, seeds, ranked, chunkLines, chunkSimilarity, vec, insert, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, path, c, where, similarityCol, rows, bareTerms, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, row, text, _computeExcerpt, excerpt, offset;
|
|
227
391
|
var _arguments = arguments;
|
|
228
392
|
return _ts_generator(this, function(_state) {
|
|
229
393
|
switch(_state.label){
|
|
230
394
|
case 0:
|
|
231
395
|
opts = _arguments.length > 3 && _arguments[3] !== void 0 ? _arguments[3] : {};
|
|
232
|
-
|
|
233
|
-
|
|
396
|
+
effective = (0, _configts.resolveSearch)(cfg, opts);
|
|
397
|
+
k = effective.k, include = effective.include, exclude = effective.exclude;
|
|
398
|
+
allPaths = db.prepare('SELECT "path" FROM frontmatter').all().map(function(r) {
|
|
399
|
+
return r.path;
|
|
400
|
+
});
|
|
401
|
+
// A preset scope reads preset_files -- the coverage reconcile actually indexed with
|
|
402
|
+
// (fast-glob semantics); re-matching globs here with node:path's matchesGlob could
|
|
403
|
+
// silently disagree with it. Ad-hoc --include has no persisted coverage, so only that
|
|
404
|
+
// path pays the JS glob match.
|
|
405
|
+
scopedPaths = opts.include ? new Set(allPaths.filter(function(p) {
|
|
406
|
+
return inScope(p, include, exclude);
|
|
407
|
+
})) : new Set(db.prepare('SELECT "path" FROM preset_files WHERE preset = ?').all(effective.presetName).map(function(r) {
|
|
408
|
+
return r.path;
|
|
409
|
+
}));
|
|
410
|
+
// A scope narrower than the whole index needs a bigger candidate pool before filtering, or
|
|
411
|
+
// filtering can starve k even though enough in-scope matches exist further down the ranked
|
|
412
|
+
// list that a plain over-fetch wouldn't have reached.
|
|
413
|
+
scopeActive = scopedPaths.size < allPaths.length;
|
|
414
|
+
fetch = scopeActive ? Math.max(k * 5, 50) : Math.max(k * 3, 30);
|
|
415
|
+
// Semantic participation: vectors run only when the effective setting allows it AND the
|
|
416
|
+
// scope actually has embedded files -- a scope covered only by semantic-false presets (or
|
|
417
|
+
// by no preset embedding at all) searches lexically, automatically, no error.
|
|
418
|
+
semanticEnabled = effective.semantic && scopeHasEmbeddings(db, cfg, scopedPaths);
|
|
234
419
|
// Terms pass verbatim to FTS5 MATCH: bare words AND-join, operators are the caller's.
|
|
235
420
|
// Invalid syntax propagates as an error, zero matches return zero -- no silent rewrites.
|
|
236
421
|
// --where applies inside the candidate query (a post-filter over the top-N would drop
|
|
237
422
|
// matches ranked past the pool) and again on the final select for link-derived rows.
|
|
238
|
-
// An explicit --where replaces the
|
|
239
|
-
// so a caller can always widen back to the whole
|
|
240
|
-
scope =
|
|
423
|
+
// An explicit --where replaces the preset's declared where rather than ANDing with it,
|
|
424
|
+
// so a caller can always widen back to the whole scope.
|
|
425
|
+
scope = effective.where;
|
|
241
426
|
whereJoin = scope ? 'JOIN frontmatter f ON f."path" = content.path' : '';
|
|
242
427
|
whereCond = scope ? "AND (".concat(scope, ")") : '';
|
|
243
|
-
|
|
428
|
+
// Docs past SNIPPET_BOUND skip snippet() entirely -- SQLite
|
|
429
|
+
// short-circuits the untaken CASE branch, so it's never invoked on them.
|
|
430
|
+
matchSql = "SELECT content.path AS path, CASE WHEN length(content.text) <= ".concat(SNIPPET_BOUND, " THEN snippet(content, -1, '\xab', '\xbb', '…', 10) ELSE NULL END AS hit FROM content ").concat(whereJoin, " WHERE content MATCH ? ").concat(whereCond, " ORDER BY ").concat(WEIGHTED_BM25, " LIMIT ").concat(fetch);
|
|
244
431
|
try {
|
|
245
432
|
matchRows = db.prepare(matchSql).all(terms);
|
|
246
433
|
} catch (err) {
|
|
247
434
|
throw (0, _searcherrorts.searchError)(err, terms, scope);
|
|
248
435
|
}
|
|
436
|
+
// Scope filtering happens in JS, on each candidate list, rather than in SQL: FTS5 match,
|
|
437
|
+
// link expansion, and vector search all run unscoped above (cheap to over-fetch), then get
|
|
438
|
+
// filtered here against the effective include/exclude before ranking is finalized.
|
|
439
|
+
matchRows = matchRows.filter(function(r) {
|
|
440
|
+
return scopedPaths.has(r.path);
|
|
441
|
+
});
|
|
249
442
|
hits = new Map(matchRows.map(function(r) {
|
|
250
443
|
return [
|
|
251
444
|
r.path,
|
|
252
445
|
r.hit
|
|
253
446
|
];
|
|
254
447
|
}));
|
|
448
|
+
// hit === null here means the bound suppressed snippet(), not "no match" -- distinguish
|
|
449
|
+
// from via='link' rows (never in matchRows, so absent from this set) below.
|
|
450
|
+
oversized = new Set(matchRows.filter(function(r) {
|
|
451
|
+
return r.hit === null;
|
|
452
|
+
}).map(function(r) {
|
|
453
|
+
return r.path;
|
|
454
|
+
}));
|
|
255
455
|
candidates = new Map();
|
|
256
456
|
matchRows.forEach(function(r, i) {
|
|
257
457
|
candidates.set(r.path, {
|
|
@@ -266,18 +466,15 @@ function find(_0, _1, _2) {
|
|
|
266
466
|
// that mass from the score list reweights fusion toward connectivity and measurably
|
|
267
467
|
// wrecks ranking on link-dense corpora (FEVER hit@10 0.997 -> 0.907; fusion-tuning.md).
|
|
268
468
|
linked = new Set(edges.flat());
|
|
269
|
-
nodes = db.prepare('SELECT "path" FROM frontmatter').all().map(function(r) {
|
|
270
|
-
return r.path;
|
|
271
|
-
});
|
|
272
469
|
seeds = new Map(matchRows.map(function(r, i) {
|
|
273
470
|
return [
|
|
274
471
|
r.path,
|
|
275
472
|
1 / (i + 1)
|
|
276
473
|
];
|
|
277
474
|
}));
|
|
278
|
-
ranked = _to_consumable_array((0, _graphts.personalizedRank)(
|
|
279
|
-
var _param = _sliced_to_array(param, 2), score = _param[1];
|
|
280
|
-
return score > 1e-9;
|
|
475
|
+
ranked = _to_consumable_array((0, _graphts.personalizedRank)(allPaths, edges, seeds)).filter(function(param) {
|
|
476
|
+
var _param = _sliced_to_array(param, 2), path = _param[0], score = _param[1];
|
|
477
|
+
return score > 1e-9 && scopedPaths.has(path);
|
|
281
478
|
}).sort(function(a, b) {
|
|
282
479
|
return b[1] - a[1];
|
|
283
480
|
}).slice(0, fetch);
|
|
@@ -299,7 +496,7 @@ function find(_0, _1, _2) {
|
|
|
299
496
|
// (weight 1, pool = fetch). Each row carries its best chunk's line range.
|
|
300
497
|
chunkLines = new Map();
|
|
301
498
|
chunkSimilarity = new Map();
|
|
302
|
-
if (!
|
|
499
|
+
if (!semanticEnabled) return [
|
|
303
500
|
3,
|
|
304
501
|
2
|
|
305
502
|
];
|
|
@@ -308,7 +505,9 @@ function find(_0, _1, _2) {
|
|
|
308
505
|
(0, _embedts.semanticCandidates)(db, cfg, terms, fetch)
|
|
309
506
|
];
|
|
310
507
|
case 1:
|
|
311
|
-
vec = _state.sent()
|
|
508
|
+
vec = _state.sent().filter(function(v) {
|
|
509
|
+
return scopedPaths.has(v.path);
|
|
510
|
+
});
|
|
312
511
|
vec.forEach(function(param, i) {
|
|
313
512
|
var path = param.path, lines = param.lines, similarity = param.similarity;
|
|
314
513
|
chunkLines.set(path, lines);
|
|
@@ -349,22 +548,81 @@ function find(_0, _1, _2) {
|
|
|
349
548
|
}
|
|
350
549
|
}
|
|
351
550
|
}
|
|
352
|
-
|
|
353
|
-
|
|
551
|
+
// Every candidate list was already filtered to scopedPaths above, so _find only ever holds
|
|
552
|
+
// in-scope rows -- the final select just needs --where again, same as before, for rows
|
|
553
|
+
// whichever candidate query didn't itself apply it to (link-derived rows never touched
|
|
554
|
+
// whereCond above).
|
|
555
|
+
where = scope ? "WHERE (".concat(scope, ")") : '';
|
|
556
|
+
// lines is always present now: semantic rows carry their chunk's range, oversized-doc
|
|
557
|
+
// lexical rows gain one below, everything else stays null. similarity stays semantic-only.
|
|
558
|
+
similarityCol = semanticEnabled ? ', _find.similarity' : '';
|
|
559
|
+
rows = db.prepare('SELECT f."path" AS path, content.title, content.summary, _find.hit, _find.via, round(_find.score, 4) AS score, _find.lines'.concat(similarityCol, '\n FROM _find JOIN frontmatter f ON f."path" = _find."path" JOIN content ON content.path = _find."path"\n ').concat(where, " ORDER BY _find.score DESC LIMIT ?")).all(k);
|
|
560
|
+
if (oversized.size > 0) {
|
|
561
|
+
bareTerms = extractBareTerms(terms);
|
|
562
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
563
|
+
try {
|
|
564
|
+
for(_iterator1 = rows[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
565
|
+
row = _step1.value;
|
|
566
|
+
if (row.hit !== null || !oversized.has(row.path)) continue;
|
|
567
|
+
text = void 0;
|
|
568
|
+
try {
|
|
569
|
+
text = (0, _nodefs.readFileSync)((0, _nodepath.join)(cfg.baseDir, row.path), 'utf8');
|
|
570
|
+
} catch (unused) {
|
|
571
|
+
continue; // vanished since the match; leave hit/lines null rather than throw
|
|
572
|
+
}
|
|
573
|
+
_computeExcerpt = computeExcerpt(text, bareTerms), excerpt = _computeExcerpt.excerpt, offset = _computeExcerpt.offset;
|
|
574
|
+
row.hit = excerpt;
|
|
575
|
+
if (row.lines == null) row.lines = (0, _configts.featureEnabled)(cfg, 'sections') ? lineRangeFor(db, row.path, lineNumberAt(text, offset)) : null;
|
|
576
|
+
}
|
|
577
|
+
} catch (err) {
|
|
578
|
+
_didIteratorError1 = true;
|
|
579
|
+
_iteratorError1 = err;
|
|
580
|
+
} finally{
|
|
581
|
+
try {
|
|
582
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
583
|
+
_iterator1.return();
|
|
584
|
+
}
|
|
585
|
+
} finally{
|
|
586
|
+
if (_didIteratorError1) {
|
|
587
|
+
throw _iteratorError1;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
354
592
|
return [
|
|
355
593
|
2,
|
|
356
|
-
|
|
594
|
+
rows
|
|
357
595
|
];
|
|
358
596
|
}
|
|
359
597
|
});
|
|
360
598
|
}).apply(this, arguments);
|
|
361
599
|
}
|
|
600
|
+
function presetCoverage(db, cfg) {
|
|
601
|
+
var embedActive = (0, _configts.anyPresetEmbeds)(cfg);
|
|
602
|
+
return (0, _configts.presetNames)(cfg).map(function(name) {
|
|
603
|
+
var files = db.prepare('SELECT COUNT(*) AS n FROM preset_files WHERE preset = ?').get(name).n;
|
|
604
|
+
var embedded = embedActive ? db.prepare('SELECT COUNT(*) AS n FROM preset_files pf WHERE pf.preset = ? AND EXISTS (SELECT 1 FROM embeddings e WHERE e."path" = pf."path" AND e.vector IS NOT NULL)').get(name).n : 0;
|
|
605
|
+
return {
|
|
606
|
+
name: name,
|
|
607
|
+
files: files,
|
|
608
|
+
embedded: embedded
|
|
609
|
+
};
|
|
610
|
+
});
|
|
611
|
+
}
|
|
362
612
|
var INTERNAL_COLUMNS = new Set([
|
|
363
613
|
'path',
|
|
364
614
|
'_mtime',
|
|
365
615
|
'_size',
|
|
366
616
|
'_rank'
|
|
367
617
|
]);
|
|
618
|
+
// A result row is capped at SQLITE_MAX_COLUMN (2000, default); two aggregate expressions
|
|
619
|
+
// per field keeps a chunk's row safely under that regardless of how many fields the tree has.
|
|
620
|
+
var MAP_COLUMN_CHUNK = 300;
|
|
621
|
+
function chunk(items, size) {
|
|
622
|
+
var out = [];
|
|
623
|
+
for(var i = 0; i < items.length; i += size)out.push(items.slice(i, i + size));
|
|
624
|
+
return out;
|
|
625
|
+
}
|
|
368
626
|
function mapTree(db, cfg) {
|
|
369
627
|
var docs = db.prepare('SELECT COUNT(*) AS count, COALESCE(SUM("_size"), 0) AS bytes FROM frontmatter').get();
|
|
370
628
|
var columns = db.prepare('PRAGMA table_info(frontmatter)').all().map(function(r) {
|
|
@@ -372,18 +630,47 @@ function mapTree(db, cfg) {
|
|
|
372
630
|
}).filter(function(name) {
|
|
373
631
|
return !INTERNAL_COLUMNS.has(name);
|
|
374
632
|
});
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
633
|
+
// Observed storage class, not a declared one: these columns are added dynamically and
|
|
634
|
+
// SQLite types per value, so a field can be text in most notes and numeric in a few.
|
|
635
|
+
// Listing every distinct type makes both the type and any drift visible.
|
|
636
|
+
// One aggregate scan per chunk of columns rather than one scan per column: COUNT already
|
|
637
|
+
// ignores NULL, and FILTER keeps typeof() looking only at the non-null rows COUNT counted,
|
|
638
|
+
// matching the old per-column `WHERE ... IS NOT NULL` exactly.
|
|
639
|
+
var allFields = [];
|
|
640
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
641
|
+
try {
|
|
642
|
+
var _loop = function() {
|
|
643
|
+
var group = _step.value;
|
|
644
|
+
var exprs = group.map(function(name, i) {
|
|
645
|
+
var quoted = '"'.concat(name.split('"').join('""'), '"');
|
|
646
|
+
return "COUNT(".concat(quoted, ") AS n").concat(i, ", GROUP_CONCAT(DISTINCT typeof(").concat(quoted, ")) FILTER (WHERE ").concat(quoted, " IS NOT NULL) AS t").concat(i);
|
|
647
|
+
});
|
|
648
|
+
var result = db.prepare("SELECT ".concat(exprs.join(', '), " FROM frontmatter")).get();
|
|
649
|
+
group.forEach(function(name, i) {
|
|
650
|
+
var _result_;
|
|
651
|
+
return allFields.push({
|
|
652
|
+
field: name,
|
|
653
|
+
coverage: result["n".concat(i)],
|
|
654
|
+
type: (_result_ = result["t".concat(i)]) !== null && _result_ !== void 0 ? _result_ : ''
|
|
655
|
+
});
|
|
656
|
+
});
|
|
385
657
|
};
|
|
386
|
-
|
|
658
|
+
for(var _iterator = chunk(columns, MAP_COLUMN_CHUNK)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
659
|
+
} catch (err) {
|
|
660
|
+
_didIteratorError = true;
|
|
661
|
+
_iteratorError = err;
|
|
662
|
+
} finally{
|
|
663
|
+
try {
|
|
664
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
665
|
+
_iterator.return();
|
|
666
|
+
}
|
|
667
|
+
} finally{
|
|
668
|
+
if (_didIteratorError) {
|
|
669
|
+
throw _iteratorError;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
allFields.sort(function(a, b) {
|
|
387
674
|
return b.coverage - a.coverage;
|
|
388
675
|
});
|
|
389
676
|
var fields = allFields.slice(0, 20);
|
|
@@ -394,11 +681,12 @@ function mapTree(db, cfg) {
|
|
|
394
681
|
fields: fields,
|
|
395
682
|
fieldsTotal: allFields.length,
|
|
396
683
|
features: (0, _configts.featureStates)(cfg),
|
|
684
|
+
presets: presetCoverage(db, cfg),
|
|
397
685
|
hubs: hubs,
|
|
398
686
|
recent: recent
|
|
399
687
|
};
|
|
400
688
|
}
|
|
401
|
-
var
|
|
689
|
+
var PEEK_LIST_LIMIT = 20;
|
|
402
690
|
function peek(db, cfg, pathArg) {
|
|
403
691
|
var _row__size;
|
|
404
692
|
var paths = db.prepare('SELECT "path" FROM frontmatter').all().map(function(r) {
|
|
@@ -438,7 +726,8 @@ function peek(db, cfg, pathArg) {
|
|
|
438
726
|
}
|
|
439
727
|
}
|
|
440
728
|
}
|
|
441
|
-
var
|
|
729
|
+
var sectionsTotal = (0, _configts.featureEnabled)(cfg, 'sections') ? db.prepare('SELECT COUNT(*) AS n FROM sections WHERE "path" = ?').get(path).n : 0;
|
|
730
|
+
var sections = (0, _configts.featureEnabled)(cfg, 'sections') ? db.prepare('SELECT level, heading, start_line, end_line, tokens FROM sections WHERE "path" = ? ORDER BY idx LIMIT ?').all(path, PEEK_LIST_LIMIT) : [];
|
|
442
731
|
var outbound = [];
|
|
443
732
|
var backlinks = [];
|
|
444
733
|
var unresolved = [];
|
|
@@ -456,7 +745,7 @@ function peek(db, cfg, pathArg) {
|
|
|
456
745
|
return l.target;
|
|
457
746
|
});
|
|
458
747
|
backlinksTotal = db.prepare('SELECT COUNT(DISTINCT src) AS n FROM links WHERE dst = ?').get(path).n;
|
|
459
|
-
backlinks = db.prepare('SELECT DISTINCT src FROM links WHERE dst = ? ORDER BY src LIMIT ?').all(path,
|
|
748
|
+
backlinks = db.prepare('SELECT DISTINCT src FROM links WHERE dst = ? ORDER BY src LIMIT ?').all(path, PEEK_LIST_LIMIT).map(function(r) {
|
|
460
749
|
return r.src;
|
|
461
750
|
});
|
|
462
751
|
}
|
|
@@ -465,9 +754,10 @@ function peek(db, cfg, pathArg) {
|
|
|
465
754
|
tokens: Math.ceil(((_row__size = row._size) !== null && _row__size !== void 0 ? _row__size : 0) / 4),
|
|
466
755
|
frontmatter: frontmatter,
|
|
467
756
|
sections: sections,
|
|
468
|
-
outbound: outbound.slice(0,
|
|
757
|
+
outbound: outbound.slice(0, PEEK_LIST_LIMIT),
|
|
469
758
|
backlinks: backlinks,
|
|
470
|
-
unresolved: unresolved.slice(0,
|
|
759
|
+
unresolved: unresolved.slice(0, PEEK_LIST_LIMIT),
|
|
760
|
+
sectionsTotal: sectionsTotal,
|
|
471
761
|
outboundTotal: outbound.length,
|
|
472
762
|
backlinksTotal: backlinksTotal,
|
|
473
763
|
unresolvedTotal: unresolved.length,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/commands.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { join, matchesGlob } from 'node:path';\nimport posix from 'node:path/posix';\nimport type { DatabaseSync } from 'node:sqlite';\nimport type { FeatureName, ResolvedConfig } from './config.ts';\nimport { anyPresetEmbeds, featureEnabled, featureStates, presetNames, resolveSearch } from './config.ts';\nimport { SenseError } from './errors.ts';\nimport { semanticCandidates } from './features/embed.ts';\nimport { linkEdges } from './features/index.ts';\nimport { personalizedRank } from './graph.ts';\nimport type { Row } from './output.ts';\nimport { searchError } from './search-error.ts';\n\n// The three commands: mapTree (orient), search (locate), peek (structure).\n// Each returns data; cli.ts renders. All of them degrade when a feature is off.\n\nconst WEIGHTED_BM25 = 'bm25(content, 10.0, 5.0, 1.0)';\nconst RRF_K = 60;\n\n// FTS5 snippet() re-tokenizes the whole doc per candidate row, superlinearly: measured\n// 2ms at 4KB docs but 189ms at 64KB for one query's pool, and ~10s for a single 1MB doc\n// (plans/performance-findings.md finding A). 16KB keeps the whole pool's snippet cost in\n// the low-ms range; bigger docs get the JS-computed excerpt, linear and only for the rows\n// actually returned.\nconst SNIPPET_BOUND = 16_384;\nconst EXCERPT_WINDOW = 160;\n\n// Bare terms from an FTS5 query string: strips operators/quoting so the oversized-doc excerpt\n// scan matches the same words the query matched on, not FTS5 syntax.\nfunction extractBareTerms(query: string): string[] {\n const cleaned = query\n .replace(/\"/g, ' ')\n .replace(/[()*]/g, ' ')\n .replace(/\\b(AND|OR|NOT|NEAR)\\b(\\/\\d+)?/gi, ' ');\n return cleaned\n .split(/\\s+/)\n .map((tok) => tok.replace(/^[A-Za-z_]\\w*:/, '')) // column filter, e.g. title:term\n .map((tok) => tok.toLowerCase().trim())\n .filter((tok) => tok.length > 0);\n}\n\nfunction findOccurrences(haystackLower: string, terms: string[]): Array<{ start: number; end: number; term: string }> {\n const occ: Array<{ start: number; end: number; term: string }> = [];\n for (const term of terms) {\n let idx = 0;\n for (;;) {\n const found = haystackLower.indexOf(term, idx);\n if (found === -1) break;\n occ.push({ start: found, end: found + term.length, term });\n idx = found + term.length;\n }\n }\n // Longest span first at equal start, so \"tests\" beats its substring \"test\" and the\n // whole word gets highlighted; the emit loop then absorbs the shorter overlap.\n return occ.sort((a, b) => a.start - b.start || b.end - a.end);\n}\n\n// Slides a window over the sorted occurrences, same semantics as FTS5's own best-window\n// pick: most distinct terms, ties broken by most total hits.\nfunction bestWindowStart(occ: Array<{ start: number; end: number; term: string }>, windowSize: number): number {\n let best = occ[0].start;\n let bestDistinct = 0;\n let bestCount = 0;\n for (let i = 0; i < occ.length; i++) {\n const winEnd = occ[i].start + windowSize;\n const seen = new Set<string>();\n let count = 0;\n for (let j = i; j < occ.length && occ[j].start < winEnd; j++) {\n seen.add(occ[j].term);\n count++;\n }\n if (seen.size > bestDistinct || (seen.size === bestDistinct && count > bestCount)) {\n best = occ[i].start;\n bestDistinct = seen.size;\n bestCount = count;\n }\n }\n return best;\n}\n\n// snippet()-shaped excerpt: matched terms wrapped in «», … at cut edges. Linear in doc\n// length, only run for rows actually returned (<= k), unlike snippet()'s per-row cost.\nfunction computeExcerpt(text: string, terms: string[]): { excerpt: string; offset: number } {\n const occ = findOccurrences(text.toLowerCase(), terms);\n if (occ.length === 0) {\n // This is a raw substring scan, not porter-stemmed: a doc matched only through a\n // stemmed variant (query \"negotiate\" vs doc \"negotiating\") finds no occurrence here.\n // Fall back to the doc's start, unmarked, rather than claim a match that isn't there.\n const end = Math.min(text.length, EXCERPT_WINDOW);\n return { excerpt: `${text.slice(0, end).replace(/\\s+/g, ' ').trim()}${end < text.length ? '…' : ''}`, offset: 0 };\n }\n const start = bestWindowStart(occ, EXCERPT_WINDOW);\n const end = Math.min(text.length, start + EXCERPT_WINDOW);\n let out = '';\n let cursor = start;\n for (const o of occ) {\n if (o.start < start || o.end > end) continue;\n // Occurrences of duplicate or substring-overlapping terms (\"test tests\") can overlap;\n // emitting each would duplicate document text. Keep the first, absorb the rest.\n if (o.start < cursor) continue;\n out += `${text.slice(cursor, o.start)}«${text.slice(o.start, o.end)}»`;\n cursor = o.end;\n }\n out += text.slice(cursor, end);\n const prefix = start > 0 ? '…' : '';\n const suffix = end < text.length ? '…' : '';\n return { excerpt: `${prefix}${out.replace(/\\s+/g, ' ')}${suffix}`, offset: start };\n}\n\nfunction lineNumberAt(text: string, offset: number): number {\n let line = 1;\n for (let i = 0; i < offset; i++) if (text.charCodeAt(i) === 10) line++;\n return line;\n}\n\nfunction lineRangeFor(db: DatabaseSync, path: string, line: number): string | null {\n const row = db.prepare('SELECT start_line, end_line FROM sections WHERE \"path\" = ? AND start_line <= ? AND end_line >= ? ORDER BY start_line DESC LIMIT 1').get(path, line, line) as { start_line: number; end_line: number } | undefined;\n return row ? `L${row.start_line}-${row.end_line}` : null;\n}\n\nexport interface SearchOptions {\n k?: number;\n where?: string; // SQL fragment against frontmatter alias `f`, e.g. \"f.status = 'active'\"\n preset?: string; // named preset; unknown name throws listing declared presets, undefined -> \"default\"\n include?: string[]; // ad hoc scope override (repeatable --include); replaces the preset's include/exclude\n semantic?: boolean; // false opts out of vector participation regardless of the preset\n}\n\n// node:path's matchesGlob is experimental (stable behind an unstable-API flag) as of the\n// engines floor (Node >=22.16); scope filtering only ever needs single-pattern matching, so\n// it's used here in JS rather than pulling fast-glob's directory walk into the query path.\nfunction inScope(path: string, include: string[], exclude?: string[]): boolean {\n if (!include.some((g) => matchesGlob(path, g))) return false;\n if (exclude?.some((g) => matchesGlob(path, g))) return false;\n return true;\n}\n\nfunction scopeHasEmbeddings(db: DatabaseSync, cfg: ResolvedConfig, scopedPaths: Set<string>): boolean {\n if (!anyPresetEmbeds(cfg)) return false; // the embeddings table doesn't exist at all in this case\n const rows = db.prepare('SELECT DISTINCT \"path\" FROM embeddings').all() as Array<{ path: string }>;\n return rows.some((r) => scopedPaths.has(r.path));\n}\n\n// BM25 + link-graph expansion, fused by reciprocal rank. `via` says which signal produced\n// each row so the agent knows what evidence it is trusting.\n// Resolution precedence (built-ins <- preset <- caller overrides) lives in\n// src/config.ts:resolveSearch; `opts` here is whatever the caller (a saved search merged\n// with any CLI flag, or a bare CLI invocation) already resolved.\nexport async function search(db: DatabaseSync, cfg: ResolvedConfig, terms: string, opts: SearchOptions = {}): Promise<Row[]> {\n const effective = resolveSearch(cfg, opts);\n const { k, include, exclude } = effective;\n\n const allPaths = (db.prepare('SELECT \"path\" FROM frontmatter').all() as Array<{ path: string }>).map((r) => r.path);\n // A preset scope reads preset_files -- the coverage reconcile actually indexed with\n // (fast-glob semantics); re-matching globs here with node:path's matchesGlob could\n // silently disagree with it. Ad-hoc --include has no persisted coverage, so only that\n // path pays the JS glob match.\n const scopedPaths = opts.include ? new Set(allPaths.filter((p) => inScope(p, include, exclude))) : new Set((db.prepare('SELECT \"path\" FROM preset_files WHERE preset = ?').all(effective.presetName) as Array<{ path: string }>).map((r) => r.path));\n // A scope narrower than the whole index needs a bigger candidate pool before filtering, or\n // filtering can starve k even though enough in-scope matches exist further down the ranked\n // list that a plain over-fetch wouldn't have reached.\n const scopeActive = scopedPaths.size < allPaths.length;\n const fetch = scopeActive ? Math.max(k * 5, 50) : Math.max(k * 3, 30);\n\n // Semantic participation: vectors run only when the effective setting allows it AND the\n // scope actually has embedded files -- a scope covered only by semantic-false presets (or\n // by no preset embedding at all) searches lexically, automatically, no error.\n const semanticEnabled = effective.semantic && scopeHasEmbeddings(db, cfg, scopedPaths);\n\n // Terms pass verbatim to FTS5 MATCH: bare words AND-join, operators are the caller's.\n // Invalid syntax propagates as an error, zero matches return zero -- no silent rewrites.\n // --where applies inside the candidate query (a post-filter over the top-N would drop\n // matches ranked past the pool) and again on the final select for link-derived rows.\n // An explicit --where replaces the preset's declared where rather than ANDing with it,\n // so a caller can always widen back to the whole scope.\n const scope = effective.where;\n const whereJoin = scope ? `JOIN frontmatter f ON f.\"path\" = content.path` : '';\n const whereCond = scope ? `AND (${scope})` : '';\n // Docs past SNIPPET_BOUND skip snippet() entirely -- SQLite\n // short-circuits the untaken CASE branch, so it's never invoked on them.\n const matchSql = `SELECT content.path AS path, CASE WHEN length(content.text) <= ${SNIPPET_BOUND} THEN snippet(content, -1, '«', '»', '…', 10) ELSE NULL END AS hit FROM content ${whereJoin} WHERE content MATCH ? ${whereCond} ORDER BY ${WEIGHTED_BM25} LIMIT ${fetch}`;\n let matchRows: Array<{ path: string; hit: string | null }>;\n try {\n matchRows = db.prepare(matchSql).all(terms) as Array<{ path: string; hit: string | null }>;\n } catch (err) {\n throw searchError(err as Error, terms, scope);\n }\n // Scope filtering happens in JS, on each candidate list, rather than in SQL: FTS5 match,\n // link expansion, and vector search all run unscoped above (cheap to over-fetch), then get\n // filtered here against the effective include/exclude before ranking is finalized.\n matchRows = matchRows.filter((r) => scopedPaths.has(r.path));\n\n const hits = new Map(matchRows.map((r) => [r.path, r.hit]));\n // hit === null here means the bound suppressed snippet(), not \"no match\" -- distinguish\n // from via='link' rows (never in matchRows, so absent from this set) below.\n const oversized = new Set(matchRows.filter((r) => r.hit === null).map((r) => r.path));\n const candidates = new Map<string, { score: number; via: string }>();\n matchRows.forEach((r, i) => {\n candidates.set(r.path, { score: 1 / (RRF_K + i), via: 'match' });\n });\n\n const edges = featureEnabled(cfg, 'links') && matchRows.length > 0 ? linkEdges(db) : [];\n if (edges.length > 0) {\n // `linked` gates the label only, not the score: PPR restart mass gives every seed a\n // nonzero rank even without an incident edge, which is not link evidence — but dropping\n // that mass from the score list reweights fusion toward connectivity and measurably\n // wrecks ranking on link-dense corpora (FEVER hit@10 0.997 -> 0.907; fusion-tuning.md).\n const linked = new Set(edges.flat());\n const seeds = new Map(matchRows.map((r, i) => [r.path, 1 / (i + 1)]));\n const ranked = [...personalizedRank(allPaths, edges, seeds)]\n .filter(([path, score]) => score > 1e-9 && scopedPaths.has(path))\n .sort((a, b) => b[1] - a[1])\n .slice(0, fetch);\n ranked.forEach(([path], i) => {\n const existing = candidates.get(path);\n if (existing) {\n existing.score += 1 / (RRF_K + i);\n if (linked.has(path)) existing.via = 'match+link';\n } else {\n candidates.set(path, { score: 1 / (RRF_K + i), via: 'link' });\n }\n });\n }\n\n // Vector expansion, invoked only: a third RRF list at the swept flat-region constants\n // (weight 1, pool = fetch). Each row carries its best chunk's line range.\n const chunkLines = new Map<string, string>();\n const chunkSimilarity = new Map<string, number>();\n if (semanticEnabled) {\n const vec = (await semanticCandidates(db, cfg, terms, fetch)).filter((v) => scopedPaths.has(v.path));\n vec.forEach(({ path, lines, similarity }, i) => {\n chunkLines.set(path, lines);\n chunkSimilarity.set(path, similarity);\n const existing = candidates.get(path);\n if (existing) {\n existing.score += 1 / (RRF_K + i);\n existing.via = `${existing.via}+vector`;\n } else {\n candidates.set(path, { score: 1 / (RRF_K + i), via: 'vector' });\n }\n });\n }\n\n db.exec('DROP TABLE IF EXISTS _find');\n db.exec('CREATE TEMP TABLE _find (\"path\" TEXT PRIMARY KEY, score REAL, via TEXT, hit TEXT, lines TEXT, similarity REAL)');\n const insert = db.prepare('INSERT INTO _find (\"path\", score, via, hit, lines, similarity) VALUES (?, ?, ?, ?, ?, ?)');\n for (const [path, c] of candidates) insert.run(path, c.score, c.via, hits.get(path) ?? null, chunkLines.get(path) ?? null, chunkSimilarity.get(path) ?? null);\n\n // Every candidate list was already filtered to scopedPaths above, so _find only ever holds\n // in-scope rows -- the final select just needs --where again, same as before, for rows\n // whichever candidate query didn't itself apply it to (link-derived rows never touched\n // whereCond above).\n const where = scope ? `WHERE (${scope})` : '';\n // lines is always present now: semantic rows carry their chunk's range, oversized-doc\n // lexical rows gain one below, everything else stays null. similarity stays semantic-only.\n const similarityCol = semanticEnabled ? ', _find.similarity' : '';\n const rows = db\n .prepare(\n `SELECT f.\"path\" AS path, content.title, content.summary, _find.hit, _find.via, round(_find.score, 4) AS score, _find.lines${similarityCol}\n FROM _find JOIN frontmatter f ON f.\"path\" = _find.\"path\" JOIN content ON content.path = _find.\"path\"\n ${where} ORDER BY _find.score DESC LIMIT ?`\n )\n .all(k) as Row[];\n\n if (oversized.size > 0) {\n const bareTerms = extractBareTerms(terms);\n for (const row of rows) {\n if (row.hit !== null || !oversized.has(row.path as string)) continue;\n let text: string;\n try {\n text = readFileSync(join(cfg.baseDir, row.path as string), 'utf8');\n } catch {\n continue; // vanished since the match; leave hit/lines null rather than throw\n }\n const { excerpt, offset } = computeExcerpt(text, bareTerms);\n row.hit = excerpt;\n if (row.lines == null) row.lines = featureEnabled(cfg, 'sections') ? lineRangeFor(db, row.path as string, lineNumberAt(text, offset)) : null;\n }\n }\n\n return rows;\n}\n\nexport interface PresetCoverage {\n name: string;\n files: number;\n embedded: number;\n}\n\n// Indexing and embedding are both derived from presets rather than declared directly, so\n// that derivation must stay visible: how many files each preset actually matched, and how\n// many of those are covered by embedding. Read from preset_files (rebuilt at reconcile), not\n// recomputed from globs, so this always reflects what's actually on disk in the cache.\nexport function presetCoverage(db: DatabaseSync, cfg: ResolvedConfig): PresetCoverage[] {\n const embedActive = anyPresetEmbeds(cfg);\n return presetNames(cfg).map((name) => {\n const files = (db.prepare('SELECT COUNT(*) AS n FROM preset_files WHERE preset = ?').get(name) as { n: number }).n;\n const embedded = embedActive ? (db.prepare('SELECT COUNT(*) AS n FROM preset_files pf WHERE pf.preset = ? AND EXISTS (SELECT 1 FROM embeddings e WHERE e.\"path\" = pf.\"path\" AND e.vector IS NOT NULL)').get(name) as { n: number }).n : 0;\n return { name, files, embedded };\n });\n}\n\nexport interface TreeMap {\n docs: { count: number; bytes: number };\n fields: Row[]; // top 20 by coverage; fieldsTotal carries the real count\n fieldsTotal: number;\n features: { on: FeatureName[]; off: FeatureName[] };\n presets: PresetCoverage[];\n hubs: Row[];\n recent: Row[];\n}\n\nconst INTERNAL_COLUMNS = new Set(['path', '_mtime', '_size', '_rank']);\n\n// A result row is capped at SQLITE_MAX_COLUMN (2000, default); two aggregate expressions\n// per field keeps a chunk's row safely under that regardless of how many fields the tree has.\nconst MAP_COLUMN_CHUNK = 300;\n\nfunction chunk<T>(items: T[], size: number): T[][] {\n const out: T[][] = [];\n for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));\n return out;\n}\n\n// mapTree: what is this tree. Fixed-size output regardless of tree size.\nexport function mapTree(db: DatabaseSync, cfg: ResolvedConfig): TreeMap {\n const docs = db.prepare('SELECT COUNT(*) AS count, COALESCE(SUM(\"_size\"), 0) AS bytes FROM frontmatter').get() as { count: number; bytes: number };\n\n const columns = (db.prepare('PRAGMA table_info(frontmatter)').all() as Array<{ name: string }>).map((r) => r.name).filter((name) => !INTERNAL_COLUMNS.has(name));\n // Observed storage class, not a declared one: these columns are added dynamically and\n // SQLite types per value, so a field can be text in most notes and numeric in a few.\n // Listing every distinct type makes both the type and any drift visible.\n // One aggregate scan per chunk of columns rather than one scan per column: COUNT already\n // ignores NULL, and FILTER keeps typeof() looking only at the non-null rows COUNT counted,\n // matching the old per-column `WHERE ... IS NOT NULL` exactly.\n const allFields: Row[] = [];\n for (const group of chunk(columns, MAP_COLUMN_CHUNK)) {\n const exprs = group.map((name, i) => {\n const quoted = `\"${name.split('\"').join('\"\"')}\"`;\n return `COUNT(${quoted}) AS n${i}, GROUP_CONCAT(DISTINCT typeof(${quoted})) FILTER (WHERE ${quoted} IS NOT NULL) AS t${i}`;\n });\n const result = db.prepare(`SELECT ${exprs.join(', ')} FROM frontmatter`).get() as Record<string, number | string | null>;\n group.forEach((name, i) => allFields.push({ field: name, coverage: result[`n${i}`] as number, type: (result[`t${i}`] as string) ?? '' }));\n }\n allFields.sort((a, b) => (b.coverage as number) - (a.coverage as number));\n const fields = allFields.slice(0, 20);\n\n const hubs = featureEnabled(cfg, 'rank') ? (db.prepare(`SELECT f.\"path\" AS path, round(f.\"_rank\" * 100, 2) AS rank, content.title FROM frontmatter f JOIN content ON content.path = f.\"path\" WHERE f.\"_rank\" IS NOT NULL ORDER BY f.\"_rank\" DESC LIMIT 8`).all() as Row[]) : [];\n\n const recent = db.prepare(`SELECT \"path\", datetime(\"_mtime\" / 1000, 'unixepoch') AS modified FROM frontmatter ORDER BY \"_mtime\" DESC LIMIT 5`).all() as Row[];\n\n return { docs, fields, fieldsTotal: allFields.length, features: featureStates(cfg), presets: presetCoverage(db, cfg), hubs, recent };\n}\n\nexport interface Peek {\n path: string;\n tokens: number;\n frontmatter: Row;\n sections: Row[];\n outbound: string[];\n backlinks: string[];\n unresolved: string[];\n // Totals before truncation: a hub can have thousands of backlinks (or a note thousands of\n // headings), and peek's whole point is bounded output. Query the sections/links tables\n // directly for the full list.\n sectionsTotal: number;\n outboundTotal: number;\n backlinksTotal: number;\n unresolvedTotal: number;\n off: FeatureName[]; // disabled features whose blocks are omitted (not empty)\n}\n\nconst PEEK_LIST_LIMIT = 20;\n\n// peek: everything about one note except its prose -- frontmatter, outline with line\n// ranges + token estimates (so the follow-up Read is a range, not the file), links both ways.\nexport function peek(db: DatabaseSync, cfg: ResolvedConfig, pathArg: string): Peek {\n const paths = (db.prepare('SELECT \"path\" FROM frontmatter').all() as Array<{ path: string }>).map((r) => r.path);\n let path = paths.find((p) => p === pathArg);\n if (!path) {\n const base = posix.basename(pathArg).replace(/\\.md$/i, '').toLowerCase();\n const matches = paths.filter((p) => posix.basename(p).replace(/\\.md$/i, '').toLowerCase() === base);\n if (matches.length === 1) path = matches[0];\n else if (matches.length > 1) throw new SenseError('NOTE_AMBIGUOUS', `\"${pathArg}\" is ambiguous: ${matches.join(', ')}`);\n else throw new SenseError('NOTE_NOT_FOUND', `no note matches \"${pathArg}\"`);\n }\n\n const row = db.prepare('SELECT * FROM frontmatter WHERE \"path\" = ?').get(path) as Row;\n const frontmatter: Row = {};\n for (const [key, value] of Object.entries(row)) {\n if (!INTERNAL_COLUMNS.has(key) && value !== null) frontmatter[key] = value;\n }\n\n const sectionsTotal = featureEnabled(cfg, 'sections') ? (db.prepare('SELECT COUNT(*) AS n FROM sections WHERE \"path\" = ?').get(path) as { n: number }).n : 0;\n const sections = featureEnabled(cfg, 'sections') ? (db.prepare('SELECT level, heading, start_line, end_line, tokens FROM sections WHERE \"path\" = ? ORDER BY idx LIMIT ?').all(path, PEEK_LIST_LIMIT) as Row[]) : [];\n\n let outbound: string[] = [];\n let backlinks: string[] = [];\n let unresolved: string[] = [];\n let backlinksTotal = 0;\n if (featureEnabled(cfg, 'links')) {\n const out = db.prepare('SELECT target, dst FROM links WHERE src = ? ORDER BY target').all(path) as Array<{ target: string; dst: string | null }>;\n outbound = [...new Set(out.filter((l) => l.dst !== null).map((l) => l.dst as string))];\n unresolved = out.filter((l) => l.dst === null).map((l) => l.target);\n backlinksTotal = (db.prepare('SELECT COUNT(DISTINCT src) AS n FROM links WHERE dst = ?').get(path) as { n: number }).n;\n backlinks = (db.prepare('SELECT DISTINCT src FROM links WHERE dst = ? ORDER BY src LIMIT ?').all(path, PEEK_LIST_LIMIT) as Array<{ src: string }>).map((r) => r.src);\n }\n\n return {\n path,\n tokens: Math.ceil(((row._size as number) ?? 0) / 4),\n frontmatter,\n sections,\n outbound: outbound.slice(0, PEEK_LIST_LIMIT),\n backlinks,\n unresolved: unresolved.slice(0, PEEK_LIST_LIMIT),\n sectionsTotal,\n outboundTotal: outbound.length,\n backlinksTotal,\n unresolvedTotal: unresolved.length,\n off: (['sections', 'links'] as FeatureName[]).filter((name) => !featureEnabled(cfg, name)),\n };\n}\n"],"names":["mapTree","peek","presetCoverage","search","WEIGHTED_BM25","RRF_K","SNIPPET_BOUND","EXCERPT_WINDOW","extractBareTerms","query","cleaned","replace","split","map","tok","toLowerCase","trim","filter","length","findOccurrences","haystackLower","terms","occ","term","idx","found","indexOf","push","start","end","sort","a","b","bestWindowStart","windowSize","best","bestDistinct","bestCount","i","winEnd","seen","Set","count","j","add","size","computeExcerpt","text","Math","min","excerpt","slice","offset","out","cursor","o","prefix","suffix","lineNumberAt","line","charCodeAt","lineRangeFor","db","path","row","prepare","get","start_line","end_line","inScope","include","exclude","some","g","matchesGlob","scopeHasEmbeddings","cfg","scopedPaths","anyPresetEmbeds","rows","all","r","has","opts","hits","chunkLines","chunkSimilarity","effective","k","allPaths","scopeActive","fetch","semanticEnabled","scope","whereJoin","whereCond","matchSql","matchRows","oversized","candidates","edges","linked","seeds","ranked","vec","insert","c","where","similarityCol","bareTerms","resolveSearch","p","presetName","max","semantic","err","searchError","Map","hit","forEach","set","score","via","featureEnabled","linkEdges","flat","personalizedRank","existing","semanticCandidates","v","lines","similarity","exec","run","readFileSync","join","baseDir","embedActive","presetNames","name","files","n","embedded","INTERNAL_COLUMNS","MAP_COLUMN_CHUNK","chunk","items","docs","columns","allFields","group","exprs","quoted","result","field","coverage","type","fields","hubs","recent","fieldsTotal","features","featureStates","presets","PEEK_LIST_LIMIT","pathArg","paths","find","base","posix","basename","matches","SenseError","frontmatter","Object","entries","key","value","sectionsTotal","sections","outbound","backlinks","unresolved","backlinksTotal","l","dst","target","src","tokens","ceil","_size","outboundTotal","unresolved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