diff --git a/Makefile b/Makefile index ca9b261..b2b3a10 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: install test test-plugin doctor verify clean lint format build-plugin sync-plugin-repo help +.PHONY: install test test-plugin doctor verify clean lint format build-plugin sync-plugin-repo uninstall-legacy help # Installation (local source, editable) - RECOMMENDED install: @@ -126,5 +126,13 @@ help: @echo "" @echo "๐Ÿ“š Documentation:" @echo " make translate - Translate README to Chinese and Japanese" - @echo " make help - Show this help message" + @echo "" + @echo "๐Ÿงน Cleanup:" + @echo " make uninstall-legacy - Remove old SuperClaude files from ~/.claude" + @echo " make help - Show this help message" + +# Remove legacy SuperClaude files from ~/.claude directory +uninstall-legacy: + @echo "๐Ÿงน Cleaning up legacy SuperClaude files..." + @bash scripts/uninstall_legacy.sh @echo "" diff --git a/scripts/uninstall_legacy.sh b/scripts/uninstall_legacy.sh new file mode 100755 index 0000000..51a0887 --- /dev/null +++ b/scripts/uninstall_legacy.sh @@ -0,0 +1,118 @@ +#!/usr/bin/env bash +# +# SuperClaude Legacy Cleanup Script +# Removes old SuperClaude-related files from ~/.claude +# + +set -euo pipefail + +CLAUDE_DIR="$HOME/.claude" +BACKUP_DIR="$HOME/.claude-superclaude-backup-$(date +%Y%m%d_%H%M%S)" + +echo "๐Ÿงน SuperClaude Legacy Cleanup" +echo "==============================" +echo "" + +# Check if .claude directory exists +if [[ ! -d "$CLAUDE_DIR" ]]; then + echo "โœ… No .claude directory found - nothing to clean" + exit 0 +fi + +# List of SuperClaude-related files/directories to remove +SUPERCLAUDE_ITEMS=( + # SuperClaude plugin (if exists) + "plugins/superclaude@superclaude" + + # Legacy SuperClaude configs (if any) + "superclaude.json" + "superclaude_config.json" +) + +# Function to backup and remove +backup_and_remove() { + local item="$1" + local full_path="$CLAUDE_DIR/$item" + + if [[ -e "$full_path" ]] || [[ -L "$full_path" ]]; then + echo "๐Ÿ“ฆ Backing up: $item" + mkdir -p "$BACKUP_DIR/$(dirname "$item")" + cp -R "$full_path" "$BACKUP_DIR/$item" 2>/dev/null || true + + echo "๐Ÿ—‘๏ธ Removing: $item" + rm -rf "$full_path" + return 0 + fi + return 1 +} + +echo "๐Ÿ” Scanning for SuperClaude files..." +echo "" + +FOUND_COUNT=0 +for item in "${SUPERCLAUDE_ITEMS[@]}"; do + if backup_and_remove "$item"; then + ((FOUND_COUNT++)) + fi +done + +# Clean up settings.json if it contains SuperClaude plugin reference +SETTINGS_FILE="$CLAUDE_DIR/settings.json" +if [[ -f "$SETTINGS_FILE" ]]; then + if grep -q "superclaude@superclaude" "$SETTINGS_FILE" 2>/dev/null; then + echo "๐Ÿ“ฆ Backing up: settings.json" + mkdir -p "$BACKUP_DIR" + cp "$SETTINGS_FILE" "$BACKUP_DIR/settings.json" + + echo "๐Ÿงน Removing SuperClaude plugin from settings.json" + # Use Python to properly manipulate JSON + python3 - <<'PYEOF' "$SETTINGS_FILE" +import json +import sys + +settings_file = sys.argv[1] + +try: + with open(settings_file, 'r') as f: + settings = json.load(f) + + # Remove SuperClaude plugin + if 'enabledPlugins' in settings: + if 'superclaude@superclaude' in settings['enabledPlugins']: + del settings['enabledPlugins']['superclaude@superclaude'] + print(f" โœ… Removed superclaude@superclaude from enabledPlugins") + + # Remove enabledPlugins if empty + if not settings['enabledPlugins']: + del settings['enabledPlugins'] + + with open(settings_file, 'w') as f: + json.dump(settings, f, indent=2) + f.write('\n') + +except Exception as e: + print(f" โš ๏ธ Failed to update settings.json: {e}", file=sys.stderr) + sys.exit(1) +PYEOF + ((FOUND_COUNT++)) + fi +fi + +echo "" +echo "==============================" + +if [[ $FOUND_COUNT -eq 0 ]]; then + echo "โœ… No SuperClaude files found - already clean!" + rmdir "$BACKUP_DIR" 2>/dev/null || true +else + echo "๐ŸŽ‰ Cleanup complete!" + echo "" + echo "๐Ÿ“ฆ Backup saved to:" + echo " $BACKUP_DIR" + echo "" + echo "Removed $FOUND_COUNT SuperClaude-related item(s)" +fi + +echo "" +echo "โ„น๏ธ Note: Official Claude Code files were NOT touched" +echo " (history.jsonl, mcp.json, projects/, etc.)"