@bacnh85/pi-rtk

Pi extension that routes shell commands through RTK for token savings.

Packages

Package details

extension

Install @bacnh85/pi-rtk from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@bacnh85/pi-rtk
Package
@bacnh85/pi-rtk
Version
0.1.2
Published
Jun 26, 2026
Downloads
not available
Author
bacnh85
License
MIT
Types
extension
Size
12 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-rtk

Pi extension that rewrites bash tool calls through RTK for token savings.

Behavior

  • Listens for Pi tool_call events for the built-in bash tool.
  • Listens for context-visible user shell commands entered as !cmd.
  • Skips !!cmd user shell commands because their output is excluded from model context.
  • Delegates command matching to rtk rewrite.
  • Mutates agent bash commands in place or wraps user shell execution when RTK returns a rewrite.
  • Fails open on errors: commands pass through unchanged.
  • Caches RTK-unavailable state briefly to avoid repeatedly probing a missing binary.
  • Can optionally notify when a command is rewritten.
  • Does not block, confirm, audit, or permission-gate commands.

Commands

  • /rtk enable enables rewrites for the current Pi session.
  • /rtk disable disables rewrites for the current Pi session.
  • /rtk notify-on enables rewrite notifications for the current Pi session.
  • /rtk notify-off disables rewrite notifications for the current Pi session.
  • /rtk status shows session state, notification state, cache state, and detected RTK details.
  • /rtk opens a picker for the same actions.

Requirements

  • rtk >= 0.23.0 available in PATH.
  • Set RTK_DISABLED=1 to bypass rewrites. The extension reads this from the process environment, current working directory .env.local/.env, or Pi global config .env.local/.env under $PI_CODING_AGENT_DIR, ~/.pi/agent, or compatibility path ~/.pi/agents.

Install

Install the published package from npm:

pi install npm:@bacnh85/pi-rtk

From this repository checkout, install only this extension package:

pi install ./extensions/pi-rtk

The package manifest points Pi directly at ./index.ts, so published npm installs and local installs load the same extension entrypoint.

Install extensions from their own subdirectories. This repository intentionally has no root Pi package because multiple extensions can live under extensions/.

Test

pi -e ./extensions/pi-rtk
rtk gain --history
RTK_DISABLED=1 pi -e ./extensions/pi-rtk