🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@piotr-oles/pi-reflag

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@piotr-oles/pi-reflag

Pi Agent extension: transparently rewrite grep commands to rg (ripgrep) for faster searches

latest
Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
35
Maintainers
1
Weekly downloads
 
Created
Source

pi-reflag

A pi coding agent extension that transparently rewrites grep commands to rg (ripgrep) and find commands to fd before they execute — faster searches with zero agent behavior change.

Install

pi install npm:@piotr-oles/pi-reflag

Requires rg and fd on $PATH:

brew install ripgrep fd      # macOS
apt install ripgrep fd-find  # Debian/Ubuntu

How it works

Intercepts bash tool calls in the tool_call event. When a command segment starts with grep, find, or xargs grep/xargs find (including piped commands), it translates the arguments to their rg/fd equivalents and rewrites the command in place before execution. The agent never sees the rewrite.

Subshell constructs ($(…), (…)) and commands with variable assignments are left untouched to avoid misinterpreting nested or complex commands.

grep → rg

What gets translated:

grep flagrg equivalent
-r, -R, --recursivedropped (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-regexpdropped (rg uses ERE by default)
-G, --basic-regexpdropped, pattern converted from BRE to ERE
-F, --fixed-strings-F
-P, --perl-regexp-P
-A, -B, -Cpassed through
--include=<glob>-g <glob>
--exclude=<glob>-g !<glob>
--exclude-dir=<dir>-g !<dir>/
-s--no-messages
-N (numeric context)-C N

find → fd

What gets translated:

find expressionfd equivalent
(always)-H added — fd excludes hidden files by default, find doesn't
(auto mode)--no-ignore added when searching inside a known ignored directory
-name <glob>-g <glob>
-iname <glob>-i -g <glob>
-name a -o -name b-g {a,b} (brace expansion)
! -name <glob> / -not -name <glob>-E <glob>
-type f/d/l-t f/d/l
-maxdepth N-d N
-mindepth N--min-depth N
-exec cmd {} \;-x cmd {}
-exec cmd {} +-X cmd {}
-print0-0
-printdropped (fd default)
-L / -follow-L
-path <pat> -prune-E <pat> (exclude directory)
-path <pat>-p <pat> (full-path match)
-regex <pat><pat> (fd regex)
-iregex <pat>-i <pat>
-size <spec>-S <spec>
-newer <file>--newer <file>
-mtime/-atime/-ctime -N--changed-within Nd
-mtime/-atime/-ctime +N--changed-before Nd
-mmin/-amin/-cmin -N--changed-within Nmin
-mmin/-amin/-cmin +N--changed-before Nmin
-user <name>--owner <name>
-group <name>--owner :<name>
-empty-t e
-executable-t x
-xdev / -mount--one-file-system
-quit-1

Ignore mode

Controls when --no-ignore is passed to fd (so it searches inside .gitignored directories):

ModeBehaviour
auto (default)adds --no-ignore when the search path contains a known ignored directory (e.g. node_modules, .venv, .yarn, dist, target, …)
no-ignorealways adds --no-ignore
ignorenever adds --no-ignore
pi --pi-reflag-ignore-mode=no-ignore

PI_REFLAG_IGNORE_MODE=no-ignore pi
Full list of directories that trigger auto mode

node_modules, .yarn, .pnpm-store, .parcel-cache, .turbo, .vite, .cache, .eslintcache, .stylelintcache, .next, .nuxt, .svelte-kit, .vuepress, .output, .docusaurus, .temp, .serverless, .firebase, dist, build, out, target, debug, obj, artifacts, _deps, CMakeFiles, coverage, .nyc_output, .hypothesis, __pycache__, .pytest_cache, .tox, .nox, .venv, venv, .ipynb_checkpoints, vendor, .bundle, .gradle, .mvn, _build, deps, .git

Verbose mode

See exactly how each command was rewritten in the UI:

pi --pi-reflag-verbose

PI_REFLAG_VERBOSE=true pi

Thanks

  • ripgrep by Andrew Gallant
  • fd by David Peter
  • greprip-rs by kaofelix — grep→rg and find→fd translation logic ported from this project (MIT)
  • reflag by kluzzebass — additional find→fd flag mappings referenced from this project (MIT)

Development

pnpm install
pnpm test
pnpm typecheck
pnpm check

To test changes manually:

pi -e packages/pi-reflag/src/index.ts

Keywords

pi-package

FAQs

Package last updated on 26 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts