npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jordyvd/pi-openai-compaction

v0.1.0

Published

OpenAI native standalone compaction replay for Pi.

Downloads

26

Readme

@jordyvd/pi-openai-compaction

A distributable Pi extension package that replays OpenAI native standalone compaction windows without patching Pi core.

This package preserves the raw compacted window returned by OpenAI's compact endpoint, stores it in Pi compaction entry details, and rewrites later supported OpenAI Responses requests to:

  • fresh current prompt envelope
  • stored opaque compacted window
  • live post-compaction tail

Supported scope

This package is intentionally narrow.

  • Providers: openai, openai-codex
  • APIs: openai-responses, openai-codex-responses
  • Failure mode: fail open back to normal Pi behavior
  • Persistence model: store the raw compacted window in CompactionEntry.details

How it works

The extension uses two hooks:

  1. session_before_compact
    • serialize the current Pi session into an OpenAI Responses-compatible compact request
    • call the compact endpoint
    • persist the returned compacted window in the compaction entry details
  2. before_provider_request
    • intercept the next supported Responses request
    • replace Pi's summary-oriented replay with native replay

Install

From a checkout of this repo:

git clone https://github.com/jordyvandomselaar/pi-codex-compaction.git
cd pi-codex-compaction
pi install .

Try without installing from the repo root:

pi -e .

After installation, run:

/reload

Configuration

Settings resolve in this order, with later layers overriding earlier ones:

  1. package-local settings.json
  2. global ~/.pi/agent/settings.json under openaiNativeCompaction
  3. project <cwd>/.pi/settings.json under openaiNativeCompaction
  4. environment variables with the PI_OPENAI_NATIVE_COMPACTION_ prefix

Default package settings:

{
  "enabled": true,
  "debug": false,
  "logProviderPayloads": false,
  "logCompactResponses": false,
  "redactSensitiveData": true,
  "artifactRoot": "~/.pi/agent/artifacts/openai-native-compaction",
  "supportedProviders": ["openai", "openai-codex"],
  "supportedApis": ["openai-responses", "openai-codex-responses"],
  "notifyOnLoad": false
}

Useful global override example:

{
  "openaiNativeCompaction": {
    "enabled": true,
    "debug": true,
    "logProviderPayloads": true,
    "logCompactResponses": true,
    "redactSensitiveData": true
  }
}

Available environment overrides:

  • PI_OPENAI_NATIVE_COMPACTION_ENABLED
  • PI_OPENAI_NATIVE_COMPACTION_DEBUG
  • PI_OPENAI_NATIVE_COMPACTION_LOG_PROVIDER_PAYLOADS
  • PI_OPENAI_NATIVE_COMPACTION_LOG_COMPACT_RESPONSES
  • PI_OPENAI_NATIVE_COMPACTION_REDACT_SENSITIVE_DATA
  • PI_OPENAI_NATIVE_COMPACTION_ARTIFACT_ROOT
  • PI_OPENAI_NATIVE_COMPACTION_SUPPORTED_PROVIDERS
  • PI_OPENAI_NATIVE_COMPACTION_SUPPORTED_APIS
  • PI_OPENAI_NATIVE_COMPACTION_NOTIFY_ON_LOAD

Debug artifacts

Artifacts are written per session under:

~/.pi/agent/artifacts/openai-native-compaction/sessions/<session-id>/

Subdirectories:

  • provider-requests/
  • compact-responses/
  • compaction-events/
  • lifecycle/

Recommended troubleshooting flow:

  1. enable debug: true
  2. enable logProviderPayloads: true
  3. keep redactSensitiveData: true
  4. /reload
  5. run /compact and then send a follow-up message
  6. inspect the newest artifact in the session directory

Package structure

package-root/
├── index.ts                    # package entrypoint declared in package.json
├── settings.json               # package-local defaults
├── src/
│   ├── extension-runtime.ts    # hook registration and top-level wiring
│   ├── settings.ts             # layered settings loader + env overrides
│   ├── debug.ts                # artifact writing + redaction helpers
│   ├── runtime.ts              # provider/api/model/baseUrl/apiKey resolution
│   ├── supported-environment.ts
│   ├── types.ts                # settings + persisted native-compaction types
│   ├── details-store.ts        # latest-valid native compaction lookup helpers
│   ├── serializer.ts           # compaction input serialization helpers
│   ├── compact-client.ts       # compact endpoint client
│   └── payload-rewrite.ts      # native replay rewrite logic
├── src/unit.test.ts
├── src/validation.test.ts
└── test/pi-smoke.test.ts

Tests

git clone https://github.com/jordyvandomselaar/pi-codex-compaction.git
cd pi-codex-compaction
bun test
bun test --coverage --coverage-reporter=text --coverage-reporter=lcov
bun test ./test/pi-smoke.test.ts