dsh-usage-bar 0.0.0-stage → 0.2.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.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -2
  3. package/Versions/Alpha Release/A-v0.1.0.md +45 -0
  4. package/Versions/Alpha Release/A-v0.1.1.md +45 -0
  5. package/Versions/Alpha Release/A-v0.1.3.md +51 -0
  6. package/Versions/Alpha Release/A-v0.1.4.md +35 -0
  7. package/Versions/Alpha Release/A-v0.1.5.md +42 -0
  8. package/Versions/Alpha Release/A-v0.1.6.md +46 -0
  9. package/Versions/Alpha Release/A-v0.1.7.md +39 -0
  10. package/Versions/Alpha Release/A-v0.1.8.md +37 -0
  11. package/Versions/Beta Release/B-v0.2.0.md +50 -0
  12. package/Versions/Official Release/R-v0.1.0.md +38 -0
  13. package/Versions/README.md +49 -0
  14. package/Versions/_template.md +40 -0
  15. package/cordis.patch.yml +4 -0
  16. package/docs/DETAIL.md +250 -0
  17. package/docs/Development.md +98 -0
  18. package/docs/assets/backfill.png +0 -0
  19. package/docs/assets/handoff.png +0 -0
  20. package/docs/assets/hero.png +0 -0
  21. package/docs/assets/logo.svg +4 -0
  22. package/docs/assets/sidebar.png +0 -0
  23. package/docs/readme/README_zh.md +229 -0
  24. package/docs/releases/B-v0.2.0.md +86 -0
  25. package/docs/releases/_template.md +51 -0
  26. package/icon.svg +4 -0
  27. package/locale/en.json +7 -0
  28. package/locale/zh.json +7 -0
  29. package/package.json +60 -4
  30. package/src/client.js +1529 -0
  31. package/src/index.js +663 -0
  32. package/src/lib/bili-stats.js +69 -0
  33. package/src/lib/ledger-stats.js +162 -0
  34. package/src/lib/session-context.js +185 -0
  35. package/src/lib/usage-backfill.js +81 -0
  36. package/src/lib/usage-migration.js +19 -0
  37. package/src/lib/usage-store.js +232 -0
  38. package/tint.example.json +7 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HydronPlus
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.md CHANGED
@@ -1,3 +1,151 @@
1
- # Temporary Holding Version
1
+ <div align="center">
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
+ <img src="docs/assets/logo.svg" alt="dsh-usage-bar logo" width="96">
4
+
5
+ # dsh-usage-bar
6
+
7
+ ### A live progress bar for the cumulative billed input tokens of a DSH session.
8
+
9
+ **Know when the context is about to run out, before it does.**
10
+
11
+ [![GitHub stars](https://img.shields.io/github/stars/HydronPlus/dsh-usage-bar?style=flat-square&label=stars)](https://github.com/HydronPlus/dsh-usage-bar/stargazers)
12
+ [![npm downloads](https://img.shields.io/npm/dm/dsh-usage-bar?style=flat-square&label=npm%20downloads)](https://www.npmjs.com/package/dsh-usage-bar)
13
+ [![license](https://img.shields.io/badge/license-MIT-f4c430?style=flat-square)](LICENSE)
14
+
15
+ **English** · [简体中文](docs/readme/README_zh.md)
16
+
17
+ [Quick start](#quick-start) · [Features](#features) · [Documentation](#documentation) · [Releases](https://github.com/HydronPlus/dsh-usage-bar/releases) · [FAQ](#faq)
18
+
19
+ </div>
20
+
21
+ > [!IMPORTANT]
22
+ > Install from the [npm package](https://www.npmjs.com/package/dsh-usage-bar) or this repository. A copied README does not make a download official.
23
+
24
+ ---
25
+
26
+ ## What it does
27
+
28
+ `dsh-usage-bar` adds one persistent line to the DSH session header — the row that already holds `Create #1`, `标准模式` and `费用明细`. The bar sits right after the billing entry and before the sub-agent counter:
29
+
30
+ ```
31
+ 累计计费输入 Tokens [▓▓▓▓░░░░░░] 250M / 500M · 50.0%
32
+ ```
33
+
34
+ It measures **cumulative billed input**: every input token this conversation has sent so far, including the system prompt, tool schemas and the full history that is re-sent on every turn. It is **not** the context-window occupancy.
35
+
36
+ The bar and both numbers change colour by ratio: green up to 40%, white to 60%, yellow from the `warn` threshold, red from `danger` (defaults 60% / 80%). The track's yellow and red hatching zones follow the same `warn` / `danger` thresholds, and once the configured `window` is reached the bar stays full and red. The green band (0–40%) also shows green hatching on the part not yet covered by the fill, so the green zone reads as textured while the fill itself stays solid.
37
+
38
+ | Metric | Source |
39
+ | --- | --- |
40
+ | Cumulative input `inputTokens` | Primary: `ledger.json` from `cost-meter` (`input + cacheRead`, summed across days). Fallback 1: `sessions[].inputTokens` from `billion-context`. Fallback 2: the plugin's own usage store |
41
+ | Context window usage `contextTokens / contextWindow` | `billion-context` `/__bili/stats` |
42
+ | Requests and folded blocks | The larger value of the available sources |
43
+
44
+ Every source is a lower bound — `billion-context` only remembers sessions this process has seen, the `cost-meter` ledger is capped in length, and the self-sampled store only counts usage after this plugin was installed — so the merge takes the larger value and keeps a `source` field saying which ones were used. When `cost-meter` and `billion-context` are both absent, the plugin still records new usage from DSH's `assistant/message` events into `~/.dsh/storages/dsh-usage-bar/usage.json`, so the bar keeps working on its own (it starts empty and only counts new turns). If an older conversation has no self-sampled history, the conversation area shows a「dsh-usage-bar」warning above the chat; click「统计历史Tokens」to scan that session's log and fold its history into the baseline. Only the current session is scanned.
45
+
46
+ The project was originally named ContextMeter; `dsh-usage-bar` is the public name.
47
+
48
+ ## Screenshots
49
+
50
+ <img src="docs/assets/hero.png" alt="Header bar in four colour states: green 25%, white 50%, yellow 70%, red 92%" width="100%">
51
+
52
+ The header bar changes colour with the cumulative billed input ratio: green below 40%, white to 60%, yellow from `warn`, red from `danger`. The hatched warning zones move with the thresholds, and the green band shows green hatching on the part not yet covered by the fill.
53
+
54
+ <img src="docs/assets/sidebar.png" alt="Sidebar session row with the ∅ disable button, in normal and disabled states" width="100%">
55
+
56
+ The ∅ button on the right of a session title toggles the disabled look: the title dims and gets a strikethrough. Title colouring by ratio is described above.
57
+
58
+ <img src="docs/assets/backfill.png" alt="Only-new-tokens warning with a count-previous button, and a backfill progress bar" width="100%">
59
+
60
+ When an older conversation has no self-sampled history, the conversation area shows a「dsh-usage-bar」warning with a「统计历史Tokens」button. The button scans that session's log and shows a progress bar; while it fills it keeps showing「统计中」and the「取消」button, and only switches to「完成」at 100%. The fill advances at a fixed 25% per second from the current value, then the history is folded into the baseline, the warning disappears, and the bar shows the total.
61
+
62
+ ## Quick start
63
+
64
+ ### Requirements
65
+
66
+ - DSH `>=0.2.0-rc.1` (see `engines.dsh` in `package.json`)
67
+ - The client bundle loads at startup, so **restart DSH after installing** — reloading the page is not enough
68
+
69
+ ### Install
70
+
71
+ ```bash
72
+ dsh plugin --profile <profile> add dsh-usage-bar
73
+ ```
74
+
75
+ Or straight from this repository:
76
+
77
+ ```bash
78
+ dsh plugin --profile <profile> add github:HydronPlus/dsh-usage-bar
79
+ ```
80
+
81
+ `<profile>` is the directory name under `~/.dsh/profiles/`, usually `desktop`.
82
+
83
+ ### Use
84
+
85
+ Restart DSH and open any conversation. The bar appears in the header next to the billing entry.
86
+
87
+ ### Update
88
+
89
+ ```bash
90
+ dsh plugin --profile <profile> add dsh-usage-bar@latest
91
+ ```
92
+
93
+ ## Features
94
+
95
+ ### Session row tinting
96
+
97
+ Session titles in the sidebar follow the same numbers: yellow from `warn`, red from `danger`, both measured against `window` in `tint.json`. The same file also accepts `warnColor` / `dangerColor`; all fields take effect within 5 seconds, without restarting DSH.
98
+
99
+ ### Mark as disabled
100
+
101
+ Hovering a session reveals a ∅ button left of the `…` menu. Clicking it dims the title and strikes it through while keeping the `#N` suffix readable, so a handed-off conversation stands out in the list. It only changes how the row looks — nothing is deleted, archived or stopped. The state is stored in `disabled.json` and survives restarts.
102
+
103
+ ### Handoff commands
104
+
105
+ Two slash commands appear in the `/` menu: `/handoff` writes a handoff file, opens a new conversation and pre-fills its draft; `/handoff-file` only writes the file.
106
+
107
+ <img src="docs/assets/handoff.png" alt="Slash command menu with handoff and handoff-file highlighted" width="100%">
108
+
109
+ ## Documentation
110
+
111
+ | Document | Contents |
112
+ | --- | --- |
113
+ | [简体中文](docs/readme/README_zh.md) | Full Chinese README, including local link installation and rollback |
114
+ | [Technical notes](docs/DETAIL.md) | Data sources, host and client halves, DOM tinting, disable state |
115
+ | [Development notes](docs/Development.md) | Directory layout, offline smoke test, debug channel, release steps |
116
+ | [CHANGELOG](CHANGELOG.md) | Version history |
117
+ | [Version log](Versions/README.md) | R/A/B version index and per-version change log |
118
+ | [Releases](https://github.com/HydronPlus/dsh-usage-bar/releases) | Published release notes |
119
+
120
+ ## How it works
121
+
122
+ ```
123
+ Browser (src/client.js) host (src/index.js) source
124
+ fetch /context-meter/stats ──► webServer route (same origin) ──┬──► ~/.dsh/storages/cost-meter/ledger.json
125
+ polls every 4 s reads files / fetches on Node ├──► 127.0.0.1:18787/__bili/stats
126
+ └──► ~/.dsh/storages/dsh-usage-bar/usage.json
127
+ ```
128
+
129
+ The browser cannot call port 18787 directly — the stats service sends no CORS headers — and cannot read `~/.dsh`, so the host half proxies all three sources. The third one is written by the plugin itself from `assistant/message` events.
130
+
131
+ ## FAQ
132
+
133
+ ### Why does a brand-new conversation show `-- / 500M`?
134
+
135
+ No source has a record until the first turn completes. The numbers appear after that turn. The denominator is `window` from `tint.json` (500M by default), and the empty label uses the same value. Without `cost-meter` / `billion-context`, the self-sampled store starts empty and only counts new turns; older conversations show the「dsh-usage-bar」warning above the conversation area, with a button to backfill.
136
+
137
+ ### Why do very old conversations still show `--`?
138
+
139
+ They predate every available source: the `cost-meter` ledger retention window, the current `billion-context` process, and the self-sampled store (which only starts when this plugin is installed). Use the「统计历史Tokens」button above the conversation area to scan that session's log and backfill its history; only when the log itself is missing will the bar stay at `--`.
140
+
141
+ ### Why is there no bar in the header?
142
+
143
+ The plugin registers at `conversation.session.header.actions` with order 2. If that action area is too narrow, the host clips or fades the content — that is the slot contract, not a bug.
144
+
145
+ ### Why are the labels in Chinese?
146
+
147
+ The UI strings are hard-coded Chinese; `locale/*.json` is only used by the plugin manager. Localizing the bar is tracked as future work.
148
+
149
+ ## License
150
+
151
+ [MIT](LICENSE)
@@ -0,0 +1,45 @@
1
+ # dsh-usage-bar: A-v0.1.0
2
+ Alpha Release-v0.1.0
3
+
4
+ - 版本名称:Alpha Release
5
+ - 版本号:A-v0.1.0
6
+ - 上一版:无(规范起点;0.1.0 已由 Official Release 发布,本条为同号开发起点)
7
+ - 日期:2026-12-05
8
+
9
+ ## 相较上一版的修改
10
+
11
+ ### 新增
12
+
13
+ - 从当前代码状态开始记录版本日志;不追溯 0.1.0 之前的历史,旧变更见 `CHANGELOG.md` 的 0.1.0 条目。
14
+ - 新增 `Versions/` 目录与 `scripts/version.mjs`,用 `Versions/README.md` 做索引。
15
+
16
+ ### 修复
17
+
18
+ - 无。
19
+
20
+ ### 文档
21
+
22
+ - 新增版本管理规范与项目内版本日志模板。
23
+
24
+ ### 内部
25
+
26
+ - `package.json.version` 从 0.1.1 调整为 0.1.0,与日志保持同一版本号;这是规范化起点,不是重新发布 0.1.0 npm 包。
27
+
28
+ ## 验证
29
+
30
+ - `node scripts/version.mjs check`:通过。
31
+ - `node --check src/index.js`:通过。
32
+ - `node --check src/client.js`:通过。
33
+ - `node tests/smoke.mjs`:SMOKE PASS。
34
+ - 未运行:重启 DSH 后的目视验证。
35
+
36
+ ## 已知限制
37
+
38
+ - 自采用量只统计插件启用后新产生的事件;旧对话通过顶栏「统计此前」按需回填。
39
+ - 侧栏标题着色依赖 cost-meter / billion-context 的会话数据,两者都没有时不显示会话行。
40
+
41
+ ## 关联
42
+
43
+ - commit:`385875a`(功能提交)
44
+ - tag:—(Alpha Release 版本不打 tag)
45
+ - Release:—(Alpha Release 版本不发 Release)
@@ -0,0 +1,45 @@
1
+ # dsh-usage-bar: A-v0.1.1
2
+ Alpha Release-A-v0.1.1
3
+
4
+ - 版本名称:Alpha Release
5
+ - 版本号:A-v0.1.1
6
+ - 上一版:A-v0.1.0
7
+ - 日期:2026-12-05
8
+
9
+ ## 相较上一版的修改
10
+
11
+ ### 新增
12
+
13
+ - 「仅计入新增」警告从顶栏移到对话区上方居中,位置对齐 DSH 的「会话已归档」提示;本版常驻显示,方便确认位置和样式。
14
+ - 警告条在视口宽度变化时重新测量位置,保持在会话 tab 行下方。
15
+
16
+ ### 修复
17
+
18
+ - 警告条不再依赖 `migration.needed`,只要当前会话有 id 就显示,避免旧对话首次启用时顶栏没有提示。
19
+ - 本版先不显示回填进度条,回填进行中只显示「统计中…」,把位置调整和进度 UI 拆成两次改动。
20
+
21
+ ### 文档
22
+
23
+ - README、中文 README、DETAIL 同步警告条的新位置和「本版常驻、暂不含进度条」。
24
+ - README 增加 `hero.png` / `sidebar.png` / `backfill.png` 三张示意图(`scripts/render-readme-assets.py` 生成),中英文 README 都能看到。
25
+
26
+ ### 内部
27
+
28
+ - 客户端改用 `ReactDOM.createPortal` 把警告挂到 `document.body`,避免被顶栏或对话区裁剪;新增 `bannerTop()` 纯函数与每秒重测逻辑。
29
+
30
+ ## 验证
31
+
32
+ - `node --check src/client.js` 通过。
33
+ - `node tests/smoke.mjs` 输出 `SMOKE PASS`,新增 `bannerTop(0)=48`、`bannerTop(52)=62`、`bannerTop(undefined)=48` 断言。
34
+ - 未运行:重启 DSH 后的浏览器内目视验证(需要重启宿主,按约定由用户执行)。
35
+
36
+ ## 已知限制
37
+
38
+ - 警告条位置靠 `[role="tablist"]` 的 `getBoundingClientRect()` 测量,DSH 若改 tab 行结构会回落到 48px。
39
+ - 回填按钮仍会发起回填,但本版隐藏了进度条;回填进行中只显示「统计中…」。
40
+
41
+ ## 关联
42
+
43
+ - commit:bf9ef3d
44
+ - tag:—(Alpha Release 版本留空)
45
+ - Release:—(Alpha Release 版本留空)
@@ -0,0 +1,51 @@
1
+ # dsh-usage-bar: A-v0.1.3
2
+ Alpha Release-A-v0.1.3
3
+
4
+ - 版本名称:Alpha Release
5
+ - 版本号:A-v0.1.3
6
+ - 上一版:A-v0.1.1
7
+ - 日期:2026-12-05
8
+
9
+ > A-v0.1.2 的「演示进度」改动没有单独落盘成版本;本次把演示替换为真实回填,并一并记录。
10
+
11
+ ## 相较上一版的修改
12
+
13
+ ### 新增
14
+
15
+ - 警告条文案改为「dsh-usage-bar(估算值)」,明确当前累计是新增量或回填后的估算值。
16
+ - 「统计历史Tokens」按钮改为调用真实回填:读取当前对话的会话日志、累加历史 usage、写入自采基线,完成后顶栏显示总 tokens 并让警告消失。
17
+ - 回填过程中显示真实进度条和百分比(来自 host 端扫描进度),按钮隐藏,不再提供「取消」。
18
+ - 只有自采缺历史、且 cost-meter / billion-context 都没有该会话数据时才显示警告;有外部数据、新会话或已回填过都不弹。
19
+
20
+ ### 修复
21
+
22
+ - 修复上一版按钮只播放演示进度、不写回填结果的问题。
23
+ - 回填失败时恢复「重试」按钮,并用 title 显示错误原因。
24
+
25
+ ### 文档
26
+
27
+ - README / README_zh / DETAIL 同步警告文案、按钮名称和真实回填行为。
28
+
29
+ ### 内部
30
+
31
+ - 移除 `demoProgressAt`、演示计时器和「取消」按钮相关逻辑。
32
+ - smoke 断言改为新的警告文案与按钮文案。
33
+
34
+ ## 验证
35
+
36
+ - `node --check src/client.js`:通过。
37
+ - `node tests/smoke.mjs`:`SMOKE PASS`(22 会话,账本命中 274.87M,`usage-store fold/persist`、`backfill scan/migration`、槽位断言通过)。
38
+ - `node scripts/version.mjs check`:见本轮执行结果。
39
+ - 未运行:重启 DSH 后在真实界面点「统计历史Tokens」,确认进度条、完成后警告消失、顶栏数字更新。
40
+
41
+ ## 已知限制
42
+
43
+ - 回填只扫描当前会话,不回溯其他会话;会话日志超过 200 MB 时提示不支持。
44
+ - 回填依赖 host 的 `session/event` 与 `~/.dsh/sessions` 日志,日志缺失时只能提示、无法补算。
45
+ - 本版未改动 npm 发布内容,仍是本地 Alpha。
46
+
47
+ ## 关联
48
+
49
+ - commit:385faba
50
+ - tag:—(Alpha Release 版本留空)
51
+ - Release:—(Alpha Release 版本留空)
@@ -0,0 +1,35 @@
1
+ # dsh-usage-bar: A-v0.1.4
2
+ Alpha Release-A-v0.1.4
3
+
4
+ - 版本名称:Alpha Release
5
+ - 版本号:A-v0.1.4
6
+ - 上一版:A-v0.1.3
7
+ - 日期:2026-12-05
8
+
9
+ ## 相较上一版的修改
10
+
11
+ ### 新增
12
+
13
+ - 增加调试开关:在浏览器 DevTools 执行 `localStorage.setItem('cm-warn', 'always')`,黄色警告会在有外部数据时也常驻显示,方便观察样式;`localStorage.removeItem('cm-warn')` 恢复默认的条件显示。
14
+ - 中英文 FAQ 补充该开关的用法。
15
+
16
+ ### 内部
17
+
18
+ - 新增 `warnAlways()`,读取 `localStorage` 或 `window.__CM_WARN_ALWAYS__`,异常时静默返回 false。
19
+ - `showWarn` 改为 `warnAlways() || migration.needed`,生产判定不变。
20
+
21
+ ## 验证
22
+
23
+ - `node --check src/client.js`:通过。
24
+ - `node tests/smoke.mjs`:`SMOKE PASS`。
25
+ - 未运行:重启 DSH 后在 DevTools 设置开关,确认警告常驻与恢复。
26
+
27
+ ## 已知限制
28
+
29
+ - 开关只影响当前浏览器,不写入配置文件,也不改变其他用户的行为。
30
+
31
+ ## 关联
32
+
33
+ - commit:e738506
34
+ - tag:—(Alpha Release 版本留空)
35
+ - Release:—(Alpha Release 版本留空)
@@ -0,0 +1,42 @@
1
+ # dsh-usage-bar: A-v0.1.5
2
+ Alpha Release-A-v0.1.5
3
+
4
+ - 版本名称:Alpha Release
5
+ - 版本号:A-v0.1.5
6
+ - 上一版:A-v0.1.4
7
+ - 日期:2026-12-05
8
+
9
+ ## 相较上一版的修改
10
+
11
+ ### 新增
12
+
13
+ - `tint.json` 新增 `forceWarn` 开关:设为 `true` 时黄色警告条常驻,用于测试和观察样式;客户端每 5 秒拉取一次,重启后仍然有效。默认 `false`,不影响正常用户。
14
+ - host 的 `/context-meter/tint` 返回 `forceWarn`,并校验为布尔值。
15
+
16
+ ### 修复
17
+
18
+ - 修复上一版仅靠 `localStorage` 调试开关、DSH 端口变化后设置失效的问题。
19
+
20
+ ### 文档
21
+
22
+ - 中英文 FAQ 改为推荐 `tint.json` 的 `forceWarn`;`docs/DETAIL.md` 补充该字段。
23
+
24
+ ### 内部
25
+
26
+ - `TINT_DEFAULT` 增加 `forceWarn: false`;客户端 `tintConfig` 同步该字段。
27
+
28
+ ## 验证
29
+
30
+ - `node --check src/index.js`、`node --check src/client.js`:通过。
31
+ - `node tests/smoke.mjs`:`SMOKE PASS`。
32
+ - 未运行:重启 DSH 后确认 `forceWarn: true` 在 5 秒内让警告常驻、改回 `false` 后恢复条件显示。
33
+
34
+ ## 已知限制
35
+
36
+ - `forceWarn` 是本地调试开关,不改变生产判定;发布给 npm 的 `tint.example.json` 保持 `false`。
37
+
38
+ ## 关联
39
+
40
+ - commit:982493a
41
+ - tag:—(Alpha Release 版本留空)
42
+ - Release:—(Alpha Release 版本留空)
@@ -0,0 +1,46 @@
1
+ # dsh-usage-bar: A-v0.1.6
2
+ Alpha Release-A-v0.1.6
3
+
4
+ - 版本名称:Alpha Release
5
+ - 版本号:A-v0.1.6
6
+ - 上一版:A-v0.1.5
7
+ - 日期:2026-12-05
8
+
9
+ ## 相较上一版的修改
10
+
11
+ ### 新增
12
+
13
+ - 回填进度条旁边新增「取消」按钮:点击后立即停止等待并恢复「统计历史Tokens」,已经开始的 host 扫描会在后台继续(只读、耗时短,不写坏数据)。
14
+
15
+ ### 修复
16
+
17
+ - 修复点「统计历史Tokens」后进度条没有填充就消失的问题:后端扫描太快时 `POST` 直接返回 `done`,旧逻辑只在 `starting`/`running` 时渲染进度条,完成态立即隐藏。现在完成态继续显示 100% 进度条约 1.2 秒,并新增本地进度平滑推进(无真实进度时缓慢爬向 90%),保证进度条可见。
18
+ - 修复进度条宽度直接使用后端 `progress` 导致 0→1 跳变、看不到中间过程的问题,改为展示值 `shownProgress`。
19
+
20
+ ### 文档
21
+
22
+ - 删除警告文案里的「(估算值)」,改为「dsh-usage-bar」;README、中文 README、DETAIL、smoke 同步。
23
+ - 补充回填完成后的停留时间与「取消」按钮说明。
24
+
25
+ ### 内部
26
+
27
+ - `src/client.js` 新增 `advanceShownProgress(current, realPercent)` 纯函数、`shownProgress` state、`progressTimer`;`finishBackfill` 停留时间 600ms → 1200ms;`sessionId` 切换/卸载清理 `progressTimer`。
28
+ - `Meter.helpers` 暴露 `advanceShownProgress`,smoke 增加 6 组断言。
29
+
30
+ ## 验证
31
+
32
+ - `node --check src/client.js`:通过。
33
+ - `node tests/smoke.mjs`:`SMOKE PASS`(含 `advanceShownProgress` 断言)。
34
+ - `node scripts/version.mjs check`:通过。
35
+ - 未运行:重启 DSH 后目视确认进度条从低值涨到 100%、停留约 1.2 秒、取消按钮可点击。
36
+
37
+ ## 已知限制
38
+
39
+ - 「取消」只停止前端等待,不中断 host 已经开始的扫描;host 对同一 session 的 running job 会复用,再次点击不会重复扫描。
40
+ - 进度条为「真实扫描进度 + 本地平滑」的融合值,不是逐字节精确比例。
41
+
42
+ ## 关联
43
+
44
+ - commit:a30db31
45
+ - tag:—(Alpha Release 版本留空)
46
+ - Release:—(Alpha Release 版本留空)
@@ -0,0 +1,39 @@
1
+ # dsh-usage-bar: A-v0.1.7
2
+ Alpha Release-A-v0.1.7
3
+
4
+ - 版本名称:Alpha Release
5
+ - 版本号:A-v0.1.7
6
+ - 上一版:A-v0.1.6
7
+ - 日期:2026-12-05
8
+
9
+ ## 相较上一版的修改
10
+
11
+ ### 修复
12
+
13
+ - 回填完成时不再瞬间把进度条拉到 100%:扫描结束后用约 1.5 秒从当前展示值线性补满,再停留约 1 秒才消失,用户能看清填充过程。
14
+ - 进度条展示值改用同步 ref(`shownRef`)记录,完成动画从真实起点补起,不会因为 React state 异步更新而跳变。
15
+
16
+ ### 文档
17
+
18
+ - README、中文 README、DETAIL 的回填说明改为「完成后约 1.5 秒补满、再停留约 1 秒」。
19
+
20
+ ### 内部
21
+
22
+ - 新增 `finishProgressAt(from, elapsedMs, durationMs)` 纯函数与 `hideTimer` 清理;smoke 增加 6 组完成动画断言。
23
+
24
+ ## 验证
25
+
26
+ - `node --check src/client.js`:通过。
27
+ - `node tests/smoke.mjs`:SMOKE PASS(含 `finishProgressAt` 断言)。
28
+ - `node scripts/version.mjs check`:通过。
29
+ - 浏览器端动画:未运行(需重启 DSH 后手动点击按钮观察)。
30
+
31
+ ## 已知限制
32
+
33
+ - 完成动画时长是前端固定值,不随实际扫描耗时动态调整;扫描超过 1.5 秒时仍按真实进度显示。
34
+
35
+ ## 关联
36
+
37
+ - commit:4d3600d
38
+ - tag:—(Alpha Release 版本留空)
39
+ - Release:—(Alpha Release 版本留空)
@@ -0,0 +1,37 @@
1
+ # dsh-usage-bar: A-v0.1.8
2
+ Alpha Release-A-v0.1.8
3
+
4
+ - 版本名称:Alpha Release
5
+ - 版本号:A-v0.1.8
6
+ - 上一版:A-v0.1.7
7
+ - 日期:2026-12-05
8
+
9
+ ## 相较上一版的修改
10
+
11
+ ### 修复
12
+
13
+ - 回填过程中不再提前显示「完成」:进度条填充期间一直显示「统计中」和「取消」,走到 100% 才显示「完成」。
14
+ - 进度条速度更均匀:完成阶段从当前值按固定 25%/秒补满,不再在切换状态后突然加速。
15
+
16
+ ### 文档
17
+
18
+ - README / 中文 README / DETAIL 补充「填充期间始终显示统计中与取消,到 100% 才显示完成」。
19
+ - Versions 索引与 CHANGELOG 记录 A-v0.1.8。
20
+
21
+ ## 验证
22
+
23
+ - `node --check src/client.js`:通过。
24
+ - `node tests/smoke.mjs`:SMOKE PASS(8 个会话;finishProgressAt 固定速度断言;usage-store / backfill / slots 全绿)。
25
+ - `node scripts/version.mjs check`:待运行。
26
+ - 浏览器目视:未运行(需要重启 DSH 加载新 client bundle)。
27
+
28
+ ## 已知限制
29
+
30
+ - 完成动画期间点「取消」会立即隐藏进度条,但后台扫描仍需跑完;任务记录只在内存里。
31
+ - 仍只覆盖启用后新增的 tokens;历史回填需要手动点击。
32
+
33
+ ## 关联
34
+
35
+ - commit:e8b5acb
36
+ - tag:—(Alpha Release 版本留空)
37
+ - Release:—(Alpha Release 版本留空)
@@ -0,0 +1,50 @@
1
+ # dsh-usage-bar: B-v0.2.0
2
+ Beta Release-B-v0.2.0
3
+
4
+ - 版本名称:Beta Release
5
+ - 版本号:B-v0.2.0
6
+ - 上一版:A-v0.1.8
7
+ - 日期:2026-12-05
8
+
9
+ ## 相较上一版的修改
10
+
11
+ ### 新增
12
+
13
+ - 版本分级从 Alpha 转入 Beta:移除仅供测试的常驻警告开关,按正常用户路径发布。
14
+
15
+ ### 修复
16
+
17
+ - 回填进度条改为按后端真实扫描进度增长,不再使用本地平滑/补间动画。
18
+ - 扫描完成后显示「完成」,「完成」停留约 1 秒后警告条自动消失。
19
+ - 扫描期间仍可点「取消」停止等待;取消只停止前端等待,后台扫描继续。
20
+
21
+ ### 文档
22
+
23
+ - README、中文 README、DETAIL 删去 `forceWarn` / `localStorage` 调试说明,改为描述正常触发条件与「完成」停留时间。
24
+ - README 配图 `docs/assets/backfill.png` 按当前警告条与按钮文案重画。
25
+
26
+ ### 内部
27
+
28
+ - 删除 `warnAlways()`、`tintConfig.forceWarn`、`shownProgress` / `shownRef` / `finishProgressAt` / `advanceShownProgress` 等调试与平滑代码。
29
+ - `tint.json` 不再有 `forceWarn` 字段;host 的 `TINT_DEFAULT` 同步移除。
30
+ - smoke 删除平滑/补间断言,保留真实进度的百分比断言。
31
+
32
+ ## 验证
33
+
34
+ - `node --check src/client.js`:通过。
35
+ - `node --check src/index.js`:通过。
36
+ - `node tests/smoke.mjs`:`SMOKE PASS`(11 个会话、账本 274.87M、usage-store / backfill / slots 全绿)。
37
+ - `node scripts/version.mjs check`:通过。
38
+ - 未运行:重启 DSH 后的 GUI 目视验证;扫描极快时进度条仍可能一闪而过(取决于日志大小)。
39
+
40
+ ## 已知限制
41
+
42
+ - 真实加载需要在重启 DSH 后确认;本版不包含发布流程。
43
+ - 「取消」只停止前端等待,不会中止 host 已开始的扫描任务。
44
+ - 历史回填只扫描当前会话,不回溯其它会话;超过 200MB 的日志会提示不支持。
45
+
46
+ ## 关联
47
+
48
+ - commit:eb6e549
49
+ - tag:v0.2.0(本地 tag,未 push)
50
+ - Release:待发布
@@ -0,0 +1,38 @@
1
+ # dsh-usage-bar: R-v0.1.0
2
+ Official Release-v0.1.0
3
+
4
+ - 版本名称:Official Release
5
+ - 版本号:R-v0.1.0
6
+ - 上一版:无(首个发布)
7
+ - 日期:2026-12-05
8
+
9
+ > 历史版本:这是启用 `Versions/` 规范前的发布,下面是摘要,完整细节见 `CHANGELOG.md` 的 `[0.1.0]`。
10
+
11
+ ## 相较上一版的修改
12
+
13
+ ### 新增
14
+
15
+ - 顶栏「累计计费输入 Tokens」进度条:读取 cost-meter 账本,billion-context 的 18787 端口可用时按会话合并补充,显示用量、上限与百分比。
16
+ - 侧栏会话标题按占用率着色:达到阈值(≥60%)时给标题上色;`debug.log` 记录 `tint` 上报。
17
+ - 会话标记停用:项目目录 `disabled.json` 持久化,行内 `∅` 按钮切换,停用行标题置灰、编号不受影响。
18
+ - `/handoff` 交接指令:生成交接文档,原对话执行后自动进入标记停用状态。
19
+ - host 路由:`GET /context-meter/{stats,contexts,disabled,handoff}`、`POST /context-meter/{disabled,tint}`。
20
+ - 中文与英文 locale(`locale/zh.json`、`locale/en.json`)。
21
+ - 测试:`node tests/smoke.mjs` 覆盖 host 两命令、六条路由、账本解析、client 三槽位与标题着色规则。
22
+
23
+ ## 验证
24
+
25
+ - 当时 `node tests/smoke.mjs` 全绿。
26
+ - npm `dsh-usage-bar@0.1.0` 已发布;GitHub tag `v0.1.0` 已推送。
27
+
28
+ ## 已知限制
29
+
30
+ - billion-context 未运行(18787 端口不可用)时只退化到 cost-meter 账本。
31
+ - 侧栏没有标题槽位,着色依赖 DOM 结构(行容器 class 含 `sessionRow`)。
32
+ - 仅当会话占用率 ≥60% 时才着色。
33
+
34
+ ## 关联
35
+
36
+ - commit:`ea4c2f5`
37
+ - tag:`v0.1.0`
38
+ - Release:未建 GitHub Release;tag 链接:https://github.com/HydronPlus/dsh-usage-bar/tree/v0.1.0
@@ -0,0 +1,49 @@
1
+ # 版本日志
2
+
3
+ 本目录记录 dsh-usage-bar 的每次版本变更。规则见 `C:\Agents Workspace\Shared\Standards\Versioning.md`(本机共享规范,不在本仓库内)。
4
+
5
+ ## 当前状态
6
+
7
+ - 当前开发版:`B-v0.2.0`(Beta Release)
8
+ - 最近发布版:`R-v0.1.0`(Official Release,npm `0.1.0` / tag `v0.1.0`)
9
+ - 下一次公开测试目标:`B-v0.2.0`(Beta Release,本地快照,暂不发布)
10
+
11
+ ## 索引
12
+
13
+ | 版本名称 | 版本号 | 日期 | 状态 | 日志 | Release |
14
+ | --- | --- | --- | --- | --- | --- |
15
+ | Beta Release | B-v0.2.0 | 2026-12-05 | 开发中 | [B-v0.2.0](Beta%20Release/B-v0.2.0.md) | — |
16
+ | Alpha Release | A-v0.1.8 | 2026-12-05 | 历史 | [A-v0.1.8](Alpha%20Release/A-v0.1.8.md) | — |
17
+ | Alpha Release | A-v0.1.7 | 2026-12-05 | 历史 | [A-v0.1.7](Alpha%20Release/A-v0.1.7.md) | — |
18
+ | Alpha Release | A-v0.1.6 | 2026-12-05 | 历史 | [A-v0.1.6](Alpha%20Release/A-v0.1.6.md) | — |
19
+ | Alpha Release | A-v0.1.5 | 2026-12-05 | 历史 | [A-v0.1.5](Alpha%20Release/A-v0.1.5.md) | — |
20
+ | Alpha Release | A-v0.1.4 | 2026-12-05 | 历史 | [A-v0.1.4](Alpha%20Release/A-v0.1.4.md) | — |
21
+ | Alpha Release | A-v0.1.3 | 2026-12-05 | 历史 | [A-v0.1.3](Alpha%20Release/A-v0.1.3.md) | — |
22
+ | Alpha Release | A-v0.1.1 | 2026-12-05 | 历史 | [A-v0.1.1](Alpha%20Release/A-v0.1.1.md) | — |
23
+ | Alpha Release | A-v0.1.0 | 2026-12-05 | 历史 | [A-v0.1.0](Alpha%20Release/A-v0.1.0.md) | — |
24
+ | Official Release | R-v0.1.0 | 2026-12-05 | 已发布 | [R-v0.1.0](Official%20Release/R-v0.1.0.md) | [tag v0.1.0](https://github.com/HydronPlus/dsh-usage-bar/tree/v0.1.0) |
25
+
26
+ ## 命名
27
+
28
+ - 目录名用版本名称全称:`Versions/Alpha Release/`、`Versions/Beta Release/`、`Versions/Official Release/`;
29
+ - 日志文件名用版本号简称:`A-vX.Y.Z.md` / `B-vX.Y.Z.md` / `R-vX.Y.Z.md`;
30
+ - 标题两行:第一行 `dsh-usage-bar: A-vX.Y.Z`,第二行 `Alpha Release-A-vX.Y.Z`;
31
+ - 单独引用写版本号 `A-vX.Y.Z`,同时标明项目名和版本号时才写 `dsh-usage-bar: A-vX.Y.Z`;
32
+ - `package.json.version` 和 git tag 只使用纯 `X.Y.Z` / `vX.Y.Z`;
33
+ - 同号例外:`R-v0.1.0` 已发布,`A-v0.1.0` 作为规范起点,不 tag、不发 Release、不 publish;下一个 B/R 用 0.2.0+。
34
+
35
+ ## 如何新增
36
+
37
+ ```bash
38
+ node scripts/version.mjs new A 0.1.4
39
+ # 同时把 package.json.version 改成 0.1.4
40
+ node scripts/version.mjs check
41
+ ```
42
+
43
+ `new` 后的 `A` / `B` / `R` 是脚本参数简称;脚本生成两行标题、版本名称占位,目录用全称,版本名称需要手工填写。
44
+
45
+ 没有脚本时,复制 [`_template.md`](_template.md) 改名填写。
46
+
47
+ ## 与 CHANGELOG 的关系
48
+
49
+ `CHANGELOG.md` 只记 B/R 发布级、用户可读的变更;本目录记全量,包括 A 的内部迭代。