@dsh-agent-toolkit/token-usage 0.1.0 → 0.3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 dsh-agent-toolkit contributors
3
+ Copyright (c) 2026 EsonXie
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,30 +1,51 @@
1
1
  # @dsh-agent-toolkit/token-usage
2
2
 
3
- DeepSeek Harness(dsh)插件:按日统计 token 用量。
3
+ DeepSeek Harness plugin: per-day token usage statistics — 13-week heatmap, stacked daily chart, `/token-usage` command.
4
4
 
5
- - `/token-usage [YYYY-MM-DD]` 斜杠命令:今日 + 近 7 日汇总,或指定日期
6
- - `GET /token-usage/api/daily?date=YYYY-MM-DD` JSON 端点(web 模式)
7
- - Web UI 侧边栏用量面板(点击打开明细弹窗)
5
+ [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(dsh)插件:按日/按小时计量 token 用量。
6
+
7
+ - 13 周活动热力图 + 单日堆叠图(按模型/按项目/压缩单列),侧边栏底栏「Token 用量」打开
8
+ - `/token-usage [YYYY-MM-DD]` 命令:今日 + 近 7 日,或指定日期
9
+ - JSON API:`/dsh-agent-toolkit/api/usage/daily?date=`、`/dsh-agent-toolkit/api/usage/range?days=`(web 模式)
10
+ - 用量缺失的样本经 tokenMeter 启发式估算,估算量单列
11
+
12
+ ## 截图
13
+
14
+ ![Token 用量面板:13 周活动热力图](https://raw.githubusercontent.com/EsonXie/dsh-agent-toolkit/master/docs/usage/images/usage-modal.png)
15
+
16
+ ![单日堆叠图](https://raw.githubusercontent.com/EsonXie/dsh-agent-toolkit/master/docs/usage/images/usage-daily.png)
8
17
 
9
18
  ## 安装
10
19
 
11
- ```sh
12
- dsh plugin --profile web add @dsh-agent-toolkit/token-usage
20
+ ```bash
21
+ dsh plugin add @dsh-agent-toolkit/token-usage
13
22
  ```
14
23
 
15
- ## 配置
24
+ 包自带 `cordis.patch.yml`(bundles 层),装进 profile 后自动激活。
16
25
 
17
- | 字段 | 类型 | 默认 | 说明 |
18
- |---|---|---|---|
19
- | `timezone` | string(IANA 名) | 系统时区 | 按日聚合的分日时区 |
26
+ > **与 dsh-agent-toolkit 二选一**:`dsh-agent-toolkit` 已内置本插件全部功能(Agent 注册表/分层提示词/委派/飞书 bots + token 用量)。
27
+ > 两者同时安装时,后到实例会自动停用用量功能(不重复计量、不注册 `/token-usage` 命令与面板),先到者完整工作;仍建议只装其一。
20
28
 
21
- profile 的 `cordis.patch.yml` 中整行覆盖:
29
+ ## 配置
22
30
 
23
31
  ```yaml
24
- - id: token-usage
25
- name: '@dsh-agent-toolkit/token-usage'
32
+ - id: '@dsh-agent-toolkit/token-usage'
26
33
  config:
27
- timezone: Asia/Shanghai
34
+ timezone: Asia/Shanghai # 默认值;按日/按小时聚合的时区
28
35
  ```
29
36
 
30
- 依赖 dsh 提供 `storageDomain`、`tokenMeter`、`commands` 服务(`@deepseek-ai/dsh-base` 均含);`webServer` 为可选注入,headless/CLI 下不注册 HTTP 端点。
37
+ 修改配置触发 HMR 热替换,无需重启。
38
+
39
+ ## 运行前提
40
+
41
+ - 宿主注入服务:`storageDomain`、`tokenMeter`、`commands`(`webServer` 可选,headless/CLI 下 API 自动不注册)。
42
+ - peer dependency:`@deepseek-ai/cordis` ^4。
43
+
44
+ ## 从 0.2.x 升级
45
+
46
+ 0.3.0 起本包重写为 `dsh-agent-toolkit` workspace 的用量模块,存储域 `token_usage` 不变,历史数据保留。
47
+ 0.1.x/0.2.x 已废弃(deprecated)。
48
+
49
+ ## License
50
+
51
+ MIT
package/cordis.patch.yml CHANGED
@@ -1,7 +1,3 @@
1
- # token-usage 组合包层:profile 的 dsh.profile.bundles 列出本包时应用。
2
- # 行 name 用包名(非路径),Node 模块解析以 profile 目录为锚点找到已安装代码。
3
- # config 不写:timezone 由 Config schema 默认(系统时区),用户可在自己 profile 的
4
- # cordis.patch.yml 中整行覆盖(patch 是整行替换,不深度合并)。
5
1
  - insert:
6
- - id: token-usage
2
+ - id: '@dsh-agent-toolkit/token-usage'
7
3
  name: '@dsh-agent-toolkit/token-usage'
@@ -0,0 +1,10 @@
1
+ import { Context } from "@deepseek-ai/cordis";
2
+ //#region src/client/usage/index.d.ts
3
+ declare function setupUsageClient(ctx: Context): void;
4
+ //#endregion
5
+ //#region src/client/index.d.ts
6
+ declare const inject: string[];
7
+ declare function apply(ctx: Context): void;
8
+ //#endregion
9
+ export { apply, inject, setupUsageClient };
10
+ //# sourceMappingURL=client-module.d.ts.map