tgrep-pi
Pi grep via Microsoft tgrep — trigram-indexed search, auto-installed prebuilt binary
Package details
Install tgrep-pi from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:tgrep-pi- Package
tgrep-pi- Version
0.1.1- Published
- Sep 9, 2026
- Downloads
- 269/mo · 269/wk
- Author
- shahidshabbir-se
- License
- MIT
- Types
- extension
- Size
- 24.2 KB
- Dependencies
- 0 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
tgrep-pi
Pi extension that installs Microsoft tgrep and uses it for the built-in grep tool.
tgrep is a trigram-indexed search engine (the same engine GitHub Copilot CLI uses for large-repo grep). This package downloads the latest prebuilt binary for your OS, keeps it updated, and routes Pi’s grep calls through it.
- npm: tgrep-pi
- pi.dev: pi.dev/packages/tgrep-pi
- Source: github.com/shahidshabbir-se/pi-tgrep
- Upstream: microsoft/tgrep · releases · benchmarks
Why use it
Pi’s default grep (and tools like ripgrep) scan every file on every query — O(total bytes). In a 100k+ file monorepo that is slow enough that the agent spends more time waiting than reading.
tgrep pre-builds a trigram index, then only opens files that could match. On large trees that is often an order of magnitude faster (see tgrep’s own numbers: up to ~50× vs ripgrep on gecko-dev / Chromium / Linux).
This extension exists so you do not have to:
- Hunt for a tgrep binary
- Keep it current
- Teach the model a new tool name
You get the same grep tool Pi already uses, backed by tgrep.
| Default Pi grep | tgrep-pi | |
|---|---|---|
| Engine | built-in scanner | microsoft/tgrep |
| Large repos | linear scan | trigram index + candidate verify |
| Binary | none | latest GitHub release, checksum-verified |
| Tool name | grep |
still grep (override) |
Use it if you search big checkouts, generated trees, or anything where cold rg/grep feels sticky. On tiny repos the difference is small; tgrep still works.
Install
pi install npm:tgrep-pi
Reload Pi (/reload or restart). Confirm with /tgrep-status.
From git instead of npm:
pi install git:github.com/shahidshabbir-se/pi-tgrep
Requires a network path to GitHub Releases on first grep (or when /tgrep-update runs).
What you get
greptool override — same parameters Pi already documents (pattern,path,exclude,caseSensitive,context,limit,cursor). Smart-case by default.- Managed binary — stored next to the package (
bin/tgreporbin/tgrep.exe), not in~/.local/bin. Safe on NixOS and other immutable systems. - Latest release — fetched from microsoft/tgrep releases. Archive SHA-256 is checked against
checksums.txtwhen GitHub publishes it. Replace is atomic (tgrep.new→ rename). - Background check — session start does not block the TUI. First
grepensures the binary; a 24h cache avoids hitting the API every turn. - Platforms — Linux/macOS/Windows, x64 and arm64 (musl static builds on Linux).
Commands
| Command | What it does |
|---|---|
/tgrep-status |
Managed path, VERSION, whether the binary exists |
/tgrep-update |
Force download and replace with the current latest release |
How the binary is kept
- Detect host triple (
x86_64-unknown-linux-musl,aarch64-apple-darwin, …). GEThttps://api.github.com/repos/microsoft/tgrep/releases/latest.- Download the matching
.tar.gz/.zip, verify checksum, extract,chmod +x, atomic replace. - Write
bin/VERSION(release tag, e.g.v1.0.4).
If GitHub is down and a local binary already exists, grep keeps using it.
GitHub API rate limits are tight unauthenticated. Set GITHUB_TOKEN or GH_TOKEN if updates start failing.
Grep mapping
Pi grep arg |
tgrep |
|---|---|
pattern |
regex / literal (tgrep auto) |
path glob (*.ts, src/**) |
-g |
path file or directory |
positional path |
exclude directory |
-g '!dir/**' |
exclude glob |
-g '!glob' |
caseSensitive: true |
-s |
caseSensitive: false |
-i |
| omitted | -S smart-case |
context |
-C |
limit / cursor |
applied in the extension (default 20) |
Output is grouped by file, with a continuation cursor when truncated.
Optional: run tgrep serve / tgrep index in a repo yourself for the full server+index path. The extension does not start a daemon; tgrep will use a running server if one is already there.
Development
git clone https://github.com/shahidshabbir-se/pi-tgrep.git
cd pi-tgrep
Local Pi also auto-loads ~/.pi/agent/extensions/pi-tgrep/ if you keep a copy there. Do not install the npm package and a local copy at the same time or grep will be registered twice.
License
MIT. Upstream tgrep is also MIT.