treeseek
v2.1.0
Published
Semantic code search CLI with auto-watching daemon. Uses Ollama + LanceDB — 100% offline and private.
Readme
treeseek
CLI com daemon watcher para busca semântica de código. Indexa codebases com AST-aware chunking, gera embeddings via Ollama e armazena em LanceDB local — 100% offline, gratuito e privado.
Prerequisites
- Node.js 20 or 22 (do NOT use Node 24 — incompatible with tree-sitter)
- Ollama running locally: https://ollama.com
ollama serve - Embedding model pulled:
ollama pull nomic-embed-text
Installation
npm install -g treeseekCommands
treeseek index <path> # Index codebase (full or incremental)
treeseek search <query> <path> # Semantic search
treeseek status <path> # Check indexing status
treeseek clear <path> # Remove index
treeseek watch <path> # Start watching and auto-reindexing
treeseek stop [path] # Stop watcher (--all for all projects)
treeseek list # List watched projectsAll commands support --json for machine-readable output.
Examples
# Index and start watching (daemon in background)
treeseek watch /my-project
# Search code semantically
treeseek search "authentication JWT" /my-project
treeseek search "database connection" /my-project --top-k 5 --json
# Check status
treeseek status /my-project
# Stop watching
treeseek stop /my-projectHow It Works
- AST-Aware Chunking — Tree-sitter parses code in 9 languages (TS, JS, Python, Java, Go, Rust, C++, C#, Scala), splitting by functions, classes and methods
- Ollama Embeddings — Generates vectors locally with
nomic-embed-text(768 dim). No external APIs - LanceDB — Stores vectors locally in
~/.codebase-indexer/. Cosine similarity search - Merkle DAG — Incremental indexing detects changes via SHA-256 hashes. Only reindexes modified files
- Daemon Watcher —
treeseek watchmonitors file changes with 10s debounce and auto-reindexes
Environment Variables
| Variable | Default | Description |
|---|---|---|
| OLLAMA_HOST | http://localhost:11434 | Ollama API endpoint |
| EMBED_MODEL | nomic-embed-text | Ollama embedding model name |
| LANCEDB_PATH | ~/.codebase-indexer | Base directory for LanceDB storage |
| EMBEDDING_BATCH_SIZE | 100 | Batch size for embedding generation |
| CUSTOM_EXTENSIONS | — | Additional file extensions (comma-separated) |
| CUSTOM_IGNORE_PATTERNS | — | Additional ignore patterns (comma-separated) |
Supported Languages
TypeScript, JavaScript, Python, Java, Go, Rust, C, C++, C#, Ruby, PHP, Swift, Kotlin, Scala, Markdown, Jupyter Notebooks.
Architecture
Codebase → Tree-sitter AST → AST Chunker → Ollama Embeddings → LanceDB
↓
treeseek search (CLI)
↓
Cosine Similarity → ResultsDaemon Watcher
treeseek watch <path> starts a background process that:
- Performs initial indexing if not already indexed
- Monitors file changes with
fs.watchFile(10s debounce) - Auto-reindexes only modified/added files
- Manages PIDs in
~/.treeseek/pids/ - Logs to
~/.treeseek/logs/
treeseek watch /my-project # Start daemon
treeseek list # List watched projects
treeseek stop /my-project # Stop specific project
treeseek stop --all # Stop all watchers