Skip to main content

dirsql-plugin-embeddings

A first-party dirsql plugin that adds semantic search over a directory of documents -- Markdown, plain text, reStructuredText and PDFs. It is the worked implementation behind the Search documents by meaning how-to, swapping that guide's local model2vec model for any OpenAI-compatible /v1/embeddings endpoint.

uvx --with dirsql-plugin-embeddings dirsql

Deliberately minimal (v0.1): one embedding provider shape, one table, no chunking, no config surface beyond three environment variables.

How it works

The plugin ships a dirsql.toml fragment that dirsql discovers when the package is installed alongside it. The fragment declares:

  • the sqlite-vec extension, for vec_distance_cosine();
  • a documents table whose on-file hook embeds each **/*.{md,markdown,mdx,rst,txt,pdf} file into a TEXT embedding column;
  • a pre-query hook that embeds the incoming question and emits the nearest-neighbor SQL.

Both hooks are console scripts that call the same embedder.

Every matched extension except .pdf is read as UTF-8 text; a .pdf is read with pypdf, whose per-page extracted text is joined and embedded like any other document. The extension check is case-insensitive (.PDF is a PDF), though the glob above is not — globset matches case-sensitively, so an uppercase-suffixed file needs its own glob entry to be picked up at all.

The glob is an allowlist rather than **/* on cost, not correctness. Every matched file costs a hook subprocess, and every file the plugin can decode costs a billed embedding call — so pointing **/* at a tree containing node_modules or .git makes for a slow and expensive scan. The list is what is worth embedding; widening it trades money for recall.

A file the plugin cannot read is skipped, not fatal. The hook exits non-zero, dirsql names the file on stderr and carries on indexing the rest, and the run exits 23 — "completed, some files skipped". From the SDK the same information is on scan_failures() / scanFailures(). A scanned, image-only PDF is not a failure at all: pypdf yields no text, and the file is indexed with an empty text, exactly like an empty .md.

Configuration

The embedder reads three environment variables (point them at any hosted or self-managed OpenAI-compatible inference server):

Variable Meaning
DIRSQL_EMBEDDINGS_BASE_URL Base URL; /v1/embeddings is appended.
DIRSQL_EMBEDDINGS_MODEL Model name sent in the request.
DIRSQL_EMBEDDINGS_API_KEY Bearer token for Authorization.

Console scripts

Script Hook Input Output
dirsql-embeddings-on-file on-file a file's absolute path (argv[1]), text or PDF one-line JSON row array with path, text, embedding
dirsql-embeddings-pre-query pre-query a raw request body (argv[1]) nearest-neighbor SQL over documents

pre-query accepts both a verbatim server body ({"q": ...}) and the CLI query subcommand's {"sql": <arg>} wrapper, so dirsql query '{"q": ...}' and a real POST /query both work.

Tests

Three tiers, per the dirsql testing conventions:

  • unit (colocated, mocked seams) — src/dirsql_plugin_embeddings/*_test.py
  • integration (tests/integration/) — each console script as a real subprocess against a local stub /v1/embeddings server
  • e2e (tests/e2e/) — the full loop through the real launcher + dirsql binary + sqlite-vec, nothing mocked but the embedding endpoint

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dirsql_plugin_embeddings-0.1.10.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dirsql_plugin_embeddings-0.1.10-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file dirsql_plugin_embeddings-0.1.10.tar.gz.

File metadata

File hashes

Hashes for dirsql_plugin_embeddings-0.1.10.tar.gz
Algorithm Hash digest
SHA256 e72745b2d60bc8a6be31a456ffdb282d0745c67e414d8b21e63b810e1da06145
MD5 7448f70d0b0766e18227d780c71b5671
BLAKE2b-256 1dbc3c32eb657a568e50ad3215c81ef67a49e25f2834d934922a8ecec792cd1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for dirsql_plugin_embeddings-0.1.10.tar.gz:

Publisher: release.yml on thekevinscott/dirsql

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dirsql_plugin_embeddings-0.1.10-py3-none-any.whl.

File metadata

File hashes

Hashes for dirsql_plugin_embeddings-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 a03b152e75d4a583bf30efc3483d6f5fbecfee1718eb5811f6e010fc3976b9cb
MD5 df9a8dc870c691e23927cb669348c866
BLAKE2b-256 a1320197e8854b0d478412bddcd4045ce9e09ea69479067119a455c3d736df10

See more details on using hashes here.

Provenance

The following attestation bundles were made for dirsql_plugin_embeddings-0.1.10-py3-none-any.whl:

Publisher: release.yml on thekevinscott/dirsql

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

This release

0.1.10 This release

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page