Fast trigram-indexed grep extension for the pi coding agent — up to 65x faster than ripgrep on large codebases.
| Tool | Description |
|---|---|
tgrep_search |
Fast regex search using trigram index |
tgrep_index |
Build/update trigram index |
tgrep_serve |
Start search server (background) |
tgrep_status |
Check index/server status |
tgrep_count |
Count text files |
| Command | Description |
|---|---|
/tgrep-search <pattern> |
Search with tgrep |
/tgrep-index |
Build trigram index |
/tgrep-serve |
Start tgrep server |
/tgrep-status |
Show server status |
/tgrep-count |
Count text files |
- pi coding agent
- Microsoft tgrep installed locally
# From source
git clone https://github.com/microsoft/tgrep
cd tgrep
cargo install --path tgrep-cli
# Or use install scripts
./scripts/install.sh # Linux/macOS
./scripts/install.ps1 # Windows# Copy extension to your project's .pi/extensions/
mkdir -p your-project/.pi/extensions/
cp -r pi-tgrep/ your-project/.pi/extensions/# Copy to pi agent's global extensions directory
cp -r pi-tgrep/ ~/.pi/agent/extensions/pi pkg install pi-tgrep# Build the index first
Tool: tgrep_index
Path: .
# Search with context
Tool: tgrep_search
Pattern: TODO|FIXME
Path: src/
Context: 3
# Search specific file type
Tool: tgrep_search
Pattern: function|class
File_type: rust
Files_only: true
# Index your codebase (do once)
tgrep index .
# Start server (optional, for persistent fast searches)
tgrep serve .
# Search!
tgrep "TODO|FIXME" .
tgrep "function" . -t rust
tgrep "error" . -i -C 3tgrep pre-builds a trigram index so searches only touch files that could match:
| Repo | ripgrep | tgrep | Speedup |
|---|---|---|---|
| chromium (494K files) | 71s | 3s | 23x |
| gecko-dev (388K files) | 39s | 0.6s | 65x |
| kubernetes (29K files) | 1s | 0.14s | 7x |
When pi starts, it automatically discovers extensions in:
your-project/
├── .pi/extensions/tgrep/
│ ├── index.ts
│ └── package.json
Or globally:
~/.pi/agent/extensions/tgrep/
- The index is automatically built in the background when you start a server
- The server watches for file changes and keeps the index updated
- You can search immediately even while the index is being built
- Output is truncated to 2000 lines / 50KB to save tokens
MIT