pi-rtk-rewrite
v0.3.0
Published
Automatic RTK rewrite integration for Pi bash tool calls (token-efficient command output)
Maintainers
Readme
pi-rtk-rewrite
✨ What this package does
pi-rtk-rewrite is a Pi extension package that intercepts Pi bash tool calls and runs:
rtk rewrite "<original command>"If RTK returns a rewritten command, the extension transparently swaps it before execution.
Example
git status→rtk git statuscargo test→rtk cargo testls -la→rtk ls -la
(when RTK has a supported rewrite rule)
✅ Why use it
- Lower token usage in agent loops
- Cleaner command output sent back to the model
- Zero workflow change — keep typing normal commands
- Safe fallback — if RTK is missing or rewrite fails, original command still runs
📦 Requirements
- Pi Coding Agent
rtkinstalled and available inPATH
Quick check:
rtk --version🚀 Installation
Install from npm
pi install npm:pi-rtk-rewriteInstall from GitHub
pi install git:github.com/viartemev/pi-rtk-rewriteor
pi install https://github.com/viartemev/pi-rtk-rewriteFor pinned GitHub install:
pi install git:github.com/viartemev/[email protected]Then in a running Pi session:
/reload🧭 Usage
After install, no extra setup is required.
Just ask Pi to execute normal bash commands. If rewrite exists, extension applies it automatically.
Default behavior
If the extension is installed, rewrite is enabled. No config file or slash command is needed.
Per-command opt-out
RTK_DISABLE_REWRITE=1 ls -la
# or
RTK_DISABLED=1 git status🔍 Behavior details
The extension follows rtk rewrite exit semantics:
0→ rewrite applied1→ no rewrite, run original command2→ deny rule matched, run original command3→ ask rule matched, rewrite applied automatically
It only targets Pi bash tool calls.
🛠 Local development
git clone https://github.com/viartemev/pi-rtk-rewrite
cd pi-rtk-rewrite
pi install ./Then in Pi:
/reload🧪 Quick validation
Inside Pi:
- Run
git status→ should be rewritten tortk git status - Run
echo hello→ usually stays unchanged - Run
RTK_DISABLE_REWRITE=1 ls -la→ should stay unchanged
🤝 Contributing
PRs welcome. See CONTRIBUTING.md.
📄 License
MIT — see LICENSE.
