dirsql 0.4.33 → 0.4.35

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.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Every config value in argv, in order (`--config X`, `--config=X`, `-c X`,
3
+ * `-c=X`, `-cX`), or the default when none are given.
4
+ */
5
+ export declare function configPathsFromArgv(argv: string[]): string[];
@@ -0,0 +1,31 @@
1
+ // The `-c`/`--config` flag is repeatable, so the scan collects every
2
+ // occurrence, in argv order.
3
+ /**
4
+ * Every config value in argv, in order (`--config X`, `--config=X`, `-c X`,
5
+ * `-c=X`, `-cX`), or the default when none are given.
6
+ */
7
+ export function configPathsFromArgv(argv) {
8
+ const paths = [];
9
+ let expectValue = false;
10
+ for (const a of argv) {
11
+ if (expectValue) {
12
+ paths.push(a);
13
+ expectValue = false;
14
+ }
15
+ else if (a === "--config" || a === "-c") {
16
+ expectValue = true;
17
+ }
18
+ else if (a.startsWith("--config=")) {
19
+ paths.push(a.slice("--config=".length));
20
+ }
21
+ else if (a.startsWith("-c")) {
22
+ const value = a.slice("-c".length);
23
+ paths.push(value.startsWith("=") ? value.slice("=".length) : value);
24
+ }
25
+ }
26
+ if (expectValue) {
27
+ // A bare trailing flag (no following value) yields "".
28
+ paths.push("");
29
+ }
30
+ return paths.length > 0 ? paths : ["./.dirsql.toml"];
31
+ }
@@ -7,45 +7,14 @@
7
7
  // resolved literal paths to the binary via repeatable `--extension` flags;
8
8
  // the binary then loads those and ignores the configs' own extension entries.
9
9
  //
10
- // The `-c`/`--config` flag is repeatable, so the scan collects every
11
- // occurrence, in argv order.
12
- //
13
10
  // Native-language configs (`.py`/`.js`/`.mjs`/`.cjs`) are untouched: the binary
14
11
  // dispatches those to `dirsql interpret`, whose handshake already carries
15
12
  // resolved paths.
16
13
  import { existsSync } from "node:fs";
14
+ import { configPathsFromArgv } from "./config-paths-from-argv.js";
17
15
  // Config extensions the binary dispatches to `dirsql interpret`; never
18
16
  // pre-resolved here (that path resolves via the handshake).
19
17
  const NATIVE_CONFIG_SUFFIXES = [".py", ".js", ".mjs", ".cjs"];
20
- /**
21
- * Every config value in argv, in order (`--config X`, `--config=X`, `-c X`,
22
- * `-c=X`, `-cX`), or the default when none are given.
23
- */
24
- function configPathsFromArgv(argv) {
25
- const paths = [];
26
- let expectValue = false;
27
- for (const a of argv) {
28
- if (expectValue) {
29
- paths.push(a);
30
- expectValue = false;
31
- }
32
- else if (a === "--config" || a === "-c") {
33
- expectValue = true;
34
- }
35
- else if (a.startsWith("--config=")) {
36
- paths.push(a.slice("--config=".length));
37
- }
38
- else if (a.startsWith("-c")) {
39
- const value = a.slice("-c".length);
40
- paths.push(value.startsWith("=") ? value.slice("=".length) : value);
41
- }
42
- }
43
- if (expectValue) {
44
- // A bare trailing flag (no following value) yields "".
45
- paths.push("");
46
- }
47
- return paths.length > 0 ? paths : ["./.dirsql.toml"];
48
- }
49
18
  /**
50
19
  * Return `argv` augmented with `--extension <path>[::entrypoint]` flags when a
51
20
  * TOML config names an extension by package name; otherwise return `argv`
@@ -498,6 +498,24 @@ and, when the query ends:
498
498
  dirsql: ran 41231 worker calls in 2m41s
499
499
  ```
500
500
 
501
+ A worker that keeps a cache of its own can say so per response
502
+ (`{"meta": {"cached": true}}` — see [Worker
503
+ protocol](./config.md#worker-protocol)), and those round trips are then split
504
+ out, because the number that answers *"will this be fast next time"* is not
505
+ the total:
506
+
507
+ ```
508
+ dirsql: running 9204 worker calls (8811 cached)
509
+ dirsql: ran 41231 worker calls in 2m41s (38104 cached)
510
+ ```
511
+
512
+ Both figures count **worker round trips, not rows**. A function declared
513
+ `deterministic = true` lets SQLite reuse one answer for identical arguments
514
+ within a query, so repeated content never reaches the worker at all and both
515
+ numbers sit below the row count on a corpus with duplicates. The split covers
516
+ only what the worker itself reports serving from cache. A worker that sends no
517
+ `meta` gets the unsplit line above, not a `(0 cached)`.
518
+
501
519
  A query that calls no worker prints nothing, whatever the setting — the
502
520
  reporting only ever speaks when there is something to report.
503
521
 
@@ -161,6 +161,15 @@ request line in, one response line out, per call:
161
161
  JSON-text vectors) — or `{"err": "message"}`, which **fails the query**
162
162
  with that message. An `{"err": ...}` response leaves the healthy worker
163
163
  running; only transport failures (timeout, crash) recycle it.
164
+ - **Optional `"meta"`**, alongside `"ok"`: a second top-level object carrying
165
+ facts about how the answer was produced rather than what it is. One key is
166
+ read today — `{"ok": [...], "meta": {"cached": true}}` says the worker
167
+ answered from a cache of its own, which dirsql reports as the `(N cached)`
168
+ split on its [worker-call progress line](./cli.md#progress-reporting). The
169
+ field is **optional and advisory**: a worker that omits it is a worker that
170
+ reports no cache hits, keys dirsql does not recognize are ignored (they
171
+ always have been), and a `meta` of an unexpected shape is ignored too rather
172
+ than failing a query over a progress counter.
164
173
  - **stderr passes through** to `dirsql`'s stderr, so a worker's progress
165
174
  bars and download logs reach the terminal.
166
175
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirsql",
3
- "version": "0.4.33",
3
+ "version": "0.4.35",
4
4
  "description": "Ephemeral SQL index over a local directory",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/thekevinscott/dirsql",
@@ -213,10 +213,10 @@
213
213
  ]
214
214
  },
215
215
  "optionalDependencies": {
216
- "@dirsql/lib-linux-x64-gnu": "0.4.33",
217
- "@dirsql/lib-linux-arm64-gnu": "0.4.33",
218
- "@dirsql/lib-darwin-x64": "0.4.33",
219
- "@dirsql/lib-darwin-arm64": "0.4.33",
220
- "@dirsql/lib-win32-x64-msvc": "0.4.33"
216
+ "@dirsql/lib-linux-x64-gnu": "0.4.35",
217
+ "@dirsql/lib-linux-arm64-gnu": "0.4.35",
218
+ "@dirsql/lib-darwin-x64": "0.4.35",
219
+ "@dirsql/lib-darwin-arm64": "0.4.35",
220
+ "@dirsql/lib-win32-x64-msvc": "0.4.35"
221
221
  }
222
222
  }