npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sherif-fanous/pi-rtk

v0.6.0

Published

Pi extension that routes bash commands through rtk (Rust Token Killer) for LLM token savings

Downloads

1,120

Readme

pi-rtk

Pi coding agent extension that uses rtk to reduce LLM token usage for shell command execution.

When pi-rtk is loaded, it participates in two Pi shell paths:

  • agent-initiated bash tool calls
  • user-issued !<cmd> shell commands whose output is included in model context

In both cases, pi-rtk first attempts to rewrite the command with:

rtk rewrite "<original command>"

If rewrite succeeds, Pi executes the rewritten command. If rewrite fails for any reason, pi-rtk falls back silently so normal Pi shell behavior continues.

Commands entered with !!<cmd> are intentionally not intercepted. They continue through Pi's normal context-excluded shell execution path unchanged.

Prerequisites

  • Pi v0.60.0 or later
  • rtk, installed and available on your PATH

If rtk is unavailable, pi-rtk still preserves normal shell behavior by falling back to the original command.

Install

Make sure your Pi installation is v0.60.0 or later before installing this package.

pi install npm:@sherif-fanous/pi-rtk

Or try without installing:

pi -e npm:@sherif-fanous/pi-rtk

To uninstall:

pi remove npm:@sherif-fanous/pi-rtk

How It Works

Agent bash tool calls

pi-rtk registers a replacement bash tool for Pi. Before the tool executes a command, the extension attempts an rtk rewrite and uses the rewritten command when available.

This preserves the normal bash tool interface while routing supported commands through rtk, which can filter and compress output before it reaches the model.

If rtk is unavailable, times out, or cannot rewrite the command, the original command runs unchanged.

Behavior summary

Agent bash tool call
        │
        ▼
pi-rtk replacement bash tool
        │
        ├─ try: rtk rewrite "<command>"
        │      │
        │      ├─ success -> execute rewritten command
        │      └─ failure -> execute original command unchanged
        │
        ▼
    same bash tool interface to Pi

User !<cmd> shell commands

pi-rtk also hooks Pi's user_bash event for context-visible user shell commands entered with !<cmd>.

For these commands, the extension probes rewrite eligibility before claiming the event. If rewrite succeeds, it returns custom bash operations so Pi can keep owning the normal execution lifecycle and UI behavior. If rewrite does not succeed, the extension falls through and Pi handles the command normally.

This keeps optimization best-effort, silent, and non-disruptive during normal operation.

Behavior summary

User !<cmd>
        │
        ├─ try: rtk rewrite "<command>"
        │      │
        │      ├─ success -> return custom bash operations
        │      └─ failure -> fall through to normal Pi user_bash handling
        │
        ▼
    same user shell experience in Pi

User !!<cmd> shell commands

Commands entered with !!<cmd> are excluded from model context by design, so pi-rtk does not intercept them.

They bypass pi-rtk completely and continue through Pi's normal context-excluded shell handling.

Behavior summary

User !!<cmd>
        │
        ▼
    bypass pi-rtk and use normal Pi context-excluded shell handling

/rtk Slash Command

pi-rtk registers a /rtk slash command for session-scoped control:

  • /rtk enable turns command rewriting on for the current Pi session.
  • /rtk disable turns command rewriting off for the current Pi session.
  • /rtk status shows the current toggle state, detected rtk binary details, and a bypass tip.
  • /rtk opens an overlay where you can choose the same actions interactively.

The footer includes a persistent pi-rtk status indicator: rtk ✓ in green when rewriting is enabled, rtk ✗ in red when disabled.

The toggle is in-memory only. It resets to enabled every time Pi restarts and is not written to disk. For a single-command bypass while leaving the session toggle enabled, use rtk's per-command form:

!RTK_DISABLED=1 <cmd>

What pi-rtk Does Not Do

pi-rtk is a rewrite shim. It does not gate, prompt for, sandbox, or deny commands based on their content, including when rtk rewrite surfaces a deny verdict.

That scope is intentional. rtk's deny verdict comes from a permission source that does not match Pi's permission model, and Pi's built-in approval flow plus Pi's extension ecosystem cover command gating better as composable layers.

If you want command-level permissions, guardrails, or shields, install a dedicated Pi extension for that. Browse pi.dev/packages filtered by extension and search for terms like permission, guardrail, or shield.

Those extensions compose with pi-rtk: they block disallowed commands at execution time, whether or not pi-rtk has rewritten the command.