{"id":"53a40ff5-afe7-4019-9473-89904c080acb","slug":"zvec-grep","kind":"mcp","name":"zvec-grep","summary":"Local-first search across your workspace, built for humans and AI agents.","owner":"zvec-ai","repoUrl":"https://github.com/zvec-ai/zvec-grep","license":"Apache-2.0","licenseTier":"permissive","trust":"community","stars":4104,"match":null,"fewStars":false,"format":"mcp","createdAt":"2026-07-10T02:58:07.000Z","addedAt":"2026-10-14T05:36:15.040Z","logoUrl":"https://avatars.githubusercontent.com/u/254627891?v=4","linkOnly":false,"collection":null,"skillPath":null,"categories":["search","developer-tools"],"tags":["ai-agents","bm25","cli","code-search","full-text-search","local-first","ripgrep","semantic-search"],"runtime":"node","local":true,"cloudCapable":false,"cloudCapability":"unknown","cloudReadyOnPlatform":false,"needsApiKey":false,"reviewed":false,"syncedAt":"2026-10-17T05:38:25.392Z","sample":false,"url":"https://conduits.dev/tools/zvec-grep","language":"Rust","transports":["stdio"],"install":{"npm":"@zvec/zvec-grep"},"requirements":{"env":[],"upstreamMayCharge":false},"tools":null,"readme":"<p align=\"right\">\n  English | <a href=\"./README_CN.md\">中文</a>\n</p>\n\n<div align=\"center\">\n  <picture>\n    <source media=\"(prefers-color-scheme: dark)\" srcset=\"./.github/assets/zg-logo-dark.svg\">\n    <img src=\"./.github/assets/zg-logo.svg\" width=\"150\" alt=\"zg logo\" />\n  </picture>\n  <p><strong>Know the words—or don’t. Just zg.</strong></p>\n  <p>The local-first search layer for humans and agents.</p>\n\n  <p>\n    <a href=\"https://www.npmjs.com/package/@zvec/zvec-grep\"><img src=\"https://img.shields.io/npm/v/@zvec/zvec-grep.svg\" alt=\"npm version\" /></a>\n    <a href=\"https://github.com/zvec-ai/zvec-grep/actions/workflows/ci.yml\"><img src=\"https://github.com/zvec-ai/zvec-grep/actions/workflows/ci.yml/badge.svg\" alt=\"CI\" /></a>\n    <a href=\"./LICENSE\"><img src=\"https://img.shields.io/badge/license-Apache%202.0-blue.svg\" alt=\"Apache 2.0 license\" /></a>\n    <img src=\"https://img.shields.io/badge/node-%3E%3D22-blue.svg\" alt=\"Node.js 22 or newer\" />\n  </p>\n\n  <p>\n    <a href=\"https://trendshift.io/repositories/200612?utm_source=trendshift-badge&amp;utm_medium=badge&amp;utm_campaign=badge-trendshift-200612\" target=\"_blank\" rel=\"noopener noreferrer\"><img src=\"https://trendshift.io/api/badge/trendshift/repositories/200612/daily?language=TypeScript\" alt=\"zvec-ai/zvec-grep | Trendshift TypeScript daily ranking\" width=\"250\" height=\"55\" /></a>\n    <a href=\"https://trendshift.io/repositories/200612?utm_source=trendshift-badge&amp;utm_medium=badge&amp;utm_campaign=badge-trendshift-200612\" target=\"_blank\" rel=\"noopener noreferrer\"><img src=\"https://trendshift.io/api/badge/trendshift/repositories/200612/daily\" alt=\"zvec-ai/zvec-grep | Trendshift all-language daily ranking\" width=\"250\" height=\"55\" /></a>\n  </p>\n\n  <p>\n    <a href=\"#tour\">🎬 <strong>Tour</strong></a> |\n    <a href=\"#features\">💫 <strong>Features</strong></a> |\n    <a href=\"#try-it-yourself\">🚀 <strong>Try it yourself</strong></a> |\n    <a href=\"./docs/README.md\">📚 <strong>Docs</strong></a> |\n    <a href=\"#benchmarks\">📊 <strong>Benchmarks</strong></a> |\n    <a href=\"#community\">🤝 <strong>Community</strong></a>\n  </p>\n</div>\n\n**zg** (**z**vec-**g**rep), powered by [zvec](https://github.com/alibaba/zvec),\nunifies ripgrep, BM25, and vector search behind\n[one local-first interface](./docs/05-architecture.md). Use it directly from the\nterminal, or let your agent use it for you.\n\nThis README and the [documentation](./docs/README.md) describe the TypeScript /\nNode.js implementation. The Rust implementation is developed separately in\n[`rust/`](./rust/README.md).\n\n<a id=\"tour\"></a>\n\n## 🎬 See it in action\n\n<div align=\"center\">\n  <picture>\n    <source media=\"(prefers-color-scheme: dark)\" srcset=\"./.github/assets/zvec-grep-tour-dark.gif\">\n    <img src=\"./.github/assets/zvec-grep-tour.gif\" width=\"1000\" alt=\"Install the agent integration, index a workspace, and let the agent search it with zvec-grep\" />\n  </picture>\n</div>\n\n<a id=\"features\"></a>\n\n## 💫 Why zg?\n\n- **Ready for humans and agents** — install once, index once, then use the same\n  workspace from the CLI or your agent on macOS, Linux, and Windows.\n- **Search beyond keywords** — discover by meaning, rank by relevance, then\n  verify with exact text or regex when needed.\n- **Multi-format search** — search source code, documents, and structured data\n  while preserving useful structure and source locations.\n- **Less searching, less context** — ranked, source-linked results surface the\n  right evidence with fewer tool calls, fewer tokens, and less noise.\n- **Local by default** — files, indexes, and local models stay on your machine;\n  remote embeddings receive data only with your permission.\n\n<a id=\"try-it-yourself\"></a>\n\n## 🚀 Try it yourself\n\n### 1. Set up a sample bookshelf\n\n```bash\n# Requires Node.js 22 or newer.\nnpm install -g @zvec/zvec-grep\n\nmkdir zg-mystery && cd zg-mystery\ncurl --retry 3 --retry-all-errors --progress-bar -fL \\\n  -o alice-in-wonderland.txt https://raw.githubusercontent.com/GITenberg/Alice-s-Adventures-in-Wonderland_11/master/11.txt \\\n  -o sherlock-holmes.txt https://raw.githubusercontent.com/GITenberg/The-Memoirs-of-Sherlock-Holmes_834/master/834.txt\n\nzg index --embedding local/potion-retrieval-32m\n```\n\n> [!NOTE]\n> The index is stored in `.zvec-grep/` under the indexed project root.\n\n> [!TIP]\n> If `zg index` or `zg query` fails, rerun the same command with `--debug`\n> for diagnostics (supported in both direct and server modes).\n> `zg status --mode direct --debug` reports per-file failures stored in an\n> existing index; rerun a failed direct command to diagnose command-level\n> fatal errors. Use\n> `zg status --mode server --debug` to inspect recorded server indexing errors.\n> For server connection failures, check `zg server status` and the\n> [server logs](./docs/06-server.md#logs-and-state).\n\n### 2. Choose how to search\n\n#### For agents: ask with OpenCode\n\nWith [OpenCode](https://opencode.ai/) configured:\n\n```bash\nzg install --target opencode --yes\nopencode models\nopencode run --model opencode/nemotron-3-ultra-free \\\n  \"An unseen creature left a few marks. What did the detective infer? Cite local evidence.\"\n```\n\nFree model availability can change. Check `opencode models` and replace the\nexample model with one that is currently available in your environment.\n\nOpenCode chooses zg on its own—the prompt does not name a tool.\n\n<details>\n<summary><strong>See the full agent run and answer</strong></summary>\n\n```text\n⚙ 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}\n→ Read sherlock-holmes.txt [offset=5440, limit=120]\n\nAnswer:\nThe detective is Sherlock Holmes in *The Adventure of the Crooked Man*.\nFrom the animal's foot-marks, he inferred:\n\n- It was not a dog, cat, monkey, or other familiar creature: its print had\n  five foot-pads, long nails, and was nearly as large as a dessert-spoon\n  (sherlock-holmes.txt:5479-5486).\n- It had a long body and very short legs: nearly two feet long, but with a\n  stride of only about three inches (sherlock-holmes.txt:5497-5502).\n- It was carnivorous because it climbed the curtain toward a canary's cage\n  (sherlock-holmes.txt:5509-5510).\n- It was probably from the weasel or stoat tribe, though unusually large\n  (sherlock-holmes.txt:5514-5516).\n\nHolmes also inferred that a man entered through the window with it and later\nleft with the key (sherlock-holmes.txt:5464-5470, 5527-5528).\n```\n\n</details>\n\n#### For humans: search directly\n\nSearch the same bookshelf directly, without an agent:\n\n```bash\nzg query --human \"An unseen creature left a few marks. What did the detective infer?\" --limit 3\n```\n\nzg returns the relevant passages from `sherlock-holmes.txt`, ranked ahead of\n`alice-in-wonderland.txt`.\n\n### Index embedding concurrency and GPU errors\n\n`zg --index --index-embedding-concurrency <n>` and\n`ZVEC_GREP_INDEX_EMBEDDING_CONCURRENCY` control embedding concurrency while\nbuilding or updating an index, for both local and remote models. The environment\nvariable also applies to automatic indexing and refresh. These controls do not\nchange query-vector inference. The CLI option is accepted only with `--index`.\n\nFor llama.cpp, the limit controls contexts per indexing model instance. For\nTransformers.js, it controls calls in flight on one cached pipeline and does not\nguarantee simultaneous native/GPU execution. Both cap positive integer values\nat **8**. For Potion/model2vec, it controls concurrent embedding batches without\nthat cap; the default is **2** and the CPU worker pool has its own capacity limit.\nFor remote models, both controls set the maximum concurrent batches without the\ncap of 8. Existing adaptive scheduling and its defaults remain unchanged; it may\nreduce concurrency after rate limits or retryable failures.\n\nThe priority is the explicit CLI/API index option, then the index environment\nvariable, then `ZVEC_GREP_LLAMA_CONTEXT_PARALLELISM` (llama.cpp indexing only),\nthen the automatic default.\n\nFor llama.cpp and Transformers.js, CPU execution or a runtime without a VRAM\nquery uses 1 unless overridden. Transformers.js currently has no VRAM query, so\nits automatic limit is 1. When a GPU runtime provides free VRAM, the limit is\n`floor(freeVRAM × 0.25 / 150 MiB)`, clamped to 1–8; a failed or invalid VRAM\nquery uses 2. This retains the existing 150 MiB heuristic, which is not a\nguarantee that a model will fit in memory.\n\nFor CUDA errors, memory exhaustion, or native crashes, try a limit of 1 and\nretry the index. These examples run directly so the new environment takes\neffect immediately:\n\n```bash\nexport ZVEC_GREP_INDEX_EMBEDDING_CONCURRENCY=1\nzg --index --mode direct\n```\n\nWindows PowerShell:\n\n```powershell\n$env:ZVEC_GREP_INDEX_EMBEDDING_CONCURRENCY = \"1\"\nzg --index --mode direct\n```\n\nAn explicit CLI option overrides the environment for that index operation,\nincluding when using the daemon; no daemon restart is needed for the CLI option:\n\n```bash\nexport ZVEC_GREP_INDEX_EMBEDDING_CONCURRENCY=8\nzg --index --index-embedding-concurrency 1\n```\n\nTo change the daemon's environment-variable default, update its startup\nenvironment, then run `zg --server off` and `zg --server on` from that environment.\nIf an agent launches zg, update its environment and restart the agent/MCP\nconnection too. JavaScript exceptions can be caught, but native aborts can\nterminate the process before any CPU fallback runs. A limit of 1 reduces\nconcurrency; it does not prevent every GPU failure. You can also retry with\n`--device cpu`.\n\n<a id=\"benchmarks\"></a>\n\n## 📊 Benchmarks\n\nEach benchmark uses paired A/B runs with tasks, agent/model, prompt,\nenvironment, and limits held constant; only zg access and usage guidance\ndiffer.\n\nSee the [benchmark documentation](./benchmarks/README.md) for full results and\nreproduction details.\n\n### 1. Cross-Domain Agent Benchmark\n\n[SWE-QA-Bench](./benchmarks/swe-qa-bench/README.md) uses Claude Code with\nClaude Opus 5 at high reasoning effort;\n[BrowseComp-Plus](./benchmarks/browse-comp-plus/README.md) uses Codex\ngpt-5.6-sol at medium reasoning effort. Both zg profiles use Qwen3.7 Text\nEmbedding.\n\n<p align=\"center\">\n  <picture>\n    <source media=\"(prefers-color-scheme: dark)\" srcset=\"./.github/assets/benchmark-overall-retrieval-indexed-v4-dark.svg\">\n    <source media=\"(prefers-color-scheme: light)\" srcset=\"./.github/assets/benchmark-overall-retrieval-indexed-v4-light.svg\">\n    <img src=\"./.github/assets/benchmark-overall-retrieval-indexed-v4-light.svg\" alt=\"Overall zg benchmark results for Coding and general text retrieval, comparing answer quality, input tokens, tool calls, and agent time against Baseline\" width=\"1200\" />\n  </picture>\n</p>\n\n- **Why it helps:** semantic discovery narrows the search space, ranked lexical\n  retrieval anchors exact identifiers, and compact evidence reduces broad\n  scans, repeated tool calls, and model context.\n- **Why it generalizes:** the same retrieval loop works across domains—code is\n  indexed with symbols, signatures, and breadcrumbs, while prose is retrieved\n  as focused sections and chunks.\n\n### 2. Real-World Case Studies\n\n<table align=\"center\">\n  <tr>\n    <td align=\"center\">\n      <picture>\n        <source media=\"(prefers-color-scheme: dark)\" srcset=\"./.github/assets/benchmark-repository-top3-v2.png\">\n        <source media=\"(prefers-color-scheme: light)\" srcset=\"./.github/assets/benchmark-repository-top3-v2-light.png\">\n        <img src=\"./.github/assets/benchmark-repository-top3-v2-light.png\" alt=\"Baseline to zg comparison across three repository-comprehension tasks: Judge score, input tokens, tool calls, and wall time\" width=\"980\" />\n      </picture>\n    </td>\n  </tr>\n</table>\n\n- **[Pylint](https://github.com/pylint-dev/pylint) — Python static analysis:** the task asks how AST node handling\n  separates annotated and non-annotated attribute initialization. Symbol-aware\n  retrieval is useful because the architectural entry point is not known in\n  advance.\n- **[Matplotlib](https://github.com/matplotlib/matplotlib) — plotting and rendering:** the task traces `FontInfo` and font\n  selection through multiple math-text rendering stages. Ranked semantic and\n  lexical evidence helps reconstruct the cross-file data and control flow.\n- **[Django](https://github.com/django/django) — web framework:** the task connects username uniqueness, ORM\n  transactions, and formset bulk operations. Compact ranked evidence brings\n  the distributed design rationale together.\n\n<details>\n<summary><strong>Repository questions</strong></summary>\n\n| Repository | Question type | Question |\n| --- | --- | --- |\n| **`pylint-dev/pylint`** | What<br>Architecture exploration | What is the architectural pattern that distinguishes type-annotated from non-annotated instance attribute initialization using AST node type separation? |\n| **`matplotlib/matplotlib`** | Where<br>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? |\n| **`django/django`** | Why<br>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? |\n\n</details>\n\n> zg works best when evidence spans files or modules and the target location is\n> unknown, especially for call-chain, data-flow, and architectural questions.\n> Since agents decide when and how to use it, results vary by model and run;\n> repeated-run averages are more reliable.\n\n## 📚 Documentation\n\n| Guide | What you can do |\n| :--- | :--- |\n| [Agent integrations](./docs/01-agents.md) | Connect zg to Codex, Claude Code, Qwen Code, Qoder, Cursor, GitHub Copilot, VS Code, Grok Build, or OpenCode and verify that it works. |\n| [CLI guide](./docs/02-cli.md) | Search, index, and manage your local workspaces from the terminal. |\n| [MCP guide](./docs/03-mcp.md) | Understand which zg tools your agent can use and how access is secured. |\n| [Retrieval pipeline](./docs/04-pipeline.md) | Choose what to index, keep it fresh, and get better search results. |\n| [Architecture](./docs/05-architecture.md) | See how zg handles your query and where your data stays. |\n| [Server and execution modes](./docs/06-server.md) | Choose between one-off commands and a long-running local server. |\n| [Embedding models](./docs/07-embedding.md) | Pick the right model for speed, search quality, privacy, and your hardware. |\n| [Roadmap](./docs/08-roadmap.md) | See what is coming next and help shape zg's priorities. |\n\n<a id=\"community\"></a>\n\n## 🤝 Join Our Community\n\n<div align=\"center\">\n\n| 💬 DingTalk | 📱 WeChat | 🎮 Discord | X (Twitter) |\n| :---: | :---: | :---: | :---: |\n| <img src=\"https://zvec.oss-cn-hongkong.aliyuncs.com/qrcode/dingding.png\" width=\"150\" alt=\"DingTalk QR Code\"/> | <img src=\"https://zvec.oss-cn-hongkong.aliyuncs.com/qrcode/wechat.png?v5\" width=\"150\" alt=\"WeChat QR Code\"/> | [![Discord](https://img.shields.io/badge/Discord-Join%20Server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/rKddFBBu9z) | [![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/ZvecAI)](<https://x.com/ZvecAI>) |\n| Scan to join | Scan to join | Click to join | Click to follow |\n\n</div>\n\n## ❤️ Contributing\n\nCommunity contributions are always welcome—bug fixes, features, and\ndocumentation improvements all help make zvec-grep better.\n\nCheck out our [Contributing Guide](./CONTRIBUTING.md) to get started!\n"}