dsh-plugin-greeting-bubble 1.2.0 → 1.2.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/README.md CHANGED
@@ -227,6 +227,7 @@ dsh-plugin-greeting-bubble/
227
227
  ├─ docs/
228
228
  │ ├─ DETAIL.md # 英文详情页文档(只含一张特性图)
229
229
  │ ├─ DETAIL.zh.md # 中文详情页文档(同一张图,中文替代文本)
230
+ │ ├─ DEV.md # 维护者开发/发布/排错指南
230
231
  │ └─ preview.svg # 特性图(640×300,无文字)
231
232
  ├─ test/
232
233
  │ └─ smoke.mjs # 离线冒烟测试(不随包发布)
@@ -238,6 +239,8 @@ dsh-plugin-greeting-bubble/
238
239
 
239
240
  ## 本地开发与测试
240
241
 
242
+ 维护者请先看 **[docs/DEV.md](docs/DEV.md)**:里面记录了完整的开发、测试、Git 与 npm 发布流程,以及我们实际踩过的坑(模块缓存、安装残留、2FA、观察期、GitHub DNS 等)。
243
+
241
244
  ```powershell
242
245
  # 1. 语法检查(需要 Node.js 18+)
243
246
  node --check index.js
package/docs/DEV.md ADDED
@@ -0,0 +1,264 @@
1
+ # 开发与发布指南(维护者)
2
+
3
+ 这份文档面向仓库维护者,记录本插件的本地开发、测试、Git 提交和 npm 发布流程,以及我们实际踩过的坑。普通用户请看 [README](../README.md)。
4
+
5
+ 所有命令都在 **PowerShell** 中执行,工作目录为仓库根目录(本文以 `D:\插件实现` 为例)。
6
+
7
+ ---
8
+
9
+ ## 0. 环境说明
10
+
11
+ 本机没有全局 `node`/`npm`,但 DSH 自带了一套 Node 和 pnpm,后面的命令统一用它们:
12
+
13
+ ```powershell
14
+ $node = 'C:\Users\81292\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies\node\bin\node.exe'
15
+ $pnpm = 'C:\Users\81292\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies\pnpm\bin\pnpm.mjs'
16
+ ```
17
+
18
+ > 路径里的用户名按实际情况替换;如果以后装了全局 Node,也可以直接用 `node` / `npm`。
19
+
20
+ ---
21
+
22
+ ## 1. 项目结构
23
+
24
+ ```text
25
+ .
26
+ ├─ package.json # 包清单:dsh.bundle.patch + dsh.client + exports/files
27
+ ├─ cordis.patch.yml # 往 Loader 插入插件行(id: greeting-bubble)
28
+ ├─ index.js # Host 半(空 apply)
29
+ ├─ client.js # 浏览器半:气泡、拖动、余额、slot 注册
30
+ ├─ icon.svg # 插件图标
31
+ ├─ locale/{zh,en}.json # 插件页标题/描述
32
+ ├─ docs/ # 详情页文档 + 本文档
33
+ ├─ test/smoke.mjs # 离线冒烟测试
34
+ └─ README.md / LICENSE / UPLOAD.md
35
+ ```
36
+
37
+ ---
38
+
39
+ ## 2. 本地开发
40
+
41
+ ### 2.1 安装到 DSH(link 方式)
42
+
43
+ 插件页 → **添加插件** → 填入仓库的**绝对路径**(例如 `D:\插件实现`)→ 安装。
44
+
45
+ 也可以用 agent:
46
+
47
+ ```text
48
+ 安装 D:\插件实现 这个插件
49
+ ```
50
+
51
+ ### 2.2 修改代码后,按需要选择刷新级别
52
+
53
+ | 改动 | 生效方式 |
54
+ |---|---|
55
+ | 只改 `client.js` / 样式 / 文案 | 插件页**关闭再打开**开关 → 刷新页面 |
56
+ | 改 `package.json`、`cordis.patch.yml`、宿主逻辑 | 卸载后重装 → 刷新页面 |
57
+ | 换过安装路径、升级/降级版本、出现 `ENOENT` | **完全退出 DSH 再打开**(重启 Host 进程) |
58
+
59
+ > 页面刷新(Ctrl+R)只重载浏览器页面,**不会清 Host 进程的模块缓存**。
60
+
61
+ ### 2.3 为什么必须重启:模块缓存与路径
62
+
63
+ DSH 的 Host 进程用 Node 的 ESM 加载插件。模块一旦被解析,结果会按“说明符 → 实际文件路径”缓存在进程里。
64
+
65
+ 如果插件是 `link` 到某个目录、之后又**删除或移动了那个目录**,Host 缓存仍指向旧路径,于是报:
66
+
67
+ ```
68
+ failed to import: ENOENT: no such file or directory, open '...\old-path\index.js'
69
+ ```
70
+
71
+ **规则:**
72
+
73
+ - 开发目录放在固定位置,**不要删、不要临时复制到别处再安装**;
74
+ - 要移动/删除目录,先到插件页**卸载**插件;
75
+ - 不得已换了路径:重启 DSH。
76
+
77
+ 另外,pnpm 替换 `node_modules` 里的链接目录时,Windows 上偶尔会报 `EPERM`(目录被占用)。这时先卸载,再清理残留(见 2.4),然后重装。
78
+
79
+ ### 2.4 清理安装残留
80
+
81
+ ```powershell
82
+ $nm = 'C:\Users\<用户名>\.dsh\profiles\desktop\node_modules'
83
+ Get-ChildItem $nm -Force | Where-Object { $_.Name -like '*greeting-bubble*' } | ForEach-Object {
84
+ if ($_.LinkType -eq 'Junction') { cmd /c rmdir "$($_.FullName)" } # 只删链接,不删目标
85
+ else { Remove-Item -LiteralPath $_.FullName -Recurse -Force }
86
+ }
87
+ ```
88
+
89
+ > 只对名称包含 `greeting-bubble` 的项操作;不要动其他插件。
90
+
91
+ ---
92
+
93
+ ## 3. 测试
94
+
95
+ 提交前至少跑:
96
+
97
+ ```powershell
98
+ $node = 'C:\Users\81292\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies\node\bin\node.exe'
99
+
100
+ node --check index.js
101
+ node --check client.js
102
+ node test/smoke.mjs # 必须输出:ok: ...
103
+ ```
104
+
105
+ 冒烟测试用假的 `window / React / Cordis / Remote` 上下文执行 `client.js`,校验模块 id、slot 注册参数、字典、账号 Remote 注入和组件渲染。
106
+
107
+ 检查 npm 会打包哪些文件:
108
+
109
+ ```powershell
110
+ $pnpm = 'C:\Users\81292\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies\pnpm\bin\pnpm.mjs'
111
+ & $node $pnpm pack --dry-run
112
+ ```
113
+
114
+ ---
115
+
116
+ ## 4. 版本与发布(npm)
117
+
118
+ ### 4.1 版本号
119
+
120
+ 遵循语义化版本:
121
+
122
+ - 修 bug:`1.2.1`
123
+ - 加功能:`1.3.0`
124
+ - 不兼容改动:`2.0.0`
125
+
126
+ npm **不允许重复发布同一个版本号**,每次发布前必须先改 `package.json` 的 `version`。
127
+
128
+ ### 4.2 登录与令牌
129
+
130
+ 发布需要 npm 账号并开启 2FA(安全密钥/生物识别)。发布令牌放在本机:
131
+
132
+ ```
133
+ C:\Users\<用户名>\AppData\Local\pnpm\config\auth.ini
134
+ ```
135
+
136
+ 内容形如:
137
+
138
+ ```
139
+ //registry.npmjs.org/:_authToken=npm_xxxxx
140
+ ```
141
+
142
+ **令牌绝不提交到仓库**。令牌过期(或误删)后重新生成一个即可:
143
+
144
+ - npm → **Access Tokens** → **Generate New Token** → **Granular Access Token**
145
+ - 权限 **Read and write (publish and stage)**、范围 **All packages**、**Bypass 2FA** 打开
146
+
147
+ > 注意:2027 年 1 月起 npm 收紧“免 2FA 令牌”的直接发布,届时需改用带验证码/可信发布(CI)的方式。
148
+
149
+ ### 4.3 发布
150
+
151
+ ```powershell
152
+ cd D:\插件实现
153
+ $node = 'C:\Users\81292\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies\node\bin\node.exe'
154
+ $pnpm = 'C:\Users\81292\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies\pnpm\bin\pnpm.mjs'
155
+
156
+ # 先干跑
157
+ & $node $pnpm publish --dry-run --no-git-checks --access public
158
+
159
+ # 正式发布
160
+ & $node $pnpm publish --no-git-checks --access public
161
+
162
+ # 验证(registry 有 1~2 分钟处理延迟)
163
+ & $node $pnpm view dsh-plugin-greeting-bubble version
164
+ ```
165
+
166
+ ### 4.4 两个常见“不是失败”的现象
167
+
168
+ 1. **`0.0.0-stage` 占位版本**:全新包第一次发布时,npm 先放一个占位版本,真版本 1~2 分钟后生效;不是错误,也不用审批。
169
+ 2. **`minimumReleaseAge` 观察期**:pnpm 默认不自动安装刚发布不久的版本。按包名安装会拿到旧版本;想立即用新版:
170
+
171
+ ```
172
+ dsh-plugin-greeting-bubble@1.2.0
173
+ ```
174
+
175
+ 安装时带上版本号,profile 会自动加入 `minimumReleaseAgeExclude` 白名单。
176
+
177
+ ### 4.5 测试版(可选)
178
+
179
+ 频繁试错时,用预发布版本代替 link 安装,避免路径缓存问题:
180
+
181
+ ```powershell
182
+ # package.json 版本改成 1.2.1-beta.0 后
183
+ & $node $pnpm publish --no-git-checks --access public --tag beta
184
+ ```
185
+
186
+ 安装时填 `dsh-plugin-greeting-bubble@1.2.1-beta.0`;测试通过后再发正式版。
187
+
188
+ ---
189
+
190
+ ## 5. Git
191
+
192
+ ### 5.1 提交与推送
193
+
194
+ ```powershell
195
+ cd D:\插件实现
196
+ git add -A
197
+ git commit -m "feat: xxx (v1.3.0)"
198
+ git tag v1.3.0
199
+ git push
200
+ git push origin v1.3.0
201
+ ```
202
+
203
+ 远端:`https://github.com/liwei169/dsh-plugin-greeting-bubble.git`
204
+
205
+ 推送会使用 Git Credential Manager 已保存的 GitHub 登录;也可以用 PAT(classic,`repo` 权限)作为密码。
206
+
207
+ ### 5.2 GitHub 网络问题
208
+
209
+ 本机到 `github.com` 的 DNS 偶尔会被解析到不可用 IP,表现为推送/安装超时。临时办法(机器级、可撤销):
210
+
211
+ - 管理员编辑 `C:\Windows\System32\drivers\etc\hosts`,加一行
212
+
213
+ ```
214
+ 20.205.243.166 github.com
215
+ ```
216
+
217
+ - 执行 `ipconfig /flushdns`;
218
+ - 用完后删除该行即可。
219
+
220
+ 长期方案:使用稳定的 DNS 或代理。
221
+
222
+ ### 5.3 `.git` 管理文件丢失的应急恢复
223
+
224
+ 如果 `git status` 报 `not a git repository`,但 `.git/objects`、`.git/refs` 还在:
225
+
226
+ ```powershell
227
+ # 1) 重建 .git/HEAD,内容为:ref: refs/heads/main
228
+ # 2) 重建 .git/config,至少包含 core、remote.origin、branch.main
229
+ # 3) 从 refs 重建索引
230
+ git reset --mixed HEAD
231
+ git status -sb
232
+ ```
233
+
234
+ 历史不会丢;`git fsck` 可校验。
235
+
236
+ ---
237
+
238
+ ## 6. 发版 Checklist
239
+
240
+ - [ ] 改代码,`package.json` 版本号 +1
241
+ - [ ] `node --check index.js` / `node --check client.js` 通过
242
+ - [ ] `node test/smoke.mjs` 输出 `ok: ...`
243
+ - [ ] `pnpm pack --dry-run` 文件清单正确(12 个文件左右)
244
+ - [ ] `git add/commit/tag/push`(含 tag)
245
+ - [ ] `pnpm publish --no-git-checks --access public`
246
+ - [ ] `pnpm view dsh-plugin-greeting-bubble version` 确认新版本
247
+ - [ ] 插件页卸载旧版 → 安装 `dsh-plugin-greeting-bubble@新版本` → 重启 DSH
248
+ - [ ] 刷新页面,确认气泡、拖动、余额正常
249
+
250
+ ---
251
+
252
+ ## 7. 常见问题
253
+
254
+ | 现象 | 原因 / 解决 |
255
+ |---|---|
256
+ | 安装报 `EPERM ... rename` | `node_modules` 里有旧目录/链接残留:卸载后按 2.4 清理再装 |
257
+ | 加载报 `ENOENT ... old-path\index.js` | Host 缓存了已删除的安装路径:完全重启 DSH |
258
+ | 插件页显示“未运行”但文件都在 | 同上,多为路径缓存或导入失败,重启后仍失败就看安装日志 |
259
+ | 新版本装不上、装到旧版 | `minimumReleaseAge` 观察期:填 `包名@版本号` 安装 |
260
+ | 气泡没出现 | 插件页确认已启用;刷新;检查控制台 `slot entry crashed`;确认 DSH 版本含 `shell.overlay` |
261
+ | 余额显示 `--` | 未登录 DeepSeek 账号或账号服务不可用;确认设置里账号正常 |
262
+ | `pnpm publish` 报 403 需要 2FA | 令牌没有 Bypass 2FA:重新生成 Granular Token 并打开 Bypass 2FA |
263
+ | `pnpm publish` 报 401 | 令牌过期/被删:重新生成并写入 `auth.ini` |
264
+ | 推送/安装 GitHub 超时 | DNS 问题,见 5.2 |
package/locale/en.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "meta": {
3
- "title": "Greeting bubble",
4
3
  "description": "Shows a “你好,腾盛” speech bubble near the bottom-right corner of the window, just above the message composer, plus the signed-in DeepSeek account balance (top-up and bonus wallets) refreshed every 60 seconds; click the balance line to refresh it immediately. Drag the bubble anywhere; its position is remembered for the next visit. Click × to dismiss it; it appears again on the next page load. The greeting stays Chinese in every interface language; only control labels are localized. Balance is read through the DSH account service, so the browser never sees the account token; a signed-out or failed read shows “Balance --”. The plugin makes no network requests of its own and collects no data. Disable or remove the bundle under Plugins to remove it.",
5
4
  "detail": "docs/DETAIL.md"
6
5
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "meta": {
3
- "title": "右下角问候气泡",
4
3
  "description": "页面加载后,在窗口右下角、输入框上方弹出「你好,腾盛」问候气泡,并显示当前 DeepSeek 账号余额(充值 + 赠送),每 60 秒刷新一次,点击余额行可立即刷新。按住气泡可以拖到任意位置,位置会记住,下次打开仍在原处。点气泡上的 × 即可关闭,下次页面加载时会再次出现。问候语在任何界面语言下都保持中文,只有按钮提示跟随界面语言。余额通过 DSH 账号服务读取,浏览器不接触账号令牌;未登录或读取失败时显示「余额 --」。插件不联网、不收集数据。在「插件」页停用或移除本插件即可彻底去掉。",
5
4
  "detail": "docs/DETAIL.zh.md"
6
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-greeting-bubble",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Shows a “你好,腾盛” speech bubble in the bottom-right corner of the DeepSeek Harness Web GUI.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {