-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·351 lines (297 loc) · 11 KB
/
install.sh
File metadata and controls
executable file
·351 lines (297 loc) · 11 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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
#!/usr/bin/env bash
set -euo pipefail
# Claude Code Power Stack - Installer
# https://github.com/bluzername/claude-code-power-stack
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CLAUDE_DIR="${HOME}/.claude"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
info() { echo -e "${BLUE}[INFO]${NC} $*"; }
ok() { echo -e "${GREEN}[OK]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
fail() { echo -e "${RED}[FAIL]${NC} $*"; }
echo ""
echo "======================================"
echo " Claude Code Power Stack - Installer"
echo "======================================"
echo ""
# ------------------------------------------
# Pre-flight checks
# ------------------------------------------
MISSING=0
if ! command -v claude &>/dev/null; then
fail "Claude Code CLI not found. Install it first: https://docs.anthropic.com/en/docs/claude-code"
MISSING=1
fi
if ! command -v go &>/dev/null && ! command -v brew &>/dev/null; then
fail "Neither Go nor Homebrew found. Need one to install Ghost."
MISSING=1
fi
if ! command -v uv &>/dev/null && ! command -v pip &>/dev/null; then
fail "Neither uv nor pip found. Need one to install cc-conversation-search."
MISSING=1
fi
if ! command -v ollama &>/dev/null; then
fail "Ollama not found. Ghost requires Ollama for embeddings."
fail " Install: https://ollama.com/ or brew install ollama"
MISSING=1
fi
if [ "$MISSING" -eq 1 ]; then
echo ""
fail "Missing prerequisites. Install them and re-run."
exit 1
fi
if [ ! -d "$CLAUDE_DIR" ]; then
fail "Claude Code config directory not found at $CLAUDE_DIR"
fail "Run Claude Code at least once first."
exit 1
fi
ok "Prerequisites check passed"
echo ""
# ------------------------------------------
# Step 1: Install Ghost
# ------------------------------------------
echo "--- Step 1/6: Ghost (persistent memory) ---"
if command -v ghost &>/dev/null; then
ok "Ghost already installed: $(ghost --version 2>/dev/null || echo 'unknown version')"
else
if command -v go &>/dev/null; then
info "Installing Ghost via Go..."
go install github.com/wcatz/ghost/cmd/ghost@latest
# Add to PATH if needed
GHOST_BIN="$(go env GOPATH)/bin/ghost"
if [ -f "$GHOST_BIN" ] && ! command -v ghost &>/dev/null; then
if [ -d "/opt/homebrew/bin" ]; then
ln -sf "$GHOST_BIN" /opt/homebrew/bin/ghost
elif [ -d "/usr/local/bin" ]; then
ln -sf "$GHOST_BIN" /usr/local/bin/ghost
else
warn "Ghost installed at $GHOST_BIN but not on PATH."
warn "Add $(go env GOPATH)/bin to your PATH."
fi
fi
elif command -v brew &>/dev/null; then
info "Installing Ghost via Homebrew..."
brew install wcatz/tap/ghost
fi
if command -v ghost &>/dev/null; then
ok "Ghost installed: $(ghost --version 2>/dev/null || echo 'ok')"
else
fail "Ghost installation failed. Install manually:"
fail " go install github.com/wcatz/ghost/cmd/ghost@latest"
fail " OR brew install wcatz/tap/ghost"
fi
fi
echo ""
# ------------------------------------------
# Step 2: Ensure Ollama + embedding model
# ------------------------------------------
echo "--- Step 2/7: Ollama + embedding model (required by Ghost) ---"
# Check if Ollama server is running
if ! curl -s http://localhost:11434/api/tags &>/dev/null; then
info "Ollama server not running. Starting it..."
ollama serve &>/dev/null &
sleep 2
if curl -s http://localhost:11434/api/tags &>/dev/null; then
ok "Ollama server started"
else
warn "Could not start Ollama. Start it manually: ollama serve"
warn "Ghost will not work without Ollama running."
fi
else
ok "Ollama server is running"
fi
# Pull the embedding model Ghost needs
if curl -s http://localhost:11434/api/tags 2>/dev/null | grep -q "nomic-embed-text"; then
ok "nomic-embed-text model already available"
else
info "Pulling nomic-embed-text model (Ghost needs this for embeddings)..."
if ollama pull nomic-embed-text 2>&1; then
ok "nomic-embed-text model ready"
else
warn "Could not pull nomic-embed-text. Run manually: ollama pull nomic-embed-text"
fi
fi
echo ""
# ------------------------------------------
# Step 3: Register Ghost MCP
# ------------------------------------------
echo "--- Step 3/7: Register Ghost with Claude Code ---"
if command -v ghost &>/dev/null; then
GHOST_PATH="$(command -v ghost)"
# Remove any existing ghost registration to avoid conflicts.
# ghost mcp init and claude mcp add can write to different scopes
# (project vs user), causing ghost to appear registered but not
# actually show up in claude mcp list.
claude mcp remove ghost -s user 2>/dev/null || true
claude mcp remove ghost -s project 2>/dev/null || true
info "Registering Ghost MCP via claude mcp add..."
if claude mcp add ghost -s user -- "$GHOST_PATH" mcp 2>&1; then
ok "Ghost MCP registered (command: $GHOST_PATH mcp)"
else
warn "claude mcp add failed. Trying ghost mcp init as fallback..."
if ghost mcp init 2>&1; then
ok "Ghost MCP registered via ghost mcp init"
else
fail "Could not register Ghost MCP. Register manually:"
fail " claude mcp add ghost -s user -- $GHOST_PATH mcp"
fi
fi
# Verify registration actually worked
if claude mcp list 2>&1 | grep -q "ghost"; then
ok "Ghost confirmed in claude mcp list"
else
warn "Ghost not visible in claude mcp list. You may need to restart Claude Code."
warn "If still missing, run: claude mcp add ghost -s user -- $GHOST_PATH mcp"
fi
else
warn "Ghost not on PATH - skipping MCP registration"
fi
echo ""
# ------------------------------------------
# Step 3: Install cc-conversation-search
# ------------------------------------------
echo "--- Step 4/7: cc-conversation-search (cross-project search) ---"
if command -v cc-conversation-search &>/dev/null; then
ok "cc-conversation-search already installed"
else
if command -v uv &>/dev/null; then
info "Installing via uv..."
uv tool install cc-conversation-search
elif command -v pip &>/dev/null; then
info "Installing via pip..."
pip install cc-conversation-search
fi
if command -v cc-conversation-search &>/dev/null; then
ok "cc-conversation-search installed"
else
fail "Installation failed. Install manually:"
fail " uv tool install cc-conversation-search"
fi
fi
if command -v cc-conversation-search &>/dev/null; then
info "Building conversation index (this may take a minute)..."
cc-conversation-search init 2>&1 | tail -3
ok "Conversation index built"
fi
echo ""
# ------------------------------------------
# Step 4: Copy commands, skills, and rules
# ------------------------------------------
echo "--- Step 5/7: Commands, skills, and rules ---"
# Commands (install all .md files from commands/)
mkdir -p "$CLAUDE_DIR/commands"
cmd_count=0
for cmd_file in "$SCRIPT_DIR"/commands/*.md; do
[ -f "$cmd_file" ] || continue
cp "$cmd_file" "$CLAUDE_DIR/commands/"
ok "Installed /$(basename "${cmd_file%.md}") command"
((cmd_count++))
done
if [ "$cmd_count" -eq 0 ]; then
warn "No commands found in repo"
fi
# Skills
mkdir -p "$CLAUDE_DIR/skills"
if [ -d "$SCRIPT_DIR/skills/planning-with-files" ]; then
cp -r "$SCRIPT_DIR/skills/planning-with-files" "$CLAUDE_DIR/skills/"
ok "Installed planning-with-files skill"
else
warn "skills/planning-with-files not found in repo"
fi
# Rules
mkdir -p "$CLAUDE_DIR/rules/common"
if [ -f "$SCRIPT_DIR/rules/session-naming.md" ]; then
cp "$SCRIPT_DIR/rules/session-naming.md" "$CLAUDE_DIR/rules/common/"
ok "Installed session-naming rule"
else
warn "rules/session-naming.md not found in repo"
fi
echo ""
# ------------------------------------------
# Step 5: Install ccs shortcut
# ------------------------------------------
echo "--- Step 6/7: ccs shortcut (search in 3 keystrokes) ---"
if [ -f "$SCRIPT_DIR/bin/ccs" ]; then
if [ -d "/opt/homebrew/bin" ]; then
cp "$SCRIPT_DIR/bin/ccs" /opt/homebrew/bin/ccs
chmod +x /opt/homebrew/bin/ccs
ok "Installed ccs to /opt/homebrew/bin/ccs"
elif [ -d "/usr/local/bin" ]; then
cp "$SCRIPT_DIR/bin/ccs" /usr/local/bin/ccs
chmod +x /usr/local/bin/ccs
ok "Installed ccs to /usr/local/bin/ccs"
else
mkdir -p "$HOME/.local/bin"
cp "$SCRIPT_DIR/bin/ccs" "$HOME/.local/bin/ccs"
chmod +x "$HOME/.local/bin/ccs"
ok "Installed ccs to ~/.local/bin/ccs"
warn "Make sure ~/.local/bin is on your PATH"
fi
# Save repo path so ccs update can find it
echo "$SCRIPT_DIR" > "$HOME/.ccs_repo_path"
ok "Saved repo path for ccs update"
else
warn "bin/ccs not found in repo"
fi
# Install shell completions
if [ -d "$SCRIPT_DIR/completions" ]; then
SHELL_NAME="$(basename "$SHELL")"
if [ "$SHELL_NAME" = "zsh" ]; then
ZSH_COMP_DIR="${HOME}/.zsh/completions"
mkdir -p "$ZSH_COMP_DIR"
cp "$SCRIPT_DIR/completions/_ccs" "$ZSH_COMP_DIR/_ccs"
ok "Installed zsh completions (restart shell or run: autoload -Uz compinit && compinit)"
elif [ "$SHELL_NAME" = "bash" ]; then
BASH_COMP_DIR="${HOME}/.local/share/bash-completion/completions"
mkdir -p "$BASH_COMP_DIR"
cp "$SCRIPT_DIR/completions/ccs.bash" "$BASH_COMP_DIR/ccs"
ok "Installed bash completions (restart shell to activate)"
fi
fi
echo ""
# ------------------------------------------
# Step 6: Update CLAUDE.md
# ------------------------------------------
echo "--- Step 7/7: Update CLAUDE.md ---"
CLAUDE_MD="$CLAUDE_DIR/CLAUDE.md"
SNIPPET="$SCRIPT_DIR/templates/claude-md-snippet.md"
if [ -f "$SNIPPET" ]; then
if [ -f "$CLAUDE_MD" ]; then
if grep -q "Memory & Context System" "$CLAUDE_MD" 2>/dev/null; then
ok "CLAUDE.md already contains Memory & Context System section"
else
echo "" >> "$CLAUDE_MD"
cat "$SNIPPET" >> "$CLAUDE_MD"
ok "Added Memory & Context System section to CLAUDE.md"
fi
else
cp "$SNIPPET" "$CLAUDE_MD"
ok "Created CLAUDE.md with Memory & Context System section"
fi
else
warn "templates/claude-md-snippet.md not found - skipping CLAUDE.md update"
fi
echo ""
echo "======================================"
echo " Installation complete!"
echo "======================================"
echo ""
echo "Next steps:"
echo " 1. Restart Claude Code to activate Ghost MCP"
echo " 2. Run ./verify.sh to confirm everything works"
echo " 3. Start a session and try: /rename-session"
echo " 4. For complex tasks, try: /plan"
echo ""
echo "Quick reference:"
echo " Search sessions: ccs <query>"
echo " Search last week: ccs <query> -d 7"
echo " List recent: ccs ls"
echo " Resume session: ccs go <session-id>"
echo " Re-index: ccs ix"
echo " Ghost health: ghost mcp status"
echo ""