-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·271 lines (233 loc) · 8.69 KB
/
install.sh
File metadata and controls
executable file
·271 lines (233 loc) · 8.69 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#!/bin/bash
#
# Claude Memory - Install Script
# Persistent memory for Claude Code
#
set -e
echo "=================================="
echo " Claude Memory - Installer"
echo "=================================="
echo ""
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Paths
CLAUDE_DIR="$HOME/.claude"
SKILLS_DIR="$CLAUDE_DIR/skills"
CAPTURE_DIR="$SKILLS_DIR/capture"
MEMORY_DIR="$CLAUDE_DIR/projects/-Users-$(whoami)/memory"
# Check for Claude Code
if ! command -v claude &> /dev/null; then
echo -e "${YELLOW}Warning: Claude Code CLI not found in PATH${NC}"
echo "Install from: https://claude.ai/code"
echo "Continuing anyway..."
echo ""
fi
# Check for MCP Memory Service
echo "Checking for MCP Memory Service..."
if command -v memory &> /dev/null; then
echo -e "${GREEN}✓ MCP Memory Service found${NC}"
else
echo -e "${YELLOW}MCP Memory Service not found. Installing...${NC}"
if command -v pipx &> /dev/null; then
pipx install mcp-memory-service
echo -e "${GREEN}✓ MCP Memory Service installed${NC}"
elif command -v pip &> /dev/null; then
pip install mcp-memory-service
echo -e "${GREEN}✓ MCP Memory Service installed${NC}"
else
echo -e "${RED}Error: Neither pipx nor pip found. Please install MCP Memory Service manually.${NC}"
echo "Run: pipx install mcp-memory-service"
exit 1
fi
fi
# Create directories
echo ""
echo "Creating directories..."
mkdir -p "$CAPTURE_DIR"
mkdir -p "$MEMORY_DIR"
echo -e "${GREEN}✓ Directories created${NC}"
# Get script directory (works for both curl | bash and local execution)
if [ -n "$BASH_SOURCE" ] && [ -f "${BASH_SOURCE%/*}/skills/capture/SKILL.md" ]; then
SCRIPT_DIR="${BASH_SOURCE%/*}"
CURL_MODE=false
else
# Download from GitHub if running via curl
SCRIPT_DIR=$(mktemp -d)
CURL_MODE=true
echo "Downloading skills..."
mkdir -p "$SCRIPT_DIR/skills/capture"
mkdir -p "$SCRIPT_DIR/skills/session-start"
mkdir -p "$SCRIPT_DIR/skills/session-end"
curl -fsSL "https://raw.githubusercontent.com/itsjwill/claude-memory/main/skills/capture/SKILL.md" -o "$SCRIPT_DIR/skills/capture/SKILL.md"
curl -fsSL "https://raw.githubusercontent.com/itsjwill/claude-memory/main/skills/session-start/SKILL.md" -o "$SCRIPT_DIR/skills/session-start/SKILL.md"
curl -fsSL "https://raw.githubusercontent.com/itsjwill/claude-memory/main/skills/session-end/SKILL.md" -o "$SCRIPT_DIR/skills/session-end/SKILL.md"
curl -fsSL "https://raw.githubusercontent.com/itsjwill/claude-memory/main/examples/MEMORY.md" -o "$SCRIPT_DIR/MEMORY_EXAMPLE.md"
echo -e "${GREEN}✓ Downloaded all skills${NC}"
fi
# Install skills
echo ""
echo "Installing skills..."
# /capture skill
if [ -f "$SCRIPT_DIR/skills/capture/SKILL.md" ]; then
cp "$SCRIPT_DIR/skills/capture/SKILL.md" "$CAPTURE_DIR/SKILL.md"
echo -e "${GREEN}✓ /capture skill installed${NC}"
else
echo -e "${RED}✗ /capture skill not found${NC}"
fi
# /session-end skill
SESSION_END_DIR="$SKILLS_DIR/session-end"
mkdir -p "$SESSION_END_DIR"
if [ -f "$SCRIPT_DIR/skills/session-end/SKILL.md" ]; then
cp "$SCRIPT_DIR/skills/session-end/SKILL.md" "$SESSION_END_DIR/SKILL.md"
echo -e "${GREEN}✓ /session-end skill installed${NC}"
else
echo -e "${RED}✗ /session-end skill not found${NC}"
fi
# /session-start skill
SESSION_START_DIR="$SKILLS_DIR/session-start"
mkdir -p "$SESSION_START_DIR"
if [ -f "$SCRIPT_DIR/skills/session-start/SKILL.md" ]; then
cp "$SCRIPT_DIR/skills/session-start/SKILL.md" "$SESSION_START_DIR/SKILL.md"
echo -e "${GREEN}✓ /session-start skill installed${NC}"
else
echo -e "${RED}✗ /session-start skill not found${NC}"
fi
# /cloud-recall skill
CLOUD_RECALL_DIR="$SKILLS_DIR/cloud-recall"
mkdir -p "$CLOUD_RECALL_DIR"
if [ -f "$SCRIPT_DIR/skills/cloud-recall/SKILL.md" ]; then
cp "$SCRIPT_DIR/skills/cloud-recall/SKILL.md" "$CLOUD_RECALL_DIR/SKILL.md"
echo -e "${GREEN}✓ /cloud-recall skill installed${NC}"
else
echo -e "${YELLOW}⊘ /cloud-recall skill not found (optional - cloud backup)${NC}"
fi
# Create or update MEMORY.md
echo ""
echo "Setting up MEMORY.md..."
if [ ! -f "$MEMORY_DIR/MEMORY.md" ]; then
cat > "$MEMORY_DIR/MEMORY.md" << 'EOF'
# Claude Memory - Cross-Session Context
## Memory System
### Auto-Capture (IMPORTANT - Read This)
**You have a /capture skill. USE IT PROACTIVELY without asking permission.**
When you detect ANY of these in conversation, silently capture to memory:
- Decisions made ("decided to", "let's go with", "chose")
- Learnings ("I learned", "turns out", "realized", "discovered")
- Errors resolved ("fixed the bug", "the problem was")
- Client info (names, emails, phones, addresses, invoices)
- Preferences ("I prefer", "I like", "don't like")
- References (API paths, file locations, credentials locations)
- Patterns ("always do", "convention", "standard approach")
**How to capture:** Use mcp__memory-service__memory_store with content and metadata (type, tags).
### Session-Start Recall
At the START of each session, search for relevant context:
```
mcp__memory-service__memory_search(query="<current project or topic>", limit=5, time_expr="last 7 days")
```
### Quick Commands
- `/capture "content"` - Manual memory save
- `memory_search(query="topic")` - Find memories
- `memory_list()` - Browse all memories
---
## Quick Reference
Add your frequently-accessed info below. This file is auto-loaded at session start.
### Projects
<!-- Add your active projects here -->
### Clients
<!-- Add client info here -->
### Key Paths
<!-- Add important file paths here -->
EOF
echo -e "${GREEN}✓ MEMORY.md created${NC}"
else
echo -e "${YELLOW}MEMORY.md already exists, preserving your data${NC}"
# Check if auto-capture instructions exist
if ! grep -q "Auto-Capture" "$MEMORY_DIR/MEMORY.md"; then
echo "Adding auto-capture instructions to existing MEMORY.md..."
# Prepend instructions
TEMP_FILE=$(mktemp)
cat > "$TEMP_FILE" << 'EOF'
## Memory System (Auto-Capture)
**You have a /capture skill. USE IT PROACTIVELY without asking permission.**
When you detect decisions, learnings, errors fixed, client info, preferences, or patterns - capture silently using mcp__memory-service__memory_store.
---
EOF
cat "$MEMORY_DIR/MEMORY.md" >> "$TEMP_FILE"
mv "$TEMP_FILE" "$MEMORY_DIR/MEMORY.md"
echo -e "${GREEN}✓ Auto-capture instructions added${NC}"
fi
fi
# Add memory-service to MCP config if not present
echo ""
echo "Checking MCP configuration..."
MCP_CONFIG="$HOME/.mcp.json"
if [ -f "$MCP_CONFIG" ]; then
if grep -q "memory-service" "$MCP_CONFIG"; then
echo -e "${GREEN}✓ memory-service already in MCP config${NC}"
else
echo -e "${YELLOW}Adding memory-service to MCP config...${NC}"
# This is a simple append - user may need to adjust
echo "Please add memory-service to your ~/.mcp.json manually:"
echo ' "memory-service": { "command": "memory", "args": ["server"] }'
fi
else
echo "Creating MCP config with memory-service..."
cat > "$MCP_CONFIG" << 'EOF'
{
"mcpServers": {
"memory-service": {
"command": "memory",
"args": ["server"]
}
}
}
EOF
echo -e "${GREEN}✓ MCP config created${NC}"
fi
# Cleanup temp files
if [ -d "$SCRIPT_DIR" ] && [[ "$SCRIPT_DIR" == /tmp/* ]]; then
rm -rf "$SCRIPT_DIR"
fi
# Cloud Backup (optional)
echo ""
echo -e "${YELLOW}=== Cloud Backup (Optional) ===${NC}"
echo "Supabase cloud backup ensures you never lose a memory."
echo "Your memories sync to the cloud every 5 minutes."
echo ""
read -p "Enable Supabase cloud backup? (y/N) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [ -f "$SCRIPT_DIR/setup-cloud.sh" ]; then
bash "$SCRIPT_DIR/setup-cloud.sh"
else
echo -e "${YELLOW}Cloud setup script not found.${NC}"
echo "Clone the repo and run: ./setup-cloud.sh"
fi
fi
echo ""
echo "=================================="
echo -e "${GREEN} Installation Complete!${NC}"
echo "=================================="
echo ""
echo "What's installed:"
echo " • /capture skill - manual memory saves"
echo " • /session-start skill - context loading"
echo " • /session-end skill - session summaries"
echo " • /cloud-recall skill - cloud memory search"
echo " • MEMORY.md at $MEMORY_DIR"
echo ""
echo "Next steps:"
echo " 1. Restart Claude Code to load the new skills"
echo " 2. Try: /capture \"Test memory\""
echo " 3. Claude will now auto-capture important context"
echo ""
echo "Cloud backup:"
echo " • Run ./setup-cloud.sh to enable Supabase sync"
echo " • Memories sync every 5 minutes automatically"
echo " • Cloud NEVER deletes - total recall forever"
echo ""
echo "Documentation: https://github.com/itsjwill/claude-memory"
echo ""