-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·124 lines (106 loc) · 3.4 KB
/
uninstall.sh
File metadata and controls
executable file
·124 lines (106 loc) · 3.4 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
#!/usr/bin/env bash
set -e
# ANSI colors
BOLD=$'\033[1m'
GREY=$'\033[90m'
RED=$'\033[31m'
GREEN=$'\033[32m'
YELLOW=$'\033[33m'
CYAN=$'\033[36m'
NC=$'\033[0m'
info() { printf "${BOLD}${GREY}>${NC} %s\n" "$*"; }
warn() { printf "${YELLOW}! %s${NC}\n" "$*"; }
error() { printf "${RED}x %s${NC}\n" "$*" >&2; }
completed() { printf "${GREEN}✓${NC} %s\n" "$*"; }
uninstall_skills() {
local skills_dir="$1"
local name="$2"
local removed=0
for skill_dir in "$skills_dir"/buddy-*/; do
[ -d "$skill_dir" ] || continue
rm -rf "$skill_dir"
removed=$((removed + 1))
done
if [ $removed -gt 0 ]; then
completed "$name: removed ${GREEN}$removed skills${NC} from ${CYAN}$skills_dir${NC}"
fi
}
uninstall_commands() {
local commands_dir="$1"
local name="$2"
local temp_dir="$3"
local source_dir="$temp_dir/commands"
[ -d "$source_dir" ] || return 0
[ -d "$commands_dir" ] || return 0
local removed=0
for cmd_file in "$source_dir"/*.md; do
[ -f "$cmd_file" ] || continue
local cmd_name
cmd_name=$(basename "$cmd_file")
if [ -f "$commands_dir/$cmd_name" ]; then
rm -f "$commands_dir/$cmd_name"
removed=$((removed + 1))
fi
done
if [ $removed -gt 0 ]; then
completed "$name: removed ${GREEN}$removed commands${NC} from ${CYAN}$commands_dir${NC}"
fi
}
# Targets: skills_dir|commands_dir|name
declare -a TARGETS=(
"$HOME/.claude/skills|$HOME/.claude/commands|Claude Code"
"$HOME/.codex/skills|$HOME/.codex/commands|OpenAI Codex"
"$HOME/.config/opencode/skill|$HOME/.config/opencode/commands|OpenCode"
"$HOME/.cursor/skills|$HOME/.cursor/commands|Cursor"
"$HOME/.gemini/skills|$HOME/.gemini/commands|Gemini CLI"
)
# Detect which tools have buddy skills installed
declare -a FOUND=()
for target in "${TARGETS[@]}"; do
IFS='|' read -r skills_dir commands_dir name <<< "$target"
has_skills=false
for d in "$skills_dir"/buddy-*/; do
[ -d "$d" ] && has_skills=true && break
done
$has_skills && FOUND+=("$target")
done
if [ ${#FOUND[@]} -eq 0 ]; then
info "No Buddy plugin installations found. Nothing to remove."
exit 0
fi
printf "\n${BOLD}Buddy Plugin Uninstall${NC}\n\n"
# Clone repo to know which commands to remove
info "Fetching command list..."
temp_dir=$(mktemp -d)
git clone --depth 1 --quiet "https://github.com/buddy/buddy-plugin" "$temp_dir"
printf "\n"
for target in "${FOUND[@]}"; do
IFS='|' read -r skills_dir commands_dir name <<< "$target"
uninstall_skills "$skills_dir" "$name"
uninstall_commands "$commands_dir" "$name" "$temp_dir"
done
# Local uninstalls (skip if CWD is $HOME)
if [ "$(pwd)" != "$HOME" ]; then
declare -a LOCAL_TARGETS=(
".claude/skills|.claude/commands|Claude Code (local)"
".codex/skills|.codex/commands|OpenAI Codex (local)"
".config/opencode/skill|.config/opencode/commands|OpenCode (local)"
".cursor/skills|.cursor/commands|Cursor (local)"
".gemini/skills|.gemini/commands|Gemini CLI (local)"
)
for target in "${LOCAL_TARGETS[@]}"; do
IFS='|' read -r skills_dir commands_dir name <<< "$target"
has_skills=false
for d in "./$skills_dir"/buddy-*/; do
[ -d "$d" ] && has_skills=true && break
done
if $has_skills; then
uninstall_skills "./$skills_dir" "$name"
uninstall_commands "./$commands_dir" "$name" "$temp_dir"
fi
done
fi
rm -rf "$temp_dir"
printf "\n${GREEN}✓ Buddy plugin uninstalled.${NC}\n"
warn "Restart your tool(s) to apply changes."
printf "\n"