-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathuninstall.ps1
More file actions
298 lines (260 loc) · 11.1 KB
/
Copy pathuninstall.ps1
File metadata and controls
298 lines (260 loc) · 11.1 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
# Lucid Memory Uninstaller for Windows
#
# One-liner uninstall (run in PowerShell):
# irm https://lucidmemory.dev/uninstall.ps1 | iex
#
# What this does:
# 1. Removes ~/.lucid directory
# 2. Removes MCP server config from Claude Code
# 3. Removes hooks from Claude Code
# 4. Removes PATH entry
# 5. Removes downloaded models
$ErrorActionPreference = "Stop"
# Catch unhandled errors so the window doesn't close before users can read them
trap {
Write-Host ""
Write-Host "Error: $_" -ForegroundColor Red
Write-Host ""
Read-Host "Press Enter to close"
break
}
# Enable ANSI colors in Windows Terminal (PS 7+ only)
if ($PSVersionTable.PSVersion.Major -ge 7) { $PSStyle.OutputRendering = 'Ansi' }
# Colors
$e = [char]27
$C1 = "$e[38;5;99m"
$C2 = "$e[38;5;105m"
$C3 = "$e[38;5;111m"
$C4 = "$e[38;5;117m"
$C5 = "$e[38;5;123m"
$C6 = "$e[38;5;159m"
$NC = "$e[0m"
$DIM = "$e[2m"
$GREEN = "$e[0;32m"
$YELLOW = "$e[1;33m"
$BOLD = "$e[1m"
function Write-Success { param($Message) Write-Host " ${GREEN}✓${NC} $Message" }
function Write-Warn { param($Message) Write-Host " ${YELLOW}⚠${NC} $Message" }
function Write-Info { param($Message) Write-Host " ${DIM}→${NC} $Message" }
function Show-Banner {
Write-Host ""
Write-Host "${C1} ██╗ ██╗ ██╗ ██████╗██╗██████╗ ${NC}"
Write-Host "${C2} ██║ ██║ ██║██╔════╝██║██╔══██╗${NC}"
Write-Host "${C3} ██║ ██║ ██║██║ ██║██║ ██║${NC}"
Write-Host "${C4} ██║ ██║ ██║██║ ██║██║ ██║${NC}"
Write-Host "${C5} ███████╗╚██████╔╝╚██████╗██║██████╔╝${NC}"
Write-Host "${C6} ╚══════╝ ╚═════╝ ╚═════╝╚═╝╚═════╝ ${NC}"
Write-Host " ${C3}M ${C4}E ${C5}M ${C6}O ${C5}R ${C4}Y${NC}"
Write-Host ""
Write-Host " ${DIM}Uninstaller${NC}"
Write-Host ""
}
Show-Banner
$LucidDir = "$env:USERPROFILE\.lucid"
$ClaudeSettingsDir = "$env:USERPROFILE\.claude"
# Claude Code uses ~/.claude.json for MCP servers
$McpConfig = "$env:USERPROFILE\.claude.json"
# Codex uses ~/.codex/config.toml
$CodexDir = "$env:USERPROFILE\.codex"
$CodexConfig = "$CodexDir\config.toml"
# OpenCode uses ~/.config/opencode/opencode.json
$OpenCodeConfigDir = "$env:USERPROFILE\.config\opencode"
$OpenCodeConfig = "$OpenCodeConfigDir\opencode.json"
# Check if Lucid is installed
if (-not (Test-Path $LucidDir)) {
Write-Host " ${YELLOW}Lucid Memory is not installed.${NC}"
Write-Host ""
return
}
# === Show removal summary ===
$RemoveList = @()
$RemoveList += " ${C4}•${NC} ~/.lucid directory (server, models, database)"
if ((Test-Path $McpConfig) -and (Select-String -Path $McpConfig -Pattern "lucid-memory" -Quiet)) {
$RemoveList += " ${C4}•${NC} MCP server config from ~/.claude.json"
}
$ClaudeSettings = "$ClaudeSettingsDir\settings.json"
if ((Test-Path $ClaudeSettings) -and (Select-String -Path $ClaudeSettings -Pattern "UserPromptSubmit" -Quiet)) {
$RemoveList += " ${C4}•${NC} Hook config from ~/.claude/settings.json"
}
if ((Test-Path $CodexConfig) -and (Select-String -Path $CodexConfig -Pattern "lucid-memory" -Quiet)) {
$RemoveList += " ${C4}•${NC} MCP server config from ~/.codex/config.toml"
}
if ((Test-Path $OpenCodeConfig) -and (Select-String -Path $OpenCodeConfig -Pattern "lucid-memory" -Quiet)) {
$RemoveList += " ${C4}•${NC} MCP server config from opencode.json"
}
if (Test-Path "$OpenCodeConfigDir\plugins\lucid-memory.ts") {
$RemoveList += " ${C4}•${NC} OpenCode plugin"
}
# Check for PATH entry
$LucidBin = "$LucidDir\bin"
$CurrentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($CurrentPath -like "*$LucidBin*") {
$RemoveList += " ${C4}•${NC} PATH entry"
}
Write-Host "${BOLD}The following will be removed:${NC}"
foreach ($item in $RemoveList) {
Write-Host $item
}
Write-Host ""
# Confirm uninstall
$Confirm = Read-Host " Continue with uninstall? [y/N]"
if ($Confirm -notmatch "^[Yy]$") {
Write-Host ""
Write-Host " ${DIM}Uninstall cancelled.${NC}"
Write-Host ""
return
}
Write-Host ""
# === Remove MCP Config ===
if (Test-Path $McpConfig) {
Write-Info "Removing MCP server config..."
try {
$Config = Get-Content $McpConfig -Raw | ConvertFrom-Json
if ($Config.mcpServers -and $Config.mcpServers.'lucid-memory') {
$Config.mcpServers.PSObject.Properties.Remove('lucid-memory')
$Utf8NoBom = New-Object System.Text.UTF8Encoding $false
[System.IO.File]::WriteAllText($McpConfig, ($Config | ConvertTo-Json -Depth 10), $Utf8NoBom)
}
Write-Success "MCP server config removed"
} catch {
Write-Warn "Could not edit MCP config - please remove 'lucid-memory' manually"
}
}
# === Remove Codex Config ===
if (Test-Path $CodexConfig) {
if (Select-String -Path $CodexConfig -Pattern '^\[mcp_servers\.lucid-memory\]' -Quiet) {
Write-Info "Removing Codex MCP configuration..."
$Lines = Get-Content $CodexConfig
$NewLines = @()
$Skip = $false
foreach ($line in $Lines) {
if ($line -match '^\[mcp_servers\.lucid-memory\]') { $Skip = $true; continue }
if ($line -match '^\[' -and $Skip) { $Skip = $false }
if (-not $Skip) { $NewLines += $line }
}
$NewLines | Set-Content $CodexConfig
Write-Success "Codex MCP config removed"
}
if (Select-String -Path $CodexConfig -Pattern "codex-notify" -Quiet) {
$Lines = Get-Content $CodexConfig | Where-Object { $_ -notmatch "codex-notify" }
$Lines | Set-Content $CodexConfig
Write-Success "Codex notify hook removed"
}
}
# === Remove OpenCode Config ===
if ((Test-Path $OpenCodeConfig) -and (Select-String -Path $OpenCodeConfig -Pattern "lucid-memory" -Quiet)) {
Write-Info "Removing OpenCode MCP configuration..."
try {
$OcConfig = Get-Content $OpenCodeConfig -Raw | ConvertFrom-Json
if ($OcConfig.mcp -and $OcConfig.mcp.'lucid-memory') {
$OcConfig.mcp.PSObject.Properties.Remove('lucid-memory')
$Utf8NoBom = New-Object System.Text.UTF8Encoding $false
[System.IO.File]::WriteAllText($OpenCodeConfig, ($OcConfig | ConvertTo-Json -Depth 10), $Utf8NoBom)
}
Write-Success "OpenCode MCP config removed"
} catch {
Write-Warn "Could not edit OpenCode config - please remove 'lucid-memory' manually"
}
}
if (Test-Path "$OpenCodeConfigDir\plugins\lucid-memory.ts") {
Remove-Item -Force "$OpenCodeConfigDir\plugins\lucid-memory.ts"
Write-Success "OpenCode plugin removed"
}
# === Remove Hooks ===
# Remove hook configuration from settings.json
$ClaudeSettings = "$ClaudeSettingsDir\settings.json"
if (Test-Path $ClaudeSettings) {
Write-Info "Removing hook configuration..."
try {
$Config = Get-Content $ClaudeSettings -Raw | ConvertFrom-Json
if ($Config.hooks -and $Config.hooks.UserPromptSubmit) {
# Filter out only Lucid's hook entries, preserve others
$Remaining = @($Config.hooks.UserPromptSubmit | Where-Object {
$IsLucid = $false
if ($_.hooks) {
foreach ($h in $_.hooks) {
if ($h.command -and $h.command -match 'lucid|user-prompt-submit') { $IsLucid = $true }
}
}
-not $IsLucid
})
if ($Remaining.Count -eq 0) {
$Config.hooks.PSObject.Properties.Remove('UserPromptSubmit')
} else {
$Config.hooks.UserPromptSubmit = $Remaining
}
$Utf8NoBom = New-Object System.Text.UTF8Encoding $false
[System.IO.File]::WriteAllText($ClaudeSettings, ($Config | ConvertTo-Json -Depth 10), $Utf8NoBom)
}
Write-Success "Hook config removed from settings.json"
} catch {
Write-Warn "Could not remove hook config - please edit $ClaudeSettings manually"
}
}
# Remove old hook file location (legacy)
$OldHooksDir = "$ClaudeSettingsDir\hooks"
$OldHookFile = "$OldHooksDir\UserPromptSubmit.ps1"
if (Test-Path $OldHookFile) {
Remove-Item -Force $OldHookFile
}
# === Remove PATH Entry ===
Write-Info "Removing PATH entry..."
$LucidBin = "$LucidDir\bin"
$CurrentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($CurrentPath -like "*$LucidBin*") {
$NewPath = ($CurrentPath -split ";" | Where-Object { $_ -ne $LucidBin }) -join ";"
[Environment]::SetEnvironmentVariable("PATH", $NewPath, "User")
}
Write-Success "PATH entry removed"
# === Stop Running Server Processes ===
# Kill any Bun processes running Lucid Memory server/CLI files — these lock
# the ~/.lucid directory and prevent deletion.
# Use WMI for command line access (Get-Process lacks it in PS 5.1)
Get-CimInstance Win32_Process -Filter "Name = 'bun.exe'" -ErrorAction SilentlyContinue | Where-Object {
$_.CommandLine -like "*\.lucid*"
} | ForEach-Object {
Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue
}
Start-Sleep -Seconds 1
# === Remove Lucid Directory ===
Write-Info "Removing ~/.lucid directory..."
try {
Remove-Item -Recurse -Force $LucidDir
} catch {
# File may still be briefly locked — retry once
Write-Host " Waiting for file locks to release..." -ForegroundColor DarkGray
Start-Sleep -Seconds 3
try {
Remove-Item -Recurse -Force $LucidDir
} catch {
Write-Warn "Could not fully remove ~/.lucid — please delete it manually"
}
}
if (-not (Test-Path $LucidDir)) {
Write-Success "Lucid directory removed"
} else {
Write-Warn "Some files in ~/.lucid could not be removed"
}
# === Done ===
Write-Host ""
Write-Host "${C1} ██╗ ██╗ ██╗ ██████╗██╗██████╗ ${NC}"
Write-Host "${C2} ██║ ██║ ██║██╔════╝██║██╔══██╗${NC}"
Write-Host "${C3} ██║ ██║ ██║██║ ██║██║ ██║${NC}"
Write-Host "${C4} ██║ ██║ ██║██║ ██║██║ ██║${NC}"
Write-Host "${C5} ███████╗╚██████╔╝╚██████╗██║██████╔╝${NC}"
Write-Host "${C6} ╚══════╝ ╚═════╝ ╚═════╝╚═╝╚═════╝ ${NC}"
Write-Host " ${C3}M ${C4}E ${C5}M ${C6}O ${C5}R ${C4}Y${NC}"
Write-Host ""
Write-Host " ${GREEN}✓${NC} ${BOLD}Uninstalled Successfully${NC}"
Write-Host ""
Write-Host " ${DIM}Thank you for trying Lucid Memory!${NC}"
Write-Host ""
Write-Host " ${DIM}Note: The following dependencies may have been installed${NC}"
Write-Host " ${DIM}and can be removed manually if no longer needed:${NC}"
Write-Host ""
Write-Host " ${DIM} winget uninstall ffmpeg yt-dlp${NC}"
Write-Host " ${DIM} pip uninstall openai-whisper${NC}"
Write-Host ""
Write-Host " ${DIM}To reinstall:${NC}"
Write-Host " ${C4}irm https://lucidmemory.dev/install.ps1 | iex${NC}"
Write-Host ""