forked from fwornle/coding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·279 lines (241 loc) · 10.7 KB
/
uninstall.sh
File metadata and controls
executable file
·279 lines (241 loc) · 10.7 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
#!/bin/bash
# Coding Tools System - Uninstall Script
# Removes installations but preserves data
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
CODING_REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo -e "${YELLOW}🗑️ Coding Tools System - Uninstaller${NC}"
echo -e "${YELLOW}=========================================${NC}"
echo ""
echo -e "${RED}⚠️ WARNING: This will remove installed components${NC}"
echo -e "${GREEN}✅ Your knowledge data (.data/knowledge-graph/ and .data/knowledge-export/) will be preserved${NC}"
echo ""
read -p "Continue with uninstall? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Uninstall cancelled."
exit 0
fi
echo -e "\n${BLUE}🔧 Removing shell configuration...${NC}"
# Remove from common shell configs
for rc_file in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.bash_profile"; do
if [[ -f "$rc_file" ]]; then
# Remove old Claude Knowledge Management System entries
sed -i '/# Claude Knowledge Management System/,+3d' "$rc_file" 2>/dev/null || true
# Remove new Coding Tools entries
sed -i '/# Coding Tools - Start/,/# Coding Tools - End/d' "$rc_file" 2>/dev/null || true
# Remove any CODING_TOOLS_PATH or CODING_REPO entries
sed -i '/CODING_TOOLS_PATH/d' "$rc_file" 2>/dev/null || true
sed -i '/CODING_REPO/d' "$rc_file" 2>/dev/null || true
# Remove team configuration
sed -i '/# Coding Tools - Team Configuration/,+1d' "$rc_file" 2>/dev/null || true
sed -i '/CODING_TEAM/d' "$rc_file" 2>/dev/null || true
# Remove any PATH additions for coding tools
sed -i '/knowledge-management.*coding/d' "$rc_file" 2>/dev/null || true
echo " Cleaned $rc_file"
fi
done
echo -e "\n${BLUE}🗑️ Removing installed components...${NC}"
# Remove bin directory
if [[ -d "$CODING_REPO/bin" ]]; then
rm -rf "$CODING_REPO/bin"
echo " Removed bin directory"
fi
# Clean memory-visualizer (git submodule - preserve source)
if [[ -d "$CODING_REPO/integrations/memory-visualizer" ]]; then
echo " Cleaning memory-visualizer (git submodule)..."
rm -rf "$CODING_REPO/integrations/memory-visualizer/node_modules"
rm -rf "$CODING_REPO/integrations/memory-visualizer/dist"
echo " Removed build artifacts (source code preserved)"
fi
# Clean mcp-server-browserbase (git submodule - preserve source)
if [[ -d "$CODING_REPO/integrations/mcp-server-browserbase" ]]; then
echo " Cleaning mcp-server-browserbase (git submodule)..."
rm -rf "$CODING_REPO/integrations/mcp-server-browserbase/node_modules"
rm -rf "$CODING_REPO/integrations/mcp-server-browserbase/dist"
echo " Removed build artifacts (source code preserved)"
fi
# Clean semantic analysis MCP server (git submodule - preserve source)
if [[ -d "$CODING_REPO/integrations/mcp-server-semantic-analysis" ]]; then
echo " Cleaning semantic analysis MCP server (git submodule)..."
# Remove node_modules
if [[ -d "$CODING_REPO/integrations/mcp-server-semantic-analysis/node_modules" ]]; then
rm -rf "$CODING_REPO/integrations/mcp-server-semantic-analysis/node_modules"
echo " Removed Node.js dependencies"
fi
# Remove built dist directory
if [[ -d "$CODING_REPO/integrations/mcp-server-semantic-analysis/dist" ]]; then
rm -rf "$CODING_REPO/integrations/mcp-server-semantic-analysis/dist"
echo " Removed built TypeScript files"
fi
# Remove logs directory
if [[ -d "$CODING_REPO/integrations/mcp-server-semantic-analysis/logs" ]]; then
rm -rf "$CODING_REPO/integrations/mcp-server-semantic-analysis/logs"
echo " Removed semantic analysis logs"
fi
echo " Git submodule source code preserved"
fi
# Clean Serena MCP server (git submodule - preserve source)
if [[ -d "$CODING_REPO/integrations/serena" ]]; then
echo " Cleaning Serena MCP server (git submodule)..."
# Remove .venv directory (uv virtual environment)
if [[ -d "$CODING_REPO/integrations/serena/.venv" ]]; then
rm -rf "$CODING_REPO/integrations/serena/.venv"
echo " Removed Python virtual environment"
fi
# Remove __pycache__ directories
find "$CODING_REPO/integrations/serena" -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
echo " Removed Python cache files"
# Remove .pyc files
find "$CODING_REPO/integrations/serena" -name "*.pyc" -type f -exec rm -f {} + 2>/dev/null || true
# Remove uv.lock file
if [[ -f "$CODING_REPO/integrations/serena/uv.lock" ]]; then
rm -f "$CODING_REPO/integrations/serena/uv.lock"
echo " Removed uv lock file"
fi
echo " Git submodule source code preserved"
fi
# Clean up node_modules in MCP servers (non-submodules)
for dir in "integrations/browser-access"; do
if [[ -d "$CODING_REPO/$dir/node_modules" ]]; then
rm -rf "$CODING_REPO/$dir/node_modules"
echo " Removed $dir/node_modules"
fi
if [[ -d "$CODING_REPO/$dir/dist" ]]; then
rm -rf "$CODING_REPO/$dir/dist"
echo " Removed $dir/dist"
fi
done
# Note: memory-visualizer and mcp-server-semantic-analysis are git submodules
# and have already been cleaned above
# Remove .coding-tools directory
if [[ -d "$HOME/.coding-tools" ]]; then
rm -rf "$HOME/.coding-tools"
echo " Removed ~/.coding-tools"
fi
# Remove logs
rm -f "$CODING_REPO/install.log" 2>/dev/null || true
# ukb removed - no temp logs to clean
rm -f /tmp/vkb-server.* 2>/dev/null || true
# Remove MCP configuration files
echo -e "\n${BLUE}🔧 Removing MCP configuration files...${NC}"
rm -f "$CODING_REPO/claude-code-mcp-processed.json" 2>/dev/null || true
# Remove user-level MCP configuration (optional - ask user)
echo ""
read -p "Remove user-level MCP configuration? This affects all projects using Claude Code. (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
USER_MCP_CONFIG="$HOME/.config/claude-code-mcp.json"
if [[ -f "$USER_MCP_CONFIG" ]]; then
rm -f "$USER_MCP_CONFIG"
echo " Removed user-level MCP configuration"
fi
# Remove from Claude app directory
if [[ "$OSTYPE" == "darwin"* ]]; then
CLAUDE_CONFIG_DIR="$HOME/Library/Application Support/Claude"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
CLAUDE_CONFIG_DIR="$HOME/.config/Claude"
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
CLAUDE_CONFIG_DIR="${APPDATA:-$HOME/AppData/Roaming}/Claude"
fi
if [[ -n "$CLAUDE_CONFIG_DIR" ]] && [[ -f "$CLAUDE_CONFIG_DIR/claude-code-mcp.json" ]]; then
rm -f "$CLAUDE_CONFIG_DIR/claude-code-mcp.json"
echo " Removed Claude app MCP configuration"
fi
else
echo " Keeping user-level MCP configuration"
fi
# Remove constraint monitor and LSL hooks
echo -e "\n${BLUE}🔗 Removing Hooks (Constraints + LSL)...${NC}"
SETTINGS_FILE="$HOME/.claude/settings.json"
if [[ ! -f "$SETTINGS_FILE" ]]; then
echo " No settings file found - hooks already removed"
else
# Check if jq is available
if ! command -v jq >/dev/null 2>&1; then
echo -e "${YELLOW} ⚠️ jq not found - cannot automatically remove hooks${NC}"
echo " Please manually edit: $SETTINGS_FILE"
echo " Remove PreToolUse hooks containing 'pre-tool-hook-wrapper.js'"
echo " Remove PostToolUse hooks containing 'tool-interaction-hook-wrapper.js'"
else
# Backup settings file
BACKUP_FILE="${SETTINGS_FILE}.backup.$(date +%Y%m%d_%H%M%S)"
cp "$SETTINGS_FILE" "$BACKUP_FILE"
echo " Backed up settings to: $BACKUP_FILE"
# Remove both PreToolUse and PostToolUse hooks
TEMP_FILE=$(mktemp)
jq 'if .hooks.PreToolUse then
.hooks.PreToolUse = [
.hooks.PreToolUse[] |
select(.hooks[]?.command | contains("pre-tool-hook-wrapper.js") | not)
]
else . end |
if .hooks.PreToolUse == [] then
del(.hooks.PreToolUse)
else . end |
if .hooks.PostToolUse then
.hooks.PostToolUse = [
.hooks.PostToolUse[] |
select(.hooks[]?.command | contains("tool-interaction-hook-wrapper.js") | not)
]
else . end |
if .hooks.PostToolUse == [] then
del(.hooks.PostToolUse)
else . end' "$SETTINGS_FILE" > "$TEMP_FILE"
# Validate and apply
if jq empty "$TEMP_FILE" 2>/dev/null; then
mv "$TEMP_FILE" "$SETTINGS_FILE"
echo " ✅ Removed PreToolUse and PostToolUse hooks from settings"
else
rm -f "$TEMP_FILE"
echo -e "${RED} ❌ Failed to update settings - JSON validation failed${NC}"
echo " Original settings preserved in: $BACKUP_FILE"
fi
fi
fi
echo -e "\n${BLUE}🗑️ Removing knowledge databases...${NC}"
# Remove .data directory with database files (optional - ask user)
if [[ -d "$CODING_REPO/.data" ]]; then
echo ""
read -p "Remove .data directory (contains SQLite knowledge database)? This will delete all learning history. (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf "$CODING_REPO/.data"
echo " Removed .data directory"
else
echo -e "${GREEN} Kept .data directory with knowledge database${NC}"
fi
fi
# Inform about Qdrant collections
echo -e "\n${YELLOW}ℹ️ Note about Qdrant collections:${NC}"
echo " If you were using Qdrant for vector search, you may want to remove collections:"
echo " docker exec qdrant-container /bin/sh -c \"rm -rf /qdrant/storage/collections/knowledge_*\""
echo " Or stop the Qdrant container:"
echo " docker stop qdrant-container"
echo -e "\n${GREEN}✅ Uninstall completed!${NC}"
echo -e "${GREEN}📊 Your knowledge data preservation status:${NC}"
# Check for GraphDB and knowledge exports
if [[ -d "$CODING_REPO/.data/knowledge-graph" ]]; then
echo " $CODING_REPO/.data/knowledge-graph/ - PRESERVED (GraphDB)"
fi
if [[ -d "$CODING_REPO/.data/knowledge-export" ]]; then
EXPORT_FILES=$(find "$CODING_REPO/.data/knowledge-export" -name "*.json" 2>/dev/null || true)
if [[ -n "$EXPORT_FILES" ]]; then
echo -e "${GREEN}📊 Knowledge export files preserved:${NC}"
echo "$EXPORT_FILES" | while read -r file; do
[[ -n "$file" ]] && echo " $(basename "$file")"
done
fi
fi
if [[ -d "$CODING_REPO/.data" ]]; then
echo -e "${GREEN}📊 Knowledge database preserved:${NC}"
echo " $CODING_REPO/.data/knowledge.db (SQLite database with learning history)"
fi
echo ""
echo "To reinstall, run: ./install.sh"
echo "Your team configuration will need to be set up again during installation."