fix: don't early-return on 'allow' in executePreToolUseHooks
When multiple hook sources are merged (global ~/.claude/settings.json + project .claude/settings.json), a global catch-all hook returning 'allow' caused early return before project-level hooks could execute. Only 'deny' and 'ask' decisions should short-circuit. 'allow' should continue processing remaining hooks so project-specific guards (e.g., file budget enforcement) get a chance to block.
This commit is contained in:
@@ -143,9 +143,9 @@ export async function executePreToolUseHooks(
|
||||
output.suppressOutput !== undefined ||
|
||||
output.systemMessage !== undefined
|
||||
|
||||
if (decision || hasCommonFields) {
|
||||
if (decision === "deny" || decision === "ask") {
|
||||
return {
|
||||
decision: decision ?? "allow",
|
||||
decision,
|
||||
reason,
|
||||
modifiedInput,
|
||||
elapsedMs: Date.now() - startTime,
|
||||
@@ -158,6 +158,11 @@ export async function executePreToolUseHooks(
|
||||
systemMessage: output.systemMessage,
|
||||
}
|
||||
}
|
||||
|
||||
// "allow" — apply modifiedInput but continue processing remaining hooks
|
||||
if (modifiedInput) {
|
||||
Object.assign(stdinData.tool_input, objectToSnakeCase(modifiedInput))
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user