feat: add uninstaller scripts for all tools + restore yolo mode

Uninstallers (.sh + .ps1) for Claude, Gemini, Codex, Qwen:
- Remove npm package / binary
- Remove settings directory (~/.gemini, ~/.qwen, ~/.codex, ~/.claude)
- Remove env vars from bashrc/zshrc, /etc/environment, /etc/profile.d
- Remove npm registry config

Also: restore defaultApprovalMode=yolo (npm package now includes
Target 9a patch in settingsSchema.js)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
delta-cloud-208e
2026-03-08 07:38:14 +00:00
parent 9de65c2151
commit a4632de6da
11 changed files with 567 additions and 5 deletions

View File

@@ -135,7 +135,7 @@ cat > ~/.gemini/settings.json << 'EOF'
"folderTrust": { "enabled": false } "folderTrust": { "enabled": false }
}, },
"telemetry": { "enabled": false, "logPrompts": false }, "telemetry": { "enabled": false, "logPrompts": false },
"general": { "defaultApprovalMode": "auto_edit" } "general": { "defaultApprovalMode": "yolo" }
} }
EOF EOF
``` ```
@@ -147,7 +147,7 @@ Then configure (Windows — run in **PowerShell**, not CMD):
$env:GEMINI_API_KEY = "ClauderAPI" $env:GEMINI_API_KEY = "ClauderAPI"
$env:GOOGLE_GEMINI_BASE_URL = "https://ai.37-187-136-86.sslip.io" $env:GOOGLE_GEMINI_BASE_URL = "https://ai.37-187-136-86.sslip.io"
$d = "$env:USERPROFILE\.gemini"; New-Item -ItemType Directory -Force -Path $d | Out-Null $d = "$env:USERPROFILE\.gemini"; New-Item -ItemType Directory -Force -Path $d | Out-Null
[System.IO.File]::WriteAllText("$d\settings.json", '{"security":{"auth":{"selectedType":"gemini-api-key"},"folderTrust":{"enabled":false}},"telemetry":{"enabled":false,"logPrompts":false},"general":{"defaultApprovalMode":"auto_edit"}}') [System.IO.File]::WriteAllText("$d\settings.json", '{"security":{"auth":{"selectedType":"gemini-api-key"},"folderTrust":{"enabled":false}},"telemetry":{"enabled":false,"logPrompts":false},"general":{"defaultApprovalMode":"yolo"}}')
``` ```
Or use CMD: Or use CMD:
@@ -155,7 +155,7 @@ Or use CMD:
setx GEMINI_API_KEY "ClauderAPI" setx GEMINI_API_KEY "ClauderAPI"
setx GOOGLE_GEMINI_BASE_URL "https://ai.37-187-136-86.sslip.io" setx GOOGLE_GEMINI_BASE_URL "https://ai.37-187-136-86.sslip.io"
mkdir "%USERPROFILE%\.gemini" 2>nul mkdir "%USERPROFILE%\.gemini" 2>nul
echo {"security":{"auth":{"selectedType":"gemini-api-key"},"folderTrust":{"enabled":false}},"telemetry":{"enabled":false,"logPrompts":false},"general":{"defaultApprovalMode":"auto_edit"}} > "%USERPROFILE%\.gemini\settings.json" echo {"security":{"auth":{"selectedType":"gemini-api-key"},"folderTrust":{"enabled":false}},"telemetry":{"enabled":false,"logPrompts":false},"general":{"defaultApprovalMode":"yolo"}} > "%USERPROFILE%\.gemini\settings.json"
``` ```
Verify: `gemini -p "Hello"` Verify: `gemini -p "Hello"`
@@ -268,6 +268,23 @@ cd unlimitedcoding
| Windows PowerShell | `powershell -ExecutionPolicy Bypass -File claude\releases\v2.1.71\install.ps1` | | Windows PowerShell | `powershell -ExecutionPolicy Bypass -File claude\releases\v2.1.71\install.ps1` |
<!-- MANUAL_VERSION:END --> <!-- MANUAL_VERSION:END -->
## Uninstall
Clone repo (if not already cloned):
```bash
git clone --depth 1 https://x-token:cadffcb0a6a3be728ac1ff619bb40c86588f6837@git.sensey24.ru/aibot777/unlimitedcoding.git
cd unlimitedcoding
```
| Tool | Linux / macOS | Windows (PowerShell) |
|------|---------------|----------------------|
| Claude Code | `sudo bash claude/uclaude_uninstall.sh` | `powershell -ExecutionPolicy Bypass -File claude\uclaude_uninstall.ps1` |
| Gemini CLI | `sudo bash gemini/ugemini_uninstall.sh` | `powershell -ExecutionPolicy Bypass -File gemini\ugemini_uninstall.ps1` |
| Codex CLI | `sudo bash codex/ucodex_uninstall.sh` | `powershell -ExecutionPolicy Bypass -File codex\ucodex_uninstall.ps1` |
| Qwen Code | `sudo bash qwen/uqwen_uninstall.sh` | `powershell -ExecutionPolicy Bypass -File qwen\uqwen_uninstall.ps1` |
Each uninstaller removes: binary/npm package, settings directory, environment variables, npm registry config.
## Troubleshooting ## Troubleshooting
### Gemini CLI: deprecated settings spam ### Gemini CLI: deprecated settings spam

