@chenlongapps/opencode-token-usage 0.2.1 → 0.2.3
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 +54 -93
- package/README.zh-CN.md +94 -0
- package/ROADMAP.md +1 -1
- package/docs/verification.md +24 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,133 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
面向 **OpenCode 2** 的 token 用量插件,当前版本 **0.2.1**。SDK 依赖固定为 2.0.9,宿主已验证 2.0.9、2.0.10 和 2.0.11。在原生 TUI 侧边栏追加用量面板,统计当前会话所在的整棵会话树,包括未打开的子代理,并显示性能指标与当前查看会话的上下文占用。
|
|
4
|
-
|
|
5
|
-
## 预览
|
|
6
|
-
|
|
7
|
-
```text
|
|
8
|
-
Token Usage
|
|
9
|
-
Context 9,810 / 128,000 (7.7%)
|
|
10
|
-
Input 54,200
|
|
11
|
-
Output 6,800
|
|
12
|
-
Reasoning 4,100
|
|
13
|
-
Cache Read 31,700
|
|
14
|
-
Cache Write 1,300
|
|
15
|
-
Cache Rate 36.4%
|
|
16
|
-
Total 98,100
|
|
17
|
-
Cost $0.21
|
|
18
|
-
|
|
19
|
-
TPS 48.7 tok/s
|
|
20
|
-
TTFT 2.7s
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
示例费用使用每百万 token 的 Input / Output / Cache Read / Cache Write 单价 $2 / $8 / $0.2 / $3。实际价格与上下文上限取自当前查看会话的活动模型。
|
|
24
|
-
|
|
25
|
-
## 安装
|
|
26
|
-
|
|
27
|
-
需要 Node.js 22+ 和 OpenCode **2.0.9、2.0.10 或 2.0.11**。更高版本的 OpenCode 尚未验证;npm SDK 依赖仍锁定为 2.0.9。
|
|
1
|
+
<h1 align="center">opencode-token-usage</h1>
|
|
28
2
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
```json
|
|
32
|
-
{
|
|
33
|
-
"plugins": ["@chenlongapps/opencode-token-usage"]
|
|
34
|
-
}
|
|
35
|
-
```
|
|
3
|
+
<p align="center">A session-tree token usage monitor for OpenCode 2.</p>
|
|
36
4
|
|
|
37
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@chenlongapps/opencode-token-usage"><img alt="npm" src="https://img.shields.io/npm/v/%40chenlongapps%2Fopencode-token-usage?style=flat-square&logo=npm" /></a>
|
|
7
|
+
<a href="https://opencode.ai/"><img alt="OpenCode 2" src="https://img.shields.io/badge/OpenCode-2-5A67D8?style=flat-square" /></a>
|
|
8
|
+
<a href="https://github.com/chenlongapps/opencode-token-usage/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/chenlongapps/opencode-token-usage/ci.yml?style=flat-square&branch=main&label=ci" /></a>
|
|
9
|
+
<a href="LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-yellow?style=flat-square" /></a>
|
|
10
|
+
</p>
|
|
38
11
|
|
|
39
|
-
|
|
12
|
+
<p align="center">
|
|
13
|
+
<strong>English</strong> |
|
|
14
|
+
<a href="https://github.com/chenlongapps/opencode-token-usage/blob/main/README.zh-CN.md">简体中文</a>
|
|
15
|
+
</p>
|
|
40
16
|
|
|
41
|
-
|
|
17
|
+
[](https://www.npmjs.com/package/@chenlongapps/opencode-token-usage)
|
|
42
18
|
|
|
43
|
-
|
|
19
|
+
---
|
|
44
20
|
|
|
45
|
-
|
|
21
|
+
### Installation
|
|
46
22
|
|
|
47
23
|
```bash
|
|
48
|
-
|
|
49
|
-
npm run typecheck
|
|
50
|
-
npm test
|
|
51
|
-
npm run build
|
|
24
|
+
opencode plugin add @chenlongapps/opencode-token-usage
|
|
52
25
|
```
|
|
53
26
|
|
|
54
|
-
|
|
27
|
+
Alternatively, add the package to your project's `opencode.json` or `opencode.jsonc`:
|
|
55
28
|
|
|
56
29
|
```json
|
|
57
30
|
{
|
|
58
|
-
"plugins": ["/
|
|
31
|
+
"plugins": ["@chenlongapps/opencode-token-usage"]
|
|
59
32
|
}
|
|
60
33
|
```
|
|
61
34
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
npm pack
|
|
66
|
-
npm install --prefix /absolute/path/local-plugins ./chenlongapps-opencode-token-usage-0.2.1.tgz
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
此时配置的插件路径为 `/absolute/path/local-plugins/node_modules/@chenlongapps/opencode-token-usage`。包包含编译后的 ESM 和类型声明,无需在使用时编译 JSX。
|
|
70
|
-
|
|
71
|
-
## 统计口径
|
|
72
|
-
|
|
73
|
-
- 沿当前会话的 `parentID` 找到根,再分页读取所有后代及其完整消息。进入子代理仍显示同一棵树的累计用量。
|
|
74
|
-
- 统计服务端上报的 assistant 和 compaction 消息,包括压缩前历史及失败消息中已记录的用量。不根据文本长度估算 token,不计入没有关联消息的标题生成用量。
|
|
75
|
-
- 按会话和消息 ID 保存快照,每次成功刷新替换旧值,重复事件不会累加两次。分叉会话属于独立会话树;继承历史只归原始来源,其副本不重复计费。分叉副本识别依据 OpenCode 2.0.9 的 ID 生成规则。
|
|
76
|
-
- `Input` 不含缓存读取或写入;`Output` 不含 `Reasoning`。
|
|
77
|
-
- `Total = Input + Output + Reasoning + Cache Read + Cache Write`。
|
|
78
|
-
- `Cache Rate = Cache Read ÷ (Input + Cache Read + Cache Write)`;保留一位小数,分母为零时显示 `0.0%`。
|
|
79
|
-
- `Cache Write` 和 `Cost` 仅在值大于零时显示。空会话保留其他统计行并显示零;首次读取显示 `Loading…` 和 `—`,首次失败显示 `Unavailable`。刷新失败保留上次完整结果,标注 `Not updated` 并自动重试。
|
|
35
|
+
> [!NOTE]
|
|
36
|
+
> Requires Node.js 22+. OpenCode 2.0.9, 2.0.10, and 2.0.11 have been verified across project releases. The current SDK 2.0.11 build has been reverified on OpenCode 2.0.11.
|
|
80
37
|
|
|
81
|
-
|
|
38
|
+
Restart OpenCode after installation. The panel appears in the native sidebar when `session.sidebar` is set to `auto` and the terminal is wide enough. OpenCode hides the sidebar in subagent views, so the plugin renders the same panel above the composer instead.
|
|
82
39
|
|
|
83
|
-
|
|
40
|
+
For remote sessions, add the package name to `plugins` in your local `~/.config/opencode/cli.json` to load only the terminal entry point. The configuration path follows `XDG_CONFIG_HOME`.
|
|
84
41
|
|
|
85
|
-
|
|
42
|
+
### Metrics
|
|
86
43
|
|
|
87
|
-
|
|
44
|
+
| Metric | Definition |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `Input` | Input tokens, excluding cache reads and writes |
|
|
47
|
+
| `Output` | Output tokens, excluding reasoning tokens |
|
|
48
|
+
| `Reasoning` | Reasoning tokens |
|
|
49
|
+
| `Cache Rate` | `Cache Read ÷ (Input + Cache Read + Cache Write)` |
|
|
50
|
+
| `Total` | Sum of all five token categories |
|
|
51
|
+
| `Context` | Latest context usage after the most recent completed compaction in the viewed session; not aggregated across the subtree |
|
|
52
|
+
| `Cost` | Estimated cost for the entire tree, recalculated using the viewed session's active model; not a provider bill |
|
|
53
|
+
| `TPS` | Generation throughput for `Output + Reasoning` across the tree; live estimates are marked with `~` |
|
|
54
|
+
| `TTFT` | Average time to first token across measurable assistant steps in the tree |
|
|
88
55
|
|
|
89
|
-
|
|
56
|
+
#### Behavior
|
|
90
57
|
|
|
91
|
-
|
|
58
|
+
- Usage includes server-reported assistant and compaction messages throughout the session tree, including unopened subagents. Token counts are never inferred from text length.
|
|
59
|
+
- A fork is a separate session tree. Inherited message copies are attributed only to their original source to prevent double counting.
|
|
60
|
+
- `Context` only searches messages after the most recent compaction with `status === "completed"` and is hidden when reliable usage or a model context limit is unavailable.
|
|
61
|
+
- `Cost` applies the viewed session's active model to the whole tree. Missing applicable prices fall back to 0, matching OpenCode's behavior.
|
|
62
|
+
- Initial read failures display `Unavailable`. Later failures retain the last complete snapshot, display `Not updated`, and retry automatically.
|
|
92
63
|
|
|
93
|
-
###
|
|
94
|
-
|
|
95
|
-
`Cost` 是按**当前查看会话的活动模型**重新估算的全树费用,不是提供商账单,也不累加历史消息中保存的 `cost`。它不使用每条消息自身记录的模型:同一会话里即使多条消息由不同模型生成,也统一按查看时活动模型的价格档位推算,因此混合模型会话的金额**不等于**按各消息实际模型计费之和——它回答的是"把这棵树按当前模型重跑一遍会花多少"。未选定模型时使用该会话位置的默认模型,切换模型后重新计算。
|
|
96
|
-
|
|
97
|
-
每条消息分别使用其传入 token 数(Input + Cache Read + Cache Write)选择价格档位:严格超过阈值才进入该档,多个档位适用时取最高阈值,否则用基础档。Output 和 Reasoning 都使用输出单价,最后合计各条消息的费用。
|
|
98
|
-
|
|
99
|
-
没有模型价格或适用档位时按 OpenCode 官方计费实现回退为 **0**。合法的免费模型也按其实际价格计算;价格请求失败会显示未更新状态。这里的“默认价格”并非内置的公开价格目录。
|
|
100
|
-
|
|
101
|
-
数字使用千位逗号分组并显示为四舍五入后的整数;例如 `1200 → 1,200`、`125000 → 125,000`、`1500000 → 1,500,000`。美元保留两位小数,正数不足一美分显示 `<$0.01`。
|
|
102
|
-
|
|
103
|
-
## 开发与验证
|
|
64
|
+
### Development
|
|
104
65
|
|
|
105
66
|
```bash
|
|
67
|
+
npm ci
|
|
106
68
|
npm run typecheck
|
|
107
69
|
npm test
|
|
108
70
|
npm run build
|
|
109
71
|
npm run test:smoke
|
|
110
72
|
```
|
|
111
73
|
|
|
112
|
-
`test:smoke`
|
|
74
|
+
`test:smoke` packages the real artifact and validates loading, refreshes, subagent aggregation, model switching, TPS, and TTFT against an isolated OpenCode instance and a local mock provider. It requires Python 3, an available local port, and npm network access. It never modifies your existing OpenCode configuration or calls paid models.
|
|
113
75
|
|
|
114
|
-
|
|
76
|
+
To load the plugin from source, build the project and add the repository's absolute path to `plugins` in the target project.
|
|
115
77
|
|
|
116
|
-
|
|
78
|
+
### Documentation
|
|
117
79
|
|
|
118
|
-
|
|
80
|
+
- [Roadmap](ROADMAP.md)
|
|
81
|
+
- [Verification record](docs/verification.md)
|
|
82
|
+
- [Release guide](docs/releasing.md)
|
|
83
|
+
- [OpenCode 2 plugin documentation](https://opencode.ai/v2/docs/build/plugins/)
|
|
84
|
+
- [OpenCode 2 CLI plugin API](https://opencode.ai/v2/docs/build/plugins/cli/)
|
|
119
85
|
|
|
120
|
-
|
|
86
|
+
The implementation follows OpenCode's [TokenUsage schema](https://github.com/anomalyco/opencode/blob/v2/packages/schema/src/token-usage.ts), [cost calculation](https://github.com/anomalyco/opencode/blob/v2/packages/core/src/session/usage.ts), and [fork history projection](https://github.com/anomalyco/opencode/blob/v2/packages/core/src/session/projector.ts).
|
|
121
87
|
|
|
122
|
-
|
|
88
|
+
### Disclaimer
|
|
123
89
|
|
|
124
|
-
|
|
125
|
-
- [OpenCode 2 插件加载](https://opencode.ai/v2/docs/build/plugins/)
|
|
126
|
-
- [CLI 设置](https://opencode.ai/v2/docs/cli/config/)
|
|
127
|
-
- [TokenUsage 定义](https://github.com/anomalyco/opencode/blob/v2/packages/schema/src/token-usage.ts)
|
|
128
|
-
- [官方计费实现](https://github.com/anomalyco/opencode/blob/v2/packages/core/src/session/usage.ts)
|
|
129
|
-
- [分叉历史投影](https://github.com/anomalyco/opencode/blob/v2/packages/core/src/session/projector.ts)
|
|
90
|
+
This is an independent community plugin. It is not built, maintained, or endorsed by the OpenCode team.
|
|
130
91
|
|
|
131
|
-
|
|
92
|
+
### License
|
|
132
93
|
|
|
133
94
|
[MIT](LICENSE)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<h1 align="center">opencode-token-usage</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">面向 OpenCode 2 的会话树 token 用量监视器。</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@chenlongapps/opencode-token-usage"><img alt="npm" src="https://img.shields.io/npm/v/%40chenlongapps%2Fopencode-token-usage?style=flat-square&logo=npm" /></a>
|
|
7
|
+
<a href="https://opencode.ai/"><img alt="OpenCode 2" src="https://img.shields.io/badge/OpenCode-2-5A67D8?style=flat-square" /></a>
|
|
8
|
+
<a href="https://github.com/chenlongapps/opencode-token-usage/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/chenlongapps/opencode-token-usage/ci.yml?style=flat-square&branch=main&label=ci" /></a>
|
|
9
|
+
<a href="LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-yellow?style=flat-square" /></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="README.md">English</a> |
|
|
14
|
+
<strong>简体中文</strong>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
[](https://www.npmjs.com/package/@chenlongapps/opencode-token-usage)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
### 安装
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
opencode plugin add @chenlongapps/opencode-token-usage
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
也可以在项目的 `opencode.json` 或 `opencode.jsonc` 中配置:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"plugins": ["@chenlongapps/opencode-token-usage"]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
> [!NOTE]
|
|
36
|
+
> 需要 Node.js 22+。项目历次发布已验证 OpenCode 2.0.9、2.0.10 和 2.0.11;当前 SDK 2.0.11 构建已在 OpenCode 2.0.11 上重新验证。
|
|
37
|
+
|
|
38
|
+
安装后重启 OpenCode。终端足够宽且 `session.sidebar` 设为 `auto` 时,面板会显示在原生侧边栏中。OpenCode 在子代理视图中隐藏侧边栏,因此插件会在输入区上方显示同一面板。
|
|
39
|
+
|
|
40
|
+
连接远程服务器时,可将包名加入本机 `~/.config/opencode/cli.json` 的 `plugins`,仅加载终端入口;配置路径遵循 `XDG_CONFIG_HOME`。
|
|
41
|
+
|
|
42
|
+
### 指标
|
|
43
|
+
|
|
44
|
+
| 指标 | 定义 |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `Input` | 输入 token,不含缓存读取和写入 |
|
|
47
|
+
| `Output` | 输出 token,不含推理 token |
|
|
48
|
+
| `Reasoning` | 推理 token |
|
|
49
|
+
| `Cache Rate` | `Cache Read ÷ (Input + Cache Read + Cache Write)` |
|
|
50
|
+
| `Total` | 五类 token 之和 |
|
|
51
|
+
| `Context` | 当前会话最后一次已完成压缩后的最新上下文用量,不随子树累计 |
|
|
52
|
+
| `Cost` | 按当前会话活动模型重新估算的全树费用,不代表提供商账单 |
|
|
53
|
+
| `TPS` | 全树 `Output + Reasoning` 的生成速度;生成中的估算值带 `~` 标记 |
|
|
54
|
+
| `TTFT` | 全树中可测 assistant step 的平均首 token 时间 |
|
|
55
|
+
|
|
56
|
+
#### 行为
|
|
57
|
+
|
|
58
|
+
- 用量覆盖会话树中服务端上报的 assistant 与 compaction 消息,包括未打开的子代理;不按文本长度估算 token。
|
|
59
|
+
- 分叉会话是独立会话树。继承消息副本只归原始来源,避免重复计费。
|
|
60
|
+
- `Context` 仅搜索最后一次 `status === "completed"` 的 compaction 之后;没有可靠用量或模型上限时隐藏。
|
|
61
|
+
- `Cost` 使用当前查看会话的活动模型重算整棵树;缺失适用价格时按 OpenCode 行为回退为 0。
|
|
62
|
+
- 首次读取失败显示 `Unavailable`;后续失败保留上次完整快照、标注 `Not updated` 并自动重试。
|
|
63
|
+
|
|
64
|
+
### 开发
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm ci
|
|
68
|
+
npm run typecheck
|
|
69
|
+
npm test
|
|
70
|
+
npm run build
|
|
71
|
+
npm run test:smoke
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`test:smoke` 会打包真实产物,并在隔离的 OpenCode 与本地模拟提供商中验证加载、刷新、子代理累计、模型切换、TPS 和 TTFT。它需要 Python 3、可用的本地端口和 npm 网络访问,不会修改现有 OpenCode 配置或调用付费模型。
|
|
75
|
+
|
|
76
|
+
从源码加载时,先构建项目,再将仓库绝对路径加入目标项目的 `plugins`。
|
|
77
|
+
|
|
78
|
+
### 文档
|
|
79
|
+
|
|
80
|
+
- [路线图](ROADMAP.md)
|
|
81
|
+
- [验证记录](docs/verification.md)
|
|
82
|
+
- [发布说明](docs/releasing.md)
|
|
83
|
+
- [OpenCode 2 插件开发文档](https://opencode.ai/v2/docs/build/plugins/)
|
|
84
|
+
- [OpenCode 2 CLI 插件接口](https://opencode.ai/v2/docs/build/plugins/cli/)
|
|
85
|
+
|
|
86
|
+
实现遵循 OpenCode 的 [TokenUsage 定义](https://github.com/anomalyco/opencode/blob/v2/packages/schema/src/token-usage.ts)、[官方计费实现](https://github.com/anomalyco/opencode/blob/v2/packages/core/src/session/usage.ts)和[分叉历史投影](https://github.com/anomalyco/opencode/blob/v2/packages/core/src/session/projector.ts)。
|
|
87
|
+
|
|
88
|
+
### 声明
|
|
89
|
+
|
|
90
|
+
这是一个独立的社区插件,并非由 OpenCode 团队构建、维护或认可。
|
|
91
|
+
|
|
92
|
+
### 许可证
|
|
93
|
+
|
|
94
|
+
[MIT](LICENSE)
|
package/ROADMAP.md
CHANGED
package/docs/verification.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# 验证记录
|
|
2
2
|
|
|
3
|
+
## 未发布(SDK 2.0.11)
|
|
4
|
+
|
|
5
|
+
验证日期:2026-09-20。环境:macOS、Node.js v22.23.2、npm 10.9.8、OpenCode v2.0.11;`@opencode/plugin`、`@opencode/client`、`@opencode/schema` 和 `@opencode/theme` 均精确锁定为 2.0.11。
|
|
6
|
+
|
|
7
|
+
### 自动化检查
|
|
8
|
+
|
|
9
|
+
| 检查 | 结果 |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `npm run typecheck` | 通过 |
|
|
12
|
+
| `npm test` | 29 项通过 |
|
|
13
|
+
| `npm run build` | 通过,输出 ESM 与类型声明 |
|
|
14
|
+
| `npm run test:smoke` | 通过,使用实际 `.tgz` 安装产物和真实 OpenCode 2.0.11 |
|
|
15
|
+
|
|
16
|
+
SDK 从 2.0.9 升级到 2.0.11 后,四个顶层 OpenCode 包及锁文件中的传递依赖均已统一到 2.0.11。`@opencode/plugin` 两版的导出结构一致;包内容差异除依赖版本外,仅为 `ToastOptions` 新增可选的 `sessionID` 类型字段。
|
|
17
|
+
|
|
18
|
+
### 真实 OpenCode 集成
|
|
19
|
+
|
|
20
|
+
隔离 smoke 测试确认打包插件可加载;空会话隐藏无数据行;活动 TPS 估算会收敛为精确值;TTFT、token、上下文与费用正常刷新;真实子代理用量可从父子视图累计且上下文保持会话局部;切换活动模型会同步更新价格选择与上下文上限。测试产物保存在 `/var/folders/rw/bmx6c8hd737brl55m0_ff_b80000gn/T/token-usage-smoke-JXe1KG`。
|
|
21
|
+
|
|
22
|
+
### 验证边界
|
|
23
|
+
|
|
24
|
+
当前 SDK 2.0.11 与宿主 2.0.11 的组合已完整验证。2.0.9 和 2.0.10 宿主的历史验证记录保留在下方,但升级 SDK 后未重新执行这两个旧宿主的打包矩阵:本地仅有 2.0.11,官方 GitHub Releases 也没有可获取的对应旧版本资产。后续升级 SDK 或宿主时,仍需重新核对分叉副本、compaction 排序及 step/delta 事件语义。
|
|
25
|
+
|
|
3
26
|
## v0.2.1(TPS 与 TTFT)
|
|
4
27
|
|
|
5
28
|
验证日期:2026-09-20。环境:macOS、Node.js v22.23.2、npm 10.9.8、OpenCode v2.0.11;插件 SDK 依赖为 2.0.9。
|
|
@@ -15,7 +38,7 @@
|
|
|
15
38
|
| `npm publish --dry-run` | 通过,完整执行 `prepublishOnly`、`prepack` 并确认 public access;未写入 registry |
|
|
16
39
|
| `npm run test:smoke` | 通过,使用实际 `chenlongapps-opencode-token-usage-0.2.1.tgz` 安装产物 |
|
|
17
40
|
|
|
18
|
-
npm 发布前检查确认无作用域名称 `opencode-token-usage`
|
|
41
|
+
npm 发布前检查确认无作用域名称 `opencode-token-usage` 已由其他作者占用,因此本项目使用与 GitHub 仓库所有者一致的 `@chenlongapps/opencode-token-usage`。`0.2.1` 已发布到 [npm](https://www.npmjs.com/package/@chenlongapps/opencode-token-usage),registry 查询确认 `latest` 指向 `0.2.1`。包元数据、公开 registry、GitHub Actions CI 与 Trusted Publishing/OIDC 发布工作流均已配置。`npm audit` 报告 2 个 low、11 个 moderate、0 个 high、0 个 critical,均来自固定的 OpenCode 2.0.9 / OpenTUI / OpenTelemetry 依赖链,当前锁定版本下没有可直接应用的完整修复。
|
|
19
42
|
|
|
20
43
|
新增测试覆盖:已完成 assistant 的 Output + Reasoning / 流式总时长加权 TPS;无效时间、零输出与 compaction 排除;reasoning/tool 历史 TTFT、纯文本历史不伪造样本、运行期样本覆盖历史;文本、推理、工具输入三类流式增量;UTF-8 字节估算、重复事件去重、并发活动流合并;无关会话忽略、新建子代理即时纳入、切换会话树清理;流式更新不读取数据源,完成后从估算 TPS 收敛到精确 TPS;性能行位于用量与费用之后,与前一组间隔一行,并保持格式与缺失隐藏。
|
|
21
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenlongapps/opencode-token-usage",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Session-tree token usage, live performance, context window and estimated cost for OpenCode 2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"typecheck": "tsc --noEmit",
|
|
49
49
|
"test": "tsx --test test/*.test.ts",
|
|
50
50
|
"test:smoke": "node scripts/smoke.mjs",
|
|
51
|
+
"release:patch": "npm version patch",
|
|
51
52
|
"prepublishOnly": "npm run typecheck && npm test",
|
|
52
53
|
"prepack": "npm run build"
|
|
53
54
|
},
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
"registry": "https://registry.npmjs.org/"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
|
-
"@opencode/plugin": "2.0.
|
|
60
|
+
"@opencode/plugin": "2.0.11"
|
|
60
61
|
},
|
|
61
62
|
"peerDependencies": {
|
|
62
63
|
"@opentui/core": "0.5.10",
|
|
@@ -65,9 +66,9 @@
|
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
68
|
"@babel/core": "^7.28.0",
|
|
68
|
-
"@opencode/client": "2.0.
|
|
69
|
-
"@opencode/schema": "2.0.
|
|
70
|
-
"@opencode/theme": "2.0.
|
|
69
|
+
"@opencode/client": "2.0.11",
|
|
70
|
+
"@opencode/schema": "2.0.11",
|
|
71
|
+
"@opencode/theme": "2.0.11",
|
|
71
72
|
"@opentui/core": "0.5.10",
|
|
72
73
|
"@opentui/solid": "0.5.10",
|
|
73
74
|
"@types/node": "^22.0.0",
|