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
@@ -0,0 +1,86 @@
1
+ # dsh-usage-bar: B-v0.2.0
2
+
3
+ **Beta Release · 2026-12-05**
4
+
5
+ From v0.1.0 to B-v0.2.0: the progress bar now measures what it actually says it measures, survives without the optional data-source plugins, and can backfill an old conversation's history.
6
+
7
+ ## 中文
8
+
9
+ ### 新增
10
+
11
+ - **自采用量**:host 侧直接监听会话的 `assistant/message` 事件,把每条回复的 usage 写入 `~/.dsh/storages/dsh-usage-bar/usage.json`。不安装 `dsh-cost-meter` 或 `billion-context` 也能统计插件启用后的新用量。
12
+ - **历史回填**:旧对话首次启用时,黄色提示条里的「统计历史Tokens」会扫描该对话日志,按后端真实进度显示百分比,可随时取消;完成后写回顶栏并记录 `historyApplied`,同一条对话不再重复提示。
13
+ - **顶栏黄色提示条**:位置从顶栏 chip 移到对话 tab 行下方居中,不再和「费用明细」挤在一起。只有「仅统计新增」或「有历史可回填」时出现;回填中显示真实进度和「取消」,完成显示「完成」约 1 秒后自动消失。
14
+ - **侧栏会话标题着色**:按该会话的累计输入比例显示绿/黄/红,阈值和颜色由 `tint.json` 的 `warn` / `danger` / `warnColor` / `dangerColor` 控制。每行行首新增 ∅ 按钮,可把会话标记为停用(只压暗显示、加删除线,不删除对话)。
15
+ - **`window` 可配置**:顶栏百分比、400M/500M 预警点和侧栏着色统一使用 `tint.json` 的 `window`(默认 500M),改文件后约 5 秒生效。
16
+ - **README 配图**:四张按实际界面绘制的图——顶栏四态、侧栏停用、回填进度、`/handoff` 命令菜单。
17
+
18
+ ### 修复
19
+
20
+ - 包名统一为 `dsh-usage-bar`(原 `dsh-context-meter`),`package.json`、`cordis.patch.yml`、client `load({ id })`、README 四处一致。
21
+ - 顶栏和侧栏的累计口径统一到同一个 `window`;tooltip 的预警点按窗口的 80% / 100% 换算,不再写死 400M / 500M。
22
+ - `/handoff` 生成的引导不再引用旧工作区的 `Config/AGENTS.md` 与 `Config/MEMORY/MEMORY.md`,改为全局 AGENTS、当前目录 AGENTS、README、MEMORY(若存在)。
23
+ - 顶栏在窄屏隐藏文字标签,进度轨道宽度自适应;侧栏着色缓存叶子节点,减少每 2.5 秒的重复 DOM 遍历。
24
+ - 回填进度不再瞬间跳到 100%:使用后端真实进度,完成阶段停留约 1 秒;完成动画期间始终显示「统计中」和「取消」。
25
+ - 移除调试用 `forceWarn`(`tint.json` 字段与客户端开关),正常显示条件回到 `migration.needed`。
26
+
27
+ ### 文档
28
+
29
+ - README 改为中英双语 + REA 风格:stars / npm downloads / license 徽章、语言切换、导航、四张配图。
30
+ - 新增 `Versions/` 版本日志(R/A/B 分级)、`docs/releases/` Release notes、`docs/DETAIL.md` 技术说明和 `docs/Development.md` 发布流程。
31
+
32
+ ### 升级
33
+
34
+ ```bash
35
+ dsh plugin --profile <profile> add dsh-usage-bar@latest
36
+ ```
37
+
38
+ 要求 DSH `>=0.2.0-rc.1`,安装后重启 DSH(仅刷新页面不够)。
39
+
40
+ ### 已知限制
41
+
42
+ - 自采和回填只覆盖插件启用后的用量与当前对话的历史;不回填其它对话。
43
+ - 侧栏着色依赖宿主 DOM 结构,DSH 改版可能失效;颜色没出现时先看项目根的 `debug.log`。
44
+ - 顶栏的百分比是「累计计费输入 / `window`」,不是上下文窗口占用率。
45
+
46
+ <details>
47
+ <summary>English</summary>
48
+
49
+ ### Added
50
+
51
+ - **Self-collected usage**: the host listens to each `assistant/message` event and accumulates usage into `~/.dsh/storages/dsh-usage-bar/usage.json`. Works without `dsh-cost-meter` or `billion-context` for new usage after the plugin is enabled.
52
+ - **History backfill**: for an old conversation, the yellow banner offers **统计历史Tokens**. It scans that conversation's log with real backend progress, can be cancelled, and writes the history baseline back to the header (`historyApplied`).
53
+ - **Header banner**: moved from the header chip to a centered banner below the conversation tab row. Appears only when stats cover new usage only or history is available; shows real progress and a Cancel button while running, then “完成” for about one second.
54
+ - **Sidebar tinting**: session titles are colored by cumulative input ratio (green/yellow/red), with thresholds and colors from `tint.json` (`warn`, `danger`, `warnColor`, `dangerColor`). A ∅ button at the start of each row marks a conversation as disabled — display only, the conversation is not deleted.
55
+ - **Configurable `window`**: the header percentage, the 400M/500M warning points and sidebar tinting all use `tint.json`'s `window` (default 500M), applied within about 5 seconds.
56
+ - **README illustrations**: four diagrams drawn after the real UI — header states, disabled sidebar row, backfill progress, and the `/handoff` command menu.
57
+
58
+ ### Fixed
59
+
60
+ - Package name unified as `dsh-usage-bar` (was `dsh-context-meter`) across `package.json`, `cordis.patch.yml`, the client `load({ id })` and the README.
61
+ - Header and sidebar now share the same `window`; warning points are derived from 80% / 100% of the window instead of hard-coded 400M / 500M.
62
+ - `/handoff` no longer references the old workspace `Config/AGENTS.md` and `Config/MEMORY/MEMORY.md`; it points to the global AGENTS, the current directory AGENTS, README and MEMORY if present.
63
+ - Narrow headers hide text labels and resize the track; sidebar tinting caches leaf nodes instead of walking the DOM every 2.5 seconds.
64
+ - Backfill progress no longer jumps to 100%: real backend progress is shown, with a ~1 second hold at completion; the Cancel button stays visible during the finishing animation.
65
+ - Removed the debug-only `forceWarn` (`tint.json` field and client switch); the normal display condition is `migration.needed` again.
66
+
67
+ ### Docs
68
+
69
+ - README rewritten in English + Chinese with REA-style stars / npm downloads / license badges, language switch, navigation and four diagrams.
70
+ - Added `Versions/` logs (R/A/B tiers), `docs/releases/` notes, `docs/DETAIL.md` and `docs/Development.md`.
71
+
72
+ ### Upgrade
73
+
74
+ ```bash
75
+ dsh plugin --profile <profile> add dsh-usage-bar@latest
76
+ ```
77
+
78
+ Requires DSH `>=0.2.0-rc.1`; restart DSH after installing (a page refresh is not enough).
79
+
80
+ ### Known limitations
81
+
82
+ - Self-collected usage starts when the plugin is enabled; only the current conversation's log is backfilled.
83
+ - Sidebar tinting depends on host DOM structure and may break when DSH changes; check `debug.log` in the project root if colors do not appear.
84
+ - The header percentage is cumulative billed input divided by `window`, not context-window occupancy.
85
+
86
+ </details>
@@ -0,0 +1,51 @@
1
+ # dsh-usage-bar: <A|B|R>-vX.Y.Z
2
+ <版本名称>-<A|B|R>-vX.Y.Z
3
+
4
+ - 版本名称:<Alpha Release | Beta Release | Official Release>
5
+ - 版本号:<A|B|R>-vX.Y.Z
6
+ - 日期:YYYY-MM-DD
7
+ - 完整逐版日志:[Versions/README.md](../Versions/README.md)
8
+ - npm:https://www.npmjs.com/package/dsh-usage-bar
9
+
10
+ ## 上次 Release → 本次 Release
11
+
12
+ <details open>
13
+ <summary>v<上次 Release> → vX.Y.Z(默认显示)</summary>
14
+
15
+ ### 新增
16
+
17
+ - 一句话一条,按重要性从高到低。
18
+
19
+ ### 修复
20
+
21
+ - 一句话一条。
22
+
23
+ ### 文档
24
+
25
+ - 一句话一条。
26
+
27
+ </details>
28
+
29
+ ## 上次 Pre-release → 本次 Release
30
+
31
+ <details>
32
+ <summary>Beta Release-v<上次 Pre-release> → Official Release-vX.Y.Z</summary>
33
+
34
+ ### 新增
35
+
36
+ - 一句话一条。
37
+
38
+ ### 修复
39
+
40
+ - 一句话一条。
41
+
42
+ </details>
43
+
44
+ ---
45
+
46
+ 使用说明:
47
+
48
+ - Official Release 版本保留两份 `<details>`,默认展开「上次 Release → 本次」;
49
+ - Beta Release 版本只保留「上次发布(Official Release 或 Beta Release)→ 本次 Beta Release」一份;
50
+ - 首次发布写「首个版本」,不写上一版;
51
+ - 内容只合并「上一次同类发布到本次」的日志,不逐条贴 Alpha Release 版本。
package/icon.svg ADDED
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
2
+ <rect x="2" y="9" width="20" height="6" rx="3" fill="none" stroke="currentColor" stroke-width="2"/>
3
+ <rect x="4" y="11" width="6" height="2" rx="1" fill="currentColor"/>
4
+ </svg>
package/locale/en.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "Cumulative Input Meter",
4
+ "description": "Shows this session's cumulative billed input tokens (0→500M) in the session header.",
5
+ "detail": "docs/DETAIL.md"
6
+ }
7
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "累计输入进度条",
4
+ "description": "在会话顶部显示本会话累计计费输入 token(0→500M),超过阈值提醒新开对话。",
5
+ "detail": "docs/DETAIL.md"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,62 @@
1
1
  {
2
2
  "name": "dsh-usage-bar",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "DSH 插件:会话顶部累计计费输入进度条 + 侧栏会话标题着色 + 标记停用 + /handoff 交接指令",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "exports": {
8
+ ".": "./src/index.js",
9
+ "./client": "./src/client.js",
10
+ "./package.json": "./package.json",
11
+ "./locale/*.json": "./locale/*.json",
12
+ "./icon": "./icon.svg"
13
+ },
14
+ "files": [
15
+ "src/",
16
+ "locale/",
17
+ "docs/",
18
+ "Versions/",
19
+ "icon.svg",
20
+ "cordis.patch.yml",
21
+ "tint.example.json"
22
+ ],
23
+ "scripts": {
24
+ "test": "node tests/smoke.mjs",
25
+ "prepublishOnly": "node tests/smoke.mjs",
26
+ "version:new": "node scripts/version.mjs new",
27
+ "version:check": "node scripts/version.mjs check",
28
+ "install-profile": "node scripts/install-profile.mjs"
29
+ },
30
+ "keywords": [
31
+ "dsh",
32
+ "dsh-plugin",
33
+ "token-usage",
34
+ "usage-bar",
35
+ "context-meter"
36
+ ],
37
+ "engines": {
38
+ "dsh": ">=0.2.0-rc.1 <0.3.0-0"
39
+ },
40
+ "author": "HydronPlus",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/HydronPlus/dsh-usage-bar.git"
44
+ },
45
+ "homepage": "https://github.com/HydronPlus/dsh-usage-bar#readme",
46
+ "bugs": {
47
+ "url": "https://github.com/HydronPlus/dsh-usage-bar/issues"
48
+ },
49
+ "license": "MIT",
50
+ "dsh": {
51
+ "bundle": {
52
+ "patch": "./cordis.patch.yml"
53
+ },
54
+ "client": {
55
+ "platform": "web",
56
+ "immediately": true,
57
+ "inject": [
58
+ "@deepseek-ai/dsh-client-ui-conversation"
59
+ ]
60
+ }
61
+ }
62
+ }