Sandbox
@zvec-ai/zvec-grep

Local workspace search for agents and the terminal

zg gives you one local search layer for code, docs, and structured data. It ranks results with lexical and semantic retrieval, keeps the index on your machine, and can be used directly or through an agent via MCP and CLI integration.

3,360 stars192 forksTypeScriptUpdated 6d ago
Who it's for

Builders who want Claude Code, Codex, or a CLI to search their local workspace with the same index.

What it delivers

You can find the right local evidence faster, with fewer tool calls and less re-explaining to your agent.

What it does

Hybrid search

Combines ripgrep, BM25, and vector search so you can search by exact text or by meaning.

Local-first indexing

Stores the index under `.zvec-grep/` in the project root and keeps files and local models on your machine by default.

Agent integration

Exposes search through MCP and agent setup commands so Codex, Claude Code, and other agents can use it.

Direct CLI search

Lets you run `zg query --human ...` to search your workspace without an agent.

Workspace management

Provides index, status, server, and debug commands for keeping a workspace searchable and diagnosing failures.

How to get it

  1. 1With OpenCode configured
    zg install --target opencode --yes
    opencode models
    opencode run --model opencode/nemotron-3-ultra-free \
      "An unseen creature left a few marks. What did the detective infer? Cite local evidence."
  2. 2Search the same bookshelf directly, without an agent
    zg query --human "An unseen creature left a few marks. What did the detective infer?" --limit 3

README

English | 中文

zg logozg logo

Know the words—or don’t. Just zg.

The local-first search layer for humans and agents.

npm version CI Apache 2.0 license Node.js 22 or newer

zvec-ai/zvec-grep | Trendshift TypeScript daily ranking zvec-ai/zvec-grep | Trendshift all-language daily ranking

🎬 Tour | 💫 Features | 🚀 Try it yourself | 📚 Docs | 📊 Benchmarks | 🤝 Community

zg (zvec-grep), powered by zvec, unifies ripgrep, BM25, and vector search behind one local-first interface. Use it directly from the terminal, or let your agent use it for you.

🎬 See it in action

Install the agent integration, index a workspace, and let the agent search it with zvec-grepInstall the agent integration, index a workspace, and let the agent search it with zvec-grep

💫 Why zg?

  • Ready for humans and agents — install once, index once, then use the same workspace from the CLI or your agent on macOS, Linux, and Windows.
  • Search beyond keywords — discover by meaning, rank by relevance, then verify with exact text or regex when needed.
  • Multi-format search — search source code, documents, and structured data while preserving useful structure and source locations.
  • Less searching, less context — ranked, source-linked results surface the right evidence with fewer tool calls, fewer tokens, and less noise.
  • Local by default — files, indexes, and local models stay on your machine; remote embeddings receive data only with your permission.

🚀 Try it yourself

1. Set up a sample bookshelf

# Requires Node.js 22 or newer.
npm install -g @zvec/zvec-grep

mkdir zg-mystery && cd zg-mystery
curl --retry 3 --retry-all-errors --progress-bar -fL \
  -o alice-in-wonderland.txt https://raw.githubusercontent.com/GITenberg/Alice-s-Adventures-in-Wonderland_11/master/11.txt \
  -o sherlock-holmes.txt https://raw.githubusercontent.com/GITenberg/The-Memoirs-of-Sherlock-Holmes_834/master/834.txt

zg index --embedding local/potion-retrieval-32m

[!NOTE] The index is stored in .zvec-grep/ under the indexed project root.

[!TIP] If zg index or zg query fails, rerun the same command with --debug for diagnostics (supported in both direct and server modes). zg status --mode direct --debug reports per-file failures stored in an existing index; rerun a failed direct command to diagnose command-level fatal errors. Use zg status --mode server --debug to inspect recorded server indexing errors. For server connection failures, check zg server status and the server logs.

2. Choose how to search

For agents: ask with OpenCode

With OpenCode configured:

zg install --target opencode --yes
opencode models
opencode run --model opencode/nemotron-3-ultra-free \
  "An unseen creature left a few marks. What did the detective infer? Cite local evidence."

Free model availability can change. Check opencode models and replace the example model with one that is currently available in your environment.

OpenCode chooses zg on its own—the prompt does not name a tool.

See the full agent run and answer
⚙ zvec_grep_zvec_grep_search {"root":".../zg-mystery","query":"An unseen creature left a few marks. What did the detective infer?","fts":["marks","unseen creature","inferred","detective"],"fuse":true}
→ Read sherlock-holmes.txt [offset=5440, limit=120]

Answer:
The detective is Sherlock Holmes in *The Adventure of the Crooked Man*.
From the animal's foot-marks, he inferred:

- It was not a dog, cat, monkey, or other familiar creature: its print had
  five foot-pads, long nails, and was nearly as large as a dessert-spoon
  (sherlock-holmes.txt:5479-5486).
- It had a long body and very short legs: nearly two feet long, but with a
  stride of only about three inches (sherlock-holmes.txt:5497-5502).
- It was carnivorous because it climbed the curtain toward a canary's cage
  (sherlock-holmes.txt:5509-5510).
