pi-jev-context

Reversible, relevance-based context pruning for Pi, powered by TypeSafe Jev.

Packages

Package details

extension

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

$ pi install npm:pi-jev-context
Package
pi-jev-context
Version
0.1.0
Published
Sep 18, 2026
Downloads
143/mo · 143/wk
Author
kevinpita
License
MIT
Types
extension
Size
489.3 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ],
  "image": "https://raw.githubusercontent.com/kevinpita/pi-jev-context/main/assets/preview.png"
}

Security note

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

README

A Pi extension that uses TypeSafe Jev to judge which older messages are still useful. Low-scoring content is hidden from future model requests, not deleted from your session.

Opt-in · Reversible filtering · Branch-aware cache · No extra runtime dependencies

Get started

Requires Pi 0.85.1+, Node.js 22.19+, and a TypeSafe API key. TypeSafe usage can incur charges. Jev is a separate judgment service, not your main coding model.

Install from GitHub now:

pi install git:github.com/kevinpita/pi-jev-context

After the first npm release:

pi install npm:pi-jev-context

Restart Pi or run /reload, then:

/login typesafe
/jev on

Enter your key in Pi's secret prompt. Do not paste it into a conversation. TYPESAFE_API_KEY is also supported. Pruning is off by default.

Data leaves your machine when enabled. Candidate assistant history, tool arguments, text results, and recent conversation excerpts go to https://api.typesafe.ai/v1/systemone. They can contain private code or secrets. Review your data policy before enabling this extension. No TypeSafe requests are made while disabled.

What changes?

Kept intact Eligible for judging
User requirements and system instructions Complete text-only tool call/result pairs
todo operations and extension messages Assistant text and readable thinking
Images, incomplete tool exchanges, summaries User shell history included in model context
Latest five tool pairs during active work Older eligible history outside that buffer

A candidate stays when its keep probability is greater than the threshold. The default is 0.8, so 0.81 stays and 0.80 is hidden. This is aggressive. Lower the threshold to retain more information.

Session history -> Jev relevance judgments -> Filtered model context
       |                                         |
       +-- Original messages stay intact         +-- /jev off restores visibility

You stay in control

Command Use it to
/jev on Enable pruning or resume judging after an error
/jev off Stop requests and restore unfiltered history
/jev status Inspect settings and cached judgments
/jev threshold 0.5 Keep more history using cached scores
/jev buffer 5 Protect the latest five tool pairs during active work
/jev cache on Judge only new or changed candidates, the default
/jev cache off Rejudge eligible history each time
/rejev Rejudge the active branch while idle, including hidden candidates

Visuals are illustrated previews, not live-session captures or benchmark results. The command preview uses the extension's actual notification text with sample state.

Designed for long sessions

  • Complete exchanges only. Tool calls and results are removed together. Parallel tool batches finish before judging starts.
  • Branch-aware state. Settings and successful judgments persist with the session branch.
  • Reversible decisions. /rejev can bring hidden content back when the task changes.
  • Cancellation support. New input and session navigation cancel pending scans.
  • Visible savings. A successful idle scan shows estimated context reduction. This is not a billing claim.

Know the limits

Jev can make incorrect relevance decisions. Cached scores do not automatically adapt to a new topic. Scans add latency and API usage, and filtering can invalidate your model provider's prompt cache.

On an API error, judging pauses but previously saved pruning still applies. Use /jev off to restore unfiltered context, or /rejev to retry. Pi's own compaction is separate. Jev cannot recover messages already removed by compaction. Pi's context meter can differ from the pruning estimate.

Configuration

Optional defaults go in ~/.pi/agent/jev-context.json (or your active Pi agent directory):

{
  "enabled": false,
  "threshold": 0.8,
  "buffer": 5,
  "cache": true,
  "model": "jev-latest",
  "timeoutMs": 60000
}

Session settings take precedence. The timeout covers a complete scan. Use a versioned model name for stable judgments. At idle, Jev scans without the active-tool buffer. Large candidates are split without truncation. If any fragment exceeds the threshold, the complete candidate stays.

Credentials use Pi's typesafe provider entry. A stored key takes precedence over TYPESAFE_API_KEY. /logout typesafe removes the stored key, not the environment variable. Jev does not add a chat model to /model.

Image data and tool-result details are not sent to Jev. Dynamically loaded tool definitions, unknown message types, and opaque thinking stay intact. Recent conversation excerpts are bounded and can miss earlier context.

Development

git clone https://github.com/kevinpita/pi-jev-context.git
cd pi-jev-context
npm ci
npm run check
npm run test:package
pi -e ./src/index.ts

Tests use synthetic history and mocked HTTP responses. They need no API key and make no TypeSafe requests. CI checks Node 22.19 and 24, strict types, Biome, behavior tests, and the packed extension through Pi's loader.

License

MIT © Kevin Pita. Independent community extension, not an official Pi or TypeSafe product.