Owen718/snapgrep 预览 preview

Owen718/snapgrep

一个进程内三元组索引,使Pi&DSH中的代码搜索比ripgrep快20-70倍,结果相同且无附属进程。

Project Overview项目介绍

snapgrep is an accelerated code search tool built around an in-process trigram index, that delivers 40 to 1900x speedups over ripgrep on warm indexes. It runs entirely inside the existing agent process with no sidecar daemon or extra background process, requiring just a 3.2MB native addon. It integrates with multiple coding agents including Pi, oh-my-pi, and DeepSeek Harness (DSH). For DSH users, install via the command dsh plugin --profile headless add snapgrep, which automatically replaces DSH’s built-in grep and glob tools. All search results are byte-for-byte verified against ripgrep to guarantee accuracy.

Coding agents perform frequent code searches, and ripgrep re-reads every byte from disk every search, which adds up to hundreds of milliseconds of wait time per search, multiple times per minute. snapgrep fixes this by keeping a compressed trigram index of the repository mapped in memory, so most searches never need to read file content from disk. It automatically falls back to ripgrep when the index is being rebuilt after code changes, so you will always get correct results even when you are actively editing code. It is ideal for anyone who uses AI coding agents and works with large code repositories.

snapgrep is built with Rust and exposes its functionality to Node via N-API. Prebuilt binaries are available for macOS (Apple Silicon and Intel), Linux (x64 and arm64 glibc), and Windows x64. Alpine Linux with musl libc is not currently supported. Only the correct binary for your host architecture and operating system is downloaded on install, so you do not need to compile anything locally. The project is open source under the MIT license, and the total download size is only around 1.2MB.

snapgrep 是一个基于三元组索引的代码搜索加速工具,可替代 ripgrep 为多个编码 agent 提供数十到上千倍的搜索速度提升,目前支持 Pi、oh-my-pi 和 DeepSeek Harness(DSH)。它将索引直接嵌入 agent 进程运行,不需要额外的守护进程或 Sidecar 进程,仅占用约 3.2MB 的原生扩展空间。

对于 DSH 用户,可通过 dsh plugin --profile headless add snapgrep 命令完成安装,安装后会自动替换内置的 grep 和 glob 工具,glob 工具保持原有 ripgrep 调用逻辑不变。它适合日常需要频繁在大型代码仓库进行代码搜索的开发人员和 AI 编码 agent 用户,能大幅减少搜索等待时间。

snapgrep 使用 N-API 调用 Rust 编译的原生模块,预构建支持 macOS(Intel 和 Apple Silicon)、Linux(x64 和 arm64 glibc)和 Windows x64,暂不支持 Alpine/musl。项目基于 MIT 许可证开源,仅下载对应平台的预构建包,无需本地编译即可使用。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 note1 项提示
  • 11 stars - an early-stage project星标 11,属于早期项目
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile headless add snapgrep

把 Owen718/snapgrep 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

snapgrep

An in-process trigram index that makes code search in Pi
Typically 40–70× faster than ripgrep on a warm index —
and every result is checked against ripgrep, byte for byte.

Terminal demo: ripgrep takes 147.7 ms to search a 17 MB repository while snapgrep takes 2.1 ms, drawn to true scale

No sidecar process. No daemon. A single 3.2 MB native addon loaded inside the agent process.

Install

Pi

npm install -g snapgrep

Pi's built-in grep is replaced automatically, in every project. To confirm, ask Pi to search for a string you know exists — the tool detail shows actualBackend: kernel.

oh-my-pi (omp)

npm install -g snapgrep

Same package, no changes: omp treats @earendil-works/pi-coding-agent as an aliased scope and its loader accepts .pi directories alongside .omp.

DeepSeek Harness (dsh)

dsh plugin --profile headless add snapgrep

Verify with dsh --profile headless --dump-config | grep snapgrep.

It replaces both grep and glob: the registry rejects a duplicate tool name outright, so the built-in search row is disabled and this plugin supplies both. glob runs the same ripgrep invocation the built-in used.


Only the addon your machine can run is downloaded — about 1.2 MB, two packages. Nothing is compiled and no daemon is started.

Prebuilt for macOS (Apple Silicon and Intel), Linux (x64 and arm64, glibc), and Windows x64. Alpine/musl is not built yet; on an unsupported platform the extension names the exact file it could not find rather than failing silently.

Other ways to install — no npm, single project, or one copy for every machine

Without npm, a script fetches the matching archive from the latest release and installs into ~/.pi/agent/extensions:

curl -fsSL https://raw.githubusercontent.com/Owen718/snapgrep/main/install.sh | sh

Set PI_EXTENSIONS_DIR to install elsewhere. For a directory that works on any machine, snapgrep-extension-all-platforms.tar.gz from the same release carries all five addons and picks the right one at load time.

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-translate 下一个 Next dsh-side-chat →