- It was probably from the weasel or stoat tribe, though unusually large
  (sherlock-holmes.txt:5514-5516).

Holmes also inferred that a man entered through the window with it and later
left with the key (sherlock-holmes.txt:5464-5470, 5527-5528).

For humans: search directly

Search the same bookshelf directly, without an agent:

zg query --human "An unseen creature left a few marks. What did the detective infer?" --limit 3

zg returns the relevant passages from sherlock-holmes.txt, ranked ahead of alice-in-wonderland.txt.

📊 Benchmarks

Each benchmark uses paired A/B runs with tasks, agent/model, prompt, environment, and limits held constant; only zg access and usage guidance differ.

See the benchmark documentation for full results and reproduction details.

1. Cross-Domain Agent Benchmark

SWE-QA-Bench uses Claude Code with Claude Opus 5 at high reasoning effort; BrowseComp-Plus uses Codex gpt-5.6-sol at medium reasoning effort. Both zg profiles use Qwen3.7 Text Embedding.

Overall zg benchmark results for Coding and general text retrieval, comparing answer quality, input tokens, tool calls, and agent time against BaselineOverall zg benchmark results for Coding and general text retrieval, comparing answer quality, input tokens, tool calls, and agent time against Baseline

  • Why it helps: semantic discovery narrows the search space, ranked lexical retrieval anchors exact identifiers, and compact evidence reduces broad scans, repeated tool calls, and model context.
  • Why it generalizes: the same retrieval loop works across domains—code is indexed with symbols, signatures, and breadcrumbs, while prose is retrieved as focused sections and chunks.

2. Real-World Case Studies

Baseline to zg comparison across three repository-comprehension tasks: Judge score, input tokens, tool calls, and wall timeBaseline to zg comparison across three repository-comprehension tasks: Judge score, input tokens, tool calls, and wall time
  • Pylint — Python static analysis: the task asks how AST node handling separates annotated and non-annotated attribute initialization. Symbol-aware retrieval is useful because the architectural entry point is not known in advance.
  • Matplotlib — plotting and rendering: the task traces FontInfo and font selection through multiple math-text rendering stages. Ranked semantic and lexical evidence helps reconstruct the cross-file data and control flow.
  • Django — web framework: the task connects username uniqueness, ORM transactions, and formset bulk operations. Compact ranked evidence brings the distributed design rationale together.
Repository questions
RepositoryQuestion typeQuestion
pylint-dev/pylintWhat
Architecture exploration
What is the architectural pattern that distinguishes type-annotated from non-annotated instance attribute initialization using AST node type separation?
matplotlib/matplotlibWhere
Data / Control-flow
Where does the FontInfo NamedTuple propagate font metrics and glyph data through the mathematical text rendering pipeline, and what control flow determines whether the postscript_name or the FT2Font object is used at different stages of character rendering?
django/djangoWhy
Design rationale
Why does the User model's unique constraint on the username field interact with Django's ORM transaction handling, and what cascading effects would occur if this constraint were removed on an existing database with formset-based bulk operations?

zg works best when evidence spans files or modules and the target location is unknown, especially for call-chain, data-flow, and architectural questions. Since agents decide when and how to use it, results vary by model and run; repeated-run averages are more reliable.

📚 Documentation

GuideWhat you can do
Agent integrationsConnect zg to Codex, Claude Code, Qwen Code, Qoder, Cursor, or OpenCode and verify that it works.
CLI guideSearch, index, and manage your local workspaces from the terminal.
MCP guideUnderstand which zg tools your agent can use and how access is secured.
Retrieval pipelineChoose what to index, keep it fresh, and get better search results.
ArchitectureSee how zg handles your query and where your data stays.
Server and execution modesChoose between one-off commands and a long-running local server.
Embedding modelsPick the right model for speed, search quality, privacy, and your hardware.
RoadmapSee what is coming next and help shape zg's priorities.

🤝 Join Our Community

💬 DingTalk📱 WeChat🎮 DiscordX (Twitter)
DingTalk QR CodeWeChat QR CodeDiscordX (formerly Twitter) Follow
Scan to joinScan to joinClick to joinClick to follow

❤️ Contributing

Community contributions are always welcome—bug fixes, features, and documentation improvements all help make zvec-grep better.

Check out our Contributing Guide to get started!

Files in the repo

Repository payload15 top-level entries
  • .github
  • benchmarks
  • docs
  • src
  • test
  • .gitignore
  • .prettierignore
  • CONTRIBUTING.md
  • eslint.config.js
  • LICENSE
  • package-lock.json
  • package.json
  • README_CN.md
  • README.md
  • tsconfig.json

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More tools

JuliusBrussee/
caveman

🪨 why use many token when few token do trick — Claude Code skill that cuts 65% of tokens by talking like caveman

105k
1 add
MemPalace/
mempalace

The best-benchmarked open-source AI memory system. And it's free.

59k
stablyai/
orca

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

66k

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

132k

Never stop coding. Free MIT AI gateway: one endpoint, 352 providers (150+ free), 1200+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 550+ contributors

64k
headroomlabs-ai/
headroom

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

71k