truelove-dreamer/dsh-plugin-hooks
DeepSeek Harness 插件:为 DSH 提供 Claude-Code 风格的生命周期钩子。配置在模型工具调用前后自动运行的 shell 命令(工具前/工具后),通过 stdin 传入 JSON 数据;工具前命令非零退出将阻止调用。
Project Overview项目介绍
dsh-plugin-hooks is a native plugin built exclusively for DeepSeek Harness (DSH) that brings Claude Code-style lifecycle hooks to the DSH platform. It was created to add hook functionality that was missing in DSH 0.1.0-rc.6, leveraging the official pre-execute and post-execute seams already reserved in DSH’s architecture. It supports two hook types: pre-tool hooks that run before matching tools are executed, and post-tool hooks that run after a tool finishes. If a pre-tool hook exits with a non-zero code, it blocks the corresponding tool call entirely, matching Claude Code’s behavior. This aligns with the design intent of the original Claude Code hook system.
Users install the plugin via the DSH CLI with the command dsh plugin --profile web add dsh-plugin-hooks, then add a mount entry in their DSH config to activate it. Hooks can be configured either via a JSON file (default path is $DSH_HOME/hooks.json) or as inline config in the DSH mount entry, and multiple configurations can be stacked together. After setup, users can list all configured hooks and the last 20 run logs with the /hooks command, or reload the config with /hooks-reload for hot updates without restarting DSH. It is targeted at DSH plugin developers and advanced users who want to customize their local development workflow.
The plugin integrates with DSH via Cordis waterfall events, and relies on the built-in ctx.shell service to run hook commands. If ctx.shell is not mounted, the plugin loads normally but hooks will not run, and a clear warning will be shown in the output of the /hooks command when DSH launches. Currently, it only supports tool lifecycle events; session-level events like Stop or SessionEnd are not supported yet because DSH has not exposed the required interfaces for those extensions. Hook commands run with full access to the host system, so the plugin should only be enabled on trusted DSH profiles.
这是一个专为DeepSeek Harness开发的原生插件,用于将Claude Code风格的生命周期钩子引入DSH,填补了DSH 0.1.0-rc.6缺少钩子能力的空白。它基于DSH架构预留的官方接口开发,支持pre-tool和post-tool两类钩子:pre-tool钩子在匹配工具执行前运行,非零退出码会阻止该工具调用,post-tool则在工具执行完后运行。
开发者可以通过JSON配置文件或内联挂载配置来定义钩子,配置支持指定钩子触发的工具范围、超时时间和启用状态。安装完成后,可通过DSH内置的/hooks命令查看已配置钩子和最近20次运行记录,用/hooks-reload命令热重载配置,无需重启DSH。该工具面向需要自定义DSH开发工作流的插件开发者和高级用户。
该插件遵循DSH的Cordis插件架构开发,依赖DSH内置的ctx.shell服务,如果该服务未挂载,插件会正常加载但钩子无法运行,启动时会在/hooks命令中给出提示。目前仅支持工具生命周期事件,会话类事件钩子暂不支持。钩子命令以受信任的主机配置运行,仅建议在可信配置文件中启用。
请帮我安装这个 DSH 插件。安装前先完成【兼容性检查 + 安全性检查】,检查通过再动手。
插件:dsh-plugin-hooks(truelove-dreamer/dsh-plugin-hooks)
仓库:https://github.com/truelove-dreamer/dsh-plugin-hooks
本站详情页:https://www.yhbd.top/plugins/truelove-dreamer-dsh-plugin-hooks/
本站登记:类型 plugin · 归类 原生 DSH 插件 · 许可证未声明 · ⭐ 2 · 最近提交 2026-08-14 · 主语言 JavaScript
按下面顺序执行,每步先把结论告诉我,再进入下一步:
【1 兼容性检查】
① 我这边:DSH 版本、Node 版本、操作系统、当前 profile(web / desktop)。
② 读它的 README、package.json、插件 manifest,列出它要求的 DSH 版本 / Node 版本 / 操作系统 / 外部依赖 / 需要另外先装的运行时。
③ 逐条比对,结论只写「满足 / 不满足 / 未知」三种;不满足的给出可行替代方案。
④ 检查是否和我已装的插件冲突:命令名重复、skill / tool 重名、端口占用、重复注册的 MCP server。
【2 安全性检查】
① 仓库可信度:和上面「本站登记」是否一致;star / fork 数、创建时间、最近提交,是否归档或长期停更。
② 安装脚本:逐行看 package.json 的 preinstall / install / postinstall,以及 install.sh、setup.ps1 之类脚本。出现 curl|bash、下载后直接执行、混淆代码、访问与插件功能无关的域名,立刻停下来告诉我,不要继续装。
③ 依赖:列出新增依赖,标出无人维护、或与知名包拼写近似的可疑包(typosquatting)。
④ 权限与副作用:它会读写哪些目录、访问哪些域名、需要哪些 DSH 权限(filesystem / network / shell / clipboard 等),以及怎么卸载和回滚。
⑤ 如果它要求 sudo / 管理员权限,或权限明显超出功能所需,先停下来问我。
【3 安装】
上面两步没有「不满足」和「高危项」时才执行;用官方推荐方式安装,不要自行提权。
【4 汇报】
用表格输出:检查项 / 结论 / 依据 / 是否需要我决策。拿不准的一律写「未知」并说明要我怎么确认——不要猜,也不要替我决定。
Send this message to DSH in your current session: it verifies compatibility and security first (answering met / not met / unknown item by item) and only installs once everything checks out — it will stop and ask you if it finds a high-risk item. The box scrolls; the copy is the full prompt. CLI install commands may not be accurate across systems, so DSH is the safer route.把上面这条消息直接发给当前会话里的 DSH:它会先核对兼容性与安全性(逐条给「满足 / 不满足 / 未知」),确认没问题再安装,有高危项会停下来问你。框内可滚动,复制到的是完整提示词;安装命令不一定准确,发给 DSH 更稳。
- No license declared - all rights reserved by default; ask the author before commercial use or redistribution未声明开源许可证 —— 默认「保留所有权利」,商用或再分发前先问作者
- Only 2 stars - very few users, little community feedback星标只有 2,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项
Compatibility兼容性
- DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
- External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
- Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册
Security安全性
- Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
- Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
- curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
- Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
- Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
- Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式
Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。
Or use CLI install (for developers)或使用命令行安装(适合开发者)
CLI Install命令行安装
dsh plugin --profile web add dsh-plugin-hooks
把 truelove-dreamer/dsh-plugin-hooks 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-plugin-hooks
DeepSeek Harness 插件:把 Claude Code 风格的 lifecycle hooks 带到 DSH —— 配置驱动的 shell 命令,在模型工具调用前后自动执行。
背景
DSH 0.1.0-rc.6 没有 hooks 能力,但架构已经预留了接缝:tools/pre-execute / tools/post-execute 两个有序 waterfall,以及 shell 服务"通过 stdin 给命令喂 JSON payload"的词汇表(见 @deepseek-ai/dsh-shell)。这个插件以纯外部插件形式补上这块空白,设计对齐官方预留接口:
pre-toolhook:匹配的工具执行前运行;命令非零退出 → 阻止该工具调用(等价 Claude Code PreToolUse 返回 error);post-toolhook:工具结果落地后运行;退出码只记录,不改变工具结果。
配置
JSON 配置,来源二选一或叠加:
- 文件(默认
$DSH_HOME/hooks.json):
{
"hooks": [
{
"id": "lint-after-edit",
"event": "post-tool",
"tools": ["edit", "write"],
"command": "npm run lint -- --quiet",
"timeoutMs": 30000
},
{
"id": "guard-prod",
"event": "pre-tool",
"tools": ["bash", "pwsh"],
"command": "node guard.js"
}
]
}
- 内联(挂载 config,追加在文件 hooks 之后):
- id: hooks
name: dsh-plugin-hooks
config:
configFile: C:/path/to/hooks.json # 可选
hooks:
- id: always-deny-db
event: pre-tool
tools: [bash]
command: "node deny-db.js"
字段:id(必填、唯一)、event(pre-tool | post-tool)、tools(可选,默认全部)、command(必填)、timeoutMs(可选)、enabled(默认 true)。
安装
dsh plugin --profile web add dsh-plugin-hooks
挂载:
- insert:
- id: hooks
name: dsh-plugin-hooks
Hook 命令收到的数据
命令通过 stdin 收到一行 JSON payload:
{ "event": "PostToolUse", "hookId": "lint-after-edit", "toolName": "edit",
"args": { "path": "a.js" }, "sessionId": "s_xxx", "cwd": "C:/repo",
"result": { "isError": false, "exitCode": 0, "error": null }, "durationMs": 123 }
环境变量:CLAUDE_PROJECT_DIR(会话 cwd)、DSH_HOOK_EVENT、DSH_HOOK_ID、DSH_SESSION_ID。pre-tool payload 无 result/durationMs 字段。
命令
/hooks— 列出已配置 hooks + 最近 20 次运行记录(含退出码/错误摘要)/hooks-reload— 重新读配置文件,热加载,无需重启
设计说明
- 通过
ctx.on("tools/pre-execute"|"tools/post-execute")接入 Cordis waterfall;pre-tool非零退出时返回{ kind:"deny", reason }阻断调用(与 dsh-tools 的 deny 决策契约一致,见prepareExecution)。 - 钩子命令经
ctx.shell.run执行(自动套用沙箱策略与超时),payload 走 stdin、cwd 走 env —— 与 DSH 为 hooks bridges 预留的 shell 词汇表一致。 - 配置解析/匹配/payload 构建全部在
lib/config.js纯函数里,npm test零依赖。 - hook 运行不会递归触发工具事件(shell 是服务调用,不是工具调用)。
诚实边界
- hook 命令是受信任的 host 配置(等同 Claude Code hooks):能读写任何 host 能访问的东西,只在可信 profile 启用。
pre-tool命令会阻塞工具执行(超时/退出码决定放行与否);post-tool命令失败只记录,不影响结果。- v1 只支持工具生命周期事件;Stop / SessionEnd 类 hook 需要会话事件订阅,官方尚未暴露,留待后续。
- 若
ctx.shell未挂载,插件照常加载但 hook 不会运行(启动时在/hooks里提示)。
本地开发
cd plugins/dsh-plugin-hooks
npm test # node --test,零依赖
接线集成测试(真实 Cordis + mock shell,验证 allow/deny 语义与 payload):见仓库根 test-wiring.mjs。
LivXue/dsh-plugin-shop
Hilbert-beinghappy/seektty
xiajiajun516/dsh-config-manager
xiaoyuyu6420/dsh-backup
better-er/dsh-edit-diff
polarskicpl/dsh-codex-migrate