View File

@@ -0,0 +1,51 @@
# Claude Code — Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File claude\uclaude_uninstall.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Claude Code -- Windows Uninstaller |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Uninstall npm package ----
Write-Host " Removing @anthropic-ai/claude-code..." -ForegroundColor Cyan
npm uninstall -g @anthropic-ai/claude-code 2>$null
Write-Host " npm package removed" -ForegroundColor Green
# ---- Remove settings ----
$claudeDir = "$env:USERPROFILE\.claude"
if (Test-Path $claudeDir) {
Write-Host " Removing $claudeDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $claudeDir
Write-Host " Settings removed" -ForegroundColor Green
}
$claudeJson = "$env:USERPROFILE\.claude.json"
if (Test-Path $claudeJson) {
Remove-Item -Force $claudeJson
Write-Host " Removed .claude.json" -ForegroundColor Green
}
# ---- Remove env vars ----
Write-Host " Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", $null, "User")
[System.Environment]::SetEnvironmentVariable("CLAUDE_CODE_USE_BEDROCK", $null, "User")
Remove-Item Env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:ANTHROPIC_BASE_URL -ErrorAction SilentlyContinue
Write-Host " Env vars removed" -ForegroundColor Green
# ---- Remove npm registry config ----
Write-Host " Removing npm registry config..." -ForegroundColor Cyan
npm config delete "@anthropic-ai:registry" 2>$null
Write-Host " Registry config removed" -ForegroundColor Green
Write-Host ""
Write-Host " Claude Code fully uninstalled!" -ForegroundColor Green
Write-Host ""

93
claude/uclaude_uninstall.sh Executable file
View File

