forked from ccxt/ccxt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-skills.sh
More file actions
executable file
·413 lines (354 loc) · 12 KB
/
install-skills.sh
File metadata and controls
executable file
·413 lines (354 loc) · 12 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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
#!/usr/bin/env bash
# CCXT Skills Installation Script
# Installs CCXT usage skills for Claude Code, OpenCode, Codex, and Gemini
#
# Usage:
# Local: ./install-skills.sh
# Remote: curl -fsSL https://raw.githubusercontent.com/ccxt/ccxt/master/install-skills.sh | bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Skill names
ALL_SKILLS=("ccxt-typescript" "ccxt-python" "ccxt-php" "ccxt-csharp" "ccxt-go")
# GitHub URL for remote installation
GITHUB_RAW_URL="https://raw.githubusercontent.com/ccxt/ccxt/master/.claude/skills"
# Detect script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILLS_SOURCE_DIR="$SCRIPT_DIR/.claude/skills"
# Target directories
CLAUDE_SKILLS_DIR="$HOME/.claude/skills"
OPENCODE_SKILLS_DIR="$HOME/.opencode/skills"
CODEX_SKILLS_DIR="$HOME/skills"
GEMINI_SKILLS_DIR="$HOME/.gemini/skills"
# Temporary directory for remote installation
TEMP_DIR=""
IS_REMOTE_INSTALL=false
# Function to print colored output
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
print_error() {
echo -e "${RED}✗${NC} $1"
}
print_info() {
echo -e "${BLUE}ℹ${NC} $1"
}
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
}
# Function to display usage
usage() {
cat <<EOF
CCXT Skills Installer
Usage: $0 [OPTIONS]
Install CCXT usage skills for Claude Code, OpenCode, Codex, and Gemini.
OPTIONS:
--typescript Install only ccxt-typescript skill
--python Install only ccxt-python skill
--php Install only ccxt-php skill
--csharp Install only ccxt-csharp skill
--go Install only ccxt-go skill
--all Install all skills (default)
--help Display this help message
EXAMPLES:
$0 # Interactive mode
$0 --all # Install all skills
$0 --typescript # Install only TypeScript skill
$0 --python --php # Install Python and PHP skills
The skills will be installed to:
- ~/.claude/skills/ (for Claude Code)
- ~/.opencode/skills/ (for OpenCode)
- ~/skills/ (for Codex)
- ~/.gemini/skills/ (for Gemini)
EOF
exit 0
}
# Function to detect if running remotely (piped from curl)
detect_remote_install() {
# Check if .claude/skills directory exists locally
if [ ! -d "$SKILLS_SOURCE_DIR" ]; then
IS_REMOTE_INSTALL=true
print_info "Running in remote mode - will download skills from GitHub"
return 0
fi
return 1
}
# Function to download a skill from GitHub
download_skill() {
local skill_name=$1
local temp_skill_dir="$TEMP_DIR/$skill_name"
mkdir -p "$temp_skill_dir"
# Download SKILL.md
local skill_url="$GITHUB_RAW_URL/$skill_name/SKILL.md"
print_info "Downloading $skill_name from GitHub..."
if command -v curl &> /dev/null; then
curl -fsSL "$skill_url" -o "$temp_skill_dir/SKILL.md" 2>/dev/null
elif command -v wget &> /dev/null; then
wget -q "$skill_url" -O "$temp_skill_dir/SKILL.md" 2>/dev/null
else
print_error "Neither curl nor wget found. Please install one of them."
return 1
fi
if [ $? -eq 0 ] && [ -f "$temp_skill_dir/SKILL.md" ]; then
return 0
else
print_warning "Failed to download $skill_name"
return 1
fi
}
# Function to setup remote installation
setup_remote_install() {
print_info "Setting up remote installation..."
# Create temporary directory
TEMP_DIR=$(mktemp -d)
if [ $? -ne 0 ]; then
print_error "Failed to create temporary directory"
exit 1
fi
# Download all selected skills
local download_success=true
for skill in "${ALL_SKILLS[@]}"; do
if ! download_skill "$skill"; then
download_success=false
fi
done
if [ "$download_success" = false ]; then
print_error "Failed to download some skills from GitHub"
cleanup_remote_install
exit 1
fi
# Update source directory to temp directory
SKILLS_SOURCE_DIR="$TEMP_DIR"
print_success "Skills downloaded successfully"
}
# Function to cleanup remote installation
cleanup_remote_install() {
if [ -n "$TEMP_DIR" ] && [ -d "$TEMP_DIR" ]; then
rm -rf "$TEMP_DIR"
fi
}
# Function to check if skills source directory exists
check_source_directory() {
if [ ! -d "$SKILLS_SOURCE_DIR" ]; then
print_error "Skills source directory not found: $SKILLS_SOURCE_DIR"
print_info "Please run this script from the CCXT repository root."
exit 1
fi
}
# Function to install a single skill
install_skill() {
local skill_name=$1
local target_dir=$2
local skill_source="$SKILLS_SOURCE_DIR/$skill_name"
local skill_target="$target_dir/$skill_name"
if [ ! -d "$skill_source" ]; then
print_warning "Skill source not found: $skill_name"
return 1
fi
# Create target directory if it doesn't exist
mkdir -p "$target_dir"
# Copy skill
if [ -d "$skill_target" ]; then
print_info "Updating $skill_name..."
rm -rf "$skill_target"
fi
cp -r "$skill_source" "$skill_target"
if [ $? -eq 0 ]; then
print_success "Installed $skill_name to $target_dir"
return 0
else
print_error "Failed to install $skill_name"
return 1
fi
}
# Function to install skills to a target directory
install_to_target() {
local target_dir=$1
local target_name=$2
local skills=("${@:3}")
if [ ${#skills[@]} -eq 0 ]; then
print_info "No skills selected for $target_name"
return
fi
echo ""
print_info "Installing to $target_name ($target_dir)..."
local success_count=0
local fail_count=0
for skill in "${skills[@]}"; do
if install_skill "$skill" "$target_dir"; then
((success_count++))
else
((fail_count++))
fi
done
echo ""
if [ $fail_count -eq 0 ]; then
print_success "Successfully installed $success_count skill(s) to $target_name"
else
print_warning "Installed $success_count skill(s), $fail_count failed"
fi
}
# Function for interactive mode
interactive_mode() {
echo ""
echo "════════════════════════════════════════════════"
echo " CCXT Skills Installer - Interactive Mode"
echo "════════════════════════════════════════════════"
echo ""
echo "Select which skills to install:"
echo ""
echo " 1) ccxt-typescript - TypeScript/JavaScript (Node.js & browser, REST & WebSocket)"
echo " 2) ccxt-python - Python (sync & async, REST & WebSocket)"
echo " 3) ccxt-php - PHP (sync & async, REST & WebSocket)"
echo " 4) ccxt-csharp - C#/.NET (REST & WebSocket)"
echo " 5) ccxt-go - Go (REST & WebSocket)"
echo " 6) All skills - Install all of the above"
echo " 7) Exit - Cancel installation"
echo ""
read -p "Enter your choice (1-7): " choice
case $choice in
1)
selected_skills=("ccxt-typescript")
;;
2)
selected_skills=("ccxt-python")
;;
3)
selected_skills=("ccxt-php")
;;
4)
selected_skills=("ccxt-csharp")
;;
5)
selected_skills=("ccxt-go")
;;
6)
selected_skills=("${ALL_SKILLS[@]}")
;;
7)
echo "Installation cancelled."
exit 0
;;
*)
print_error "Invalid choice. Please run the script again."
exit 1
;;
esac
return 0
}
# Main installation function
main() {
local selected_skills=()
# Detect if running remotely and setup if needed
if detect_remote_install; then
# Remote installation - download skills from GitHub
# In remote mode, default to installing all skills
if [ $# -eq 0 ]; then
selected_skills=("${ALL_SKILLS[@]}")
fi
fi
# Parse command line arguments
if [ $# -eq 0 ]; then
# No arguments
if [ "$IS_REMOTE_INSTALL" = false ]; then
# Local mode - run interactive mode
check_source_directory
interactive_mode
fi
# Remote mode - already set selected_skills to ALL_SKILLS above
else
# Parse flags
while [ $# -gt 0 ]; do
case "$1" in
--help|-h)
usage
;;
--typescript)
selected_skills+=("ccxt-typescript")
;;
--python)
selected_skills+=("ccxt-python")
;;
--php)
selected_skills+=("ccxt-php")
;;
--csharp)
selected_skills+=("ccxt-csharp")
;;
--go)
selected_skills+=("ccxt-go")
;;
--all)
selected_skills=("${ALL_SKILLS[@]}")
;;
*)
print_error "Unknown option: $1"
echo "Use --help for usage information."
exit 1
;;
esac
shift
done
fi
# If no skills selected, show error
if [ ${#selected_skills[@]} -eq 0 ]; then
print_error "No skills selected for installation."
exit 1
fi
# Setup remote installation if needed
if [ "$IS_REMOTE_INSTALL" = true ]; then
setup_remote_install
# Set trap to cleanup on exit
trap cleanup_remote_install EXIT
else
check_source_directory
fi
# Display installation summary
echo ""
echo "═══════════════════════════════════════════════════════════════"
echo " Installing CCXT Skills"
echo "═══════════════════════════════════════════════════════════════"
echo ""
echo "Skills to install:"
for skill in "${selected_skills[@]}"; do
echo " • $skill"
done
echo ""
# Install to Claude Code
install_to_target "$CLAUDE_SKILLS_DIR" "Claude Code" "${selected_skills[@]}"
# Install to OpenCode
install_to_target "$OPENCODE_SKILLS_DIR" "OpenCode" "${selected_skills[@]}"
# Install to Codex
install_to_target "$CODEX_SKILLS_DIR" "Codex" "${selected_skills[@]}"
# Install to Gemini
install_to_target "$GEMINI_SKILLS_DIR" "Gemini" "${selected_skills[@]}"
# Display completion message
echo ""
echo "═══════════════════════════════════════════════════════════════"
print_success "Installation complete!"
echo "═══════════════════════════════════════════════════════════════"
echo ""
echo "The skills are now available in Claude Code, OpenCode, Codex, and Gemini."
echo ""
echo "Usage examples:"
echo ""
for skill in "${selected_skills[@]}"; do
local lang=$(echo "$skill" | sed 's/ccxt-//')
echo " /$skill"
echo " Get help using CCXT in $lang"
echo ""
done
echo "You can also ask questions like:"
echo " \"How do I connect to Binance using CCXT in Python?\""
echo " \"Show me how to fetch a ticker in TypeScript\""
echo " \"How do I handle errors in CCXT Go?\""
echo ""
print_info "Restart your Claude Code/OpenCode/Codex/Gemini session to load the new skills."
echo ""
}
# Run main function
main "$@"