bowenliang123/dsh-context
bowenliang123/dsh-contextDSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
自动检测最新DeepSeek Harness版本, 显示当前版本号, 并提供一键升级按钮。
dsh plugin add 安装后立即热加载生效,无需重启 dsh。npm install -g 安装最新版;
安装完成后按钮文字变为「重启」。dsh web --no-open 重启,日志追加写入 ~/dsh.log(Windows 写 %USERPROFILE%\dsh.log)。从 npm 安装:
dsh plugin --profile web add @just-ai/dsh-auto-update
从本地安装(从仓库根目录执行):
dsh plugin --profile web add ./plugins/dsh-auto-update
本插件要求 dsh >= 0.2.0-rc.2。该要求在 package.json 的 engines.dsh 中声明:
"engines": {
"node": ">=18",
"dsh": ">=0.2.0-rc.2"
}
这几个细节是刻意的:
engines.dsh 而不是 peerDependencies。 dsh-market 判定主机兼容性时会同时读
engines.dsh(也接受 dsh.engines.dsh 写法,两者都存在时顶层优先)和所有匹配
@deepseek-ai/dsh* 的 peerDependencies,多个声明之间取交集。本插件不在代码里 import
任何 @deepseek-ai/* 包——Host 半边零 import,Client 半边只 require("react")——
因此没有需要声明 peer 的包;@deepseek-ai/dsh 在 index.js 里只是被 npm view /
npm install -g 用到的字符串常量。改用 engines.dsh 还有一个好处:npm 只检查
engines.node 与 engines.npm,忽略自定义键,所以它既不会触发 peer 自动安装,
也不会有预发布版本引起的 ERESOLVE。engines.dsh 时采用 includePrerelease 语义,
故 >=0.2.0-rc.2 同时匹配 0.2.0-rc.2、0.2.1-rc.1、0.3.0-rc.1 等后续预发布版本,
同时排除 0.1.7-rc.2 与 0.2.0-rc.1。latest manifest,不是 GitHub
仓库,所以改完必须发布新版本(推 v* tag 触发 .github/workflows/publish.yml)才会在
市场详情页显示。收录条目本身(
data/plugins/<owner>__<repo>.yml)没有版本字段,兼容性声明只存在于 插件自己的package.json中。
dsh-auto-update/
├── package.json # 声明 dsh.bundle.patch + dsh.client + engines.dsh
├── cordis.patch.yml # 挂载条目(insert:id + 包名)
├── index.js # Host 半边:ESM 模块,export { name, inject, apply }
└── client.js # Client 半边:浏览器 bundle(window.__ModuleLoader__.load)
本插件为纯手写 JS、无构建步骤,故入口按官方 bundle 最简范式直接放在包根目录 (对照打包与安装插件 的
hello-plugin示例)。lib/在 dsh 约定中指由src/构建出的产物目录,此处不适用。
dsh --version 读取当前版本;npm view @deepseek-ai/dsh time --json
读取 npm 上所有版本的发布时间,取其中发布时间最近的版本作为「最新版」(跨通道,不区分
latest / next / alpha)。加载时执行一次,之后 ctx.interval 每 30 分钟一次。
命令执行走 shell 接缝:dsh ≥ 0.2 用 ctx.shell.resolve() → ctx.shell.execute() →
execution.result();更早的 dsh 用已被移除的 ctx.shell.run() 兜底(同一份代码兼容两者)。ctx.webServer.register 注册 /dsh-auto-update/api 路由
(POST {method} → JSON),Client 通过 fetch() 调用,方法为 getStatus / installUpdate / restart。installUpdate 执行 npm install -g @deepseek-ai/dsh@<最新版确切版本号>(安装的就是
检测到的那个发布时间最近的版本,而非某个 dist-tag)。restart 先用 node -p process.platform 检测操作系统,再按平台选择脚本——
Linux 用 setsid + nohup + &、macOS 用 nohup + &(无 setsid)、Windows 用 PowerShell
(Get-NetTCPConnection 结束监听进程 + Start-Process 拉起新进程),均以脱离父进程的方式后台运行,
确保父进程(当前 dsh web)被杀死后脚本仍能继续启动新进程。shell(bash 后端)、timer、webServer 服务;Client 侧依赖 slots、timer 服务。lsof(或 fuser)/setsid/nohup;macOS 依赖 lsof/nohup;
Windows 依赖 PowerShell(Get-NetTCPConnection/Stop-Process/Start-Process,需 PowerShell 4+)。settings.trigger 插槽(即「设置」按钮的内容区),侧边栏折叠为窄栏时只显示齿轮图标。0.1.5-alpha.2 虽是 alpha tag
指向的版本,但若 0.1.5-rc.2 发布时间更晚,则后者才是「真正的最新版」,检测与安装都取它。
检测到的版本就是会被安装的版本:npm install -g @deepseek-ai/dsh@<该确切版本号>。