mirror of
https://github.com/thedotmack/claude-mem
synced 2026-04-25 17:15:04 +02:00
- Introduced functionality for installing, uninstalling, and checking the status of Cursor hooks. - Added a new command structure for managing hooks with detailed usage instructions. - Implemented a method to locate the cursor-hooks directory across different environments. - Updated build-hooks script to inform users about the location of Cursor hooks. This enhancement streamlines the integration of Claude-Mem with Cursor, improving user experience and accessibility of hooks.
88 lines
2.4 KiB
Bash
Executable File
88 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Installation script for claude-mem Cursor hooks
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
INSTALL_TYPE="${1:-user}" # 'user', 'project', or 'enterprise'
|
|
|
|
echo "Installing claude-mem Cursor hooks (${INSTALL_TYPE} level)..."
|
|
|
|
case "$INSTALL_TYPE" in
|
|
"project")
|
|
if [ ! -d ".cursor" ]; then
|
|
mkdir -p .cursor
|
|
fi
|
|
TARGET_DIR=".cursor"
|
|
HOOKS_DIR=".cursor/hooks"
|
|
;;
|
|
"user")
|
|
TARGET_DIR="${HOME}/.cursor"
|
|
HOOKS_DIR="${HOME}/.cursor/hooks"
|
|
;;
|
|
"enterprise")
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
TARGET_DIR="/Library/Application Support/Cursor"
|
|
HOOKS_DIR="/Library/Application Support/Cursor/hooks"
|
|
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
TARGET_DIR="/etc/cursor"
|
|
HOOKS_DIR="/etc/cursor/hooks"
|
|
else
|
|
echo "Enterprise installation not supported on this OS"
|
|
exit 1
|
|
fi
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo "Enterprise installation requires root privileges"
|
|
exit 1
|
|
fi
|
|
;;
|
|
*)
|
|
echo "Invalid install type: $INSTALL_TYPE"
|
|
echo "Usage: $0 [user|project|enterprise]"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Create hooks directory
|
|
mkdir -p "$HOOKS_DIR"
|
|
|
|
# Copy hook scripts
|
|
echo "Copying hook scripts..."
|
|
cp "$SCRIPT_DIR"/*.sh "$HOOKS_DIR/"
|
|
chmod +x "$HOOKS_DIR"/*.sh
|
|
|
|
# Copy hooks.json
|
|
echo "Copying hooks.json..."
|
|
cp "$SCRIPT_DIR/hooks.json" "$TARGET_DIR/hooks.json"
|
|
|
|
# Update paths in hooks.json if needed
|
|
if [ "$INSTALL_TYPE" = "project" ]; then
|
|
# For project-level, paths should be relative
|
|
sed -i.bak 's|\./cursor-hooks/|\./\.cursor/hooks/|g' "$TARGET_DIR/hooks.json"
|
|
rm -f "$TARGET_DIR/hooks.json.bak"
|
|
elif [ "$INSTALL_TYPE" = "user" ]; then
|
|
# For user-level, use absolute paths
|
|
sed -i.bak "s|\./cursor-hooks/|${HOOKS_DIR}/|g" "$TARGET_DIR/hooks.json"
|
|
rm -f "$TARGET_DIR/hooks.json.bak"
|
|
elif [ "$INSTALL_TYPE" = "enterprise" ]; then
|
|
# For enterprise, use absolute paths
|
|
sed -i.bak "s|\./cursor-hooks/|${HOOKS_DIR}/|g" "$TARGET_DIR/hooks.json"
|
|
rm -f "$TARGET_DIR/hooks.json.bak"
|
|
fi
|
|
|
|
echo ""
|
|
echo "✓ Installation complete!"
|
|
echo ""
|
|
echo "Hooks installed to: $TARGET_DIR/hooks.json"
|
|
echo "Scripts installed to: $HOOKS_DIR"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Ensure claude-mem worker is running:"
|
|
echo " cd ~/.claude/plugins/marketplaces/thedotmack && npm run worker:start"
|
|
echo ""
|
|
echo "2. Restart Cursor to load the hooks"
|
|
echo ""
|
|
echo "3. Check Cursor Settings → Hooks tab to verify hooks are active"
|
|
echo ""
|
|
|