-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinstall.sh
More file actions
138 lines (107 loc) · 4.02 KB
/
install.sh
File metadata and controls
138 lines (107 loc) · 4.02 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
#!/bin/bash
# claudemem installer
# Usage: curl -fsSL https://raw.githubusercontent.com/MadAppGang/claudemem/main/install.sh | bash
set -e
REPO="MadAppGang/claudemem"
INSTALL_DIR="${CLAUDE_MEM_INSTALL_DIR:-$HOME/.local/bin}"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
info() { echo -e "${BLUE}[info]${NC} $1"; }
success() { echo -e "${GREEN}[success]${NC} $1"; }
warn() { echo -e "${YELLOW}[warn]${NC} $1"; }
error() { echo -e "${RED}[error]${NC} $1"; exit 1; }
detect_platform() {
local os arch
case "$(uname -s)" in
Linux*) os="linux";;
Darwin*) os="darwin";;
MINGW*|MSYS*|CYGWIN*) error "Windows detected. Use: irm https://raw.githubusercontent.com/${REPO}/main/install.ps1 | iex";;
*) error "Unsupported OS: $(uname -s)";;
esac
case "$(uname -m)" in
x86_64|amd64) arch="x64";;
arm64|aarch64) arch="arm64";;
*) error "Unsupported architecture: $(uname -m)";;
esac
echo "${os}-${arch}"
}
get_latest_version() {
curl -sL "https://api.github.com/repos/${REPO}/releases/latest" | \
grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/'
}
compute_sha256() {
if command -v sha256sum &>/dev/null; then
sha256sum "$1" | cut -d' ' -f1
elif command -v shasum &>/dev/null; then
shasum -a 256 "$1" | cut -d' ' -f1
fi
}
verify_checksum() {
local file="$1" version="$2" platform="$3"
local checksums_url="https://github.com/${REPO}/releases/download/v${version}/checksums.txt"
local expected actual
expected=$(curl -fsSL "$checksums_url" 2>/dev/null | grep "claudemem-${platform}" | cut -d' ' -f1)
if [ -z "$expected" ]; then
warn "Checksums not available, skipping verification"
return 0
fi
actual=$(compute_sha256 "$file")
if [ -z "$actual" ]; then
warn "No sha256 tool found, skipping verification"
return 0
fi
if [ "$expected" != "$actual" ]; then
error "Checksum mismatch!\n Expected: ${expected}\n Got: ${actual}"
fi
success "Checksum verified"
}
install() {
local platform version download_url tmp_file
platform=$(detect_platform)
info "Platform: ${CYAN}${platform}${NC}"
version=$(get_latest_version)
[ -z "$version" ] && error "Could not determine latest version"
info "Version: ${CYAN}v${version}${NC}"
download_url="https://github.com/${REPO}/releases/download/v${version}/claudemem-${platform}"
info "Downloading: ${download_url}"
tmp_file=$(mktemp)
curl -fsSL "$download_url" -o "$tmp_file" || error "Download failed"
verify_checksum "$tmp_file" "$version" "$platform"
mkdir -p "$INSTALL_DIR"
chmod +x "$tmp_file"
mv "$tmp_file" "${INSTALL_DIR}/claudemem"
success "Installed to ${INSTALL_DIR}/claudemem"
if [[ ":$PATH:" != *":${INSTALL_DIR}:"* ]]; then
warn "${INSTALL_DIR} is not in PATH"
echo ""
echo "Add to your shell config:"
echo " export PATH=\"\$PATH:${INSTALL_DIR}\""
fi
}
main() {
echo ""
echo -e "${CYAN}╔════════════════════════════════════════╗${NC}"
echo -e "${CYAN}║${NC} ${GREEN}claudemem${NC} installer ${CYAN}║${NC}"
echo -e "${CYAN}║${NC} Local code indexing for Claude ${CYAN}║${NC}"
echo -e "${CYAN}╚════════════════════════════════════════╝${NC}"
echo ""
command -v curl &>/dev/null || error "curl is required"
install
echo ""
success "Installation complete!"
echo ""
echo "Quick start:"
echo " ${CYAN}claudemem init${NC} # Set up API key"
echo " ${CYAN}claudemem index${NC} # Index your codebase"
echo " ${CYAN}claudemem search \"...\"${NC} # Search code"
echo ""
echo "MCP server (Claude Code integration):"
echo " ${CYAN}claudemem --mcp${NC}"
echo ""
}
main "$@"