dirsql 0.3.93 → 0.3.94

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.
@@ -1,23 +1,34 @@
1
1
  # Keep the index across restarts
2
2
 
3
3
  By default the database is ephemeral: rebuilt from your files on every
4
- startup and discarded on exit. [`persist`](../reference/config.md#dirsql-keys) keeps the
5
- SQLite index on disk instead, so a restart only re-parses files that
6
- actually changed — the difference between seconds and milliseconds on large
7
- trees, and between re-running and skipping expensive
4
+ startup and discarded on exit. The [`--persist [PATH]`](../reference/cli.md#server-mode)
5
+ flag keeps the SQLite index on disk instead, so a restart only re-parses
6
+ files that actually changed — the difference between seconds and
7
+ milliseconds on large trees, and between re-running and skipping expensive
8
8
  [`on-file`](./extract-from-contents.md) commands.
9
9
 
10
+ Whether and where to cache is a machine-local operational choice — it
11
+ belongs to the command you run, not to the shared `.dirsql.toml`. That is
12
+ why it is a CLI flag, not a config key.
13
+
10
14
  ## 1. Turn it on
11
15
 
12
- ```toml
13
- [dirsql]
14
- persist = true
16
+ ```bash
17
+ dirsql --persist
15
18
  ```
16
19
 
17
20
  That's the whole change. On the next run the cache is written to
18
21
  `.dirsql/cache.db` under the root; runs after that start from it. To put
19
- the cache elsewhere (a CI cache dir, a tmpfs), set
20
- [`persist_path`](../reference/config.md#dirsql-keys).
22
+ the cache elsewhere (a CI cache dir, a tmpfs), pass a path:
23
+
24
+ ```bash
25
+ dirsql --persist /var/cache/dirsql.db
26
+ ```
27
+
28
+ The same flag works on [`dirsql query`](../reference/cli.md#dirsql-query);
29
+ put a bare `--persist` after the SQL there so it does not consume the query
30
+ argument. Embedding `dirsql`? The SDK constructors expose the same switch —
31
+ see [_Embedding `dirsql`?_](#embedding-dirsql) below.
21
32
 
22
33
  ## 2. Keep the cache out of git
23
34
 
@@ -48,6 +48,7 @@ requests, closes open `/events` streams, and exits.
48
48
  | `-c, --config <path>` | `./.dirsql.toml` | Path to the [config file](./config.md). The index is rooted at the directory containing this file (unless the config sets `[dirsql].root`). When the file does not exist, the server runs in [zero-config mode](#zero-config-mode). |
49
49
  | `--host <addr>` | `localhost` | Bind address. |
50
50
  | `--port <n>` | `7117` | TCP port to bind. |
51
+ | `--persist [<path>]` | off | Keep the SQLite index on disk between runs so a restart only re-parses files that actually changed. Bare `--persist` caches at `<root>/.dirsql/cache.db`; `--persist <path>` caches at `<path>`. Off by default (the index is ephemeral). Global — also honored by [`dirsql query`](#dirsql-query). See [Keep the index across restarts](../howto/persist.md). |
51
52
  | `--extension <path>` | none | Load a SQLite extension by literal path, overriding the config's `[[dirsql.extension]]` entries. Repeatable. Format: `<path>` or `<path>::<entrypoint>`. Internal plumbing for the pip/npm launchers, which resolve package-name extensions and pass the resolved paths here — not intended for direct use. When any `--extension` is present, the config file's own extension entries are not loaded. |
52
53
  | `--version` | | Print the version and exit. |
53
54
  | `--help` | | Print usage and exit. |
@@ -119,6 +120,10 @@ uses**, so behavior is identical to `POST /query` by construction:
119
120
  - **Config discovery** honors `--config` (default `./.dirsql.toml`),
120
121
  [zero-config mode](#zero-config-mode), and `--extension` overrides,
121
122
  exactly as server mode does.
123
+ - **`--persist [<path>]`** is honored, so a repeated `dirsql query` reuses the
124
+ on-disk cache. Because its value is optional, place a bare `--persist` after
125
+ the SQL (`dirsql query "SELECT …" --persist`) or use the `=` form
126
+ (`--persist=/path`) so it does not swallow the SQL argument.
122
127
  - **Hooks** ([`pre-query`](./hooks.md#pre-query) /
123
128
  [`post-query`](./hooks.md#post-query)) and the
124
129
  [`[dirsql].hook-timeout`](./config.md#dirsql-keys) apply identically.
@@ -11,7 +11,7 @@ The [CLI](./cli.md) loads `./.dirsql.toml` by default (`--config <path>`
11
11
  overrides). The [SDKs](./sdk.md) load a config via the `config` constructor
12
12
  parameter.
13
13
 
14
- **Path resolution.** Relative paths in the config (`root`, `persist_path`,
14
+ **Path resolution.** Relative paths in the config (`root`,
15
15
  `[[dirsql.extension]]` `path`) resolve against the config file's parent
16
16
  directory. The scan root defaults to that same directory when `root` is not
17
17
  set.
@@ -22,8 +22,6 @@ set.
22
22
  |---|---|---|---|
23
23
  | `root` | string | config file's parent directory | Directory to index. Relative values resolve against the config file's parent. An explicit `root` passed to an SDK constructor overrides this (a warning is emitted on stderr). |
24
24
  | `ignore` | array of strings | `[]` | Glob patterns matched against root-relative paths. Matched files are skipped entirely — excluded from the initial scan and from watch events. |
25
- | `persist` | boolean | `false` | Keep the SQLite index on disk between runs. When `false`, the index is ephemeral: rebuilt from your files on every startup and discarded on exit. |
26
- | `persist_path` | string | `<root>/.dirsql/cache.db` | Location of the on-disk cache. Relative values resolve against the config file's parent. Ignored unless `persist = true`. |
27
25
  | `pre-query` | string | none | Server-wide command hook: the raw `POST /query` request body is passed to this command as `{args}`, and the plain-text SQL it prints is executed instead of parsing the body as `{"sql": …}`. CLI server only; the SDKs ignore it. Must be non-empty. See [Command hooks](./hooks.md#pre-query). |
28
26
  | `post-query` | string | none | Server-wide command hook: each successful `POST /query` result set is handed to this command (as a JSON array on stdin, and as `{args}` up to 96 KiB), and the JSON body it prints is returned instead of the bare row array. CLI server only; the SDKs ignore it. Must be non-empty. See [Command hooks](./hooks.md#post-query). |
29
27
  | `hook-timeout` | integer (seconds) | `30` | One global per-run timeout for every command hook — `on-file`, `pre-query`, and `post-query` alike. Positive whole seconds; zero and negative values are a config error. See [Command hooks](./hooks.md#timeout). |
@@ -38,11 +36,13 @@ directory.
38
36
  [dirsql]
39
37
  root = "../data"
40
38
  ignore = ["node_modules/**", ".git/**"]
41
- persist = true
42
- persist_path = ".dirsql/cache.db" # the default; shown for illustration
43
39
  hook-timeout = 300
44
40
  ```
45
41
 
42
+ Persistence is not a config key. Keep the SQLite index on disk between runs
43
+ with the [`--persist [PATH]` CLI flag](./cli.md#server-mode) — a machine-local
44
+ operational choice that belongs to the runner, not to shareable config.
45
+
46
46
  ## `[[dirsql.extension]]`
47
47
 
48
48
  Each entry declares a SQLite extension to load at startup. Extensions are
@@ -150,7 +150,6 @@ SDKs raise/reject) when:
150
150
  ```toml
151
151
  [dirsql]
152
152
  ignore = ["node_modules/**", ".git/**", "dist/**"]
153
- persist = true
154
153
  pre-query = "uv run python to_sql.py {args}"
155
154
  post-query = "jq -c '{results: .}'"
156
155
  hook-timeout = 120
@@ -111,11 +111,10 @@ directory" error.
111
111
  - `persist` — Keep the SQLite index on disk between runs (default off:
112
112
  ephemeral, rebuilt every startup). The cache lives at
113
113
  `<root>/.dirsql/cache.db` by default; on restart, only files whose stat
114
- changed are re-parsed. `persist = true` in the config also enables it.
115
- - `persist_path` / `persistPath` — Override the cache location. An
116
- explicit value wins over the config's `persist_path`. Ignored when
117
- persistence is off. (Config-file values resolve relative to the config's
118
- parent directory; constructor values are used as given.)
114
+ changed are re-parsed. (The CLI exposes the same switch as the
115
+ [`--persist [PATH]`](./cli.md#server-mode) flag; it is not a config key.)
116
+ - `persist_path` / `persistPath` — Override the cache location. Ignored when
117
+ persistence is off. Constructor values are used as given.
119
118
  - `extensions` — SQLite extensions to load at startup, before any table
120
119
  DDL (enable → load → disable, so SQL `load_extension()` is never
121
120
  exposed). Each entry pairs a shared-library `path` with an optional
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirsql",
3
- "version": "0.3.93",
3
+ "version": "0.3.94",
4
4
  "description": "Ephemeral SQL index over a local directory",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/thekevinscott/dirsql",
@@ -212,15 +212,15 @@
212
212
  ]
213
213
  },
214
214
  "optionalDependencies": {
215
- "@dirsql/lib-linux-x64-gnu": "0.3.93",
216
- "@dirsql/lib-linux-arm64-gnu": "0.3.93",
217
- "@dirsql/lib-darwin-x64": "0.3.93",
218
- "@dirsql/lib-darwin-arm64": "0.3.93",
219
- "@dirsql/lib-win32-x64-msvc": "0.3.93",
220
- "@dirsql/cli-linux-x64-gnu": "0.3.93",
221
- "@dirsql/cli-linux-arm64-gnu": "0.3.93",
222
- "@dirsql/cli-darwin-x64": "0.3.93",
223
- "@dirsql/cli-darwin-arm64": "0.3.93",
224
- "@dirsql/cli-win32-x64-msvc": "0.3.93"
215
+ "@dirsql/lib-linux-x64-gnu": "0.3.94",
216
+ "@dirsql/lib-linux-arm64-gnu": "0.3.94",
217
+ "@dirsql/lib-darwin-x64": "0.3.94",
218
+ "@dirsql/lib-darwin-arm64": "0.3.94",
219
+ "@dirsql/lib-win32-x64-msvc": "0.3.94",
220
+ "@dirsql/cli-linux-x64-gnu": "0.3.94",
221
+ "@dirsql/cli-linux-arm64-gnu": "0.3.94",
222
+ "@dirsql/cli-darwin-x64": "0.3.94",
223
+ "@dirsql/cli-darwin-arm64": "0.3.94",
224
+ "@dirsql/cli-win32-x64-msvc": "0.3.94"
225
225
  }
226
226
  }