Skip to main content

Delphi Code

Offline semantic code search for agents. Delphi Code is a small Python CLI that indexes local source trees with a local embedding model and answers natural-language queries with JSON. It runs one command at a time, with no daemon, server, account, cloud embedding provider, or runtime downloads.

Quick start

uv tool install --python 3.12 --managed-python delphi-code
delphi-code setup
delphi-code index -p /absolute/path/to/project
delphi-code search 'where are user passwords checked?'

setup downloads and verifies the pinned embedding model once. After that, every command runs fully offline. Without -p, search looks through every indexed project.

Requirements

  • macOS 14 or later on arm64 (the tested target). Linux has not yet been verified; Windows is not supported by the current file locking implementation.
  • CPython 3.12 with SQLite loadable extensions. Some python.org macOS builds disable that feature; --managed-python makes uv use its own Python build, which supports it. doctor reports this explicitly.
  • CPU inference; no GPU is needed.

Installation

From PyPI, as in the quick start:

uv tool install --python 3.12 --managed-python delphi-code
delphi-code setup

From a checkout, with uv:

uv tool install --python 3.12 --managed-python /absolute/path/to/delphi-code
delphi-code setup

From a checkout, with the pinned dependency versions and a Python 3.12 build that supports SQLite extensions:

python3.12 -m venv .venv
.venv/bin/python -m pip install -r requirements-lock.txt
.venv/bin/python -m pip install --no-deps --no-build-isolation .
.venv/bin/delphi-code setup

requirements-lock.txt records the tested macOS environment, not a cross-platform lock.

Model setup

setup downloads the pinned all-MiniLM-L6-v2 revision in a separate process. It validates every file against bundled SHA-256 hashes and runs local embedding, SQLite, and native-storage diagnostics before moving the model into place.

  • Running setup again verifies and reuses valid assets.
  • Concurrent setup for the same destination fails clearly.
  • Failed downloads or diagnostics never leave a partial model behind; invalid existing models are preserved with recovery instructions.
  • setup --model /absolute/path or DELPHI_CODE_MODEL selects a different destination.

For an offline installation, install dependencies from a wheelhouse prepared for the target platform, then import a complete prepared MiniLM directory, including its license and model card:

delphi-code setup --from /absolute/path/to/all-MiniLM-L6-v2

setup provisions the pinned MiniLM model only. Other models can be used at runtime through --model or DELPHI_CODE_MODEL (see Models below). index, search, status, and doctor never download anything.

Commands

delphi-code doctor -p /path/to/project
delphi-code index -p /path/to/project
delphi-code search -p /path/to/project 'where are user passwords checked?'
delphi-code search -p /path/to/project 'parse configuration' --language python --path 'src/*' --limit 5
delphi-code status -p /path/to/project
  • index builds or incrementally updates a project's index.
  • search runs a natural-language query. Without -p, it searches every stored index.
  • status reports stored index state. It needs no model and does not rescan source files to detect staleness.
  • doctor checks the model, SQLite extensions, and native storage, then runs a real local embedding and vector distance calculation.
  • setup provisions the model (see above).

python -m delphi_code works as an alternative to the delphi-code executable.

Selecting a project

  • --project / -p accepts a path, resolved relative to the current working directory. The project root is explicit; it is not inferred from Git.
  • After a project has been indexed once, its folder name works too, for example delphi-code search -p myapp 'parse config'. A bare name selects the uniquely matching indexed project; duplicate names produce an error listing their paths. Use ./name or an absolute path to select a directory explicitly.
  • Without --project, search searches all stored indexes; other commands use the current directory.

Searching across projects

Cross-project search returns a single globally ranked list, with the full project path on each result. The query is embedded once, --limit applies to the combined list, and path/language filters apply within every index. All indexes must be readable, complete, and built with the selected model: a busy, broken, or incompatible index produces an error rather than silently partial results. Use -p to narrow the search when needed.

Output

Each command writes one JSON object to stdout with schema_version, ok, command, and either data or error. Progress and library diagnostics go to stderr; argument help is plain text.

{
  "command": "search",
  "ok": true,
  "schema_version": 1,
  "data": {
    "project": "/Users/me/src/delphi-code",
    "index_directory": "/Users/me/Library/Application Support/delphi-code/indexes/3a3565ee…",
    "query": "where is the model checksum verified?",
    "results": [
      {
        "path": "delphi_code/setup.py",
        "language": "python",
        "start_line": 17,
        "end_line": 31,
        "distance": 1.1042553186416626,
        "score": 0.3903100956258001,
        "text": "def verify_assets(root):\n    manifest = json.loads(…"
      }
    ]
  }
}

Search results contain project-relative paths, language, inclusive 1-based line ranges, the original chunk text, Euclidean distance, and cosine similarity score. Lower distance and higher score mean closer matches; scores are not probabilities. Equal distances use stable path/line/id ordering.

Exit code Meaning
0 Success, including a search with no matches
2 Invalid arguments or project
3 Missing or incompatible model or runtime assets
4 Missing, incomplete, or incompatible index
5 Busy index or operational failure

Indexing and filters

