README
dsh-hooks
Config-driven lifecycle hooks plugin for DeepSeek Harness (dsh).
Declare event -> command hooks directly in your profile's cordis.patch.yml — like Codex CLI / OpenCode hooks, but for dsh. No plugin code required.
中文文档 | Design | Feishu example | Web GUI
Install
One package ships everything (hook engine + Web GUI settings page):
dsh plugin --profile web add dsh-hooks # from npm
# or straight from git:
dsh plugin --profile web add github:PeterBon/dsh-hooks
Restart dsh web. The settings panel gains a "Hooks" section (see Web GUI).
Configure
Add a config block to your profile's cordis.patch.yml:
- id: dsh-hooks
name: dsh-hooks
config:
hooks:
- on: 'turn/end'
when: 'completed' # optional: only completed turns
run: 'node examples/notify-feishu.mjs'
timeoutMs: 10000 # optional, default 10000
- on: 'approval/asked'
run: 'powershell -Command "Write-Output approval-requested >> hooks.log"'
- on: 'tool/call'
match: # optional: field → regex, all must match
tool: '^(rm|git|ssh)'
run: 'node examples/notify-webhook.mjs --slack'
- on: 'turn/end'
when: 'completed'
run: 'node examples/notify-feishu.mjs'
retries: 2 # optional: retry non-zero exits (default 0)
retryDelayMs: 1000 # optional: base retry delay, doubles (default 500)
- on: 'turn/end'
input: 'stdin' # optional: write the full context JSON to stdin
run: 'node my-hook.mjs'
- on: 'approval/asked'
notify: # built-in notification: instead of run, no script needed
channel: 'desktop' # platform balloon/toast
- on: 'turn/end'
when: 'completed'
notify:
channel: 'webhook' # POST JSON to any HTTP endpoint
url: 'https://hooks.slack.com/services/…'
slack: true # optional: { text } one-line summary (Slack style)
- on: 'step/end'
run: 'node examples/log-step.mjs'
debounceMs: 500 # optional: debounce high-frequency events
maxConcurrent: 2 # optional: cap concurrent processes
- on: 'tool/result'
match:
toolDurationMs: '>10000' # numeric comparison ({ gt: 10000 } object form too)
run: 'node examples/notify-slow-tool.mjs'
- on: 'turn/end'
enabled: false # optional: disable without deleting
cwd: 'session' # optional: run in the session working directory
run: 'node examples/log-turn.mjs'
Every hook field:
| Field | Meaning | Default |
|---|---|---|
on |
triggering event (see the event table) | required |
when |
filter turn/end by end reason |
all reasons |
match |
field → regex or numeric comparison, all must match; fields are context keys (tool / sessionName / sessionId / error / source / cwd / content / reason / turn / durationMs / toolDurationMs, …), a field absent from the context never matches. Regexes test the string form; comparisons ({ gt: 10000 } or '>10000', ops gt / gte / lt / lte / eq, combinable) apply only to numeric fields and never match non-numeric ones |
no filter |
run |
command spawned through the platform shell (exactly one of run / notify) |
one of the two required |
notify |
built-in notification (exactly one of run / notify): channel: webhook (HTTP JSON; omit url to use DSH_HOOKS_WEBHOOK_URL, slack: true for a one-line summary), channel: desktop (platform balloon/toast), or channel: feishu (post the card straight from the plugin using the scan-flow credentials — no external script; see the Feishu section) |
one of the two required |
input |
env passes only the DSH_HOOK_* variables; stdin additionally writes the full context JSON to the command's stdin |
env |
timeoutMs |
per-run timeout (ms); the process tree is terminated on expiry. On the notify webhook channel it bounds one request (default 10000); the desktop channel is a local balloon whose script intentionally lives ~9 s, so it does not apply there | 10000 |
retries |
retry count for non-zero exit codes (spawn failures and timeouts never retry) | 0 |
retryDelayMs |
base delay between retries (ms), doubles per attempt, capped at 30 s | 500 |
enabled |
false disables the hook without deleting it: the declaration stays, dispatch skips it silently (never counts as a failure) |
true |
cwd |
working directory for the spawned command: session runs in the session's cwd, an absolute path runs there (run only) |
plugin process directory |
maxConcurrent |
max concurrently running processes for this hook; triggers beyond the cap are dropped (recorded as skipped) |
unlimited |
debounceMs |
debounce window (ms): triggers of high-frequency events (step/end, tool/*, …) inside the window collapse into one trailing execution carrying the latest context |
0 (off) |
Events (v1)
更多「整合與分享」外掛
dsh-notification
作者 omdsh-dev
DeepSeek Harness 桌面通知外掛,任務完成時提醒,可按結果與關鍵詞規則控制。
dsh-lark-bot
作者 plutokeating
DeepSeek Harness (dsh) 接入飛書/Lark bot,掃碼即用:流式卡片、專案工作區、並行任務、多角色 Agent、跨會話通知、對話內模型/金鑰管理與安全網守護(dsh 崩潰後飛書仍可自救)。A scan-to-connect bridge bot connecting DeepSeek Harness (dsh) into Feishu/Lark: streaming cards, workspaces, parallel tasks, multi-role agents, cross-session notify, in-chat model/key management, and a safety-net guardian.
dsh-session-notification
作者 dingyi222666
為 Deepseek Harness 提供會話完成等四種狀態的通知響應,支援瀏覽器提示和提示詞
dsh-chatgpt-web
作者 wlv-zedd
將標準 ChatGPT Web 直接橋接到 DeepSeek Harness 的 DSH ChatGPT Free 外掛。
