-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathon-session-start.sh
More file actions
executable file
·43 lines (36 loc) · 1.51 KB
/
on-session-start.sh
File metadata and controls
executable file
·43 lines (36 loc) · 1.51 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Hook script for Claude Code SessionStart event
# Shows welcome message, Warp detection status, and emits plugin version
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/should-use-structured.sh"
# Legacy fallback for old Warp versions
if ! should_use_structured; then
exec "$SCRIPT_DIR/legacy/on-session-start.sh"
fi
if ! command -v jq &>/dev/null; then
cat << 'EOF'
{
"systemMessage": "🚨 Warp notifications require jq! Install it with your system package manager (e.g. brew install jq, apt install jq) 🚨"
}
EOF
exit 0
fi
source "$SCRIPT_DIR/build-payload.sh"
# Read hook input from stdin
INPUT=$(cat)
# Best-effort Claude Code version detection.
# Cache in $CLAUDE_ENV_FILE so subsequent hooks can skip the lookup, and
# export it now so the rest of this hook (warp-notify.sh below) can use it.
if [ -n "${CLAUDE_ENV_FILE:-}" ] && [ -z "${CLAUDE_CODE_VERSION:-}" ]; then
CC_VERSION=$(claude --version 2>/dev/null | head -1 || true)
if [ -n "$CC_VERSION" ]; then
echo "export CLAUDE_CODE_VERSION=\"$CC_VERSION\"" >> "$CLAUDE_ENV_FILE"
export CLAUDE_CODE_VERSION="$CC_VERSION"
fi
fi
# Read plugin version from plugin.json
PLUGIN_VERSION=$(jq -r '.version // "unknown"' "$SCRIPT_DIR/../.claude-plugin/plugin.json" 2>/dev/null)
# Emit structured notification with plugin version so Warp can track it
BODY=$(build_payload "$INPUT" "session_start" \
--arg plugin_version "$PLUGIN_VERSION")
"$SCRIPT_DIR/warp-notify.sh" "warp://cli-agent" "$BODY"