← Catalog

pi-rust-cli-tools

Pi extension that detects which modern CLI tools are installed (rg, fd, lsd, eza, ...), tells the agent, and rewrites grep -r, find -name and ls -l to rg, fd and lsd before they run.

Extension

Install

Install with PiG

pig install npm:pi-rust-cli-tools

Install with Pi

pi install npm:pi-rust-cli-tools
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extensions/rust-cli-tools.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.4 (README.md). PiG does not review it.

pi-rust-cli-tools

npm CI License: MIT Audit Fuzz

A pi extension that steers the agent to fast modern CLI tools (rg, fd, lsd, ...) only when they are installed.

What it does

  1. Detects which of rg fd bat lsd eza sd dust procs hyperfine tokei delta difft jq just rtk are on PATH (once per session).
  2. Tells the agent which are installed, in a few lines of the system prompt.
  3. Rewrites a bash call that has an installed replacement, before it runs, so the agent never pays for a retry:
Agent runsRuns insteadNeeds
grep -rn foo src (also -R, --recursive, egrep, fgrep)rg -n foo srcrg
find . -name '*.ts' -type f (also -iname, -maxdepth, -mindepth)fd -t f -g '*.ts' .fd
ls -la srclsd -la srclsd

Details that keep the meaning intact:

  • rg and fd skip hidden and git-ignored files, grep -r and find do not. That is the point (no node_modules, no target/), but search an ignored path with /rust-cli-tools mode off or grep off.

  • grep flags map one to one (-i -w -l -c -v -F -P -o -q, -A/-B/-C N, -m N, -e, -f, --include/--exclude/--exclude-dir to -g), -n is added so the output has line numbers, and a path is always named (rg would read stdin otherwise).

  • Only the command is rewritten: quotes, redirections, pipes, cd x && and the rest of the line stay as they were.

  • A basic regex (grep without -E) is spelled for rg: grep -rn 'fn main()' becomes rg -n 'fn main\(\)', since ( ) + ? | { } are plain characters to grep and operators to rg. -x/--line-regexp maps to -x.

  • What cannot be said the same way (a GNU regex like \(a\|b\), a back-reference, patterns from -f in a basic regex, find -o, -path, an unknown flag) is blocked with a hint instead, and the agent retries by hand.

  • Plain ls, du, ps, grep without -r, find -exec/-delete/-mtime/... and anything inside a quote, a heredoc or $(...) are left alone. ls -l | wc -l is left alone too (ls -l prints a total line).

Modes and settings

Command(blank)
/rust-cli-tools statussettings, installed tools, how many commands were rewritten
/rust-cli-tools mode [rewrite|block|hint|off]rewrite (default) runs the modern tool; block refuses with a hint; hint only tells the model; off does nothing
/rust-cli-tools on / offthe same as mode rewrite / mode off
/rust-cli-tools [grep|find|ls] [on|off]switch one rule

Settings are saved in <agent dir>/rust-cli-tools.json (the agent dir is PI_CODING_AGENT_DIR, then $XDG_CONFIG_HOME/pi/agent, then ~/.pi/agent). The status line shows cli: N rewritten.

Works together with pi-squeeze: this plugin decides which command runs, pi-squeeze shrinks its output (rg -n, fd and lsd -l results are compacted).

Install

pi install npm:pi-rust-cli-tools

Install the tools themselves, for example: brew install ripgrep fd lsd.

Development

bun install
just check   # typecheck + tests (95% coverage gate) + pack check + nu script tests

Releases run in CI: Actions → Release → Run workflow with a bump (patch, minor, major), or just release-ci minor. The workflow runs the quality gate, bumps package.json, regenerates CHANGELOG.md with git-cliff, commits, tags, pushes and publishes to npm (secret NPM_TOKEN).

License

MIT