What gets indexed

  • Nested .gitignore and .delphi-codeignore files apply with Git-style patterns and negation; an ignored parent directory is not traversed. .delphi-codeignore follows .gitignore within each directory.
  • Repeated --ignore patterns add another exclusion layer.
  • Git's global ignore file and .git/info/exclude are not read.
  • Built-in exclusions: .git, .delphi-code, .venv, venv, node_modules, __pycache__, .models, and the selected model directory.
  • Symlinks, binary or non-UTF-8 files, blank files, and files over --max-bytes (default 1 MiB) are skipped.
  • Unknown languages are indexed as text.

Filters

Repeated --path globs are alternatives over project-relative POSIX paths (* can match /). Repeated --language values are alternatives using CocoIndex language names such as python, rust, and typescript. Path and language filters combine with AND.

  • On index, filters define the entire indexed set for that run, and previously indexed files outside it are removed. Running index without filters returns to the full selection.
  • On search, filters restrict results before ranking, so a matching result cannot be lost behind unfiltered top-k candidates.

Incremental updates

CocoIndex memoizes each file's content-dependent work and maintains the exported SQLite vec0 rows. Changed contents are detected even when timestamps are unchanged, and deleted or newly excluded files have their rows removed. Every candidate file is read on each index run, but unchanged files skip chunking and embedding. The selected file contents are held in memory during indexing.

The code splitter targets 900-byte chunks with overlap. Embeddings are normalized SentenceTransformers outputs computed on the CPU, with the same model configuration for indexing and queries. The model's token limit can truncate long chunks.

Search is an exact sqlite-vec distance scan over the filtered rows, not an approximate-nearest-neighbor index. That keeps results exact and suits small codebases.

Models

The default model is MiniLM: a small, general-purpose model that keeps the tool fast and light, not one tuned for code retrieval. Any local SentenceTransformers model can be used through --model /absolute/local/model or DELPHI_CODE_MODEL, provided that it:

  • uses only Transformer, Pooling, Normalize, and Dense modules;
  • stores its weights as safetensors (pickle weights and custom model code are not supported);
  • is trusted and stays unchanged while a command runs.

Models with asymmetric query/document instructions are not specially configured. Each index records a hash of the full model assets, so searching an index with different weights or configuration fails with a clear error instead of returning wrong results.

Storage

Models and indexes live outside the installation, so reinstalling or upgrading leaves them intact:

  • macOS: ~/Library/Application Support/delphi-code/
  • Linux: $XDG_DATA_HOME/delphi-code/, or ~/.local/share/delphi-code/

The default model is under models/all-MiniLM-L6-v2/ and indexes are under indexes/. DELPHI_CODE_INDEX_ROOT overrides the index location.

Each project has one index at indexes/<sha256 of the resolved project path>/, independent of the working directory. It holds CocoIndex's incremental state, the SQLite vector table, and a manifest recording the project path; command output includes this index_directory.

  • A file lock prevents reads during updates and concurrent writers.
  • An interrupted or failed update leaves the index marked ready: false, and search refuses it until indexing succeeds. There is no fallback to a last good snapshot.
  • Moving a project changes its index identity.
  • To switch model assets or rebuild incompatible state, move that index_directory aside and run index again.

Offline guarantees

Before any third-party import, the CLI disables CocoIndex usage tracking and Hugging Face telemetry, and sets the Hub and Transformers offline flags. Models load only from an existing local directory with local_files_only=True, trust_remote_code=False, and safetensors weights.

A Python audit hook also rejects Internet socket operations and DNS lookups. This is defense in depth, not OS isolation: it does not cover native extensions. For an OS-level boundary on macOS, run commands under a sandbox that denies networking:

/usr/bin/sandbox-exec -p '(version 1)(allow default)(deny network*)' \
  delphi-code index -p /path/to/project

Delphi Code needs read access to source and model files, write access to its user index directory, threads, SQLite extensions, and CocoIndex's LMDB memory maps. It needs no network access. Some stricter sandboxes deny CocoIndex's native storage initialization with EPERM; doctor probes for this and reports sandbox_storage_denied. The application never escalates its own permissions. doctor reports the Python guard only; it does not claim that an external OS sandbox is active.

Development

See CONTRIBUTING.md for running the tests and publishing releases.

License

Apache-2.0. See THIRD_PARTY_NOTICES.md for dependency and model provenance and redistribution notes. The package does not bundle dependencies or model weights; the model's asset hashes are recorded in MODEL_PROVENANCE.json.

Metadata

Release files for delphi-code 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for delphi-code 0.1.0
File Size Uploaded
delphi_code-0.1.0.tar.gz 29.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for delphi-code 0.1.0
File Interpreter ABI Platform
delphi_code-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 54.2 kB

Release files / delphi_code-0.1.0.tar.gz

Download URL delphi_code-0.1.0.tar.gz
Size 29.5 kB
Tags Source
SHA-256 checksum
How to use checksums
96b7d4fd55d4751604d54fe4a662a28d327ae9cd04502a675aea452b5f981141
BLAKE2b-256 checksum
How to use checksums
be765a0435b29281b3effff5d80a9b5409530932403d6fd02760237d53b18a8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / delphi_code-0.1.0-py3-none-any.whl

Download URL delphi_code-0.1.0-py3-none-any.whl
Size 24.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2e03cb0816af18da14a2990bd581fc9785600a5c6326e262a6897bbfc322d61
BLAKE2b-256 checksum
How to use checksums
52038098402b26c77049cd34f83350fe01244a08c50a8f60c78e0ed935670c7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release 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