forked from Durafen/Claude-code-memory
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·157 lines (138 loc) · 5.39 KB
/
install.sh
File metadata and controls
executable file
·157 lines (138 loc) · 5.39 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
# Claude Code Memory Solution - Global Installer
# Creates a global wrapper script for the indexer
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Get the absolute path to the memory project directory
MEMORY_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PACKAGE_PATH="$MEMORY_DIR/claude_indexer"
VENV_PATH="$MEMORY_DIR/.venv"
WRAPPER_PATH="/usr/local/bin/claude-indexer"
echo -e "${BLUE}Claude Code Memory Solution - Global Installer${NC}"
echo "========================================"
# Check if claude_indexer package exists
if [[ ! -d "$PACKAGE_PATH" ]]; then
echo -e "${RED}Error: claude_indexer package not found at $PACKAGE_PATH${NC}"
exit 1
fi
# Check if virtual environment exists
if [[ ! -d "$VENV_PATH" ]]; then
echo -e "${RED}Error: Virtual environment not found at $VENV_PATH${NC}"
echo -e "${YELLOW}Please run: python3.12 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt${NC}"
exit 1
fi
# Check if /usr/local/bin exists
if [[ ! -d "/usr/local/bin" ]]; then
echo -e "${YELLOW}Creating /usr/local/bin directory...${NC}"
if ! mkdir -p /usr/local/bin 2>/dev/null; then
echo -e "${YELLOW}Need sudo permissions to create /usr/local/bin${NC}"
sudo mkdir -p /usr/local/bin
fi
fi
# Create the wrapper script
echo -e "${BLUE}Creating global wrapper script at $WRAPPER_PATH${NC}"
sudo tee "$WRAPPER_PATH" > /dev/null << EOF
#!/bin/bash
# Claude Code Memory Solution - Global Wrapper
# Auto-activates virtual environment and runs indexer
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
MEMORY_DIR="$MEMORY_DIR"
PACKAGE_PATH="$PACKAGE_PATH"
VENV_PATH="$VENV_PATH"
# Check if files still exist
if [[ ! -d "\$PACKAGE_PATH" ]]; then
echo -e "\${RED}Error: claude_indexer package not found at \$PACKAGE_PATH\${NC}"
echo -e "\${YELLOW}The memory project may have been moved or deleted.\${NC}"
exit 1
fi
if [[ ! -d "\$VENV_PATH" ]]; then
echo -e "\${RED}Error: Virtual environment not found at \$VENV_PATH\${NC}"
exit 1
fi
# Use absolute python path instead of activating venv to avoid PATH conflicts
PYTHON_BIN="\$VENV_PATH/bin/python"
# Check if we're in a Python project (has .py files)
if [[ "\$1" == "--project" && "\$2" == "." ]]; then
if [[ ! \$(find . -name "*.py" -type f 2>/dev/null | head -1) ]]; then
echo -e "\${YELLOW}Warning: No Python files found in current directory${NC}"
echo -e "\${YELLOW}Make sure you're in a Python project directory${NC}"
fi
fi
# Run the indexer with all passed arguments
# Smart command detection and routing
# All known CLI commands that should be passed through directly
KNOWN_COMMANDS="index|init|doctor|status|show-config|config|file|post-write|stop-check|session-start|watch|service|hooks|collections|session|workspace|ignore|search|add-mcp|chat|quality-gates|perf"
if [[ "\$1" =~ ^(\$KNOWN_COMMANDS)\$ ]]; then
# Known commands - pass through directly
exec "\$PYTHON_BIN" -m claude_indexer "\$@"
elif [[ "\$1" =~ ^--(help|version)$ ]]; then
# Help and version commands
exec "\$PYTHON_BIN" -m claude_indexer "\$@"
elif [[ "\$1" == "--help" || "\$1" == "-h" || "\$1" == "help" ]]; then
# Help command variations
exec "\$PYTHON_BIN" -m claude_indexer --help
elif [[ \$# -eq 0 ]]; then
# No arguments - show help
exec "\$PYTHON_BIN" -m claude_indexer --help
else
# Basic indexing - use default index command for backward compatibility
exec "\$PYTHON_BIN" -m claude_indexer index "\$@"
fi
EOF
# Make the wrapper executable
sudo chmod +x "$WRAPPER_PATH"
# Remove problematic venv binary that conflicts with global wrapper
VENV_CLAUDE_INDEXER="$VENV_PATH/bin/claude-indexer"
if [[ -f "$VENV_CLAUDE_INDEXER" ]]; then
echo -e "${BLUE}Removing conflicting venv binary...${NC}"
rm "$VENV_CLAUDE_INDEXER"
fi
# Verify installation
if [[ -x "$WRAPPER_PATH" ]]; then
echo -e "${GREEN}✅ Installation successful!${NC}"
echo ""
echo -e "${BLUE}Usage:${NC}"
echo " claude-indexer --project /path/to/project --collection project-name"
echo " claude-indexer --project . --collection current-project"
echo " claude-indexer --help"
echo ""
echo -e "${BLUE}Basic Examples:${NC}"
echo " # Index current directory"
echo " claude-indexer --project . --collection my-project"
echo ""
echo " # Index with incremental updates"
echo " claude-indexer --project /path/to/project --collection name --incremental"
echo ""
echo " # Generate commands for debugging"
echo " claude-indexer --project . --collection test --generate-commands"
echo ""
echo -e "${BLUE}Advanced Commands:${NC}"
echo " # File watching"
echo " claude-indexer watch start --project . --collection my-project"
echo ""
echo " # Git hooks"
echo " claude-indexer hooks install --project . --collection my-project"
echo ""
echo " # Search collections"
echo " claude-indexer search \"query\" --project . --collection my-project"
echo ""
echo " # Add MCP server"
echo " claude-indexer add-mcp my-project"
echo ""
echo " # Chat processing"
echo " claude-indexer chat index --project . --collection my-project"
echo ""
echo -e "${GREEN}You can now use 'claude-indexer' from any directory!${NC}"
else
echo -e "${RED}❌ Installation failed${NC}"
exit 1
fi