pi-diet
Compact oversized Pi tool results with transparent previews and spill files.
Package details
Install pi-diet from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-diet- Package
pi-diet- Version
0.1.6- Published
- Jun 5, 2026
- Downloads
- not available
- Author
- probabilityengineer
- License
- MIT
- Types
- extension
- Size
- 20.8 KB
- Dependencies
- 0 dependencies · 2 peers
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-diet
Compact oversized Pi tool results with transparent previews and spill files.
pi-diet keeps Pi sessions lean by filtering runaway tool outputs before they bloat model context and session JSONL files. Small results pass through unchanged. Large results are saved losslessly under ~/.pi/agent/pi-diet/spills/ and replaced with a compact preview, tail, omitted-size count, and spill path.
Install
From npm:
pi install npm:pi-diet
From GitHub:
pi install git:github.com/ProbabilityEngineer/pi-diet
For local development without installing:
pi -e ./index.ts
Status
Early MVP, but validated against a real Pi session for oversized bash output.
Behavior
- pass through small tool results unchanged
- compact oversized tool results automatically via the Pi
tool_resulthook - spill full original output to disk before replacing model-visible content
- preserve transparent access to the full output via a spill-file path
- provide specialized previews for bash, read-image, noisy LSP JSON, and generic search-style output
Default thresholds
thresholdChars: 64000headChars: 8000tailChars: 8000
Commands
/diettoggles on/off/diet status/diet on/diet off
Example
Ask Pi to run a command with very large output. Instead of storing the whole result in model context, pi-diet will replace it with a compact marker and a spill path like:
[pi-diet: compacted oversized bash result]
Original size: 102955 chars
Full output: ~/.pi/agent/pi-diet/spills/...
Rescue script
Rescue a single session file:
node scripts/rescue-session.mjs ~/.pi/agent/sessions/.../session.jsonl --out /tmp/pi-diet-rescue
Rescue every session file under a directory:
node scripts/rescue-session.mjs ~/.pi/agent/sessions/some-project --out /tmp/pi-diet-rescue
Development
npm test
Safety
pi-diet does not silently discard oversized tool results. It writes the full original result to a spill file first, then replaces the model-visible content with a compact preview.