Preface¶
When writing plugins in DeepSeek Harness (DSH), the common loop is: change a line of logic, restart the host, wait for the process to come up, then manually reproduce the scenario. The host side ships with @deepseek-ai/dsh-hmr, but third-party plugins installed by the profile actually land under the path ~/.dsh/profiles/<profile>/node_modules/<package-name>/. The built-in HMR has two hardcoded exclusions for node_modules, and its watch roots are mostly empty. Changes to lib/*.js often don’t make it into the reload queue, so you can only restart.
dsh-hot-reloader is published by community maintainer xfgil, categorized as workflow, aimed at plugin developers: about one second after saving source code, it hot-reloads that plugin in place within the running host, without needing to restart DSH. It fills the gap left by built-in HMR for third-party plugin scenarios; the Web client side has its own independent HMR, while this plugin targets the server-side code on the host side.
What is this¶
dsh-hot-reloader is a DSH plugin with zero external dependencies (only uses Node built-ins node:fs, node:path, node:url, node:module). It traverses the package roots of installed plugins, polls to detect source changes, clears the cache, and rebuilds the Cordis fiber with the original configuration.
Maintainer: xfgil. License: MIT (see repository). Current package version is 0.1.0; the README states it has been tested on DSH 0.2.0-rc.2.
Why built-in HMR doesn’t handle profile plugins¶
The chain can be summarized as:
- Even if a file change reaches built-in HMR, when the module URL contains
/node_modules/,loadDependencies()andanalyzeChanges()skip it directly. - When the dependency set is empty, the reload queue decision is always
continue, so the plugin never enters the reload. - Built-in HMR has
root: []in the base composition, mainly targeting profile configuration and host modules; excludingnode_modulesis a conservative design, not an “official bug fix” that this plugin is trying to replace.
This plugin reimplements the watch and reload chain, does not exclude node_modules, and tries to reuse the built-in HMR’s _resolve() and runExclusive() transactions to avoid colliding with built-in HMR; when hmr cannot be obtained, it falls back to a self-implemented path.
Environment requirements and prerequisites¶
| Item | Description |
|---|---|
| DSH | 0.2.0-rc.2 (tested in README) |
| Node (plugin engines) | >=22 |
| Host startup | Must carry --expose-internals; the DSH desktop host process carries it by default, otherwise the plugin constructor will throw |
| Installation location | Installed on the profile side, the directory should ideally be outside the profile’s node_modules, or use link: installation |
Built-in @deepseek-ai/dsh-hmr |
Optional but recommended to be enabled together; this plugin works with it |
No additional ports are needed, it goes through the host’s webServer. After installing this plugin, you also don’t need to restart DSH for it to take effect (profile manifest reconcile).
Installation¶
During development, use link to point to the local directory (replace the path with your absolute path):
dsh plugin --profile <your profile> add link:<absolute path to this directory>
Example:
dsh plugin --profile desktop add link:D:/path/to/plugins/dsh-hot-reloader
If using the released version, install from npm:
dsh plugin --profile <your profile> add dsh-hot-reloader
After installation, the profile manifest will update, and once the host built-in HMR reconciles, this plugin will work.
Typical usage¶
Default behavior: No extra action needed after installation. Modify any installed plugin’s lib/*.js (and other .js/.mjs/.cjs/.json files scanned within the package), and it will automatically hot reload in about one second. Logs are printed to the host logs; you can also view and control it via the HTTP interface.
The default port example is 19387 (based on your local host):
# View status
curl http://127.0.0.1:19387/dsh-hot-reloader
# Only reload the specified package
curl -X POST http://127.0.0.1:19387/dsh-hot-reloader/reload \
-H 'content-type: application/json' \
-d '["dsh-onebot-qq"]'
# Reload all
curl -X POST http://127.0.0.1:19387/dsh-hot-reloader/reload
# Pause / resume auto reload
curl -X POST http://127.0.0.1:19387/dsh-hot-reloader/toggle
| Method | Path | Purpose |
|---|---|---|
| GET | /dsh-hot-reloader |
Full status including watched packages, scan statistics, recent logs |
| POST | /dsh-hot-reloader/reload |
Manual reload; empty body for all, or ["package-name"] / {"packages":["package-name"]} |
| POST | /dsh-hot-reloader/toggle |
Pause or resume auto reload |
| POST | /dsh-hot-reloader/self-reload |
Reload this plugin itself (when developing this plugin) |
Configuration¶
Override the plugin item in the profile’s cordis.patch.yml, e.g.:
- id: dsh-hot-reloader
config:
intervalMs: 1000 # Polling interval (milliseconds)
debounceMs: 400 # Wait for writes to stabilize after changes
reloadSelf: false # Whether to auto reload this plugin itself
only: [] # Only watch these package names (empty = all)
except: [] # Skipped package names
extraRoots: [] # Additional absolute paths to watch
includeAsar: false # Whether to watch host packages inside app.asar
ignore: ['.bak', '.test.', '.spec.', '.map']
maxDepth: 8
quiet: false # Silent: only record failures
installQuietMs: 8000 # Yield duration after detecting package management operations; 0 disables
profileDir: '' # Default derived from the loader tree
To only focus on the package being developed, or to temporarily reduce frequency / go silent during large refactors, adjust only, quiet, intervalMs, etc. according to the README examples.
How it works (overview)¶
- Locate package root: resolve URL from the loader entry, find
package.jsonupward. - Polling comparison: scan JS/JSON within the package, compare
mtimeMsandsize(chokidar etc. usually cannot be resolved in the profile’snode_modules, so polling is used). - Debounce: wait for
debounceMsto avoid the editor’s intermediate write states. - Clear cache: clear the package’s entries in the Node ESM LoadCache and CJS
require.cache, without cascading cleanup of nested third-party dependencies within the package. - Rebuild: re-import the entry, unload the old plugin instance, rebuild with the original config; on failure, roll back entirely to avoid half-dead states.
Multiple entries under the same package root will be remounted together; by default it doesn’t touch host packages inside app.asar.
Applicable scenarios and notes¶
Suitable for: Developers who frequently modify the host-side code of DSH third-party plugins, wanting to compress “change → restart → reproduce” into “change → see the result”.
Limitations (as explained in the README):
- Reloading will lose the memory state held by the plugin (connections, caches, timers, etc.); long-connection type plugins may experience brief interruptions at the moment of reload.
- Depends on the host’s
--expose-internalsand Node loader internal structures; it is a development-oriented capability. - The plugin runs with the permissions of the current DSH process; before installation you should review the GitHub source and MIT license yourself, and do not install arbitrary plugins from untrusted sources.
The DSH community plugin directory is an independent site, the SkillHub plugin page, with no official affiliation with DeepSeek / High-Flyer (幻方).
Links¶
- Directory page: https://www.skillhub.cn/plugins/xfgil/dsh-hot-reloader
- Repository: https://github.com/xfgil/dsh-hot-reloader