sensemaking 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli.js +3 -0
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/commands/check.d.cts +3 -0
- package/dist/cjs/commands/check.d.ts +3 -0
- package/dist/cjs/commands/check.js +143 -0
- package/dist/cjs/commands/check.js.map +1 -0
- package/dist/cjs/commands/index.js +5 -0
- package/dist/cjs/commands/index.js.map +1 -1
- package/dist/cjs/commands/shared.js +14 -2
- package/dist/cjs/commands/shared.js.map +1 -1
- package/dist/cjs/commands/status.js +67 -9
- package/dist/cjs/commands/status.js.map +1 -1
- package/dist/cjs/config.d.cts +7 -0
- package/dist/cjs/config.d.ts +7 -0
- package/dist/cjs/config.js +101 -10
- 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 +1 -1
- 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.d.cts +1 -0
- package/dist/cjs/features/embed.d.ts +1 -0
- package/dist/cjs/features/embed.js +6 -2
- package/dist/cjs/features/embed.js.map +1 -1
- package/dist/cjs/output.js +34 -8
- package/dist/cjs/output.js.map +1 -1
- package/dist/cjs/scan.d.cts +1 -1
- package/dist/cjs/scan.d.ts +1 -1
- package/dist/cjs/scan.js +8 -2
- package/dist/cjs/scan.js.map +1 -1
- package/dist/cjs/search-error.d.cts +1 -0
- package/dist/cjs/search-error.d.ts +1 -0
- package/dist/cjs/search-error.js +42 -0
- package/dist/cjs/search-error.js.map +1 -0
- package/dist/cjs/verbs.js +27 -12
- package/dist/cjs/verbs.js.map +1 -1
- package/dist/esm/cli.js +3 -0
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/commands/check.d.ts +3 -0
- package/dist/esm/commands/check.js +69 -0
- package/dist/esm/commands/check.js.map +1 -0
- package/dist/esm/commands/index.js +1 -0
- package/dist/esm/commands/index.js.map +1 -1
- package/dist/esm/commands/shared.js +13 -1
- package/dist/esm/commands/shared.js.map +1 -1
- package/dist/esm/commands/status.js +38 -7
- package/dist/esm/commands/status.js.map +1 -1
- package/dist/esm/config.d.ts +7 -0
- package/dist/esm/config.js +47 -1
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/db.d.ts +1 -1
- package/dist/esm/db.js +1 -1
- 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.d.ts +1 -0
- package/dist/esm/features/embed.js +11 -2
- package/dist/esm/features/embed.js.map +1 -1
- package/dist/esm/output.js +29 -7
- package/dist/esm/output.js.map +1 -1
- package/dist/esm/scan.d.ts +1 -1
- package/dist/esm/scan.js +8 -2
- package/dist/esm/scan.js.map +1 -1
- package/dist/esm/search-error.d.ts +1 -0
- package/dist/esm/search-error.js +25 -0
- package/dist/esm/search-error.js.map +1 -0
- package/dist/esm/verbs.js +29 -12
- package/dist/esm/verbs.js.map +1 -1
- package/package.json +1 -1
- package/schema.json +24 -1
- package/skills/sense/SKILL.md +30 -2
- package/skills/sense-setup/SKILL.md +22 -4
package/dist/cjs/cli.js
CHANGED
|
@@ -304,6 +304,9 @@ function cli(argv, name) {
|
|
|
304
304
|
if (cfg.migratedFrom !== undefined) {
|
|
305
305
|
console.warn("".concat(name, ": migrated ").concat(cfg.configPath, " from config version ").concat(cfg.migratedFrom, " to ").concat(_configts.SUPPORTED_CONFIG_VERSION));
|
|
306
306
|
}
|
|
307
|
+
if (cfg.unknownKeys !== undefined) {
|
|
308
|
+
console.warn("".concat(name, ": ").concat(cfg.configPath, " sets ").concat(cfg.unknownKeys.join(', '), ", which this build does not read (no effect); see schema.json for the keys it does"));
|
|
309
|
+
}
|
|
307
310
|
return cfg;
|
|
308
311
|
},
|
|
309
312
|
usageError: function usageError(message) {
|
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 './commands/index.ts';\nimport type { Ctx } from './commands/types.ts';\nimport { loadConfig, SUPPORTED_CONFIG_VERSION } from './config.ts';\n\n// Parsing and dispatch only. Commands live in src/commands/, 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} find \"<terms>\" [--where \"<sql>\"] [--k n] [--semantic]\\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} 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 | 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 semantic: { 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 return cfg;\n },\n usageError(message) {\n console.error(message);\n process.exit(2);\n },\n };\n\n try {\n if (values.list) {\n for (const queryName of Object.keys(ctx.resolveConfig().queries).sort()) console.log(queryName);\n return;\n }\n\n const [first, ...params] = positionals;\n if (!first) {\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 import('./commands/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","queryName","first","params","err","parseArgs","args","options","format","type","default","config","where","k","semantic","list","force","short","help","allowPositionals","console","error","message","process","exit","log","rest","slice","resolveConfig","cfg","loadConfig","migratedFrom","undefined","warn","configPath","SUPPORTED_CONFIG_VERSION","usageError","Object","keys","queries","sort","COMMANDS"],"mappings":";;;;+BAqCA,mFAAmF;AACnF;;;eAA8BA;;;0BAtCA;wBACJ;uBACD;wBAE4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,2FAA2F;AAC3F,6EAA6E;AAE7E,0FAA0F;AAC1F,SAASC;IACP,IAAMC,OAAOC,IAAAA,yBAAa,EAAC;IAC3B,gBAAkB,QAAA;QAAC;QAAmB;QAAsB;KAAwB,OAAlE,mBAAoE;YAA3EC,MAAO;QAChB,IAAI;YACF,IAAMC,MAAMH,KAAKE;YACjB,IAAIC,IAAIC,IAAI,KAAK,iBAAiBD,IAAIE,OAAO,EAAE,OAAOF,IAAIE,OAAO;QACnE,EAAE,eAAM,CAAC;IACX;IACA,OAAO;AACT;AAEA,SAASC,MAAMF,IAAY;IACzB,OACE,AAAC,UAAc,OAALA,MAAK,iEACf,AAAC,UAAc,OAALA,MAAK,kCACf,AAAC,UAAc,OAALA,MAAK,8DACf,AAAC,UAAc,OAALA,MAAK,YACf,AAAC,UAAc,OAALA,MAAK,oBACf,AAAC,UAAc,OAALA,MAAK,eACf,AAAC,UAAc,OAALA,MAAK,aACf,AAAC,UAAc,OAALA,MAAK,wBACf,AAAC,UAAc,OAALA,MAAK,eACf,AAAC,UAAc,OAALA,MAAK,gBACf,AAAC,UAAc,OAALA,MAAK;AAEnB;AAGe,SAAeN,IAAIS,IAAc,EAAEH,IAAY;;YACxDI,QACAC,kBAgCEC,
|
|
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 './commands/index.ts';\nimport type { Ctx } from './commands/types.ts';\nimport { loadConfig, SUPPORTED_CONFIG_VERSION } from './config.ts';\n\n// Parsing and dispatch only. Commands live in src/commands/, 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} find \"<terms>\" [--where \"<sql>\"] [--k n] [--semantic]\\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} 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 | 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 semantic: { 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 for (const queryName of Object.keys(ctx.resolveConfig().queries).sort()) console.log(queryName);\n return;\n }\n\n const [first, ...params] = positionals;\n if (!first) {\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 import('./commands/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","queryName","first","params","err","parseArgs","args","options","format","type","default","config","where","k","semantic","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","queries","sort","COMMANDS"],"mappings":";;;;+BAqCA,mFAAmF;AACnF;;;eAA8BA;;;0BAtCA;wBACJ;uBACD;wBAE4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,2FAA2F;AAC3F,6EAA6E;AAE7E,0FAA0F;AAC1F,SAASC;IACP,IAAMC,OAAOC,IAAAA,yBAAa,EAAC;IAC3B,gBAAkB,QAAA;QAAC;QAAmB;QAAsB;KAAwB,OAAlE,mBAAoE;YAA3EC,MAAO;QAChB,IAAI;YACF,IAAMC,MAAMH,KAAKE;YACjB,IAAIC,IAAIC,IAAI,KAAK,iBAAiBD,IAAIE,OAAO,EAAE,OAAOF,IAAIE,OAAO;QACnE,EAAE,eAAM,CAAC;IACX;IACA,OAAO;AACT;AAEA,SAASC,MAAMF,IAAY;IACzB,OACE,AAAC,UAAc,OAAL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;oBACd,IAAI,CAACG,OAAO;wBACVkB,QAAQC,KAAK,CAACzB,MAAMF;wBACpB6B,QAAQC,IAAI,CAAC;oBACf;oBAEMlC,OAAOqD,iBAAQ,CAACzC,MAAM;yBACxBZ,MAAAA;;;;oBAAa;;wBAAMA;;;oBAAb;;wBAAO,cAAcoB,OAAO,CAACV;;;oBAA7B;;;;;;oBACJ;;wBAAM;2EAAA,QAAO;;;;oBAAb,cAAqCU,OAAO,CAACV,KAAKE,OAAOC;;;;;;;;oBACxDC;oBACPgB,QAAQC,KAAK,CAAC,AAACjB,IAAckB,OAAO;oBACpCC,QAAQC,IAAI,CAAC;;;;;;;;;;;IAEjB"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _dbts = require("../db.js");
|
|
12
|
+
var _outputts = require("../output.js");
|
|
13
|
+
var _sharedts = require("./shared.js");
|
|
14
|
+
function _array_like_to_array(arr, len) {
|
|
15
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
16
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
17
|
+
return arr2;
|
|
18
|
+
}
|
|
19
|
+
function _array_with_holes(arr) {
|
|
20
|
+
if (Array.isArray(arr)) return arr;
|
|
21
|
+
}
|
|
22
|
+
function _iterable_to_array_limit(arr, i) {
|
|
23
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
24
|
+
if (_i == null) return;
|
|
25
|
+
var _arr = [];
|
|
26
|
+
var _n = true;
|
|
27
|
+
var _d = false;
|
|
28
|
+
var _s, _e;
|
|
29
|
+
try {
|
|
30
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
31
|
+
_arr.push(_s.value);
|
|
32
|
+
if (i && _arr.length === i) break;
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
_d = true;
|
|
36
|
+
_e = err;
|
|
37
|
+
} finally{
|
|
38
|
+
try {
|
|
39
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
40
|
+
} finally{
|
|
41
|
+
if (_d) throw _e;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return _arr;
|
|
45
|
+
}
|
|
46
|
+
function _non_iterable_rest() {
|
|
47
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
48
|
+
}
|
|
49
|
+
function _sliced_to_array(arr, i) {
|
|
50
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
51
|
+
}
|
|
52
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
53
|
+
if (!o) return;
|
|
54
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
55
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
56
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
57
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
58
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
59
|
+
}
|
|
60
|
+
// A saved query that returns zero rows looks identical to a true empty result, so a broken
|
|
61
|
+
// one can sit unnoticed -- one field report had `WHERE flag = 'true'` against a numeric
|
|
62
|
+
// column reading as "nothing tagged yet" for hours. Preparing each query catches syntax and
|
|
63
|
+
// unknown-column errors without executing it; queries that take no parameters are also run
|
|
64
|
+
// for a row count. Parameterised queries are validated but not counted: inventing arguments
|
|
65
|
+
// would report a count for a query nobody ran.
|
|
66
|
+
var check = function check(ctx) {
|
|
67
|
+
var _cfg_queries;
|
|
68
|
+
var cfg = ctx.resolveConfig();
|
|
69
|
+
var _open = (0, _dbts.open)(cfg), db = _open.db, warnings = _open.warnings;
|
|
70
|
+
(0, _sharedts.printWarnings)(warnings);
|
|
71
|
+
var rows = [];
|
|
72
|
+
var failed = 0;
|
|
73
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
74
|
+
try {
|
|
75
|
+
for(var _iterator = Object.entries((_cfg_queries = cfg.queries) !== null && _cfg_queries !== void 0 ? _cfg_queries : {})[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
76
|
+
var _step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], sql = _step_value[1];
|
|
77
|
+
var _sql_match;
|
|
78
|
+
var _cfg_checks;
|
|
79
|
+
var params = ((_sql_match = sql.match(/\?/g)) !== null && _sql_match !== void 0 ? _sql_match : []).length;
|
|
80
|
+
var expectEmpty = ((_cfg_checks = cfg.checks) === null || _cfg_checks === void 0 ? void 0 : _cfg_checks[name]) === 'empty';
|
|
81
|
+
try {
|
|
82
|
+
var statement = db.prepare(sql);
|
|
83
|
+
if (params > 0) {
|
|
84
|
+
rows.push({
|
|
85
|
+
query: name,
|
|
86
|
+
params: params,
|
|
87
|
+
rows: '—',
|
|
88
|
+
status: 'ok (not run: needs parameters)'
|
|
89
|
+
});
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
var count = statement.all().length;
|
|
93
|
+
if (expectEmpty) {
|
|
94
|
+
// An invariant query: rows are violations, so 0 is the pass, anything else fails.
|
|
95
|
+
if (count > 0) failed++;
|
|
96
|
+
rows.push({
|
|
97
|
+
query: name,
|
|
98
|
+
params: params,
|
|
99
|
+
rows: count,
|
|
100
|
+
status: count === 0 ? 'ok (empty, as asserted)' : "FAILED: expected empty, returned ".concat(count, " row(s)")
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
rows.push({
|
|
104
|
+
query: name,
|
|
105
|
+
params: params,
|
|
106
|
+
rows: count,
|
|
107
|
+
status: count === 0 ? 'ok, but returns 0 rows' : 'ok'
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
} catch (err) {
|
|
111
|
+
failed++;
|
|
112
|
+
rows.push({
|
|
113
|
+
query: name,
|
|
114
|
+
params: params,
|
|
115
|
+
rows: '—',
|
|
116
|
+
status: "FAILED: ".concat(err.message)
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
} catch (err) {
|
|
121
|
+
_didIteratorError = true;
|
|
122
|
+
_iteratorError = err;
|
|
123
|
+
} finally{
|
|
124
|
+
try {
|
|
125
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
126
|
+
_iterator.return();
|
|
127
|
+
}
|
|
128
|
+
} finally{
|
|
129
|
+
if (_didIteratorError) {
|
|
130
|
+
throw _iteratorError;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
db.close();
|
|
135
|
+
if (rows.length === 0) {
|
|
136
|
+
console.log('no saved queries in config');
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
(0, _outputts.printRows)(rows, ctx.format);
|
|
140
|
+
if (failed > 0) process.exit(1);
|
|
141
|
+
};
|
|
142
|
+
var _default = check;
|
|
143
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/commands/check.ts"],"sourcesContent":["import { open } from '../db.ts';\nimport type { Row } from '../output.ts';\nimport { printRows } from '../output.ts';\nimport { printWarnings } from './shared.ts';\nimport type { Command } from './types.ts';\n\n// A saved query that returns zero rows looks identical to a true empty result, so a broken\n// one can sit unnoticed -- one field report had `WHERE flag = 'true'` against a numeric\n// column reading as \"nothing tagged yet\" for hours. Preparing each query catches syntax and\n// unknown-column errors without executing it; queries that take no parameters are also run\n// for a row count. Parameterised queries are validated but not counted: inventing arguments\n// would report a count for a query nobody ran.\nconst check: Command = (ctx) => {\n const cfg = ctx.resolveConfig();\n const { db, warnings } = open(cfg);\n printWarnings(warnings);\n\n const rows: Row[] = [];\n let failed = 0;\n for (const [name, sql] of Object.entries(cfg.queries ?? {})) {\n const params = (sql.match(/\\?/g) ?? []).length;\n const expectEmpty = cfg.checks?.[name] === 'empty';\n try {\n const statement = db.prepare(sql);\n if (params > 0) {\n rows.push({ query: name, params, rows: '—', status: 'ok (not run: needs parameters)' });\n continue;\n }\n const count = (statement.all() as unknown[]).length;\n if (expectEmpty) {\n // An invariant query: rows are violations, so 0 is the pass, anything else fails.\n if (count > 0) failed++;\n rows.push({ query: name, params, rows: count, status: count === 0 ? 'ok (empty, as asserted)' : `FAILED: expected empty, returned ${count} row(s)` });\n } else {\n rows.push({ query: name, params, rows: count, status: count === 0 ? 'ok, but returns 0 rows' : 'ok' });\n }\n } catch (err) {\n failed++;\n rows.push({ query: name, params, rows: '—', status: `FAILED: ${(err as Error).message}` });\n }\n }\n\n db.close();\n if (rows.length === 0) {\n console.log('no saved queries in config');\n return;\n }\n printRows(rows, ctx.format);\n if (failed > 0) process.exit(1);\n};\nexport default check;\n"],"names":["check","ctx","cfg","resolveConfig","open","db","warnings","printWarnings","rows","failed","Object","entries","queries","name","sql","params","match","length","expectEmpty","checks","statement","prepare","push","query","status","count","all","err","message","close","console","log","printRows","format","process","exit"],"mappings":";;;;+BAkDA;;;eAAA;;;oBAlDqB;wBAEK;wBACI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9B,2FAA2F;AAC3F,wFAAwF;AACxF,4FAA4F;AAC5F,2FAA2F;AAC3F,4FAA4F;AAC5F,+CAA+C;AAC/C,IAAMA,QAAiB,e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AI,CAAC;oBAAEC,OAAOV;oBAAME,QAAAA;oBAAQP,MAAM;oBAAKgB,QAAQ,AAAC,WAAiC,OAAvB,AAACG,IAAcC,OAAO;gBAAG;YAC1F;QACF;;QArBK;QAAA;;;iBAAA,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;IAuBLvB,GAAGwB,KAAK;IACR,IAAIrB,KAAKS,MAAM,KAAK,GAAG;QACrBa,QAAQC,GAAG,CAAC;QACZ;IACF;IACAC,IAAAA,mBAAS,EAACxB,MAAMP,IAAIgC,MAAM;IAC1B,IAAIxB,SAAS,GAAGyB,QAAQC,IAAI,CAAC;AAC/B;IACA,WAAenC"}
|
|
@@ -65,6 +65,11 @@ var COMMANDS = {
|
|
|
65
65
|
return /*#__PURE__*/ _interop_require_wildcard(require("./status.js"));
|
|
66
66
|
});
|
|
67
67
|
},
|
|
68
|
+
check: function check() {
|
|
69
|
+
return Promise.resolve().then(function() {
|
|
70
|
+
return /*#__PURE__*/ _interop_require_wildcard(require("./check.js"));
|
|
71
|
+
});
|
|
72
|
+
},
|
|
68
73
|
rebuild: function rebuild() {
|
|
69
74
|
return Promise.resolve().then(function() {
|
|
70
75
|
return /*#__PURE__*/ _interop_require_wildcard(require("./rebuild.js"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/commands/index.ts"],"sourcesContent":["import type { Command } from './types.ts';\n\n// Lazy registry: a command's imports load only when it runs, so a heavy dependency in one\n// command never taxes the others (or --version/--help). These names are reserved: a named\n// query in config can never shadow them.\nexport const COMMANDS: Record<string, () => Promise<{ default: Command }>> = {\n init: () => import('./init.ts'),\n watch: () => import('./watch.ts'),\n status: () => import('./status.ts'),\n rebuild: () => import('./rebuild.ts'),\n query: () => import('./query.ts'),\n find: () => import('./find.ts'),\n map: () => import('./map.ts'),\n peek: () => import('./peek.ts'),\n};\n\nexport type { Command, Ctx } from './types.ts';\n"],"names":["COMMANDS","init","watch","status","rebuild","query","find","map","peek"],"mappings":";;;;+BAKaA;;;eAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAN,IAAMA,WAAgE;IAC3EC,MAAM,SAANA;eAAY;2DAAA,QAAO;;;IACnBC,OAAO,SAAPA;eAAa;2DAAA,QAAO;;;IACpBC,QAAQ,SAARA;eAAc;2DAAA,QAAO;;;IACrBC,SAAS,SAATA;eAAe;2DAAA,QAAO;;;IACtBC,OAAO,SAAPA;eAAa;2DAAA,QAAO;;;IACpBC,MAAM,SAANA;eAAY;2DAAA,QAAO;;;IACnBC,KAAK,SAALA;eAAW;2DAAA,QAAO;;;IAClBC,MAAM,SAANA;eAAY;2DAAA,QAAO;;;AACrB"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/commands/index.ts"],"sourcesContent":["import type { Command } from './types.ts';\n\n// Lazy registry: a command's imports load only when it runs, so a heavy dependency in one\n// command never taxes the others (or --version/--help). These names are reserved: a named\n// query in config can never shadow them.\nexport const COMMANDS: Record<string, () => Promise<{ default: Command }>> = {\n init: () => import('./init.ts'),\n watch: () => import('./watch.ts'),\n status: () => import('./status.ts'),\n check: () => import('./check.ts'),\n rebuild: () => import('./rebuild.ts'),\n query: () => import('./query.ts'),\n find: () => import('./find.ts'),\n map: () => import('./map.ts'),\n peek: () => import('./peek.ts'),\n};\n\nexport type { Command, Ctx } from './types.ts';\n"],"names":["COMMANDS","init","watch","status","check","rebuild","query","find","map","peek"],"mappings":";;;;+BAKaA;;;eAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAN,IAAMA,WAAgE;IAC3EC,MAAM,SAANA;eAAY;2DAAA,QAAO;;;IACnBC,OAAO,SAAPA;eAAa;2DAAA,QAAO;;;IACpBC,QAAQ,SAARA;eAAc;2DAAA,QAAO;;;IACrBC,OAAO,SAAPA;eAAa;2DAAA,QAAO;;;IACpBC,SAAS,SAATA;eAAe;2DAAA,QAAO;;;IACtBC,OAAO,SAAPA;eAAa;2DAAA,QAAO;;;IACpBC,MAAM,SAANA;eAAY;2DAAA,QAAO;;;IACnBC,KAAK,SAALA;eAAW;2DAAA,QAAO;;;IAClBC,MAAM,SAANA;eAAY;2DAAA,QAAO;;;AACrB"}
|
|
@@ -21,6 +21,7 @@ _export(exports, {
|
|
|
21
21
|
});
|
|
22
22
|
var _dbts = require("../db.js");
|
|
23
23
|
var _outputts = require("../output.js");
|
|
24
|
+
var _searcherrorts = require("../search-error.js");
|
|
24
25
|
function _array_like_to_array(arr, len) {
|
|
25
26
|
if (len == null || len > arr.length) len = arr.length;
|
|
26
27
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -237,7 +238,6 @@ function withDb(ctx, fn) {
|
|
|
237
238
|
})();
|
|
238
239
|
}
|
|
239
240
|
function runSql(cfg, sql, params, format, label) {
|
|
240
|
-
var _db_prepare;
|
|
241
241
|
var _sql_match;
|
|
242
242
|
var placeholderCount = ((_sql_match = sql.match(/\?/g)) !== null && _sql_match !== void 0 ? _sql_match : []).length;
|
|
243
243
|
if (params.length !== placeholderCount) {
|
|
@@ -246,7 +246,19 @@ function runSql(cfg, sql, params, format, label) {
|
|
|
246
246
|
}
|
|
247
247
|
var _open = (0, _dbts.open)(cfg), db = _open.db, warnings = _open.warnings;
|
|
248
248
|
printWarnings(warnings);
|
|
249
|
-
|
|
249
|
+
var rows;
|
|
250
|
+
try {
|
|
251
|
+
var _db_prepare;
|
|
252
|
+
rows = (_db_prepare = db.prepare(sql)).all.apply(_db_prepare, _to_consumable_array(params));
|
|
253
|
+
} catch (err) {
|
|
254
|
+
db.close();
|
|
255
|
+
// A saved query or ad-hoc SQL can carry `content MATCH ?` too, so the same FTS5
|
|
256
|
+
// punctuation trap applies -- the bound parameters are the search terms there. SQL
|
|
257
|
+
// without MATCH gets its error verbatim; search advice on a plain typo would mislead.
|
|
258
|
+
if (/\bMATCH\b/i.test(sql)) throw (0, _searcherrorts.searchError)(err, params.join(' '));
|
|
259
|
+
throw err;
|
|
260
|
+
}
|
|
261
|
+
(0, _outputts.printRows)(rows, format);
|
|
250
262
|
db.close();
|
|
251
263
|
}
|
|
252
264
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/commands/shared.ts"],"sourcesContent":["import type { ResolvedConfig } from '../config.ts';\nimport type { OpenResult } from '../db.ts';\nimport { open } from '../db.ts';\nimport type { Row } from '../output.ts';\nimport { printRows } from '../output.ts';\nimport type { Ctx } from './types.ts';\n\n// Shared open-query-close envelope for commands that touch the tree.\n\nexport function printWarnings(warnings: string[]): void {\n for (const w of warnings) console.warn(w);\n}\n\nexport async function withDb(ctx: Ctx, fn: (db: OpenResult['db'], cfg: ResolvedConfig) => void | Promise<void>): Promise<void> {\n const cfg = ctx.resolveConfig();\n const { db, warnings } = open(cfg);\n printWarnings(warnings);\n try {\n await fn(db, cfg);\n } finally {\n db.close();\n }\n}\n\n// An unbound `?` silently binds NULL, so mismatched param counts fail loudly instead.\nexport function runSql(cfg: ResolvedConfig, sql: string, params: string[], format: 'table' | 'json', label: string): void {\n const placeholderCount = (sql.match(/\\?/g) ?? []).length;\n if (params.length !== placeholderCount) {\n console.error(`${label} expects ${placeholderCount} parameter(s), got ${params.length}`);\n process.exit(2);\n }\n const { db, warnings } = open(cfg);\n printWarnings(warnings);\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/commands/shared.ts"],"sourcesContent":["import type { ResolvedConfig } from '../config.ts';\nimport type { OpenResult } from '../db.ts';\nimport { open } from '../db.ts';\nimport type { Row } from '../output.ts';\nimport { printRows } from '../output.ts';\nimport { searchError } from '../search-error.ts';\nimport type { Ctx } from './types.ts';\n\n// Shared open-query-close envelope for commands that touch the tree.\n\nexport function printWarnings(warnings: string[]): void {\n for (const w of warnings) console.warn(w);\n}\n\nexport async function withDb(ctx: Ctx, fn: (db: OpenResult['db'], cfg: ResolvedConfig) => void | Promise<void>): Promise<void> {\n const cfg = ctx.resolveConfig();\n const { db, warnings } = open(cfg);\n printWarnings(warnings);\n try {\n await fn(db, cfg);\n } finally {\n db.close();\n }\n}\n\n// An unbound `?` silently binds NULL, so mismatched param counts fail loudly instead.\nexport function runSql(cfg: ResolvedConfig, sql: string, params: string[], format: 'table' | 'json', label: string): void {\n const placeholderCount = (sql.match(/\\?/g) ?? []).length;\n if (params.length !== placeholderCount) {\n console.error(`${label} expects ${placeholderCount} parameter(s), got ${params.length}`);\n process.exit(2);\n }\n const { db, warnings } = open(cfg);\n printWarnings(warnings);\n let rows: Row[];\n try {\n rows = db.prepare(sql).all(...params) as Row[];\n } catch (err) {\n db.close();\n // A saved query or ad-hoc SQL can carry `content MATCH ?` too, so the same FTS5\n // punctuation trap applies -- the bound parameters are the search terms there. SQL\n // without MATCH gets its error verbatim; search advice on a plain typo would mislead.\n if (/\\bMATCH\\b/i.test(sql)) throw searchError(err as Error, params.join(' '));\n throw err;\n }\n printRows(rows, format);\n db.close();\n}\n"],"names":["printWarnings","runSql","withDb","warnings","w","console","warn","ctx","fn","cfg","open","db","resolveConfig","close","sql","params","format","label","placeholderCount","match","length","error","process","exit","rows","prepare","all","err","test","searchError","join","printRows"],"mappings":";;;;;;;;;;;QAUgBA;eAAAA;;QAgBAC;eAAAA;;QAZMC;eAAAA;;;oBAZD;wBAEK;6BACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKrB,SAASF,cAAcG,QAAk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AAcZ,OAAOe,IAAI,CAAC;QACxE,MAAMH;IACR;IACAI,IAAAA,mBAAS,EAACP,MAAMR;IAChBL,GAAGE,KAAK;AACV"}
|
|
@@ -11,22 +11,80 @@ Object.defineProperty(exports, "default", {
|
|
|
11
11
|
var _configts = require("../config.js");
|
|
12
12
|
var _dbts = require("../db.js");
|
|
13
13
|
var _sharedts = require("./shared.js");
|
|
14
|
+
function _define_property(obj, key, value) {
|
|
15
|
+
if (key in obj) {
|
|
16
|
+
Object.defineProperty(obj, key, {
|
|
17
|
+
value: value,
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
obj[key] = value;
|
|
24
|
+
}
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
function _object_spread(target) {
|
|
28
|
+
for(var i = 1; i < arguments.length; i++){
|
|
29
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
30
|
+
var ownKeys = Object.keys(source);
|
|
31
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
32
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
33
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
ownKeys.forEach(function(key) {
|
|
37
|
+
_define_property(target, key, source[key]);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return target;
|
|
41
|
+
}
|
|
42
|
+
// Vectors are computed on the first semantic query, not at reconcile, so a tree can be
|
|
43
|
+
// embed-enabled with nothing embedded yet -- reported here because a fast `rebuild` on an
|
|
44
|
+
// embed tree otherwise reads as "the feature isn't on".
|
|
45
|
+
function vectorState(db) {
|
|
46
|
+
try {
|
|
47
|
+
var row = db.prepare('SELECT COUNT(vector) AS embedded, COUNT(*) - COUNT(vector) AS pending FROM embeddings').get();
|
|
48
|
+
return row;
|
|
49
|
+
} catch (unused) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
14
53
|
var status = function status(ctx) {
|
|
54
|
+
var _ref;
|
|
55
|
+
var _cfg_defaults_find, _cfg_defaults;
|
|
15
56
|
var cfg = ctx.resolveConfig();
|
|
16
57
|
var _open = (0, _dbts.open)(cfg), db = _open.db, dbPath = _open.dbPath, warnings = _open.warnings;
|
|
17
58
|
(0, _sharedts.printWarnings)(warnings);
|
|
18
|
-
console.log("db: ".concat(dbPath));
|
|
19
|
-
console.log("docs: ".concat((0, _dbts.docCount)(db)));
|
|
20
59
|
var features = (0, _configts.featureStates)(cfg);
|
|
21
|
-
var off = features.off.length > 0 ? " \xb7 off: ".concat(features.off.map(function(name) {
|
|
22
|
-
return "".concat(name, " (features.").concat(name, ")");
|
|
23
|
-
}).join(', ')) : '';
|
|
24
|
-
console.log("features: ".concat(features.on.join(', ')).concat(off));
|
|
25
60
|
var e = (0, _configts.embedConfig)(cfg);
|
|
26
|
-
|
|
61
|
+
var vectors = e ? vectorState(db) : null;
|
|
27
62
|
var heartbeat = (0, _dbts.getMeta)(db, 'watch_heartbeat');
|
|
28
|
-
|
|
29
|
-
|
|
63
|
+
var result = {
|
|
64
|
+
db: dbPath,
|
|
65
|
+
docs: (0, _dbts.docCount)(db),
|
|
66
|
+
features: features.on,
|
|
67
|
+
featuresOff: features.off,
|
|
68
|
+
embed: e ? _object_spread({
|
|
69
|
+
type: e.type,
|
|
70
|
+
model: e.model
|
|
71
|
+
}, vectors !== null && vectors !== void 0 ? vectors : {}) : null,
|
|
72
|
+
findDefaultWhere: (_ref = (_cfg_defaults = cfg.defaults) === null || _cfg_defaults === void 0 ? void 0 : (_cfg_defaults_find = _cfg_defaults.find) === null || _cfg_defaults_find === void 0 ? void 0 : _cfg_defaults_find.where) !== null && _ref !== void 0 ? _ref : null,
|
|
73
|
+
watcherHeartbeatSecondsAgo: heartbeat ? Math.round((Date.now() - Date.parse(heartbeat)) / 1000) : null
|
|
74
|
+
};
|
|
75
|
+
if (ctx.format === 'json') {
|
|
76
|
+
console.log(JSON.stringify(result, null, 2));
|
|
77
|
+
} else {
|
|
78
|
+
console.log("db: ".concat(result.db));
|
|
79
|
+
console.log("docs: ".concat(result.docs));
|
|
80
|
+
var off = features.off.length > 0 ? " \xb7 off: ".concat(features.off.map(function(name) {
|
|
81
|
+
return "".concat(name, " (features.").concat(name, ")");
|
|
82
|
+
}).join(', ')) : '';
|
|
83
|
+
console.log("features: ".concat(features.on.join(', ')).concat(off));
|
|
84
|
+
if (e) console.log("embed: ".concat(e.type, " ").concat(e.model).concat(vectors ? " (vectors: ".concat(vectors.embedded, " embedded, ").concat(vectors.pending, " pending — embedded on first --semantic query)") : ''));
|
|
85
|
+
if (result.findDefaultWhere) console.log("find default scope: ".concat(result.findDefaultWhere, " (--where replaces it)"));
|
|
86
|
+
console.log(result.watcherHeartbeatSecondsAgo === null ? 'watcher: no watcher' : "watcher: last heartbeat ".concat(result.watcherHeartbeatSecondsAgo, "s ago"));
|
|
87
|
+
}
|
|
30
88
|
db.close();
|
|
31
89
|
};
|
|
32
90
|
var _default = status;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/commands/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\nconst status: Command = (ctx) => {\n const cfg = ctx.resolveConfig();\n const { db, dbPath, warnings } = open(cfg);\n printWarnings(warnings);\n console.log(`db: ${
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/commands/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 be\n// embed-enabled with nothing embedded yet -- reported here because a fast `rebuild` on an\n// embed 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 heartbeat = getMeta(db, 'watch_heartbeat');\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 findDefaultWhere: cfg.defaults?.find?.where ?? null,\n watcherHeartbeatSecondsAgo: heartbeat ? Math.round((Date.now() - Date.parse(heartbeat)) / 1000) : null,\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 const off = features.off.length > 0 ? ` · off: ${features.off.map((name) => `${name} (features.${name})`).join(', ')}` : '';\n console.log(`features: ${features.on.join(', ')}${off}`);\n if (e) console.log(`embed: ${e.type} ${e.model}${vectors ? ` (vectors: ${vectors.embedded} embedded, ${vectors.pending} pending — embedded on first --semantic query)` : ''}`);\n if (result.findDefaultWhere) console.log(`find default scope: ${result.findDefaultWhere} (--where replaces it)`);\n console.log(result.watcherHeartbeatSecondsAgo === null ? 'watcher: no watcher' : `watcher: last heartbeat ${result.watcherHeartbeatSecondsAgo}s ago`);\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","heartbeat","getMeta","result","docs","docCount","on","featuresOff","off","embed","type","model","findDefaultWhere","defaults","find","where","watcherHeartbeatSecondsAgo","Math","round","Date","now","parse","format","console","log","JSON","stringify","length","map","name","join","embedded","pending","close"],"mappings":";;;;+BAiDA;;;eAAA;;;wBAjD2C;oBACH;wBACV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9B,uFAAuF;AACvF,0FAA0F;AAC1F,wDAAwD;AACxD,SAASA,YAAYC,EAAiC;IACpD,IAAI;QACF,IAAMC,MAAMD,GAAGE,OAAO,CAAC,yFAAyFC,GAAG;QACnH,OAAOF;IACT,EAAE,eAAM;QACN,OAAO;IACT;AACF;AAEA,IAAMG,SAAkB,gBAACC;;QAeHC,oBAAAA;IAdpB,IAAMA,MAAMD,IAAIE,aAAa;IAC7B,IAAiCC,QAAAA,IAAAA,UAAI,EAACF,MAA9BN,KAAyBQ,MAAzBR,IAAIS,SAAqBD,MAArBC,QAAQC,WAAaF,MAAbE;IACpBC,IAAAA,uBAAa,EAACD;IAEd,IAAME,WAAWC,IAAAA,uBAAa,EAACP;IAC/B,IAAMQ,IAAIC,IAAAA,qBAAW,EAACT;IACtB,IAAMU,UAAUF,IAAIf,YAAYC,MAAM;IACtC,IAAMiB,YAAYC,IAAAA,aAAO,EAAClB,IAAI;IAC9B,IAAMmB,SAAS;QACbnB,IAAIS;QACJW,MAAMC,IAAAA,cAAQ,EAACrB;QACfY,UAAUA,SAASU,EAAE;QACrBC,aAAaX,SAASY,GAAG;QACzBC,OAAOX,IAAI;YAAEY,MAAMZ,EAAEY,IAAI;YAAEC,OAAOb,EAAEa,KAAK;WAAMX,oBAAAA,qBAAAA,UAAW,CAAC,KAAO;QAClEY,gBAAgB,WAAEtB,gBAAAA,IAAIuB,QAAQ,cAAZvB,qCAAAA,qBAAAA,cAAcwB,IAAI,cAAlBxB,yCAAAA,mBAAoByB,KAAK,uCAAI;QAC/CC,4BAA4Bf,YAAYgB,KAAKC,KAAK,CAAC,AAACC,CAAAA,KAAKC,GAAG,KAAKD,KAAKE,KAAK,CAACpB,UAAS,IAAK,QAAQ;IACpG;IAEA,IAAIZ,IAAIiC,MAAM,KAAK,QAAQ;QACzBC,QAAQC,GAAG,CAACC,KAAKC,SAAS,CAACvB,QAAQ,MAAM;IAC3C,OAAO;QACLoB,QAAQC,GAAG,CAAC,AAAC,OAAgB,OAAVrB,OAAOnB,EAAE;QAC5BuC,QAAQC,GAAG,CAAC,AAAC,SAAoB,OAAZrB,OAAOC,IAAI;QAChC,IAAMI,MAAMZ,SAASY,GAAG,CAACmB,MAAM,GAAG,IAAI,AAAC,cAA8E,OAApE/B,SAASY,GAAG,CAACoB,GAAG,CAAC,SAACC;mBAAS,AAAC,GAAoBA,OAAlBA,MAAK,eAAkB,OAALA,MAAK;WAAIC,IAAI,CAAC,SAAU;QACzHP,QAAQC,GAAG,CAAC,AAAC,aAAqChB,OAAzBZ,SAASU,EAAE,CAACwB,IAAI,CAAC,OAAY,OAAJtB;QAClD,IAAIV,GAAGyB,QAAQC,GAAG,CAAC,AAAC,UAAmB1B,OAAVA,EAAEY,IAAI,EAAC,KAAaV,OAAVF,EAAEa,KAAK,EAA8H,OAA3HX,UAAU,AAAC,cAA2CA,OAA9BA,QAAQ+B,QAAQ,EAAC,eAA6B,OAAhB/B,QAAQgC,OAAO,EAAC,oDAAkD;QACzK,IAAI7B,OAAOS,gBAAgB,EAAEW,QAAQC,GAAG,CAAC,AAAC,uBAA8C,OAAxBrB,OAAOS,gBAAgB,EAAC;QACxFW,QAAQC,GAAG,CAACrB,OAAOa,0BAA0B,KAAK,OAAO,wBAAwB,AAAC,2BAA4D,OAAlCb,OAAOa,0BAA0B,EAAC;IAChJ;IACAhC,GAAGiD,KAAK;AACV;IACA,WAAe7C"}
|
package/dist/cjs/config.d.cts
CHANGED
|
@@ -22,11 +22,18 @@ export interface Config {
|
|
|
22
22
|
rank?: boolean;
|
|
23
23
|
embed?: boolean | EmbedConfig;
|
|
24
24
|
};
|
|
25
|
+
defaults?: {
|
|
26
|
+
find?: {
|
|
27
|
+
where?: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
checks?: Record<string, 'empty'>;
|
|
25
31
|
queries: Record<string, string>;
|
|
26
32
|
}
|
|
27
33
|
export interface ResolvedConfig extends Config {
|
|
28
34
|
baseDir: string;
|
|
29
35
|
configPath: string | null;
|
|
36
|
+
unknownKeys?: string[];
|
|
30
37
|
migratedFrom?: number;
|
|
31
38
|
}
|
|
32
39
|
export declare function featureEnabled(cfg: Config, name: FeatureName): boolean;
|
package/dist/cjs/config.d.ts
CHANGED
|
@@ -22,11 +22,18 @@ export interface Config {
|
|
|
22
22
|
rank?: boolean;
|
|
23
23
|
embed?: boolean | EmbedConfig;
|
|
24
24
|
};
|
|
25
|
+
defaults?: {
|
|
26
|
+
find?: {
|
|
27
|
+
where?: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
checks?: Record<string, 'empty'>;
|
|
25
31
|
queries: Record<string, string>;
|
|
26
32
|
}
|
|
27
33
|
export interface ResolvedConfig extends Config {
|
|
28
34
|
baseDir: string;
|
|
29
35
|
configPath: string | null;
|
|
36
|
+
unknownKeys?: string[];
|
|
30
37
|
migratedFrom?: number;
|
|
31
38
|
}
|
|
32
39
|
export declare function featureEnabled(cfg: Config, name: FeatureName): boolean;
|
package/dist/cjs/config.js
CHANGED
|
@@ -60,6 +60,9 @@ function _array_like_to_array(arr, len) {
|
|
|
60
60
|
function _array_with_holes(arr) {
|
|
61
61
|
if (Array.isArray(arr)) return arr;
|
|
62
62
|
}
|
|
63
|
+
function _array_without_holes(arr) {
|
|
64
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
65
|
+
}
|
|
63
66
|
function _define_property(obj, key, value) {
|
|
64
67
|
if (key in obj) {
|
|
65
68
|
Object.defineProperty(obj, key, {
|
|
@@ -73,6 +76,9 @@ function _define_property(obj, key, value) {
|
|
|
73
76
|
}
|
|
74
77
|
return obj;
|
|
75
78
|
}
|
|
79
|
+
function _iterable_to_array(iter) {
|
|
80
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
81
|
+
}
|
|
76
82
|
function _iterable_to_array_limit(arr, i) {
|
|
77
83
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
78
84
|
if (_i == null) return;
|
|
@@ -100,6 +106,9 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
100
106
|
function _non_iterable_rest() {
|
|
101
107
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
102
108
|
}
|
|
109
|
+
function _non_iterable_spread() {
|
|
110
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
111
|
+
}
|
|
103
112
|
function _object_spread(target) {
|
|
104
113
|
for(var i = 1; i < arguments.length; i++){
|
|
105
114
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -142,6 +151,9 @@ function _object_spread_props(target, source) {
|
|
|
142
151
|
function _sliced_to_array(arr, i) {
|
|
143
152
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
144
153
|
}
|
|
154
|
+
function _to_consumable_array(arr) {
|
|
155
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
156
|
+
}
|
|
145
157
|
function _type_of(obj) {
|
|
146
158
|
"@swc/helpers - typeof";
|
|
147
159
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
@@ -282,8 +294,51 @@ function findConfigPath(startDir) {
|
|
|
282
294
|
// Shape check for hand-edited files: a typo'd config fails with a named error, not a
|
|
283
295
|
// TypeError from whatever code touched the missing field first. `queries` is optional
|
|
284
296
|
// on disk (absent = none); `scan.include` has no usable default.
|
|
297
|
+
// Keys each block actually reads. A key outside these sets is accepted and ignored, which
|
|
298
|
+
// looks identical to working -- one field report set `scan.exclude`, saw no change in doc
|
|
299
|
+
// count and no warning, and reasonably concluded the filter had applied. Reported as a
|
|
300
|
+
// warning rather than an error so a config carrying an unknown key still runs.
|
|
301
|
+
var KNOWN_KEYS = new Set([
|
|
302
|
+
'$schema',
|
|
303
|
+
'version',
|
|
304
|
+
'scan',
|
|
305
|
+
'features',
|
|
306
|
+
'defaults',
|
|
307
|
+
'checks',
|
|
308
|
+
'queries'
|
|
309
|
+
]);
|
|
310
|
+
var KNOWN_SCAN_KEYS = new Set([
|
|
311
|
+
'include'
|
|
312
|
+
]);
|
|
313
|
+
function unknownConfigKeys(cfg) {
|
|
314
|
+
var unknown = Object.keys(cfg).filter(function(k) {
|
|
315
|
+
return !KNOWN_KEYS.has(k);
|
|
316
|
+
}).map(function(k) {
|
|
317
|
+
return k;
|
|
318
|
+
});
|
|
319
|
+
var scan = cfg.scan;
|
|
320
|
+
if (scan && (typeof scan === "undefined" ? "undefined" : _type_of(scan)) === 'object' && !Array.isArray(scan)) {
|
|
321
|
+
var _unknown;
|
|
322
|
+
(_unknown = unknown).push.apply(_unknown, _to_consumable_array(Object.keys(scan).filter(function(k) {
|
|
323
|
+
return !KNOWN_SCAN_KEYS.has(k);
|
|
324
|
+
}).map(function(k) {
|
|
325
|
+
return "scan.".concat(k);
|
|
326
|
+
})));
|
|
327
|
+
}
|
|
328
|
+
var features = cfg.features;
|
|
329
|
+
if (features && (typeof features === "undefined" ? "undefined" : _type_of(features)) === 'object' && !Array.isArray(features)) {
|
|
330
|
+
var _unknown1;
|
|
331
|
+
(_unknown1 = unknown).push.apply(_unknown1, _to_consumable_array(Object.keys(features).filter(function(k) {
|
|
332
|
+
return !FEATURE_NAMES.includes(k);
|
|
333
|
+
}).map(function(k) {
|
|
334
|
+
return "features.".concat(k);
|
|
335
|
+
})));
|
|
336
|
+
}
|
|
337
|
+
return unknown;
|
|
338
|
+
}
|
|
285
339
|
function validateConfig(parsed, configPath) {
|
|
286
340
|
var _cfg_features;
|
|
341
|
+
var _defaults_find;
|
|
287
342
|
if ((typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
288
343
|
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": config must be a JSON object"));
|
|
289
344
|
}
|
|
@@ -300,13 +355,47 @@ function validateConfig(parsed, configPath) {
|
|
|
300
355
|
})) {
|
|
301
356
|
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries must be an object of name -> SQL string"));
|
|
302
357
|
}
|
|
358
|
+
var defaults = cfg.defaults;
|
|
359
|
+
if (defaults !== undefined && ((typeof defaults === "undefined" ? "undefined" : _type_of(defaults)) !== 'object' || defaults === null || Array.isArray(defaults) || defaults.find !== undefined && typeof ((_defaults_find = defaults.find) === null || _defaults_find === void 0 ? void 0 : _defaults_find.where) !== 'string')) {
|
|
360
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": defaults.find.where must be a SQL condition string"));
|
|
361
|
+
}
|
|
362
|
+
var checks = cfg.checks;
|
|
363
|
+
if (checks !== undefined) {
|
|
364
|
+
var _cfg_queries;
|
|
365
|
+
if ((typeof checks === "undefined" ? "undefined" : _type_of(checks)) !== 'object' || checks === null || Array.isArray(checks) || !Object.values(checks).every(function(v) {
|
|
366
|
+
return v === 'empty';
|
|
367
|
+
})) {
|
|
368
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ': checks must be an object of query name -> "empty"'));
|
|
369
|
+
}
|
|
370
|
+
var queries = (_cfg_queries = cfg.queries) !== null && _cfg_queries !== void 0 ? _cfg_queries : {};
|
|
371
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
372
|
+
try {
|
|
373
|
+
for(var _iterator = Object.keys(checks)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
374
|
+
var name = _step.value;
|
|
375
|
+
if (queries[name] === undefined) throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ': checks names "').concat(name, '", which is not a saved query'));
|
|
376
|
+
}
|
|
377
|
+
} catch (err) {
|
|
378
|
+
_didIteratorError = true;
|
|
379
|
+
_iteratorError = err;
|
|
380
|
+
} finally{
|
|
381
|
+
try {
|
|
382
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
383
|
+
_iterator.return();
|
|
384
|
+
}
|
|
385
|
+
} finally{
|
|
386
|
+
if (_didIteratorError) {
|
|
387
|
+
throw _iteratorError;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
303
392
|
if (cfg.features !== undefined && (_type_of(cfg.features) !== 'object' || cfg.features === null || Array.isArray(cfg.features))) {
|
|
304
393
|
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": features must be an object of name -> boolean"));
|
|
305
394
|
}
|
|
306
|
-
var
|
|
395
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
307
396
|
try {
|
|
308
397
|
var _loop = function() {
|
|
309
|
-
var _step_value = _sliced_to_array(
|
|
398
|
+
var _step_value = _sliced_to_array(_step1.value, 2), name = _step_value[0], value = _step_value[1];
|
|
310
399
|
if (typeof value === 'boolean') return "continue";
|
|
311
400
|
// embed alone takes an object form: { model?, type?: static|api, url?, key? }.
|
|
312
401
|
var embed = value;
|
|
@@ -321,18 +410,18 @@ function validateConfig(parsed, configPath) {
|
|
|
321
410
|
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": features.").concat(name, " must be a boolean").concat(name === 'embed' ? ' or { model?, type?: "static"|"api", url?, key? }' : ''));
|
|
322
411
|
}
|
|
323
412
|
};
|
|
324
|
-
for(var
|
|
413
|
+
for(var _iterator1 = Object.entries((_cfg_features = cfg.features) !== null && _cfg_features !== void 0 ? _cfg_features : {})[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true)_loop();
|
|
325
414
|
} catch (err) {
|
|
326
|
-
|
|
327
|
-
|
|
415
|
+
_didIteratorError1 = true;
|
|
416
|
+
_iteratorError1 = err;
|
|
328
417
|
} finally{
|
|
329
418
|
try {
|
|
330
|
-
if (!
|
|
331
|
-
|
|
419
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
420
|
+
_iterator1.return();
|
|
332
421
|
}
|
|
333
422
|
} finally{
|
|
334
|
-
if (
|
|
335
|
-
throw
|
|
423
|
+
if (_didIteratorError1) {
|
|
424
|
+
throw _iteratorError1;
|
|
336
425
|
}
|
|
337
426
|
}
|
|
338
427
|
}
|
|
@@ -366,10 +455,12 @@ function loadConfig(explicitPath) {
|
|
|
366
455
|
migratedFrom = result.from;
|
|
367
456
|
(0, _nodefs.writeFileSync)(configPath, "".concat(JSON.stringify(cfg, null, 2), "\n"));
|
|
368
457
|
}
|
|
458
|
+
var unknownKeys = unknownConfigKeys(cfg);
|
|
369
459
|
return _object_spread_props(_object_spread({}, cfg), {
|
|
370
460
|
baseDir: (0, _nodepath.dirname)(configPath),
|
|
371
461
|
configPath: configPath,
|
|
372
|
-
migratedFrom: migratedFrom
|
|
462
|
+
migratedFrom: migratedFrom,
|
|
463
|
+
unknownKeys: unknownKeys.length > 0 ? unknownKeys : undefined
|
|
373
464
|
});
|
|
374
465
|
}
|
|
375
466
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|