dsh-ds-whale 0.0.0-stage → 1.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,196 @@
1
+ # Changelog
2
+
3
+ 本项目从本机自用版本一路演进到可发布形态,版本号按改动规模重定:`0.9.0` 视为「首个可对外安装的开发版」,仍属 0.x,接口与界面可能继续调整。
4
+
5
+ ## 1.2.0 — 2026-11-23
6
+
7
+ - **数据目录可配置 + 系统目录选择框**:设置页新增「数据目录」,点「选择目录」直接打开系统文件夹选择框(Windows / macOS / Linux),不用手粘路径;账本 / 立绘 / 音效 / pending 全部跟着走,不再只能放 C 盘。留空 = `$DSH_HOME`,修改后重启 DSH 生效,首次切到新目录会把旧数据复制过去(旧目录保留作备份)
8
+ - 自测扩到 17 项宿主用例(数据目录解析 / 首次迁移 / 运行期切换);浏览器端立绘链路通过
9
+
10
+ <!-- dsh-release: stable -->
11
+
12
+ ## 1.1.1 — 2026-11-23
13
+
14
+ - **修复「恢复默认」后图标不还原**:默认形象改用独立缓存键 `v=d1`,宿主对 `d1 / 0 / 5 / 6` 只发包内 assets,绝不把用户上传图缓存到默认 URL 上;点恢复默认后设置页缩略图、页头图标和右下角挂件都会立刻回内置立绘
15
+ - 自测补一条缓存键回归:`d1/0` 必须返回包内 assets,自定义 `rev` 仍返回上传图(宿主用例 16 项)
16
+
17
+ <!-- dsh-release: stable -->
18
+
19
+ ## 1.1.0 — 2026-11-23
20
+
21
+ - **立绘去背景不再只认白底**:纯色背景现在都行——蓝 / 绿 / 粉 / 深灰等,只要四条边颜色一致就自动泛洪抠掉;白色主体(白甲、白裙)按「背景→前景」投影重算边缘 alpha,不会被误伤
22
+ - **复杂照片背景保持原样**:渐变 / 实景背景仍然整张保留(保护人物不被误伤);需要 cut-out 的话建议先用去底工具处理好再上传,「自动去背景」开关可随时关掉
23
+ - 自测扩到 21 个像素用例、15 个浏览器用例(蓝 / 粉 / 深灰 / 绿幕、白甲贴蓝底、jpg 蓝底)与 15 项宿主用例
24
+
25
+ <!-- dsh-release: stable -->
26
+
27
+ ## 1.0.0 — 2026-11-23
28
+
29
+ - **1.0 正式版**:接口与设置项冻结;0.x 的数据文件、设置、自定义音效与立绘都能直接沿用,后续 1.x 只做兼容性修复与增强
30
+ - **设置页直接换立绘**:六种状态各一行,上传 jpg / png / webp / bmp 即可;浏览器内完成解码 → 自动去白底 / 白边 → 按人物裁成正方形 → 导出 512 / 128(待机另带 64),写入 `$DSH_HOME/dsh-ds-whale-assets/`,不用再跑 PowerShell,也不用手动换文件
31
+ - **去白边通过率补强**:只抠与边界连通的浅色背景,白围裙 / 白袜子不会误伤;白、米白、浅灰与 JPEG 噪声自适应;浅蓝渐变等照片底直接跳过;边缘两圈重算 alpha 并剥掉白色成分;透明 PNG 只清理贴边半透明像素,内部阴影与发丝不动
32
+ - **两个新设置**:「自动去白底」开关与「形象留白」滑块(0–25%),某张图被抠坏时关掉开关即可只裁切缩放;「恢复默认」随时回到内置立绘
33
+ - **新接口**:`POST /api/dsh-ds-whale/avatar/upload`、`POST /api/dsh-ds-whale/avatar/reset`;`/state` 增加 `avatars` 元数据,`/avatar.png` 用 rev 做缓存键,上传 / 恢复默认即时生效
34
+ - **修复设置写入偶发失败**:DSH 写 profile 的 `package.json.lock` 被上一次中断的写入留下时,之后所有设置写都会超时;现在写入排队串行、自动清理本进程遗留的僵尸锁并重试一次,profile 写失败改为琥珀提示 + 自动补写,运行时设置始终生效
35
+ - **自带三段自测**:`tools/avatar-selftest/` 一条命令覆盖真图像素管线(jpg 白底 / 浅灰 / 米白 / 小图 / 宽图 / 照片底)、无头 Chrome 端到端上传链路、宿主路由与锁恢复(16 + 12 + 15 个用例)
36
+ - **文档**:中英 README 补齐立绘上传、设置项、路由与 1.0 发布说明;数据与隐私口径不变(立绘和音效都只存本机)
37
+
38
+ <!-- dsh-release: stable -->
39
+
40
+ ## 0.10.1 — 2026-11-19
41
+
42
+ - **修复重启 / 重载丢账**:进行中的轮次每 1.5 秒把累计写进独立的 pending 文件(`$DSH_HOME/dsh-ds-whale-pending/`),插件启动时补记进当天;以前一轮跨了重载,前面花的钱直接消失(实测 105 条消息只记到 37 条、少记 63%)
43
+ - **峰谷判定改用事件自身时间**:不再用「收到消息的时刻」判档,会话恢复 / 事件回放时不会把 5 折算成全价(或反过来);结算日也按事件时间落,跨午夜的消费不再整笔算到第二天
44
+ - 补记的轮次带 `recovered` 标记,金额照常计入当日账本
45
+
46
+ ## 0.10.0 — 2026-11-18
47
+
48
+ - **峰谷切换提醒**:高峰开始 / 空闲时段开始时弹一次气泡(5 秒自动收)并响一声;新增第五个音效场景「峰谷切换」,和另外四个场景一样能单独开关、试听、上传自定义音效(`soundPeak`)。设置里可整体关掉提醒(`peakNotify`)
49
+ - **异常轮次提示**:某轮花费 ≥ 最近 20 轮中位数的 5 倍、且至少多花 1 分钱时,播报里标一句「⚠ 比平时贵 N 倍」,概览的「最近一轮」也会标黄并给出倍数(样本不足 5 轮不判断)
50
+ - **缓存命中率**:概览的 token 行右侧直接给命中率(≥80% 绿 / ≥50% 灰 / 更低橙),不用自己拿命中 ÷(命中 + 未命中)算
51
+ - **花费趋势**:用量页签新增近 14 天柱状图,标题行给日均;没有观测数据的那天用本机估算兜底,柱子上悬停看当天金额
52
+ - **余额构成**:主卡「充值 / 赠金」下面加一条 3px 细比例条,悬停显示各自占比,不增加卡片高度
53
+ - **自动更新提示**:宿主每 6 小时查一次 GitHub Releases(失败 30 分钟后重试,结果落盘,离线 / 限流静默),设置页底部显示「已是最新 / 发现新版本 vX」,也能手动检查(新路由 `/update`)
54
+ - **设置页重构**:按「外观与位置 / 额度与提醒 / 音效 / 天气与位置 / 高级」五组分区;「缓存口径」从只藏在 schema 里改成可点;版本与数据文件收成两行;页头只留「数据只存在本机」
55
+
56
+ ## 0.9.18 — 2026-11-17
57
+
58
+ - 修复每日天气接口:Open-Meteo 不通时自动切 wttr.in
59
+
60
+ ## 0.9.17 — 2026-11-16
61
+
62
+ - 修复音效播放时会叠加爆炸的问题
63
+
64
+ ## 0.9.16 — 2026-11-16
65
+
66
+ - 重构余额详情样式,再也不臃肿啦~
67
+
68
+ ## 0.9.15 — 2026-11-12
69
+
70
+ - **音效自定义**:设置页分四类场景(打招呼、每轮播报、点击、预警),支持开关、试听、上传,格式 wav / mp3 / ogg / m4a / flac,上限 500 KB
71
+ - **上传即时试听**:不用等轮询,恢复默认回到合成提示音
72
+ - **连点不会哑**:每次点击新建播放源,支持连续播放,各场景默认音色分开
73
+ - 音效文件存在 `$DSH_HOME/dsh-ds-whale-sounds/`(`greet` / `turn` / `click` / `warn`),元数据跟着 `.dsh-ds-whale.json` 走;直接往目录里放同名文件也会被识别
74
+
75
+ ## 0.9.13 — 2026-11-12
76
+
77
+ - 增加立绘点击台词,随机显示,优化气泡框大小调整
78
+
79
+ ## 0.9.12 — 2026-11-12
80
+
81
+ - 重构气泡样式,变的更圆润,配色更符合大众审美
82
+
83
+ ## 0.9.11 — 2026-11-10
84
+
85
+ - 修形象大小滑块拖动卡顿
86
+
87
+ ## 0.9.10 — 2026-11-06
88
+
89
+ - **立绘全部重绘**:六种状态(平静 / 气鼓鼓 / 脸红 / 慌张 / 挥手 / 托腮)统一换成新画风的鲸鱼娘——2.5 头身、深蓝到青色渐变的长卷发、白色蕾丝头饰 + 蓝蝴蝶结、鲸鱼鳍耳、深蓝女仆裙配白围裙鲸鱼刺绣,图更干净、留白更舒服;README 的功能截图也一并换成实拍图
90
+ - 新增 scripts/import-avatar.ps1:把自己喜欢的图(JPG / PNG / WebP)丢进去,一条命令自动去白底、按人物裁正方、导出 512 / 128,写进插件目录;也可以直接把图丢到 ~/.dsh/dsh-ds-whale-assets/ 同名覆盖,不用改仓库
91
+ - 修位置跟边不跟距:位置存档从「距右边多少」改成「贴哪边 + 距那条边多远」(旧档自动迁移),贴左就一直贴左、贴右就一直贴右
92
+ - 修开机位置跑到窗口外:视口与标题栏高度改成持续订阅,渲染时按当前视口把位置收进安全区,存档只在视口稳定后回写
93
+
94
+ ## 0.9.9 — 2026-11-06
95
+
96
+ - 修城市设置写不进配置;首次点天气直接在气泡里填城市
97
+
98
+ ## 0.9.8 — 2026-11-06
99
+
100
+ - 新增官网充值按钮,优化多项展示
101
+
102
+ <!-- dsh-release: stable -->
103
+
104
+ ## 0.9.7 — 2026-11-06
105
+
106
+ - 修鲸鱼拖到窗口顶部时头部被标题栏盖住
107
+
108
+ <!-- dsh-release: stable -->
109
+
110
+ ## 0.9.6 — 2026-11-03
111
+
112
+ - **修气泡被窗口顶部裁掉**:鲸鱼可以拖到最上面,播报气泡按实测高度判断朝向 —— 上方装不下就翻到鲸鱼下方,小尾巴与边框跟着翻;常驻小气泡改为垂直居中跟随;余额详情面板也改成按可用空间选上下并限高,不再顶出窗口。
113
+ - **发版脚本补 README 同步**:`release.mjs` / `bump-version.mjs` 现在会把 README 顶部的 `badge/version-x.y.z` 一起改(此前每次发版 README 徽章都会落后一版),有残留旧版本号时还会警告。
114
+
115
+ <!-- dsh-release: stable -->
116
+
117
+ ## 0.9.5 — 2026-11-02
118
+
119
+ - **天气改成必须填城市**:实测多家 IP 定位服务都不稳(有的 403、有的只给英文城市名、有的直接超时),0.9.4 的「自动定位」等于不可用。现在:设置里没填「天气城市」时,点「今日天气」不会发任何请求,而是托腮思考地问你一句「先告诉我在哪座城市嘛~」,按钮「去填城市」直接跳到小鲸鱼设置分区;在设置里把城市存好后,这一行会给出回执「记好啦~再右键小鲸鱼点一次『今日天气』试试」。宿主 `getWeather` 不再有 IP 定位分支,缺城市时返回 `{ok:false, error:'need-city'}`,IP 定位相关的三个函数已删除。
120
+ - **两张新立绘入库**:`assets/whale-greet.png`(挥手打招呼)与 `assets/whale-think.png`(托腮思考),各带 `-128` 小尺寸,由 `tools/make-avatar.py` 去白底导出;`MOOD_FILES` 与 `GET /avatar.png?mood=` 同步支持 `greet` / `think`。
121
+ - **开机问候换挥手图**:问候气泡带 `mood:'greet'`,说话期间一直用挥手立绘(轻晃两下就停),气泡收起后回到平静。
122
+ - **天气播报换思考图**:点「今日天气」到气泡期间用托腮思考立绘(慢速浮动),失败告警仍走慌张脸。
123
+ - **右键菜单悬停反馈**:每个菜单项 hover / focus-visible 时背景变品牌蓝(14% 透明度)+ 文字转品牌色 + 内描边 + 右移 2px + 左侧竖条展开 + 图标放大 1.16 倍并微转,全部 150ms 过渡;`:active` 再加一点回弹缩放。之前只有一层极淡的背景色,深色主题下几乎看不出来。
124
+ - README 补:三种新动作对照表、六种立绘、天气必填城市说明、新增设置项与 `/weather` 路由、外部请求清单加入 Open-Meteo。
125
+
126
+ <!-- dsh-release: stable -->
127
+
128
+ ## 0.9.4 — 2026-11-02
129
+
130
+ - **左键点击即刷新余额**:点一下鲸鱼(或常驻气泡)直接回源刷新,带醒目刷新动画——脚下发光呼吸 + 外圈 conic-gradient 旋转进度环,右上角角标「刷新中…」带三点跳动,鲸鱼同时轻微放大。
131
+ - **防刷频**:新增设置项「点击刷新最小间隔(毫秒)」(2000 ~ 120000,默认 6000);冷却期内点击只弹角标提示还差几秒,不打余额接口;请求本身还有 `refreshLock` 互斥 + 620ms 最短动画时长,连点不会叠请求。
132
+ - **右键菜单**:右键鲸鱼不再有受击动画,弹出菜单——立即刷新余额 / 查看余额详情 / 今日天气 / 打开小鲸鱼设置(底部标注「左键刷新余额 · 右键打开菜单」)。菜单坐标自动避开视口边缘,点空白、Esc、滚动、改窗口大小都会关掉。原「点击弹面板」改为菜单里的「查看余额详情」。
133
+ - **今日天气(零 token)**:宿主新增 `GET /api/dsh-ds-whale/weather`,直接走 Open-Meteo 免费接口(不经过模型,不消耗 token);城市可留空(按出口 IP 自动定位,多源轮询兜底,最后退回系统时区城市),也可在设置里填固定城市 —— **该自动定位已在 0.9.5 移除,改为必须填城市**。10 分钟进程内缓存,只在过期或手动刷新时回源。气泡展示当前温度、今日高低温、降雨概率、未来三小时趋势和出行提示。
134
+ - **开机问候**:每次打开 DSH,按设定的昵称主动打招呼(六档时间段话术,中英各一套),复用每轮播报的同一套形象与提示音;设置里可关(「打开 DSH 时打招呼」)。
135
+ - **设置页新增三项**:点击刷新最小间隔、打开 DSH 时打招呼、天气城市。
136
+ - 打开设置面板走 `slots.entries('sidebar.settings')` 拿到设置 shell 的单例 store 句柄调用 `openSection('dsh-ds-whale')`,直达小鲸鱼分区;拿不到句柄时退回模拟点击侧边栏设置入口。
137
+
138
+ ## 0.9.3 — 2026-10-31
139
+
140
+ - README 校订 + 两张立绘素材入库(试用发版流程)
141
+
142
+ ## 0.9.2 — 2026-10-31
143
+
144
+ - 修复左边气泡被裁
145
+
146
+ ## 0.9.1 — 2026-10-31
147
+
148
+ - 修复挂件吸附到左侧时播报气泡溢出屏幕左侧被裁(气泡改为按侧翻转到挂件内侧,宽度按视口兜底)
149
+
150
+ ## 0.9.0 — 2026-10-31
151
+
152
+ 发布准备版(首个公开可安装版本)。
153
+
154
+ - **双语界面**:新增「界面语言」设置(跟随系统 / 中文 / English)。英文模式下挂件、气泡、播报台词、设置页全部为英文;默认按浏览器/系统区域自动选择。
155
+ - **设置页**:插件设置正式挂进 DSH 设置左侧导航(`小鲸鱼 / Whale`,位于「喵记忆」下方),13 项配置全部由设置页管理,写入 profile 的 `cordis.patch.yml`。
156
+ - **拟人播报**:每轮结束后以角色口吻播报本轮消耗(按金额分 5 档文案),需点「知道啦~/Got it~」手动关闭;支持自定义昵称。
157
+ - **四状态立绘**:平静 / 气鼓鼓(点击受击)/ 脸红(说话)/ 慌张(余额告警),320ms 交叉淡入 + 各状态专属小动作。
158
+ - **余额告警**:低于预警线时换慌张立绘并播报,带「去充值 / 知道啦」按钮。
159
+ - 版本号、`repository` / `homepage` / `keywords` / `license` 等发布字段就位。
160
+
161
+ ## 0.8.0 — 2026-10-31
162
+
163
+ - 设置从挂件面板整体搬到 DSH 设置页;挂件面板只留余额与记录。
164
+ - 受击动画改为 `pointerdown` 立即触发,连续点击可重放。
165
+ - 播报与告警改为可持久展示(不再自动消失)。
166
+
167
+ ## 0.7.0 — 2026-10-31
168
+
169
+ - 接入 DeepSeek 官网用量接口(`/api/v0/usage/by_api_key/{amount,cost}`),今日用量的金额 / 请求数 / tokens 与官网用量页同源。
170
+ - 面板主数字改用官网口径,并保留「余额差观测 + 本机估算」作为对照。
171
+
172
+ ## 0.6.0 — 2026-10-31
173
+
174
+ - 新增说话 / 告警两套立绘与情绪动画。
175
+ - 播报框重做(296px 卡片、右上角标签、胶囊按钮、指向尾巴)。
176
+
177
+ ## 0.5.0 — 2026-10-31
178
+
179
+ - 形象改用 PNG 立绘(去白底),支持 `mood` 参数;静态资源加 ETag,换图即时生效。
180
+ - 拖拽吸附改为按页面中线判定左右。
181
+
182
+ ## 0.4.0 — 2026-10-31
183
+
184
+ - 昵称、拟人播报、点击换表情首版。
185
+
186
+ ## 0.3.0 — 2026-10-31
187
+
188
+ - 余额取数三层兜底(启动退避重试 / 20s 保活 / 请求时自愈),修掉宿主重启后常驻 `no-credentials-service` 的问题。
189
+
190
+ ## 0.2.0 — 2026-10-31
191
+
192
+ - 常驻参数气泡、可自定义显示项、初始尺寸调整。
193
+
194
+ ## 0.1.0 — 2026-10-31
195
+
196
+ - 首个能跑的版本:右下角浮动挂件、余额展示与刷新、今日已用、每轮消耗、峰谷定价与倒计时、拖拽吸附、用量记录。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Iceseas
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,222 @@
1
+ <div align="center">
2
+
3
+ <img src="assets/whale.png" width="220" alt="dsh-ds-whale" />
4
+
5
+ # 🐳 dsh-ds-whale
6
+
7
+ **A whale balance & usage widget for DeepSeek** · DSH Web UI plugin
8
+
9
+ [简体中文](README.md) · **English**
10
+
11
+ [![version](https://img.shields.io/badge/version-1.2.0-blue)](CHANGELOG.md)
12
+ [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
13
+ [![platform](https://img.shields.io/badge/platform-DSH%20Web%20UI-purple)](https://github.com/Iceseas)
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ A little whale docked in the bottom-right corner: balance, today's official spend, per-turn cost and the peak/off-peak countdown — all narrated in character.
20
+
21
+ Install it into your DSH profile, reload once, and she shows up in the bottom-right corner. She greets you by nickname on startup; a left click refreshes the balance (6s cooldown by default); the right-click menu has balance details, today's weather and the settings page. Balance comes from the DSH credential `DEEPSEEK_API_KEY` (or your DSH DeepSeek sign-in), today's spend is pulled straight from the official usage API (the same numbers as `platform.deepseek.com/usage`), every turn's cost is narrated in a cute voice, and she switches between six hand-drawn expressions. Weather is fetched from Open-Meteo by the host process, with `wttr.in` as an automatic fallback; it uses your system proxy (`HTTPS_PROXY` / Windows proxy settings) when one is configured and falls back to a direct connection — **zero tokens**, never through a model. Everything is stored locally in `$DSH_HOME/.dsh-ds-whale.json`. The UI is available in **中文 / English**, auto-selected from your system locale.
22
+
23
+ > **1.0 stable**: APIs and settings are frozen. The headline addition is **swapping poses right in Settings** — upload jpg / png / webp / bmp and the browser removes the background, crops and scales it; no scripts, no file juggling.
24
+
25
+ ## ✨ What it does
26
+
27
+ | | Feature | Details |
28
+ | --- | --- | --- |
29
+ | 💰 | **Balance** | Available balance (total / topped-up / granted), auto-refreshed every 60s by default. **Left click refreshes immediately** (6s cooldown by default, so mashing never hammers the API) — while refreshing you get a glow, a spinning progress ring and a "refreshing…" badge. Failures caused by the credential service not being ready right after host startup retry with backoff (4s→60s, up to 8 attempts) |
30
+ | 📊 | **Today's spend (official)** | Calls DeepSeek's usage endpoints `/api/v0/usage/by_api_key/{amount,cost}` directly, so money / requests / tokens match `platform.deepseek.com/usage` **exactly**. If the endpoint is unreachable it falls back to the balance-delta reading and labels that in the UI |
31
+ | 🗣️ | **Narrated turns** | After every turn she says, in character, how much that turn cost (5 tiers by amount), with model and input/output tokens in the sub-line. **Only closes on "got it~"** — never auto-dismisses |
32
+ | 🎭 | **Six expressions** | calm / pouting (on click) / blushing (while talking) / panicking (balance warning) / **waving hello (startup greeting)** / **chin on hand (weather)** |
33
+ | 🎨 | **Swap poses in Settings** | One row per expression: upload a jpg / png / webp / bmp and the browser removes white / light / solid-colour backgrounds (blue, green, pink, dark grey…; complex photo backgrounds are kept), crops the character to a square and exports 512 / 128 (plus 64 for the idle pose) into `$DSH_HOME/dsh-ds-whale-assets/` — no scripts and no file juggling for white-background JPGs. If one image is cut badly, turn off “Auto-remove background”; “Use default” restores the bundled art |
34
+ | 🖱️ | **Left click refresh · right-click menu** | Right click (no hit shake) opens: refresh now / balance details / top up / today's weather / open whale settings. "Top up" opens the official top-up page in one click (prefers the `topUpUrl` from DSH's account service, falls back to `platform.deepseek.com/top_up`) — no need to open a panel first. Menu items have proper hover highlight and transitions |
35
+ | 🌤️ | **Today's weather** | "Today's weather" in the right-click menu: **zero tokens**. Current temperature, today's range, rain probability, the next three hours, plus a line on whether to grab an umbrella or hydrate. First use lets you **type the city right in the bubble** (the input sits next to the whale; save and the weather shows up immediately, no trip to the settings page). City → lat/lon has three fallbacks (built-in city table → photon → Open-Meteo); the forecast races Open-Meteo against wttr.in and takes whichever answers first, and it distinguishes "city not found" from "network unreachable" |
36
+ | 🔊 | **Custom sounds** | Five independent scenes: **greeting** (when DSH opens) / **per-turn narration** / **click** / **balance & budget alert** / **peak switch**. Each row has its own on/off, preview, and upload (wav / mp3 / ogg / m4a / flac, ≤ 1 MB each). A successful upload swaps the sound instantly and previews it; "reset to default" goes back to the synthesized chime. Without an upload the five default chimes differ in pitch and rhythm (short click, rising greeting, two-note falling alert, three-note rise for peak switches), so you can tell events apart without looking. Rapid clicks on the same scene fade the previous playback out (about 10ms, no pop) and start the new one, so clicks never stack into a wall of sound — and it still never goes "sound once, silent after" |
37
+ | 👋 | **Startup greeting** | Every time DSH opens she greets you by your nickname in the same cute voice (six tiers by time of day), with the waving pose and a chime |
38
+ | 💬 | **Persistent bubble** | A small vertical bubble next to the avatar: a **peak/off-peak status strip** on top (dot + peak/idle + full price/50% off + countdown to the next switch), and the 1–3 metrics you picked below (balance / today / local estimate / this turn / peak countdown) |
39
+ | ⏰ | **Peak pricing** | Weekdays 09:00–12:00 and 14:00–18:00 are peak (full price); all other hours and weekends are idle (50% off). The bubble has the status strip, the details panel pins a **24-hour price band** with a now-cursor at the top, plus the current window and the next window's name; weekend countdowns are shown as "d:h" |
40
+ | 🧭 | **Tabbed details** | The brand-blue hero card at the top pins two primary numbers (available balance / spent today), the 24-hour price band and the current rates; everything else is split into three tabs: **Overview** (today's books with the official cache/input/output split, last round, reconcile link) / **Usage** (range totals, model cost) / **Records** (every entry, search, clear actions). Tabs are a solid-blue segmented control, range filters are small pills, and long content scrolls inside the panel instead of stacking up |
41
+ | 🔔 | **Peak-switch reminder** | When peak hours start or end, one bubble pops (auto-dismisses in 5s) and a sound plays; the fifth sound scene ("peak switch") can be toggled, previewed and customized like the others. Turn the reminder off in settings to keep only the countdown |
42
+ | ⚠️ | **Anomalous turn** | When a turn costs at least 5× the median of the last 20 turns (and at least ¥0.01 more), the narration marks it "⚠ N× pricier than usual" and the last round in Overview turns amber; fewer than 5 samples means no judgement |
43
+ | 📈 | **Cache hit rate · spend trend** | The token line in Overview now ends with the cache hit rate (≥80% green / ≥50% grey / lower amber); Usage has a 14-day bar chart with the daily average, falling back to the local estimate for days without observations |
44
+ | 🧮 | **Balance composition** | A 3px split bar under "topped-up / granted" in the hero card; hover for the percentages, no extra height |
45
+ | 🔄 | **New-version hint** | The host checks GitHub Releases every 6 hours (retries after 30 minutes on failure, caches to disk, stays silent offline or rate-limited); the settings page footer shows "up to date" or "new version vX", and you can check manually |
46
+ | 🚨 | **Balance / budget alerts** | Below the warning line or over today's budget she switches to the panicking face and narrates it, with "top up" / "see usage" / "got it" buttons |
47
+ | 📒 | **Usage ledger** | Inside the **Records** tab: filter by today / last 7 days / all time, search by model or date, entries grouped by day; clear today, clear all, reset baseline |
48
+ | ⚙️ | **Settings page** | A dedicated "小鲸鱼 / Whale" page in **DSH Settings → left nav** (right below 喵记忆), plus the host-generated form at **DSH Settings → Plugins → dsh-ds-whale**. "Open whale settings" in the right-click menu jumps straight to it |
49
+ | 🖱️ | **Feel** | Drag to move with position memory (stores "which edge + how far from that edge", so resizing the window keeps the edge, not the distance), edge snapping judged by the **page midline**, a size slider. The whale can be dragged to the very top of the window — narration bubbles and the details panel then flip below it (based on measured height), and the small persistent bubble follows vertically centered, so nothing gets clipped by the window edge |
50
+
51
+ <div align="center">
52
+ <img src="assets/whale-blush.png" width="110" alt="blushing" />
53
+ <img src="assets/whale-angry.png" width="110" alt="pouting" />
54
+ <img src="assets/whale-panic.png" width="110" alt="panicking" />
55
+ <img src="assets/whale-greet.png" width="110" alt="waving hello" />
56
+ <img src="assets/whale-think.png" width="110" alt="thinking" />
57
+ </div>
58
+
59
+ ## 👋 Three new gestures
60
+
61
+ | When | Pose | Sample line |
62
+ | --- | --- | --- |
63
+ | DSH opens | waving hello | "小蓝,早上好呀!余额我盯好了,随时可以开工。" — "Good morning, Xiaolan! Balance is watched, we can start whenever." |
64
+ | Click "Today's weather" | chin on hand | "Beijing · 7°C clear" / today 4–16°C · mostly clear · 0% rain |
65
+ | Click weather before setting a city | chin on hand | "Tell me which city first~" → an input appears right in the bubble; save and the result shows immediately |
66
+
67
+ <div align="center">
68
+ <img src="assets/shot-dock.png" width="300" alt="Persistent bubble: peak status strip + three metrics" />
69
+ <img src="assets/shot-dock-cooldown.png" width="300" alt="Cooldown hint after a click" />
70
+ <br />
71
+ <img src="assets/shot-greet.png" width="286" alt="Startup greeting: waving pose + narration" />
72
+ <img src="assets/shot-summary.png" width="286" alt="Turn summary: how much it cost, whether it was worth it" />
73
+ </div>
74
+
75
+ ## 🚀 Install
76
+
77
+ Prerequisites: DSH desktop app or `dsh web`, Node ≥ 20.
78
+
79
+ **Option 1: install from GitHub (recommended)**
80
+
81
+ ```bash
82
+ # install the whole repo into the current profile's plugin directory
83
+ dsh plugin add github:Iceseas/dsh-ds-whale
84
+ ```
85
+
86
+ Restart DSH (or reload the plugin) and the whale appears in the bottom-right corner. If your DSH build has no `plugin add`, do a one-off local install:
87
+
88
+ ```bash
89
+ git clone https://github.com/Iceseas/dsh-ds-whale.git
90
+ # then in DSH run plugin_manager action=install_bundle with target set to that directory's absolute path
91
+ ```
92
+
93
+ **Option 2: drop it in manually**
94
+
95
+ 1. Copy the repo to `<DSH_PROFILE_DIR>/node_modules/dsh-ds-whale` (`DSH_PROFILE_DIR` is usually `~/.dsh/profiles/desktop`);
96
+ 2. Add `"dsh-ds-whale"` to `dsh.profile.bundles` in that profile's `package.json`;
97
+ 3. Restart DSH.
98
+
99
+ **What it needs to be useful right away**: DeepSeek credentials configured in DSH (`DEEPSEEK_API_KEY`) **or** a signed-in DeepSeek account. Without either, the widget still appears — the balance row just says credentials are needed.
100
+
101
+ ## ⬆️ Update
102
+
103
+ To see the current version: whale panel → Settings; the bottom line shows `版本 vX.Y.Z` and "view new version" (goes to the Releases list). For the latest version see [Releases](https://github.com/Iceseas/dsh-ds-whale/releases) (from 1.0 on, releases are published as stable — the repo's Releases card and `/releases/latest` point at them; the 0.x history shipped as Pre-releases, which only affected display, not install or update).
104
+
105
+ **Installed without a version pin** (`github:Iceseas/dsh-ds-whale`) — tracks the default branch, one command:
106
+
107
+ ```bash
108
+ dsh plugin update dsh-ds-whale
109
+ ```
110
+
111
+ **Pinned to a tag** (`.../dsh-ds-whale#vX.Y.Z`) — `update` won't cross versions, switch the tag explicitly:
112
+
113
+ ```bash
114
+ # replace vX.Y.Z with the target tag (pick the latest one from Releases)
115
+ dsh plugin add github:Iceseas/dsh-ds-whale#vX.Y.Z
116
+ ```
117
+
118
+ **Installed from a zip / by hand**: download the new `dsh-ds-whale-x.y.z.zip`, overwrite `<DSH_PROFILE_DIR>/node_modules/dsh-ds-whale/` wholesale, restart.
119
+
120
+ Either way, **restart DSH** afterwards — the plugin has host-side code (`lib/index.js` routes and state) and hot reload only swaps the front end.
121
+
122
+ > Multi-profile setups (`desktop` + `web`) need `--profile`, e.g. `dsh plugin update dsh-ds-whale --profile web`.
123
+
124
+ ## 🔐 Data & privacy
125
+
126
+ - The only data file: `$DSH_HOME/.dsh-ds-whale.json` (Windows default `C:\Users\<you>\.dsh\.dsh-ds-whale.json`), **local only**.
127
+ - It stores: balance observations, official usage cache, daily totals, per-turn amounts. **No conversation content**, nothing uploaded.
128
+ - Only four kinds of outbound requests, all using credentials already on your machine (the third and fourth are credential-free):
129
+ 1. `GET https://api.deepseek.com/user/balance` (Bearer `DEEPSEEK_API_KEY`)
130
+ 2. Official usage `GET https://platform.deepseek.com/api/v0/usage/by_api_key/{amount,cost}` (with the DSH-session `x-dsh-auth-token`)
131
+ 3. Weather (only when you click "Today's weather"): city name → lat/lon, then the forecast. **No credentials, no token, nothing beyond the city you typed**; results are cached in the host process for 10 minutes. Geocoding has three fallbacks: built-in coordinate table for common cities (a hit means no network at all) → `photon.komoot.io` → `geocoding-api.open-meteo.com`; forecasts prefer `api.open-meteo.com` and fall back to `wttr.in` (no key) when it is unreachable. These host-side requests prefer the local system proxy (`HTTPS_PROXY` / Windows proxy settings) and fall back to a direct connection
132
+ 4. Update check (at most every 6 hours): `GET https://api.github.com/repos/Iceseas/dsh-ds-whale/releases` — **no credentials at all**, only to read the latest version tag; skipped silently when offline or rate-limited
133
+ - No hard-coded secrets anywhere; the repo carries no `.env`, credentials or personal paths.
134
+ - "Clear today / clear all / reset baseline" at the bottom of the ledger page wipes the books whenever you want.
135
+
136
+ ## ⚙️ Settings
137
+
138
+ | Field | Details |
139
+ | --- | --- |
140
+ | UI language `language` | `auto` follows the system locale / `zh` Chinese / `en` English; in English both the UI and the narration are fully English |
141
+ | Nickname `nickname` | How she addresses you in narration (up to 16 chars; leave empty to skip names) |
142
+ | Size `scale` | 0.6–2× |
143
+ | Auto-remove background `avatarAutoMatte` | Flood-fills light (white / cream / light grey) and solid-colour (blue / green / pink / dark grey…) backgrounds from the four edges and recomputes edge alpha against the sampled background colour; complex photo backgrounds are kept as-is. Turn it off to only crop and scale |
144
+ | Avatar padding `avatarPad` | Empty margin kept when cropping to a square (0–0.25, default 0.05 = 5%); smaller means a bigger character |
145
+ | Bubble metrics `miniFields` | `balance` / `today` / `estimate` / `turn` / `peak`, up to 3 |
146
+ | Per-turn narration `turnPop` | Turn it off and no narration popup appears |
147
+ | Warning line `warnBelow` | Below this value she switches to the panicking face; 0 = off |
148
+ | Daily budget `dailyBudget` | Alert once when exceeded; 0 = unlimited |
149
+ | Refresh interval `refreshMs` | Balance auto-refresh period (15s–1h) |
150
+ | Chime `soundOn` / `soundVolume` | End-of-turn chime and volume |
151
+ | Midline snap `snap` | Snap to the nearest side after dragging (judged by the page midline) |
152
+ | Peak hours `showPeak` | Whether the persistent bubble shows the status strip (peak/idle, full/50%, countdown to the next switch); off leaves only your chosen numbers |
153
+ | Click cooldown `clickCooldownMs` | Minimum interval between left-click refreshes (2000–120000ms, default 6000) so rapid clicking can't hammer the balance API |
154
+ | Startup greeting `greetOnStart` | Whether to greet you by nickname every time DSH opens |
155
+ | Weather city `weatherCity` | City used for weather (e.g. `Shanghai` / `Tokyo`). **Required**: without it, "Today's weather" asks right inside the bubble and shows the result once saved. In the settings page this field also saves as you type (800ms debounce, no blur needed) |
156
+ | Peak-switch reminder `peakNotify` | Pops one bubble and plays a sound when the pricing window switches; off leaves only the countdown |
157
+ | Peak-switch sound `soundPeak` | The fifth sound scene (peak hours start / end); preview and upload work like the others |
158
+ | Cache accounting `cacheInInput` | Whether `inputTokens` already includes cache hits; DeepSeek does not, so keep this off |
159
+
160
+ ## 🧮 Pricing & math
161
+
162
+ CNY per million tokens, formatted `[idle, peak]`:
163
+
164
+ | Model family | Cache hit | Cache miss input | Output |
165
+ | --- | --- | --- | --- |
166
+ | `deepseek-flash` (incl. the v4-flash series) | 0.02 / 0.04 | 1 / 2 | 4 / 8 |
167
+ | `deepseek-v4-pro` (incl. pro / reasoner / r1) | 0.15 / 0.30 | 4.5 / 9.0 | 13.5 / 27.0 |
168
+
169
+ `cost = (cache hits × hit price + cache-miss input × input price + output × output price) / 1e6`
170
+
171
+ In DeepSeek's usage, `totalTokens = inputTokens + outputTokens + cacheReadTokens` — i.e. `inputTokens` **excludes** cache hits, so "cache-miss input" can use `inputTokens` directly. Only turn on `cacheInInput` when some provider folds cache hits into `inputTokens`.
172
+
173
+ **How the three readings relate**: official usage (authoritative, the main number) → balance-delta observation (corroborating) → local token estimate (cross-check). The panel renders their difference as "deviation", which is how you spot price-table drift.
174
+
175
+ ## 🧩 Routes
176
+
177
+ Prefix `/api/dsh-ds-whale`, same-origin `POST` (reachable only from the local browser):
178
+
179
+ | Route | Purpose |
180
+ | --- | --- |
181
+ | `/state` | Balance + today (incl. official usage) + peak hours + settings + recent records (stale data is refetched automatically) |
182
+ | `/refresh` | Force-refresh balance and official usage |
183
+ | `/update` | Manual update check (POST); the response is the full `/state`, with `latest / hasUpdate / url` under `update` |
184
+ | `/weather` | Today's weather (`{force?, city?}`): zero tokens. Returns `{ok:false, error:"need-city"}` when no city is configured, `geocode-failed` when the city isn't found, `geocode-offline` on network failure (the two have different messages) |
185
+ | `/settings` | Write settings: `{"patch":{...}}` changes runtime state, `{"config":{...}}` writes into the profile's `cordis.patch.yml` |
186
+ | `/ledger` | `clear-today` / `clear-all` / `ack-adjust` / `rebaseline` |
187
+ | `/history` | Search history by model name or date |
188
+ | `/client-hello` | Front-end self-report (build / current mood) for troubleshooting |
189
+ | `GET /avatar.png` | Avatar PNG; supports `?size=128` and `&mood=angry\|blush\|panic\|greet\|think`; ETag enabled |
190
+ | `/avatar/upload` | Upload art: `{mood, name, big, small, tiny}` — three browser-processed PNGs at 512 / 128 (plus 64 for calm), base64; the host only validates the PNG signature and dimensions before writing, and responds with the new `avatars` metadata |
191
+ | `/avatar/reset` | Drop one pose's custom art and fall back to the bundled assets: `{mood}` |
192
+ | `GET /sound` | Custom sound file: `?scene=greet\|turn\|click\|warn\|peak`; ETag enabled (rev changes when the file changes, so the browser refetches) |
193
+ | `/sound/upload` | Upload a sound: `{scene, name, mime, data(base64)}`, ≤ 1 MB; the response carries the new `sounds` metadata |
194
+ | `/sound/reset` | Drop a scene's custom sound and go back to the default chime: `{scene}` |
195
+
196
+ ## 🛠️ Development
197
+
198
+ ```
199
+ dsh-ds-whale/
200
+ ├── lib/index.js # Host half: balance, official usage, ledger, HTTP routes, config schema
201
+ ├── lib/client.js # Client half: dock UI, mood animation, narration, settings page components
202
+ ├── assets/ # six poses + small sizes
203
+ ├── locale/ # meta.title / meta.description
204
+ ├── scripts/gen-avatars.mjs # batch-generate the poses via local Agnes (six moods)
205
+ ├── scripts/cut-bg.ps1 # white → transparent (4-edge flood fill + edge feathering)
206
+ ├── scripts/build-avatar.ps1 # trim to bbox + downscale to 512/128/64
207
+ ├── scripts/finalize-avatars.ps1 # chains the two steps above
208
+ ├── tools/avatar-selftest/ # upload-pipeline self-test (pixels + headless Chrome + host routes)
209
+ ├── cordis.patch.yml # plugin line declaration
210
+ └── package.json
211
+ ```
212
+
213
+ - Editing `lib/client.js`: DSH's client-hmr hot-reloads it (do one Ctrl+Shift+R hard refresh if needed, so an old module instance doesn't sit under the new one).
214
+ - Editing `lib/index.js`: reload the host half (toggle the plugin off/on in the plugin manager).
215
+ - Sound files live in `$DSH_HOME/dsh-ds-whale-sounds/<scene>` (`greet` / `turn` / `click` / `warn` / `peak`); metadata travels with `.dsh-ds-whale.json`. Dropping same-named files in that directory (or deleting them) is reconciled from disk on the next start.
216
+ - Poses: `node scripts/gen-avatars.mjs` (requires DSH running + `dsh-agnes-studio` installed with `AGNES_API_KEY` configured) generates six images into `avatar-out/` from `CHARACTER` + `POSES`; then `& scripts\finalize-avatars.ps1 -SrcDir avatar-out -OutDir avatar-out\final -Pad 0.02` removes the white background, trims to the bbox and exports 512/128/64; finally overwrite `assets/`. File prefixes are fixed as `whale` / `whale-angry` / `whale-blush` / `whale-panic` / `whale-greet` / `whale-think`; the host serves them straight from `MOOD_FILES` (`mood=greet` / `mood=think`). Swapping art no longer means touching files: use the six upload rows under “Avatar art” in Settings (the browser removes the background, crops and scales — white JPG borders included). The scripts remain for batch generation, and dropping same-named files into `~/.dsh/dsh-ds-whale-assets/` still works. After changing the algorithm run `python tools/avatar-selftest/selftest.py`: it covers the pixel pipeline, a headless-Chrome end-to-end pass and the host routes.
217
+
218
+ ## 📄 License
219
+
220
+ [MIT](LICENSE) © 2026 Iceseas
221
+
222
+ > Unofficial project. DeepSeek and DeepSeek Harness names and trademarks belong to their respective owners.