zvec-grep (zg) is a Rust CLI that puts ripgrep-style search, BM25 full-text search and vector search behind one command. It indexes a workspace into .zvec-grep/, runs locally, and ships an MCP server and agent installers so Claude Code, Codex or OpenCode can call it instead of looping on grep and cat.
Why I starred it
Agents burn most of their tokens finding the right file. Plain grep needs the right word. Pure embedding search loses exact identifiers. I wanted to see how someone combines both without bolting two tools together. The repo is from the zvec team (Alibaba's vector database), so it also doubles as the reference client for their storage engine.
How it works
The workspace is rust/ with twelve crates. ARCHITECTURE.md is unusually direct about the boundaries: zg-engine holds retrieval, indexing, extraction and storage, zg-daemon keeps a resident process with watchers and background jobs, zg-transport-mcp owns tool schemas. The rule I liked: "Shared abstractions require multiple real implementations." No generic command bus.
The interesting part is crates/zg-engine/src/pipelines/indexed_search/pipeline.rs. Every query becomes a list of routes, each either FTS or vector. Recall is iterative, not fixed:
const RRF_K: f64 = 60.0;
const RECALL_INITIAL_DEPTH: usize = 200;
const RECALL_MAX_DEPTH: usize = 2_000;
const RECALL_GROWTH_FACTOR: usize = 2;
// pipeline.rs:406, inside collect_adaptive_recall
loop {
let mut saturated = false;
for route in &recall_routes {
let hits = match route.route.mode { /* fts or vector */ };
saturated |= hits.len() >= depth;
add_recall_hits(candidates, &hits, route)?;
}
if candidates.len() >= target || !saturated || depth >= RECALL_MAX_DEPTH {
return Ok(());
}
depth = (depth * RECALL_GROWTH_FACTOR).min(RECALL_MAX_DEPTH);
}
It starts at 200 hits per route. If the candidate pool is below limit * 5 (minimum 50) and a route came back full, it doubles the depth up to 2,000. That matters because candidates are entities, not rows: several chunks of one function collapse into one candidate, so a fixed top-k can leave you with three results after dedup.
Fusion is textbook reciprocal rank fusion, with one twist in the tie-breaker:
candidate.score = candidate.recall.iter()
.filter_map(|trace| trace.rank)
.map(|rank| 1.0 / (RRF_K + rank_as_f64(rank)))
.sum();
...
.then_with(|| right.matched_symbol_recall.cmp(&left.matched_symbol_recall))
.then_with(|| left.id.as_str().cmp(right.id.as_str()))
The final sort is deterministic down to the entity id. The symbol twist is build_recall_routes: with prefer_symbol, it extracts identifier-looking tokens from the query and adds an extra FTS route filtered to symbol_names, suffixed .prefer-symbol. Symbol hits only break RRF ties; they never outrank a better fused score. There is a test named prefer_symbol_breaks_only_rrf_ties_in_mixed_results that pins exactly that.
The second thing I did not expect is a call graph. zg --callers save and --callees storage::flush come from a tree-sitter based extractor (extraction/graph/collector.rs, around 4,800 lines) and a resolver (pipelines/indexing/graph_resolver.rs, around 5,000) covering C, C++, Go, Java, PHP, JS/TS, Python and Rust. Recent commits show how deep that rabbit hole goes. Commit #440 fixes bare-call binding in Rust modules: a fn flush inside mod storage calling save() was bound to the file-level save. The fix walks nested function scopes, respects type versus value namespace, and tracks use super::* globs. The commit message is a long list of review rounds, each one a case where the resolver claimed an edge it could not prove. They prefer leaving a call "pending" over guessing. That is the right call for something an agent will trust.
Extraction is also structure-aware: Markdown is sectioned by headings, PDFs go through LiteParse with page-aware results, code is indexed with symbols, signatures and breadcrumbs. Embedding models run locally via llama.cpp or ONNX (zg-llama-native, zg-ort-native), with HTTP embedding endpoints configurable at runtime.
Using it
npm install -g @zvec/zvec-grep --allow-scripts=@zvec/zvec-grep
zg --index --embedding local/potion-retrieval-32m
zg --preview detail "An unseen creature left a few marks. What did the detective infer?" --limit 3
zg --callers save
zg --install --target opencode --yes
Repeated --hybrid, --fts and --vector flags run separate queries, and results are grouped under labels like -- query 2/2: timeout --. The agent path writes the integration config so the model picks zg on its own, without the prompt naming the tool. Results carry file and line ranges, which is what lets agents cite evidence.
I did not run it. I read the source from a shallow clone and did not install or execute anything, so the benchmark numbers below are the maintainers' claims, not mine.
Rough edges
- It is big: roughly 195k lines of Rust across about 1,260 tracked files, and around 2,100 test functions. The test suite is a strength, but the maintenance surface is large for a search tool.
- Files like
pipeline.rs(5.1k lines),graph_resolver.rs(5k) andcollector.rs(4.8k) are hard to read in one sitting. - The benchmarks (SWE-QA-Bench with Claude Code, BrowseComp-Plus with Codex) are the project's own, and the README says results vary by model and run. It also admits zg helps most when the target location is unknown, such as call-chain and architectural questions. For "find this exact string" ripgrep is still enough.
- The repo is from July 2026 and moves fast: the last 20 commits span about nine days, several touching Rust resolver semantics. Expect index format and flag churn. 108 open issues at the time I looked.
- Images are skipped during indexing, and the install uses a postinstall script, hence the
--allow-scriptsflag.
Bottom line
If you run coding agents on mid-size or large repos and are tired of watching them grep their way around, zg is the most carefully engineered attempt at hybrid local retrieval I have read. For a small project or pure exact-match work, ripgrep wins on simplicity.
