dsh-dev-hotreload
DiscoveredDeepSeek Harness's local development hot-reload bridge: monitors the source code of link-installed plugins/presets, and on every save triggers a recombination of the official profile, hot-replacing the running host directly without needing a restart.
dsh-dev-hotreload
给 DeepSeek Harness(DSH)用的保存即热重载桥:你在本地开发的插件/预设源码一保存,正在运行的宿主就把那个包热替换掉,不用重启。
它解决什么问题
DSH 自带 @deepseek-ai/dsh-hmr,但它对本地链接包的模块监听是失效的:
link:/file:安装的包,模块在 ESM 缓存里的键是<profile>/node_modules/<pkg>/...这个 symlink 路径;- 而 HMR 的模块监听 dispatch 先用
realpath得到真实路径再去比对缓存,esmHas(url)恒为false; - 结果就是:改源码只 emit 一个
hmr/change事件,永远不会真正重载(这是 dsh-hmr 0.2.1-rc.3 实测结论)。
真正有效的官方路径是 profile 重新组合(reconciliation):profile 的 cordis.patch.yml / package.json 一变,dsh-hmr 就比对已加载模块的文件身份(mtime + size),把发生变化的插件停掉、清 ESM 缓存、重新 import。官方文档也明说「linked 包在下次重组合时生效」。
所以本插件的做法很轻:监视你的本地源码目录,保存后轻触 profile 的 cordis.patch.yml,触发官方那套重组合。
保存源码 → 防抖(400ms) → 改写 cordis.patch.yml 的 tick 注释
→ dsh-hmr 的配置监视 → profile 重组合
→ 插件热替换(工具 schema 同步更新)→ client-hmr 推送前端
安装
# 从打包好的 tgz(分发用;pnpm pack 的产物)
dsh plugin --profile <profile> add /absolute/path/to/dsh-dev-hotreload-1.0.0.tgz
# 从本地目录链接(想改源码立刻自举生效时最常用)
dsh plugin --profile <profile> add link:/absolute/path/to/dsh-dev-hotreload
# 从 GitHub
dsh plugin --profile <profile> add github:Pxczxn/dsh-dev-hotreload
打包自己分发:
pnpm pack --pack-destination ./dist
包自带 bundle 层(dsh.bundle.patch),安装后行 dev-hotreload 会自动进组合,零配置即可工作。
零配置时它怎么找到东西
| 需要的东西 | 自动发现方式 |
|---|---|
| profile 目录 | profileContext.dir → ctx.baseUrl → 宿主进程参数里的绝对路径 → $DSH_HOME/profiles/desktop,取第一个"像 profile"的目录 |
| 要监视的源码目录 | 读该 profile 的 package.json,取 link: / file: 依赖的真实目录;再加 node_modules 顶层(含 @scope/pkg)所有 symlink 的真实目录 |
| 要轻触的 patch 文件 | <profile>/cordis.patch.yml |
| 日志 | os.tmpdir()/dsh-dev-hotreload.log |
node_modules、.git、dist、build、out、coverage、cache 等目录里的写入会被忽略。
配置(可选)
在 profile 的 cordis.patch.yml 里用同 id 覆盖,config 是整体替换,没写的字段用默认值:
- id: dev-hotreload
config:
dirs: # 额外监视的目录(自动发现之外)
- 'D:\Coding\project\dsh\plugins\my-plugin'
autoDiscover: true # 默认 true:自动发现 link: 依赖
profile: 'D:\...\profiles\desktop' # 默认自动定位
patch: 'D:\...\profiles\desktop\cordis.patch.yml' # 默认 <profile>/cordis.patch.yml
log: 'D:\Coding\tmp\dev-hotreload.log' # 默认 tmpdir 下;false 关闭
debounce: 400 # 毫秒
只想监视指定目录、不要自动发现:
- id: dev-hotreload
config:
autoDiscover: false
dirs:
- 'D:\repo\my-plugin'
验证它真的在工作
- 编辑任意 linked 包里被
import到的文件(比如src/tools.js); - 看日志:
Get-Content "$env:TEMP\dsh-dev-hotreload.log" -Tail 20,应出现change: src/...和ticked cordis.patch.yml; - 宿主里立刻能用到改后的行为(比如工具输出变了),说明插件已热替换。
须知 / 限制
- 它依赖
@deepseek-ai/dsh-hmr的配置监视能力。若你在 profile 里把hmr行disabled: true,本插件就无效了。config.root不需要为本插件设置(模块监听对 linked 包无效,root: []即可)。 - 保存后有一次重组合,性能开销与"改配置"同级;
debounce可调。 - 重组合失败时 dsh-hmr 不会回滚到旧版本 —— 改坏代码会看到插件
failed,修好再保存即可恢复。 - 只对会重新执行
apply的宿主侧代码生效;纯 client(浏览器侧)bundle 的更新由 client-hmr 负责,视插件是否声明dsh.client而定。
开发
node --test test/index.test.js
License
MIT
Comments
Loading…
Similar plugins
by kuroshio4396
DeepSeek Harness 桌面版插件:不关程序热重载插件与界面(类似 Ctrl+F5),或彻底结束程序并由独立重启器立即拉起。
★ 3
MIT
JavaScript
Oct 20, 2026
dsh plugin --profile web add dsh-reloaderby lixiaohao001
DSH 插件:装完即可用、无需重启——检查已安装组合、就地完成激活并热重载插件模块 | Post-install plugin activation and in-place hot refresh for DeepSeek Harness
★ 0
MIT
JavaScript
Oct 11, 2026
dsh plugin --profile web add dsh_plugin_refreshby 5102a
Hot-toggle any installed plugin in DeepSeek Harness from the Web settings — instant apply, no restart, persisted. 在 DSH 设置页一键热启用/停用任意插件,立即生效、无需重启、状态持久化。
★ 0
↓ 126/wk
MIT
JavaScript
Aug 16, 2026
dsh plugin --profile web add dsh-plugin-hot-toggleHot-reload a DeepSeek Harness agent preset: rebuild its revision and rebind running sessions, without restarting dsh.
★ 0
dsh plugin --profile web add dsh-preset-reloadby xiaolu511
DSH 热重启插件:窗口内一个固定按钮,一键关闭并自动重开 DeepSeek Harness,全程零控制台窗口;内置自检系统,出问题点一下就能生成可直接定位的诊断报告 · Hot-restart plugin for DSH, with a built-in self-check that writes a one-file diagnostic report
★ 7
↓ 216/wk
MIT
JavaScript
Oct 13, 2026
dsh plugin --profile web add dsh-hot-restartby KYinCode
DeepSeek Harness (dsh) 插件热管理器:装一次、重启一次,之后装插件、卸插件、升级插件全部即时生效,不用再重启。 | A plugin that makes installing, removing and upgrading DeepSeek Harness (dsh) plugins take effect instantly — restart once, then ne
★ 9
↓ 102/wk
MIT
JavaScript
Sep 22, 2026
dsh plugin --profile web add dsh-hot-installer