@chenlongapps/opencode-token-usage 0.4.24 → 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 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
+ [![OpenCode Token Usage plugin preview](https://raw.githubusercontent.com/chenlongapps/opencode-token-usage/main/docs/assets/opencode-token-usage-preview.webp)](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
- [![OpenCode Token Usage plugin preview](https://raw.githubusercontent.com/chenlongapps/opencode-token-usage/main/docs/assets/opencode-token-usage-preview.webp)](https://www.npmjs.com/package/@chenlongapps/opencode-token-usage)
34
-
35
35
  ---
36
36
 
37
37
  ### Installation
@@ -69,11 +69,11 @@ For remote sessions, add the package name to `plugins` in your local `~/.config/
69
69
 
70
70
  ### Compatibility
71
71
 
72
- Requires Node.js 22+ (see the OpenTUI engine note under [Development](#development)). OpenCode 2.0.9 and 2.0.10 have been verified in earlier releases. SDK 2.0.24 integration checks have passed on OpenCode 2.0.11, 2.0.22, 2.0.24, 2.0.26, and 2.0.28. Native turn durations and sidebar title clicks were integration-tested on 2.0.26 and 2.0.28; the other listed host checks predate these additions. See the [verification record](docs/verification.md) for tested combinations.
72
+ Requires Node.js 22+ (see the OpenTUI engine note under [Development](#development)). With SDK **2.3.0**, the full packaged integration suite has passed on OpenCode **2.0.28** and **2.3.0**. Earlier SDK/release combinations were tested on 2.0.9–2.0.11, 2.0.22, 2.0.24, 2.0.26 and 2.1.2; those historical results do not establish compatibility with the current SDK. See the [verification record](docs/verification.md) for tested combinations.
73
73
 
74
- Version **0.4.24** uses `/token-usage` for plugin details; `/usage` is reserved for OpenCode. Native first-token timestamps improve TTFT and historical TPS when available, with fallbacks for older hosts.
74
+ Since **0.4.24**, the plugin uses `/token-usage` for details; `/usage` is reserved for OpenCode. Native first-token timestamps improve TTFT and historical TPS when available, with fallbacks for older hosts.
75
75
 
76
- OpenCode **2.3.0 has partial verification only**: plugin details, coexistence with built-in `/usage`, native performance timing and history restoration passed. The full smoke suite stopped at a subagent total mismatch (6,350 actual vs 5,080 expected); full compatibility is not confirmed. OpenCode **2.0.28 passed the full packaged regression** for these changes. See the [verification record](docs/verification.md).
76
+ OpenCode **2.3.0 now passes the full suite**, including plugin details alongside built-in `/usage`, native performance timing, history restoration, subagents, forks and compaction. The earlier 6,350 vs 5,080 mismatch was an outdated fixture assumption: background child completion triggers an additional parent model call. Smoke now independently reconciles totals against actual mock-provider requests.
77
77
 
78
78
  ### Detailed usage
79
79
 
@@ -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
- The OpenCode SDK packages are pinned to `2.0.24`, with OpenTUI `0.5.14`. Clean installation, typecheck, tests, build, and real-host smoke have passed on Node.js 22. 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. This upgrade keeps the project's Node.js 22+ minimum unchanged.
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
 
@@ -164,10 +167,12 @@ Performance lifecycle checks also use the real host's active-session API, with e
164
167
 
165
168
  By default, smoke uses `opencode` from `PATH`. Stable OpenCode 2 versions from 2.0.9 onward can run; a host not yet verified with the current SDK prints a warning and continues through the actual compatibility checks. Passing the version check alone does not establish compatibility. The SDK dependencies remain pinned independently of your local CLI updates.
166
169
 
170
+ CI configures full packaged smoke jobs for pinned OpenCode **2.0.28** and **2.3.0**, using isolated local mock providers and uploading diagnostic artifacts. Tree totals are checked against actual mock-provider requests: background child-completion notifications can trigger an additional parent call on newer hosts.
171
+
167
172
  To reproduce a baseline with a separately installed binary, without downgrading your normal installation:
168
173
 
169
174
  ```bash
170
- OPENCODE_BIN=/absolute/path/to/opencode-2.0.11 npm run test:smoke
175
+ OPENCODE_BIN=/absolute/path/to/opencode-2.0.28 npm run test:smoke
171
176
  ```
172
177
 
173
178
  `OPENCODE_BIN` selects the same executable for the version check, isolated server, and TUI. Relative paths resolve from the directory where you run the command. The host version and selected binary are recorded in the smoke output and `result.json`; see the [verification record](docs/verification.md) for tested combinations.
package/README.zh-CN.md CHANGED
@@ -15,6 +15,8 @@
15
15
  <strong>简体中文</strong>
16
16
  </p>
17
17
 
18
+ [![OpenCode Token Usage 插件预览](https://raw.githubusercontent.com/chenlongapps/opencode-token-usage/main/docs/assets/opencode-token-usage-preview.webp)](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
- [![OpenCode Token Usage 插件预览](https://raw.githubusercontent.com/chenlongapps/opencode-token-usage/main/docs/assets/opencode-token-usage-preview.webp)](https://www.npmjs.com/package/@chenlongapps/opencode-token-usage)
34
-
35
35
  ---
36
36
 
37
37
  ### 安装
@@ -69,11 +69,11 @@ opencode plugin add @chenlongapps/opencode-token-usage
69
69
 
70
70
  ### 兼容性
71
71
 
72
- 需要 Node.js 22+(见[开发](#开发)中的 OpenTUI 引擎说明)。此前发布已验证 OpenCode 2.0.9 和 2.0.10;SDK 2.0.24 集成检查已在 OpenCode 2.0.11、2.0.22、2.0.24、2.0.26 和 2.0.28 上通过。原生对话耗时与侧边栏标题点击的集成验证使用 2.0.26 和 2.0.28,其余列出的宿主检查早于这些功能加入。已测试组合见[验证记录](docs/verification.md)。
72
+ 需要 Node.js 22+(见[开发](#开发)中的 OpenTUI 引擎说明)。使用 SDK **2.3.0** 的完整打包集成检查已在 OpenCode **2.0.28** 和 **2.3.0** 上通过。此前 SDK/发布组合曾验证 2.0.9–2.0.11、2.0.22、2.0.24、2.0.26 和 2.1.2;这些历史结果不代表已验证当前 SDK 的兼容性。已测试组合见[验证记录](docs/verification.md)。
73
73
 
74
- **0.4.24** 使用 `/token-usage` 打开插件详情,`/usage` 留给 OpenCode 原生命令。TTFT 与历史 TPS 在可用时优先采用原生首 token 时间,旧宿主保留回退。
74
+ 从 **0.4.24** 起,插件使用 `/token-usage` 打开详情,`/usage` 留给 OpenCode 原生命令。TTFT 与历史 TPS 在可用时优先采用原生首 token 时间,旧宿主保留回退。
75
75
 
76
- OpenCode **2.3.0 仅通过部分验证**:插件详情、与原生 `/usage` 共存、原生性能计时和历史恢复已通过;完整冒烟停在子代理总量不匹配(实际 6,350,预期 5,080),尚未确认完整兼容。上述变更已通过 OpenCode **2.0.28 完整打包回归**,详见[验证记录](docs/verification.md)。
76
+ OpenCode **2.3.0 现已通过完整检查**,包含插件详情与原生 `/usage` 共存、原生性能计时、历史恢复、子代理、分叉和压缩。此前 6,350 与 5,080 的差异来自旧夹具假设:后台子代理完成会触发父会话额外调用一次模型。冒烟现按实际模拟提供商请求独立核验总量。
77
77
 
78
78
  ### 详细用量
79
79
 
@@ -142,17 +142,20 @@ OpenCode **2.3.0 仅通过部分验证**:插件详情、与原生 `/usage` 共
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
- OpenCode SDK 包精确锁定为 `2.0.24`,OpenTUI 为 `0.5.14`。Node.js 22 下已通过干净安装、类型检查、测试、构建和真实宿主 smoke。OpenTUI 为其原生 Node 运行时声明 Node.js `>=26.4.0`,因此 Node 22 安装时 npm 会输出 `EBADENGINE`;启用 `engine-strict` 时须使用满足该依赖引擎要求的 Node 版本。插件的 TUI 在 OpenCode 内运行,并非独立的 Node 22 渲染器。本次升级保持项目 Node.js 22+ 的最低要求不变。
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** 手动触发。快照无变化就不发布。经审核的原厂来源白名单内有变化时,先通过类型检查、测试、构建和打包检查,再自动升级 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`。
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
 
@@ -164,10 +167,12 @@ OpenCode SDK 包精确锁定为 `2.0.24`,OpenTUI 为 `0.5.14`。Node.js 22 下
164
167
 
165
168
  默认使用 `PATH` 中的 `opencode`。OpenCode 2.0.9 及之后的稳定版 2.x 可以运行;尚未与当前 SDK 验证的宿主会输出警告,然后继续实际兼容性检查。仅通过版本检查不代表兼容性已验证。SDK 依赖仍独立锁定,不随本机 CLI 更新而自动升级。
166
169
 
170
+ CI 配置了固定 OpenCode **2.0.28** 与 **2.3.0** 的完整打包冒烟任务,使用隔离的本地模拟提供商并上传诊断产物。会话树总量按实际模拟请求独立核验:新宿主的后台子代理完成通知可能让父会话额外调用一次模型。
171
+
167
172
  如需用独立安装的二进制复现基准,而不降级日常使用的安装:
168
173
 
169
174
  ```bash
170
- OPENCODE_BIN=/absolute/path/to/opencode-2.0.11 npm run test:smoke
175
+ OPENCODE_BIN=/absolute/path/to/opencode-2.0.28 npm run test:smoke
171
176
  ```
172
177
 
173
178
  `OPENCODE_BIN` 为版本检查、隔离服务端和 TUI 统一选择同一个可执行文件。相对路径以执行命令时的目录为基准解析。smoke 输出和 `result.json` 会记录宿主版本与所选二进制;已测试组合见[验证记录](docs/verification.md)。
@@ -1,5 +1,5 @@
1
1
  export declare const GENERATED_PRICE_SNAPSHOT: {
2
- readonly verified: "2026-11-13";
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";
@@ -1,5 +1,5 @@
1
1
  export const GENERATED_PRICE_SNAPSHOT = {
2
- verified: "2026-11-13",
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-13";
17
+ verified: "2026-11-17";
18
18
  source: "https://models.dev/api.json";
19
19
  entries: OfficialPriceEntry[];
20
20
  };
@@ -1,3 +1,53 @@
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
+
11
+ # 0.4.25 发布准备(2026-11-17)
12
+
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 检查的是版本升级和本节文档变更之前的提交;各次记录中的发布状态均以当时为准。
14
+
15
+ 本地 macOS、Node.js 22.23.2 / npm 10.9.8 在版本升级前重新通过类型检查、269 项测试、构建、`npm pack --dry-run` 与 `git diff --check`。上述双宿主结果来自对应的真实 GitHub CI 运行及下方既有本地验证。
16
+
17
+ # SDK 2.3.0 与双宿主完整冒烟(2026-11-17)
18
+
19
+ 环境:macOS arm64、Node.js v22.23.2、npm 10.9.8。`@opencode/plugin/client/schema/theme` 统一从 2.0.24 升至 2.3.0,OpenTUI 从 0.5.14 升至 0.8.4,Solid 与 `babel-preset-solid` 升至 1.9.16,以满足新版 OpenTUI 编译器的 peer 要求。插件业务源码无需迁移。
20
+
21
+ ## 夹具修复与实际原因
22
+
23
+ - 使用旧 SDK 在真实 2.3.0 复现原子代理摘要超时。`requests.json` 与流事件证实:父会话初始回答、subagent 工具调用、工具返回后的回答、子代理回答,以及 `<subagent state="completed">` 通知后的父会话回答共 5 次模型调用。每次固定上报 1,270 tokens,总量 6,350、费用 `$0.0063` 正确;旧宿主同步等待子代理,只有 4 次调用、5,080 tokens、`$0.00504`。这是测试夹具的生命周期假设失效,不是插件重复计费。
24
+ - 冒烟按实际模拟提供商请求独立计算期望总量/费用,并逐条核对父子会话原始 assistant 数及五类 tokens,再检查父侧边栏、子摘要与弹窗、模型切换后的历史计价。`tree-fixture.json` 保存期望值和原始消息;`result.json` 记录实际调用数与总量。
25
+ - 2.3+ 等待子代理完成通知被父会话消费后再读取最终状态。空闲父会话耗时检查以该通知触发的合法父轮次结算后为基线;离屏回收场景在新宿主显式保持父提供商响应运行,在旧宿主仍保持父工具等待,均以真实 `session.active()` 核验。
26
+ - PTY stdout 直接以字节流交给 xterm,原始 ANSI 保存为 Buffer,修复 UTF-8 条形图字符跨块时被 `toString()` 解码为 `�` 的偶发断言失败。
27
+
28
+ ## 完整打包集成结果
29
+
30
+ | SDK | 宿主 | 结果 | 全树调用 / tokens / 费用 |
31
+ | --- | --- | --- | --- |
32
+ | 2.3.0 | OpenCode 2.0.28 | 完整通过 | 4 / 5,080 / $0.00504 |
33
+ | 2.3.0 | OpenCode 2.3.0 | 完整通过 | 5 / 6,350 / $0.0063 |
34
+
35
+ 两版均验证真实打包/隔离安装、侧边栏与标题点击、`/token-usage` 紧凑/详细/窄终端、子代理、模型切换/缺失上下文上限/价格回退、实时性能/Responses 突发与静默过期、原生累计与实时估算耗时、中断、首轮 synthetic 延续、视图恢复、终端焦点事件、异常流回收。2.3.0 另通过原生 `/usage` 共存及 first-token 性能/同屏页脚/新 TUI 历史恢复:TTFT 306ms,首 delta 晚 103ms,历史 TPS 43.6 tok/s。
36
+
37
+ 真实分叉在两版均保留 `_序号` 继承 ID、独立根、继承上下文与来源计费;新调用只计分叉自身。真实 compaction 均为 `status === "completed"`,升序完整历史保留旧消息,压缩边界清除旧上下文,后续 assistant 恢复上下文,compaction 不计 assistant Steps。加速 25 小时的生命周期检查不代表实际等待 25 小时,终端焦点检查不代表物理多屏/App Nap/睡眠唤醒验证。
38
+
39
+ 产物:
40
+
41
+ - 2.3.0:`/private/var/folders/rw/bmx6c8hd737brl55m0_ff_b80000gn/T/opencode/token-usage-smoke-qsXSiu`
42
+ - 2.0.28:`/private/var/folders/rw/bmx6c8hd737brl55m0_ff_b80000gn/T/opencode/token-usage-smoke-QMm0QN`
43
+ - 旧 SDK 的 2.3.0 总量失败复现:`/private/var/folders/rw/bmx6c8hd737brl55m0_ff_b80000gn/T/opencode/token-usage-smoke-OLYgeh`
44
+
45
+ ## 版本与 CI 策略
46
+
47
+ 当前 SDK 的已验证宿主列表收敛为 2.0.28、2.3.0,旧 SDK 的历史验证保留在下方,不自动继承。仍允许稳定版 `>=2.0.9 <3.0.0` 实际执行检查,未验证版输出警告。CI 新增固定双宿主完整冒烟矩阵、Python 终端环境及诊断产物上传;actionlint 静态检查通过,尚未推送或触发真实 GitHub Actions,不能将本地通过称为远程 CI 通过。
48
+
49
+ Node 22 干净 `npm ci`、类型检查、269 项自动化测试(零失败/跳过)、构建、`npm pack --dry-run --json`、`npm ls --all`、冒烟脚本语法检查与 `git diff --check` 通过。旧安装树在原地升级时触发 npm 10 的 Effect peer 解析冲突,重新生成锁文件并干净安装后解决;Solid/编译器协调升级后依赖树无 invalid peer。OpenTUI 的既有 Node >=26.4 引擎警告保留,Node 22 工具链与宿主内 TUI 的通过不代表独立 Node 22 原生渲染受支持。首次旧 SDK 打包安装还遇到继承 npm 缓存的 AWS ETARGET,使用独立缓存后恢复。包版本仍为 0.4.24,本次未提交、推送或发布。
50
+
1
51
  # 0.4.24 发布前验证(2026-11-15)
2
52
 
3
53
  本次在 Linux、Node.js 24.22.1、npm 11.9.0 环境中重新执行:干净安装(独立 npm 缓存)、`npm run typecheck`、269 项 `npm test`、`npm run build`、`npm pack --dry-run` 与 `git diff --check`,均通过。安装仍有固定 OpenTUI 依赖的 Node >=26.4 引擎警告。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenlongapps/opencode-token-usage",
3
- "version": "0.4.24",
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": {
@@ -62,26 +64,30 @@
62
64
  "registry": "https://registry.npmjs.org/"
63
65
  },
64
66
  "dependencies": {
65
- "@opencode/plugin": "2.0.24"
67
+ "@opencode/plugin": "2.3.0"
66
68
  },
67
69
  "peerDependencies": {
68
- "@opentui/core": "0.5.14",
69
- "@opentui/solid": "0.5.14",
70
+ "@opentui/core": "0.8.4",
71
+ "@opentui/solid": "0.8.4",
70
72
  "solid-js": ">=1.9.0"
71
73
  },
72
74
  "devDependencies": {
73
75
  "@babel/core": "^7.28.0",
74
- "@opencode/client": "2.0.24",
75
- "@opencode/schema": "2.0.24",
76
- "@opencode/theme": "2.0.24",
77
- "@opentui/core": "0.5.14",
78
- "@opentui/solid": "0.5.14",
76
+ "@eslint/js": "^10.0.1",
77
+ "@opencode/client": "2.3.0",
78
+ "@opencode/schema": "2.3.0",
79
+ "@opencode/theme": "2.3.0",
80
+ "@opentui/core": "0.8.4",
81
+ "@opentui/solid": "0.8.4",
79
82
  "@types/node": "^22.0.0",
80
83
  "@xterm/headless": "6.0.0",
81
- "babel-preset-solid": "1.9.12",
82
- "solid-js": "1.9.12",
84
+ "babel-preset-solid": "1.9.16",
85
+ "eslint": "^10.15.0",
86
+ "globals": "^17.14.0",
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
  }