@piotr-oles/pi-reflag
Pi Agent extension: transparently rewrite grep commands to rg (ripgrep) for faster searches
Package details
Install @piotr-oles/pi-reflag from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@piotr-oles/pi-reflag- Package
@piotr-oles/pi-reflag- Version
0.1.0- Published
- Jun 5, 2026
- Downloads
- not available
- Author
- piotr-oles
- License
- unknown
- Types
- extension
- Size
- 10.9 KB
- Dependencies
- 1 dependency · 2 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-reflag
A pi coding agent extension that transparently rewrites grep commands to rg (ripgrep) before they execute — faster searches with zero agent behavior change.
Install
pi install npm:@piotr-oles/pi-reflag
Requires rg on $PATH. Install ripgrep via your package manager if needed:
brew install ripgrep # macOS
apt install ripgrep # Debian/Ubuntu
How it works
Intercepts bash tool calls in the tool_call event. When the command starts with grep (including piped commands like grep … | head), it translates the arguments to their rg equivalents and rewrites the command in place before execution. The agent never sees the rewrite — only a user-visible toast notification is shown.
What gets translated:
| grep flag | rg equivalent |
|---|---|
-r, -R, --recursive |
dropped (rg is recursive by default) |
-i, --ignore-case |
-i |
-n, --line-number |
-n |
-v, --invert-match |
-v |
-w, --word-regexp |
-w |
-l, --files-with-matches |
-l |
-c, --count |
-c |
-o, --only-matching |
-o |
-E, --extended-regexp |
dropped (rg uses ERE by default) |
-G, --basic-regexp |
dropped, pattern converted from BRE to ERE |
-F, --fixed-strings |
-F |
-P, --perl-regexp |
-P |
-A, -B, -C |
passed through |
--include=<glob> |
-g <glob> |
--exclude=<glob> |
-g !<glob> |
--exclude-dir=<dir> |
-g !<dir>/ |
-s |
--no-messages |
-N (numeric context) |
-C N |
Subshell constructs ($(…), (…)) are left untouched to avoid misinterpreting nested commands.
Usage
The extension is active by default. Disable it per-session with the --pi-reflag-grep flag:
pi --pi-reflag-grep off
Thanks
- ripgrep by Andrew Gallant — the fast, modern grep replacement this extension routes to
- greprip-rs by kaofelix — the grep → rg argument translation logic is ported from that project (MIT)
Development
pnpm install
pnpm test
pnpm typecheck
pnpm check
To test changes manually:
pi -e packages/pi-reflag/src/index.ts