opencode-model-price-intel 0.0.0-stage → 1.1.0
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/LICENSE +21 -0
- package/NOTICE +37 -0
- package/README.md +163 -2
- package/package.json +63 -4
- package/src/aa-snapshot.ts +515 -0
- package/src/aa.ts +911 -0
- package/src/index.ts +411 -0
- package/src/pricing.ts +142 -0
- package/src/rpc.ts +65 -0
- package/src/table.ts +404 -0
- package/src/tui.tsx +207 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Christopher Joseph
|
|
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/NOTICE
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
NOTICE
|
|
2
|
+
======
|
|
3
|
+
|
|
4
|
+
Artificial Analysis data
|
|
5
|
+
------------------------
|
|
6
|
+
|
|
7
|
+
This package bundles a fallback snapshot of the Artificial Analysis Intelligence
|
|
8
|
+
Index (v5.0) captured on 2026-10-31 from the public model pages at:
|
|
9
|
+
|
|
10
|
+
https://artificialanalysis.ai/
|
|
11
|
+
|
|
12
|
+
At runtime the plugin prefers live data from the Artificial Analysis Data API
|
|
13
|
+
(when a key is configured) or the public Artificial Analysis pages. The bundled
|
|
14
|
+
snapshot is used only when live data and the plugin cache are unavailable.
|
|
15
|
+
|
|
16
|
+
Intelligence Index scores and related model data are produced by Artificial
|
|
17
|
+
Analysis. Attribution is provided in the plugin output and in this NOTICE.
|
|
18
|
+
Use of Artificial Analysis data is subject to their terms:
|
|
19
|
+
|
|
20
|
+
https://artificialanalysis.ai/terms
|
|
21
|
+
|
|
22
|
+
The snapshot is derived data and is not a substitute for the live Artificial
|
|
23
|
+
Analysis service. Do not remove this NOTICE or the attribution when
|
|
24
|
+
redistributing the package.
|
|
25
|
+
|
|
26
|
+
Some source comments in `src/aa-snapshot.ts` record that individual scores were
|
|
27
|
+
cross-checked against a third-party "llmcompare snapshot 2026-10-12". Those
|
|
28
|
+
comments are retained for provenance/traceability only; the authoritative
|
|
29
|
+
source and attribution for the bundled Intelligence Index data remains
|
|
30
|
+
Artificial Analysis.
|
|
31
|
+
|
|
32
|
+
Test fixtures
|
|
33
|
+
-------------
|
|
34
|
+
|
|
35
|
+
`test/fixtures/aa-payload.txt` is a capture of public Artificial Analysis model
|
|
36
|
+
data used only by the repository test suite. Fixtures are not included in the
|
|
37
|
+
published npm package. See `test/fixtures/README.md` for capture details.
|
package/README.md
CHANGED
|
@@ -1,3 +1,164 @@
|
|
|
1
|
-
#
|
|
1
|
+
# opencode-model-price-intel
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/chris15joseph/opencode-model-price-intel/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/opencode-model-price-intel)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
An OpenCode 2 plugin that puts **prices and the Artificial Analysis
|
|
8
|
+
Intelligence Index** next to every model in `/models`, and opens a full
|
|
9
|
+
`/model-pricing` table in a native TUI dialog when you need the details.
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
/models
|
|
13
|
+
GPT 6 Astra · in $2.5 out $15 · cache read $0.25 write $0 (2 tiers) · AA 56.9
|
|
14
|
+
Kimi K3 · in $3 out $15 · cache read $0.3 write $3 · AA n/a
|
|
15
|
+
Big Pickle · free · AA n/a
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Prices are USD per 1M tokens, read from the live OpenCode model registry. Scores
|
|
19
|
+
come from Artificial Analysis and refresh in the background. Scores are cached,
|
|
20
|
+
so the first `/models` render is instant and the network never blocks it.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
Requires OpenCode 2.2.x (the plugin pins `@opencode/plugin` to `2.2.5`) and
|
|
25
|
+
Node.js 20 or newer.
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
opencode plugin add opencode-model-price-intel
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or add it to `opencode.json(c)` yourself:
|
|
32
|
+
|
|
33
|
+
```jsonc
|
|
34
|
+
{
|
|
35
|
+
"$schema": "https://opencode.ai/config.json",
|
|
36
|
+
"plugins": ["opencode-model-price-intel"]
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Local checkout:
|
|
41
|
+
|
|
42
|
+
```jsonc
|
|
43
|
+
{
|
|
44
|
+
"$schema": "https://opencode.ai/config.json",
|
|
45
|
+
"plugins": ["/absolute/path/to/opencode-model-price-intel"]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
A plugin directory under `.opencode/plugins/` also loads automatically. Do not
|
|
50
|
+
list the same plugin twice.
|
|
51
|
+
|
|
52
|
+
### Options
|
|
53
|
+
|
|
54
|
+
```jsonc
|
|
55
|
+
{
|
|
56
|
+
"$schema": "https://opencode.ai/config.json",
|
|
57
|
+
"plugins": [
|
|
58
|
+
{
|
|
59
|
+
"package": "opencode-model-price-intel",
|
|
60
|
+
"options": {
|
|
61
|
+
"decorateNames": true,
|
|
62
|
+
"costFormat": "compact",
|
|
63
|
+
"aaApiKey": "{env:ARTIFICIALANALYSIS_API_KEY}",
|
|
64
|
+
"refreshHours": 12
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
| Option | Default | Meaning |
|
|
72
|
+
| --- | --- | --- |
|
|
73
|
+
| `decorateNames` | `true` | Append the price/score summary to `/models` names. The `/model-pricing` dialog still works when this is off. |
|
|
74
|
+
| `costFormat` | `"detailed"` | `"detailed"` renders `in $2.5 out $15 · cache read $0.25 write $0`; `"compact"` renders `$2.5/$15/$0.25/$0`. |
|
|
75
|
+
| `aaApiKey` | unset | Artificial Analysis API key. Falls back to `ARTIFICIALANALYSIS_API_KEY`. Without either, the public model-list page is used. |
|
|
76
|
+
| `refreshHours` | `12` | Score cache TTL and refresh interval, clamped to `1..596` hours. |
|
|
77
|
+
|
|
78
|
+
Invalid option values log one warning and fall back to the defaults.
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
Open the native model picker with `/models`. Each row's name carries the
|
|
83
|
+
one-line summary:
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
GPT 6 Astra · Turbo · in $2.5 out $15 · cache read $0.25 write $0 (2 tiers) · AA 56.9
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Multi-tier models show the tier count; the `/models` row itself stays a single
|
|
90
|
+
line.
|
|
91
|
+
|
|
92
|
+
For the full table, run `/model-pricing` (or `/prices`). It opens a native TUI
|
|
93
|
+
dialog with an aligned, scrollable table of every provider, price tier, cache
|
|
94
|
+
price, and AA score. Click any column header to sort by it; click the same
|
|
95
|
+
header again to reverse the order. The active header shows `▲` (ascending) or
|
|
96
|
+
`▼` (descending), and multi-tier models stay together with their continuation
|
|
97
|
+
rows. The dialog can be dismissed with `Esc`, `Ctrl+C`, or a
|
|
98
|
+
click outside. The command handler is a toggle, so invoking it again while the
|
|
99
|
+
dialog is open closes it (the dialog is modal, so `Esc` is the usual path from
|
|
100
|
+
the prompt). The table is a TUI feature; the `/models` decoration is
|
|
101
|
+
server-side and works in every client.
|
|
102
|
+
|
|
103
|
+
The TUI part asks the server for structured rows over RPC, so the dialog uses
|
|
104
|
+
the same live registry and score cache as `/models`. It does not send a prompt
|
|
105
|
+
or make a model call. The table is laid out for the current terminal width and
|
|
106
|
+
scrolls vertically (and horizontally when the window is narrow).
|
|
107
|
+
|
|
108
|
+
## How it works
|
|
109
|
+
|
|
110
|
+
- Prices come from `Model.Info.cost` in the live OpenCode registry. The plugin
|
|
111
|
+
does not bundle a price table and does not convert currencies.
|
|
112
|
+
- Scores are fetched from the Artificial Analysis Free Data API when a key is
|
|
113
|
+
configured, otherwise from the public model-list page.
|
|
114
|
+
- A bundled v5.0 snapshot (captured 2026-10-31) is registered before any
|
|
115
|
+
network or storage work, so the first render is immediate. It is only merged
|
|
116
|
+
with live data from the same **major** index version.
|
|
117
|
+
- The last good result is cached in OpenCode plugin storage for `refreshHours`.
|
|
118
|
+
A cache older than 30 days is ignored.
|
|
119
|
+
- The model registry reloads only when the score data actually changes.
|
|
120
|
+
- The TUI part is registered through the package's `./tui` export and fetches
|
|
121
|
+
the table through the server-side RPC in `./rpc`.
|
|
122
|
+
- Unscored models show `AA n/a`. A model with no registry cost shows
|
|
123
|
+
`pricing n/a` (or `n/a` in compact mode).
|
|
124
|
+
|
|
125
|
+
## Limitations
|
|
126
|
+
|
|
127
|
+
- The built-in picker has no plugin column API, so the summary is appended to
|
|
128
|
+
the model **name**. Set `decorateNames: false` to leave names untouched.
|
|
129
|
+
- Prices are catalog prices, not your invoice. Providers can add surcharges,
|
|
130
|
+
discounts, or regional pricing that the registry does not carry.
|
|
131
|
+
- AA scores are comparative within one index major version. The plugin never
|
|
132
|
+
mixes a v5 snapshot into a v6 result.
|
|
133
|
+
- The plugin only decorates the model list and renders the pricing dialog. It
|
|
134
|
+
does not route requests or change model selection.
|
|
135
|
+
- The `/model-pricing` dialog requires the TUI. Other clients still get the
|
|
136
|
+
`/models` decoration.
|
|
137
|
+
|
|
138
|
+
## Development
|
|
139
|
+
|
|
140
|
+
Requires Node.js 20 or newer.
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
npm ci
|
|
144
|
+
npm run typecheck
|
|
145
|
+
npm test
|
|
146
|
+
npm pack --dry-run
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The package exports raw TypeScript (`src/index.ts`, `src/rpc.ts`, and
|
|
150
|
+
`src/tui.tsx`); OpenCode 2.2.x transpiles it at load. Plain Node cannot import
|
|
151
|
+
the installed package from `node_modules`. The TUI part uses the host's
|
|
152
|
+
`@opentui` packages, declared as peer dependencies.
|
|
153
|
+
|
|
154
|
+
## Attribution
|
|
155
|
+
|
|
156
|
+
Scores and related model data are produced by
|
|
157
|
+
[Artificial Analysis](https://artificialanalysis.ai/). The `/model-pricing`
|
|
158
|
+
dialog carries the source, index version, capture/fetch date, and attribution
|
|
159
|
+
link. See [`NOTICE`](NOTICE) and [`SNAPSHOT-NOTICE.md`](SNAPSHOT-NOTICE.md)
|
|
160
|
+
for further provenance.
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
MIT. See [LICENSE](LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-model-price-intel",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "OpenCode 2 plugin that adds input/output/cache prices and Artificial Analysis Intelligence Index scores to /models, plus a full /model-pricing TUI dialog.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/index.ts",
|
|
8
|
+
"./rpc": "./src/rpc.ts",
|
|
9
|
+
"./tui": "./src/tui.tsx"
|
|
10
|
+
},
|
|
11
|
+
"types": "./src/index.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"src",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE",
|
|
16
|
+
"NOTICE"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=20"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@opencode/plugin": "2.2.5"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@opentui/core": ">=0.6.6",
|
|
26
|
+
"@opentui/solid": ">=0.6.6",
|
|
27
|
+
"solid-js": ">=1.9.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@opentui/core": "^0.8.3",
|
|
31
|
+
"@opentui/solid": "^0.8.3",
|
|
32
|
+
"@types/node": "22.20.5",
|
|
33
|
+
"solid-js": "^1.9.18",
|
|
34
|
+
"typescript": "5.9.3"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"test": "node --import ./scripts/register-ts.mjs --test test/*.test.ts",
|
|
39
|
+
"prepublishOnly": "npm run typecheck && npm test"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/chris15joseph/opencode-model-price-intel.git"
|
|
44
|
+
},
|
|
45
|
+
"author": "Christopher Joseph <chrisjoseph15496@gmail.com>",
|
|
46
|
+
"homepage": "https://github.com/chris15joseph/opencode-model-price-intel#readme",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/chris15joseph/opencode-model-price-intel/issues"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"keywords": [
|
|
54
|
+
"opencode",
|
|
55
|
+
"opencode-plugin",
|
|
56
|
+
"pricing",
|
|
57
|
+
"model-pricing",
|
|
58
|
+
"model-cost",
|
|
59
|
+
"artificial-analysis",
|
|
60
|
+
"intelligence-index",
|
|
61
|
+
"llm",
|
|
62
|
+
"cost"
|
|
63
|
+
],
|
|
64
|
+
"license": "MIT"
|
|
65
|
+
}
|