dsh-plugin-upgrader 1.5.0 → 1.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.6.1 — 2026-10-30
4
+
5
+ - **The source test no longer calls a working mirror unreachable.** The probe tried
6
+ `/-/ping` first and the registry root only if that failed, with 1500 ms for the whole
7
+ thing. `registry.npmmirror.com` answers `/-/ping` in 3 to 15 seconds on some networks
8
+ while its root answers in 0.3 s, so the mainland mirror — the mirror this feature exists
9
+ for — came back as "unreachable", and so did `registry.npmjs.org` on a slow link at
10
+ 2.2 s. Both paths are now asked at the same time, the first 2xx wins, and
11
+ `PROBE_TIMEOUT_MS` is 5 s for the whole probe rather than per request.
12
+ - **A failed test now says which failure it was.** A status line ("HTTP 503" — the host is
13
+ up and unhappy) is reported ahead of a timeout, and a timeout is reported as
14
+ `timed out after 5000 ms` instead of passing `AbortSignal.timeout`'s
15
+ `The operation was aborted due to timeout` straight into the dialog.
16
+
17
+ ## 1.6.0 — 2026-10-30
18
+
19
+ - **The install source is now a setting, not a file edit.** The Versions tab header
20
+ carries a registry control: the official registry, the mainland mirror, whatever
21
+ `pluginManager` is configured with, sources the user added, or an address typed in.
22
+ The choice is written to the profile through the host's settings service, so it
23
+ survives a restart and is the same in every browser — which is the part the plugin
24
+ page's per-install registry choice never did (issue #1). The version list is re-read
25
+ from the chosen source and every install passes it to the manager, so the list and the
26
+ click cannot disagree about where a package comes from. "Follow pnpm's config" keeps
27
+ the previous behaviour and is the default.
28
+ - **The control opens a dialog that manages sources, not just picks one.** It lists
29
+ every source the tab can use — the two built-in addresses, the ones `pluginManager`
30
+ is configured with, and the ones the user added — and each row can be tested against
31
+ the host (`/-/ping`, falling back to the registry root) and switched to with one click,
32
+ so "is this mirror actually up" is answered in the place the user picks it instead of
33
+ by a failed install.
34
+ - **The built-in sources have no edit and no delete, by construction.** They are
35
+ compiled in (`src/client/registry.ts` `WELL_KNOWN_REGISTRIES`) and never written
36
+ into the saved list, so there is no row to edit or remove — not a disabled button
37
+ that a later refactor could re-enable.
38
+ - **The settings are volatile `Config` fields**, which is the only shape the host
39
+ exposes a form for: a plain field is invisible to the settings service, and a
40
+ non-volatile write would restart the plugin. `src/host/config.ts` declares `registry`
41
+ and `customRegistries`, `src/client/registry.ts` reads and writes them through
42
+ `configForms`. A host without that service still renders the tab, with the source
43
+ shown but not editable.
44
+ - **Custom sources are the second field**, `customRegistries`, so the list persists
45
+ through the same settings write as the choice and is the same in every browser.
46
+ Adding, editing and deleting all send the whole array: one bad element fails the
47
+ write, so validating the list before saving and storing it verbatim afterwards keeps
48
+ a click from half-applying. Deleting or editing the source in use also moves the
49
+ choice, so an install can never be redirected to an address the list no longer holds.
50
+ - **`@deepseek-ai/schemastery` is a real dependency now.** It was already present
51
+ transitively through `dsh-plugin-manager`, but a `Config` schema must be built by the
52
+ same library the loader validates with, so it is declared rather than borrowed.
53
+
3
54
  ## 1.5.0 — 2026-10-30
4
55
 
5
56
  - **The package now passes the DSH Store's fixed-commit review on everything a
package/README.en.md CHANGED
@@ -30,6 +30,14 @@ English · [中文](./README.md)
30
30
  version number opens that version's GitHub release page.
31
31
  - **A lagging mirror is named** — versions published upstream but not yet mirrored
32
32
  are listed separately instead of the row pretending to be current.
