@izhimu/pi-rtk
v0.1.7
Published
RTK integration for pi — transparent command rewriting for 60-90% token savings
Maintainers
Readme
pi-rtk
RTK (Rust Token Killer) integration for pi and oh-my-pi — transparent command rewriting that reduces LLM token consumption by 60-90%.
Upstream: rtk-ai/rtk
Features
- Transparent rewriting — shell commands automatically use
rtkequivalents, no workflow changes - 60-90% token savings — tested across 100+ command categories
- Zero overhead — single Rust binary, <10ms rewrite latency
- Toggle on/off —
/rtk on//rtk offwithout restarting - Session stats — track rewrites, passthroughs, and errors per session
- Safe by default — all error paths pass through, RTK never blocks execution
Install
npm (recommended)
pi install @izhimu/pi-rtkFrom git
# Global
pi install git:github.com/izhimu/pi-rtk
# Project-local (shared with team via .pi/settings.json)
pi install git:github.com/izhimu/pi-rtk -lFrom local path
pi install /path/to/pi-rtk
pi install ./relative/path/to/pi-rtkQuick test (no install)
pi -e ./extensions/rtk.tsCommands
| Command | Effect |
|---------|--------|
| /rtk | Show status (on/off, version, rewrite count) |
| /rtk on | Enable rewriting |
| /rtk off | Disable rewriting |
| /rtk-status | Show project-scoped token savings |
| /rtk-status global | Show global token savings |
Supported Categories
| Category | Examples | Savings | |----------|----------|---------| | Test runners | vitest, pytest, cargo test, go test, playwright, bun, deno | 90-99% | | Build tools | cargo build, npm, pnpm, bun, deno, dotnet, make, mvn, gradle | 70-90% | | VCS & Git CLI | git status/log/diff/show, gh, glab | 70-80% | | Language servers | tsc, mypy | 80-83% | | Linters & AST | eslint, ruff, golangci-lint, biome, oxlint, ast-grep | 80-85% | | Package managers | pip, cargo install, pnpm list | 75-80% | | File operations | ls, find, grep, cat, head, tail | 60-75% | | Infrastructure | docker, kubectl, aws, terraform | 75-85% |
Examples
# Before: 2.4k tokens
git status
# After: ~480 tokens (80% savings)
rtk git status
# Before: 8k tokens
cargo test
# After: ~800 tokens (90% savings)
rtk cargo testRequirements
rtk >= 0.23.0in PATH- Install:
brew install rtkor see rtk installation
How It Works
- Extension loads, probes
rtk --version(disables if missing or too old) - Subscribes to
tool_callevents, narrows tobashandpowershelltools - Calls
rtk rewrite <command>for each shell command - If rewrite differs, mutates command in-place
- All error paths pass through — RTK never blocks execution
Override
RTK_DISABLED=1prefix skips rewriting for one command- Already-prefixed
rtk ...commands pass through unchanged
Project Structure
pi-rtk/
├── extensions/
│ └── rtk.ts # pi ExtensionAPI integration
├── CHANGELOG.md
├── package.json # pi package manifest
├── tsconfig.json
├── LICENSE
└── README.mdChangelog
See CHANGELOG.md for release history.
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feat/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