@@ -0,0 +1,93 @@
#!/usr/bin/env bash
# Claude Code — Uninstaller
# Removes Claude Code CLI, settings, env vars, and npm registry config.
#
# Usage: sudo bash uclaude_uninstall.sh
set -euo pipefail
GREEN="\033[92m"
CYAN="\033[96m"
YELLOW="\033[93m"
BOLD="\033[1m"
RESET="\033[0m"
log() { echo -e "${GREEN}[+]${RESET} $*"; }
warn() { echo -e "${YELLOW}[~]${RESET} $*"; }
info() { echo -e "${CYAN}[i]${RESET} $*"; }
echo -e "${BOLD}"
echo " +--------------------------------------+"
echo " | Claude Code — Uninstaller |"
echo " +--------------------------------------+"
echo -e "${RESET}"
# ---- Uninstall npm package ----
if npm list -g @anthropic-ai/claude-code &>/dev/null 2>&1; then
info "Removing @anthropic-ai/claude-code..."
npm uninstall -g @anthropic-ai/claude-code 2>/dev/null || true
log "npm package removed"
else
warn "Claude Code not found in npm global packages"
fi
# ---- Remove settings ----
for user_home in /root /home/*; do
CLAUDE_DIR="$user_home/.claude"
if [ -d "$CLAUDE_DIR" ]; then
info "Removing $CLAUDE_DIR..."
rm -rf "$CLAUDE_DIR"
log "Removed $CLAUDE_DIR"
fi
CLAUDE_JSON="$user_home/.claude.json"
if [ -f "$CLAUDE_JSON" ]; then
rm -f "$CLAUDE_JSON"
log "Removed $CLAUDE_JSON"
fi
done
# ---- Remove env vars from shell rc files ----
for user_home in /root /home/*; do
for rc_file in "$user_home/.bashrc" "$user_home/.zshrc"; do
if [ -f "$rc_file" ] && grep -q 'ANTHROPIC_API_KEY\|CLAUDE_CODE\|Claude Code\|ANTHROPIC_BASE_URL' "$rc_file" 2>/dev/null; then
info "Cleaning env vars from $rc_file..."
sed -i '/# Claude Code/d' "$rc_file"
sed -i '/# UnlimitedCoding.*[Cc]laude/d' "$rc_file"
sed -i '/ANTHROPIC_API_KEY/d' "$rc_file"
sed -i '/ANTHROPIC_BASE_URL/d' "$rc_file"
sed -i '/CLAUDE_CODE/d' "$rc_file"
log "Cleaned $rc_file"
fi
done
done
# ---- Remove /etc/profile.d script ----
for f in /etc/profile.d/claude-code.sh /etc/profile.d/claude_code.sh; do
if [ -f "$f" ]; then
rm -f "$f"
log "Removed $f"
fi
done
# ---- Remove env vars from /etc/environment ----
if [ -f "/etc/environment" ] && grep -q 'ANTHROPIC_API_KEY\|ANTHROPIC_BASE_URL\|CLAUDE_CODE' /etc/environment 2>/dev/null; then
info "Cleaning /etc/environment..."
sed -i '/ANTHROPIC_API_KEY/d' /etc/environment
sed -i '/ANTHROPIC_BASE_URL/d' /etc/environment
sed -i '/CLAUDE_CODE/d' /etc/environment
log "Cleaned /etc/environment"
fi
# ---- Remove npm registry config ----
info "Removing npm registry config..."
npm config delete @anthropic-ai:registry 2>/dev/null || true
log "npm registry config removed"
echo ""
echo -e "${GREEN}${BOLD} Claude Code fully uninstalled!${RESET}"
echo ""

View File

@@ -0,0 +1,60 @@
# Codex CLI — Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File codex\ucodex_uninstall.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Codex CLI -- Windows Uninstaller |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Remove binary ----
$installDir = "$env:LOCALAPPDATA\Programs\codex"
if (Test-Path "$installDir\codex.exe") {
Write-Host " Stopping codex processes..." -ForegroundColor Cyan
Get-Process -Name "codex" -ErrorAction SilentlyContinue | Stop-Process -Force
Write-Host " Removing $installDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $installDir
Write-Host " Binary removed" -ForegroundColor Green
# Remove from PATH
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -like "*$installDir*") {
$newPath = ($userPath -split ";" | Where-Object { $_ -ne $installDir }) -join ";"
[System.Environment]::SetEnvironmentVariable("Path", $newPath, "User")
Write-Host " Removed from PATH" -ForegroundColor Green
}
} else {
Write-Host " Codex binary not found at $installDir" -ForegroundColor Yellow
# Check other common locations
$altPath = (Get-Command codex -ErrorAction SilentlyContinue).Source
if ($altPath) {
Write-Host " Found at: $altPath — remove manually" -ForegroundColor Yellow
}
}
# ---- Remove config ----
$codexDir = "$env:USERPROFILE\.codex"
if (Test-Path $codexDir) {
Write-Host " Removing $codexDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $codexDir
Write-Host " Config removed" -ForegroundColor Green
} else {
Write-Host " No config directory found" -ForegroundColor Yellow
}
# ---- Remove env vars ----
Write-Host " Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("OPENAI_BASE_URL", $null, "User")
Remove-Item Env:OPENAI_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:OPENAI_BASE_URL -ErrorAction SilentlyContinue
Write-Host " Env vars removed" -ForegroundColor Green
Write-Host ""
Write-Host " Codex CLI fully uninstalled!" -ForegroundColor Green
Write-Host ""

79
codex/ucodex_uninstall.sh Executable file
View File

@@ -0,0 +1,79 @@
#!/usr/bin/env bash
# Codex CLI — Uninstaller
# Removes Codex CLI binary, config, env vars.
#
# Usage: sudo bash ucodex_uninstall.sh
set -euo pipefail
GREEN="\033[92m"
CYAN="\033[96m"
YELLOW="\033[93m"
BOLD="\033[1m"
RESET="\033[0m"
log() { echo -e "${GREEN}[+]${RESET} $*"; }
warn() { echo -e "${YELLOW}[~]${RESET} $*"; }
info() { echo -e "${CYAN}[i]${RESET} $*"; }
echo -e "${BOLD}"
echo " +--------------------------------------+"
echo " | Codex CLI — Uninstaller |"
echo " +--------------------------------------+"
echo -e "${RESET}"
# ---- Remove binary ----
CODEX_PATH=$(which codex 2>/dev/null || echo "")
if [ -n "$CODEX_PATH" ]; then
info "Removing binary: $CODEX_PATH"
rm -f "$CODEX_PATH"
log "Binary removed"
else
warn "Codex binary not found in PATH"
fi
# ---- Remove config ----
for user_home in /root /home/*; do
CODEX_DIR="$user_home/.codex"
if [ -d "$CODEX_DIR" ]; then
info "Removing $CODEX_DIR..."
rm -rf "$CODEX_DIR"
log "Removed $CODEX_DIR"
fi
done
# ---- Remove env vars from shell rc files ----
for user_home in /root /home/*; do
for rc_file in "$user_home/.bashrc" "$user_home/.zshrc"; do
if [ -f "$rc_file" ] && grep -q 'OPENAI_API_KEY\|OPENAI_BASE_URL\|Codex' "$rc_file" 2>/dev/null; then
info "Cleaning env vars from $rc_file..."
sed -i '/# Codex/d' "$rc_file"
sed -i '/# UnlimitedCoding.*[Cc]odex/d' "$rc_file"
sed -i '/OPENAI_API_KEY/d' "$rc_file"
sed -i '/OPENAI_BASE_URL/d' "$rc_file"
log "Cleaned $rc_file"
fi
done
done
# ---- Remove env vars from /etc/environment ----
if [ -f "/etc/environment" ] && grep -q 'OPENAI_API_KEY\|OPENAI_BASE_URL' /etc/environment 2>/dev/null; then
info "Cleaning /etc/environment..."
sed -i '/OPENAI_API_KEY/d' /etc/environment
sed -i '/OPENAI_BASE_URL/d' /etc/environment
log "Cleaned /etc/environment"
fi
# ---- Remove /etc/profile.d script ----
if [ -f "/etc/profile.d/codex-cli.sh" ]; then
rm -f "/etc/profile.d/codex-cli.sh"
log "Removed /etc/profile.d/codex-cli.sh"
fi
echo ""
echo -e "${GREEN}${BOLD} Codex CLI fully uninstalled!${RESET}"
echo ""

View File

@@ -160,7 +160,7 @@ $json = @'
"logPrompts": false "logPrompts": false
}, },
"general": { "general": {
"defaultApprovalMode": "auto_edit" "defaultApprovalMode": "yolo"
} }
} }
'@ '@

View File

@@ -173,7 +173,7 @@ assert d.get('security',{}).get('auth',{}).get('selectedType') == 'gemini-api-ke
"folderTrust": { "enabled": false } "folderTrust": { "enabled": false }
}, },
"telemetry": { "enabled": false, "logPrompts": false }, "telemetry": { "enabled": false, "logPrompts": false },
"general": { "defaultApprovalMode": "auto_edit" } "general": { "defaultApprovalMode": "yolo" }
} }
SETTINGS_EOF SETTINGS_EOF
# Trust common folders # Trust common folders

View File

@@ -0,0 +1,46 @@
# Gemini CLI — Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File gemini\ugemini_uninstall.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Gemini CLI -- Windows Uninstaller |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Uninstall npm package ----
Write-Host " Removing @google/gemini-cli..." -ForegroundColor Cyan
npm uninstall -g @google/gemini-cli 2>$null
Write-Host " npm package removed" -ForegroundColor Green
# ---- Remove settings ----
$geminiDir = "$env:USERPROFILE\.gemini"
if (Test-Path $geminiDir) {
Write-Host " Removing $geminiDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $geminiDir
Write-Host " Settings removed" -ForegroundColor Green
} else {
Write-Host " No settings directory found" -ForegroundColor Yellow
}
# ---- Remove env vars ----
Write-Host " Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("GEMINI_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("GOOGLE_GEMINI_BASE_URL", $null, "User")
Remove-Item Env:GEMINI_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:GOOGLE_GEMINI_BASE_URL -ErrorAction SilentlyContinue
Write-Host " Env vars removed" -ForegroundColor Green
# ---- Remove npm registry config ----
Write-Host " Removing npm registry config..." -ForegroundColor Cyan
npm config delete "@google:registry" 2>$null
Write-Host " Registry config removed" -ForegroundColor Green
Write-Host ""
Write-Host " Gemini CLI fully uninstalled!" -ForegroundColor Green
Write-Host ""

85
gemini/ugemini_uninstall.sh Executable file
View File

@@ -0,0 +1,85 @@
#!/usr/bin/env bash
# Gemini CLI — Uninstaller
# Removes Gemini CLI, settings, env vars, and npm registry config.
#
# Usage: sudo bash ugemini_uninstall.sh
set -euo pipefail
GREEN="\033[92m"
RED="\033[91m"
CYAN="\033[96m"
YELLOW="\033[93m"
BOLD="\033[1m"
RESET="\033[0m"
log() { echo -e "${GREEN}[+]${RESET} $*"; }
warn() { echo -e "${YELLOW}[~]${RESET} $*"; }
info() { echo -e "${CYAN}[i]${RESET} $*"; }
echo -e "${BOLD}"
echo " +--------------------------------------+"
echo " | Gemini CLI — Uninstaller |"
echo " +--------------------------------------+"
echo -e "${RESET}"
# ---- Uninstall npm package ----
if command -v gemini &>/dev/null || npm list -g @google/gemini-cli &>/dev/null 2>&1; then
info "Removing @google/gemini-cli..."
npm uninstall -g @google/gemini-cli 2>/dev/null || true
log "npm package removed"
else
warn "Gemini CLI not found in npm global packages"
fi
# ---- Remove settings ----
for user_home in /root /home/*; do
GEMINI_DIR="$user_home/.gemini"
if [ -d "$GEMINI_DIR" ]; then
info "Removing $GEMINI_DIR..."
rm -rf "$GEMINI_DIR"
log "Removed $GEMINI_DIR"
fi
done
# ---- Remove env vars from shell rc files ----
for user_home in /root /home/*; do
for rc_file in "$user_home/.bashrc" "$user_home/.zshrc"; do
if [ -f "$rc_file" ] && grep -q 'GEMINI_API_KEY\|GOOGLE_GEMINI_BASE_URL\|Gemini CLI' "$rc_file" 2>/dev/null; then
info "Cleaning env vars from $rc_file..."
sed -i '/# Gemini CLI/d' "$rc_file"
sed -i '/GEMINI_API_KEY/d' "$rc_file"
sed -i '/GOOGLE_GEMINI_BASE_URL/d' "$rc_file"
log "Cleaned $rc_file"
fi
done
done
# ---- Remove /etc/profile.d script ----
if [ -f "/etc/profile.d/gemini-cli.sh" ]; then
info "Removing /etc/profile.d/gemini-cli.sh..."
rm -f "/etc/profile.d/gemini-cli.sh"
log "Removed /etc/profile.d/gemini-cli.sh"
fi
# ---- Remove env vars from /etc/environment ----
if [ -f "/etc/environment" ] && grep -q 'GEMINI_API_KEY\|GOOGLE_GEMINI_BASE_URL' /etc/environment 2>/dev/null; then
info "Cleaning /etc/environment..."
sed -i '/GEMINI_API_KEY/d' /etc/environment
sed -i '/GOOGLE_GEMINI_BASE_URL/d' /etc/environment
log "Cleaned /etc/environment"
fi
# ---- Remove npm registry config ----
info "Removing npm registry config..."
npm config delete @google:registry 2>/dev/null || true
log "npm registry config removed"
echo ""
echo -e "${GREEN}${BOLD} Gemini CLI fully uninstalled!${RESET}"
echo ""

46
qwen/uqwen_uninstall.ps1 Normal file
View File

@@ -0,0 +1,46 @@
# Qwen Code — Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File qwen\uqwen_uninstall.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Qwen Code -- Windows Uninstaller |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
# ---- Uninstall npm package ----
Write-Host " Removing @qwen-code/qwen-code..." -ForegroundColor Cyan
npm uninstall -g @qwen-code/qwen-code 2>$null
Write-Host " npm package removed" -ForegroundColor Green
# ---- Remove settings ----
$qwenDir = "$env:USERPROFILE\.qwen"
if (Test-Path $qwenDir) {
Write-Host " Removing $qwenDir..." -ForegroundColor Cyan
Remove-Item -Recurse -Force $qwenDir
Write-Host " Settings removed" -ForegroundColor Green
} else {
Write-Host " No settings directory found" -ForegroundColor Yellow
}
# ---- Remove env vars ----
Write-Host " Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("QWEN_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("QWEN_BASE_URL", $null, "User")
Remove-Item Env:QWEN_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:QWEN_BASE_URL -ErrorAction SilentlyContinue
Write-Host " Env vars removed" -ForegroundColor Green
# ---- Remove npm registry config ----
Write-Host " Removing npm registry config..." -ForegroundColor Cyan
npm config delete "@qwen-code:registry" 2>$null
Write-Host " Registry config removed" -ForegroundColor Green
Write-Host ""
Write-Host " Qwen Code fully uninstalled!" -ForegroundColor Green
Write-Host ""

85
qwen/uqwen_uninstall.sh Executable file
View File

@@ -0,0 +1,85 @@
#!/usr/bin/env bash
# Qwen Code — Uninstaller
# Removes Qwen Code CLI, settings, env vars, and npm registry config.
#
# Usage: sudo bash uqwen_uninstall.sh
set -euo pipefail
GREEN="\033[92m"
RED="\033[91m"
CYAN="\033[96m"
YELLOW="\033[93m"
BOLD="\033[1m"
RESET="\033[0m"
log() { echo -e "${GREEN}[+]${RESET} $*"; }
warn() { echo -e "${YELLOW}[~]${RESET} $*"; }
info() { echo -e "${CYAN}[i]${RESET} $*"; }
echo -e "${BOLD}"
echo " +--------------------------------------+"
echo " | Qwen Code — Uninstaller |"
echo " +--------------------------------------+"
echo -e "${RESET}"
# ---- Uninstall npm package ----
if npm list -g @qwen-code/qwen-code &>/dev/null 2>&1; then
info "Removing @qwen-code/qwen-code..."
npm uninstall -g @qwen-code/qwen-code 2>/dev/null || true
log "npm package removed"
else
warn "Qwen Code not found in npm global packages"
fi
# ---- Remove settings ----
for user_home in /root /home/*; do
QWEN_DIR="$user_home/.qwen"
if [ -d "$QWEN_DIR" ]; then
info "Removing $QWEN_DIR..."
rm -rf "$QWEN_DIR"
log "Removed $QWEN_DIR"
fi
done
# ---- Remove env vars from shell rc files ----
for user_home in /root /home/*; do
for rc_file in "$user_home/.bashrc" "$user_home/.zshrc"; do
if [ -f "$rc_file" ] && grep -q 'QWEN_API_KEY\|QWEN_BASE_URL\|Qwen Code' "$rc_file" 2>/dev/null; then
info "Cleaning env vars from $rc_file..."
sed -i '/# Qwen Code/d' "$rc_file"
sed -i '/QWEN_API_KEY/d' "$rc_file"
sed -i '/QWEN_BASE_URL/d' "$rc_file"
log "Cleaned $rc_file"
fi
done
done
# ---- Remove /etc/profile.d script ----
if [ -f "/etc/profile.d/qwen-code.sh" ]; then
info "Removing /etc/profile.d/qwen-code.sh..."
rm -f "/etc/profile.d/qwen-code.sh"
log "Removed /etc/profile.d/qwen-code.sh"
fi
# ---- Remove env vars from /etc/environment ----
if [ -f "/etc/environment" ] && grep -q 'QWEN_API_KEY\|QWEN_BASE_URL' /etc/environment 2>/dev/null; then
info "Cleaning /etc/environment..."
sed -i '/QWEN_API_KEY/d' /etc/environment
sed -i '/QWEN_BASE_URL/d' /etc/environment
log "Cleaned /etc/environment"
fi
# ---- Remove npm registry config ----
info "Removing npm registry config..."
npm config delete @qwen-code:registry 2>/dev/null || true
log "npm registry config removed"
echo ""
echo -e "${GREEN}${BOLD} Qwen Code fully uninstalled!${RESET}"
echo ""