33
+ - **Pick your own source** — switch the npm registry from the top of the Versions tab
34
+ (official, the mainland mirror, or an address you type). The version list is re-read
35
+ from the new source immediately and installs follow it; the choice is written to the
36
+ profile, so it survives a restart and is the same in every browser.
37
+ - **Manage sources in a dialog** — the Registry button opens a dialog listing the
38
+ built-in sources, the ones `pluginManager` is configured with, and the ones you added.
39
+ Built-ins cannot be edited or deleted; your own can. Every row can be tested on its
40
+ own, and so can the source currently in use.
33
41
 
34
42
  > **Changing this repo? Read [AGENTS.md](./AGENTS.md) first.** It lists the behaviour
35
43
  > that already works and must keep working, with the code location and the test that
@@ -41,6 +49,17 @@ English · [中文](./README.md)
41
49
  A **Versions** tab appears next to *Installed* and *Discover* on the Plugins page:
42
50
 
43
51
  - Header counts: upgradable / installed / version count
52
+ - The header **Registry** control opens the source dialog:
53
+ - built-in sources (official registry, mainland mirror): switch to and test, never edit
54
+ or delete
55
+ - sources from `pluginManager`: use one directly, or keep it in your own list
56
+ - sources you added: edit and delete; deleting the one in use falls back to
57
+ *Follow pnpm's config*
58
+ - **Test** on a row asks `/-/ping` and the registry root at the same time and keeps
59
+ whichever answers first, with a 5 s budget for the whole probe (a sequential probe
60
+ reported mainland mirrors as unreachable — their `/-/ping` can take 15 s while the
61
+ root answers in 0.3 s), and shows the verdict under that row
62
+ - the footer's *Follow pnpm's config* keeps pnpm's own registry (usually `.npmrc`)
44
63
  - **Upgrade all** handles every upgradable plugin; the selection bar below handles
45
64
  **Upgrade selected**
46
65
  - **Check for updates** bypasses the 5-minute registry cache
@@ -213,7 +232,7 @@ dsh-plugin-upgrader/
213
232
  │ │ └── manager.ts the minimal host pluginManager type contract
214
233
  │ └── client/ browser side (modules, bundled into one file)
215
234
  │ ├── index.ts createPlugin(require): slot registration entry
216
- │ ├── components/ Tab / PluginRow / VersionLine / JobPanel
235
+ │ ├── components/ Tab / PluginRow / VersionLine / JobPanel / SourceDialog
217
236
  │ ├── copy.ts zh / en strings
218
237
  │ ├── styles.ts scoped CSS
219
238
  │ ├── hooks.ts locale subscription, overview fetching
@@ -221,7 +240,7 @@ dsh-plugin-upgrader/
221
240
  │ ├── format.ts versions / dates / external links
222
241
  │ ├── env.ts minimal window typings
223
242
  │ └── types.ts payload types
224
- ├── lib/ build output (**committed**, see AGENTS.md §12)
243
+ ├── lib/ build output (**committed**, see AGENTS.md §13)
225
244
  │ ├── index.js host entry (tsc output)
