opencode-model-costs 0.0.0-stage → 0.5.2

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 ADDED
@@ -0,0 +1,91 @@
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.2 — 2026-11-20
7
+
8
+ - Fixed `/models-cost` so switching between globally configured and
9
+ project-configured models updates the composer in the same session.
10
+ - Added home-screen model and reasoning-effort selection for the first prompt.
11
+ OpenCode starts the session when you submit that prompt.
12
+
13
+ ## 0.5.1 — 2026-11-20
14
+
15
+ - Enabled the price footer by default and restored its own row below the prompt
16
+ status line. It shows base input, output, cache read, and cache write prices
17
+ when they fit, with a compact input/output display on narrower terminals.
18
+ Set `footer: false` in the CLI plugin options to hide it.
19
+ - Added reasoning-effort selection for models with variants. Default or a named
20
+ variant applies with the model in one session switch. Esc cancels the selection.
21
+ - Added demo variants and refreshed the README captures to show the price table,
22
+ model details, effort picker, and cache rates in the footer.
23
+
24
+ ## 0.5.0 — 2026-11-20
25
+
26
+ - Enter in `/models-cost` opens price details. Switching is a separate action
27
+ available only for the active session that opened the browser.
28
+ - The wide table has a transparent search field and more space around the
29
+ results and keyboard hints. Narrow terminals use OpenCode’s native picker.
30
+ - Price details identify config overrides and catalog rates. Missing prices
31
+ show a dash, explicit zeroes show `$0`, and a failed config read shows a
32
+ retry message.
33
+ - The prompt footer is opt-in through CLI settings and shows one muted line of
34
+ base input and output rates.
35
+ - Added a project-local demo config with synthetic rates for two providers,
36
+ plus the integration instructions and release plan.
37
+ - Pinned the tested OpenCode 2.3.2 dependencies, consolidated on the npm lockfile,
38
+ added the MIT license, and made the JSX runtime explicit for tarball installs.
39
+
40
+ ## 0.4.0 — 2026-11-18
41
+
42
+ - `/models-cost` now renders as a monospace table in a custom modal (`ui.dialog.show`, built from
43
+ plain padded text rows): right-aligned column headers (in / out / cache read / cache write / ctx)
44
+ over a rule line, provider section rows separated by blank lines, right-aligned money columns, a
45
+ context-limit column (dropped when no model has one), and dim sub-rows for extra pricing tiers.
46
+ - Row markers: ▶ cursor, ★ configured default, ● current session model.
47
+ - Keyboard control via renderer-level key events while the dialog is open (host bindings are
48
+ paused with an exclusive input mode): up/down (j/k) move, pageup/pagedown page, home/end jump,
49
+ enter switches the session model, escape/q closes; lists longer than 18 rows scroll in a sliding
50
+ window that follows the cursor.
51
+ - Hosts without `ui.dialog.show` (or errors while opening the custom dialog) fall back to the
52
+ previous built-in select list. The content block is centered horizontally in the dialog with
53
+ left/bottom padding insets. Data layer unchanged — costs still come from opencode.json(c).
54
+
55
+ ## 0.3.4 — 2026-11-18
56
+
57
+ - 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`.
58
+ - The npm package now ships `CHANGELOG.md` instead of `PLAN.md` (no code changes).
59
+
60
+ ## 0.3.3 — 2026-11-18
61
+
62
+ - 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.
63
+ - 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.
64
+
65
+ ## 0.3.2 — 2026-11-18
66
+
67
+ - 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.
68
+
69
+ ## 0.3.1 — 2026-11-18
70
+
71
+ - All four prices on the dialog row line; the config-provenance label was dropped from the meta line.
72
+ - Prompt badge split into two rows (in/out over cache read/write).
73
+
74
+ ## 0.3.0 — 2026-11-18
75
+
76
+ - Two-line prices (in/out + cache read/write) on unclipped detail lines.
77
+ - Provider sections grouped without the duplicate provider label on every row.
78
+ - xlarge modal applied after open; removed the hidden ctrl+d tier toast.
79
+
80
+ ## 0.2.0 — 2026-11-18
81
+
82
+ - Command renamed to `/models-cost`; xlarge modal; full-width row details.
83
+ - Badge shows beside the provider from startup, falling back to the configured default model when no session has started.
84
+
85
+ ## 0.1.1 — 2026-11-18
86
+
87
+ - Aliases `cost`/`models-cost`; dialog rows no longer truncate (prices in description, meta in right-aligned footer).
88
+
89
+ ## 0.1.0 — 2026-11-18
90
+
91
+ - 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,87 @@
1
- # Temporary Holding Version
1
+ # OpenCode Model Costs
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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
+ ![OpenCode model cost table showing three demo models, cache prices, and a 200k context pricing tier](docs/images/model-costs-table.png)
6
+
7
+ The screenshot uses the repository’s synthetic pricing fixture.
8
+
9
+ ## Install from source
10
+
11
+ This plugin targets **OpenCode 2.3.2**. Installing the pinned OpenTUI dependencies with npm requires **Node.js 26.4.0 or later**.
12
+
13
+ 1. Download or clone this repository.
14
+ 2. Run `npm ci` in the checkout.
15
+ 3. Add the checkout’s absolute path to the `plugins` array in your project’s `opencode.json(c)`. For all projects, use your global OpenCode config instead.
16
+
17
+ ```json
18
+ {
19
+ "plugins": ["/absolute/path/to/opencode-model-costs"]
20
+ }
21
+ ```
22
+
23
+ Open OpenCode in your project and run `/models-cost`. From the checkout itself, the included [demo config](opencode.json) loads the plugin automatically. Run `opencode --standalone` there to try it with synthetic rates. The demo providers point to a loopback endpoint for browsing and session selection.
24
+
25
+ ## Browse and switch models
26
+
27
+ - Type to filter by model or provider. Use **↑** and **↓** to move and **Enter** to inspect prices. **Esc** clears the search, then closes the table.
28
+ - The wide view groups models by provider and shows cache prices and context tiers inline. Narrow terminals use OpenCode’s native picker.
29
+ - 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.
30
+ - On the home screen, the same action selects the model and effort for your first prompt.
31
+
32
+ ![Model details displaying the config override label, base rates, 200k tier, and context limit](docs/images/model-costs-details.png)
33
+
34
+ ![Reasoning effort picker for Demo Large with Default, low, and high options](docs/images/model-costs-effort.png)
35
+
36
+ ## Configure the footer
37
+
38
+ 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 plugin path as in the install step.
39
+
40
+ ![Prompt footer showing input, output, cache read, and cache write rates on their own row](docs/images/model-costs-footer.png)
41
+
42
+ ```json
43
+ {
44
+ "plugins": [
45
+ {
46
+ "package": "/absolute/path/to/opencode-model-costs",
47
+ "options": { "footer": false }
48
+ }
49
+ ]
50
+ }
51
+ ```
52
+
53
+ For a one-off run, pass this JSON via `OPENCODE_CLI_CONFIG_CONTENT`. [OpenCode CLI settings](https://opencode.ai/docs/cli/config/#plugins)
54
+
55
+ ## Where prices come from
56
+
57
+ 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.
58
+
59
+ 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.
60
+
61
+ Here is a model cost override for an existing provider model:
62
+
63
+ ```json
64
+ {
65
+ "providers": {
66
+ "anthropic": {
67
+ "models": {
68
+ "claude-sonnet-4": {
69
+ "cost": {
70
+ "input": 3,
71
+ "output": 15,
72
+ "cache": { "read": 0.3, "write": 3.75 }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ 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.
82
+
83
+ ## Contribute
84
+
85
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the development setup and hands-on verification steps. The [changelog](CHANGELOG.md) records releases.
86
+
87
+ 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.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.5.2",
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
+ }