@xynogen/pix-optimizer

Performance optimization suite for Pi Coding Agent - caveman mode + RTK tool rewriting + jq/TOON JSON compression

Packages

Package details

extension

Install @xynogen/pix-optimizer from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@xynogen/pix-optimizer
Package
@xynogen/pix-optimizer
Version
1.0.0
Published
Jun 9, 2026
Downloads
not available
Author
xynogen
License
MIT
Types
extension
Size
72.7 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

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

README

pix-optimizer

Token-optimization suite for Pi Coding Agent. Three tools wired into one extension via src/index.ts, fronted by a single /opt command and one shared status-bar cell:

  • Caveman () — terse-output system prompt
  • RTK () — prefixes shell commands with rtk + injects RTK prompt
  • TOON () — jq + TOON guidance for dense JSON (+ bundled skill)

Command

One command routes to every tool:

/opt                  → status + help
/opt caveman <level>  → set caveman level (1/2/3/lite/full/ultra/micro/off/config)
/opt rtk [on|off]     → toggle RTK rewriting
/opt toon [on|off]    → toggle jq+TOON guidance

Status bar

A single cell always shows all three icons in a fixed order (⛏ ⚔ ✂), color- coded by state: accent when the tool is enabled, dim when disabled.

Features

Caveman Mode ()

Cuts ~75% of output tokens while keeping full technical accuracy.

# Name Description
1 lite Professional, no fluff
2 full Classic caveman
3 ultra Maximum compression
micro Experimental prompt-minimized

/opt caveman config opens a settings dialog. Default level for new sessions and status-bar visibility are saved to ~/.pi/agent/caveman.json.

RTK Tool Rewriting ()

Two layers, both active automatically:

  1. Prompt layer — injects the RTK system prompt (tells the model to prefix commands with rtk).
  2. Execute layer — rewrites bash tool calls, prefixing known commands (git, gh, cargo, npm, pnpm, docker, kubectl, ls, grep, …) with rtk when the model forgets. Command chains are split on &&, ||, ; and |, and every known segment is prefixed — e.g. git add . && git push becomes rtk git add . && rtk git push. Operators inside quotes are ignored, and unparseable commands are left untouched. Falls back gracefully when the rtk binary is missing (warns once).

Requirement: the rtk binary must be on PATH.

cargo install rtk-ai

TOON / JSON Compression ()

Guidance + a bundled toon-json skill for handling information-dense JSON via jq (query/reshape) and toon (compress). The system-prompt nudge is injected only when the user prompt mentions JSON (json/jsonl/jq/toon/ openapi/…). TOON shines on uniform/tabular arrays; deeply nested or array-of-arrays data and API contracts stay as JSON.

Requirement: jq and toon on PATH.

npm i -g @toon-format/cli

Installation

pi install git:github.com/xynogen/pix-optimizer

Architecture

File Role
src/index.ts Wires the three tools + shared status, registers /opt
src/opt.ts The /opt router: parse, complete, dispatch
src/status.ts Shared status-bar cell + OptimizerHandle contract
src/caveman.ts Caveman logic, levels, prompt, settings dialog
src/rtk.ts RTK prompt + bash command rewriting
src/json.ts jq+TOON guidance, heuristics, bundled skill registration

Each tool registers its own lifecycle hooks and exposes an OptimizerHandle that /opt dispatches to. All three share one OptimizerStatus.

Development

bun test

License

MIT