226
245
  │ ├── host/*.js host modules plus .d.ts
227
246
  │ └── client.js the browser bundle, wrapped in __ModuleLoader__
@@ -258,12 +277,21 @@ pnpm run check # all of the above, plus the pack check and the build-committ
258
277
  will not run `prepare` to fill in missing runtime files. So `pnpm install` no longer
259
278
  builds (install-time scripts are an automatic rejection in that review) and the build
260
279
  hangs off `prepack`; after editing `src/` you must `pnpm run build` and commit `lib/`
261
- with it, which `pnpm run check` verifies. See [AGENTS.md](./AGENTS.md) §12.
280
+ with it, which `pnpm run check` verifies. See [AGENTS.md](./AGENTS.md) §13.
262
281
 
263
282
  The host half lives in `src/index.ts` (a `webServer` prefix route at
264
283
  `/api/plugin-upgrader`), the browser half in `src/client/index.ts` (registering the
265
284
  `plugins.tab` slot).
266
285
 
286
+ The user settings are `registry` (the source in use, empty for "follow pnpm") and
287
+ `customRegistries` (the sources the user added), both declared in `src/host/config.ts`.
288
+ Both are marked `.volatile()`, which is what makes the host's settings service expose a
289
+ form for them and what lets a write reach the running plugin without a DSH restart. The
290
+ browser reads and writes them through the `configForms` client service
291
+ (`src/client/registry.ts`); a host without that service still renders the tab, with the
292
+ source shown but not editable. The two built-in sources are constants, never entries in
293
+ `customRegistries` — that is why no click can edit or delete them.
294
+
267
295
  `pnpm run dev` runs two watchers side by side: `tsc --watch` owns `lib/index.js`
268
296
  and `lib/host/**`, esbuild owns `lib/client.js`, so neither overwrites the other.
269
297
  esbuild only strips types, it does not check them — run `pnpm run typecheck` after
package/README.md CHANGED
@@ -23,6 +23,11 @@ DSH 自带的插件页能装、能卸、能看已安装列表,但缺两件事
23
23
  - **一键跳 GitHub** —— 每行的 `GH` 按钮打开插件仓库主页;点版本号直接进该版本的 GitHub 发布页。
24
24
  - **镜像落后会标出来** —— 配置的镜像还没同步、但上游已经发布的版本会单独标一行,
25
25
  而不是假装已经是最新版。
26
+ - **自己选安装源** —— 版本页顶部就能切换 npm 源(官方源 / 大陆镜像 / 自己填的私有源),
27
+ 选完立刻按新源重读版本列表,升级也走这个源;选择写进 profile,重启和换浏览器都还在。
28
+ - **安装源管理** —— 「注册表」按钮打开一个对话框,里面列出自带源、`pluginManager` 配的源
29
+ 和用户自己加的源;自带源不能改也不能删,自己加的可以随时改/删。每一行都能单独
30
+ 「测试」能不能连上,当前在用的那个也能一键测。
26
31
 
27
32
  > **要改这个仓库?先读 [AGENTS.md](./AGENTS.md)。** 那里逐条写了「已经实现并且必须继续成立」
28
33
  > 的行为、对应代码位置和守护它的测试。上面这些功能里,`GH` 链接和 in-place 升级都曾经
@@ -33,6 +38,14 @@ DSH 自带的插件页能装、能卸、能看已安装列表,但缺两件事
33
38
  插件页顶部标签栏多出一个「版本」标签,与「已安装」「发现」并列:
34
39
 
35
40
  - 顶部统计:可升级数量 / 已安装数量 / 每个插件的版本数
41
+ - 顶部「注册表」按钮打开安装源对话框:
42
+ - 自带源(官方源、大陆镜像):只能切过去和测试,不能改也不能删
43
+ - `pluginManager` 里配的源:可以「收进列表」变成自己的常用源,或直接用
44
+ - 自己加的源:可以改、可以删,删掉的如果正在用会自动退回「跟随 pnpm 配置」
45
+ - 每行「测试」同时打 `/-/ping` 和根地址,谁先答应用谁,整次探测 5 秒预算
46
+ (串行探测会把大陆镜像报成连不上:`/-/ping` 有时要 15 秒,根地址只要 0.3 秒),
47
+ 结果显示在那一行下面
48
+ - 底部「跟随 pnpm 配置」用 pnpm 自己的源(通常是 `~/.npmrc` 里的那个)
36
49
  - 「一键升级」升全部可升级插件;下面一条选择栏负责「升级选中」
37
50
  - 「检查更新」强制刷新 registry 缓存(默认缓存 5 分钟)
38
51
  - 搜索框按包名过滤
@@ -176,6 +189,7 @@ dsh-plugin-upgrader/
176
189
  ├── src/ 源码(TypeScript)
177
190
  │ ├── index.ts 宿主端入口:路由注册、job 调度、加载时恢复 manifest
178
191
  │ ├── host/ 宿主端逻辑(Node,无 DOM)
192
+ │ │ ├── config.ts Config schema(volatile 的 registry / customRegistries)、读取用户选择
179
193
  │ │ ├── overview.ts 组装 overview 载荷(含并发上限)
180
194
  │ │ ├── registry.ts registry packument 拉取 / 裁剪、GitHub tag 列表、镜像缺口
181
195
  │ │ ├── install.ts 单步安装:in-place 替换、remove 回退、enabled 状态恢复
@@ -189,7 +203,8 @@ dsh-plugin-upgrader/
189
203
  │ │ └── manager.ts 宿主 pluginManager 服务的最小类型契约
190
204
  │ └── client/ 浏览器端(拆成模块,由 esbuild 打成一个文件)
191
205
  │ ├── index.ts createPlugin(require):槽位注册入口
192
- │ ├── components/ Tab / PluginRow / VersionLine / JobPanel
206
+ │ ├── components/ Tab / PluginRow / VersionLine / JobPanel / SourceDialog
207
+ │ ├── registry.ts 读写安装源设置、可选源列表的增删改
193
208
  │ ├── boot.ts reload 前确认 boot 文档还有效(见 AGENTS.md 第 4 条)
194
209
  │ ├── copy.ts zh / en 文案
195
210
  │ ├── styles.ts 作用域 CSS
@@ -198,7 +213,7 @@ dsh-plugin-upgrader/
198
213
  │ ├── format.ts 版本号 / 日期 / 外部链接
199
214
  │ ├── env.ts window 上的最小类型声明
200
215
  │ └── types.ts 载荷类型
201
- ├── lib/ 构建产物(**已提交**,见 AGENTS.md 第 12 条)
216
+ ├── lib/ 构建产物(**已提交**,见 AGENTS.md 第 13 条)
202
217
  │ ├── index.js 宿主端入口(tsc 输出)
203
218
  │ ├── host/*.js 宿主端模块 + .d.ts
204
219
  │ └── client.js 浏览器端单文件 bundle(含 __ModuleLoader__ 包装)
@@ -233,7 +248,7 @@ pnpm run check # 以上全部(typecheck + build + test + pack 检查 + 产
233
248
  `lib/` 是**提交进仓库**的,不是构建垃圾:DSH Store 审核固定 commit,不会为了补齐
234
249
  运行时文件去执行 `prepare`。所以 `pnpm install` 不再触发构建(安装期脚本会被审核
235
250
  直接否决),构建挂在 `prepack` 上;改完 `src/` 必须 `pnpm run build` 并把 `lib/`
236
- 一起提交,`pnpm run check` 会替你核对。详见 [AGENTS.md](./AGENTS.md) 第 12 条。
251
+ 一起提交,`pnpm run check` 会替你核对。详见 [AGENTS.md](./AGENTS.md) 第 13 条。
237
252
 
238
253
  **改任何代码前先读 [AGENTS.md](./AGENTS.md)。** 那里列的是「已经实现、不能再退回」的行为,
239
254
  每条都附了代码位置和守护它的测试名;`pnpm run check` 全绿只说明没写坏,不说明没改坏
@@ -245,6 +260,13 @@ pnpm run check # 以上全部(typecheck + build + test + pack 检查 + 产
245
260
  宿主端在 `src/index.ts`(`webServer` 前缀路由 `/api/plugin-upgrader`),
246
261
  浏览器端在 `src/client/index.ts`(注册 `plugins.tab` 槽位)。
247
262
 
263
+ 用户设置有两个:`registry`(当前在用的源,空 = 跟随 pnpm)和 `customRegistries`
264
+ (用户自己加的源),都在 `src/host/config.ts` 里声明成 `.volatile()`——这是宿主
265
+ 设置服务愿意为它生成表单、并且写入能进到正在运行的插件里而不重启的唯一形状。
266
+ 浏览器端通过 `configForms` 服务读写(`src/client/registry.ts`);没有那个服务的
267
+ 宿主照样能渲染这一页,只是源只能看不能改。两个自带源是常量,永远不写进
268
+ `customRegistries`,所以没有任何点击能改它们或删它们。
269
+
248
270
  `pnpm run dev` 会并行跑两个监听器:`tsc --watch` 负责 `lib/index.js` 和
249
271
  `lib/host/**`,esbuild 负责 `lib/client.js`,两者输出互不覆盖。注意 esbuild
250
272
  打包时会直接剥掉类型而不做检查,所以改浏览器端时顺手跑一次 `pnpm run typecheck`。