-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-sweep-hook.sh
More file actions
executable file
·89 lines (78 loc) · 2.61 KB
/
install-sweep-hook.sh
File metadata and controls
executable file
·89 lines (78 loc) · 2.61 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# Install Sweep prediction hook for Claude Code
set -e
HOOK_DIR="$HOME/.claude/hooks"
SWEEP_DIR="$HOME/.stackmemory/sweep"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(dirname "$SCRIPT_DIR")"
echo "Installing Sweep prediction hook for Claude Code..."
# Create directories
mkdir -p "$HOOK_DIR"
mkdir -p "$SWEEP_DIR"
# Copy hook script
cp "$REPO_DIR/templates/claude-hooks/post-edit-sweep.js" "$HOOK_DIR/"
chmod +x "$HOOK_DIR/post-edit-sweep.js"
# Copy Python prediction script
cp "$REPO_DIR/packages/sweep-addon/python/sweep_predict.py" "$SWEEP_DIR/"
# Update hooks.json if it exists, otherwise create it
HOOKS_JSON="$HOME/.claude/hooks.json"
if [ -f "$HOOKS_JSON" ]; then
# Check if post-tool-use already configured
if grep -q "post-tool-use" "$HOOKS_JSON"; then
echo "Note: post-tool-use hook already configured in $HOOKS_JSON"
echo "You may need to manually add the sweep hook."
else
echo "Adding sweep hook to $HOOKS_JSON..."
# Use node to safely update JSON
node -e "
const fs = require('fs');
const hooks = JSON.parse(fs.readFileSync('$HOOKS_JSON', 'utf-8'));
hooks['post-tool-use'] = '$HOOK_DIR/post-edit-sweep.js';
fs.writeFileSync('$HOOKS_JSON', JSON.stringify(hooks, null, 2));
console.log('Updated hooks.json');
"
fi
else
echo "Creating $HOOKS_JSON..."
cat > "$HOOKS_JSON" << 'EOF'
{
"post-tool-use": "~/.claude/hooks/post-edit-sweep.js"
}
EOF
fi
# Check Python dependencies
echo ""
echo "Checking Python dependencies..."
if python3 -c "import llama_cpp" 2>/dev/null; then
echo " llama-cpp-python: installed"
else
echo " llama-cpp-python: NOT INSTALLED"
echo " Run: pip install llama-cpp-python"
fi
if python3 -c "import huggingface_hub" 2>/dev/null; then
echo " huggingface_hub: installed"
else
echo " huggingface_hub: NOT INSTALLED"
echo " Run: pip install huggingface_hub"
fi
# Check model
MODEL_PATH="$HOME/.stackmemory/models/sweep/sweep-next-edit-1.5b.q8_0.v2.gguf"
if [ -f "$MODEL_PATH" ]; then
echo " Model: downloaded"
else
echo " Model: NOT DOWNLOADED"
echo " Run: stackmemory sweep setup --download"
fi
echo ""
echo "Installation complete!"
echo ""
echo "Hook installed at: $HOOK_DIR/post-edit-sweep.js"
echo "Python script at: $SWEEP_DIR/sweep_predict.py"
echo ""
echo "Usage:"
echo " - Hook runs automatically after Edit/Write operations"
echo " - Predictions appear after 2+ edits in session"
echo " - Check status: node $HOOK_DIR/post-edit-sweep.js --status"
echo " - Clear state: node $HOOK_DIR/post-edit-sweep.js --clear"
echo " - Disable: export SWEEP_ENABLED=false"
echo ""