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

@madsoftwaredev/opencode-compaction-model

v0.1.2

Published

OpenCode V2 plugin that summarizes checkpoints with a dedicated compaction model and variant.

Readme

@madsoftwaredev/opencode-compaction-model

Summarizes local checkpoint compaction with a dedicated model and variant while the session keeps its selected working model.

opencode plugin add @madsoftwaredev/opencode-compaction-model

Choose the compaction model

Set options.model in your global ~/.config/opencode/opencode.json or your project's opencode.json (JSONC also works). If the CLI already added a string entry for this package, replace that entry with the object below, keeping your other plugins:

{
  "$schema": "https://opencode.ai/config.json",
  "plugins": [
    {
      "package": "@madsoftwaredev/opencode-compaction-model",
      "options": {
        "model": "deepseek/deepseek-flash#max"
      }
    }
  ]
}

Use provider/model#variant, with #variant optional. Choose an enabled model and supported reasoning variant from /models, using a provider connected in OpenCode. The example selects direct DeepSeek; you can select another provider and model the same way. Omitting #variant uses that model's default settings.

When model options are omitted, the default is opencode-go/deepseek-v4.1-flash#max, which requires an OpenCode Go connection. This default is overridable. The separate providerID, modelID, and variant options are also supported; a full model string takes precedence over them.

There is no default character cutoff. Optional maxTranscriptChars is a guard: exceeding it logs a fallback rather than silently deleting the middle of the history.

Why the Go adapter exists

In OpenCode 2.0.8–2.0.9, ctx.generate.text() makes a stateless request without x-opencode-session. OpenCode Go rejects that request. The plugin's Go adapter uses the existing OpenCode connection, catalog endpoint, model ID, and variant, and sends the originating session ID to the chat-completions endpoint. It does not store an API key or change the session's model. Other providers use the native ctx.generate.text() API.

Starting with 0.1.2, credential lookup checks the model's own provider integration first, then the integration ID reported by the provider, accepting only API-key credentials. OpenCode Go can report the Console integration, whose active connection may be OAuth rather than the Go API key. Earlier releases used only that reported integration, causing compaction to fall back even when a Go key was connected. The fix does not embed connection IDs, keys, or endpoint URLs; it uses the selected model and runtime provider metadata.

The Go adapter currently supports models using @opencode/ai/providers/openai-compatible (including the default DeepSeek model). Other Go protocols produce a diagnostic and fall back to normal compaction.

Check a compaction

Successful checkpoints carry this metadata:

{
  "compactionModel": "opencode-go/deepseek-v4.1-flash#max",
  "compactionPlugin": "compaction-model"
}

OpenCode still stamps the checkpoint's top-level model with the session's working model. Check metadata.compactionModel to identify the actual summarizer:

opencode api get '/api/session/SESSION_ID/message?type=compaction&order=desc&limit=1'

Successes and fallbacks are logged in ~/.local/share/opencode/log/compaction-model.log (or beneath $XDG_DATA_HOME). The log does not include transcripts, summaries, credentials, or Go response bodies.

Summary and failure behavior

  • Sends the full supplied text/tool transcript, including prior checkpoints. Binary media is represented by a filename/type descriptor.
  • Requires the checkpoint headings and retries an invalid summary once with the original transcript. Empty, truncated, or twice-invalid summaries are not installed.
  • Go requests have a three-minute timeout and a 32,768-token output ceiling.
  • On failure, logs the reason and lets OpenCode use the session's normal compaction.
  • OpenCode owns automatic scheduling, recent-context retention, and checkpoint installation. The plugin handles requests delivered to the compaction hook; native provider checkpoint routes are outside this adapter's verification.

Verification

From the repository root:

bun test ./packages/compaction-model/index.test.js

The regression suite covers Go session routing, provider/integration mismatches and credential fallback, concurrent sessions, variant selection, long-history preservation, invalid/truncated results, and logged fallback. A live scratch session using Muse was manually compacted with DeepSeek and its checkpoint metadata verified.

References: V2 plugin hooks, V2 compaction.

License

MIT