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

better-compact

v0.1.5

Published

OpenCode plugin that improves long-session context with boundary-time pruning

Downloads

649

Readme

Better Compact

OpenCode plugin that keeps long-running sessions usable with staged, pruning-first context management.

Better Compact preserves raw user intent, prunes old tool-heavy context first, writes transcript references for exact recall, and summarizes old assistant turns only when lighter pruning is not enough.

Install

Requires OpenCode 1.17.13 or a newer 1.x release. Install globally with OpenCode's built-in plugin manager:

opencode plugin better-compact --global

Install an explicit version:

opencode plugin [email protected] --global

OpenCode downloads the prebuilt package with its embedded package manager and updates both plugin configurations:

~/.config/opencode/opencode.json
~/.config/opencode/tui.json

OpenCode also preserves and updates existing opencode.jsonc and tui.jsonc files.

No separate Node.js, Bun, pnpm, npm, curl, or tar installation is required.

Restart OpenCode after installation.

Commands

  • /better-compact runs staged pruning immediately.
  • /better-compact-settings opens global compaction and summary-effort settings.

How It Works

Better Compact applies a virtual context plan to OpenCode's outgoing model request. It does not rewrite OpenCode's durable session history.

Default light mode:

  • Prunes loaded skill context.
  • Prunes old tool calls/results while preserving recent tool context.
  • Prunes thinking/reasoning only if needed.
  • Prunes remaining tool calls/results only if needed.
  • Summarizes high-value old assistant turns only if needed.
  • Writes raw transcripts under .opencode/better-compact/sessions/... for exact recall.

The TUI shows live progress, context-window bars, stages completed, and final savings.

Configuration

Better Compact searches config files in this order:

  1. ~/.config/opencode/better-compact.jsonc or better-compact.json
  2. $OPENCODE_CONFIG_DIR/better-compact.jsonc or better-compact.json
  3. .opencode/better-compact.jsonc or better-compact.json

Example:

{
    "$schema": "https://raw.githubusercontent.com/AshishKumar4/opencode-better-compact/master/better-compact.schema.json",
    "enabled": true,
    "autoUpdate": false,
    "debug": false,
    "compaction": {
        "automatic": true,
        "preset": "light",
        "summaryEffort": "inherit",
    },
}

Compaction strength:

  • Gentle (light): waits longer and preserves more recent tool output.
  • Balanced (moderate): compacts earlier and keeps a moderate recent tool window.
  • Aggressive (max): frees the most working room and keeps less old tool output verbatim.
  • Custom: choose the automatic trigger, deep-summary goal, and recent tool-output budget.

Summary effort is configured separately. inherit uses the model default. Low, medium, high, and max are applied only when the active model advertises a matching variant; unsupported levels safely fall back to the model default.

The settings panel saves global behavior to ~/.config/opencode/better-compact.jsonc, preserving comments and unrelated settings. Changes apply to subsequent manual and automatic runs without restarting OpenCode.

Uninstall

Remove better-compact from the plugin arrays in the JSON or JSONC equivalents of:

~/.config/opencode/opencode.json
~/.config/opencode/tui.json

Restart OpenCode.

Development

pnpm install
pnpm run typecheck
pnpm test
pnpm run build

For local development, point OpenCode at this checkout:

{
    "plugin": ["file:///path/to/opencode-better-compact/index.ts"]
}

For the TUI plugin, add this to ~/.config/opencode/tui.json:

{
    "plugin": ["file:///path/to/opencode-better-compact/tui.tsx"]
}

Restart OpenCode after changing plugin config.

Releases

CI uses pnpm and verifies every push/PR with:

  • typecheck
  • tests
  • host-shaped OpenTUI visual/runtime tests under Bun
  • production build
  • package verification

Tag releases as v*:

git tag v0.1.5
git push origin v0.1.5

The release workflow verifies that the tag matches package.json, builds and tests the compiled server and TUI artifacts, publishes the package to npm with provenance, and creates the GitHub Release.

Upstream

Better Compact is forked from Opencode-DCP/opencode-dynamic-context-pruning, originally published as @tarquinen/opencode-dcp by tarquinen and contributors.

This fork keeps the upstream AGPL-3.0-or-later license and builds on the original plugin architecture while changing the product direction to boundary-time context pruning and Better Compact branding.

License

AGPL-3.0-or-later