Stop AI Agents from guessing wrong keywords. zg unifies ripgrep, BM25, and vector search into one local command for precise code retrieval.
By Meng Li
Published: 2026-09-04
URL: https://pythonlibraries.substack.com/p/one-command-zero-local-search-hassle
Has anyone run into this scenario—
You ask an AI Agent to find the code logic for “restore theme preference on startup.” The Agent takes that sentence and starts searching: first theme preference — nothing; then restore theme — still nothing; then startup settings… After several rounds, it has read a pile of irrelevant files, and the answer it finally gives is still wrong.
In the actual code, the function is named hydratePreferences.
This isn’t because the Agent isn’t smart enough. It’s because the tools in its hands are the wrong ones.
The Agent receives a natural-language intent. The default retrieval tool it can use is ripgrep (the familiar rg), which only understands exact keyword matching.
The “vocabulary gap” between code names and natural-language descriptions traps the Agent in a typical vicious cycle: guess a keyword → search → not enough information → try another word → search again…
Every loop costs real money: more tool calls, more tokens, longer wait times. Worse, the Agent may draw a conclusion from incomplete information — and that kind of error is hard to notice.
What local retrieval needs is not “a faster grep.” It needs three new capabilities: semantic discovery, relevance ranking, and context organization.
Alibaba’s recently open-sourced zg (zvec-grep) is aimed at exactly this pain point — packing ripgrep, BM25, and vector search, three very different retrieval capabilities, into one local-first CLI tool.
