AIFeed

面向人类与 AI 智能体的本地优先工作区搜索

Translation(model translation, not the source's own text)

文章标题:Local-first search across your workspace, built for humans and AI agents

正文: English | 中文 | 日本語

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

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

zg(zvec-grep)由 zvec 驱动,将 ripgrep、BM25 和向量搜索统一在一个 local-first 接口之后。你可以直接在终端中使用它,也可以让你的 agent 替你使用它。

🎬 See it in action

安装 agent 集成、为工作区建立索引,然后让 agent 用 zvec-grep 搜索它
安装 agent 集成、为工作区建立索引,然后让 agent 用 zvec-grep 搜索它

💫 Why zg?

  • 为人类和 agent 而准备——安装一次、索引一次,之后即可在 macOS、Linux 和 Windows 上通过 CLI 或你的 agent 使用同一个工作区。
  • 超越关键词的搜索——按语义发现,按相关性排序,需要时再用精确文本或正则进行验证。
  • 多格式搜索——搜索源代码、文档和结构化数据,同时保留有用的结构和来源位置。
  • 更少的搜索,更少的上下文——带排序、带来源链接的结果以更少的工具调用、更少的 token 和更少的噪声呈现正确的证据。
  • 默认本地——文件、索引和本地模型都留在你的机器上;远程嵌入只有在获得你许可时才会接收数据。

🚀 Try it yourself

1. Set up a sample bookshelf


        npm install -g @zvec/zvec-grep --allow-scripts=@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
      

索引存储在已索引项目根目录下的 .zvec-grep/ 中。

2. Choose how to search

For agents: ask with OpenCode

配置好 OpenCode 后:


        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."
      

免费模型的可用性可能会变化。请查看 opencode models,并将示例模型替换为你当前环境中可用的模型。

OpenCode 会自行选择 zg——提示词中并未点名任何工具。


        ⚙ 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

不借助 agent,直接搜索同一个书架:


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

zg 返回 sherlock-holmes.txt 中的相关段落,其排名高于 alice-in-wonderland.txt。

对多个独立查询重复使用 --hybrid、--fts 或 --vector 标志。每个非空结果组都以原始查询和位置开头,例如 -- query 2/2: timeout --;彩色输出使用暗色分隔线和品红色标签。

📊 Benchmarks

文章标题:面向整个工作区的本地优先搜索,为人类和 AI 智能体而构建

正文: 每个基准测试都采用配对的 A/B 运行,任务、智能体/模型、提示词、环境和限制条件均保持不变;只有 zg 的访问权限和使用指引不同。

完整结果和复现细节请参阅基准测试文档。

1. 跨领域智能体基准测试

SWE-QA-Bench 使用 Claude Code 搭配 Claude Opus 5,推理强度设为高;BrowseComp-Plus 使用 Codex gpt-5.6-sol,推理强度设为中。两个 zg 配置均使用 Qwen3.7 Text Embedding。

Coding 和通用文本检索的 zg 整体基准测试结果,对比答案质量、输入 token、工具调用次数和智能体耗时与 Baseline 的差异
Coding 和通用文本检索的 zg 整体基准测试结果,对比答案质量、输入 token、工具调用次数和智能体耗时与 Baseline 的差异
  • 为什么有帮助:语义发现缩小搜索空间,排序后的词法检索锚定精确标识符,紧凑的证据减少大范围扫描、重复工具调用和模型上下文。
  • 为什么具有通用性:同一套检索循环可跨领域工作——代码按符号、签名和面包屑索引,而散文则按聚焦的章节和块进行检索。

2. 真实案例研究

三个仓库理解任务上 Baseline 与 zg 的对比:Judge 分数、输入 token、工具调用次数和实际耗时
三个仓库理解任务上 Baseline 与 zg 的对比:Judge 分数、输入 token、工具调用次数和实际耗时
  • Pylint——Python 静态分析:该任务询问 AST 节点处理如何区分带注解和不带注解的属性初始化。符号感知检索很有用,因为架构入口点事先未知。
  • Matplotlib——绘图与渲染:该任务追踪 FontInfo 和字体选择在多个数学文本渲染阶段中的传递。排序后的语义和词法证据有助于重建跨文件的数据流和控制流。
  • Django——Web 框架:该任务将用户名唯一性、ORM 事务和 formset 批量操作联系起来。紧凑的排序证据将分散的设计理由汇聚在一起。
仓库问题类型问题
pylint-dev/pylintWhat 架构探索通过 AST 节点类型分离来区分带类型注解和不带注解的实例属性初始化,其架构模式是什么?
matplotlib/matplotlibWhere 数据/控制流FontInfo NamedTuple 在数学文本渲染管线中于何处传播字体度量和字形数据,以及在字符渲染的不同阶段,是什么控制流决定使用 postscript_name 还是 FT2Font 对象?
django/djangoWhy 设计理由为什么 User 模型对 username 字段的唯一约束会与 Django 的 ORM 事务处理相互作用,如果在已有数据库上移除该约束并使用基于 formset 的批量操作,会产生什么级联影响?
当证据跨越文件或模块且目标位置未知时,zg 效果最佳,尤其适用于调用链、数据流和架构类问题。由于智能体自行决定何时以及如何使用它,结果会因模型和运行而异;多次运行的平均值更可靠。

🤝 加入我们的社区

💬 钉钉📱 微信🎮 DiscordX (Twitter)
扫码加入扫码加入点击加入点击关注
钉钉二维码
钉钉二维码
微信二维码
微信二维码
X(原 Twitter)关注
X(原 Twitter)关注

❤️ 贡献

社区贡献始终受到欢迎——缺陷修复、新功能和文档改进都有助于让 zvec-grep 变得更好。

查看我们的贡献指南以开始参与!

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