Skip to content
    ↑↓ select↵ openesc close
    English中文
    bendtherules

    Compaction Prompt

    v0.3.1Other
    opencode-plugin-compaction-prompt

    Customize OpenCode's compaction prompt to preserve important context and omit unnecessary details.

    GitHub stars

    0

    Monthly installs

    1,147

    51 in 7 days

    Composite scoreSCORE

    38.7

    Multi-signal model

    Last commit

    9 days ago

    2026-08-11

    Install and configure

    opencode.json

    Writes to this project's opencode.json — applies to this repository only.

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-plugin-compaction-prompt@0.3.1"]
    }

    opencode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.

    Compact fearlessly with priority-aware compaction.

    When you work across multiple features, OpenCode's default compaction doesn't know how to distinguish active work from older discussions, so it gives them equal priority. This can make important current details easy to lose.

    Customize OpenCode's compaction prompt for priority-aware compaction, deciding which messages are prioritized or discarded in the next session. Specify which discussions to discard and which decisions, files, and snippets to prioritize in the summary.

    GitHub · npm

    Install

    opencode plugin -g opencode-plugin-compaction-prompt
    

    This installs the plugin in your global OpenCode configuration. To install it for one project only, omit -g.

    You can also add it manually to your global opencode.jsonc:

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": [
        [
          "opencode-plugin-compaction-prompt",
          {
            "memoryFile": ".opencode/compaction.md",
            "mode": "append",
            "completionMarker": "opencode-plugin-compaction-prompt: Custom compaction done."
          }
        ]
      ]
    }
    

    Create .opencode/compaction.md in the project when you have project-specific context to preserve. The file is optional.

    /plugin-compaction-init

    • Writes the memory file at the configured memoryFile path with a top instruction line and ## Keep and ## Discard sections containing classification rules for which messages to preserve or drop.
    • Recommended: pass user instructions to extend the default rules with concrete topics — specific areas of discussion you want kept or dropped.

    Options

    Option Default Description
    memoryFile .opencode/compaction.md File resolved relative to the active worktree.
    mode append Append instructions to OpenCode's default prompt, or use replace to provide a complete prompt.
    prompt "" (empty) Additional instructions used together with memoryFile; both are included in the compaction instructions.
    completionMarker opencode-plugin-compaction-prompt: Custom compaction done. Exact text the model is asked to append at the end of the summary.

    Append mode is the recommended default because it preserves OpenCode's built-in compaction behavior. Replace mode is available when the complete prompt needs to be controlled by this plugin.

    When neither a prompt nor a memory file is available, the plugin asks the model to echo opencode-plugin-compaction-prompt: No custom compaction applied. instead.

    Development

    bun install
    bun test
    bun run typecheck
    bun run build
    bun run pack:check
    

    The npm package exposes the compiled entrypoint at dist/index.js and TypeScript declarations at dist/index.d.ts.

    Publishing

    Update the changelog

    Add the changes for the new version to CHANGELOG.md.

    Verify the release

    bun run format:check
    bun test
    bun run typecheck
    bun run build
    bun run pack:check
    

    Publish the release

    npm version minor -m "chore: release v%s"
    git push origin main --follow-tags
    VERSION="$(node -p "require('./package.json').version")"
    gh release create "v$VERSION" --generate-notes
    npm publish
    

    Use npm version patch or npm version major when appropriate. npm publish rebuilds dist/ automatically.

    Compatibility

    The plugin uses OpenCode's experimental.session.compacting hook. OpenCode may change experimental plugin APIs between releases; test the package against the OpenCode version you support.