-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall
More file actions
executable file
·42 lines (35 loc) · 1.14 KB
/
install
File metadata and controls
executable file
·42 lines (35 loc) · 1.14 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
#!/usr/bin/env bash
set -euo pipefail
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CLAUDE_DIR="$HOME/.claude"
HOOKS_DIR="$CLAUDE_DIR/hooks"
SETTINGS="$CLAUDE_DIR/settings.json"
echo "Installing ai-behaviors hook"
mkdir -p "$HOOKS_DIR"
# --- Symlink hook ---
ln -sf "$REPO_DIR/hooks/inject-behaviors.sh" "$HOOKS_DIR/inject-behaviors.sh"
echo " symlinked: inject-behaviors.sh → $HOOKS_DIR/"
# --- Register hook in settings.json ---
if [ ! -f "$SETTINGS" ]; then
cat > "$SETTINGS" <<'EOF'
{
"hooks": {}
}
EOF
fi
inject_cmd="$HOOKS_DIR/inject-behaviors.sh"
if ! grep -q "inject-behaviors.sh" "$SETTINGS" 2>/dev/null; then
tmp=$(mktemp)
jq --arg cmd "$inject_cmd" '
.hooks //= {} |
.hooks.UserPromptSubmit //= [] |
.hooks.UserPromptSubmit += [{"hooks": [{"type": "command", "command": $cmd, "timeout": 5}]}]
' "$SETTINGS" > "$tmp" && mv "$tmp" "$SETTINGS"
echo " registered: inject-behaviors.sh in settings.json"
else
echo " already registered: inject-behaviors.sh"
fi
echo ""
echo "Done. Use #hashtags in Claude Code prompts:"
echo " Fix the auth bug #=code #challenge"
echo " Review this PR #=review #deep #challenge"