dsh-dscost-tide 0.0.0-stage → 1.0.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,57 @@
1
+ # Changelog
2
+
3
+ 本文件记录 `dsh-dscost-tide` 的发布变更。版本号遵循 [SemVer](https://semver.org/lang/zh-CN/)。
4
+
5
+ ## 1.0.1 — 2026-10-31
6
+
7
+ **修复**
8
+
9
+ - npm 包里的 README 安装命令写成了 `@yanzi-251147/dsh-dscost-tide`,而实际发布名是不带 scope 的 `dsh-dscost-tide`(`@yanzi-251147` 不是 npm 账号所拥有的 scope)。本版本把中英 README、`publish.yml`、`CHANGELOG` 里的名字全部对齐为 `dsh plugin add dsh-dscost-tide`,并改由 GitHub Actions 发布,顺带验证 CI 发布链路。
10
+
11
+ ## 1.0.0 — 2026-10-31
12
+
13
+ 首个公开版本。侧边栏底部卡片 + 点击弹窗,覆盖「现在是不是高峰时段、账户还有多少钱、这些钱花在哪些 token 上」。
14
+
15
+ **新增**
16
+
17
+ - 侧边栏底部(`sidebar.footer.action`,紧随余额插件之后)两行卡片:第一行 `● 高峰/低谷 状态`,第二行余额与当前时间;高峰红、低谷绿。
18
+ - 点击卡片打开弹窗:当前时段 Hero、计费时段(倒计时 / 下次切换 / 24 格峰谷条)、账户余额(总额 + 充值钱包 + 赠送钱包)、用量统计。
19
+ - 用量统计按 **今天 / 近 7 天 / 近 30 天 / 全部** 四个时间维度切换,四个磁贴:消耗 token、缓存命中率、消耗金额、API 请求次数;下方六行明细:提示词(命中 · 未命中)、输出(含思考)、模型调用、联网搜索、统计天数 · 日均、统计区间。
20
+ - 新增 host 路由 `GET /dsh-dscost-tide/api/usage?range=today|7d|30d|all[&refresh=1]`:通过宿主 `sessionPersistence` 服务折叠会话日志,按每条事件的自身时刻套用当时的峰谷价,fork/子代理会话按 `inheritedEventCount` 跳过父前缀。
21
+ - 新增 host 路由 `GET /dsh-dscost-tide/api/balance`:优先读宿主账户余额,回退到 `DEEPSEEK_API_KEY` 查询。
22
+ - 离线测试 `test/plugin.test.mjs`(`node --test test/plugin.test.mjs`)。
23
+
24
+ **变更**
25
+
26
+ - 行 id 与座位占用 id 统一为插件名(先改名 `dsh-deepseek-tide`,最终随仓库定名 `dsh-dscost-tide`;更早是 `deepseek-tide`),避免与其他峰谷插件撞 id。
27
+ - 项目定名 **`dsh-dscost-tide`**(与 GitHub 仓库同名),npm 发布名同为 `dsh-dscost-tide`(不带 scope,2026-10-31 已发布 1.0.0);回环路由前缀随之改为 `/dsh-dscost-tide/api`。
28
+ - 包元数据补全:`repository` / `homepage` / `bugs` / `keywords` / `files` / `engines`,可用于 npm 发布与插件市场收录。
29
+
30
+ ## 0.4.1 — 2026-10-31
31
+
32
+ **变更**
33
+
34
+ - 弹窗「计费时段」区精简:删去「当前时段」「当前计费区间」两行(峰谷状态已由 Hero 胶囊表达),再删去「计费规则」行与逐日明细列表。现在该区只保留 `倒计时` / `下次切换` 两行与 24 格峰谷条,用量区只保留四个磁贴 + 六行统计。
35
+
36
+ ## 0.4.0 — 2026-10-05
37
+
38
+ **新增**
39
+
40
+ - 弹窗内直接展示用量:去掉右下角「用量明细」外链按钮,改为内嵌「用量统计」区,支持四个时间维度切换。
41
+
42
+ ## 0.3.0 — 2026-09
43
+
44
+ **新增**
45
+
46
+ - 仿 `dsh-ui-usage-billing` 排布的重排弹窗:Hero 时段、计费时段、账户余额三区,右下角两个动作(充值 / 刷新)。
47
+ - 余额口径修正为「充值钱包 + 赠送钱包」之和。
48
+
49
+ ## 0.2.0 — 2026-09
50
+
51
+ **变更**
52
+
53
+ - 卡片改为两行、与侧边栏等宽;第二行右侧显示当前时间(不再显示峰谷切换时刻)。
54
+
55
+ ## 0.1.0 — 2026-09
56
+
57
+ - 首个可运行版本:侧边栏底部按高峰 / 低谷染色的小卡片。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-dscost-tide contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md ADDED
@@ -0,0 +1,105 @@
1
+ # dsh-dscost-tide
2
+
3
+ > One glance at the DeepSeek Harness sidebar footer tells you **whether DeepSeek is in its peak-priced window, how much balance you have left, and where those tokens went.**
4
+
5
+ A DSH bundle plugin that occupies the `sidebar.footer.action` seat in the sidebar footer, right after the built-in balance widget.
6
+
7
+ ## What you get
8
+
9
+ A two-row card in the sidebar footer, tinted red during peak hours and green off-peak, plus a click-through dashboard.
10
+
11
+ ```
12
+ ● Peak 2h 30m to off-peak
13
+ ¥6.77 14:32
14
+ ```
15
+
16
+ The dashboard is split into four sections: a peak-phase hero, the pricing schedule (countdown, next switch, 24-hour strip), the account balance (total, topped-up wallet, granted wallet), and usage statistics.
17
+
18
+ ```
19
+ Usage [Today][7 days][30 days][All time]
20
+ Tokens 10.69M Cache hit rate 95.57%
21
+ Cost ¥1.27 API requests 137
22
+ Prompt 10,550,026 (hit 10,082,816 · miss 467,210)
23
+ Output 149,427
24
+ Model calls 137 · ¥1.2666
25
+ Web search 0 · ¥0.0000
26
+ Days 6 · avg ¥0.2111
27
+ Window 2026-10-05 to 2026-10-05
28
+ ```
29
+
30
+ ## Features
31
+
32
+ - **Peak/valley at a glance** — official windows (Beijing time, weekdays 09:00–12:00 and 14:00–18:00 are peak; everything else, including whole weekends since 2026-08-23, is off-peak), with a live countdown to the next switch.
33
+ - **Account balance** — the Host's authorized DeepSeek account balance (topped-up + granted wallets), falling back to `DEEPSEEK_API_KEY` against `api.deepseek.com/user/balance`.
34
+ - **Usage by time dimension** — `today` / `7 days` / `30 days` / `all time`, with consumed tokens, cache hit rate, cost and API request count, plus the prompt hit/miss split, output, model calls, web-search calls, daily average and covered window.
35
+ - **Real prices** — every `assistant/message` usage record is priced with the band in force **at its own timestamp** (including the 2026-09-10 12:00 flash reprice); web searches are billed at ¥0.02 each.
36
+ - **Quiet** — usage is fetched only while the dashboard is open, and folded session logs are memoised by their revision so a refresh only re-reads what changed.
37
+
38
+ ## Install
39
+
40
+ ### From the plugin catalogue
41
+
42
+ Once published:
43
+
44
+ ```bash
45
+ dsh plugin add dsh-dscost-tide
46
+ ```
47
+
48
+ or open it in **Plugins → Installed**. Afterwards, **fully quit and restart DeepSeek Harness** — the client bundle is preloaded at startup, so a hot reload cannot pick up new UI code.
49
+
50
+ ### From local source (`link:`)
51
+
52
+ For development, add to `~/.dsh/profiles/<profile>/package.json`:
53
+
54
+ ```json
55
+ {
56
+ "dependencies": { "dsh-dscost-tide": "link:E:/path/to/dsh-dscost-tide" },
57
+ "dsh": { "profile": { "bundles": ["...", "dsh-dscost-tide"] } }
58
+ }
59
+ ```
60
+
61
+ Then run `pnpm install` in the profile directory and restart DSH.
62
+
63
+ ## Pricing model
64
+
65
+ | Family | Off-peak input | Off-peak cache hit | Off-peak output | Peak |
66
+ | --- | ---: | ---: | ---: | ---: |
67
+ | Flash (`deepseek-v4-flash`, `deepseek-flash`) | ¥1 / 1M | ¥0.02 / 1M | ¥4 / 1M | ×2 |
68
+ | Flash before 2026-09-10 12:00 | ¥1.5 / 1M | ¥0.05 / 1M | ¥4.5 / 1M | ×2 |
69
+ | Pro (`deepseek-v4-pro`) | ¥4.5 / 1M | ¥0.15 / 1M | ¥13.5 / 1M | ×2 |
70
+
71
+ Peak/valley pricing starts 2026-08-17; older records are charged the off-peak rate. Amounts are CNY. If a number disagrees with your bill, the [official price page](https://api-docs.deepseek.com/quick_start/pricing) wins.
72
+
73
+ ## Data and privacy
74
+
75
+ - **Phase** is computed locally from the wall clock — no network.
76
+ - **Balance** comes from the Host's account grant (or your `DEEPSEEK_API_KEY`), exposed on the loopback route `/dsh-dscost-tide/api/balance`.
77
+ - **Usage** is folded from local `~/.dsh/sessions/**` logs only. Message content is never read or sent anywhere; fork/sub-agent sessions skip their inherited parent prefix via `inheritedEventCount`.
78
+ - Both routes serve loopback requests only: the `Host` header must be loopback/trusted, cross-site requests are refused, and `Origin` must match.
79
+
80
+ ## Compatibility
81
+
82
+ - DeepSeek Harness **0.2.x** (`engines.dsh: >=0.2.0-rc.1 <0.3.0-0`), verified on `0.2.1-rc.5` (Windows desktop).
83
+ - The browser half uses `@deepseek-ai/dsh-client-ui-primitives` when present and falls back to its own modal otherwise.
84
+ - Node.js ≥ 22 is only needed for development and tests.
85
+
86
+ ## Development
87
+
88
+ ```bash
89
+ node --test test/plugin.test.mjs # offline unit tests, no DSH runtime needed
90
+ node scripts/check-publish.mjs # manifest / files / placeholder checks
91
+ node scripts/prepare-publish.mjs # build the publishable copy and pack it
92
+ ```
93
+
94
+ The working tree keeps `"name": "dsh-dscost-tide"` (it is the install key in the profile's `dependencies` / `dsh.profile.bundles`), and that same unscoped name is used on npm, so publishing starts with:
95
+
96
+ ```bash
97
+ node scripts/prepare-publish.mjs --repo yanzi-251147/dsh-dscost-tide
98
+ cd _intermediate/publish && npm publish --access public
99
+ ```
100
+
101
+ > npm writes a `0.0.0-stage` placeholder version when the package is first created and then uploads the real version — that is npm's current policy for bypass-2FA tokens, not a failure. One `npm publish` is enough; no approval step is involved.
102
+
103
+ ## License
104
+
105
+ [MIT](./LICENSE)
package/README.md CHANGED
@@ -1,3 +1,132 @@
1
- # Temporary Holding Version
1
+ # dsh-dscost-tide
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > 在 DeepSeek Harness 侧边栏底部看一眼就知道:**现在是高峰还是低谷、账户还有多少钱、这些钱花在哪些 token 上。**
4
+
5
+ 一个 DSH 组合包(Cordis 插件)插件,占用侧边栏底部的 `sidebar.footer.action` 座位,排在官方余额插件之后。
6
+
7
+ ## 长什么样
8
+
9
+ 侧边栏底部是一张两行卡片,高峰染红、低谷染绿:
10
+
11
+ ```
12
+ ● 高峰期 距入谷 2 小时 30 分
13
+ ¥余额 14:32
14
+ ```
15
+
16
+ 点一下卡片弹出详情(四个区):
17
+
18
+ ```
19
+ 现在 高峰期
20
+ 高峰按时段价,低谷五折 ← Hero 胶囊
21
+
22
+ 计费时段
23
+ 倒计时 距入谷 2 小时 30 分
24
+ 下次切换 今天 12:00(入谷)
25
+ [ 24 格峰谷条:凌晨 / 上午 / 午后 / 晚间 ]
26
+
27
+ 账户余额
28
+ 总额 ¥数字
29
+ 充值钱包 ¥数字
30
+ 赠送钱包 ¥数字
31
+
32
+ 用量统计 [今天][近 7 天][近 30 天][全部]
33
+ 消耗 token 1,069 万 缓存命中率 95.57%
34
+ 消耗金额 ¥1.27 API 请求次数 137
35
+ 提示词 10,550,026(命中 10,082,816 · 未命中 467,210)
36
+ 输出 149,427
37
+ 模型调用 137 次 · ¥1.2666
38
+ 联网搜索 0 次 · ¥0.0000
39
+ 统计天数 6 天 · 日均 ¥0.2111
40
+ 统计区间 2026-10-05 至 2026-10-05
41
+ ```
42
+
43
+ ## 功能
44
+
45
+ - **峰谷一眼可见**:按官方峰谷时段(北京时间工作日 09:00–12:00、14:00–18:00 为高峰,其余为低谷;2026-08-23 起周末全天低谷)给卡片染色,并显示距下次切换的倒计时。
46
+ - **账户余额**:优先读取 Host 已授权的 DeepSeek 账户余额(充值钱包 + 赠送钱包),读不到时回退到 `DEEPSEEK_API_KEY` 查询 `api.deepseek.com/user/balance`。
47
+ - **用量统计(按时间维度)**:`今天` / `近 7 天` / `近 30 天` / `全部` 四档,给出消耗 token、缓存命中率、消耗金额、API 请求次数,以及提示词命中/未命中、输出、模型调用、联网搜索、日均与统计区间。
48
+ - **真实计价**:token 不估算,逐个 `assistant/message` 事件按**它自己的时间戳**套用当时生效的峰谷价(含 2026-09-10 12:00 的 Flash 调价),联网搜索按 ¥0.02/次计。
49
+ - **不打扰**:只在弹窗打开时拉取用量;折叠结果按会话日志版本号缓存,刷新只重读变化的日志。
50
+
51
+ ## 安装
52
+
53
+ ### 方式一:作为组合包安装(推荐)
54
+
55
+ 发布到 npm 之后,在 DSH 的 **插件** 页直接安装并启用:
56
+
57
+ ```bash
58
+ npm install -g dsh # 已有 DSH 可跳过
59
+ dsh plugin add dsh-dscost-tide
60
+ ```
61
+
62
+ 或在「插件 → 已安装」里打开本插件。装好后**完全退出并重启 DeepSeek Harness**(客户端 bundle 在启动时预载,热更新拿不到新的 UI 代码)。
63
+
64
+ ### 方式二:从本地源码 `link:` 安装
65
+
66
+ 适合改代码调试。编辑 `~/.dsh/profiles/<profile>/package.json`:
67
+
68
+ ```json
69
+ {
70
+ "dependencies": {
71
+ "dsh-dscost-tide": "link:E:/path/to/dsh-dscost-tide"
72
+ },
73
+ "dsh": {
74
+ "profile": {
75
+ "bundles": ["...", "dsh-dscost-tide"]
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ 然后在 profile 目录执行一次 `pnpm install`,再完全重启 DSH。源码改动同样需要重启才能生效。
82
+
83
+ ### 卸载
84
+
85
+ 在插件页关闭或移除即可;手动安装的话,删掉 `dependencies` 与 `dsh.profile.bundles` 里的条目,重启。
86
+
87
+ ## 计费口径
88
+
89
+ | 模型族 | 低谷 · 输入 | 低谷 · 缓存命中 | 低谷 · 输出 | 高峰 |
90
+ | --- | ---: | ---: | ---: | ---: |
91
+ | Flash(`deepseek-v4-flash` / `deepseek-flash`) | ¥1 / 1M | ¥0.02 / 1M | ¥4 / 1M | ×2 |
92
+ | Flash(2026-09-10 12:00 之前) | ¥1.5 / 1M | ¥0.05 / 1M | ¥4.5 / 1M | ×2 |
93
+ | Pro(`deepseek-v4-pro`) | ¥4.5 / 1M | ¥0.15 / 1M | ¥13.5 / 1M | ×2 |
94
+
95
+ - 高峰窗口:北京时间 **工作日 09:00–12:00、14:00–18:00**;低谷 = 其余时间(2026-08-23 起含周末全天)。
96
+ - 峰谷价自 **2026-08-17** 起生效;更早的会话按低谷价计。
97
+ - 一次调用的花费 = `未命中 token × 输入价 + 命中 token × 缓存价 + 输出 token × 输出价`;联网搜索另计 ¥0.02/次。
98
+ - 金额单位 CNY。价格随官方调整而变化,若与账单有出入,以 [DeepSeek 官方定价](https://api-docs.deepseek.com/quick_start/pricing) 为准。
99
+
100
+ ## 数据来源与隐私
101
+
102
+ - **峰谷**:纯本地时钟计算,不联网。
103
+ - **余额**:Host 侧账户授权(或你配置的 `DEEPSEEK_API_KEY`)向 DeepSeek 查询,只走本机回环路由 `/dsh-dscost-tide/api/balance`。
104
+ - **用量**:只读本机 `~/.dsh/sessions/**` 会话日志,不读取、不外发任何消息内容;fork/子代理会话按 `inheritedEventCount` 跳过继承的父前缀,避免重复计数。
105
+ - 两条路由都只服务本机回环请求:校验 `Host` 必须是回环或受信主机,拒绝跨站请求与不匹配的 `Origin`。
106
+
107
+ ## 兼容性
108
+
109
+ - 需要 DeepSeek Harness **0.2.x**(`engines.dsh: >=0.2.0-rc.1 <0.3.0-0`),在 `0.2.1-rc.5`(Windows 桌面端)上验证。
110
+ - 浏览器端需要 `@deepseek-ai/dsh-client-ui-primitives`(存在时使用其 `Modal`,缺失时自动回退到自带遮罩层)。
111
+ - Node.js ≥ 22(仅开发/测试需要)。
112
+
113
+ ## 开发
114
+
115
+ ```bash
116
+ node --test test/plugin.test.mjs # 纯函数级离线测试,不需要 DSH 运行时
117
+ node scripts/check-publish.mjs # 发布前自检(清单字段 / 文件 / 占位符)
118
+ node scripts/prepare-publish.mjs # 生成可发布副本并打包,打印 tarball 内容
119
+ ```
120
+
121
+ `prepare-publish` 会把可发布的文件复制到 `_intermediate/publish/`,并改写仓库地址。本地工作树里的 `name` 保持 `dsh-dscost-tide` 不动(它是 profile `dependencies` / `dsh.profile.bundles` 里的安装键),npm 上的包名也沿用同一个,发布前跑一次:
122
+
123
+ ```bash
124
+ node scripts/prepare-publish.mjs --repo yanzi-251147/dsh-dscost-tide
125
+ cd _intermediate/publish && npm publish --access public
126
+ ```
127
+
128
+ > npm 会先在建包时写一个 `0.0.0-stage` 占位版本再上传正式版本,这是 npm 对 bypass-2FA token 的新策略,属正常现象。发布只需要一次 `npm publish`,无需再批准。
129
+
130
+ ## 许可
131
+
132
+ [MIT](./LICENSE)
@@ -0,0 +1,5 @@
1
+ # dsh bundle patch: mount the dsh-dscost-tide row when this package is
2
+ # enabled in a profile. Mirrors the @ychris12138/dsh-usage-stats install layout.
3
+ - insert:
4
+ - id: dsh-dscost-tide
5
+ name: dsh-dscost-tide