dirsql 0.4.85 → 0.4.87

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/dirsql.d.ts CHANGED
@@ -22,7 +22,8 @@ export interface ExtensionSpec {
22
22
  * Options accepted by the {@link DirSQL} constructor.
23
23
  *
24
24
  * The index root is the explicit `root` when given, otherwise the process
25
- * working directory. The `config` file's location never sets the root.
25
+ * working directory. The `config` file's location never sets the root; its
26
+ * `[[table]]` globs anchor at the config file's own directory.
26
27
  */
27
28
  export interface DirSQLOptions {
28
29
  /** Root directory to scan. */
@@ -62,7 +62,9 @@ and [`ignore`](../reference/config.md#dirsql-keys).
62
62
  There are **no plugin-specific keys and no plugin-specific restrictions**. The
63
63
  config schema is content-only: the index root and persistence are
64
64
  [runner-owned](../reference/config.md#dirsql-keys) — the root is the directory
65
- `dirsql` is run from (or an SDK's explicit `root`), persistence is the
65
+ `dirsql` is run from (or an SDK's explicit `root`) and governs path-tables,
66
+ while a fragment's own `[[table]]` globs anchor at the fragment's directory
67
+ (see [glob anchor](../reference/config.md#glob-anchor)); persistence is the
66
68
  `--persist [PATH]` flag — decided by whoever runs `dirsql`, never by a config
67
69
  file, so a plugin has nothing to say about them. Whatever you can put in your
68
70
  own `.dirsql.toml`, a plugin can put in its fragment, and vice-versa.
@@ -86,11 +88,10 @@ matter most for a published plugin:
86
88
  - **A hook runs in its declaring config's directory.** For a plugin that is
87
89
  the installed fragment's directory — inside **site-packages**. That is a
88
90
  read-only, shared location: **run from it, never write to it.** Read the
89
- matched files from the absolute paths the hook appends as arguments, and use
90
- [`{root}`](../reference/hooks.md#on-file) to reach the user's project
91
- directory. Write any cache to `{root}` or a real cache dir,
92
- never next to the fragment.
93
- - **The paths are absolute and `{root}` is the index root**, so a command is
91
+ matched files from the absolute paths the hook appends as arguments. Write any cache to a real cache dir, never next to
92
+ the fragment.
93
+ - **The paths are absolute and `{root}` is the table's glob anchor** (the
94
+ fragment's directory, or the literal prefix of an absolute / `~/` glob), so a command is
94
95
  self-sufficient from any working directory — it works whether the plugin
95
96
  lives in the project or in site-packages.
96
97
 
@@ -244,7 +244,7 @@ Config flags are subcommand-local: pass them after `server`
244
244
 
245
245
  | Flag | Default | Description |
246
246
  |---|---|---|
247
- | `-c, --config <path>` | none | Path to a [config file](./config.md). **Repeatable** (`-c a -c b`): the configs load and merge in argv order — see [Composing multiple configs](./config.md#composing-multiple-configs). The index is always rooted at the **invocation directory** (the current working directory), regardless of where a config lives — so `--config /elsewhere/.dirsql.toml` still indexes the directory you ran `dirsql server` from. With none given, **no named tables are defined** — query the filesystem with a [path-table](./path-tables.md) (`FROM './'`). A `./.dirsql.toml` on disk is **not** auto-loaded; pass it explicitly. A `-c` naming a file that does not exist is an [error](#degraded-mode). |
247
+ | `-c, --config <path>` | none | Path to a [config file](./config.md). **Repeatable** (`-c a -c b`): the configs load and merge in argv order — see [Composing multiple configs](./config.md#composing-multiple-configs). The index root is the **invocation directory** (the current working directory) and governs path-tables; a config's `[[table]]` globs anchor at **that config's own directory** (see [glob anchor](./config.md#glob-anchor)), so `--config /elsewhere/.dirsql.toml` indexes `/elsewhere`, from any working directory. With none given, **no named tables are defined** — query the filesystem with a [path-table](./path-tables.md) (`FROM './'`). A `./.dirsql.toml` on disk is **not** auto-loaded; pass it explicitly. A `-c` naming a file that does not exist is an [error](#degraded-mode). |
248
248
  | `--host <addr>` | `localhost` | Bind address. |
249
249
  | `--port <n>` | `7117` | TCP port to bind. |
250
250
  | `--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). Also available on [`dirsql query`](#dirsql-query). See [Keep the index across restarts](../howto/persist.md). |
@@ -14,17 +14,19 @@ with none given [no named tables](./cli.md#configless-mode) are defined (a
14
14
  `./.dirsql.toml` on disk is **not** auto-loaded). The [SDKs](./sdk.md) load a
15
15
  config via the `config` constructor parameter.
16
16
 
17
- **Path resolution.** Relative paths in the config (`[[dirsql.extension]]`
18
- `path`) resolve against the config file's parent
19
- directory. The **index root is not a config concern** — it is decided by the
20
- runner (the CLI's invocation directory, or an SDK's explicit root), never by
21
- the config file's location. See [`--config`](./cli.md#flags).
17
+ **Path resolution.** A path written in a config resolves against the config
18
+ file's parent directory: a `[[table]]` `glob` (see [anchoring](#glob-anchor)),
19
+ `ignore`, and `[[dirsql.extension]]` `path`. A config therefore works from any
20
+ working directory. The **index root is not a config concern** — it is decided
21
+ by the runner (the CLI's invocation directory, or an SDK's explicit root) and
22
+ governs only path-tables and programmatic tables. See
23
+ [`--config`](./cli.md#flags).
22
24
 
23
25
  ## `[dirsql]` keys
24
26
 
25
27
  | Key | Type | Default | Description |
26
28
  |---|---|---|---|
27
- | `ignore` | array of strings | `[]` | Glob patterns matched against root-relative paths, under the [one glob rule](#glob-rule): `*` matches one level, `**` any depth. Matched files are skipped entirely — excluded from the initial scan and from watch events. |
29
+ | `ignore` | array of strings | `[]` | Glob patterns matched against paths relative to the config file's directory, under the [one glob rule](#glob-rule): `*` matches one level, `**` any depth. They apply only to this config's `[[table]]` entries (not to path-tables, and not to another config's tables). Matched files are skipped entirely — excluded from the initial scan and from watch events. |
28
30
 
29
31
  There is no timeout key. `on-file` hook runs are unbounded; to bound one, wrap
30
32
  its command in `timeout(1)` (see [Command hooks](./hooks.md#bounding-a-hook)).
@@ -230,7 +232,7 @@ what its required `on-file` command emits — dirsql injects nothing (see
230
232
  |---|---|---|
231
233
  | `name` | yes | The table's SQL name — the name you query it by. Declared, never derived from `ddl`: dirsql does not read the DDL text. The `ddl` must create a table by this name; if it doesn't, loading fails. |
232
234
  | `ddl` | yes | A SQL batch, run verbatim — any number of statements. It must create a table called `name`; that table holds the file rows, and only the columns it declares are kept (keys the `on-file` command emits that are not declared are dropped). The rest of the batch is yours: indexes, virtual tables, triggers. See [Batch `ddl`](#batch-ddl). |
233
- | `glob` | yes | Glob pattern matched against root-relative paths, under the [one glob rule](#glob-rule): `*` matches one level, `**` any depth. Every table whose glob matches a file receives that file's rows — a file can populate multiple tables. A `{name}` segment is rewritten to `*` (it matches one path segment but captures nothing). |
235
+ | `glob` | yes | Glob pattern, [anchored](#glob-anchor) at the config file's directory, under the [one glob rule](#glob-rule): `*` matches one level, `**` any depth. Every table whose glob matches a file receives that file's rows — a file can populate multiple tables. A `{name}` segment is rewritten to `*` (it matches one path segment but captures nothing). |
234
236
  | `on-file` | **yes** | A command run once per table, with every matched file's absolute path appended as a trailing argument; its stdout (one JSON array of row objects) is the table's rows. Must be non-empty. A `[[table]]` with no `on-file` is a load error (see [parse errors](#parse-errors)). See [Command hooks](./hooks.md#on-file). |
235
237
  | `strict` | no (default `false`) | When `true`, rows whose keys do not exactly match the declared columns are rejected with an error: extra keys error, and every declared column must be supplied by the `on-file` output. When `false`, extra keys are dropped and missing columns become `NULL`. |
236
238
 
@@ -256,6 +258,22 @@ on-file = "uv run python extract_papers.py"
256
258
  strict = true
257
259
  ```
258
260
 
261
+ ### Glob anchor
262
+
263
+ A table's `glob` is matched beneath its **anchor**, never the index root:
264
+
265
+ | `glob` starts with | Anchor |
266
+ |---|---|
267
+ | nothing special, or `./` | the config file's directory |
268
+ | `/` (or a drive / UNC root) | the literal directory chain before the first glob character |
269
+ | `~/` | your home directory, then the literal chain |
270
+ | `../` | resolved against the config file's directory, then the literal chain |
271
+
272
+ So `glob = "projects/*/*.jsonl"` in `~/.claude/.dirsql.toml` indexes
273
+ `~/.claude/projects` from any working directory, and a shared config elsewhere
274
+ writes `glob = "~/.claude/projects/*/*.jsonl"`. A table's `path` and `dir`
275
+ columns, `{root}`, and `ignore` are all relative to its anchor.
276
+
259
277
  ### Batch `ddl`
260
278
 
261
279
  `ddl` is handed to SQLite whole, so a table declaration is not limited to one
@@ -346,7 +364,7 @@ dirsql -c ./.dirsql.toml -c ~/team/embeddings.toml -c ./local.toml
346
364
 
347
365
  The configs load and merge in **argv order**:
348
366
 
349
- - **`[[table]]`, `ignore`, `[[dirsql.extension]]`, and `[[dirsql.function]]`
367
+ - **`[[table]]`, `[[dirsql.extension]]`, and `[[dirsql.function]]`
350
368
  entries accumulate** across all configs, in order.
351
369
  - **Each config's `on-file` hooks and `[[dirsql.function]]` workers run from
352
370
  that config file's own directory** — so a relative command like
@@ -360,7 +378,8 @@ The configs load and merge in **argv order**:
360
378
  silent last-writer-wins.
361
379
 
362
380
  The index [root](./cli.md#flags) is the invocation directory regardless of where
363
- any config lives. With no `-c`, [no named tables](./cli.md#configless-mode) are
381
+ any config lives; each config's `[[table]]` globs anchor at that config's own
382
+ directory, and its `ignore` applies to its own tables only. With no `-c`, [no named tables](./cli.md#configless-mode) are
364
383
  defined (no `./.dirsql.toml` auto-discovery); a single `-c` behaves exactly as
365
384
  before.
366
385
 
@@ -42,7 +42,8 @@ relative paths in the command resolve predictably regardless of where
42
42
  `dirsql` was launched. A command named by the `--on-file` flag has no config
43
43
  file: it runs in the **index root**, the directory `dirsql query` was run in,
44
44
  which is also the directory a `./` path-table is relative to. In both forms
45
- `{root}` is the index root. The command inherits `dirsql`'s environment, so
45
+ `{root}` is where the table's glob is anchored: the index root for `--on-file`,
46
+ the [glob anchor](./config.md#glob-anchor) for a `[[table]]`. The command inherits `dirsql`'s environment, so
46
47
  tools like `uvx --with …` / `npx …` resolve their dependencies as usual.
47
48
 
48
49
  ### stdout protocol
@@ -143,7 +144,7 @@ the path or stat metadata emits it (it has the paths).
143
144
 
144
145
  | Placeholder | Value |
145
146
  |---|---|
146
- | `{root}` | The index root directory. Derive a root-relative path with `relpath(path, {root})`. |
147
+ | `{root}` | The directory the table's glob is anchored at (the index root for `--on-file`; the config file's directory, or the literal prefix of an absolute / `~/` glob, for a `[[table]]`). Derive an anchor-relative path with `relpath(path, {root})`. |
147
148
 
148
149
  The matched files' **absolute** paths are not placeholders: they are appended
149
150
  to the command as trailing arguments, after everything written in the
@@ -98,7 +98,9 @@ DirSQL::builder()
98
98
 
99
99
  Creates a SQLite index over a directory. The index root is the explicit
100
100
  `root` when given, else the **process cwd** — the `config` file's location
101
- never sets the root.
101
+ never sets the root. A config's `[[table]]` globs anchor at the config file's
102
+ own directory instead (see [glob anchor](./config.md#glob-anchor)); `root`
103
+ governs programmatic tables and path-tables.
102
104
 
103
105
  Constructing with **neither a `config` nor programmatic `tables`** defines
104
106
  **no named tables** — the same as the CLI with no
@@ -127,7 +129,9 @@ shortcut was removed in #603 — use
127
129
  entries are appended after any programmatic `tables`; its `ignore`
128
130
  patterns and `[[dirsql.extension]]` entries are appended likewise. The
129
131
  config file does **not** set the index root: with no explicit `root`, the
130
- index roots at the process cwd. **Multiple configs merge in order** on
132
+ index roots at the process cwd. Its `[[table]]` globs anchor at the config
133
+ file's directory (or at the literal prefix of an absolute / `~/` glob), not
134
+ at `root`; its `ignore` applies to its own tables only. **Multiple configs merge in order** on
131
135
  every SDK — **Python** `config` accepts a `str` or a `list[str]`, the
132
136
  **Rust** builder's `.config()` is repeatable (call it once per file), and
133
137
  **TypeScript** `config` accepts a `string` or a `string[]`; the configs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirsql",
3
- "version": "0.4.85",
3
+ "version": "0.4.87",
4
4
  "description": "Ephemeral SQL index over a local directory",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/thekevinscott/dirsql",
@@ -221,10 +221,10 @@
221
221
  ]
222
222
  },
223
223
  "optionalDependencies": {
224
- "@dirsql/lib-linux-x64-gnu": "0.4.85",
225
- "@dirsql/lib-linux-arm64-gnu": "0.4.85",
226
- "@dirsql/lib-darwin-x64": "0.4.85",
227
- "@dirsql/lib-darwin-arm64": "0.4.85",
228
- "@dirsql/lib-win32-x64-msvc": "0.4.85"
224
+ "@dirsql/lib-linux-x64-gnu": "0.4.87",
225
+ "@dirsql/lib-linux-arm64-gnu": "0.4.87",
226
+ "@dirsql/lib-darwin-x64": "0.4.87",
227
+ "@dirsql/lib-darwin-arm64": "0.4.87",
228
+ "@dirsql/lib-win32-x64-msvc": "0.4.87"
229
229
  }
230
230
  }