trailhead

Command-line code indexing and semantic search tool. It parses source files into a property graph (modules, classes, functions, and their relationships) stored in SQLite, generates text embeddings with sentence-transformers, and exposes everything through a CLI and HTTP API.

  • Single CLI command: th
  • Text embeddings powered by sentence-transformers (models cached locally)
  • Polyglot code indexing via tree-sitter (Python built-in; 12 additional languages optional)
  • Property graph persisted in a single SQLite file with optional vector search
  • Warm-model FastAPI server keeps the embedding model loaded in memory
  • Background file watcher incrementally re-indexes on change
  • Interactive browser UI for querying and visualizing the code graph

Architecture

flowchart LR CLI[CLI: th index / serve / query] LI[LiveIndexer\nbackground file watcher] DB[(SQLite\nproperty graph + embeddings)] SRV[FastAPI Server\nwarm embedding model] UI[Browser UI] CLI -->|index| DB CLI -->|serve| SRV SRV --> LI LI -->|watches source tree, reindexes| DB SRV -->|reads/writes| DB SRV --> UI CLI -->|query| DB

th index builds the graph once. th serve starts the FastAPI server, which runs a LiveIndexer in the background to keep the graph fresh as source files change, and keeps the embedding model warm in memory across requests. th query and the HTTP API both read from the same SQLite file.

Where to start

License

trailhead is licensed under the MIT License. See the repository LICENSE file for details.