KYinCode/dsh-hooks-plugin

Claude Code 风格的 DSH hooks:通过 .dsh/hooks.json 在智能体/工具生命周期事件上运行 shell 命令 | Claude Code style hooks for DeepSeek Harness: shell commands on agent/tool events via .dsh/hooks.json

Project Overview项目介绍

This is a native DSH plugin built exclusively for DeepSeek Harness, designed to bring Claude Code-style hook functionality to the DSH ecosystem. It lets users run custom shell commands when specific agent or tool lifecycle events fire, and follows the same JSON configuration schema as Claude Code hooks, making it easy to migrate existing hook scripts. It supports four layers of configuration, starting from the global level at ~/.dsh/hooks.json, then preset-level, project-level, and finally project-level local configuration. Installation can be done directly via the DSH plugin command, either from the npm registry or from a local packed tarball.

After installation, the plugin takes effect automatically for both new and existing open sessions, no restart of DSH is required. Any changes to project configuration are automatically reloaded via the file watcher, and if you have the dsh-hot-installer plugin installed, even plugin upgrades work without a restart. The plugin includes a full configuration manual bundled with the installation package, so you don’t need to check the source code to understand how to write hooks. It also automatically registers an authoring skill that gives you quick access to guidance right inside DSH.

The plugin only supports the command and http hook types in v1, with prompt and agent types aligned to the Claude Code schema but not implemented yet. It keeps compatibility with Claude Code at the configuration and protocol level only, and does not replicate CC-specific environment variables or plugin mechanisms. Hook execution records are persisted up to 200 entries, which is configurable via the DSH_HOOKS_RECENT_MAX environment variable, and logs are automatically rotated when they hit 1 MiB, with the size limit also configurable. The plugin is released under the permissive MIT open source license.

这是一个面向 DeepSeek Harness 开发的原生插件,为 DSH 提供 Claude Code 风格的钩子功能,允许用户在智能体或工具的生命周期事件触发时运行自定义 shell 命令。配置遵循与 Claude Code 兼容的 JSON 结构,存储在 .dsh/hooks.json 路径下,支持全局、预设、项目、项目本地四层配置,可直接复用已有的 Claude Code 钩子脚本,无需额外改造。

它支持多种匹配规则,对齐 Claude Code 的去重逻辑,覆盖 PreToolUse、会话开始结束、子代理结束等多个生命周期事件,还支持拦截工具调用,默认对子代理生效,支持配置变更热重载,无需重启 DSH 即可生效。搭配 dsh-hot-installer 还可以实现免重启热升级插件,浮动控制台按会话隔离显示钩子记录,切换会话自动更新对应内容。

本插件采用 MIT 开源许可证,可通过 dsh plugin --profile <p> add 命令从 npm 或本地安装包安装,安装后新建和已有会话均可自动生效。插件自带配置手册,自动注册作者编写技能,方便开发者查阅学习,钩子记录会自动持久化保存,支持日志轮转,不会无限占用本地存储空间。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 3 stars - very few users, little community feedback星标只有 3,几乎没人在用,遇到问题缺少社区反馈
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-hooks-plugin

把 KYinCode/dsh-hooks-plugin 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-hooks-plugin

中文 | English

为 DeepSeek Harness 提供 Claude Code 风格的 hooks:在智能体 / 工具生命周期事件上运行 shell 命令,配置来自 .dsh/hooks.json(与 Claude Code hooks 兼容的 JSON 结构)。

产品名是 dsh-hooks;npm / GitHub 包名是 dsh-hooks-plugin(dsh-hooks 已被占用)。运行时 API 与日志路径沿用 dsh-hooks 名:~/.dsh/logs/dsh-hooks/dsh-hooks.log 与 GET /dsh-hooks/recent(见下)。

目录

特性(v1)

  • 四层配置:全局 ~/.dsh/hooks.json → 预设 <preset-dir>/hooks.json → 项目 <项目根>/.dsh/hooks.json → 项目本地 .dsh/hooks.local.json。
  • CC 兼容 schema 与协议:matcher[] + hooks[] 结构、stdin JSON 输入 / stdout JSON 决策输出,可复用现有 Claude Code hook 脚本。
  • 去重规则对齐 CC 2.1.88 hookDedupKey:command = shell+command+if、http = url+if、prompt/agent = prompt+if;同一 key 跨层只执行一次,最后合并层胜出;callback/function 不去重。
  • matcher 语义对齐 CC matchesPattern:* 全匹配、A|B 管道精确匹配、其余按正则;if 条件支持权限规则语法(Bash(git *)、Read(*.ts))。
  • 事件:PreToolUse / PostToolUse / PostToolUseFailure / UserPromptSubmit / SessionStart / SessionEnd / Stop / SubagentEnd。
    • PreToolUse 决策 deny → 官方工具失败卡片(模型看到 Error: <reason>)。
  • 子代理:默认触发,输入载荷携带 agent_id / agent_type / delegation_depth;可用 subagents: false 关闭;命令在触发者自己的沙箱上下文执行。
  • 热重载:项目配置改动自动重新加载(fs.watchFile),无需重启。
  • 免重启热升级:安装 dsh-hot-installer 后,dsh plugin --profile web add <包>@<新版本> 当场生效,无需重启。
  • 浮动控制台按会话隔离:shell.overlay 上的 🔌 Hooks 浮动控制台只显示当前正在查看的会话的 hooks(含该会话子代理触发的记录,带 subagent·dN 角标,行内显示触发工具名);切换会话即随之更新,头部显示 会话·<标题>。
  • 最近记录持久化:每条 hook 记录写入 recent.jsonl(限 200 条,DSH_HOOKS_RECENT_MAX 可调),插件热升级/进程重启后自动回填——控制台不丢最近历史。
  • 日志轮转:~/.dsh/logs/dsh-hooks/dsh-hooks.log 超过 1 MiB(可用 DSH_HOOKS_MAX_LOG_BYTES 调整)自动滚动为 .1 并续写新文件,不会无限增长。
  • 交付形态:profile bundle(cordis.patch.yml 自动插行),用 dsh plugin --profile <p> add 安装。
  • 随包自带手册:docs/CONFIGURATION.md(配置 / 协议 / 边界全讲清)随 npm 包装入——装完的 agent 可直接 read 它,不必翻源码猜协议。
  • 自动注册作者技能:apply() 把包内 skills/dsh-hooks-authoring 注册进技能注册表(global 层),任意 agent 装完即在其 skill 目录看到 dsh-hooks-authoring;加载即得「四条钉死事实 + 配置/决策 JSON + Windows/沙箱边界」索引,深度问题读随包手册。

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-prompt-polish 下一个 Next dsh-traffic-light →