dsh-hooks
Config-driven lifecycle hooks plugin for DeepSeek Harness: declare event -> command hooks in cordis.patch.yml, no plugin code required.
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:PeterBon/dsh-hooks说明文档
阅读完整 README ↗dsh-hooks
DeepSeek Harness(dsh)的配置驱动生命周期 hooks 插件。
直接在 profile 的 cordis.patch.yml 里声明「事件 → 命令」——就像 Codex CLI / OpenCode 的 hooks,但属于 dsh。不需要写插件代码。
安装
dsh plugin --profile web add dsh-hooks # 从 npm 安装
# 或直接从 git 安装:
dsh plugin --profile web add github:PeterBon/dsh-hooks
重启 dsh web 生效。
配置
在你的 profile 的 cordis.patch.yml 里添加配置块:
- id: dsh-hooks
name: dsh-hooks
config:
hooks:
- on: 'turn/end'
when: 'completed' # 可选:只在回合正常完成时触发
run: 'node examples/notify-feishu.mjs'
timeoutMs: 10000 # 可选,默认 10000
- on: 'approval/asked'
run: 'powershell -Command "Add-Content hooks.log approval-requested"'
事件(v1)
| 事件 | 触发时机 | 有用上下文 |
|---|---|---|
turn/start | 回合开始 | 会话 id、回合号 |
turn/end | 回合结束(completed / error / aborted / blocked / max-tokens / interrupted) | reason、回合号、耗时 |
approval/asked | 工具调用请求用户审批 | 工具名、调用 id、原因 |
agent/created | Agent 发布 | 会话 id |
agent/disposed | Agent 离开注册表 | 会话 id |
agent/error | Agent 循环报错 | 错误文本 |
agent/status | Agent 状态切换 | 状态 |
turn/end 的 when 匹配结束原因(completed、error…);其他事件的 hook 无条件执行。
命令执行
- 每个命中的 hook 通过系统 shell 执行
run,fire-and-forget:失败只console.warn,绝不重试、绝不阻塞 agent 循环。