Skip to content

plugins: add opencode-cost-guard: Warn or stop your OpenCode session …#288

Open
jjmartres wants to merge 1 commit intoawesome-opencode:mainfrom
jjmartres:add-opencode-cost-guard
Open

plugins: add opencode-cost-guard: Warn or stop your OpenCode session …#288
jjmartres wants to merge 1 commit intoawesome-opencode:mainfrom
jjmartres:add-opencode-cost-guard

Conversation

@jjmartres
Copy link
Copy Markdown

…when it hits a spending limit

Submission Type

  • Plugin
  • Project
  • Theme
  • Agent
  • Resource

Details

Name: opencode-cost-guard
Repository: https://github.com/jjmartres/opencode-cost-guard
Tagline: Warn or stop your OpenCode session when it hits a spending limit
Description:

  opencode-cost-guard monitors your session cost in real time and fires a
  warning message when you approach your budget, then a limit-reached alert
  when you cross it.
  OpenCode has no built-in per-session cost cap. This plugin fills that gap
  with a single line of config.
  **Features**
  - Early warning at a configurable percentage of your budget (default 80%)
  - Hard limit alert in warn or block mode when the threshold is crossed
  - Each alert fires once per session — no spam
  - Per-project config overrides the global one
  - Zero dependencies, one line to install
  **Install**
  Add to `~/.config/opencode/opencode.json`:
  ```json
  { "plugins": ["opencode-cost-guard"] }

  **Configure**
  Drop a cost-guard.config.json in ~/.config/opencode/:
  ```json
  {
    "maxCostUsd": 20.0,
    "warnAtPercent": 80,
    "mode": "warn"
  }

  Set mode to "block" to stop the session when the limit is reached.
  Set COST_GUARD_DEBUG=1 to enable verbose per-event logging.

  Note: The limit is reactive — it fires after a response completes,
  not before. One expensive response can push you over before the plugin
  catches it.

Checklist

  • Relevant to OpenCode
  • Repository is public and accessible
  • Actively maintained
  • Not a duplicate
  • YAML file in correct folder (data/{category}/)
  • Filename is kebab-case (e.g., my-plugin.yaml)

YAML Format

Create a file in data/{category}/your-entry.yaml:

name: Your Entry Name
repo: https://github.com/owner/repo
tagline: Short punchy summary (shown in collapsed view)
description: Longer description explaining what it does.

See contributing.md for full instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant