dsh-compat-adapter: Explicitly Integrating Hooks and Rules from Five AI Coding Tools into DSH

Preface

DSH (DeepSeek Harness) is a runtime designed for agents. Many teams have already established hooks and rules in environments like Claude Code, Codex, WorkBuddy, OpenCode, and GitHub Copilot. These include intercepting actions before file writes, adding context after tool calls, and running scripts at the end of a session. However, if you simply hard-wire these assets into DSH based on event names, common problems arise: Claude’s updatedInput might be parsed but fail to take effect; Codex’s permissionDecision: "ask" might lack an approval path and degenerate into an auto-allow; Copilot might write deny at the top level, but the DSH parser only reads hookSpecificOutput, causing the deny to be treated as “no decision” and auto-allowed; and OpenCode’s TypeScript callback bodies cannot be migrated along with their names.

Below, we introduce the community plugin dsh-compat-adapter (maintained by denceee). Acting as a front-end/base adaptation layer for DSH, it explicitly declares the vendor and event, grades capabilities, and routes to real seams. This ensures that the cost of each adaptation is legible, rather than superficially functional but silently failing in practice. The plugin is categorized as a workflow and can be viewed on the SkillHub directory page; the source code and documentation are available on GitHub.

What is this?

dsh-compat-adapter is a DSH Cordis bundle plugin. Upon installation, it solely provides the ctx.compatAdapter service; it does not automatically migrate any assets itself. Instead, preset-class plugins trigger the adaptation by calling registerHook / registerRules within their apply() methods.

The design principles can be summarized in three points:

Step Meaning
Declare Preset authors must explicitly write out the vendor and event. There is no filename sniffing or ownership guessing.
Grade Each asset returns a frozen, four-level capability result. Losses are listed one-by-one in degradations[].
Route If an official bridge exists, reuse it. If an interceptable seam exists, perform native translation. If only observation is possible, mark it as such. If nothing can be done, reject.

Two clear boundaries:

  1. Do not reinvent official bridges. Events that can be mapped are delegated to @deepseek-ai/dsh-hooks-claude-code / @deepseek-ai/dsh-hooks-codex. This plugin is responsible for writing the declarations into bridge configurations and handling events that lack official bridges.
  2. Do not execute external code. JS function handlers, OpenCode TS callbacks, and Claude’s http / mcp_tool / prompt / agent handlers are all marked as UNSUPPORTED. We do not embed other plugins’ runtimes into the DSH Host.

The current package.json version is 0.5.0, targeting DSH 0.2.0-rc.2. Node requirements are ^22.19.0 or >=24.0.0, and the license is MIT. The README states that 141 tests pass.

Capability Grading: Not a Binary “Supported / Unsupported” Choice

Every registration returns a frozen result. There is no supported: true field that smooths over risks.

Grade Meaning This Version
DIRECT A 1:1 seam exists in DSH, and the semantics are preserved as-is. 0 (Even official bridges are dialect adaptations, so the plugin does not mark them as DIRECT)
ADAPTED A seam exists, but there are semantic losses which must be listed in degradations[]. All 112 hook events
CARRY No universal mapping exists. Rules are carried byte-for-byte and injected at the start of a session, but they do not become executable policies. Rules from all five vendors
UNSUPPORTED No faithful mapping exists. The asset is rejected with a reason and is not mounted. See boundaries below.

The 112 events are aligned with code in the documentation and test/doc-counts.test.js. 102 are real/precise mappings, and 10 are self-described as Approximate in their respective degradations (Claude’s MessageDisplay, StopFailure; Codex’s Interrupt; WorkBuddy’s Elicitation, ElicitationResult; OpenCode’s installation.updated, server.connected, session.deleted, session.updated, tui.toast.show). The README also mentions 29 native translation points, as well as implementation directions like a self-built Copilot bridge, real file watching, real git worktree detection, and official LSP integration. Any capability not declared in the matrix should not be assumed to exist.

Test-enforced invariants include: ADAPTED must have at least one degradations entry; unknown vendor/event throws UNKNOWN_VENDOR / UNKNOWN_EVENT; UNSUPPORTED assets are never written to configuration or mounted to a bridge. Common UNSUPPORTED paths include: JS function handlers; command hooks that cannot execute because ctx.shell is missing from the composition (rules can still read files and inject); rejection when a profile cannot resolve dsh-hooks-* (no fallback to a homemade implementation); and throwing INVALID_HANDLER for handler types other than command.

Supported Vendors and Routing

The five vendors are independent of each other. Data is located in src/vendors/<vendor>.js, and the matrix can be unit-tested independently of the Harness.

Vendor Alias Official Bridge Events Official Bridge Native Translation Observe Only Builtin Bridge Approximate Rules
claude claude-code, cc dsh-hooks-claude-code 33 7 24 2 0 2 CARRY
codex openai-codex dsh-hooks-codex 12 5 4 3 0 1 CARRY
workbuddy codebuddy dsh-hooks-claude-code 24 5 19 0 0 2 CARRY
opencode — None 29 0 29 0 0 5 CARRY
copilot github-copilot None 14 0 4 0 10 0 CARRY
Total 112 17 80 5 10 10

