DeepSeek Harness 自动更新插件 dsh-auto-update

前言

DeepSeek Harness (DSH) 的核心设计理念是「一切皆插件」。目前的官方 CLI 并没有内置 self-update 能力。社区现有的更新检查插件,通常只能完成「检测」这一步,后续仍需用户手动操作。dsh-auto-update 插件补全了这一环,它能在宿主端启动时自动对比版本,并按配置决定是仅提醒还是直接执行安装。

它是什么

这是一个运行在宿主端的插件,由 frostming 维护,开源协议为 MIT。

核心功能

  1. 启动时检查一次:利用 ctx.effect 注册 setTimeout,启动几秒后自动检查一次,之后不再重复检查。
  2. 正确的 semver 比较:能正确处理预发布版本,例如 0.1.0-rc.5 与 0.1.0-rc.6 的对比。
  3. 两种模式:
    • notify(默认):只在控制台打印醒目的横幅,不安装。
    • install:自动执行安装命令。
  4. 状态持久化:检查结果写入 ~/.dsh/dsh-auto-update-state.json,保留最近 10 次历史。
  5. Profile 无关:不依赖 webServer,所有 profile(如 web、headless、tui)均可用。
  6. 优雅卸载:通过 ctx.effect 管理,卸载时自动清理定时器。
  7. 零运行时依赖:仅使用 Node 内置模块。

安装

使用以下命令将插件添加到当前 profile:

dsh plugin --profile web add github:frostming/dsh-auto-update

安装后重启 dsh web 生效。默认情况下,插件只提醒不安装,控制台会打印类似以下的横幅:

════════════════════════════════════════════════════════
  dsh-auto-update: update available
    installed: 0.1.0-rc.5
    available: 0.1.0-rc.6 (latest)
    action:    notify only — run npm install -g @deepseek-ai/dsh@0.1.0-rc.6
════════════════════════════════════════════════════════

开启自动安装

要启用自动安装,需编辑 profile 的 cordis.patch.yml 文件(路径通常为 $DSH_HOME/profiles/<name>/cordis.patch.yml),覆盖 mode 为 install:

- insert:
    - id: dsh-auto-update
      name: 'dsh-auto-update'
      config:
        mode: install
        # 可选:自定义安装命令,{version} / {package} 会被替换
        installCommand: 'npm install -g {package}@{version}'

配置项

键 默认值 说明
channels ["latest", "next"] 按优先级咨询的 dist-tag
startupDelayMs 5000 启动后检查的延迟,毫秒
mode "notify" "notify" 或 "install"
installCommand npm install -g {package}@{version} 安装命令模板
stateFile ~/.dsh/dsh-auto-update-state.json 状态文件路径
verbose true 是否打印检查日志

注意事项

  • DeepSeek Harness 目前处于 developer preview 阶段,官方明确声明会有破坏性兼容变更。
  • 自动安装等于接受这种风险,请谨慎开启。
  • 插件以当前 dsh 进程权限运行,安装前应检查源码与许可证。
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