pi-rtk-rewrite
Automatic RTK rewrite integration for Pi bash tool calls (token-efficient command output)
Package details
Install pi-rtk-rewrite from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-rtk-rewrite- Package
pi-rtk-rewrite- Version
0.3.0- Published
- May 22, 2026
- Downloads
- not available
- Author
- viartemev
- License
- MIT
- Types
- extension
- Size
- 6.9 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./extensions"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
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-rewrite
Install from GitHub
pi install git:github.com/viartemev/pi-rtk-rewrite
or
pi install https://github.com/viartemev/pi-rtk-rewrite
For pinned GitHub install:
pi install git:github.com/viartemev/pi-rtk-rewrite@v0.2.1
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.