keyiadiannao/dsh-restart-button ↗★ 0
dsh-restart-button
Self-contained power control for DSH: sidebar power button with an upward 重启/关机 menu plus a Windows-shutdown-style overlay. Own restart & shutdown engine (no dependency on other plugins), MIT licensed.
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:keyiadiannao/dsh-restart-button说明文档
阅读完整 README ↗dsh-restart-button
DeepSeek Harness 的自包含电源控制插件:侧边栏底部电源按钮 + 上拉重启/关机菜单 + 全屏过渡动画。重启/关机引擎内置在本插件中,不依赖其它插件。
由 DeepSeek AI 辅助开发,发布前经人工 review。
功能
- 电源按钮:注册到侧边栏底部(
sidebar.footer.action),外观与旁边的"设置"按钮一致(34px 行高,主题变量,跟随深浅色) - 上拉菜单:「重启」「关机」两项,点外部或 Esc 关闭
- 重启:写
.cjshelper →nodedetached 启动(无控制台窗口)→ 等端口释放 → 用相同 execPath/execArgv/argv/cwd 重新拉起 DSH → 响应刷出后终止旧进程 - 关机:终止进程,不再拉起
- 过渡动画:Windows 关机风格遮罩 + 环形进度 + 阶段文字;重启后自动刷新
restart_harness模型工具:与anweat/dsh-restart同名,单独安装时由本插件提供;名字被占用则自动跳过
安装
dsh plugin --profile web add "github:keyiadiannao/dsh-restart-button#master"
重启 DSH 后生效:侧边栏底部出现电源按钮。需要 Node ≥ 22.19。
工作原理
点击电源 → 菜单 → 重启
[宿主] POST /api/dsh-restart-button/restart
→ 写 $USERPROFILE/.dsh/restart-helper-
-.cjs
→ spawn `node ` (detached, windowsHide)
[助手] 等旧 PID 退出 → 等端口释放 → 用相同 execPath/argv/cwd 重新拉起 DSH → 自删
[宿主] 响应刷出后终止
[客户端] 轮询 health → 确认新 instanceId → 自动刷新
关机则 POST /api/dsh-restart-button/shutdown,终止且不拉起。
开发中踩过的两个坑:
- helper 必须脱离进程树(detached + unref),否则杀 DSH 时 helper 一起死
- helper 写成真实 .cjs 文件而非
node -e:多行node -e脚本会被 Windows CreateProcess 破坏成静默 SyntaxError
安全
- 破坏性 POST 带 同源/loopback 防护(CSRF)
- at-most-once 锁:并发重复重启会被拒绝(第二次返回 409)
- 重启成功以每次进程独立的 instanceId 变化为准(旧→新),而非仅凭短暂离线