dsh-plugin-restart-prompt
DSH 插件变动后提示「重启 DSH」,并一键完成静默重启(全程无命令提示符窗口);同一张卡片上还能展开「查看变动」,看这次到底改了什么。
仅 Windows。重启链路用 VBScript + WMI + taskkill,依赖 wscript.exe 与 System32\taskkill.exe。
English · 安装 · 接口
它解决什么
DSH 的插件组合在宿主启动时构建:装完 / 更新完 / 卸掉一个插件,界面不会自己变,必须重启 DSH。手动重启的麻烦在于——要么在进程管理器里翻出 PID,要么看着终端闪一个黑框,而且如果此刻 Agent 正在跑任务,重启会直接中断它。
本插件把这条链路收成一张卡片:
重启怎么实现(全程无窗口)
两段 VBScript,由 wscript.exe(GUI 子系统,启动时不分配控制台) 承载 → WMI 派生 → taskkill 结束整套 DSH 进程 → 重新拉起外壳 exe。
' launcher.vbs —— 宿主同步执行(约 100ms,退出码 = WMI ReturnValue)
Set svc = GetObject("winmgmts:\\.\root\cimv2:Win32_Process")
rv = svc.Create("""C:\Windows\System32\wscript.exe"" //B //Nologo ""...\relaunch.vbs""")
WScript.Quit rv
' relaunch.vbs —— WMI 子进程执行(宿主被杀也不受影响)
WScript.Sleep 700
Set sh = CreateObject("WScript.Shell")
sh.Run """C:\Windows\System32\taskkill.exe"" /F /T /IM ""<外壳进程名>""", 0, True ' 0 = 窗口隐藏
WScript.Sleep 1800
sh.Run """<DSH 外壳 exe>""", 1, False ' 1 = 正常显示新窗口
关键决策:
什么算「插件变动」
只有插件身份变化才提示重启,判定口径:
因此改推理等级、切模型、调主题这类只写 config 段的设置不会再弹重启卡片。
变动详情面板
- 差异来源:本次变动前后的
package.json、cordis.yml、cordis.patch.yml、pnpm-workspace.yaml 快照;cordis 层只保留 id / name 条目行,不贴 config。
- 行级 diff 为 LCS 实现,改动行上下各留 2 行上下文,其余折成「… 跳过 N 行」,单文件上限 400 行。
- 结构化摘要:依赖版本变化(
a 1.0.0 → 1.1.0)、dsh.profile.bundles 增删、node_modules 里新增 / 移除的包。
pnpm-lock.yaml 体积大,只标注「依赖锁已变化」,不做行级对比。
- 快照只在变动稳定后采集,不增加 1s 轮询的开销;内容不落盘。
安装
dsh plugin --profile desktop add dsh-plugin-restart-prompt
装好后重启 DSH 一次,插件开始工作;此后每次插件变动都由它提示重启。
本地开发(把源码目录 link 进去,改完即生效):
cd ~/.dsh/profiles/desktop
# package.json: dependencies 增加 "dsh-plugin-restart-prompt": "link:/path/to/dsh-plugin-restart-prompt"
# dsh.profile.bundles 末尾增加 "dsh-plugin-restart-prompt"
pnpm install
接口
客户端注入走两条通道:桌面端 webserver/index-inject 内联行、Web 形态 webServer.tapIndex。
隐私
只读 profile 目录下 4 个小配置文件的文本与 node_modules 的目录名,用于本地差异展示;不读取会话内容,不上传任何数据,不发起外部网络请求。
冒烟
node smoke.mjs # 路由 / 注入行 / 变动监听 / 本机栅栏;不会真的重启
node smoke-changes.mjs # 差异计算(构造快照)+ 真实 profile 快照采集
English
Prompts you to restart DSH after a plugin change, then restarts it in one click — silently, with no console window — and can show you exactly what changed.
Windows only: the restart path is VBScript + WMI Win32_Process.Create + taskkill, so it needs wscript.exe and System32\taskkill.exe.
What it does
- Watches the profile's plugin manifest and dependency tree (
package.json, pnpm-lock.yaml, cordis*.yml, node_modules). Once a change settles, a card appears in the bottom-right corner.
- View changes opens a panel with a per-file line diff, dependency version moves, additions to
dsh.profile.bundles, and packages added to node_modules. pnpm-lock.yaml is reported as changed rather than diffed.
- Restart DSH dispatches the restart. If any agent is running, it first asks for confirmation — the Yes button is red-highlighted, because work in progress will be interrupted.
- Later hides the card; the next change prompts again.
Why it is built this way
wscript.exe is a GUI-subsystem binary, so unlike powershell.exe or cmd.exe it never flashes a console. The actual kill-and-relaunch runs under WMI rather than as a detached child, because the desktop shell puts its children in a Job Object — a detached child would die together with the host it is supposed to replace. Everything uses absolute paths, since PATH may contain neither pwsh nor powershell, and a failed spawn only raises an async error that try/catch never sees. Failures surface as a red message with a retry button and are appended to $DSH_HOME/dsh-plugin-restart/relaunch.log.
Privacy: reads four small config files in the profile plus the names of installed modules, for local display only. No session content, no network calls, nothing uploaded.