sensemaking 0.9.2 → 0.9.3
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 +6 -1
- package/bin/cli.js +5 -1
- package/dist/cjs/cli/check.js +2 -1
- package/dist/cjs/cli/check.js.map +1 -1
- package/dist/cjs/cli/exit.d.cts +5 -0
- package/dist/cjs/cli/exit.d.ts +5 -0
- package/dist/cjs/cli/exit.js +147 -0
- package/dist/cjs/cli/exit.js.map +1 -0
- package/dist/cjs/cli/named.js +2 -5
- package/dist/cjs/cli/named.js.map +1 -1
- package/dist/cjs/cli/shared.d.cts +13 -8
- package/dist/cjs/cli/shared.d.ts +13 -8
- package/dist/cjs/cli/shared.js +124 -29
- package/dist/cjs/cli/shared.js.map +1 -1
- package/dist/cjs/cli.js +116 -111
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/db.js +5 -0
- package/dist/cjs/db.js.map +1 -1
- package/dist/esm/cli/check.js +2 -1
- package/dist/esm/cli/check.js.map +1 -1
- package/dist/esm/cli/exit.d.ts +5 -0
- package/dist/esm/cli/exit.js +15 -0
- package/dist/esm/cli/exit.js.map +1 -0
- package/dist/esm/cli/named.js +2 -5
- package/dist/esm/cli/named.js.map +1 -1
- package/dist/esm/cli/shared.d.ts +13 -8
- package/dist/esm/cli/shared.js +55 -33
- package/dist/esm/cli/shared.js.map +1 -1
- package/dist/esm/cli.js +68 -74
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/db.js +5 -0
- package/dist/esm/db.js.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -21,6 +21,9 @@ npm install -g sensemaking
|
|
|
21
21
|
cd your-notes && sense init
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
Needs Node 22.16 or newer: that is the first release whose built-in SQLite carries FTS5, which
|
|
25
|
+
`sense search` indexes prose with.
|
|
26
|
+
|
|
24
27
|
```bash
|
|
25
28
|
sense map # orient: fields, hub notes, recent changes
|
|
26
29
|
sense search "revenue OR earnings" --k 10 # locate: words + links + meaning, one ranked list
|
|
@@ -182,7 +185,9 @@ features, frontmatter conventions, and note size are decisions with consequences
|
|
|
182
185
|
Dependencies: [yaml](https://github.com/eemeli/yaml),
|
|
183
186
|
[remove-markdown](https://github.com/zuchka/remove-markdown),
|
|
184
187
|
[fast-glob](https://github.com/mrmlnc/fast-glob),
|
|
185
|
-
[@huggingface/tokenizers](https://github.com/huggingface/tokenizers.js) (pure JS),
|
|
188
|
+
[@huggingface/tokenizers](https://github.com/huggingface/tokenizers.js) (pure JS),
|
|
189
|
+
[getopts-compat](https://github.com/kmalakoff/getopts) and
|
|
190
|
+
[exit-compat](https://github.com/kmalakoff/exit-compat) for the CLI, and Node's
|
|
186
191
|
built-in SQLite. No native builds.
|
|
187
192
|
|
|
188
193
|
## License
|
package/bin/cli.js
CHANGED
|
@@ -2,4 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
// biome-ignore lint/security/noGlobalEval: dual esm and cjs
|
|
4
4
|
if (typeof require === 'undefined') eval("import('../dist/esm/cli.js').then((cli) => cli.default(process.argv.slice(2), 'sense')).catch((err) => { console.error(err); process.exit(-1); });");
|
|
5
|
-
else
|
|
5
|
+
else
|
|
6
|
+
require('../dist/cjs/cli.js')(process.argv.slice(2), 'sense').catch((err) => {
|
|
7
|
+
console.error(err);
|
|
8
|
+
process.exit(-1);
|
|
9
|
+
});
|
package/dist/cjs/cli/check.js
CHANGED
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "default", {
|
|
|
11
11
|
var _commandsts = require("../commands.js");
|
|
12
12
|
var _dbts = require("../db.js");
|
|
13
13
|
var _outputts = require("../output.js");
|
|
14
|
+
var _exitts = require("./exit.js");
|
|
14
15
|
var _indexts = require("./index.js");
|
|
15
16
|
var _sharedts = require("./shared.js");
|
|
16
17
|
function _array_like_to_array(arr, len) {
|
|
@@ -386,7 +387,7 @@ var check = function check(ctx) {
|
|
|
386
387
|
];
|
|
387
388
|
}
|
|
388
389
|
(0, _outputts.printRows)(rows, format);
|
|
389
|
-
if (failed > 0)
|
|
390
|
+
if (failed > 0) throw new _exitts.ExitError(1);
|
|
390
391
|
return [
|
|
391
392
|
2
|
|
392
393
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/check.ts"],"sourcesContent":["import { search } from '../commands.ts';\nimport { open } from '../db.ts';\nimport type { Row } from '../output.ts';\nimport { printRows } from '../output.ts';\nimport { USAGE } from './index.ts';\nimport { CONFIG, FORMAT, formatOf, parse, 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. Saved searches run lexically with k=1 -- that\n// validates the `where` fragment, the FTS5 terms, and the `preset` name (resolveSearch throws\n// on an unknown one, the same breakage class prepare() catches for SQL strings) -- but never\n// semantically (a semantic pass costs model time and, on api trees, network). Whether a\n// result being empty is good or bad is the reader's judgment -- there is no assertion path.\nconst check: Command = async (ctx) => {\n const { values } = parse(ctx.argv, `usage: ${ctx.name} ${USAGE.check}`, { ...FORMAT, ...CONFIG });\n const format = formatOf(values);\n const cfg = ctx.resolveConfig(values.config as string | undefined);\n const { db, warnings } = open(cfg);\n printWarnings(warnings);\n\n const rows: Row[] = [];\n let failed = 0;\n for (const [name, entry] of Object.entries(cfg.queries ?? {})) {\n if (typeof entry === 'object' && entry !== null && 'search' in entry) {\n try {\n const count = (await search(db, cfg, entry.search, { k: 1, where: entry.where, preset: entry.preset, include: entry.include, semantic: false })).length;\n rows.push({ query: name, params: '—', rows: '—', status: count === 0 ? 'ok, but matches 0 notes (lexical probe)' : 'ok (probe run with k=1)' });\n } catch (err) {\n failed++;\n rows.push({ query: name, params: '—', rows: '—', status: `FAILED: ${(err as Error).message}` });\n }\n continue;\n }\n const sql = typeof entry === 'string' ? entry : entry.sql;\n const params = (sql.match(/\\?/g) ?? []).length;\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 rows.push({ query: name, params, rows: count, status: count === 0 ? 'ok, but returns 0 rows' : 'ok' });\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, format);\n if (failed > 0)
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/check.ts"],"sourcesContent":["import { search } from '../commands.ts';\nimport { open } from '../db.ts';\nimport type { Row } from '../output.ts';\nimport { printRows } from '../output.ts';\nimport { ExitError } from './exit.ts';\nimport { USAGE } from './index.ts';\nimport { CONFIG, FORMAT, formatOf, parse, 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. Saved searches run lexically with k=1 -- that\n// validates the `where` fragment, the FTS5 terms, and the `preset` name (resolveSearch throws\n// on an unknown one, the same breakage class prepare() catches for SQL strings) -- but never\n// semantically (a semantic pass costs model time and, on api trees, network). Whether a\n// result being empty is good or bad is the reader's judgment -- there is no assertion path.\nconst check: Command = async (ctx) => {\n const { values } = parse(ctx.argv, `usage: ${ctx.name} ${USAGE.check}`, { ...FORMAT, ...CONFIG });\n const format = formatOf(values);\n const cfg = ctx.resolveConfig(values.config as string | undefined);\n const { db, warnings } = open(cfg);\n printWarnings(warnings);\n\n const rows: Row[] = [];\n let failed = 0;\n for (const [name, entry] of Object.entries(cfg.queries ?? {})) {\n if (typeof entry === 'object' && entry !== null && 'search' in entry) {\n try {\n const count = (await search(db, cfg, entry.search, { k: 1, where: entry.where, preset: entry.preset, include: entry.include, semantic: false })).length;\n rows.push({ query: name, params: '—', rows: '—', status: count === 0 ? 'ok, but matches 0 notes (lexical probe)' : 'ok (probe run with k=1)' });\n } catch (err) {\n failed++;\n rows.push({ query: name, params: '—', rows: '—', status: `FAILED: ${(err as Error).message}` });\n }\n continue;\n }\n const sql = typeof entry === 'string' ? entry : entry.sql;\n const params = (sql.match(/\\?/g) ?? []).length;\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 rows.push({ query: name, params, rows: count, status: count === 0 ? 'ok, but returns 0 rows' : 'ok' });\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, format);\n if (failed > 0) throw new ExitError(1);\n};\nexport default check;\n"],"names":["check","ctx","cfg","values","format","open","db","warnings","rows","failed","name","entry","sql","count","err","params","statement","parse","argv","USAGE","FORMAT","CONFIG","formatOf","resolveConfig","config","printWarnings","Object","entries","queries","search","k","where","preset","include","semantic","length","push","query","status","message","match","prepare","all","close","console","log","printRows","ExitError"],"mappings":";;;;+BA+DA;;;eAAA;;;0BA/DuB;oBACF;wBAEK;sBACA;uBACJ;wBACyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;oBACR,IAAInC,KAAK2B,MAAM,KAAK,GAAG;wBACrBS,QAAQC,GAAG,CAAC;wBACZ;;;oBACF;oBACAC,IAAAA,mBAAS,EAACtC,MAAMJ;oBAChB,IAAIK,SAAS,GAAG,MAAM,IAAIsC,iBAAS,CAAC;;;;;;IACtC;;IACA,WAAe/C"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// Commands never end the process themselves: they throw this, and cli.ts -- the one place
|
|
2
|
+
// that owns the exit -- drains stdio through exit-compat and returns. Neither alternative
|
|
3
|
+
// works here: a direct process.exit() races a pending write, and a bare return would let a
|
|
4
|
+
// command body run on after --help had already printed its usage.
|
|
5
|
+
"use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
function _export(target, all) {
|
|
10
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
_export(exports, {
|
|
16
|
+
get ExitError () {
|
|
17
|
+
return ExitError;
|
|
18
|
+
},
|
|
19
|
+
get usageError () {
|
|
20
|
+
return usageError;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function _assert_this_initialized(self) {
|
|
24
|
+
if (self === void 0) {
|
|
25
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
26
|
+
}
|
|
27
|
+
return self;
|
|
28
|
+
}
|
|
29
|
+
function _call_super(_this, derived, args) {
|
|
30
|
+
derived = _get_prototype_of(derived);
|
|
31
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
32
|
+
}
|
|
33
|
+
function _class_call_check(instance, Constructor) {
|
|
34
|
+
if (!(instance instanceof Constructor)) {
|
|
35
|
+
throw new TypeError("Cannot call a class as a function");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function _construct(Parent, args, Class) {
|
|
39
|
+
if (_is_native_reflect_construct()) {
|
|
40
|
+
_construct = Reflect.construct;
|
|
41
|
+
} else {
|
|
42
|
+
_construct = function construct(Parent, args, Class) {
|
|
43
|
+
var a = [
|
|
44
|
+
null
|
|
45
|
+
];
|
|
46
|
+
a.push.apply(a, args);
|
|
47
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
48
|
+
var instance = new Constructor();
|
|
49
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
50
|
+
return instance;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return _construct.apply(null, arguments);
|
|
54
|
+
}
|
|
55
|
+
function _get_prototype_of(o) {
|
|
56
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
57
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
58
|
+
};
|
|
59
|
+
return _get_prototype_of(o);
|
|
60
|
+
}
|
|
61
|
+
function _inherits(subClass, superClass) {
|
|
62
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
63
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
64
|
+
}
|
|
65
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
66
|
+
constructor: {
|
|
67
|
+
value: subClass,
|
|
68
|
+
writable: true,
|
|
69
|
+
configurable: true
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
73
|
+
}
|
|
74
|
+
function _is_native_function(fn) {
|
|
75
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
76
|
+
}
|
|
77
|
+
function _possible_constructor_return(self, call) {
|
|
78
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
79
|
+
return call;
|
|
80
|
+
}
|
|
81
|
+
return _assert_this_initialized(self);
|
|
82
|
+
}
|
|
83
|
+
function _set_prototype_of(o, p) {
|
|
84
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
85
|
+
o.__proto__ = p;
|
|
86
|
+
return o;
|
|
87
|
+
};
|
|
88
|
+
return _set_prototype_of(o, p);
|
|
89
|
+
}
|
|
90
|
+
function _type_of(obj) {
|
|
91
|
+
"@swc/helpers - typeof";
|
|
92
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
93
|
+
}
|
|
94
|
+
function _wrap_native_super(Class) {
|
|
95
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
96
|
+
_wrap_native_super = function wrapNativeSuper(Class) {
|
|
97
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
98
|
+
if (typeof Class !== "function") {
|
|
99
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
100
|
+
}
|
|
101
|
+
if (typeof _cache !== "undefined") {
|
|
102
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
103
|
+
_cache.set(Class, Wrapper);
|
|
104
|
+
}
|
|
105
|
+
function Wrapper() {
|
|
106
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
107
|
+
}
|
|
108
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
109
|
+
constructor: {
|
|
110
|
+
value: Wrapper,
|
|
111
|
+
enumerable: false,
|
|
112
|
+
writable: true,
|
|
113
|
+
configurable: true
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return _set_prototype_of(Wrapper, Class);
|
|
117
|
+
};
|
|
118
|
+
return _wrap_native_super(Class);
|
|
119
|
+
}
|
|
120
|
+
function _is_native_reflect_construct() {
|
|
121
|
+
try {
|
|
122
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
123
|
+
} catch (_) {}
|
|
124
|
+
return (_is_native_reflect_construct = function() {
|
|
125
|
+
return !!result;
|
|
126
|
+
})();
|
|
127
|
+
}
|
|
128
|
+
var ExitError = /*#__PURE__*/ function(Error1) {
|
|
129
|
+
"use strict";
|
|
130
|
+
_inherits(ExitError, Error1);
|
|
131
|
+
function ExitError(code) {
|
|
132
|
+
_class_call_check(this, ExitError);
|
|
133
|
+
var _this;
|
|
134
|
+
_this = _call_super(this, ExitError, [
|
|
135
|
+
"exit ".concat(code)
|
|
136
|
+
]);
|
|
137
|
+
_this.code = code;
|
|
138
|
+
return _this;
|
|
139
|
+
}
|
|
140
|
+
return ExitError;
|
|
141
|
+
}(_wrap_native_super(Error));
|
|
142
|
+
function usageError(message, usage) {
|
|
143
|
+
console.error(message);
|
|
144
|
+
if (usage !== undefined) console.error(usage);
|
|
145
|
+
throw new ExitError(2);
|
|
146
|
+
}
|
|
147
|
+
/* 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/cli/exit.ts"],"sourcesContent":["// Commands never end the process themselves: they throw this, and cli.ts -- the one place\n// that owns the exit -- drains stdio through exit-compat and returns. Neither alternative\n// works here: a direct process.exit() races a pending write, and a bare return would let a\n// command body run on after --help had already printed its usage.\nexport class ExitError extends Error {\n readonly code: number;\n constructor(code: number) {\n super(`exit ${code}`);\n this.code = code;\n }\n}\n\nexport function usageError(message: string, usage?: string): never {\n console.error(message);\n if (usage !== undefined) console.error(usage);\n throw new ExitError(2);\n}\n"],"names":["ExitError","usageError","code","Error","message","usage","console","error","undefined"],"mappings":"AAAA,0FAA0F;AAC1F,0FAA0F;AAC1F,2FAA2F;AAC3F,kEAAkE;;;;;;;;;;;;QACrDA;eAAAA;;QAQGC;eAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AART,IAAA,AAAMD,0BAAN;;cAAMA;aAAAA,UAECE,IAAY;gCAFbF;;gBAGT,kBAHSA;YAGF,QAAY,OAALE;;QACd,MAAKA,IAAI,GAAGA;;;WAJHF;qBAAkBG;AAQxB,SAASF,WAAWG,OAAe,EAAEC,KAAc;IACxDC,QAAQC,KAAK,CAACH;IACd,IAAIC,UAAUG,WAAWF,QAAQC,KAAK,CAACF;IACvC,MAAM,IAAIL,UAAU;AACtB"}
|
package/dist/cjs/cli/named.js
CHANGED
|
@@ -14,6 +14,7 @@ Object.defineProperty(exports, // Fallback when the first positional is not a co
|
|
|
14
14
|
});
|
|
15
15
|
var _commandsts = require("../commands.js");
|
|
16
16
|
var _outputts = require("../output.js");
|
|
17
|
+
var _exitts = require("./exit.js");
|
|
17
18
|
var _sharedts = require("./shared.js");
|
|
18
19
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
19
20
|
try {
|
|
@@ -183,11 +184,7 @@ function named(ctx, queryName) {
|
|
|
183
184
|
configPath = values.config;
|
|
184
185
|
cfg = ctx.resolveConfig(configPath);
|
|
185
186
|
entry = cfg.queries[queryName];
|
|
186
|
-
if (entry === undefined)
|
|
187
|
-
console.error('unknown query: "'.concat(queryName, '"'));
|
|
188
|
-
console.error("valid queries: ".concat(Object.keys(cfg.queries).sort().join(', ')));
|
|
189
|
-
process.exit(2);
|
|
190
|
-
}
|
|
187
|
+
if (entry === undefined) (0, _exitts.usageError)('unknown query: "'.concat(queryName, '"'), "valid queries: ".concat(Object.keys(cfg.queries).sort().join(', ')));
|
|
191
188
|
if (typeof entry === 'string') {
|
|
192
189
|
(0, _sharedts.runSql)(cfg, entry, params, format, 'query "'.concat(queryName, '"'));
|
|
193
190
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/named.ts"],"sourcesContent":["import { search } from '../commands.ts';\nimport { printRows } from '../output.ts';\nimport { CONFIG, FORMAT, formatOf, parse, parseK, runSql, SEARCH_FLAGS, withDb } from './shared.ts';\nimport type { Ctx } from './types.ts';\n\n// Fallback when the first positional is not a command: a named query from config, either a\n// SQL string (run as-is) or a saved search (run through the `search` command's own machinery).\n// Flags cover both shapes -- SEARCH_FLAGS override a saved search's fields the same way they\n// override a preset's.\nexport default async function named(ctx: Ctx, queryName: string): Promise<void> {\n const usage = `usage: ${ctx.name} ${queryName} [params...] [--format table|json] [--config path] [--where \"<sql>\"] [--k n] [--preset name] [--include glob ...] [--lexical]`;\n const { values, positionals: params } = parse(ctx.argv, usage, { ...SEARCH_FLAGS, ...FORMAT, ...CONFIG });\n const format = formatOf(values);\n const configPath = values.config as string | undefined;\n\n const cfg = ctx.resolveConfig(configPath);\n const entry = cfg.queries[queryName];\n if (entry === undefined)
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/named.ts"],"sourcesContent":["import { search } from '../commands.ts';\nimport { printRows } from '../output.ts';\nimport { usageError } from './exit.ts';\nimport { CONFIG, FORMAT, formatOf, parse, parseK, runSql, SEARCH_FLAGS, withDb } from './shared.ts';\nimport type { Ctx } from './types.ts';\n\n// Fallback when the first positional is not a command: a named query from config, either a\n// SQL string (run as-is) or a saved search (run through the `search` command's own machinery).\n// Flags cover both shapes -- SEARCH_FLAGS override a saved search's fields the same way they\n// override a preset's.\nexport default async function named(ctx: Ctx, queryName: string): Promise<void> {\n const usage = `usage: ${ctx.name} ${queryName} [params...] [--format table|json] [--config path] [--where \"<sql>\"] [--k n] [--preset name] [--include glob ...] [--lexical]`;\n const { values, positionals: params } = parse(ctx.argv, usage, { ...SEARCH_FLAGS, ...FORMAT, ...CONFIG });\n const format = formatOf(values);\n const configPath = values.config as string | undefined;\n\n const cfg = ctx.resolveConfig(configPath);\n const entry = cfg.queries[queryName];\n if (entry === undefined) usageError(`unknown query: \"${queryName}\"`, `valid queries: ${Object.keys(cfg.queries).sort().join(', ')}`);\n\n if (typeof entry === 'string') {\n runSql(cfg, entry, params, format, `query \"${queryName}\"`);\n return;\n }\n if ('sql' in entry) {\n runSql(cfg, entry.sql, params, format, `query \"${queryName}\"`);\n return;\n }\n\n // A saved search's text is fixed in config; there is nowhere for a positional to bind.\n if (params.length > 0) {\n ctx.usageError(`\"${queryName}\" is a saved search and takes no positional parameters; edit its \"search\" in sense.config.json, or use \"${ctx.name} search\" directly`);\n }\n const k = parseK(values.k as string | undefined, ctx.usageError) ?? entry.k;\n const where = (values.where as string | undefined) ?? entry.where;\n const preset = (values.preset as string | undefined) ?? entry.preset;\n const include = (values.include as string[] | undefined) ?? entry.include;\n // --lexical upgrades a saved search's semantic behavior the same way --where/--k\n // override; absent means the saved value (the flag has no default false override).\n const semantic = values.lexical ? false : entry.semantic;\n await withDb(ctx, configPath, async (db, resolvedCfg) => printRows(await search(db, resolvedCfg, entry.search, { k, where, preset, include, semantic }), format));\n}\n"],"names":["named","ctx","queryName","parseK","values","usage","parse","params","format","configPath","cfg","entry","k","where","preset","include","semantic","name","argv","SEARCH_FLAGS","FORMAT","CONFIG","positionals","formatOf","config","resolveConfig","queries","undefined","usageError","Object","keys","sort","join","runSql","sql","length","lexical","withDb","db","resolvedCfg","search","printRows"],"mappings":";;;;+BAMA,2FAA2F;AAC3F,+FAA+F;AAC/F,6FAA6F;AAC7F,uBAAuB;AACvB;;;eAA8BA;;;0BAVP;wBACG;sBACC;wBAC2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOvE,SAAeA,MAAMC,GAAQ,EAAEC,SAAiB;;YAuBnDC,SACKC,eACCA,gBACCA,iBAzBXC,OACkCC,QAAhCF,QAAqBG,QACvBC,QACAC,YAEAC,KACAC,OAgBAC,GACAC,OACAC,QACAC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OAAOU,MAAM,cAAbV,4BAAAA,iBAAwCO,MAAMG,MAAM;oBAC9DC,WAAWX,kBAAAA,OAAOW,OAAO,cAAdX,6BAAAA,kBAA2CO,MAAMI,OAAO;oBACzE,iFAAiF;oBACjF,mFAAmF;oBAC7EC,WAAWZ,OAAOgC,OAAO,GAAG,QAAQzB,MAAMK,QAAQ;oBACxD;;wBAAMqB,IAAAA,gBAAM,EAACpC,KAAKQ,YAAY,SAAO6B,IAAIC;;;;;4CAA0B;;gDAAMC,IAAAA,kBAAM,EAACF,IAAIC,aAAa5B,MAAM6B,MAAM,EAAE;oDAAE5B,GAAAA;oDAAGC,OAAAA;oDAAOC,QAAAA;oDAAQC,SAAAA;oDAASC,UAAAA;gDAAS;;;;;gDAA5FyB,mBAAS;oDAAC;oDAAsFjC;;;;;;;;;oBAAzJ;;;;;;IACF"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import type { ParseArgsOptionsConfig } from 'node:util';
|
|
2
1
|
import type { ResolvedConfig } from '../config.js';
|
|
3
2
|
import type { OpenResult } from '../db.js';
|
|
4
3
|
import type { Ctx } from './types.js';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export interface Flag {
|
|
5
|
+
type: 'string' | 'boolean';
|
|
6
|
+
default?: string | boolean;
|
|
7
|
+
multiple?: boolean;
|
|
8
|
+
short?: string;
|
|
9
|
+
}
|
|
10
|
+
export type Flags = Record<string, Flag>;
|
|
11
|
+
export declare const FORMAT: Flags;
|
|
12
|
+
export declare const CONFIG: Flags;
|
|
13
|
+
export declare const SEARCH_FLAGS: Flags;
|
|
14
|
+
export type Values = Record<string, string | boolean | string[] | undefined>;
|
|
9
15
|
export declare function formatOf(values: Values): 'table' | 'json';
|
|
10
|
-
export declare function parse(argv: string[], usage: string,
|
|
16
|
+
export declare function parse(argv: string[], usage: string, flags?: Flags): {
|
|
11
17
|
values: Values;
|
|
12
18
|
positionals: string[];
|
|
13
19
|
};
|
|
14
|
-
export declare function parseK(k: string | undefined,
|
|
20
|
+
export declare function parseK(k: string | undefined, usageErrorFn: (message: string) => never): number | undefined;
|
|
15
21
|
export declare function printWarnings(warnings: string[]): void;
|
|
16
22
|
export declare function withDb(ctx: Ctx, configPath: string | undefined, fn: (db: OpenResult['db'], cfg: ResolvedConfig) => void | Promise<void>): Promise<void>;
|
|
17
23
|
export declare function runSql(cfg: ResolvedConfig, sql: string, params: string[], format: 'table' | 'json', label: string): void;
|
|
18
|
-
export {};
|
package/dist/cjs/cli/shared.d.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import type { ParseArgsOptionsConfig } from 'node:util';
|
|
2
1
|
import type { ResolvedConfig } from '../config.js';
|
|
3
2
|
import type { OpenResult } from '../db.js';
|
|
4
3
|
import type { Ctx } from './types.js';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export interface Flag {
|
|
5
|
+
type: 'string' | 'boolean';
|
|
6
|
+
default?: string | boolean;
|
|
7
|
+
multiple?: boolean;
|
|
8
|
+
short?: string;
|
|
9
|
+
}
|
|
10
|
+
export type Flags = Record<string, Flag>;
|
|
11
|
+
export declare const FORMAT: Flags;
|
|
12
|
+
export declare const CONFIG: Flags;
|
|
13
|
+
export declare const SEARCH_FLAGS: Flags;
|
|
14
|
+
export type Values = Record<string, string | boolean | string[] | undefined>;
|
|
9
15
|
export declare function formatOf(values: Values): 'table' | 'json';
|
|
10
|
-
export declare function parse(argv: string[], usage: string,
|
|
16
|
+
export declare function parse(argv: string[], usage: string, flags?: Flags): {
|
|
11
17
|
values: Values;
|
|
12
18
|
positionals: string[];
|
|
13
19
|
};
|
|
14
|
-
export declare function parseK(k: string | undefined,
|
|
20
|
+
export declare function parseK(k: string | undefined, usageErrorFn: (message: string) => never): number | undefined;
|
|
15
21
|
export declare function printWarnings(warnings: string[]): void;
|
|
16
22
|
export declare function withDb(ctx: Ctx, configPath: string | undefined, fn: (db: OpenResult['db'], cfg: ResolvedConfig) => void | Promise<void>): Promise<void>;
|
|
17
23
|
export declare function runSql(cfg: ResolvedConfig, sql: string, params: string[], format: 'table' | 'json', label: string): void;
|
|
18
|
-
export {};
|
package/dist/cjs/cli/shared.js
CHANGED
|
@@ -37,15 +37,19 @@ _export(exports, {
|
|
|
37
37
|
return withDb;
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
-
var
|
|
40
|
+
var _getoptscompat = /*#__PURE__*/ _interop_require_default(require("getopts-compat"));
|
|
41
41
|
var _dbts = require("../db.js");
|
|
42
42
|
var _outputts = require("../output.js");
|
|
43
43
|
var _searcherrorts = require("../search-error.js");
|
|
44
|
+
var _exitts = require("./exit.js");
|
|
44
45
|
function _array_like_to_array(arr, len) {
|
|
45
46
|
if (len == null || len > arr.length) len = arr.length;
|
|
46
47
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
47
48
|
return arr2;
|
|
48
49
|
}
|
|
50
|
+
function _array_with_holes(arr) {
|
|
51
|
+
if (Array.isArray(arr)) return arr;
|
|
52
|
+
}
|
|
49
53
|
function _array_without_holes(arr) {
|
|
50
54
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
51
55
|
}
|
|
@@ -91,9 +95,41 @@ function _define_property(obj, key, value) {
|
|
|
91
95
|
}
|
|
92
96
|
return obj;
|
|
93
97
|
}
|
|
98
|
+
function _interop_require_default(obj) {
|
|
99
|
+
return obj && obj.__esModule ? obj : {
|
|
100
|
+
default: obj
|
|
101
|
+
};
|
|
102
|
+
}
|
|
94
103
|
function _iterable_to_array(iter) {
|
|
95
104
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
96
105
|
}
|
|
106
|
+
function _iterable_to_array_limit(arr, i) {
|
|
107
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
108
|
+
if (_i == null) return;
|
|
109
|
+
var _arr = [];
|
|
110
|
+
var _n = true;
|
|
111
|
+
var _d = false;
|
|
112
|
+
var _s, _e;
|
|
113
|
+
try {
|
|
114
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
115
|
+
_arr.push(_s.value);
|
|
116
|
+
if (i && _arr.length === i) break;
|
|
117
|
+
}
|
|
118
|
+
} catch (err) {
|
|
119
|
+
_d = true;
|
|
120
|
+
_e = err;
|
|
121
|
+
} finally{
|
|
122
|
+
try {
|
|
123
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
124
|
+
} finally{
|
|
125
|
+
if (_d) throw _e;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return _arr;
|
|
129
|
+
}
|
|
130
|
+
function _non_iterable_rest() {
|
|
131
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
132
|
+
}
|
|
97
133
|
function _non_iterable_spread() {
|
|
98
134
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
99
135
|
}
|
|
@@ -136,6 +172,9 @@ function _object_spread_props(target, source) {
|
|
|
136
172
|
}
|
|
137
173
|
return target;
|
|
138
174
|
}
|
|
175
|
+
function _sliced_to_array(arr, i) {
|
|
176
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
177
|
+
}
|
|
139
178
|
function _to_consumable_array(arr) {
|
|
140
179
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
141
180
|
}
|
|
@@ -279,41 +318,100 @@ var SEARCH_FLAGS = {
|
|
|
279
318
|
function formatOf(values) {
|
|
280
319
|
return values.format === 'json' ? 'json' : 'table';
|
|
281
320
|
}
|
|
282
|
-
function parse(argv, usage
|
|
283
|
-
var
|
|
284
|
-
var
|
|
321
|
+
function parse(argv, usage) {
|
|
322
|
+
var flags = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
323
|
+
var table = _object_spread_props(_object_spread({}, flags), {
|
|
324
|
+
help: {
|
|
325
|
+
type: 'boolean',
|
|
326
|
+
default: false,
|
|
327
|
+
short: 'h'
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
var string = [];
|
|
331
|
+
var boolean = [];
|
|
332
|
+
var alias = {};
|
|
333
|
+
var defaults = {};
|
|
334
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
285
335
|
try {
|
|
286
|
-
var
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
default: false,
|
|
293
|
-
short: 'h'
|
|
294
|
-
}
|
|
295
|
-
}),
|
|
296
|
-
strict: true,
|
|
297
|
-
allowPositionals: true
|
|
298
|
-
}), values = ref.values, positionals = ref.positionals, ref;
|
|
336
|
+
for(var _iterator = Object.entries(table)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
337
|
+
var _step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], flag = _step_value[1];
|
|
338
|
+
(flag.type === 'boolean' ? boolean : string).push(name);
|
|
339
|
+
if (flag.default !== undefined) defaults[name] = flag.default;
|
|
340
|
+
if (flag.short !== undefined) alias[name] = flag.short;
|
|
341
|
+
}
|
|
299
342
|
} catch (err) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
343
|
+
_didIteratorError = true;
|
|
344
|
+
_iteratorError = err;
|
|
345
|
+
} finally{
|
|
346
|
+
try {
|
|
347
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
348
|
+
_iterator.return();
|
|
349
|
+
}
|
|
350
|
+
} finally{
|
|
351
|
+
if (_didIteratorError) {
|
|
352
|
+
throw _iteratorError;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
303
355
|
}
|
|
304
|
-
|
|
356
|
+
// getopts is lenient about undeclared flags -- they land in the result and are silently
|
|
357
|
+
// ignored, which is the bug 0.9.2 fixed. Record the first and fail below; returning false
|
|
358
|
+
// also keeps it out of the result. `--k -1` arrives here as unknown option "1", because
|
|
359
|
+
// getopts reads a leading dash as a new option rather than as --k's value; the message is
|
|
360
|
+
// blunter than the old one but it is still a usage error rather than a silent default.
|
|
361
|
+
var unknown;
|
|
362
|
+
var parsed = (0, _getoptscompat.default)(argv, {
|
|
363
|
+
string: string,
|
|
364
|
+
boolean: boolean,
|
|
365
|
+
alias: alias,
|
|
366
|
+
default: defaults,
|
|
367
|
+
unknown: function unknown1(name) {
|
|
368
|
+
if (unknown === undefined) unknown = name;
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
if (unknown !== undefined) (0, _exitts.usageError)("unknown option: ".concat(unknown), usage);
|
|
373
|
+
if (parsed.help) {
|
|
305
374
|
console.log(usage);
|
|
306
|
-
|
|
375
|
+
throw new _exitts.ExitError(0);
|
|
376
|
+
}
|
|
377
|
+
// Two getopts shapes the callers must not see: an unset string flag reads as "" rather
|
|
378
|
+
// than undefined, and a flag passed once reads as a string rather than a one-element
|
|
379
|
+
// array. Both matter -- `?? saved.field` means "flag absent", and --include is a list.
|
|
380
|
+
var values = {};
|
|
381
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
382
|
+
try {
|
|
383
|
+
for(var _iterator1 = Object.entries(table)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
384
|
+
var _step_value1 = _sliced_to_array(_step1.value, 2), name1 = _step_value1[0], flag1 = _step_value1[1];
|
|
385
|
+
var raw = parsed[name1];
|
|
386
|
+
if (flag1.type === 'boolean') values[name1] = raw;
|
|
387
|
+
else if (flag1.multiple) values[name1] = raw === '' ? undefined : Array.isArray(raw) ? raw : [
|
|
388
|
+
raw
|
|
389
|
+
];
|
|
390
|
+
else values[name1] = raw === '' ? undefined : raw;
|
|
391
|
+
}
|
|
392
|
+
} catch (err) {
|
|
393
|
+
_didIteratorError1 = true;
|
|
394
|
+
_iteratorError1 = err;
|
|
395
|
+
} finally{
|
|
396
|
+
try {
|
|
397
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
398
|
+
_iterator1.return();
|
|
399
|
+
}
|
|
400
|
+
} finally{
|
|
401
|
+
if (_didIteratorError1) {
|
|
402
|
+
throw _iteratorError1;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
307
405
|
}
|
|
308
406
|
return {
|
|
309
407
|
values: values,
|
|
310
|
-
positionals:
|
|
408
|
+
positionals: parsed._
|
|
311
409
|
};
|
|
312
410
|
}
|
|
313
|
-
function parseK(k,
|
|
411
|
+
function parseK(k, usageErrorFn) {
|
|
314
412
|
if (k === undefined) return undefined;
|
|
315
413
|
var parsed = Number(k);
|
|
316
|
-
if (!Number.isInteger(parsed) || parsed <= 0)
|
|
414
|
+
if (!Number.isInteger(parsed) || parsed <= 0) usageErrorFn('--k expects a positive integer, got "'.concat(k, '"'));
|
|
317
415
|
return parsed;
|
|
318
416
|
}
|
|
319
417
|
function printWarnings(warnings) {
|
|
@@ -381,10 +479,7 @@ function withDb(ctx, configPath, fn) {
|
|
|
381
479
|
function runSql(cfg, sql, params, format, label) {
|
|
382
480
|
var _sql_match;
|
|
383
481
|
var placeholderCount = ((_sql_match = sql.match(/\?/g)) !== null && _sql_match !== void 0 ? _sql_match : []).length;
|
|
384
|
-
if (params.length !== placeholderCount)
|
|
385
|
-
console.error("".concat(label, " expects ").concat(placeholderCount, " parameter(s), got ").concat(params.length));
|
|
386
|
-
process.exit(2);
|
|
387
|
-
}
|
|
482
|
+
if (params.length !== placeholderCount) (0, _exitts.usageError)("".concat(label, " expects ").concat(placeholderCount, " parameter(s), got ").concat(params.length));
|
|
388
483
|
var _open = (0, _dbts.open)(cfg), db = _open.db, warnings = _open.warnings;
|
|
389
484
|
printWarnings(warnings);
|
|
390
485
|
var rows;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/shared.ts"],"sourcesContent":["import type { ParseArgsOptionsConfig } from 'node:util';\nimport { parseArgs } from 'node:util';\nimport 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// Spreadable option fragments -- one flag name keeps one meaning across every command's table.\nexport const FORMAT: ParseArgsOptionsConfig = { format: { type: 'string', default: 'table' } };\nexport const CONFIG: ParseArgsOptionsConfig = { config: { type: 'string' } };\nexport const SEARCH_FLAGS: ParseArgsOptionsConfig = {\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};\n\ntype Values = Record<string, string | boolean | string[] | undefined>;\n\nexport function formatOf(values: Values): 'table' | 'json' {\n return values.format === 'json' ? 'json' : 'table';\n}\n\n// Per-command parseArgs: strict (a foreign flag exits 2), and every table gets --help for free.\nexport function parse(argv: string[], usage: string, options: ParseArgsOptionsConfig): { values: Values; positionals: string[] } {\n let values: Values;\n let positionals: string[];\n try {\n ({ values, positionals } = parseArgs({\n args: argv,\n options: { ...options, help: { type: 'boolean', default: false, short: 'h' } },\n strict: true,\n allowPositionals: true,\n }));\n } catch (err) {\n console.error((err as Error).message);\n console.error(usage);\n process.exit(2);\n }\n if (values.help) {\n console.log(usage);\n process.exit(0);\n }\n return { values, positionals };\n}\n\n// --k must be a positive integer: SQLite reads a bound LIMIT of -1 as \"unlimited\" and 0 as\n// \"nothing\", and parseInt would silently truncate \"5.9\" -- all three are caller mistakes\n// worth a usage error, matching the config-level SavedSearch validation.\nexport function parseK(k: string | undefined, usageError: (message: string) => never): number | undefined {\n if (k === undefined) return undefined;\n const parsed = Number(k);\n if (!Number.isInteger(parsed) || parsed <= 0) usageError(`--k expects a positive integer, got \"${k}\"`);\n return parsed;\n}\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, configPath: string | undefined, fn: (db: OpenResult['db'], cfg: ResolvedConfig) => void | Promise<void>): Promise<void> {\n const cfg = ctx.resolveConfig(configPath);\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":["CONFIG","FORMAT","SEARCH_FLAGS","formatOf","parse","parseK","printWarnings","runSql","withDb","format","type","default","config","where","k","preset","include","multiple","lexical","values","argv","usage","options","positionals","parseArgs","args","help","short","strict","allowPositionals","err","console","error","message","process","exit","log","usageError","undefined","parsed","Number","isInteger","warnings","w","warn","ctx","configPath","fn","cfg","open","db","resolveConfig","close","sql","params","label","placeholderCount","match","length","rows","prepare","all","test","searchError","join","printRows"],"mappings":";;;;;;;;;;;QAYa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OAAtCE,kBAAiB,uBAAmC,OAAdF,OAAOI,MAAM;QACrFxB,QAAQC,IAAI,CAAC;IACf;IACA,IAAyBc,QAAAA,IAAAA,UAAI,EAACD,MAAtBE,KAAiBD,MAAjBC,IAAIR,WAAaO,MAAbP;IACZpC,cAAcoC;IACd,IAAIiB;IACJ,IAAI;YACKT;QAAPS,OAAOT,CAAAA,cAAAA,GAAGU,OAAO,CAACP,MAAKQ,GAAG,OAAnBX,aAAoB,qBAAGI;IAChC,EAAE,OAAOxB,KAAK;QACZoB,GAAGE,KAAK;QACR,gFAAgF;QAChF,mFAAmF;QACnF,sFAAsF;QACtF,IAAI,aAAaU,IAAI,CAACT,MAAM,MAAMU,IAAAA,0BAAW,EAACjC,KAAcwB,OAAOU,IAAI,CAAC;QACxE,MAAMlC;IACR;IACAmC,IAAAA,mBAAS,EAACN,MAAMlD;IAChByC,GAAGE,KAAK;AACV"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/cli/shared.ts"],"sourcesContent":["import getopts from 'getopts-compat';\nimport 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 { ExitError, usageError } from './exit.ts';\nimport type { Ctx } from './types.ts';\n\n// Flag descriptors, spreadable so one flag name keeps one meaning across every command's\n// table. parse() converts them to the getopts call the rest of the CLIs here make directly.\nexport interface Flag {\n type: 'string' | 'boolean';\n default?: string | boolean;\n multiple?: boolean;\n short?: string;\n}\nexport type Flags = Record<string, Flag>;\n\nexport const FORMAT: Flags = { format: { type: 'string', default: 'table' } };\nexport const CONFIG: Flags = { config: { type: 'string' } };\nexport const SEARCH_FLAGS: Flags = {\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};\n\nexport type Values = Record<string, string | boolean | string[] | undefined>;\n\nexport function formatOf(values: Values): 'table' | 'json' {\n return values.format === 'json' ? 'json' : 'table';\n}\n\n// Per-command parse: strict (a foreign flag exits 2), and every table gets --help for free.\nexport function parse(argv: string[], usage: string, flags: Flags = {}): { values: Values; positionals: string[] } {\n const table: Flags = { ...flags, help: { type: 'boolean', default: false, short: 'h' } };\n const string: string[] = [];\n const boolean: string[] = [];\n const alias: Record<string, string> = {};\n const defaults: Record<string, string | boolean> = {};\n for (const [name, flag] of Object.entries(table)) {\n (flag.type === 'boolean' ? boolean : string).push(name);\n if (flag.default !== undefined) defaults[name] = flag.default;\n if (flag.short !== undefined) alias[name] = flag.short;\n }\n\n // getopts is lenient about undeclared flags -- they land in the result and are silently\n // ignored, which is the bug 0.9.2 fixed. Record the first and fail below; returning false\n // also keeps it out of the result. `--k -1` arrives here as unknown option \"1\", because\n // getopts reads a leading dash as a new option rather than as --k's value; the message is\n // blunter than the old one but it is still a usage error rather than a silent default.\n let unknown: string | undefined;\n const parsed = getopts(argv, {\n string,\n boolean,\n alias,\n default: defaults,\n unknown: (name: string): boolean => {\n if (unknown === undefined) unknown = name;\n return false;\n },\n });\n if (unknown !== undefined) usageError(`unknown option: ${unknown}`, usage);\n if (parsed.help) {\n console.log(usage);\n throw new ExitError(0);\n }\n\n // Two getopts shapes the callers must not see: an unset string flag reads as \"\" rather\n // than undefined, and a flag passed once reads as a string rather than a one-element\n // array. Both matter -- `?? saved.field` means \"flag absent\", and --include is a list.\n const values: Values = {};\n for (const [name, flag] of Object.entries(table)) {\n const raw = parsed[name];\n if (flag.type === 'boolean') values[name] = raw as boolean;\n else if (flag.multiple) values[name] = raw === '' ? undefined : Array.isArray(raw) ? (raw as string[]) : [raw as string];\n else values[name] = raw === '' ? undefined : (raw as string);\n }\n return { values, positionals: parsed._ };\n}\n\n// --k must be a positive integer: SQLite reads a bound LIMIT of -1 as \"unlimited\" and 0 as\n// \"nothing\", and parseInt would silently truncate \"5.9\" -- all three are caller mistakes\n// worth a usage error, matching the config-level SavedSearch validation.\nexport function parseK(k: string | undefined, usageErrorFn: (message: string) => never): number | undefined {\n if (k === undefined) return undefined;\n const parsed = Number(k);\n if (!Number.isInteger(parsed) || parsed <= 0) usageErrorFn(`--k expects a positive integer, got \"${k}\"`);\n return parsed;\n}\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, configPath: string | undefined, fn: (db: OpenResult['db'], cfg: ResolvedConfig) => void | Promise<void>): Promise<void> {\n const cfg = ctx.resolveConfig(configPath);\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) usageError(`${label} expects ${placeholderCount} parameter(s), got ${params.length}`);\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":["CONFIG","FORMAT","SEARCH_FLAGS","formatOf","parse","parseK","printWarnings","runSql","withDb","format","type","default","config","where","k","preset","include","multiple","lexical","values","argv","usage","flags","table","help","short","string","boolean","alias","defaults","Object","entries","name","flag","push","undefined","unknown","parsed","getopts","usageError","console","log","ExitError","raw","Array","isArray","positionals","_","usageErrorFn","Number","isInteger","warnings","w","warn","ctx","configPath","fn","cfg","open","db","resolveConfig","close","sql","params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