返回目錄

dsh-hooks

精選清單收錄維護狀態: 活躍

peterbon/dsh-hooks

基於配置的生命週期鉤子外掛,為 DeepSeek Harness 擴充套件自動化時機。

前往 GitHub
$ dsh plugin add dsh-hooks

安裝

dsh 沒有統一的安裝指令 —— 把該外掛 README 中的設定行加入你的 profile / patch 設定,然後重啟即可。

查看安裝教學

10

星數

3

Fork

TypeScript

語言

MIT

授權條款

2026-08-15

建立於

2026-11-19

最近推送

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)

在 GitHub 閱讀完整 README →

DSH Plugins 是獨立的 DeepSeek Harness 外掛目錄,與 DeepSeek 官方無關,也不代表官方背書。第三方外掛未經安全稽核,安裝前請審查原始碼。

每週取得最新的 DeepSeek Harness 外掛,絕不濫發。