GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ProbabilityEngineer/pi-diet: Compact oversized Pi tool results with transparent previews and spill files.

BranchesTags
Open more actions menu

Latest commit

 

History

19 Commits
19 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
docs
docs
 
 
scripts
scripts
 
 
src
src
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
AGENTS.md
AGENTS.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
diet-pi-implementation-brief.md
diet-pi-implementation-brief.md
 
 
index.ts
index.ts
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

pi-diet

One of my diet context engineering and workflow extensions. Explore the complete collection: https://www.npmjs.com/~probabilityengineer

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_result hook
  • spill full original output to disk before replacing model-visible content
  • preserve transparent access to the full output via a spill-file path
  • when compacting, replace original metadata larger than 4,000 serialized characters with an omission summary and spill-file reference; retain complete metadata in the spill file
  • provide specialized previews for bash, read-image, noisy LSP JSON, and generic search-style output

Default thresholds

  • thresholdChars: 64000
  • headChars: 8000
  • tailChars: 8000

The compaction threshold includes content and metadata. The 4,000-character metadata limit applies only when a result is compacted; smaller results still pass through unchanged.

Using with SoL-Pi

pi-diet reduces oversized results immediately through the tool_result hook, including oversized metadata on the compaction path. SoL-Pi's ObservationPack instead reduces repeated replay of large text results in model-facing context while leaving stored history unchanged.

These mechanisms overlap but are not equivalent. When both are enabled, ObservationPack may archive pi-diet's compacted preview, so recovering the original can require recalling the preview and then reading its spill file. Other SoL-Pi output reducers can add further overlap. Coexistence has not been integration-tested; choose enabled mechanisms deliberately rather than assuming that more reducers are always better.

Commands

  • /diet toggles compaction between enabled and disabled.
  • /diet-footer toggles the pi-diet footer entry between visible and hidden.

The footer preference persists in ~/.pi/agent/pi-diet/config.json; the footer status is visible by default.

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.

About

Compact oversized Pi tool results with transparent previews and spill files.

Resources

Readme
MIT license
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.