{"_id":"@alexparamonov/pi-tokf","_rev":"2-f58d008ce610272f866d58af1b2f04b7","name":"@alexparamonov/pi-tokf","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@alexparamonov/pi-tokf","version":"0.1.0","keywords":["pi-package","pi","pi-extension","tokf"],"author":{"name":"AlexParamonov"},"license":"MIT","_id":"@alexparamonov/pi-tokf@0.1.0","maintainers":[{"name":"alexparamonov","email":"alexander.n.paramonov@gmail.com"}],"homepage":"https://github.com/AlexParamonov/pi-tokf#readme","bugs":{"url":"https://github.com/AlexParamonov/pi-tokf/issues"},"pi":{"extensions":["./extensions/index.ts"]},"dist":{"shasum":"388a8d4d801632e64f6bc44d7f8668a10601314e","tarball":"https://registry.npmjs.org/@alexparamonov/pi-tokf/-/pi-tokf-0.1.0.tgz","fileCount":4,"integrity":"sha512-o+iMoaZI5vLC7nIF0sdj8Cbc61CH+8nal1E5Bqrz5upN2WSR8GNq/Q/8t3tTCbXxFi1EzpDjdfUD1B87U74d3A==","signatures":[{"sig":"MEUCIQCl/viqyP64pE26SKWxOTh3z5UijyQ2jjzzL+m2dBnOawIgMDH56eK2jREn/c8EXbuw8o0PitQODsXLnKxjYJsDowc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6958},"engines":{"node":">=14"},"gitHead":"5e15f1dc5616d3fb1dccff54748c6339c871d8ae","scripts":{"typecheck":"tsc --noEmit"},"_npmUser":{"name":"alexparamonov","email":"alexander.n.paramonov@gmail.com"},"repository":{"url":"git+https://github.com/AlexParamonov/pi-tokf.git","type":"git"},"_npmVersion":"11.9.0","description":"pi extension that wraps commands through tokf for compressed output.","directories":{},"_nodeVersion":"24.14.0","_hasShrinkwrap":false,"peerDependencies":{"@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"tmp":"tmp/pi-tokf_0.1.0_1779237192263_0.5900381743597709","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Renamed to pi-tokf — use pi install npm:pi-tokf"}},"time":{"created":"2026-05-20T00:33:12.081Z","modified":"2026-05-26T13:22:35.864Z","0.1.0":"2026-05-20T00:33:12.475Z"},"bugs":{"url":"https://github.com/AlexParamonov/pi-tokf/issues"},"author":{"name":"AlexParamonov"},"license":"MIT","homepage":"https://github.com/AlexParamonov/pi-tokf#readme","keywords":["pi-package","pi","pi-extension","tokf"],"repository":{"url":"git+https://github.com/AlexParamonov/pi-tokf.git","type":"git"},"description":"pi extension that wraps commands through tokf for compressed output.","maintainers":[{"name":"alexparamonov","email":"alexander.n.paramonov@gmail.com"}],"readme":"# @alexparamonov/pi-tokf\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n[pi](https://pi.dev) extension that wraps commands through [tokf](https://github.com/mpecan/tokf) for compressed output.\n\nIntercepts bash tool calls before execution — main agent and all subagents, zero config.\n\n## How It Works\n\nThe extension hooks into pi's `tool_call` event pipeline. Every time the agent (or any subagent) runs a bash command:\n\n1. The extension calls `tokf rewrite \"<command>\"` as a subprocess\n2. If tokf returns a rewritten command, it replaces the original in the event payload with `tokf run --no-mask-exit-code <rewritten>`\n3. If tokf is missing, times out, or returns nothing, the command passes through unmodified\n\nThis mirrors the approach used in tokf's Claude Code hook, adapted for pi's event system.\n\n**Example — running 207 tests:**\n\n```\n# Without tokf\n> bash(\"cd gateway && mix test\")\nwarning: undefined module attribute @kill_timeout...\n...\nRunning ExUnit with seed: 188487, max_cases: 32\n..........................................................................\nFinished in 0.4 seconds\n207 tests, 0 failures\n\n# With tokf (rewrites to: tokf run --no-mask-exit-code cd gateway && mix test)\n✓ All tests passed\n```\n\n## Install\n\n```bash\n# Global (user settings)\npi install npm:@alexparamonov/pi-tokf\n\n# Project-local (shared via .pi/settings.json)\npi install -l npm:@alexparamonov/pi-tokf\n\n# Try without installing (current run only)\npi -e npm:@alexparamonov/pi-tokf\n\n# From git\npi install git:github.com/AlexParamonov/pi-tokf\n```\n\n## Requirements\n\n- [tokf](https://github.com/mpecan/tokf) installed and on PATH\n- Node.js >= 14\n\n## Notes\n\n- Exit codes are preserved (`--no-mask-exit-code`) so failures are never masked\n- tokf is resolved from PATH — no hardcoded paths\n- Falls back to original command on any error (never blocks execution)\n\n## Debugging\n\nWhen tokf fails (missing, timeout, error), the extension logs to stderr via `console.error()`. To see these logs, run pi with:\n\n```bash\nPI_VERBOSE=1 pi\n```\n\nThis surfaces messages like:\n- `[pi-tokf] rewrite failed: spawn tokf ENOENT` — tokf is not installed\n- `[pi-tokf] rewrite timed out after 3000ms` — slow tokf rewrite\n\n## Development\n\n```bash\ngit clone https://github.com/AlexParamonov/pi-tokf.git\ncd pi-tokf\nnpm install\nnpm run typecheck       # TypeScript validation\n```\n\nTo test the extension locally without publishing:\n\n```bash\npi -e ./extensions/index.ts\n```\n\nOr register it in a project's `.pi/settings.json`:\n\n```json\n{\n  \"extensions\": [\"./extensions/index.ts\"]\n}\n```\n","readmeFilename":"README.md"}