@chenlongapps/opencode-token-usage 0.4.24 → 0.4.25
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 +7 -5
- package/README.zh-CN.md +7 -5
- package/docs/verification.md +40 -0
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -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)).
|
|
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
|
-
|
|
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
|
|
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
|
|
|
@@ -150,7 +150,7 @@ npm run test:smoke
|
|
|
150
150
|
|
|
151
151
|
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
152
|
|
|
153
|
-
The OpenCode SDK packages are pinned to `2.0
|
|
153
|
+
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
154
|
|
|
155
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`.
|
|
156
156
|
|
|
@@ -164,10 +164,12 @@ Performance lifecycle checks also use the real host's active-session API, with e
|
|
|
164
164
|
|
|
165
165
|
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
166
|
|
|
167
|
+
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.
|
|
168
|
+
|
|
167
169
|
To reproduce a baseline with a separately installed binary, without downgrading your normal installation:
|
|
168
170
|
|
|
169
171
|
```bash
|
|
170
|
-
OPENCODE_BIN=/absolute/path/to/opencode-2.0.
|
|
172
|
+
OPENCODE_BIN=/absolute/path/to/opencode-2.0.28 npm run test:smoke
|
|
171
173
|
```
|
|
172
174
|
|
|
173
175
|
`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
|
@@ -69,11 +69,11 @@ opencode plugin add @chenlongapps/opencode-token-usage
|
|
|
69
69
|
|
|
70
70
|
### 兼容性
|
|
71
71
|
|
|
72
|
-
需要 Node.js 22+(见[开发](#开发)中的 OpenTUI
|
|
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**
|
|
74
|
+
从 **0.4.24** 起,插件使用 `/token-usage` 打开详情,`/usage` 留给 OpenCode 原生命令。TTFT 与历史 TPS 在可用时优先采用原生首 token 时间,旧宿主保留回退。
|
|
75
75
|
|
|
76
|
-
OpenCode **2.3.0
|
|
76
|
+
OpenCode **2.3.0 现已通过完整检查**,包含插件详情与原生 `/usage` 共存、原生性能计时、历史恢复、子代理、分叉和压缩。此前 6,350 与 5,080 的差异来自旧夹具假设:后台子代理完成会触发父会话额外调用一次模型。冒烟现按实际模拟提供商请求独立核验总量。
|
|
77
77
|
|
|
78
78
|
### 详细用量
|
|
79
79
|
|
|
@@ -150,7 +150,7 @@ npm run test:smoke
|
|
|
150
150
|
|
|
151
151
|
针对提供 `time.firstToken` 的宿主,可运行 `npm run test:smoke -- --performance-only` 验证原生 TTFT/TPS。该专项检查覆盖流式计时、原生页脚和重开会话后的历史恢复,不能替代完整集成检查。
|
|
152
152
|
|
|
153
|
-
OpenCode SDK 包精确锁定为 `2.0
|
|
153
|
+
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
154
|
|
|
155
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`。
|
|
156
156
|
|
|
@@ -164,10 +164,12 @@ OpenCode SDK 包精确锁定为 `2.0.24`,OpenTUI 为 `0.5.14`。Node.js 22 下
|
|
|
164
164
|
|
|
165
165
|
默认使用 `PATH` 中的 `opencode`。OpenCode 2.0.9 及之后的稳定版 2.x 可以运行;尚未与当前 SDK 验证的宿主会输出警告,然后继续实际兼容性检查。仅通过版本检查不代表兼容性已验证。SDK 依赖仍独立锁定,不随本机 CLI 更新而自动升级。
|
|
166
166
|
|
|
167
|
+
CI 配置了固定 OpenCode **2.0.28** 与 **2.3.0** 的完整打包冒烟任务,使用隔离的本地模拟提供商并上传诊断产物。会话树总量按实际模拟请求独立核验:新宿主的后台子代理完成通知可能让父会话额外调用一次模型。
|
|
168
|
+
|
|
167
169
|
如需用独立安装的二进制复现基准,而不降级日常使用的安装:
|
|
168
170
|
|
|
169
171
|
```bash
|
|
170
|
-
OPENCODE_BIN=/absolute/path/to/opencode-2.0.
|
|
172
|
+
OPENCODE_BIN=/absolute/path/to/opencode-2.0.28 npm run test:smoke
|
|
171
173
|
```
|
|
172
174
|
|
|
173
175
|
`OPENCODE_BIN` 为版本检查、隔离服务端和 TUI 统一选择同一个可执行文件。相对路径以执行命令时的目录为基准解析。smoke 输出和 `result.json` 会记录宿主版本与所选二进制;已测试组合见[验证记录](docs/verification.md)。
|
package/docs/verification.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
# 0.4.25 发布准备(2026-11-17)
|
|
2
|
+
|
|
3
|
+
[GitHub CI 43921929492](https://github.com/chenlongapps/opencode-token-usage/actions/runs/43921929492) 已在依赖升级提交 `c8906a8` 上通过:Node 22 干净安装、类型检查、测试、构建、打包检查,以及 OpenCode 2.0.28/2.3.0 的完整打包冒烟均成功。该 CI 检查的是版本升级和本节文档变更之前的提交;各次记录中的发布状态均以当时为准。
|
|
4
|
+
|
|
5
|
+
本地 macOS、Node.js 22.23.2 / npm 10.9.8 在版本升级前重新通过类型检查、269 项测试、构建、`npm pack --dry-run` 与 `git diff --check`。上述双宿主结果来自对应的真实 GitHub CI 运行及下方既有本地验证。
|
|
6
|
+
|
|
7
|
+
# SDK 2.3.0 与双宿主完整冒烟(2026-11-17)
|
|
8
|
+
|
|
9
|
+
环境: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 要求。插件业务源码无需迁移。
|
|
10
|
+
|
|
11
|
+
## 夹具修复与实际原因
|
|
12
|
+
|
|
13
|
+
- 使用旧 SDK 在真实 2.3.0 复现原子代理摘要超时。`requests.json` 与流事件证实:父会话初始回答、subagent 工具调用、工具返回后的回答、子代理回答,以及 `<subagent state="completed">` 通知后的父会话回答共 5 次模型调用。每次固定上报 1,270 tokens,总量 6,350、费用 `$0.0063` 正确;旧宿主同步等待子代理,只有 4 次调用、5,080 tokens、`$0.00504`。这是测试夹具的生命周期假设失效,不是插件重复计费。
|
|
14
|
+
- 冒烟按实际模拟提供商请求独立计算期望总量/费用,并逐条核对父子会话原始 assistant 数及五类 tokens,再检查父侧边栏、子摘要与弹窗、模型切换后的历史计价。`tree-fixture.json` 保存期望值和原始消息;`result.json` 记录实际调用数与总量。
|
|
15
|
+
- 2.3+ 等待子代理完成通知被父会话消费后再读取最终状态。空闲父会话耗时检查以该通知触发的合法父轮次结算后为基线;离屏回收场景在新宿主显式保持父提供商响应运行,在旧宿主仍保持父工具等待,均以真实 `session.active()` 核验。
|
|
16
|
+
- PTY stdout 直接以字节流交给 xterm,原始 ANSI 保存为 Buffer,修复 UTF-8 条形图字符跨块时被 `toString()` 解码为 `�` 的偶发断言失败。
|
|
17
|
+
|
|
18
|
+
## 完整打包集成结果
|
|
19
|
+
|
|
20
|
+
| SDK | 宿主 | 结果 | 全树调用 / tokens / 费用 |
|
|
21
|
+
| --- | --- | --- | --- |
|
|
22
|
+
| 2.3.0 | OpenCode 2.0.28 | 完整通过 | 4 / 5,080 / $0.00504 |
|
|
23
|
+
| 2.3.0 | OpenCode 2.3.0 | 完整通过 | 5 / 6,350 / $0.0063 |
|
|
24
|
+
|
|
25
|
+
两版均验证真实打包/隔离安装、侧边栏与标题点击、`/token-usage` 紧凑/详细/窄终端、子代理、模型切换/缺失上下文上限/价格回退、实时性能/Responses 突发与静默过期、原生累计与实时估算耗时、中断、首轮 synthetic 延续、视图恢复、终端焦点事件、异常流回收。2.3.0 另通过原生 `/usage` 共存及 first-token 性能/同屏页脚/新 TUI 历史恢复:TTFT 306ms,首 delta 晚 103ms,历史 TPS 43.6 tok/s。
|
|
26
|
+
|
|
27
|
+
真实分叉在两版均保留 `_序号` 继承 ID、独立根、继承上下文与来源计费;新调用只计分叉自身。真实 compaction 均为 `status === "completed"`,升序完整历史保留旧消息,压缩边界清除旧上下文,后续 assistant 恢复上下文,compaction 不计 assistant Steps。加速 25 小时的生命周期检查不代表实际等待 25 小时,终端焦点检查不代表物理多屏/App Nap/睡眠唤醒验证。
|
|
28
|
+
|
|
29
|
+
产物:
|
|
30
|
+
|
|
31
|
+
- 2.3.0:`/private/var/folders/rw/bmx6c8hd737brl55m0_ff_b80000gn/T/opencode/token-usage-smoke-qsXSiu`
|
|
32
|
+
- 2.0.28:`/private/var/folders/rw/bmx6c8hd737brl55m0_ff_b80000gn/T/opencode/token-usage-smoke-QMm0QN`
|
|
33
|
+
- 旧 SDK 的 2.3.0 总量失败复现:`/private/var/folders/rw/bmx6c8hd737brl55m0_ff_b80000gn/T/opencode/token-usage-smoke-OLYgeh`
|
|
34
|
+
|
|
35
|
+
## 版本与 CI 策略
|
|
36
|
+
|
|
37
|
+
当前 SDK 的已验证宿主列表收敛为 2.0.28、2.3.0,旧 SDK 的历史验证保留在下方,不自动继承。仍允许稳定版 `>=2.0.9 <3.0.0` 实际执行检查,未验证版输出警告。CI 新增固定双宿主完整冒烟矩阵、Python 终端环境及诊断产物上传;actionlint 静态检查通过,尚未推送或触发真实 GitHub Actions,不能将本地通过称为远程 CI 通过。
|
|
38
|
+
|
|
39
|
+
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,本次未提交、推送或发布。
|
|
40
|
+
|
|
1
41
|
# 0.4.24 发布前验证(2026-11-15)
|
|
2
42
|
|
|
3
43
|
本次在 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.
|
|
3
|
+
"version": "0.4.25",
|
|
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",
|
|
@@ -62,24 +62,24 @@
|
|
|
62
62
|
"registry": "https://registry.npmjs.org/"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@opencode/plugin": "2.0
|
|
65
|
+
"@opencode/plugin": "2.3.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@opentui/core": "0.
|
|
69
|
-
"@opentui/solid": "0.
|
|
68
|
+
"@opentui/core": "0.8.4",
|
|
69
|
+
"@opentui/solid": "0.8.4",
|
|
70
70
|
"solid-js": ">=1.9.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@babel/core": "^7.28.0",
|
|
74
|
-
"@opencode/client": "2.0
|
|
75
|
-
"@opencode/schema": "2.0
|
|
76
|
-
"@opencode/theme": "2.0
|
|
77
|
-
"@opentui/core": "0.
|
|
78
|
-
"@opentui/solid": "0.
|
|
74
|
+
"@opencode/client": "2.3.0",
|
|
75
|
+
"@opencode/schema": "2.3.0",
|
|
76
|
+
"@opencode/theme": "2.3.0",
|
|
77
|
+
"@opentui/core": "0.8.4",
|
|
78
|
+
"@opentui/solid": "0.8.4",
|
|
79
79
|
"@types/node": "^22.0.0",
|
|
80
80
|
"@xterm/headless": "6.0.0",
|
|
81
|
-
"babel-preset-solid": "1.9.
|
|
82
|
-
"solid-js": "1.9.
|
|
81
|
+
"babel-preset-solid": "1.9.16",
|
|
82
|
+
"solid-js": "1.9.16",
|
|
83
83
|
"tsx": "^4.20.0",
|
|
84
84
|
"typescript": "^5.9.0"
|
|
85
85
|
},
|