@capybearista/opencode-ram-monitor
v2.1.1
Published
Monitor OpenCode's RAM usage in real-time, right from your sidebar.
Readme
opencode-ram-monitor
Why?
This plugin gives developers real-time, zero-dependency insight into how much memory OpenCode is using. The sidebar shows the total, split into OpenCode itself (this TUI and the shared server) and the tools the server runs (MCP servers, language servers, shell commands, terminals). The
/ramcommand (and clicking the widget) opens the full process tree in a pop-up.
Philosophy: Extending OpenCode
OpenCode V2 runs one shared background server per user. Every TUI connects to it, and the server owns sessions and tool execution. Memory is shared rather than per-session, so this plugin reports it by role:
- OpenCode: this TUI (plus its own helper processes) and the server it is connected to.
- Tools: everything the server runs, plus terminal panes (
opencode-pty) that outlived a server restart.
The plugin asks OpenCode which server this TUI talks to and only trusts that answer when the local process table confirms it. It runs locally, needs no dependencies, and falls back to this TUI's own memory if the server or the process list cannot be read.
Architecture
flowchart TB
TUI["TUI plugin"] --> Widget["Sidebar widget (full or minimal)"]
TUI --> Modal["/ram modal"]
Widget --> Inspect["Server pid (client.server.info) + one process snapshot per poll"]
Modal --> Inspect
Inspect --> Roles["OpenCode = TUI + server · Tools = server's subtree + orphaned terminals"]Features
- Real-time sidebar widget: shows the total, then OpenCode vs. tools, in a compact card.
- Minimal layout: one borderless line,
RAM ● 4.88 GB (tools 3.39 GB), for a quieter sidebar. /ramcommand: opens the TUI, server, and terminal process trees in a pop-up (also opened by clicking the widget).- Cross-platform: uses native commands (
pson Unix,wmicon Windows) for lightweight zero-dependency metrics. - Configurable: layout and polling interval via plugin
options, applied live whencli.jsonchanges.
Install
OpenCode V2
Requires OpenCode 2.1 or later. This is a TUI-only plugin: add it under the "plugins" key in cli.json (your global OpenCode config directory, usually ~/.config/opencode/cli.json):
{
"plugins": ["@capybearista/opencode-ram-monitor@latest"]
}[!IMPORTANT] This plugin is TUI-only, so it belongs in
cli.json.
Upgrading from 2.0.x
- Move
experimental.ramMonitor.refreshIntervalMsinto the plugin entry'soptionsasrefreshIntervalMs(see Configuration). - Sessions without a TUI no longer have
/ram; it remains in the TUI. - The "This" / "All" rows and the session count are gone. The widget now shows OpenCode vs. Tools (see Usage).
OpenCode V1
Add it under the "plugin" key in opencode.json(c):
{
"plugin": ["@capybearista/[email protected]"]
}AND
Add it under the "plugin" key in tui.json(c):
{
"plugin": ["@capybearista/[email protected]"]
}On V1 (1.1.0), set the polling interval with experimental.ramMonitor.refreshIntervalMs (default 5000, clamped between 1000 and 60000) in opencode.json(c) or tui.json(c), globally or under .opencode/.
See the V1 plugin guide for details.
Uninstall
Remove the plugin from "plugin(s)" from the respective config files they were added to.
Usage
Once installed, the RAM monitor appears in the TUI sidebar of every session:
╭───────────────────────────────────╮
│ RAM Usage ● 4.88 GB │
│ OpenCode 1.49 GB · Tools 3.39 GB │
╰───────────────────────────────────╯- Header: total memory; the dot flips on every refresh.
- OpenCode: this TUI plus the shared server.
- Tools: MCP servers, language servers, shell commands, and terminal panes the server runs.
Type /ram or click the widget for the full process tree; esc closes it.
Configuration
Pass options in the plugin's cli.json entry, using the object form:
{
"plugins": [
{
"package": "@capybearista/opencode-ram-monitor@latest",
"options": { "layout": "minimal", "refreshIntervalMs": 2000 }
}
]
}[!WARNING] Use the object form above. The V1 tuple form (
["@capybearista/opencode-ram-monitor", { ... }]) is not valid in V2'scli.json, and one invalid entry makes OpenCode ignore the whole file, including your theme, keybinds, and every other plugin.
| Option | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| layout | "full" | "minimal" | "full" | full is the bordered two-row card. minimal is one borderless line: RAM ● 4.88 GB (tools 3.39 GB). |
| refreshIntervalMs | number | 5000 | Polling interval in milliseconds. Numeric strings are accepted. Values are clamped between 1000 and 60000. |
Invalid values fall back to the default and show a warning: as footer text in the full layout, as a warning color in the minimal layout, and listed near the top of the /ram pop-up.
The minimal layout has no room for text, so the "server not visible" and "process list unavailable" notices (see Troubleshooting) also appear only as a warning color there. The full layout and the /ram pop-up show them as text.
OpenCode re-applies a plugin's options when cli.json changes, so edits take effect without a restart. Options are only read from cli.json; the 2.0.x experimental.ramMonitor config-file key is no longer supported.
Troubleshooting
- Widget missing from sidebar: Check the entry is in the global
cli.jsonpluginslist. OpenCode does not read project-levelcli.jsonfiles. The sidebar also hides for subagent sessions and on narrow terminals (toggle it with thesession.sidebar.togglecommand). - "server not visible": The plugin could not confirm which server this TUI uses, so it shows only this TUI and its helper processes; terminal panes are left out too. This is expected when the TUI is connected with
--serverto a server on another machine, because that server's processes are not in the local process list. - "process list unavailable":
ps(orwmicon Windows) could not be run, so only this TUI's own memory is shown. Ensure standard process utilities are installed. - Windows shows only the TUI's memory: On Windows the plugin reads the process list with
wmic, which Microsoft has deprecated and newer Windows 11 releases no longer install by default. Without it, the widget falls back to this TUI's own memory with the "process list unavailable" notice. Where Windows still offers WMIC as an optional feature, enabling it restores the full numbers. WSL is unaffected; it uses the Linux path. - Other OpenCode windows are not counted: Each TUI counts itself plus the shared server and its tools. Other TUI windows connected to the same server are not included, unless one runs inside an OpenCode terminal pane, where it counts as a tool.
- Terminals missing after a server restart: Terminal panes that outlive a server restart are matched by their runtime directory under your home directory. If
XDG_STATE_HOMEpoints outside your home, they are not counted. - Tools look high: Tools include everything the server starts: MCP servers, language servers, shell commands, and terminal panes. Open
/ramto see which processes are responsible. - Options did not apply: Make sure the entry uses the object form (see Configuration) and lives in the global
cli.json.
Development Notes
Debug logging
Debug logging is disabled by default. To enable diagnostic logs during development:
OPENCODE_RAM_MONITOR_DEBUG=1 opencodeWhen enabled, the plugin appends structured JSON log lines to .opencode-ram-monitor.log in the current working directory.
Contributing
This package lives in the opencode-plugins monorepo.
See the contribution guidelines before opening a pull request.
- From the monorepo root, run
bun run buildbefore artifact checks, thenbun run typecheck,bun run lint, and the canonicalbun run testTurbo pipeline. Do not use bare rootbun testas the workspace check. - For a focused run,
bun testis supported from this package directory.bun run smokebuilds the package and loads it through OpenCode's own entry resolver. bun run checkwrites Biome changes; use it only when formatting changes are intended.- Prefer small, direct changes.
Please open an issue or check for existing ones before creating a pull request.

