Skip to content
    ↑↓ select↵ openesc close
    JeffreyJYZ

    Context

    @jeffreyjyz/opencode-context·v0.1.1·Memory & Context

    Context-window breakdown for opencode: a /context dialog plus a context_breakdown tool showing where the window went (system prompt, tool definitions, thinking, tool I/O, messages), delta.app style.

    GitHub stars

    0

    Monthly installs

    0

    Composite score

    20.0

    Multi-signal model

    Last commit

    23 hours ago

    2026-10-04

    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": ["@jeffreyjyz/opencode-context@0.1.1"]
    }

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

    Context-window breakdown for opencode. /context opens a dialog showing where the window went — system prompt, tool definitions, thinking, tool inputs and outputs (split per tool), user and assistant messages — with a stacked bar and a measured used / limit header, in the style of delta.app's Context Window. A context_breakdown tool returns the same numbers as markdown so a model can ask for them itself.

    Install

    Add it to the plugins array in ~/.config/opencode/opencode.json and restart (or /reload) opencode:

    {
      "plugins": ["@jeffreyjyz/opencode-context"]
    }
    

    For local development point at the checkout instead — an absolute path is treated as a local plugin:

    {
      "plugins": ["/Users/you/dev/cmdcode-tools/opencode-context"]
    }
    

    A symlink under ~/.config/opencode/plugins/ is also picked up. After bun run build in the checkout, the root index.js / tui.js shims load dist/.

    Use

    • /context — opens the breakdown for the current session.
    • context_breakdown — the model calls it and gets the breakdown as markdown.

    How it works

    Two halves of one package, because they run in different processes:

    half file job
    server src/index.ts measures the assembled system prompt and tool definitions on every request (their sizes only) and registers the tool
    TUI src/tui.tsx the /context slash command and the dialog

    The message store holds no system prompt or tool schemas, so the server half records their byte sizes in $XDG_CACHE_HOME/opencode-context/<session>.json (one small JSON per session; no prompt text) and the dialog reads them. The rest of the breakdown comes straight from opencode's live data — the replayable context (session.context, post-compaction), the model's context limit, and the agent instructions as a fallback.

    Units: each row shows UTF-8 bytes (delta's size column) and the header shows the provider's measured tokens over the model limit. Per-row percentages are share of the byte total.

    Development

    bun install
    bun test
    bun run typecheck
    bun run build
    

    Notes

    • The System Prompt and Tool Definitions rows need one request to have happened in the session (that is when they are measured); before that the System Prompt row falls back to the agent instructions and Tool Definitions is hidden.
    • Only sizes are cached, never prompt or tool text.
    • The install cache for a published version can lag npm; see the ecosystem notes in AGENTS.md before publishing.

    Similar plugins