dsh-quick-restart 0.1.2 → 0.1.4

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 (3) hide show
  1. package/README.md +55 -32
  2. package/lib/index.js +18 -0
  3. package/package.json +5 -2
package/README.md CHANGED
@@ -2,69 +2,92 @@
2
2
 
3
3
  ![标题栏上的「重载插件」与「重启」按钮](images/titlebar.png)
4
4
 
5
- 给 **DeepSeek Harness(DSH)** 标题栏加两个按钮:**重载插件代码**(不用关程序)和 **重启 DSH**。
5
+ 给 **DeepSeek Harness(DSH)** 标题栏加两个按钮:**重载插件**、**重启 DSH**。
6
6
 
7
- > 中文为主,末尾有简短的 English 说明。
7
+ 平时改插件代码要「完全退出客户端再打开」才生效。有了这两个按钮,大部分情况点一下就够。
8
8
 
9
- ## 它解决什么问题
9
+ ## 「重载插件」到底是什么
10
10
 
11
- DSH 的第三方插件改了代码之后,默认要**完全退出再打开**才生效(刷新页面没用,热重载也不会自动发生)。
12
- 这个插件在标题栏菜单栏加两个按钮,把这件事变成点一下:
11
+ 先说清楚一件事:**DSH 的插件不是独立程序。**
13
12
 
