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.suppressOutput !== undefined ||
|
||||||
output.systemMessage !== undefined
|
output.systemMessage !== undefined
|
||||||
|
|
||||||
if (decision || hasCommonFields) {
|
if (decision === "deny" || decision === "ask") {
|
||||||
return {
|
return {
|
||||||
decision: decision ?? "allow",
|
decision,
|
||||||
reason,
|
reason,
|
||||||
modifiedInput,
|
modifiedInput,
|
||||||
elapsedMs: Date.now() - startTime,
|
elapsedMs: Date.now() - startTime,
|
||||||
@@ -158,6 +158,11 @@ export async function executePreToolUseHooks(
|
|||||||
systemMessage: output.systemMessage,
|
systemMessage: output.systemMessage,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "allow" — apply modifiedInput but continue processing remaining hooks
|
||||||
|
if (modifiedInput) {
|
||||||
|
Object.assign(stdinData.tool_input, objectToSnakeCase(modifiedInput))
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user