sensemaking 0.8.0 → 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 +48 -39
- package/dist/cjs/cli/check.js +24 -43
- package/dist/cjs/cli/check.js.map +1 -1
- package/dist/cjs/cli/index.js +2 -2
- package/dist/cjs/cli/index.js.map +1 -1
- package/dist/cjs/cli/named.js +18 -8
- package/dist/cjs/cli/named.js.map +1 -1
- package/dist/cjs/cli/search.d.cts +3 -0
- package/dist/cjs/cli/search.d.ts +3 -0
- package/dist/cjs/cli/{find.js → search.js} +7 -5
- package/dist/cjs/cli/search.js.map +1 -0
- package/dist/cjs/cli/shared.js.map +1 -1
- package/dist/cjs/cli/status.js +29 -12
- package/dist/cjs/cli/status.js.map +1 -1
- package/dist/cjs/cli/types.d.cts +3 -1
- package/dist/cjs/cli/types.d.ts +3 -1
- package/dist/cjs/cli.js +25 -5
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/commands.d.cts +11 -2
- package/dist/cjs/commands.d.ts +11 -2
- package/dist/cjs/commands.js +86 -21
- package/dist/cjs/commands.js.map +1 -1
- package/dist/cjs/config.d.cts +41 -14
- package/dist/cjs/config.d.ts +41 -14
- package/dist/cjs/config.js +448 -160
- 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 +208 -62
- 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 +12 -2
- package/dist/cjs/features/embed.js.map +1 -1
- package/dist/cjs/features/types.d.cts +2 -1
- package/dist/cjs/features/types.d.ts +2 -1
- package/dist/cjs/index.d.cts +3 -3
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +6 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/output.d.cts +15 -0
- package/dist/cjs/output.d.ts +15 -0
- package/dist/cjs/output.js +26 -5
- package/dist/cjs/output.js.map +1 -1
- package/dist/cjs/scan.d.cts +3 -0
- package/dist/cjs/scan.d.ts +3 -0
- package/dist/cjs/scan.js +84 -4
- package/dist/cjs/scan.js.map +1 -1
- package/dist/esm/cli/check.js +20 -41
- package/dist/esm/cli/check.js.map +1 -1
- package/dist/esm/cli/index.js +1 -1
- package/dist/esm/cli/index.js.map +1 -1
- package/dist/esm/cli/named.js +17 -9
- package/dist/esm/cli/named.js.map +1 -1
- 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/esm/cli/shared.js +1 -1
- package/dist/esm/cli/shared.js.map +1 -1
- package/dist/esm/cli/status.js +10 -10
- package/dist/esm/cli/status.js.map +1 -1
- package/dist/esm/cli/types.d.ts +3 -1
- package/dist/esm/cli/types.js.map +1 -1
- package/dist/esm/cli.js +20 -4
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/commands.d.ts +11 -2
- package/dist/esm/commands.js +76 -24
- package/dist/esm/commands.js.map +1 -1
- package/dist/esm/config.d.ts +41 -14
- package/dist/esm/config.js +354 -114
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/db.d.ts +1 -1
- package/dist/esm/db.js +53 -6
- 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 +12 -2
- package/dist/esm/features/embed.js.map +1 -1
- package/dist/esm/features/types.d.ts +2 -1
- 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 +15 -0
- package/dist/esm/output.js +19 -5
- package/dist/esm/output.js.map +1 -1
- package/dist/esm/scan.d.ts +3 -0
- package/dist/esm/scan.js +32 -4
- package/dist/esm/scan.js.map +1 -1
- package/package.json +9 -3
- package/schema.json +74 -54
- package/skills/sense/EXAMPLES.md +8 -6
- package/skills/sense/SKILL.md +51 -48
- package/skills/sense-setup/EXAMPLES.md +121 -0
- package/skills/sense-setup/SKILL.md +71 -66
- package/dist/cjs/cli/find.d.cts +0 -3
- package/dist/cjs/cli/find.d.ts +0 -3
- package/dist/cjs/cli/find.js.map +0 -1
- package/dist/esm/cli/find.d.ts +0 -3
- package/dist/esm/cli/find.js +0 -14
- package/dist/esm/cli/find.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/status.ts"],"sourcesContent":["import { embedConfig, featureStates } from '../config.ts';\nimport { docCount, getMeta, open } from '../db.ts';\nimport { printWarnings } from './shared.ts';\nimport type { Command } from './types.ts';\n\n// Vectors are computed on the first semantic query, not at reconcile, so a tree can
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/status.ts"],"sourcesContent":["import { presetCoverage } from '../commands.ts';\nimport { embedConfig, featureStates } from '../config.ts';\nimport { docCount, getMeta, open } from '../db.ts';\nimport { featuresLine, presetsLines } from '../output.ts';\nimport { printWarnings } from './shared.ts';\nimport type { Command } from './types.ts';\n\n// Vectors are computed on the first semantic query, not at reconcile, so a tree can have a\n// semantic-on preset with nothing embedded yet -- reported here because a fast `rebuild` on\n// such a tree otherwise reads as \"the feature isn't on\".\nfunction vectorState(db: ReturnType<typeof open>['db']): { embedded: number; pending: number } | null {\n try {\n const row = db.prepare('SELECT COUNT(vector) AS embedded, COUNT(*) - COUNT(vector) AS pending FROM embeddings').get() as { embedded: number; pending: number };\n return row;\n } catch {\n return null;\n }\n}\n\nconst status: Command = (ctx) => {\n const cfg = ctx.resolveConfig();\n const { db, dbPath, warnings } = open(cfg);\n printWarnings(warnings);\n\n const features = featureStates(cfg);\n const e = embedConfig(cfg);\n const vectors = e ? vectorState(db) : null;\n const presets = presetCoverage(db, cfg);\n const heartbeat = getMeta(db, 'watch_heartbeat');\n // Derived at open() (F): 3x the largest reconcile this cache has ever held its write\n // transaction for, floored at 30s -- read back from the connection rather than\n // recomputed here, so this always reports what open() actually set.\n const busyTimeoutMs = (db.prepare('PRAGMA busy_timeout').get() as { timeout: number }).timeout;\n const result = {\n db: dbPath,\n docs: docCount(db),\n features: features.on,\n featuresOff: features.off,\n embed: e ? { type: e.type, model: e.model, ...(vectors ?? {}) } : null,\n presets,\n watcherHeartbeatSecondsAgo: heartbeat ? Math.round((Date.now() - Date.parse(heartbeat)) / 1000) : null,\n busyTimeoutMs,\n };\n\n if (ctx.format === 'json') {\n console.log(JSON.stringify(result, null, 2));\n } else {\n console.log(`db: ${result.db}`);\n console.log(`docs: ${result.docs}`);\n console.log(featuresLine(features));\n if (e) console.log(`embed: ${e.type} ${e.model}${vectors ? ` (vectors: ${vectors.embedded} embedded, ${vectors.pending} pending — embedded on the first semantic search)` : ''}`);\n for (const line of presetsLines(presets)) console.log(line);\n console.log(result.watcherHeartbeatSecondsAgo === null ? 'watcher: no watcher' : `watcher: last heartbeat ${result.watcherHeartbeatSecondsAgo}s ago`);\n console.log(`busy_timeout: ${result.busyTimeoutMs}ms (derived: 3x the largest reconcile this cache has recorded, floored at 30000ms)`);\n }\n db.close();\n};\nexport default status;\n"],"names":["vectorState","db","row","prepare","get","status","ctx","cfg","resolveConfig","open","dbPath","warnings","printWarnings","features","featureStates","e","embedConfig","vectors","presets","presetCoverage","heartbeat","getMeta","busyTimeoutMs","timeout","result","docs","docCount","on","featuresOff","off","embed","type","model","watcherHeartbeatSecondsAgo","Math","round","Date","now","parse","format","console","log","JSON","stringify","featuresLine","embedded","pending","presetsLines","line","close"],"mappings":";;;;+BAyDA;;;eAAA;;;0BAzD+B;wBACY;oBACH;wBACG;wBACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9B,2FAA2F;AAC3F,4FAA4F;AAC5F,yDAAyD;AACzD,SAASA,YAAYC,EAAiC;IACp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EAAE;QAC5BuC,QAAQC,GAAG,CAAC,AAAC,SAAoB,OAAZjB,OAAOC,IAAI;QAChCe,QAAQC,GAAG,CAACG,IAAAA,sBAAY,EAAC/B;QACzB,IAAIE,GAAGyB,QAAQC,GAAG,CAAC,AAAC,UAAmB1B,OAAVA,EAAEgB,IAAI,EAAC,KAAad,OAAVF,EAAEiB,KAAK,EAAiI,OAA9Hf,UAAU,AAAC,cAA2CA,OAA9BA,QAAQ4B,QAAQ,EAAC,eAA6B,OAAhB5B,QAAQ6B,OAAO,EAAC,uDAAqD;YACvK,kCAAA,2BAAA;;YAAL,QAAK,YAAcC,IAAAA,sBAAY,EAAC7B,6BAA3B,SAAA,6BAAA,QAAA,yBAAA;gBAAA,IAAM8B,OAAN;gBAAqCR,QAAQC,GAAG,CAACO;;;YAAjD;YAAA;;;qBAAA,6BAAA;oBAAA;;;oBAAA;0BAAA;;;;QACLR,QAAQC,GAAG,CAACjB,OAAOS,0BAA0B,KAAK,OAAO,wBAAwB,AAAC,2BAA4D,OAAlCT,OAAOS,0BAA0B,EAAC;QAC9IO,QAAQC,GAAG,CAAC,AAAC,iBAAqC,OAArBjB,OAAOF,aAAa,EAAC;IACpD;IACArB,GAAGgD,KAAK;AACV;IACA,WAAe5C"}
|
package/dist/cjs/cli/types.d.cts
CHANGED
|
@@ -7,8 +7,10 @@ export interface Ctx {
|
|
|
7
7
|
config?: string;
|
|
8
8
|
where?: string;
|
|
9
9
|
k?: string;
|
|
10
|
+
preset?: string;
|
|
11
|
+
include?: string[];
|
|
10
12
|
force: boolean;
|
|
11
|
-
|
|
13
|
+
lexical: boolean;
|
|
12
14
|
};
|
|
13
15
|
resolveConfig(): ResolvedConfig;
|
|
14
16
|
usageError(message: string): never;
|
package/dist/cjs/cli/types.d.ts
CHANGED
|
@@ -7,8 +7,10 @@ export interface Ctx {
|
|
|
7
7
|
config?: string;
|
|
8
8
|
where?: string;
|
|
9
9
|
k?: string;
|
|
10
|
+
preset?: string;
|
|
11
|
+
include?: string[];
|
|
10
12
|
force: boolean;
|
|
11
|
-
|
|
13
|
+
lexical: boolean;
|
|
12
14
|
};
|
|
13
15
|
resolveConfig(): ResolvedConfig;
|
|
14
16
|
usageError(message: string): never;
|
package/dist/cjs/cli.js
CHANGED
|
@@ -100,6 +100,10 @@ function _non_iterable_rest() {
|
|
|
100
100
|
function _to_array(arr) {
|
|
101
101
|
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
|
|
102
102
|
}
|
|
103
|
+
function _type_of(obj) {
|
|
104
|
+
"@swc/helpers - typeof";
|
|
105
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
106
|
+
}
|
|
103
107
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
104
108
|
if (!o) return;
|
|
105
109
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -226,11 +230,11 @@ function packageVersion() {
|
|
|
226
230
|
return 'unknown';
|
|
227
231
|
}
|
|
228
232
|
function usage(name) {
|
|
229
|
-
return "usage: ".concat(name, " <name> [params...] [--format table|json] [--config path]\n") + " ".concat(name, ' query "<sql>" [params...]\n') + " ".concat(name, '
|
|
233
|
+
return "usage: ".concat(name, " <name> [params...] [--format table|json] [--config path]\n") + " ".concat(name, ' query "<sql>" [params...]\n') + " ".concat(name, ' search "<terms>" [--preset name] [--include glob ...] [--where "<sql>"] [--k n] [--lexical]\n') + " ".concat(name, " map\n") + " ".concat(name, " peek <path>\n") + " ".concat(name, " --list\n") + " ".concat(name, " init\n") + " ".concat(name, " watch [--force]\n") + " ".concat(name, " status\n") + " ".concat(name, " check\n") + " ".concat(name, " rebuild\n") + " ".concat(name, " --version");
|
|
230
234
|
}
|
|
231
235
|
function cli(argv, name) {
|
|
232
236
|
return _async_to_generator(function() {
|
|
233
|
-
var values, positionals, ref, ctx, queries, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, queryName, _positionals, first, params, load, err;
|
|
237
|
+
var values, positionals, ref, ctx, queries, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, queryName, entry, isSavedSearch, _positionals, first, params, load, err;
|
|
234
238
|
return _ts_generator(this, function(_state) {
|
|
235
239
|
switch(_state.label){
|
|
236
240
|
case 0:
|
|
@@ -252,8 +256,16 @@ function cli(argv, name) {
|
|
|
252
256
|
k: {
|
|
253
257
|
type: 'string'
|
|
254
258
|
},
|
|
255
|
-
|
|
256
|
-
type: '
|
|
259
|
+
preset: {
|
|
260
|
+
type: 'string'
|
|
261
|
+
},
|
|
262
|
+
include: {
|
|
263
|
+
type: 'string',
|
|
264
|
+
multiple: true
|
|
265
|
+
},
|
|
266
|
+
lexical: {
|
|
267
|
+
type: 'boolean',
|
|
268
|
+
default: false
|
|
257
269
|
},
|
|
258
270
|
list: {
|
|
259
271
|
type: 'boolean',
|
|
@@ -327,7 +339,9 @@ function cli(argv, name) {
|
|
|
327
339
|
try {
|
|
328
340
|
for(_iterator = Object.keys(queries).sort()[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
329
341
|
queryName = _step.value;
|
|
330
|
-
|
|
342
|
+
entry = queries[queryName];
|
|
343
|
+
isSavedSearch = (typeof entry === "undefined" ? "undefined" : _type_of(entry)) === 'object' && entry !== null && 'search' in entry;
|
|
344
|
+
console.log(isSavedSearch ? "".concat(queryName, " (search)") : queryName);
|
|
331
345
|
}
|
|
332
346
|
} catch (err) {
|
|
333
347
|
_didIteratorError = true;
|
|
@@ -352,6 +366,12 @@ function cli(argv, name) {
|
|
|
352
366
|
console.error(usage(name));
|
|
353
367
|
process.exit(2);
|
|
354
368
|
}
|
|
369
|
+
// find -> search (breaking rename): one release of a pointer instead of "unknown query".
|
|
370
|
+
if (first === 'find') {
|
|
371
|
+
console.error("".concat(name, ": find is now search"));
|
|
372
|
+
console.error(usage(name));
|
|
373
|
+
process.exit(2);
|
|
374
|
+
}
|
|
355
375
|
load = _indexts.COMMANDS[first];
|
|
356
376
|
if (!load) return [
|
|
357
377
|
3,
|
package/dist/cjs/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { parseArgs } from 'node:util';\nimport { COMMANDS } from './cli/index.ts';\nimport type { Ctx } from './cli/types.ts';\nimport { loadConfig, SUPPORTED_CONFIG_VERSION } from './config.ts';\n\n// Parsing and dispatch only. Commands live in src/cli/, one file each, lazy-loaded --\n// nothing tree- or dependency-heavy may be imported at the top of this file.\n\n// Works from dist/cjs and dist/esm alike: walk up past the dist type-marker package.json.\nfunction packageVersion(): string {\n const load = createRequire(import.meta.url);\n for (const rel of ['../package.json', '../../package.json', '../../../package.json']) {\n try {\n const pkg = load(rel) as { name?: string; version?: string };\n if (pkg.name === 'sensemaking' && pkg.version) return pkg.version;\n } catch {}\n }\n return 'unknown';\n}\n\nfunction usage(name: string): string {\n return (\n `usage: ${name} <name> [params...] [--format table|json] [--config path]\\n` +\n ` ${name} query \"<sql>\" [params...]\\n` +\n ` ${name}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { parseArgs } from 'node:util';\nimport { COMMANDS } from './cli/index.ts';\nimport type { Ctx } from './cli/types.ts';\nimport { loadConfig, SUPPORTED_CONFIG_VERSION } from './config.ts';\n\n// Parsing and dispatch only. Commands live in src/cli/, one file each, lazy-loaded --\n// nothing tree- or dependency-heavy may be imported at the top of this file.\n\n// Works from dist/cjs and dist/esm alike: walk up past the dist type-marker package.json.\nfunction packageVersion(): string {\n const load = createRequire(import.meta.url);\n for (const rel of ['../package.json', '../../package.json', '../../../package.json']) {\n try {\n const pkg = load(rel) as { name?: string; version?: string };\n if (pkg.name === 'sensemaking' && pkg.version) return pkg.version;\n } catch {}\n }\n return 'unknown';\n}\n\nfunction usage(name: string): string {\n return (\n `usage: ${name} <name> [params...] [--format table|json] [--config path]\\n` +\n ` ${name} query \"<sql>\" [params...]\\n` +\n ` ${name} search \"<terms>\" [--preset name] [--include glob ...] [--where \"<sql>\"] [--k n] [--lexical]\\n` +\n ` ${name} map\\n` +\n ` ${name} peek <path>\\n` +\n ` ${name} --list\\n` +\n ` ${name} init\\n` +\n ` ${name} watch [--force]\\n` +\n ` ${name} status\\n` +\n ` ${name} check\\n` +\n ` ${name} rebuild\\n` +\n ` ${name} --version`\n );\n}\n\n// Thrown errors -> exit 1 with the message verbatim; usage errors exit 2 directly.\nexport default async function cli(argv: string[], name: string): Promise<void> {\n let values: Record<string, string | boolean | string[] | undefined>;\n let positionals: string[];\n try {\n ({ values, positionals } = parseArgs({\n args: argv,\n options: {\n format: { type: 'string', default: 'table' },\n config: { type: 'string' },\n where: { type: 'string' },\n k: { type: 'string' },\n preset: { type: 'string' },\n include: { type: 'string', multiple: true },\n lexical: { type: 'boolean', default: false },\n list: { type: 'boolean', default: false },\n force: { type: 'boolean', default: false },\n version: { type: 'boolean', default: false, short: 'v' },\n help: { type: 'boolean', default: false, short: 'h' },\n },\n allowPositionals: true,\n }));\n } catch (err) {\n console.error((err as Error).message);\n console.error(usage(name));\n process.exit(2);\n }\n\n if (values.version) {\n console.log(`v${packageVersion()}`);\n return;\n }\n if (values.help) {\n console.log(usage(name));\n return;\n }\n\n const ctx: Ctx = {\n name,\n rest: positionals.slice(1),\n format: values.format === 'json' ? 'json' : 'table',\n values: values as Ctx['values'],\n resolveConfig() {\n const cfg = loadConfig(values.config as string | undefined);\n if (cfg.migratedFrom !== undefined) {\n console.warn(`${name}: migrated ${cfg.configPath} from config version ${cfg.migratedFrom} to ${SUPPORTED_CONFIG_VERSION}`);\n }\n if (cfg.unknownKeys !== undefined) {\n console.warn(`${name}: ${cfg.configPath} sets ${cfg.unknownKeys.join(', ')}, which this build does not read (no effect); see schema.json for the keys it does`);\n }\n return cfg;\n },\n usageError(message) {\n console.error(message);\n process.exit(2);\n },\n };\n\n try {\n if (values.list) {\n const queries = ctx.resolveConfig().queries;\n for (const queryName of Object.keys(queries).sort()) {\n const entry = queries[queryName];\n const isSavedSearch = typeof entry === 'object' && entry !== null && 'search' in entry;\n console.log(isSavedSearch ? `${queryName} (search)` : queryName);\n }\n return;\n }\n\n const [first, ...params] = positionals;\n if (!first) {\n console.error(usage(name));\n process.exit(2);\n }\n\n // find -> search (breaking rename): one release of a pointer instead of \"unknown query\".\n if (first === 'find') {\n console.error(`${name}: find is now search`);\n console.error(usage(name));\n process.exit(2);\n }\n\n const load = COMMANDS[first];\n if (load) await (await load()).default(ctx);\n else await (await import('./cli/named.ts')).default(ctx, first, params);\n } catch (err) {\n console.error((err as Error).message);\n process.exit(1);\n }\n}\n"],"names":["cli","packageVersion","load","createRequire","rel","pkg","name","version","usage","argv","values","positionals","ctx","queries","queryName","entry","isSavedSearch","first","params","err","parseArgs","args","options","format","type","default","config","where","k","preset","include","multiple","lexical","list","force","short","help","allowPositionals","console","error","message","process","exit","log","rest","slice","resolveConfig","cfg","loadConfig","migratedFrom","undefined","warn","configPath","SUPPORTED_CONFIG_VERSION","unknownKeys","join","usageError","Object","keys","sort","COMMANDS"],"mappings":";;;;+BAsCA,mFAAmF;AACnF;;;eAA8BA;;;0BAvCA;wBACJ;uBACD;wBAE4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,sFAAsF;AACtF,6EAA6E;AAE7E,0FAA0F;AAC1F,SAASC;IACP,IAAMC,OAAOC,IAAAA,yBAAa,EAAC;IAC3B,gBAAkB,QAAA;QAAC;QAAmB;QA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d.cts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import type { DatabaseSync } from 'node:sqlite';
|
|
2
2
|
import type { FeatureName, ResolvedConfig } from './config.js';
|
|
3
3
|
import type { Row } from './output.js';
|
|
4
|
-
export interface
|
|
4
|
+
export interface SearchOptions {
|
|
5
5
|
k?: number;
|
|
6
6
|
where?: string;
|
|
7
|
+
preset?: string;
|
|
8
|
+
include?: string[];
|
|
7
9
|
semantic?: boolean;
|
|
8
10
|
}
|
|
9
|
-
export declare function
|
|
11
|
+
export declare function search(db: DatabaseSync, cfg: ResolvedConfig, terms: string, opts?: SearchOptions): Promise<Row[]>;
|
|
12
|
+
export interface PresetCoverage {
|
|
13
|
+
name: string;
|
|
14
|
+
files: number;
|
|
15
|
+
embedded: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function presetCoverage(db: DatabaseSync, cfg: ResolvedConfig): PresetCoverage[];
|
|
10
18
|
export interface TreeMap {
|
|
11
19
|
docs: {
|
|
12
20
|
count: number;
|
|
@@ -18,6 +26,7 @@ export interface TreeMap {
|
|
|
18
26
|
on: FeatureName[];
|
|
19
27
|
off: FeatureName[];
|
|
20
28
|
};
|
|
29
|
+
presets: PresetCoverage[];
|
|
21
30
|
hubs: Row[];
|
|
22
31
|
recent: Row[];
|
|
23
32
|
}
|
package/dist/cjs/commands.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import type { DatabaseSync } from 'node:sqlite';
|
|
2
2
|
import type { FeatureName, ResolvedConfig } from './config.js';
|
|
3
3
|
import type { Row } from './output.js';
|
|
4
|
-
export interface
|
|
4
|
+
export interface SearchOptions {
|
|
5
5
|
k?: number;
|
|
6
6
|
where?: string;
|
|
7
|
+
preset?: string;
|
|
8
|
+
include?: string[];
|
|
7
9
|
semantic?: boolean;
|
|
8
10
|
}
|
|
9
|
-
export declare function
|
|
11
|
+
export declare function search(db: DatabaseSync, cfg: ResolvedConfig, terms: string, opts?: SearchOptions): Promise<Row[]>;
|
|
12
|
+
export interface PresetCoverage {
|
|
13
|
+
name: string;
|
|
14
|
+
files: number;
|
|
15
|
+
embedded: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function presetCoverage(db: DatabaseSync, cfg: ResolvedConfig): PresetCoverage[];
|
|
10
18
|
export interface TreeMap {
|
|
11
19
|
docs: {
|
|
12
20
|
count: number;
|
|
@@ -18,6 +26,7 @@ export interface TreeMap {
|
|
|
18
26
|
on: FeatureName[];
|
|
19
27
|
off: FeatureName[];
|
|
20
28
|
};
|
|
29
|
+
presets: PresetCoverage[];
|
|
21
30
|
hubs: Row[];
|
|
22
31
|
recent: Row[];
|
|
23
32
|
}
|
package/dist/cjs/commands.js
CHANGED
|
@@ -9,14 +9,17 @@ 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
|
});
|
|
22
25
|
var _nodefs = require("node:fs");
|
|
@@ -219,7 +222,7 @@ function _ts_generator(thisArg, body) {
|
|
|
219
222
|
};
|
|
220
223
|
}
|
|
221
224
|
}
|
|
222
|
-
// The three
|
|
225
|
+
// The three commands: mapTree (orient), search (locate), peek (structure).
|
|
223
226
|
// Each returns data; cli.ts renders. All of them degrade when a feature is off.
|
|
224
227
|
var WEIGHTED_BM25 = 'bm25(content, 10.0, 5.0, 1.0)';
|
|
225
228
|
var RRF_K = 60;
|
|
@@ -363,23 +366,63 @@ function lineRangeFor(db, path, line) {
|
|
|
363
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);
|
|
364
367
|
return row ? "L".concat(row.start_line, "-").concat(row.end_line) : null;
|
|
365
368
|
}
|
|
366
|
-
|
|
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) {
|
|
367
389
|
return _async_to_generator(function(db, cfg, terms) {
|
|
368
|
-
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;
|
|
369
391
|
var _arguments = arguments;
|
|
370
392
|
return _ts_generator(this, function(_state) {
|
|
371
393
|
switch(_state.label){
|
|
372
394
|
case 0:
|
|
373
395
|
opts = _arguments.length > 3 && _arguments[3] !== void 0 ? _arguments[3] : {};
|
|
374
|
-
|
|
375
|
-
|
|
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);
|
|
376
419
|
// Terms pass verbatim to FTS5 MATCH: bare words AND-join, operators are the caller's.
|
|
377
420
|
// Invalid syntax propagates as an error, zero matches return zero -- no silent rewrites.
|
|
378
421
|
// --where applies inside the candidate query (a post-filter over the top-N would drop
|
|
379
422
|
// matches ranked past the pool) and again on the final select for link-derived rows.
|
|
380
|
-
// An explicit --where replaces the
|
|
381
|
-
// so a caller can always widen back to the whole
|
|
382
|
-
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;
|
|
383
426
|
whereJoin = scope ? 'JOIN frontmatter f ON f."path" = content.path' : '';
|
|
384
427
|
whereCond = scope ? "AND (".concat(scope, ")") : '';
|
|
385
428
|
// Docs past SNIPPET_BOUND skip snippet() entirely -- SQLite
|
|
@@ -390,6 +433,12 @@ function find(_0, _1, _2) {
|
|
|
390
433
|
} catch (err) {
|
|
391
434
|
throw (0, _searcherrorts.searchError)(err, terms, scope);
|
|
392
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
|
+
});
|
|
393
442
|
hits = new Map(matchRows.map(function(r) {
|
|
394
443
|
return [
|
|
395
444
|
r.path,
|
|
@@ -417,18 +466,15 @@ function find(_0, _1, _2) {
|
|
|
417
466
|
// that mass from the score list reweights fusion toward connectivity and measurably
|
|
418
467
|
// wrecks ranking on link-dense corpora (FEVER hit@10 0.997 -> 0.907; fusion-tuning.md).
|
|
419
468
|
linked = new Set(edges.flat());
|
|
420
|
-
nodes = db.prepare('SELECT "path" FROM frontmatter').all().map(function(r) {
|
|
421
|
-
return r.path;
|
|
422
|
-
});
|
|
423
469
|
seeds = new Map(matchRows.map(function(r, i) {
|
|
424
470
|
return [
|
|
425
471
|
r.path,
|
|
426
472
|
1 / (i + 1)
|
|
427
473
|
];
|
|
428
474
|
}));
|
|
429
|
-
ranked = _to_consumable_array((0, _graphts.personalizedRank)(
|
|
430
|
-
var _param = _sliced_to_array(param, 2), score = _param[1];
|
|
431
|
-
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);
|
|
432
478
|
}).sort(function(a, b) {
|
|
433
479
|
return b[1] - a[1];
|
|
434
480
|
}).slice(0, fetch);
|
|
@@ -450,7 +496,7 @@ function find(_0, _1, _2) {
|
|
|
450
496
|
// (weight 1, pool = fetch). Each row carries its best chunk's line range.
|
|
451
497
|
chunkLines = new Map();
|
|
452
498
|
chunkSimilarity = new Map();
|
|
453
|
-
if (!
|
|
499
|
+
if (!semanticEnabled) return [
|
|
454
500
|
3,
|
|
455
501
|
2
|
|
456
502
|
];
|
|
@@ -459,7 +505,9 @@ function find(_0, _1, _2) {
|
|
|
459
505
|
(0, _embedts.semanticCandidates)(db, cfg, terms, fetch)
|
|
460
506
|
];
|
|
461
507
|
case 1:
|
|
462
|
-
vec = _state.sent()
|
|
508
|
+
vec = _state.sent().filter(function(v) {
|
|
509
|
+
return scopedPaths.has(v.path);
|
|
510
|
+
});
|
|
463
511
|
vec.forEach(function(param, i) {
|
|
464
512
|
var path = param.path, lines = param.lines, similarity = param.similarity;
|
|
465
513
|
chunkLines.set(path, lines);
|
|
@@ -500,10 +548,14 @@ function find(_0, _1, _2) {
|
|
|
500
548
|
}
|
|
501
549
|
}
|
|
502
550
|
}
|
|
503
|
-
|
|
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, ")") : '';
|
|
504
556
|
// lines is always present now: semantic rows carry their chunk's range, oversized-doc
|
|
505
557
|
// lexical rows gain one below, everything else stays null. similarity stays semantic-only.
|
|
506
|
-
similarityCol =
|
|
558
|
+
similarityCol = semanticEnabled ? ', _find.similarity' : '';
|
|
507
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);
|
|
508
560
|
if (oversized.size > 0) {
|
|
509
561
|
bareTerms = extractBareTerms(terms);
|
|
@@ -545,6 +597,18 @@ function find(_0, _1, _2) {
|
|
|
545
597
|
});
|
|
546
598
|
}).apply(this, arguments);
|
|
547
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
|
+
}
|
|
548
612
|
var INTERNAL_COLUMNS = new Set([
|
|
549
613
|
'path',
|
|
550
614
|
'_mtime',
|
|
@@ -617,6 +681,7 @@ function mapTree(db, cfg) {
|
|
|
617
681
|
fields: fields,
|
|
618
682
|
fieldsTotal: allFields.length,
|
|
619
683
|
features: (0, _configts.featureStates)(cfg),
|
|
684
|
+
presets: presetCoverage(db, cfg),
|
|
620
685
|
hubs: hubs,
|
|
621
686
|
recent: recent
|
|
622
687
|
};
|