14
- - **重载** —— 只重新加载第三方插件,主进程和会话都不动,实测 8/8 成功;
15
- - **重启** —— 关掉并重开 DSH(需要另外安装 [`dsh-hot-restart`](https://github.com/InariNGT-Ofiicial/dsh-hot-restart) 提供重启引擎,没装就只有"重载"可用)。
13
+ 它没有自己的 exe、没有自己的进程,而是**跑在 DSH 主进程里的一个模块**——跟主程序挤在同一个进程里。所以严格说,没有「插件程序」可以启动或停止。
14
+
15
+ **「重载」做的事**:在 DSH 还开着的前提下,把这个插件模块的缓存清掉、重新加载一次、替换掉旧的那一份。效果等于「插件这一块被拆开重建了一遍」。
16
+
17
+ **重载之后,下面这些全都不变**:
18
+
19
+ | | 重载后 |
20
+ |---|---|
21
+ | DSH 主程序 | 还在跑,没退出 |
22
+ | 当前对话、上下文 | 全都在 |
23
+ | 窗口、界面 | 不动 |
24
+ | 本地端口 | 不变(重启才会变) |
25
+ | 耗时 | 1~2 秒 |
26
+
27
+ **什么时候该点它**:你改的是插件的**服务端代码**(那些 apply()、路由、定时任务),想立刻生效又不想关程序。
28
+
29
+ **什么时候它不管用**(这两点最容易被误会):
30
+
31
+ - 改的是插件的**前端界面**(client.js、样式、按钮)→ 重载只管服务端,界面还是旧的。按一下 Ctrl + R 刷新窗口即可,不用重启。
32
+ - 改的是 DSH 自己的**内置插件**(@deepseek-ai/*)→ 它们在安装包的 app.asar 里,只能靠重启。
33
+
34
+ 它重载的是**第三方插件**(你从市场装的、自己写的那些),逐个报结果;失败时鼠标悬停在按钮上能看到是哪个包、什么错误。
35
+
36
+ ## 「重启」是另一件事
37
+
38
+ 重启 = 把 DSH 整个关掉再打开。耗时十几秒,**本地端口会变**(连着的 QQ 桥接之类要重连)。装新插件、换了前端、动了内置插件,才需要它。
39
+
40
+ > 重启的引擎用的是 dsh-hot-restart(作者 xiaolu511,MIT)。它已经作为**依赖内置**在这个包里,你不需要另外安装。
16
41
 
17
42
  ## 安装
18
43
 
19
44
  **方式一:DSH 插件市场**(推荐)
20
45
 
21
- 设置 → 插件 → 搜索 `dsh-quick-restart` → 安装 → **完全退出 DSH 再打开**(按钮要宿主启动时注入,刷新页面没用)。
46
+ 设置 → 插件 → 搜索 dsh-quick-restart → 安装 → **完全退出 DSH 再打开**(按钮是宿主启动时注入的,刷新页面出不来)。
22
47
 
23
48
  **方式二:命令行 / 直链**
24
49
 
25
- ```bash
26
- npm i dsh-quick-restart
27
- ```
50
+ npm i dsh-quick-restart
28
51
 
29
52
  或把下面这个地址填进 DSH 的插件安装入口:
30
53
 
31
- ```
32
- https://registry.npmjs.org/dsh-quick-restart/-/dsh-quick-restart-0.1.2.tgz
33
- ```
34
-
54
+ https://registry.npmjs.org/dsh-quick-restart/-/dsh-quick-restart-0.1.4.tgz
35
55
 
36
56
  ## 用起来什么效果
37
57
 
38
- 标题栏菜单栏(文件/编辑那一条的右侧)多出两个小按钮:**重载**、**重启**。
39
- 点"重载"后,按钮会短暂显示结果;如果有插件重载失败,鼠标悬停能看到是哪个包、什么错误。
58
+ 标题栏菜单栏(文件 / 编辑那一条的右侧)多出两个小按钮:**重载插件**、**重启**。
59
+
60
+ 点「重载插件」后按钮会短暂显示结果(成功几个、失败几个);点「重启」会先弹一句确认,然后程序关闭并自动重开。
40
61
 
41
62
  ## 边界(老实说)
42
63
 
43
- - **只重载第三方插件**。`@deepseek-ai/*`(宿主内置,在 app.asar 里)和 `cordis:*`(虚拟分组)会被跳过——碰它们必然失败。
44
- - **前端 bundle 不会跟着换**。插件如果带前端界面,重载后界面那段还是旧的,得重启程序。这是宿主机制,不是本插件的问题。
45
- - **重启按钮依赖 `dsh-hot-restart`**。没装也能用"重载",只是重启那颗点了没反应。
46
- - 仅测试于 **Windows 桌面版**。其他平台未验证。
64
+ - **只重载第三方插件**。@deepseek-ai/*(宿主内置,在 app.asar 里)和 cordis:*(虚拟分组条目)会被跳过,碰它们必然失败。
65
+ - **前端 bundle 不跟着换**,见上面「什么时候它不管用」。
66
+ - **插件自己 spawn 的子进程不受影响**。重载只管插件模块本体,插件另起的进程(比如重启助手的 vbs)不会被回收,也不会重载。
67
+ - **重启只在 Windows 桌面版验证过**;重载是纯 JS,理论上平台无关,但未实测。
47
68
 
48
69
  ## 卸载
49
70
 
50
- ```bash
51
- pnpm remove dsh-quick-restart
52
- ```
53
- 再从 `dsh.profile.bundles` 里删掉对应条目,重启 DSH。
71
+ pnpm remove dsh-quick-restart
72
+
73
+ 再从 dsh.profile.bundles 里删掉对应条目,重启 DSH。
54
74
 
55
75
  ## 它是怎么做的(给好奇的人)
56
76
 
57
- 桌面壳的 `index.html` 直接读安装包里的静态 dist,不走 `renderIndex`,所以 `webServer.tapIndex` 无效。
58
- 唯一可用的通道是宿主启动时**一次性收集**的 `webserver/index-inject` 注入表——所以插件里不能写对象级 `inject = ['webServer']`,
59
- 否则 `apply()` 会推迟到 webServer 就绪之后,错过那次收集,界面上永远看不到按钮。这一点已在代码注释里写明。
77
+ 桌面壳的 index.html 直接读安装包里的静态 dist,不走 renderIndex,所以 webServer.tapIndex 无效。唯一可用的通道是宿主启动时**一次性收集**的 webserver/index-inject 注入表——所以插件里不能写对象级 inject = ["webServer"],否则 apply() 会推迟到 webServer 就绪之后,错过那次收集,界面上永远看不到按钮。
78
+
79
+ 重载本身是:取 loader 的 entries → 清掉该包在 loader.internal.loadCache 里的模块 → 重新 import → 用新插件替换旧的 fiber。
60
80
 
61
- 重载本身是:取 loader 的 entries → 清掉该包在 `loader.internal.loadCache` 里的模块 → 重新 import → 用新插件替换旧的 fiber。
81
+ 重启是调用 dsh-hot-restart 的 apply()(作为依赖装在同一个包里),由它的 vbs 助手完成脱离进程树的重开。
62
82
 
63
83
  ## English (short)
64
84
 
65
- **dsh-quick-restart** adds two titlebar buttons to DeepSeek Harness: **reload** third-party plugins without restarting the app, and **restart** DSH
66
- (the latter requires `dsh-hot-restart`). Built-in `@deepseek-ai/*` plugins and front-end bundles are intentionally not hot-reloaded — that's a host limitation.
67
- Tested on Windows desktop only. MIT licensed.
85
+ **dsh-quick-restart** adds two titlebar buttons to DeepSeek Harness.
86
+
87
+ - **Reload**: re-imports third-party plugins **inside the running host process**. The main process, your conversation, the window and the port all stay as they are. It only replaces server-side plugin modules — front-end changes still need a window refresh (Ctrl+R), and built-in @deepseek-ai/* plugins are skipped.
88
+ - **Restart**: fully quits and relaunches DSH, using the dsh-hot-restart engine (bundled as a dependency, nothing extra to install).
89
+
90
+ Windows desktop only for the restart path. MIT licensed.
68
91
 
69
92
  ## License
70
93
 
package/lib/index.js CHANGED
@@ -11,6 +11,24 @@ import { existsSync, readFileSync } from 'node:fs'
11
11
 
12
12
  export const name = 'dsh-quick-restart'
13
13
 
14
+ // 把 dsh-hot-restart 当作内置引擎:它是本包的依赖,直接 import 后调用它的 apply。
15
+ // 这样用户只装 dsh-quick-restart 一个包,「重启」就能用;
16
+ // 如果用户另外也装了 dsh-hot-restart,路由可能重复注册,这里忽略冲突即可。
17
+ async function embedHotRestart(ctx, log) {
18
+ try {
19
+ const mod = await import('dsh-hot-restart')
20
+ const plugin = (mod && mod.default) || mod
21
+ const apply = plugin && (plugin.apply || (plugin.default && plugin.default.apply))
22
+ if (typeof apply !== 'function') { log('内置重启引擎没有 apply,跳过'); return false }
23
+ await apply(ctx)
24
+ log('内置重启引擎(dsh-hot-restart)已启动')
25
+ return true
26
+ } catch (e) {
27
+ log('内置重启引擎加载失败(重启按钮会不可用): ' + String((e && e.message) || e))
28
+ return false
29
+ }
30
+ }
31
+
14
32
  const HERE = dirname(fileURLToPath(import.meta.url))
15
33
  const SELF = 'dsh-quick-restart'
16
34
  const CLIENT_ROUTE = '/dsh-quick-restart/client.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-quick-restart",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "description": "DeepSeek Harness 插件:标题栏加两个按钮——重载第三方插件(不用重启宿主)、重启 DSH。",
6
6
  "keywords": [
@@ -40,5 +40,8 @@
40
40
  "bugs": {
41
41
  "url": "https://github.com/a994903574/dsh-quick-restart/issues"
42
42
  },
43
- "author": "a994903574"
43
+ "author": "a994903574",
44
+ "dependencies": {
45
+ "dsh-hot-restart": "^0.3.16"
46
+ }
44
47
  }