-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·162 lines (136 loc) · 4.23 KB
/
install.sh
File metadata and controls
executable file
·162 lines (136 loc) · 4.23 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
#!/usr/bin/env bash
set -e
REPO="https://github.com/buddy/buddy-plugin"
# ANSI colors
BOLD=$'\033[1m'
GREY=$'\033[90m'
RED=$'\033[31m'
GREEN=$'\033[32m'
YELLOW=$'\033[33m'
MAGENTA=$'\033[35m'
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" "$*"; }
print_success() {
printf "${MAGENTA}"
cat <<'EOF'
____ _ _
| __ ) _ _ __| | __| |_ _
| _ \| | | |/ _` |/ _` | | | |
| |_) | |_| | (_| | (_| | |_| |
|____/ \__,_|\__,_|\__,_|\__, |
|___/
EOF
printf "${NC}"
printf " ${GREEN}Plugin installed successfully!${NC}\n\n"
}
install_skills() {
local skills_dir="$1"
local name="$2"
local temp_dir="$3"
local source_dir="$temp_dir/skills"
mkdir -p "$skills_dir"
# Remove legacy buddy skills from previous installs
for old_skill in "$skills_dir"/buddy-*/; do
[ -d "$old_skill" ] && rm -rf "$old_skill"
done
local installed=0
for skill_dir in "$source_dir"/*/; do
[ -d "$skill_dir" ] || continue
local skill_name
skill_name=$(basename "$skill_dir")
local target_dir="$skills_dir/buddy-$skill_name"
if [ ! -f "$skill_dir/SKILL.md" ]; then
warn "Skipping $skill_name: no SKILL.md found"
continue
fi
rm -rf "$target_dir"
cp -R "$skill_dir" "$target_dir"
installed=$((installed + 1))
done
if [ $installed -gt 0 ]; then
completed "$name: installed ${GREEN}$installed skills${NC} → ${CYAN}$skills_dir${NC}"
fi
}
install_commands() {
local commands_dir="$1"
local name="$2"
local temp_dir="$3"
local source_dir="$temp_dir/commands"
[ -d "$source_dir" ] || return 0
mkdir -p "$commands_dir"
local installed=0
for cmd_file in "$source_dir"/*.md; do
[ -f "$cmd_file" ] || continue
local cmd_name
cmd_name=$(basename "$cmd_file")
cp "$cmd_file" "$commands_dir/$cmd_name"
installed=$((installed + 1))
done
if [ $installed -gt 0 ]; then
completed "$name: installed ${GREEN}$installed commands${NC} → ${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 available tools
declare -a FOUND=()
for target in "${TARGETS[@]}"; do
IFS='|' read -r skills_dir commands_dir name <<< "$target"
parent="${skills_dir%/*}"
[ -d "$parent" ] && FOUND+=("$target")
done
if [ ${#FOUND[@]} -eq 0 ]; then
error "No supported tools found."
printf "\nSupported:\n"
printf " • Claude Code (~/.claude)\n"
printf " • OpenAI Codex (~/.codex)\n"
printf " • OpenCode (~/.config/opencode)\n"
printf " • Cursor (~/.cursor)\n"
printf " • Gemini CLI (~/.gemini)\n"
exit 1
fi
printf "\n${BOLD}Buddy Plugin${NC}\n\n"
info "Downloading from ${CYAN}$REPO${NC}..."
temp_dir=$(mktemp -d)
git clone --depth 1 --quiet "$REPO" "$temp_dir"
printf "\n"
for target in "${FOUND[@]}"; do
IFS='|' read -r skills_dir commands_dir name <<< "$target"
install_skills "$skills_dir" "$name" "$temp_dir"
install_commands "$commands_dir" "$name" "$temp_dir"
done
# Local installs (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"
parent="${skills_dir%/*}"
if [ -d "./$parent" ]; then
install_skills "./$skills_dir" "$name" "$temp_dir"
install_commands "./$commands_dir" "$name" "$temp_dir"
fi
done
fi
rm -rf "$temp_dir"
printf "\n"
print_success
warn "Restart your tool(s) to load the plugin."
printf "\n"
info "Re-run anytime to update."
printf "\n"