pi-compact-jev

A Pi Coding Agent extension that uses Jev to prune conversation history during compaction while preserving retained text verbatim.

Packages

Package details

extension

Install pi-compact-jev from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-compact-jev
Package
pi-compact-jev
Version
0.5.1
Published
Sep 20, 2026
Downloads
184/mo · 184/wk
Author
wb1936
License
MIT
Types
extension
Size
124 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./src/extension.ts"
  ]
}

Security note

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

README

pi-compact-jev

Uses Jev to compact Pi Coding Agent conversations by removing or shortening tool output and preserving retained text verbatim. Automatic compaction is enabled by default; if Jev pruning cannot be used, Pi falls back to its built-in summarizer.

Install

Choose one installation source.

pi install npm:pi-compact-jev
pi install git:github.com/dev-willbird1936/pi-jev-compact

Restart Pi, or run /reload in an existing session.

What it does

When Pi would summarize a dropped prefix, this extension scores unpinned tool calls with Jev:

  • not useful → delete the call
  • useful and needed in full → keep the output word for word
  • useful but not full → keep the first and last 25% of the output, each capped at 2,500 characters

Unresolved errors, git commits, edits, writes, images, and invoked skills skip Jev and stay. Auto-compact can call Pi compact() after a settled turn. At 512,000 tokens it compacts without waiting for Jev.

Scoring sends selected conversation, tool output, and workspace context to TypeSafe or OpenRouter. It does not share Pi’s live session cache.

Exact prune path: HOW.md.

Commands

Command Effect
/jev-compact Compact now
/jev-compact on / off Enable or disable the package
/jev-compact-config Settings menu

Status bar: compact:auto, compact:jev, compact:off, or compact:no key.

Requirements

  • Node.js >=22.19.0
  • Pi Coding Agent >=0.84.0
  • Pi compaction enabled (settings.json → "compaction": { "enabled": true })
  • A Jev key (TypeSafe first, else OpenRouter)

Keys, in order:

  • TypeSafe: TYPESAFE_API_KEY or JEV_API_KEY, then ~/.brain/secrets/typesafe-api-key.txt or ~/.brain/secrets/jev-api-key.txt
  • OpenRouter: OPENROUTER_API_KEY, then ~/.brain/secrets/openrouter-api-key.txt

provider: auto uses a TypeSafe/Jev key when present, otherwise OpenRouter.

Configuration

~/.pi/agent/pi-jev-compact.json is created on first load. /jev-compact on|off writes enabled. /jev-compact-config edits the rest.

Field Default Role
enabled true Hook no-ops when false
provider auto typesafe, openrouter, or auto
autoCompact true After a settled turn, Jev may call Pi compact()
minContextTokens 64000 Auto-compact will not judge below this
forceCompactTokens 512000 Compact without Jev at this size
keepThreshold 0.5 Minimum useful score to keep
preserveRecentTurns 5 Last N user and N assistant windows
windowChars 2000 Stored head/tail per windowed prompt/reply
maxStateTokens 28000 Fitted Jev state ceiling
maxRequestTokens 64000 State plus one batch of questions
truncateHeadChars 2500 Max chars at each end of a stubbed dump
minReduction 0.25 Else fall back to Pi’s summarizer
timeoutMs 30000 Per Jev request
debug false Log stats to stderr

Development

bun test
bun run typecheck

By dev-willbird1936.