-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhook_client.sh
More file actions
executable file
·27 lines (23 loc) · 825 Bytes
/
hook_client.sh
File metadata and controls
executable file
·27 lines (23 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
# Fast hook client — sends event to daemon via unix socket.
# Usage: echo '{"tool_name":"Bash",...}' | hook_client.sh pre|post
# Falls back to dispatcher if daemon not running.
SOCK="/tmp/claude_hook_daemon.sock"
EVENT_TYPE="${1:-pre}"
input=$(cat)
[ -z "$input" ] && echo '{}' && exit 0
# Try daemon (inject _event key with sed — no python3 needed)
if [ -S "$SOCK" ]; then
payload="{\"_event\":\"${EVENT_TYPE}\",\"_data\":${input}}"
result=$(printf '%s' "$payload" | nc -U "$SOCK" -w 2 2>/dev/null)
if [ -n "$result" ]; then
echo "$result"
exit 0
fi
fi
# Fallback to dispatcher
if [ "$EVENT_TYPE" = "pre" ]; then
echo "$input" | python3 /Users/bernard/.claude/hooks/dispatcher_pre.py
else
echo "$input" | python3 /Users/bernard/.claude/hooks/dispatcher_post.py
fi