Summary
With prompt hooks enabled in published version 0.1.0, a native Claude prompt-hook response of {"ok":false,"reason":"REGRESSION_DENY"} produces a successful, unblocked decision. A rejecting prompt hook can therefore permit an action that it was intended to block.
Environment and scope
- Plugin:
@hamzaabili/[email protected]
- Event: PreToolUse
- Handler: prompt, with
allowPromptHooks: true
- Runtime-level reproduction: Bun 1.4.3 on macOS, Apple Silicon
- Model response supplied deterministically through
Host.generateText; no actual-provider prompt-hook reproduction is claimed
- Prompt hooks are disabled by default, limiting the affected default surface
Minimal hook
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "prompt",
"prompt": "Return {\"ok\":false,\"reason\":\"REGRESSION_DENY\"}.",
"onFailure": "block"
}
]
}
]
}
}
Configure allowPromptHooks: true and trust the disposable fixture source. For a deterministic runtime test, make the model callback return the exact response above rather than relying on a real model to follow the prompt.
Deterministic parser/decision reproduction
From a source checkout, this script can be placed in a scratch file at the repository root and run with Bun. It does not execute a tool or contact a model:
import { parsePromptOutput, mergeDecisions } from './src/output.ts'
const parsed = parsePromptOutput(
'{"ok":false,"reason":"REGRESSION_DENY"}'
)
const decision = mergeDecisions('PreToolUse', [{
sourceID: 'fixture',
sourceLabel: 'fixture',
event: 'PreToolUse',
status: parsed.status,
output: parsed.output,
message: parsed.message,
onFailure: 'block',
}])
console.log({
status: parsed.status,
blocked: decision.blocked,
stop: decision.stop,
permission: decision.permission,
})
// Actual: success, blocked false, stop false, permission undefined
// Expected: a rejection effect for the native ok:false response
The same response through HookRuntime.run with an injected Host.generateText returned status: "success", blocked: false, stop: false, and no permission decision. Setting onFailure: "block" does not help because the response is classified as successful.
Expected mapping
Claude prompt hooks use an ok/reason response schema. An ok: false response must produce the event's rejection behavior rather than a successful no-op. See Prompt-hook response schema.
The prompt response parser should be distinct from command-output parsing, or explicitly translate the native prompt schema before merging decisions. Event-specific rejection behavior should be preserved.
Relevant code and regression coverage
parsePromptOutput calls parseHookJson, whose readOutput does not interpret ok. The prompt runtime asks for a generic Claude hook output schema, and existing prompt tests supply command-style decisions. See output handling and prompt runtime.
Useful regression cases include ok: false with a reason, ok: true, and malformed/missing required prompt-response fields. Cover the supported events' distinct rejection effects rather than treating command-output decisions as a substitute for the prompt protocol.
Doctor output
Not applicable to the deterministic runtime-only reproduction: a fixture source and generated response were injected directly, so discovery, source activation, and provider access are not prerequisites for reproducing the mapping failure.
Remediation
Fixed in 0.1.2. Prompt hooks now parse Claude's native {ok, reason, impossible} response schema. ok: false maps to the event rejection effect: PreToolUse denies, Stop/SubagentStop continue unless impossible: true, and PostToolUse, PostToolUseFailure and UserPromptSubmit block. Unrecognized or malformed prompt responses are errors instead of silent allows, and the model prompt asks for the native schema. Command-style JSON remains a compatibility fallback.
The adapter maps rejection to OpenCode's existing block semantics; Claude's separate continueOnBlock turn-end distinction is not modelled.
Release: https://github.com/Hamza-Abili/opencode-claude-hooks/releases/tag/v0.1.2
Credit: @j-256
Summary
With prompt hooks enabled in published version 0.1.0, a native Claude prompt-hook response of
{"ok":false,"reason":"REGRESSION_DENY"}produces a successful, unblocked decision. A rejecting prompt hook can therefore permit an action that it was intended to block.Environment and scope
@hamzaabili/[email protected]allowPromptHooks: trueHost.generateText; no actual-provider prompt-hook reproduction is claimedMinimal hook
{ "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "prompt", "prompt": "Return {\"ok\":false,\"reason\":\"REGRESSION_DENY\"}.", "onFailure": "block" } ] } ] } }Configure
allowPromptHooks: trueand trust the disposable fixture source. For a deterministic runtime test, make the model callback return the exact response above rather than relying on a real model to follow the prompt.Deterministic parser/decision reproduction
From a source checkout, this script can be placed in a scratch file at the repository root and run with Bun. It does not execute a tool or contact a model:
The same response through
HookRuntime.runwith an injectedHost.generateTextreturnedstatus: "success",blocked: false,stop: false, and no permission decision. SettingonFailure: "block"does not help because the response is classified as successful.Expected mapping
Claude prompt hooks use an
ok/reasonresponse schema. Anok: falseresponse must produce the event's rejection behavior rather than a successful no-op. See Prompt-hook response schema.The prompt response parser should be distinct from command-output parsing, or explicitly translate the native prompt schema before merging decisions. Event-specific rejection behavior should be preserved.
Relevant code and regression coverage
parsePromptOutputcallsparseHookJson, whosereadOutputdoes not interpretok. The prompt runtime asks for a generic Claude hook output schema, and existing prompt tests supply command-style decisions. See output handling and prompt runtime.Useful regression cases include
ok: falsewith a reason,ok: true, and malformed/missing required prompt-response fields. Cover the supported events' distinct rejection effects rather than treating command-output decisions as a substitute for the prompt protocol.Doctor output
Not applicable to the deterministic runtime-only reproduction: a fixture source and generated response were injected directly, so discovery, source activation, and provider access are not prerequisites for reproducing the mapping failure.
Remediation
Fixed in
0.1.2. Prompt hooks now parse Claude's native{ok, reason, impossible}response schema.ok: falsemaps to the event rejection effect:PreToolUsedenies,Stop/SubagentStopcontinue unlessimpossible: true, andPostToolUse,PostToolUseFailureandUserPromptSubmitblock. Unrecognized or malformed prompt responses are errors instead of silent allows, and the model prompt asks for the native schema. Command-style JSON remains a compatibility fallback.The adapter maps rejection to OpenCode's existing block semantics; Claude's separate
continueOnBlockturn-end distinction is not modelled.Release: https://github.com/Hamza-Abili/opencode-claude-hooks/releases/tag/v0.1.2
Credit: @j-256