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 <noreply@github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mitchell
2026-03-31 22:05:16 +01:00
committed by GitHub
parent d1e2209a52
commit 5596159a83

View File

@@ -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"