dsh-plugin-guard 使用指南
DeepSeek Harness 的安装安全网:安装前自动快照、启动失败自动回退、不兼容插件自动隔离并生成事故报告自动触发 Agent 分析。
本文为派生内容(基于 wiki / faq / compatibility_json 自动组装),非 AI 即时创作。
本文由本站基于该插件已收录的字段自动派生(wiki / faq / compatibility_json / readme),非 AI 即时创作。每节末尾标源字段。
快速上手
dsh-plugin-guard
— 源: plugin_wiki.wiki_content
安装与验证
dsh plugin --profile web add github:lxzy-7/dsh-plugin-guard
复制以上命令在 DSH Web Profile 内运行。安装完成后在「插件列表」启用即可。
— 源: plugins.install
关键要点
keepSnapshots— how many snapshots each profile retains (clamped to 2–100, default 10). Pruning removes older ones.port— web port used by health checks / incident reports (default 3080). Set it if yourdsh webruns on another port. You can also pass--portto the CLI.- Rollback = restore the 4 config files +
pnpm install --frozen-lockfileto reproducenode_modulesexactly. - Every rollback first writes a
pre-rollbacksnapshot, so rollback itself is reversible. - "Last good" = the newest snapshot not tagged
pre-boot/pre-rollback.
— 源: plugin_wiki.readme_zh (fallback readme_raw)
常见问题
安装后需要做什么才能让守护启动生效?
需要把启动命令改为运行包内的 boot-guard 脚本(Windows 用 boot-guard.ps1,macOS/Linux 用 boot-guard.sh),而不是直接运行 dsh web。插件安装本身通过 settings.service 注册 HTTP 路由,但启动级检测由守护脚本完成。
守护启动脚本做了什么?普通插件安装和它有什么关系?
守护启动脚本在启动 dsh web 前对所有 profile 做一次快照(tag=pre-boot),启动后用 HTTP / 做健康检查;若启动失败,kill 进程树、回退到最近良好快照、重试一次;两次都失败则从启动日志诊断问题插件并隔离(写入 disabled: true),确保应用至少能起来。普通 plugin_install 工具会在安装前自动快照作为第二道防线。
应用起不来了还能用这个插件吗?
能。包内的 dsh-guard CLI(scripts/guard-cli.js)和 Windows 下的 rollback.cmd 都是独立 Node/PowerShell 脚本,不依赖 dsh web 进程。即便 dsh web 完全起不来,也可以手动执行 dsh-guard snapshot / list / rollback / incident 等命令。
回滚操作会不会把数据也弄丢?
不会。回滚只还原 4 个配置文件(package.json、pnpm-lock.yaml、pnpm-workspace.yaml、cordis.yml、cordis.patch.yml),然后重跑 pnpm install --frozen-lockfile 复原 node_modules;MCP 服务器配置也包含在 cordis.yml 里一起被还原。回退前会自动先存一份 pre-rollback 快照,所以回退本身也可逆。
它会"评判"一个插件好坏吗?会不会拦截安装?
不会。插件从不拦截或拒绝任何 plugin_install / plugin_uninstall / plugin_toggle 调用——它只做副作用(先快照)。如果快照失败,错误会被吞掉,安装依然继续。它保证的是"任何变更都可逆 + 启动失败自动回退 + 事故自动分析",而不是"插件是否合格"。
配置文件存在哪里?需要手动创建吗?
在 $DSH_HOME/guard/config.json(DSH_HOME 默认为 ~/.dsh),首次写入时自动创建,全部可选。snapshot 数据本身存在 $DSH_HOME/rollbacks/
我改了 dsh web 端口(不是默认 3080)会怎样?
健康检查会失败。两种办法:编辑 $DSH_HOME/guard/config.json 把 port 改成实际端口;或者 dsh-guard health --port <实际端口>、dsh-guard incident --port <实际端口> 临时覆盖。设置范围 1-65535。
为什么删 bundle 插件要重启 dsh web 才生效?
因为 bundle 插件是 dsh web 启动时一次性加载到 profile 层栈的,运行期改 cordis.patch.yml 不影响已加载的实例。这是 DSH 本身的限制,不是这个插件的限制。
— 源: plugin_wiki.faq_json
兼容性
- DSH: rc.7+(推荐;旧版缺少 settings surface 会回退为纯 config.json 路径)
- Node: >=18
— 源: plugin_wiki.compatibility_json
踩坑提醒
安装前请审阅上游仓库;本指南基于已收录字段自动派生,可能滞后于最新版本。如发现与官方文档冲突,请以上游为准。
— 来源:通用规则