ディレクトリに戻る

dsh-hooks

キュレーションリスト掲載メンテナンス: 活発

peterbon/dsh-hooks

設定駆動ライフサイクル hooks

GitHub で見る
$ dsh plugin add dsh-hooks

インストール方法

dsh には中央のインストールコマンドはありません。このプラグインのエントリ(README に記載)をプロファイルまたはパッチ設定に追加し、再起動します。

インストールの仕組み

10

スター

3

フォーク

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の新着プラグインを毎週お届け。スパムはありません。