opencode-model-costs 0.0.0-stage → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +96 -0
- package/LICENSE +21 -0
- package/README.md +94 -2
- package/package.json +39 -4
- package/src/costs.ts +540 -0
- package/src/index.ts +17 -0
- package/src/tui.tsx +898 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `opencode-model-costs` per released version, newest first.
|
|
4
|
+
On every version bump, add an entry here at the top.
|
|
5
|
+
|
|
6
|
+
## 0.5.3 — 2026-11-20
|
|
7
|
+
|
|
8
|
+
- Documented installing the plugin from npm globally or per project, pinning a
|
|
9
|
+
release, and configuring the footer for an npm installation.
|
|
10
|
+
|
|
11
|
+
## 0.5.2 — 2026-11-20
|
|
12
|
+
|
|
13
|
+
- Fixed `/models-cost` so switching between globally configured and
|
|
14
|
+
project-configured models updates the composer in the same session.
|
|
15
|
+
- Added home-screen model and reasoning-effort selection for the first prompt.
|
|
16
|
+
OpenCode starts the session when you submit that prompt.
|
|
17
|
+
|
|
18
|
+
## 0.5.1 — 2026-11-20
|
|
19
|
+
|
|
20
|
+
- Enabled the price footer by default and restored its own row below the prompt
|
|
21
|
+
status line. It shows base input, output, cache read, and cache write prices
|
|
22
|
+
when they fit, with a compact input/output display on narrower terminals.
|
|
23
|
+
Set `footer: false` in the CLI plugin options to hide it.
|
|
24
|
+
- Added reasoning-effort selection for models with variants. Default or a named
|
|
25
|
+
variant applies with the model in one session switch. Esc cancels the selection.
|
|
26
|
+
- Added demo variants and refreshed the README captures to show the price table,
|
|
27
|
+
model details, effort picker, and cache rates in the footer.
|
|
28
|
+
|
|
29
|
+
## 0.5.0 — 2026-11-20
|
|
30
|
+
|
|
31
|
+
- Enter in `/models-cost` opens price details. Switching is a separate action
|
|
32
|
+
available only for the active session that opened the browser.
|
|
33
|
+
- The wide table has a transparent search field and more space around the
|
|
34
|
+
results and keyboard hints. Narrow terminals use OpenCode’s native picker.
|
|
35
|
+
- Price details identify config overrides and catalog rates. Missing prices
|
|
36
|
+
show a dash, explicit zeroes show `$0`, and a failed config read shows a
|
|
37
|
+
retry message.
|
|
38
|
+
- The prompt footer is opt-in through CLI settings and shows one muted line of
|
|
39
|
+
base input and output rates.
|
|
40
|
+
- Added a project-local demo config with synthetic rates for two providers,
|
|
41
|
+
plus the integration instructions and release plan.
|
|
42
|
+
- Pinned the tested OpenCode 2.3.2 dependencies, consolidated on the npm lockfile,
|
|
43
|
+
added the MIT license, and made the JSX runtime explicit for tarball installs.
|
|
44
|
+
|
|
45
|
+
## 0.4.0 — 2026-11-18
|
|
46
|
+
|
|
47
|
+
- `/models-cost` now renders as a monospace table in a custom modal (`ui.dialog.show`, built from
|
|
48
|
+
plain padded text rows): right-aligned column headers (in / out / cache read / cache write / ctx)
|
|
49
|
+
over a rule line, provider section rows separated by blank lines, right-aligned money columns, a
|
|
50
|
+
context-limit column (dropped when no model has one), and dim sub-rows for extra pricing tiers.
|
|
51
|
+
- Row markers: ▶ cursor, ★ configured default, ● current session model.
|
|
52
|
+
- Keyboard control via renderer-level key events while the dialog is open (host bindings are
|
|
53
|
+
paused with an exclusive input mode): up/down (j/k) move, pageup/pagedown page, home/end jump,
|
|
54
|
+
enter switches the session model, escape/q closes; lists longer than 18 rows scroll in a sliding
|
|
55
|
+
window that follows the cursor.
|
|
56
|
+
- Hosts without `ui.dialog.show` (or errors while opening the custom dialog) fall back to the
|
|
57
|
+
previous built-in select list. The content block is centered horizontally in the dialog with
|
|
58
|
+
left/bottom padding insets. Data layer unchanged — costs still come from opencode.json(c).
|
|
59
|
+
|
|
60
|
+
## 0.3.4 — 2026-11-18
|
|
61
|
+
|
|
62
|
+
- Added a README explaining what the plugin does, how to enable it, and the `cost` config shape; added a `CHANGELOG.md` and agent-facing `AGENTS.md`.
|
|
63
|
+
- The npm package now ships `CHANGELOG.md` instead of `PLAN.md` (no code changes).
|
|
64
|
+
|
|
65
|
+
## 0.3.3 — 2026-11-18
|
|
66
|
+
|
|
67
|
+
- Prompt badge is now a single line ("in … · out … · cache read … · cache write") on the row directly under the prompt's status row, replacing the two-row badge beside the agent/model info.
|
|
68
|
+
- The badge aligns with the prompt box's left edge on every route — the offset is tracked against the footer row instead of terminal column 0, so it stays visible in sessions where the tab rail and route padding sit left of the prompt.
|
|
69
|
+
|
|
70
|
+
## 0.3.2 — 2026-11-18
|
|
71
|
+
|
|
72
|
+
- The dialog resizes itself to the smallest host size that fits the widest rendered line (medium/large/xlarge auto-fit) instead of always opening at xlarge.
|
|
73
|
+
|
|
74
|
+
## 0.3.1 — 2026-11-18
|
|
75
|
+
|
|
76
|
+
- All four prices on the dialog row line; the config-provenance label was dropped from the meta line.
|
|
77
|
+
- Prompt badge split into two rows (in/out over cache read/write).
|
|
78
|
+
|
|
79
|
+
## 0.3.0 — 2026-11-18
|
|
80
|
+
|
|
81
|
+
- Two-line prices (in/out + cache read/write) on unclipped detail lines.
|
|
82
|
+
- Provider sections grouped without the duplicate provider label on every row.
|
|
83
|
+
- xlarge modal applied after open; removed the hidden ctrl+d tier toast.
|
|
84
|
+
|
|
85
|
+
## 0.2.0 — 2026-11-18
|
|
86
|
+
|
|
87
|
+
- Command renamed to `/models-cost`; xlarge modal; full-width row details.
|
|
88
|
+
- Badge shows beside the provider from startup, falling back to the configured default model when no session has started.
|
|
89
|
+
|
|
90
|
+
## 0.1.1 — 2026-11-18
|
|
91
|
+
|
|
92
|
+
- Aliases `cost`/`models-cost`; dialog rows no longer truncate (prices in description, meta in right-aligned footer).
|
|
93
|
+
|
|
94
|
+
## 0.1.0 — 2026-11-18
|
|
95
|
+
|
|
96
|
+
- First release: `/model-cost` command (palette + slash, aliases) with model switching on Enter, and a four-price prompt-footer badge.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 opencode-model-costs contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,95 @@
|
|
|
1
|
-
#
|
|
1
|
+
# OpenCode Model Costs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Compare input, output, and cache prices across models without leaving the [OpenCode](https://opencode.ai) terminal. Prices are in **USD per million tokens**. Open `/models-cost` to browse rates before choosing a model.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
The screenshot uses the repository’s synthetic pricing fixture.
|
|
8
|
+
|
|
9
|
+
## Install from npm
|
|
10
|
+
|
|
11
|
+
This plugin targets **OpenCode 2.3.2**. Run this command to install it and add it to your global OpenCode config. [OpenCode plugin commands](https://opencode.ai/docs/cli/commands/#plugin)
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
opencode plugin add opencode-model-costs
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Start or restart OpenCode and run `/models-cost`.
|
|
18
|
+
|
|
19
|
+
### Install for one project
|
|
20
|
+
|
|
21
|
+
Add `opencode-model-costs` to the `plugins` array in the project’s `opencode.json` or `opencode.jsonc`.
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"plugins": ["opencode-model-costs"]
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
OpenCode installs the plugin from npm when it loads the configuration. To pin a release, use `opencode-model-costs@0.5.3` in the `plugins` array or as the argument to `opencode plugin add`. [OpenCode plugin configuration](https://opencode.ai/docs/build/plugins/#load)
|
|
30
|
+
|
|
31
|
+
## Browse and switch models
|
|
32
|
+
|
|
33
|
+
- Type to filter by model or provider. Use **↑** and **↓** to move and **Enter** to inspect prices. **Esc** clears the search, then closes the table.
|
|
34
|
+
- The wide view groups models by provider and shows cache prices and context tiers inline. Narrow terminals use OpenCode’s native picker.
|
|
35
|
+
- In a session, choose **Switch to this model** or **Choose reasoning effort** if the model has variants. Pick **Default** or a named variant to apply the model and effort together. Esc cancels the picker and keeps the current selection. Switching applies to the current session and leaves config files untouched.
|
|
36
|
+
- On the home screen, the same action selects the model and effort for your first prompt.
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
## Configure the footer
|
|
43
|
+
|
|
44
|
+
By default, the footer shows the current model’s base rates on a separate row below the prompt status line. It includes cache read and write when pricing is available and the line fits. On narrow terminals it shows input and output only. To hide it on OpenCode 2.3.2, set `footer: false` on the plugin entry in your terminal client’s `cli.json` (typically `~/.config/opencode/cli.json`). Use the same package reference as in your `opencode.json(c)`.
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"plugins": [
|
|
51
|
+
{
|
|
52
|
+
"package": "opencode-model-costs",
|
|
53
|
+
"options": { "footer": false }
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
For a one-off run, pass this JSON via `OPENCODE_CLI_CONFIG_CONTENT`. [OpenCode CLI settings](https://opencode.ai/docs/cli/config/#plugins)
|
|
60
|
+
|
|
61
|
+
## Where prices come from
|
|
62
|
+
|
|
63
|
+
The plugin reads configuration declarations and model prices through the OpenCode client. When you declare a provider in `opencode.json(c)`, the browser lists only the models declared in config. With no provider declarations, it lists the configured catalog instead.
|
|
64
|
+
|
|
65
|
+
Model details identify configured overrides and catalog rates. **`$0`** means the source reported zero. **`—`** means a rate was unavailable. The plugin displays rates, while OpenCode tracks session spend separately.
|
|
66
|
+
|
|
67
|
+
Here is a model cost override for an existing provider model:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"providers": {
|
|
72
|
+
"anthropic": {
|
|
73
|
+
"models": {
|
|
74
|
+
"claude-sonnet-4": {
|
|
75
|
+
"cost": {
|
|
76
|
+
"input": 3,
|
|
77
|
+
"output": 15,
|
|
78
|
+
"cache": { "read": 0.3, "write": 3.75 }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Use an array of cost entries for tiered pricing. A context tier adds `"tier": { "type": "context", "size": 200000 }` to the entry that applies above that threshold. See the [demo config](opencode.json) for a complete example. Legacy `provider` declarations and V1-shaped cost fields are also recognized by the V2 plugin.
|
|
88
|
+
|
|
89
|
+
## Contribute
|
|
90
|
+
|
|
91
|
+
To run from source, clone this repository and run `npm ci` with Node.js 26.4.0 or later. Run `opencode --standalone` in the checkout to try the included demo config with synthetic rates. To use the checkout in another project, add its absolute path to that project’s `plugins` array.
|
|
92
|
+
|
|
93
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for hands-on verification steps. The [changelog](CHANGELOG.md) records releases.
|
|
94
|
+
|
|
95
|
+
Released under the [MIT License](LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-model-costs",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.5.3",
|
|
4
|
+
"description": "Compare model rates in the OpenCode TUI with an optional prompt footer.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.ts",
|
|
9
|
+
"./tui": "./src/tui.tsx"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"src",
|
|
13
|
+
"CHANGELOG.md"
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@opencode/plugin": "2.3.2"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@opentui/core": "0.8.4",
|
|
20
|
+
"@opentui/solid": "0.8.4",
|
|
21
|
+
"solid-js": "1.9.17"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"typescript": "5.9.3"
|
|
25
|
+
},
|
|
26
|
+
"author": {
|
|
27
|
+
"name": "Elcris1"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/Elcris1/opencode-cost-plugin.git"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/Elcris1/opencode-cost-plugin#readme",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/Elcris1/opencode-cost-plugin/issues"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
}
|
|
41
|
+
}
|