From 5596159a83376473006b697f3c351f9339cb94c6 Mon Sep 17 00:00:00 2001 From: Mitchell Date: Tue, 31 Mar 2026 22:05:16 +0100 Subject: [PATCH] fix(hooks): pass phase argument from hook ID to observe.sh (#1042) The shell wrapper run-with-flags-shell.sh was not extracting the phase prefix from the hook ID (e.g., "pre:observe" -> "pre") and passing it as $1 to the invoked script. This caused observe.sh to always default to "post", recording all observations as tool_complete events with no tool_start events captured. Fixes #1018 Co-authored-by: Millectable Co-authored-by: Claude Opus 4.6 (1M context) --- scripts/hooks/run-with-flags-shell.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/hooks/run-with-flags-shell.sh b/scripts/hooks/run-with-flags-shell.sh index 4b064c32..227b8fc7 100755 --- a/scripts/hooks/run-with-flags-shell.sh +++ b/scripts/hooks/run-with-flags-shell.sh @@ -29,4 +29,8 @@ if [[ ! -f "$SCRIPT_PATH" ]]; then exit 0 fi -printf '%s' "$INPUT" | "$SCRIPT_PATH" +# Extract phase prefix from hook ID (e.g., "pre:observe" -> "pre", "post:observe" -> "post") +# This is needed by scripts like observe.sh that behave differently for PreToolUse vs PostToolUse +HOOK_PHASE="${HOOK_ID%%:*}" + +printf '%s' "$INPUT" | "$SCRIPT_PATH" "$HOOK_PHASE"