dsh-drink 0.0.0-stage → 1.0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 glenn5158
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,88 @@
1
- # Temporary Holding Version
1
+ # 鲸鱼妹喝水提醒 / dsh-drink
2
+
3
+ DSH 视窗右下角的一只鲸鱼妹浮窗:只在工作时段隔一阵子催你喝水,说的话每次都不一样。
4
+
5
+ - npm:`dsh-drink`
6
+ - 仓库:<https://github.com/glenn5158/DSH-DRINK>
7
+ - 许可证:MIT
8
+
9
+ ## 安装 / Install
10
+
11
+ 在 DSH 的 **Plugins → Add plugin** 里填包名 `dsh-drink`;或用插件管理工具的 `install_bundle`,`target` 传 `dsh-drink`。本地开发时直接传这个目录的绝对路径即可(会以 `link:` 方式挂载)。
12
+
13
+ ## 工作时段 / Working hours
14
+
15
+ 一律按 **Asia/Shanghai** 计算,并按**中国大陆法定工作日**判定(含调休):
16
+
17
+ | 日子 | 提醒时段 |
18
+ | --- | --- |
19
+ | 周一、周二、周四 | 09:30 – 21:00 |
20
+ | 其他工作日(周三、周五,以及调休上班的周末) | 09:30 – 19:00 |
21
+ | 周末(非调休)、法定节假日 | 不提醒 |
22
+
23
+ - 到点时间若落在时段之外,会自动顺延到**下一个工作时段的开头**(加 0–10 分钟随机偏移),不会在深夜或假日跳出来。
24
+ - 非工作时段她只是安静地待在角落,点头像会显示"现在不在提醒时段"。
25
+ - 节假日与调休数据来自国务院通知的机器可读版本(`NateScarlet/holiday-cn`),当前内嵌 **2026、2027** 两年:
26
+ - 2026:元旦 1/1–1/3,春节 2/15–2/23,清明 4/4–4/6,劳动节 5/1–5/5,端午 6/19–6/21,中秋 9/25–9/27,国庆 10/1–10/7;调休上班 1/4、2/14、2/28、5/9、9/20、10/10。
27
+ - 2027:元旦 1/1–1/3,春节 2/5–2/13,清明 4/3–4/5,劳动节 5/1–5/5,端午 6/9,中秋 9/15,国庆 10/1–10/7;调休上班 1/31、2/14、5/8、9/26、10/9。
28
+ - **没有数据年份按"周一至周五"兜底**。要补 2028 等年份:把新一年的 `days` 里 `isOffDay: true` 的日期加进 `client.js` 的 `OFF_DAYS`,`isOffDay: false` 的加进 `MAKEUP_WORKDAYS`(数据源:`https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/<year>.json`)。
29
+
30
+ ## 行为 / What it does
31
+
32
+ - 浮在整个 DSH 视窗右下角(`shell.overlay` 浮层,固定定位,不占用任何列的空间)。
33
+ - **间隔每轮重新随机**:45~60 分钟之间随机(精确到秒),喝完 / 放鸽子 / 重开页面后的下一轮都会重新抽。
34
+ - **不预告时间**:没有倒计时、没有进度条、也没有"还有多久"的提示;也**没有暂停**功能。
35
+ - **提醒内容由大模型现生成**:那句话和两个按钮上的字,都通过本插件的 Host 路由向 harness 的默认模型请求。
36
+ 送进模型的上下文只有:当前时间(时/分/星期,按上海时间)、今天喝了几杯、今天被提醒过几次、其中几次被放鸽子、上次喝水距今多少分钟、这一轮的间隔分钟数,以及随机选定的语气(撒娇催 / 假装生气 / 讲冷笑话 / 翻旧账…)。不发送聊天内容、文件、会话记录。
37
+ - **提醒时只有两个按钮**:「喝了」(重置计时 + 记一杯)、拒绝的那个(记一次放鸽子并重抽间隔),按钮文案同样由模型生成。
38
+ - 提前约 45 秒预取下一次文案;模型 20 秒内没回话或调用失败,就换成插件自带的轮换台词。
39
+ - 提醒弹出后 10 分钟没人理,自动算一次放鸽子并重抽间隔。
40
+ - 计时、计数、上一句台词只写在当前浏览器的 `localStorage`(键 `dsh.whale-water-reminder.v3`)。
41
+
42
+ ## 实现 / Implementation
43
+
44
+ | 文件 | 作用 |
45
+ | --- | --- |
46
+ | `index.js` | Host 半边:注册 `/_dsh-local/whale-water-reminder/copy` 只读路由,用 `llm.stream()` + 默认模型生成「一句话 + 两个按钮文案」,只允许本页面的浏览器 peer 调用,10 秒冷却。 |
47
+ | `client.js` | Client 半边:工作日历(`OFF_DAYS` / `MAKEUP_WORKDAYS` / 时段钳制)、随机间隔引擎、文案预取与本地兜底、`localStorage` 持久化、中英文字典。 |
48
+ | `assets/whale-girl.png` | 鲸鱼妹立绘;运行时以 base64 data URL 内联在 `client.js` 里。 |
49
+ | `locale/en.json`、`locale/zh.json` | Plugin Manager 里的标题与说明(含模型调用与工作时段)。 |
50
+ | `icon.svg` | 插件图标(鲸鱼妹头像 + 水花)。 |
51
+
52
+ ## 注意 / Limitations
53
+
54
+ - 只在前端计时:DSH 页面关闭期间不会提醒,重开页面后若仍在工作时段内且已过期会立刻提醒一次,否则顺延到下一个时段。
55
+ - 每次提醒是一次真实的模型请求(默认模型、约 320 输出 token 上限),会产生调用费用与延迟。
56
+ - 不弹系统通知、不发声,提醒只发生在视窗内。
57
+ - 杯数、提醒次数、放鸽子次数按上海日期跨天归零。
58
+ - 中国的节假日安排每年由国务院另行发布;数据年份之外按周一至周五兜底,可能把法定假日当工作日。
59
+
60
+ ## 开发 / Development
61
+
62
+ ```bash
63
+ npm run verify # 发布前体检:清单、导出、语法、资源、文案
64
+ npm test # 工作日历单元测试(会从 client.js 里抽取日历逻辑跑断言)
65
+ ```
66
+
67
+ CI 在 3 个机器时区(UTC / Asia/Shanghai / America/New_York)下各跑一遍 `npm test`,确保结果与运行环境时区无关。
68
+
69
+ ## 发布 / Release
70
+
71
+ 打 tag 即发布:
72
+
73
+ ```bash
74
+ npm version patch # 或 minor / major,会改 package.json 并提交
75
+ git push --follow-tags # 推送提交与 tag,触发 GitHub Actions
76
+ ```
77
+
78
+ `.github/workflows/publish.yml` 会在 `v*` tag 上依次执行:校验 tag 与 `package.json` 版本一致 → `npm run verify` → `npm test` → `npm publish --provenance`。包名 `dsh-drink` 没有 scope,默认就是公开包;若以后改成带 scope 的名字(如 `@glenn5158/dsh-drink`),把 workflow 里的命令改成 `npm publish --access public --provenance` 即可。
79
+
80
+ 发布前需要在仓库里配置一个 Actions secret:
81
+
82
+ | Secret | 用途 |
83
+ | --- | --- |
84
+ | `NPM_TOKEN` | npm 的 Automation token(npmjs.com → Access Tokens → Generate New Token → Automation),用于 `npm publish` |
85
+ | | 无需 `GITHUB_TOKEN`;provenance 由 `id-token: write` 自动签发 |
86
+
87
+ `.github/workflows/verify.yml` 在每次 push 和 PR 上跑体检与测试(不发布)。
2
88
 
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.
Binary file