- Início
- Plugins
- Desenvolvimento e ferramentas de plugins
- dsh-lazy-mount (src)
dsh-lazy-mount (src)
slammingbang/dsh-lazy-mount/src
Defers chosen heavy plugins so they activate about five seconds after startup instead of blocking it, with a settings panel that shows each plugin's real wake-up cost and a whitelist for plugins that must never be deferred. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.
Instalar
dsh plugin --profile web add github:slammingbang/dsh-lazy-mountEste plugin está no subdiretório src do repositório.
README
dsh-lazy-mount
为 DeepSeek Harness(dsh)准备的插件懒加载管理器:把重型插件的加载推迟到窗口可用之后,并在设置面板里选择延迟哪些插件。
Defer heavy plugin activation until after the window is usable, with a settings page to pick which plugins.
先说清楚它能做什么、不能做什么
能做到:让指定的几个插件不在启动时加载,改为启动约 5 秒后唤醒。它们的功能不会丢,只是晚几秒就绪。
不能做到:让窗口更早出现。
原因是 dsh 桌面壳的显示顺序固定:
host 启动 → 全部插件 apply 完成 → host 发 ready → Electron 才 window.show()
窗口一定晚于所有插件加载完毕。所以本插件能把插件工作挪出启动期中间段,但无法改变窗口出现的时刻。
实测数据(21 个 bundle、7 个懒加载包):
| 场景 | 窗口可见 |
|---|---|
| 热启动(系统有缓存) | 6.5 ~ 10 s |
| 冷启动(整机重启后首次) | 49 ~ 54 s |
| 冷启动中,7 个懒加载包合计耗时 | 5.8 s |
冷启动那 49 秒里,大头是渲染进程冷解析约 10.8 MB 前端代码(33 秒),与本插件无关。
结论:收益取决于你的机器和插件组合。如果期望“装了快一倍”,那不是它。
适合什么场景
- 有一两个明显拖慢启动的重型插件,且它们不需要在窗口出来的瞬间就可用
- 能接受开机后约 5 秒内部分面板/能力尚未就绪
- 想有个统一的地方管理这些插件的加载
安装
dsh plugin install dsh-lazy-mount
或从源码:
git clone https://github.com/Slammingbang/dsh-lazy-mount.git
装好后打开 设置 → 懒加载,勾选要延迟的插件。
仓库结构
dsh-lazy-mount/
├── src/ 插件本体(Host 端 index.js、前端 client.js、locale、图标)
├── docs/ 已知问题、设计约束、启动耗时分析
├── tests/ 验证脚本与启动计时工具
└── backups/ 本地备份(不入库)
工作原理(给想看代码的人)
关键在于不能新建 loader 行。
dsh 的 configEditor.entries() 只认 parent.tree.ctx.fiber.entry.id === 'include' 的行。用 loader.create() 新建的行会落在 loader 根树,不算“profile 可配置行” → 该插件设置页拿到空命名空间 → 整页只读。
所以本插件的做法是:让 profile 原本那一行从禁用态启动。
# 写进 cordis.patch.yml 的管理块
- id: web-search-free
name: 'dsh-free-search'
disabled: !!js '!(typeof globalThis !== "undefined" && globalThis.__DSH_LAZY_MOUNT__ && globalThis.__DSH_LAZY_MOUNT__["web-search-free"] === true)'
冷启动时标记不存在 → 表达式为 true → 不加载。
到点唤醒时置 globalThis.__DSH_LAZY_MOUNT__[id] = true → 表达式转 false → 调 entry.refresh() 走正常激活路径 → 行仍是 profile 那一行,设置页可编辑。
三个容易踩的坑
-
管理块必须放在
cordis.patch.yml最前面。configEditor.edit()用findLastIndex找同 id 同 name 的行写config;块在末尾的话,用户配置会被写进块内,下次重写块就丢了。 -
disabled表达式必须走globalThis且带typeof保护。 裸标识符会抛ReferenceError,而 Cordis 把表达式抛错当作disabled—— 结果对但污染日志。 -
bundles 与 patch disabled 分工不同。 bundles 决定“插件市场/设置页认为是否启用”,patch 决定“启动时是否加载”。懒加载包必须留在 bundles 里,否则设置页立刻只读。
启动日志
按天写到 <profile>/.dsh-lazy-mount/logs/<日期>.jsonl,保留 7 天自动清理。每条记录含真实加载耗时与状态:
| 字段 | 含义 |
|---|---|
hostUptimeMsAtApply | 插件 apply 时 host 已运行多久 |
hostUptimeMsAtWakeDone | 全部唤醒完成时 host 已运行多久 |
hostPid | 本次 host 进程号(区分冷启动与热重载) |
loaderAtApply / loaderAtWakeDone | {total, active, pending} 加载行快照 |
每包 preActive | 唤醒前是否已有实例。false = 确实延迟了;true = 热重载/重复唤醒 |
不能懒加载的插件
| 包 | 原因 |
|---|---|
@deepseek-ai/* | dsh 官方核心包,启动必需 |
dsh-lazy-mount(本插件) | 否则无法管理自己 |
dshmarket | 插件管理器,关掉就没法管理插件 |
dsh-mnemon | 它的 bundle 用 JS 表达式读主行 disabled 状态,外部禁用会崩溃 |
已知限制
- 唤醒是串行的,一个包超时会阻塞后面的包
- 唤醒时机是固定延迟,不是“等其他行全部就绪”
- 只做延迟,不做“永久禁用”;永久禁用请走插件市场开关(但那样设置页会变只读)
更多文档
- CHANGELOG.md —— 版本更新记录
- docs/KnownIssues.md —— 已知问题、设计约束、启动耗时分析、白名单说明
License
MIT
Plugins relacionados
deepseek-harness
deepseek-ai/deepseek-harness
dsh-market
dsh-market/dsh-market
dsh-web (dsh-plugin-manager)
zhu1090093659/dsh-web
dsh-web
zhu1090093659/dsh-web