Brief explanation of routing:

  • official-bridge (17): For claude / codex / workbuddy, if the official package is present, the bridge maps the event to the DSH seam.
  • native-translate (80): This plugin’s src/translate.js directly produces DSH verdict types.
  • native-seam / Observe Only (5): src/observe.js records block attempts but does not cancel the lifecycle.
  • builtin-bridge (10): Copilot only. When DSH lacks an official bridge, src/bridges/copilot.js is used (e.g., deny blocks tools, block continues execution, sub-agent injection, approvals, etc. See the Copilot section in the repository README for details).
  • CARRY: Rules from all five vendors are injected into the model-visible context, but not executed as policies.

When reading the matrix, note: workbuddy is treated according to the CodeBuddy engine (Claude-Code compatible). Limitations such as the desktop version lacking a public hook API are written in each degradation entry. opencode callback names can be mapped, but the TS callback body is not carried over and must be rewritten as a command. copilot top-level deny semantics are covered by a combination of the builtin bridge and native translation, but are still marked as ADAPTED with loss explanations.

Installation and Activation

The plugin is distributed as a standard DSH Cordis bundle (dsh.bundle.patch + cordis.patch.yml in package.json). The installation command should follow the README. You must use the absolute path of this repository on disk; do not construct remote URLs based on the plugin name.

# Method A: plugin_manager tool (managed path, recommended)
#   action: install_bundle, target: <absolute path of this repo>

# Method B: CLI
dsh plugin --profile <profile> add <absolute path of this repo>

Once installed, only the compatAdapter service is registered in Cordis; the actual migration logic is implemented in your preset plugin.

cordis.patch.yml Notes: The baseUrl for the bundle patch is the profile root directory. The name in the insert line must be a bare specifier (e.g., 'dsh-compat-adapter'). Do not write it as a relative path or a node_modules/... prefix, otherwise the package cannot be resolved.

In your agent preset, insert this plugin first, then mount your asset plugin, and declare inject: ['compatAdapter']:

- insert:
    - id: preset-my-preset
      name: '@deepseek-ai/dsh-agent-preset'
      config:
        id: my-preset
        name: My Preset
        plugins:
          - id: compat-adapter
            name: 'dsh-compat-adapter'
          - id: my-vendor-assets
            name: './my-vendor-assets/index.js'

Typical Usage: Registering a Command Hook

The preset plugin’s apply() completes registration during the setup phase (can be async; Cordis will wait). The following example is from the README: an explicit vendor + event, where the handler is a command string.

// my-vendor-assets/index.js
export const name = 'my-vendor-assets'
export const inject = ['compatAdapter']

export async function apply(ctx) {
  const r = await ctx.compatAdapter.registerHook({
    vendor: 'claude',
    event: 'PreToolUse',
    matcher: 'Write',
    handler: 'node ./hooks/no-write.mjs',
  })
  // r.capability === 'ADAPTED'
  // Fields like r.seam and r.degradations should be logged or displayed to the user by the preset logic
}

For how consumers can combine multiple hooks and register rules, see INTEGRATION.md in the repository.

Local validation options:

npm test
# Or full verification chain
npm run verify

Applicable Scenarios and Notes

For Whom: This is for teams that are using DSH as their agent foundation and need to auditably reuse existing hooks (in command form) and rules from Claude Code / Codex / WorkBuddy / OpenCode / GitHub Copilot. This is for teams willing to accept “full coverage with itemized loss descriptions,” rather than assuming byte-for-byte identical behavior to the original vendors.

Important Notes:

  1. The plugin runs with the same permissions as the DSH process. Before installation, please read the source code and the MIT license to confirm that the handler commands and rule content are trustworthy.
  2. There is no “all DIRECT” shortcut. Integration UIs or documentation should display degradations to avoid hiding Approximate events from users.
  3. Peer dependencies include 0.2.0-rc.2 aligned versions of @deepseek-ai/dsh, dsh-hook-protocol, dsh-hooks-claude-code, dsh-hooks-codex, etc. Behavior in case of version mismatch follows the actual resolution result, and a missing official bridge will cause a fail-closed state.
  4. SkillHub (skillhub.cn) is a community plugin directory and has no official affiliation with DeepSeek / High-Flyer. Star counts and categories are based on the directory’s registration (currently 1 star on GitHub, categorized as Workflow).

Conclusion

The value of dsh-compat-adapter lies in turning the migration paths for five vendors, 112 hook events, and rules into a testable matrix. It routes to real DSH seams, rejecting false equivalences and silent passes. If you want to reuse existing coding assistant assets on DSH, you can start by viewing the entry on the directory page, reading the matrix and INTEGRATION guide on GitHub, installing the bundle via your profile’s local path, and letting your preset plugin explicitly register each adaptation item.

  • Directory Page: https://www.skillhub.cn/plugins/denceee/dsh-compat-adapter
  • Repository: https://github.com/denceee/dsh-compat-adapter
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye