pi-rtk-rewrite

内容来源:README.md(说明文档) · 原始地址 · 查看安装指南

原始内容

pi-rtk-rewrite

Automatic RTK command rewrite for Pi bash tool calls
Make Pi run compact, token-efficient RTK commands without changing your workflow.

License Powered by RTK Pi compatible


✨ 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 statusrtk git status
  • cargo testrtk cargo test
  • ls -lartk 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

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 applied
  • 1 → no rewrite, run original command
  • 2 → deny rule matched, run original command
  • 3 → 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:

  1. Run git status → should be rewritten to rtk git status
  2. Run echo hello → usually stays unchanged
  3. Run RTK_DISABLE_REWRITE=1 ls -la → should stay unchanged

🤝 Contributing

PRs welcome. See CONTRIBUTING.md.


📄 License

MIT — see LICENSE.