forked from yusufkaraaslan/Skill_Seekers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·584 lines (522 loc) · 20.6 KB
/
setup.sh
File metadata and controls
executable file
·584 lines (522 loc) · 20.6 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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
#!/bin/bash
# Skill Seekers - Global Installation & MCP Setup
# This script installs skill-seekers globally and configures MCP for AI agents
set -e # Exit on error
echo "=========================================================="
echo "Skill Seekers - Global Installation & MCP Setup"
echo "=========================================================="
echo ""
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Global variables
HTTP_PORT=3000
HTTP_AGENTS=()
STDIO_AGENTS=()
SELECTED_AGENTS=()
# =============================================================================
# STEP 1: CHECK PYTHON VERSION
# =============================================================================
echo "Step 1: Checking Python version..."
if ! command -v python3 &> /dev/null; then
echo -e "${RED}❌ Error: python3 not found${NC}"
echo "Please install Python 3.10 or higher"
exit 1
fi
PYTHON_VERSION=$(python3 --version | cut -d' ' -f2)
PYTHON_MAJOR=$(echo $PYTHON_VERSION | cut -d'.' -f1)
PYTHON_MINOR=$(echo $PYTHON_VERSION | cut -d'.' -f2)
if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 10 ]); then
echo -e "${YELLOW}⚠ Warning: Python 3.10+ required${NC}"
echo "Current version: $PYTHON_VERSION"
exit 1
else
echo -e "${GREEN}✓${NC} Python $PYTHON_VERSION found"
fi
echo ""
# =============================================================================
# STEP 2: INSTALL SKILL-SEEKERS GLOBALLY
# =============================================================================
echo "Step 2: Installing skill-seekers globally from PyPI..."
echo ""
echo "This will install skill-seekers and all dependencies:"
echo " • skill-seekers (latest version)"
echo " • mcp, fastmcp (MCP server support)"
echo " • beautifulsoup4, requests, httpx (scraping)"
echo " • GitPython, PyGithub (GitHub integration)"
echo " • PyMuPDF (PDF support)"
echo " • uvicorn (HTTP server)"
echo ""
read -p "Install globally? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Installing skill-seekers..."
# Try pip3 install first
if pip3 install skill-seekers 2>/dev/null; then
echo -e "${GREEN}✓${NC} Installed successfully via pip3"
else
# Fallback to pip3 with --break-system-packages (for system Python)
echo "Standard install failed, trying with --break-system-packages..."
pip3 install skill-seekers --break-system-packages || {
echo -e "${RED}❌ Failed to install skill-seekers${NC}"
echo "Try manually: pip3 install skill-seekers"
exit 1
}
echo -e "${GREEN}✓${NC} Installed successfully with --break-system-packages"
fi
# Verify installation
if command -v skill-seekers &> /dev/null; then
INSTALLED_VERSION=$(skill-seekers --version 2>/dev/null || echo "unknown")
echo -e "${GREEN}✓${NC} skill-seekers command available"
echo " Version: $INSTALLED_VERSION"
else
echo -e "${YELLOW}⚠${NC} skill-seekers command not found in PATH"
echo " Add ~/.local/bin to PATH: export PATH=\"\$HOME/.local/bin:\$PATH\""
fi
else
echo "Installation skipped"
exit 0
fi
echo ""
# =============================================================================
# STEP 3: TEST MCP SERVER
# =============================================================================
echo "Step 3: Testing MCP server..."
# Test stdio mode
echo " Testing stdio transport..."
timeout 3 python3 -m skill_seekers.mcp.server_fastmcp 2>/dev/null || {
if [ $? -eq 124 ]; then
echo -e " ${GREEN}✓${NC} Stdio transport working"
else
echo -e " ${YELLOW}⚠${NC} Stdio test inconclusive, but may still work"
fi
}
# Test HTTP mode
echo " Testing HTTP transport..."
if python3 -c "import uvicorn" 2>/dev/null; then
# Start HTTP server in background
python3 -m skill_seekers.mcp.server_fastmcp --transport http --port 8765 > /dev/null 2>&1 &
HTTP_TEST_PID=$!
sleep 2
# Test health endpoint
if curl -s http://127.0.0.1:8765/health > /dev/null 2>&1; then
echo -e " ${GREEN}✓${NC} HTTP transport working (port 8765)"
HTTP_AVAILABLE=true
else
echo -e " ${YELLOW}⚠${NC} HTTP transport test failed (may need manual check)"
HTTP_AVAILABLE=false
fi
# Cleanup
kill $HTTP_TEST_PID 2>/dev/null || true
else
echo -e " ${YELLOW}⚠${NC} uvicorn not installed (HTTP transport unavailable)"
echo " Install with: pip3 install uvicorn"
HTTP_AVAILABLE=false
fi
echo ""
# =============================================================================
# STEP 4: DETECT INSTALLED AI AGENTS
# =============================================================================
echo "Step 4: Detecting installed AI coding agents..."
echo ""
# Use Python agent detector
DETECTED_AGENTS=$(python3 -c "
from skill_seekers.mcp.agent_detector import AgentDetector
detector = AgentDetector()
agents = detector.detect_agents()
if agents:
for agent in agents:
print(f\"{agent['agent']}|{agent['name']}|{agent['config_path']}|{agent['transport']}\")
else:
print('NONE')
" 2>/dev/null || echo "ERROR")
if [ "$DETECTED_AGENTS" = "ERROR" ]; then
echo -e "${RED}❌ Error: Failed to run agent detector${NC}"
echo "Falling back to manual configuration..."
DETECTED_AGENTS="NONE"
fi
# Parse detected agents
if [ "$DETECTED_AGENTS" = "NONE" ]; then
echo -e "${YELLOW}No AI coding agents detected.${NC}"
echo ""
echo "Supported agents:"
echo " • Claude Code (stdio)"
echo " • Cursor (HTTP)"
echo " • Windsurf (HTTP)"
echo " • VS Code + Cline extension (stdio)"
echo " • IntelliJ IDEA (HTTP)"
echo ""
echo "Manual configuration will be shown at the end."
else
echo -e "${GREEN}Detected AI coding agents:${NC}"
echo ""
# Display detected agents
IFS=$'\n'
for agent_line in $DETECTED_AGENTS; do
IFS='|' read -r agent_id agent_name config_path transport <<< "$agent_line"
if [ "$transport" = "http" ]; then
HTTP_AGENTS+=("$agent_id|$agent_name|$config_path")
echo -e " ${CYAN}✓${NC} $agent_name (HTTP transport)"
else
STDIO_AGENTS+=("$agent_id|$agent_name|$config_path")
echo -e " ${CYAN}✓${NC} $agent_name (stdio transport)"
fi
echo " Config: $config_path"
done
unset IFS
fi
echo ""
# =============================================================================
# STEP 5: AUTO-CONFIGURE DETECTED AGENTS
# =============================================================================
if [ "$DETECTED_AGENTS" != "NONE" ]; then
echo "Step 5: Configure detected agents"
echo "=================================================="
echo ""
# Ask which agents to configure
echo "Which agents would you like to configure?"
echo ""
echo " 1. All detected agents (recommended)"
echo " 2. Select individual agents"
echo " 3. Skip auto-configuration (manual setup)"
echo ""
read -p "Choose option (1-3): " -n 1 -r
echo ""
echo ""
CONFIGURE_ALL=false
CONFIGURE_SELECT=false
case $REPLY in
1)
CONFIGURE_ALL=true
echo "Configuring all detected agents..."
;;
2)
CONFIGURE_SELECT=true
echo "Select agents to configure:"
;;
3)
echo "Skipping auto-configuration"
echo "Manual configuration instructions will be shown at the end."
;;
*)
echo "Invalid option. Skipping auto-configuration."
;;
esac
echo ""
# Build selection list
if [ "$CONFIGURE_ALL" = true ] || [ "$CONFIGURE_SELECT" = true ]; then
# Combine all agents
ALL_AGENTS=("${STDIO_AGENTS[@]}" "${HTTP_AGENTS[@]}")
if [ "$CONFIGURE_ALL" = true ]; then
SELECTED_AGENTS=("${ALL_AGENTS[@]}")
else
# Individual selection
for agent_line in "${ALL_AGENTS[@]}"; do
IFS='|' read -r agent_id agent_name config_path <<< "$agent_line"
read -p " Configure $agent_name? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
SELECTED_AGENTS+=("$agent_line")
fi
done
unset IFS
echo ""
fi
# Configure selected agents
if [ ${#SELECTED_AGENTS[@]} -eq 0 ]; then
echo "No agents selected for configuration."
else
echo "Configuring ${#SELECTED_AGENTS[@]} agent(s)..."
echo ""
# Check if HTTP transport needed
NEED_HTTP=false
for agent_line in "${SELECTED_AGENTS[@]}"; do
IFS='|' read -r agent_id agent_name config_path <<< "$agent_line"
# Check if this is an HTTP agent
for http_agent in "${HTTP_AGENTS[@]}"; do
if [ "$agent_line" = "$http_agent" ]; then
NEED_HTTP=true
break 2
fi
done
done
unset IFS
# Configure HTTP port if needed
if [ "$NEED_HTTP" = true ]; then
echo "HTTP transport required for some agents."
read -p "Enter HTTP server port [default: 3000]: " PORT_INPUT
if [ -n "$PORT_INPUT" ]; then
HTTP_PORT=$PORT_INPUT
fi
echo "Using port: $HTTP_PORT"
echo ""
fi
# Configure each selected agent
for agent_line in "${SELECTED_AGENTS[@]}"; do
IFS='|' read -r agent_id agent_name config_path <<< "$agent_line"
echo "Configuring $agent_name..."
# Check if config already exists
if [ -f "$config_path" ]; then
echo -e " ${YELLOW}⚠ Config file already exists${NC}"
# Create backup
BACKUP_PATH="${config_path}.backup.$(date +%Y%m%d_%H%M%S)"
cp "$config_path" "$BACKUP_PATH"
echo -e " ${GREEN}✓${NC} Backup created: $BACKUP_PATH"
# Check if skill-seeker already configured
if grep -q "skill-seeker" "$config_path" 2>/dev/null; then
echo -e " ${YELLOW}⚠ skill-seeker already configured${NC}"
read -p " Overwrite existing skill-seeker config? (y/n) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo " Skipping $agent_name"
continue
fi
fi
fi
# Generate config using Python (with global command)
GENERATED_CONFIG=$(python3 -c "
from skill_seekers.mcp.agent_detector import AgentDetector
detector = AgentDetector()
# Use global skill-seekers command (not local repo path)
server_command = 'python3 -m skill_seekers.mcp.server_fastmcp'
config = detector.generate_config('$agent_id', server_command, $HTTP_PORT)
print(config)
" 2>/dev/null)
if [ -n "$GENERATED_CONFIG" ]; then
# Create parent directory if needed
mkdir -p "$(dirname "$config_path")"
# Write or merge configuration
if [ -f "$config_path" ]; then
# Merge with existing config
python3 -c "
import json
# Read existing config
try:
with open('$config_path', 'r') as f:
existing = json.load(f)
except:
existing = {}
# Parse new config
new = json.loads('''$GENERATED_CONFIG''')
# Merge (add skill-seeker, preserve others)
if 'mcpServers' not in existing:
existing['mcpServers'] = {}
existing['mcpServers']['skill-seeker'] = new['mcpServers']['skill-seeker']
# Write back
with open('$config_path', 'w') as f:
json.dump(existing, f, indent=2)
" 2>/dev/null || {
echo -e " ${RED}✗${NC} Failed to merge config"
continue
}
echo -e " ${GREEN}✓${NC} Merged with existing config"
else
# Write new config
echo "$GENERATED_CONFIG" > "$config_path"
echo -e " ${GREEN}✓${NC} Config created"
fi
echo " Location: $config_path"
else
echo -e " ${RED}✗${NC} Failed to generate config"
fi
echo ""
done
unset IFS
fi
fi
else
echo "Step 5: Auto-configuration skipped (no agents detected)"
echo ""
fi
# =============================================================================
# STEP 6: START HTTP SERVER (IF NEEDED)
# =============================================================================
if [ ${#SELECTED_AGENTS[@]} -gt 0 ]; then
# Check if any selected agent needs HTTP
NEED_HTTP_SERVER=false
for agent_line in "${SELECTED_AGENTS[@]}"; do
for http_agent in "${HTTP_AGENTS[@]}"; do
if [ "$agent_line" = "$http_agent" ]; then
NEED_HTTP_SERVER=true
break 2
fi
done
done
if [ "$NEED_HTTP_SERVER" = true ]; then
echo "Step 6: HTTP Server Setup"
echo "=================================================="
echo ""
echo "Some configured agents require HTTP transport."
echo "The MCP server needs to run in HTTP mode on port $HTTP_PORT."
echo ""
echo "Options:"
echo " 1. Start server now (background process)"
echo " 2. Show manual start command (start later)"
echo " 3. Skip (I'll manage it myself)"
echo ""
read -p "Choose option (1-3): " -n 1 -r
echo ""
echo ""
case $REPLY in
1)
echo "Starting HTTP server on port $HTTP_PORT..."
# Start server in background
nohup python3 -m skill_seekers.mcp.server_fastmcp --transport http --port $HTTP_PORT > /tmp/skill-seekers-mcp.log 2>&1 &
SERVER_PID=$!
sleep 2
# Check if server started
if curl -s http://127.0.0.1:$HTTP_PORT/health > /dev/null 2>&1; then
echo -e "${GREEN}✓${NC} HTTP server started (PID: $SERVER_PID)"
echo " Health check: http://127.0.0.1:$HTTP_PORT/health"
echo " Logs: /tmp/skill-seekers-mcp.log"
echo ""
echo -e "${YELLOW}Note:${NC} Server is running in background. To stop:"
echo " kill $SERVER_PID"
else
echo -e "${RED}✗${NC} Failed to start HTTP server"
echo " Check logs: /tmp/skill-seekers-mcp.log"
fi
;;
2)
echo "Manual start command:"
echo ""
echo -e "${GREEN}python3 -m skill_seekers.mcp.server_fastmcp --transport http --port $HTTP_PORT${NC}"
echo ""
echo "Or run in background:"
echo -e "${GREEN}nohup python3 -m skill_seekers.mcp.server_fastmcp --transport http --port $HTTP_PORT > /tmp/skill-seekers-mcp.log 2>&1 &${NC}"
;;
3)
echo "Skipping HTTP server start"
;;
esac
echo ""
else
echo "Step 6: HTTP Server not needed (all agents use stdio)"
echo ""
fi
else
echo "Step 6: HTTP Server setup skipped"
echo ""
fi
# =============================================================================
# STEP 7: FINAL INSTRUCTIONS
# =============================================================================
echo "=========================================================="
echo "Setup Complete!"
echo "=========================================================="
echo ""
if [ ${#SELECTED_AGENTS[@]} -gt 0 ]; then
echo -e "${GREEN}Next Steps:${NC}"
echo ""
echo "1. ${YELLOW}Restart your AI coding agent(s)${NC}"
echo " (Completely quit and reopen, don't just close window)"
echo ""
echo "2. ${YELLOW}Test the integration${NC}"
echo " Try commands like:"
echo " • ${CYAN}List all available configs${NC}"
echo " • ${CYAN}Generate config for React at https://react.dev${NC}"
echo " • ${CYAN}Scrape docs for configs/godot.json${NC}"
echo ""
# HTTP-specific instructions
if [ "$NEED_HTTP_SERVER" = true ]; then
echo "3. ${YELLOW}HTTP Server${NC}"
echo " Make sure HTTP server is running on port $HTTP_PORT"
echo " Test with: ${CYAN}curl http://127.0.0.1:$HTTP_PORT/health${NC}"
echo ""
fi
else
echo -e "${YELLOW}Manual Configuration Required${NC}"
echo ""
echo "No agents were auto-configured. Here are configuration examples:"
echo ""
# Show stdio example
echo "${CYAN}For Claude Code (stdio):${NC}"
echo "File: ~/.config/claude-code/mcp.json"
echo ""
echo -e "${GREEN}{"
echo " \"mcpServers\": {"
echo " \"skill-seeker\": {"
echo " \"command\": \"python3\","
echo " \"args\": [\"-m\", \"skill_seekers.mcp.server_fastmcp\"]"
echo " }"
echo " }"
echo -e "}${NC}"
echo ""
# Show HTTP example if available
if [ "$HTTP_AVAILABLE" = true ]; then
echo "${CYAN}For Cursor/Windsurf (HTTP):${NC}"
echo ""
echo "1. Start HTTP server:"
echo " ${GREEN}python3 -m skill_seekers.mcp.server_fastmcp --transport http --port 3000${NC}"
echo ""
echo "2. Add to agent config:"
echo -e "${GREEN}{"
echo " \"mcpServers\": {"
echo " \"skill-seeker\": {"
echo " \"url\": \"http://localhost:3000/sse\""
echo " }"
echo " }"
echo -e "}${NC}"
echo ""
fi
fi
echo "=========================================================="
echo "Available MCP Tools (18 total):"
echo "=========================================================="
echo ""
echo "${CYAN}Config Tools:${NC}"
echo " • generate_config - Create config files for any docs site"
echo " • list_configs - Show all available preset configs"
echo " • validate_config - Validate config file structure"
echo ""
echo "${CYAN}Scraping Tools:${NC}"
echo " • estimate_pages - Estimate page count before scraping"
echo " • scrape_docs - Scrape documentation and build skills"
echo " • scrape_github - Scrape GitHub repositories"
echo " • scrape_pdf - Extract content from PDF files"
echo " • unified_scrape - Multi-source scraping (docs + github + pdf)"
echo ""
echo "${CYAN}Packaging Tools:${NC}"
echo " • package_skill - Package skills into .zip files"
echo " • upload_skill - Upload skills to platforms"
echo " • install_skill - Complete workflow automation"
echo ""
echo "${CYAN}Splitting Tools:${NC}"
echo " • split_config - Split large documentation configs"
echo " • generate_router - Generate router/hub skills"
echo ""
echo "${CYAN}Config Source Tools:${NC}"
echo " • fetch_config - Download configs from remote sources"
echo " • submit_config - Submit configs to community"
echo " • add_config_source - Add custom config sources"
echo " • list_config_sources - Show available config sources"
echo " • remove_config_source - Remove config sources"
echo ""
echo "=========================================================="
echo "CLI Commands:"
echo "=========================================================="
echo " ${GREEN}skill-seekers --help${NC} # Show all commands"
echo " ${GREEN}skill-seekers scrape${NC} # Scrape documentation"
echo " ${GREEN}skill-seekers github${NC} # Scrape GitHub repos"
echo " ${GREEN}skill-seekers unified${NC} # Multi-source scraping"
echo " ${GREEN}skill-seekers install${NC} # One-command workflow"
echo ""
echo "=========================================================="
echo "Troubleshooting:"
echo "=========================================================="
echo " • Test MCP server:"
echo " ${CYAN}python3 -m skill_seekers.mcp.server_fastmcp${NC}"
echo ""
echo " • Test HTTP server:"
echo " ${CYAN}python3 -m skill_seekers.mcp.server_fastmcp --transport http --port 8000${NC}"
echo " ${CYAN}curl http://127.0.0.1:8000/health${NC}"
echo ""
echo " • View server logs (if HTTP):"
echo " ${CYAN}tail -f /tmp/skill-seekers-mcp.log${NC}"
echo ""
echo "Happy skill creating! 🚀"
echo ""