Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tgrep Extension

Fast trigram-indexed grep extension for the pi coding agent — up to 65x faster than ripgrep on large codebases.

Features

Tools (LLM-callable)

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

Commands (user-invokable)

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

Requirements

Installation

1. Install tgrep CLI

# 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

2. Install this extension

Option A: Project-specific (recommended)

# Copy extension to your project's .pi/extensions/
mkdir -p your-project/.pi/extensions/
cp -r pi-tgrep/ your-project/.pi/extensions/

Option B: Global installation

# Copy to pi agent's global extensions directory
cp -r pi-tgrep/ ~/.pi/agent/extensions/

Option C: Use pi packages (if supported)

pi pkg install pi-tgrep

Usage

Example Tool Calls (for pi agent)

# 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

CLI Reference

# 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 3

Performance

tgrep 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

Auto-Discovery

When pi starts, it automatically discovers extensions in:

your-project/
├── .pi/extensions/tgrep/
│   ├── index.ts
│   └── package.json

Or globally:

~/.pi/agent/extensions/tgrep/

Notes

  • 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

License

MIT

About

An extension for Pi Coding Agent that leverages Microsoft’s Tgrep library to efficiently search and match grep patterns.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages