greplm-core
Core indexing and search engine for greplm: a fast, offline trigram code index with code intelligence built for LLM agents.
The index lives in a .greplm/ directory at the project root. Immutable, mmap-backed segments combine trigram FSTs, roaring posting lists, and symbol tables. Search filters candidates by trigram intersection, then verifies matches with the real literal/regex matcher.
Features
- Trigram content search — literal, regex, whole-word, with language and path filters
- Symbol extraction — tree-sitter parsing for Rust, Python, JavaScript, TypeScript/TSX, Go, Java, C, C++, C#, Ruby, PHP, Swift, and Dart
- Code intelligence — references, call graph (callers/callees/blast radius), typed go-to-definition, structural (AST) search
- Context packs — task-driven, token-budgeted code assembly ranked by relevance and call-graph centrality
- Git integration — blame, symbol history, changed-files-since-revision
- Incremental indexing — only re-indexes what changed; optional file watcher and warm daemon
- Fully offline — no network calls
Install
Add as a path or git dependency (the crate is not published separately on crates.io today; use the workspace or git URL):
[]
= { = "../greplm-core" }
# or
= { = "https://github.com/KhaledSMQ/greplm" }
Optional features:
= { = "../greplm-core", = ["semantic"] }
| Feature | Description |
|---|---|
semantic |
Offline semantic (vector) search with a trained Model2Vec embedder |
Quick start
use ;
use Greplm;
API overview
Greplm
The main entry point for a project and its index.
| Method | Description |
|---|---|
Greplm::open(root) |
Open (and lazily initialize) the index for a project root |
Greplm::discover(start) |
Walk up from start to find the nearest .greplm/ directory |
index(force) |
Build or refresh the index (incremental unless force) |
searcher() |
Open a Searcher over the current index |
status() |
Report segment count, document/symbol counts, last index time |
watch(debounce, on_change) |
Re-index incrementally on file changes |
compact() |
Merge segments and drop tombstoned documents |
clean() |
Remove the entire .greplm/ directory |
Searcher
Query interface over a loaded index. Key methods:
search— content searchsymbols— symbol lookup (exact, prefix, substring, fuzzy)references/references_resolved— text and structural referencescallers/callees/blast_radius— call graph navigationdefinition/references_of— typed go-to-definition at a positionstructural_search— tree-sitter query or$NAMEmeta-variable patternscontext_pack— token-budgeted task contextoutline/read_snippet— file structure and slicesblame/symbol_history/changed_since— git time-travelsummary— repository statistics
Other modules
| Module | Purpose |
|---|---|
config |
.greplm/config.toml parsing |
lang |
Language detection and tree-sitter wiring |
client / daemon / proto |
Warm-index daemon over a Unix socket |
semantic |
Optional vector search (semantic feature) |
savings |
Token-efficiency tracking |
Index layout
.greplm/
├── config.toml # project configuration
├── meta.bin # segment manifest and counts
├── cache/ # per-file hash cache for incremental indexing
├── segments/ # immutable mmap-backed index segments
└── savings.jsonl # token-savings log (optional)
Related crates
greplm-cli— command-line interface (greplm)greplm-mcp— MCP stdio server (greplm-mcp)
See the project docs for the full feature list, benchmarks, and agent setup.
License
MIT