@chenlongapps/opencode-token-usage 0.4.25 → 0.4.26
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/README.md +6 -3
- package/README.zh-CN.md +6 -3
- package/dist/prices.generated.d.ts +83 -1
- package/dist/prices.generated.js +5 -1
- package/dist/pricing.d.ts +1 -1
- package/docs/verification.md +10 -0
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
<a href="https://github.com/chenlongapps/opencode-token-usage/blob/main/README.zh-CN.md">简体中文</a>
|
|
16
16
|
</p>
|
|
17
17
|
|
|
18
|
+
[](https://www.npmjs.com/package/@chenlongapps/opencode-token-usage)
|
|
19
|
+
|
|
18
20
|
### Overview
|
|
19
21
|
|
|
20
22
|
**opencode-token-usage** is a community plugin that brings token usage, context window occupancy, estimated cost and performance metrics into OpenCode 2's terminal interface.
|
|
@@ -30,8 +32,6 @@ Use it to see how many tokens a session and its subagents consume, how full the
|
|
|
30
32
|
- **Native terminal UI:** Keep a sidebar panel in the main session and a single-line summary in subagent views; open details only when needed.
|
|
31
33
|
- **On-demand details:** Use `/token-usage` for compact or detailed statistics, including per-model usage and rates, without sending a prompt to the model.
|
|
32
34
|
|
|
33
|
-
[](https://www.npmjs.com/package/@chenlongapps/opencode-token-usage)
|
|
34
|
-
|
|
35
35
|
---
|
|
36
36
|
|
|
37
37
|
### Installation
|
|
@@ -142,17 +142,20 @@ Costs follow the sidebar's pricing and `partial`/unavailable/free conventions. I
|
|
|
142
142
|
|
|
143
143
|
```bash
|
|
144
144
|
npm ci
|
|
145
|
+
npm run lint
|
|
145
146
|
npm run typecheck
|
|
146
147
|
npm test
|
|
147
148
|
npm run build
|
|
148
149
|
npm run test:smoke
|
|
149
150
|
```
|
|
150
151
|
|
|
152
|
+
Lint uses ESLint 10 Flat Config with the JavaScript/TypeScript recommended rules, without formatting or React rules. It covers source, tests, scripts, and root JavaScript files, excluding build output, dependencies, temporary directories, and the generated price snapshot. Use `npm run lint:fix` for supported automatic fixes. On Node 22, ESLint requires >=22.13; Node >=24 is also supported. This development-tool requirement does not change the plugin's Node.js 22+ runtime minimum.
|
|
153
|
+
|
|
151
154
|
For native TTFT/TPS checks on a host with `time.firstToken`, run `npm run test:smoke -- --performance-only`. This targeted lane verifies streaming timing, the native footer and history restoration after reopening; it does not replace the full integration suite.
|
|
152
155
|
|
|
153
156
|
The OpenCode SDK packages are pinned to `2.3.0`, with OpenTUI `0.8.4` and Solid/compiler `1.9.16`. OpenTUI declares Node.js `>=26.4.0` for its native Node runtime, so npm reports `EBADENGINE` on Node 22; `engine-strict` installations require a Node version meeting that dependency's engine requirement. The plugin's TUI runs inside OpenCode, not as a standalone Node 22 renderer. The project's Node.js 22+ minimum is unchanged; see the [verification record](docs/verification.md) for checks of this dependency set.
|
|
154
157
|
|
|
155
|
-
The [price update workflow](.github/workflows/update-prices.yml) checks models.dev every 4 hours (or on demand via **Run workflow** on `main`). No snapshot diff means no release. Changes within the reviewed first-party source allowlist pass typecheck, tests, build, and pack validation, then automatically bump the patch version (for example, `0.4.4` → `0.4.5`), commit only `src/prices.generated.ts`, `package.json`, and `package-lock.json`, and atomically push `main` and its version tag. The workflow creates a GitHub Release and explicitly dispatches [`publish.yml`](.github/workflows/publish.yml) on that tag to publish via npm Trusted Publishing/OIDC; no long-lived npm token is needed. GitHub Actions must be allowed to push to `main` and create tags, and npm must trust `publish.yml` with permission to run `npm publish`.
|
|
158
|
+
The [price update workflow](.github/workflows/update-prices.yml) checks models.dev every 4 hours (or on demand via **Run workflow** on `main`). No snapshot diff means no release. Changes within the reviewed first-party source allowlist pass lint, typecheck, tests, build, and pack validation, then automatically bump the patch version (for example, `0.4.4` → `0.4.5`), commit only `src/prices.generated.ts`, `package.json`, and `package-lock.json`, and atomically push `main` and its version tag. The workflow creates a GitHub Release and explicitly dispatches [`publish.yml`](.github/workflows/publish.yml) on that tag to publish via npm Trusted Publishing/OIDC; no long-lived npm token is needed. GitHub Actions must be allowed to push to `main` and create tags, and npm must trust `publish.yml` with permission to run `npm publish`.
|
|
156
159
|
|
|
157
160
|
Failed validation never bumps the version. An unfinished tagged price release is retried with the same version before checking new prices; registry outages are not treated as missing versions. Publishing skips versions already on npm, prevents moving `latest` backwards, and polls registry visibility for up to 10 minutes after publication, logging progress. A verification timeout is not proof that `npm publish` failed: check the registry and retry the same tag without bumping the version; already-published versions are not republished. Manufacturer/source allowlist additions, aliases, and manually verified price exceptions still require human review. See the [release guide](docs/releasing.md) for setup, verification timing, and retries.
|
|
158
161
|
|
package/README.zh-CN.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
<strong>简体中文</strong>
|
|
16
16
|
</p>
|
|
17
17
|
|
|
18
|
+
[](https://www.npmjs.com/package/@chenlongapps/opencode-token-usage)
|
|
19
|
+
|
|
18
20
|
### 项目简介
|
|
19
21
|
|
|
20
22
|
**opencode-token-usage** 是一个面向 OpenCode 2 的社区插件,在终端界面中展示 token 用量、上下文窗口占用、估算费用和性能指标。
|
|
@@ -30,8 +32,6 @@
|
|
|
30
32
|
- **原生终端界面:** 主会话使用侧边栏,子代理视图保留单行摘要,按需打开完整面板。
|
|
31
33
|
- **按需查看详情:** 通过 `/token-usage` 切换紧凑/详细统计,查看各模型的用量与费率,不向模型发送提示词。
|
|
32
34
|
|
|
33
|
-
[](https://www.npmjs.com/package/@chenlongapps/opencode-token-usage)
|
|
34
|
-
|
|
35
35
|
---
|
|
36
36
|
|
|
37
37
|
### 安装
|
|
@@ -142,17 +142,20 @@ OpenCode **2.3.0 现已通过完整检查**,包含插件详情与原生 `/usag
|
|
|
142
142
|
|
|
143
143
|
```bash
|
|
144
144
|
npm ci
|
|
145
|
+
npm run lint
|
|
145
146
|
npm run typecheck
|
|
146
147
|
npm test
|
|
147
148
|
npm run build
|
|
148
149
|
npm run test:smoke
|
|
149
150
|
```
|
|
150
151
|
|
|
152
|
+
lint 使用 ESLint 10 Flat Config 及 JavaScript/TypeScript 推荐规则,不引入格式化或 React 规则。检查覆盖源码、测试、脚本和根目录 JavaScript 文件,忽略构建产物、依赖、临时目录及生成的价格快照。可运行 `npm run lint:fix` 自动修复支持的问题。在 Node 22 分支,ESLint 要求 >=22.13;也支持 Node >=24。该开发工具要求不改变插件运行时 Node.js 22+ 的最低要求。
|
|
153
|
+
|
|
151
154
|
针对提供 `time.firstToken` 的宿主,可运行 `npm run test:smoke -- --performance-only` 验证原生 TTFT/TPS。该专项检查覆盖流式计时、原生页脚和重开会话后的历史恢复,不能替代完整集成检查。
|
|
152
155
|
|
|
153
156
|
OpenCode SDK 包精确锁定为 `2.3.0`,OpenTUI 为 `0.8.4`,Solid 与编译器为 `1.9.16`。OpenTUI 为其原生 Node 运行时声明 Node.js `>=26.4.0`,因此 Node 22 安装时 npm 会输出 `EBADENGINE`;启用 `engine-strict` 时须使用满足该依赖引擎要求的 Node 版本。插件的 TUI 在 OpenCode 内运行,并非独立的 Node 22 渲染器。项目 Node.js 22+ 的最低要求不变;该依赖组合的检查见[验证记录](docs/verification.md)。
|
|
154
157
|
|
|
155
|
-
[价格更新工作流](.github/workflows/update-prices.yml) 每 4 小时检查 models.dev,也可在 `main` 上通过 **Run workflow**
|
|
158
|
+
[价格更新工作流](.github/workflows/update-prices.yml) 每 4 小时检查 models.dev,也可在 `main` 上通过 **Run workflow** 手动触发。快照无变化就不发布。经审核的原厂来源白名单内有变化时,先通过 lint、类型检查、测试、构建和打包检查,再自动升级 patch 版本(例如 `0.4.4` → `0.4.5`),只提交 `src/prices.generated.ts`、`package.json` 和 `package-lock.json`,并原子推送 `main` 与版本标签。工作流创建 GitHub Release,显式触发该标签上的 [`publish.yml`](.github/workflows/publish.yml),通过 npm Trusted Publishing/OIDC 发布,无需长期 npm token。仓库必须允许 GitHub Actions 推送 `main` 和创建标签;npm 必须信任 `publish.yml` 并允许执行 `npm publish`。
|
|
156
159
|
|
|
157
160
|
验证失败不会升版本。已打标签但未完成的自动价格发布会优先重试同一版本,再检查新价格;registry 故障不会被当作版本不存在。发布时跳过 npm 已有版本、防止 `latest` 倒退,并在发布后最多轮询 10 分钟核验 registry 可见性,输出进度。校验超时不代表 `npm publish` 失败:先检查 registry,再重试原标签,不另升版本;已发布版本不会重复发布。新增原厂/来源白名单、别名及人工核实的价格例外仍需人工审核。配置、校验时限和重试方法见[发布说明](docs/releasing.md)。
|
|
158
161
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
2
|
-
readonly verified: "2026-11-
|
|
2
|
+
readonly verified: "2026-11-17";
|
|
3
3
|
readonly source: "https://models.dev/api.json";
|
|
4
4
|
readonly entries: readonly [{
|
|
5
5
|
readonly providerID: "ai21";
|
|
@@ -2796,6 +2796,88 @@ export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
|
2796
2796
|
};
|
|
2797
2797
|
}];
|
|
2798
2798
|
readonly released: "2026-10-26";
|
|
2799
|
+
}, {
|
|
2800
|
+
readonly providerID: "openai";
|
|
2801
|
+
readonly id: "gpt-6.2-astra";
|
|
2802
|
+
readonly prices: readonly [{
|
|
2803
|
+
readonly input: 8;
|
|
2804
|
+
readonly output: 40;
|
|
2805
|
+
readonly cache: {
|
|
2806
|
+
readonly read: 0.4;
|
|
2807
|
+
readonly write: 10;
|
|
2808
|
+
};
|
|
2809
|
+
}, {
|
|
2810
|
+
readonly input: 16;
|
|
2811
|
+
readonly output: 60;
|
|
2812
|
+
readonly cache: {
|
|
2813
|
+
readonly read: 0.8;
|
|
2814
|
+
readonly write: 20;
|
|
2815
|
+
};
|
|
2816
|
+
readonly tier: {
|
|
2817
|
+
readonly type: "context";
|
|
2818
|
+
readonly size: 272000;
|
|
2819
|
+
};
|
|
2820
|
+
}];
|
|
2821
|
+
readonly released: "2026-11-17";
|
|
2822
|
+
}, {
|
|
2823
|
+
readonly providerID: "openai";
|
|
2824
|
+
readonly id: "gpt-6.2-astra-fast";
|
|
2825
|
+
readonly providers: readonly ["openai"];
|
|
2826
|
+
readonly prices: readonly [{
|
|
2827
|
+
readonly input: 16;
|
|
2828
|
+
readonly output: 80;
|
|
2829
|
+
readonly cache: {
|
|
2830
|
+
readonly read: 0.8;
|
|
2831
|
+
readonly write: 20;
|
|
2832
|
+
};
|
|
2833
|
+
}, {
|
|
2834
|
+
readonly tier: {
|
|
2835
|
+
readonly type: "context";
|
|
2836
|
+
readonly size: 272000;
|
|
2837
|
+
};
|
|
2838
|
+
}];
|
|
2839
|
+
readonly released: "2026-11-17";
|
|
2840
|
+
}, {
|
|
2841
|
+
readonly providerID: "openai";
|
|
2842
|
+
readonly id: "gpt-6.2-sol";
|
|
2843
|
+
readonly prices: readonly [{
|
|
2844
|
+
readonly input: 2;
|
|
2845
|
+
readonly output: 10;
|
|
2846
|
+
readonly cache: {
|
|
2847
|
+
readonly read: 0.1;
|
|
2848
|
+
readonly write: 2.5;
|
|
2849
|
+
};
|
|
2850
|
+
}, {
|
|
2851
|
+
readonly input: 4;
|
|
2852
|
+
readonly output: 15;
|
|
2853
|
+
readonly cache: {
|
|
2854
|
+
readonly read: 0.2;
|
|
2855
|
+
readonly write: 5;
|
|
2856
|
+
};
|
|
2857
|
+
readonly tier: {
|
|
2858
|
+
readonly type: "context";
|
|
2859
|
+
readonly size: 272000;
|
|
2860
|
+
};
|
|
2861
|
+
}];
|
|
2862
|
+
readonly released: "2026-11-17";
|
|
2863
|
+
}, {
|
|
2864
|
+
readonly providerID: "openai";
|
|
2865
|
+
readonly id: "gpt-6.2-sol-fast";
|
|
2866
|
+
readonly providers: readonly ["openai"];
|
|
2867
|
+
readonly prices: readonly [{
|
|
2868
|
+
readonly input: 4;
|
|
2869
|
+
readonly output: 20;
|
|
2870
|
+
readonly cache: {
|
|
2871
|
+
readonly read: 0.2;
|
|
2872
|
+
readonly write: 5;
|
|
2873
|
+
};
|
|
2874
|
+
}, {
|
|
2875
|
+
readonly tier: {
|
|
2876
|
+
readonly type: "context";
|
|
2877
|
+
readonly size: 272000;
|
|
2878
|
+
};
|
|
2879
|
+
}];
|
|
2880
|
+
readonly released: "2026-11-17";
|
|
2799
2881
|
}, {
|
|
2800
2882
|
readonly providerID: "openai";
|
|
2801
2883
|
readonly id: "gpt-daybreak-blue-latest";
|
package/dist/prices.generated.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const GENERATED_PRICE_SNAPSHOT = {
|
|
2
|
-
verified: "2026-11-
|
|
2
|
+
verified: "2026-11-17",
|
|
3
3
|
source: "https://models.dev/api.json",
|
|
4
4
|
entries: [
|
|
5
5
|
{ "providerID": "ai21", "id": "jamba-large", "prices": [{ "input": 2, "output": 8 }], "released": "2025-07-03" },
|
|
@@ -231,6 +231,10 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
231
231
|
{ "providerID": "openai", "id": "gpt-6.1-sol-fast", "providers": ["openai"], "prices": [{ "input": 4, "output": 20, "cache": { "read": 0.2, "write": 5 } }, { "tier": { "type": "context", "size": 272000 } }], "released": "2026-09-29" },
|
|
232
232
|
{ "providerID": "openai", "id": "gpt-6.1-terra", "prices": [{ "input": 1, "output": 5, "cache": { "read": 0.05, "write": 1.25 } }, { "input": 2, "output": 7.5, "cache": { "read": 0.1, "write": 2.5 }, "tier": { "type": "context", "size": 272000 } }], "released": "2026-10-26" },
|
|
233
233
|
{ "providerID": "openai", "id": "gpt-6.1-terra-fast", "providers": ["openai"], "prices": [{ "input": 2, "output": 10, "cache": { "read": 0.1, "write": 2.5 } }, { "tier": { "type": "context", "size": 272000 } }], "released": "2026-10-26" },
|
|
234
|
+
{ "providerID": "openai", "id": "gpt-6.2-astra", "prices": [{ "input": 8, "output": 40, "cache": { "read": 0.4, "write": 10 } }, { "input": 16, "output": 60, "cache": { "read": 0.8, "write": 20 }, "tier": { "type": "context", "size": 272000 } }], "released": "2026-11-17" },
|
|
235
|
+
{ "providerID": "openai", "id": "gpt-6.2-astra-fast", "providers": ["openai"], "prices": [{ "input": 16, "output": 80, "cache": { "read": 0.8, "write": 20 } }, { "tier": { "type": "context", "size": 272000 } }], "released": "2026-11-17" },
|
|
236
|
+
{ "providerID": "openai", "id": "gpt-6.2-sol", "prices": [{ "input": 2, "output": 10, "cache": { "read": 0.1, "write": 2.5 } }, { "input": 4, "output": 15, "cache": { "read": 0.2, "write": 5 }, "tier": { "type": "context", "size": 272000 } }], "released": "2026-11-17" },
|
|
237
|
+
{ "providerID": "openai", "id": "gpt-6.2-sol-fast", "providers": ["openai"], "prices": [{ "input": 4, "output": 20, "cache": { "read": 0.2, "write": 5 } }, { "tier": { "type": "context", "size": 272000 } }], "released": "2026-11-17" },
|
|
234
238
|
{ "providerID": "openai", "id": "gpt-daybreak-blue-latest", "prices": [{ "input": 4, "output": 20, "cache": { "read": 0.4, "write": 5 } }, { "input": 8, "output": 30, "cache": { "read": 0.8, "write": 10 }, "tier": { "type": "context", "size": 272000 } }], "released": "2026-08-07" },
|
|
235
239
|
{ "providerID": "openai", "id": "gpt-daybreak-red-latest", "prices": [{ "input": 12.5, "output": 75, "cache": { "read": 1.25, "write": 15.625 } }], "released": "2026-08-07" },
|
|
236
240
|
{ "providerID": "openai", "id": "o1", "prices": [{ "input": 15, "output": 60, "cache": { "read": 7.5 } }], "released": "2024-12-05" },
|
package/dist/pricing.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface OfficialPriceEntry {
|
|
|
14
14
|
/** Checked-in data: updating prices is explicit, not a network request at
|
|
15
15
|
* startup, during a refresh, or during an npm build. */
|
|
16
16
|
export declare const OFFICIAL_PRICE_SNAPSHOT: {
|
|
17
|
-
verified: "2026-11-
|
|
17
|
+
verified: "2026-11-17";
|
|
18
18
|
source: "https://models.dev/api.json";
|
|
19
19
|
entries: OfficialPriceEntry[];
|
|
20
20
|
};
|
package/docs/verification.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# 价格任务与手动发布窗口竞态(2026-11-17)
|
|
2
|
+
|
|
3
|
+
[价格任务 43924512241](https://github.com/chenlongapps/opencode-token-usage/actions/runs/43924512241) 首次在 UTC 2026-11-16 18:02:05 检查到 `0.4.25` 尚未出现在 npm,且 `v0.4.25` 是手动版本提交,于是报错。GitHub Release 在 18:02:19 才发布;[npm 发布任务 43924608496](https://github.com/chenlongapps/opencode-token-usage/actions/runs/43924608496) 随后成功,并于 18:05:19 完成 registry 可见性确认。这是发布窗口重叠,不是价格快照或 npm 发布失败。
|
|
4
|
+
|
|
5
|
+
`priceReleaseState` 现在对尚未打标签、或标签有效但属于手动发布的未上架版本返回显式 `deferred` 状态;CLI 写入输出与任务摘要,价格工作流跳过后续更新,下次调度重新检查。自动价格版本仍只重试原始、已验证的价格专用标签;损坏标签、自动提交混入其他文件、registry 网络/HTTP/响应错误仍然失败。
|
|
6
|
+
|
|
7
|
+
本地类型检查、273 项测试、构建、actionlint 1.7.12 工作流静态检查与 `git diff --check` 通过。回归覆盖打标签前后延期、后续文档提交、发布后恢复、异常标签、registry 故障与 CLI 输出/摘要。此次未改插件运行逻辑,未重跑宿主冒烟。
|
|
8
|
+
|
|
9
|
+
原任务已使用远程既有代码重跑成功,价格没有变化,未触发新版本发布;这验证了发布完成后的恢复,不代表新的延期分支已在 GitHub 运行。防复发修复当前仅在本地,未提交或推送,包版本仍为 0.4.25。
|
|
10
|
+
|
|
1
11
|
# 0.4.25 发布准备(2026-11-17)
|
|
2
12
|
|
|
3
13
|
[GitHub CI 43921929492](https://github.com/chenlongapps/opencode-token-usage/actions/runs/43921929492) 已在依赖升级提交 `c8906a8` 上通过:Node 22 干净安装、类型检查、测试、构建、打包检查,以及 OpenCode 2.0.28/2.3.0 的完整打包冒烟均成功。该 CI 检查的是版本升级和本节文档变更之前的提交;各次记录中的发布状态均以当时为准。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenlongapps/opencode-token-usage",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.26",
|
|
4
4
|
"description": "OpenCode 2 plugin for session-tree token usage, context window monitoring, estimated costs, and performance metrics (TPS, TTFT, run time).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
@@ -49,12 +49,14 @@
|
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "node scripts/build.mjs",
|
|
52
|
+
"lint": "eslint . --max-warnings 0",
|
|
53
|
+
"lint:fix": "npm run lint -- --fix",
|
|
52
54
|
"typecheck": "tsc --noEmit",
|
|
53
55
|
"test": "tsx --test test/*.test.ts test/*.test.mjs",
|
|
54
56
|
"test:smoke": "node scripts/smoke.mjs",
|
|
55
57
|
"prices:update": "tsx scripts/update-prices.ts",
|
|
56
58
|
"release:patch": "npm version patch",
|
|
57
|
-
"prepublishOnly": "npm run typecheck && npm test",
|
|
59
|
+
"prepublishOnly": "npm run lint && npm run typecheck && npm test",
|
|
58
60
|
"prepack": "npm run build"
|
|
59
61
|
},
|
|
60
62
|
"publishConfig": {
|
|
@@ -71,6 +73,7 @@
|
|
|
71
73
|
},
|
|
72
74
|
"devDependencies": {
|
|
73
75
|
"@babel/core": "^7.28.0",
|
|
76
|
+
"@eslint/js": "^10.0.1",
|
|
74
77
|
"@opencode/client": "2.3.0",
|
|
75
78
|
"@opencode/schema": "2.3.0",
|
|
76
79
|
"@opencode/theme": "2.3.0",
|
|
@@ -79,9 +82,12 @@
|
|
|
79
82
|
"@types/node": "^22.0.0",
|
|
80
83
|
"@xterm/headless": "6.0.0",
|
|
81
84
|
"babel-preset-solid": "1.9.16",
|
|
85
|
+
"eslint": "^10.15.0",
|
|
86
|
+
"globals": "^17.14.0",
|
|
82
87
|
"solid-js": "1.9.16",
|
|
83
88
|
"tsx": "^4.20.0",
|
|
84
|
-
"typescript": "^5.9.0"
|
|
89
|
+
"typescript": "^5.9.0",
|
|
90
|
+
"typescript-eslint": "^8.73.0"
|
|
85
91
|
},
|
|
86
92
|
"packageManager": "npm@10.9.8"
|
|
87
93
|
}
|