The two hook bridges (dsh-hooks-claude, dsh-hooks-codex) would otherwise duplicate
the bulk of the protocol — Codex deliberately reimplements a SUBSET of the Claude
Code protocol (same hooks.json shape, exit-code/stdout contract, command-hook
model). This library holds the genuinely-identical primitives; each bridge owns
only what differs (per-event stdin payload, env/substitution, decision mapping).
New packages/hooks/ group; hook-protocol is a LIBRARY (no plugin, registers/injects
nothing):
- matcher: matchesMatcher(pattern, query, mode) — the one dialect axis collapsed to
a mode param (claude = literal-or-regex with pipe alternation; codex = always
unanchored regex). Match-all on absent/''/'*'; invalid regex matches nothing.
- codec: parseHookOutput(exit, stdout, stderr) → dialect-neutral HookOutput. Exit 0
→ lenient JSON; exit 2 → blocking error (stderr = reason, surfaced as
decision:'block'); other → non-blocking. Parses the CC superset
(continue/stopReason/decision/hookSpecificOutput.{permissionDecision,
additionalContext,updatedInput}/systemMessage); permissionDecision overrides the
legacy top-level decision.
- runner: runHook(bash, hook, opts, now) — runs a command hook via ctx.bash (stdin
payload + trusted-plugin env), honors timeoutSec, never throws (executor reject →
non-blocking-error HookOutput). Injected clock for testable durations.
- merge: mergeHookOutputs — most-restrictive fold (deny>ask>allow, sticky stop,
block reasons joined, context/system-messages accumulated).
- hook/* session events (declaration-merged into SessionEventMap, log-only like
compact/*) + appendHookInvoked/appendHookResult helpers.
updatedInput is parsed but NOT honored (deferred pre-tool-input-rewrite RFC); a
bridge logs+warns. 47 unit tests at per-file 100% (matcher per-mode, codec per
exit-code/field, runner plumbing w/ stub executor, merge precedence, hook/*
helpers). RFC: implemented/feature/2026-06-30-hook-protocol-lib.md.
58 lines
2.1 KiB
JSON
58 lines
2.1 KiB
JSON
{
|
|
"compilerOptions": {
|
|
"target": "es2024",
|
|
"module": "esnext",
|
|
"moduleResolution": "bundler",
|
|
"declaration": true,
|
|
"sourceMap": true,
|
|
"declarationMap": true,
|
|
"composite": true,
|
|
"incremental": true,
|
|
"skipLibCheck": true,
|
|
"esModuleInterop": true,
|
|
"allowImportingTsExtensions": true,
|
|
"rewriteRelativeImportExtensions": true,
|
|
"verbatimModuleSyntax": false,
|
|
"strict": true,
|
|
"noUncheckedIndexedAccess": true,
|
|
"exactOptionalPropertyTypes": true,
|
|
"noImplicitOverride": true,
|
|
"noFallthroughCasesInSwitch": true,
|
|
"noUnusedLocals": true,
|
|
"noUnusedParameters": true,
|
|
"types": ["node"],
|
|
// Source-level resolution for every repo-local graph. Project references,
|
|
// not declaration path aliases, keep each package/vendor source compiled
|
|
// under its own tsconfig boundary.
|
|
"paths": {
|
|
"cordis": ["./vendor/cordis/src"],
|
|
"cosmokit": ["./vendor/cosmokit/src"],
|
|
"schemastery": ["./vendor/schemastery/src"],
|
|
"@cordisjs/plugin-loader": ["./vendor/loader/src"],
|
|
"@cordisjs/plugin-include": ["./vendor/include/src"],
|
|
"@cordisjs/plugin-group": ["./vendor/group/src"],
|
|
"@cordisjs/plugin-timer": ["./vendor/timer/src"],
|
|
"@cordisjs/plugin-hmr": ["./vendor/hmr/src"],
|
|
"@cordisjs/plugin-logger-console": ["./vendor/logger-console/src"],
|
|
// One wildcard maps every @deepseek-ai/dsh-<name> to its source. Package
|
|
// dir names are unique across groups, so first-on-disk-wins resolution is
|
|
// unambiguous; adding a package under an existing group needs no edit
|
|
// here. The build graph's project references (tsconfig.build.json) stay
|
|
// explicit — TS project references have no wildcard form.
|
|
"@deepseek-ai/dsh-*": [
|
|
"./packages/core/*/src",
|
|
"./packages/llm/*/src",
|
|
"./packages/bash/*/src",
|
|
"./packages/compact/*/src",
|
|
"./packages/subagent/*/src",
|
|
"./packages/todo/*/src",
|
|
"./packages/hooks/*/src",
|
|
"./packages/session-persistence/*/src",
|
|
"./packages/ui/*/src",
|
|
"./packages/util/*/src",
|
|
"./packages/support/*/src"
|
|
]
|
|
}
|
|
}
|
|
}
|