forked from wshobson/agents
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·287 lines (237 loc) · 8.83 KB
/
install.sh
File metadata and controls
executable file
·287 lines (237 loc) · 8.83 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
#!/bin/bash
# Claude Code Agents Installation Script
# This script automatically installs and configures agents for Claude Code
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
# Default Claude Code directory
CLAUDE_DIR="$HOME/.claude"
AGENTS_DIR="$CLAUDE_DIR/agents"
CONFIG_FILE="$CLAUDE_DIR/claude_code_config.json"
BACKUP_SUFFIX=".backup.$(date +%Y%m%d_%H%M%S)"
# Function to print colored output
print_color() {
echo -e "${2}${1}${NC}"
}
# Function to print header
print_header() {
echo ""
print_color "=====================================" "$BLUE"
print_color "$1" "$BLUE"
print_color "=====================================" "$BLUE"
echo ""
}
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to create backup
create_backup() {
if [ -f "$1" ]; then
cp "$1" "$1$BACKUP_SUFFIX"
print_color "✓ Backed up: $1" "$GREEN"
fi
}
# Welcome message
print_header "Claude Code Agents Installer"
print_color "This script will install Claude Code agents to enhance your development experience." "$YELLOW"
echo ""
# Check prerequisites
print_color "Checking prerequisites..." "$YELLOW"
if ! command_exists git; then
print_color "✗ Git is not installed. Please install git first." "$RED"
exit 1
fi
if ! command_exists jq; then
print_color "⚠ jq is not installed. Installing jq is recommended for JSON processing." "$YELLOW"
read -p "Would you like to continue without jq? (y/n): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
USE_JQ=false
else
USE_JQ=true
fi
# Check if Claude Code directory exists
if [ ! -d "$CLAUDE_DIR" ]; then
print_color "Creating Claude Code directory at $CLAUDE_DIR..." "$YELLOW"
mkdir -p "$CLAUDE_DIR"
fi
# Clone or update agents repository
print_header "Setting up Agents"
if [ -d "$AGENTS_DIR" ]; then
print_color "Agents directory already exists. Updating..." "$YELLOW"
cd "$AGENTS_DIR"
# Check if it's a git repository
if [ -d ".git" ]; then
# Stash any local changes
git stash push -m "Auto-stash before update $(date +%Y%m%d_%H%M%S)" >/dev/null 2>&1 || true
# Pull latest changes
git pull origin main || git pull origin master || {
print_color "⚠ Could not update repository. Using existing version." "$YELLOW"
}
print_color "✓ Agents updated successfully" "$GREEN"
else
print_color "⚠ Existing directory is not a git repository. Skipping update." "$YELLOW"
fi
else
print_color "Cloning agents repository..." "$YELLOW"
git clone https://github.com/OrrisTech/agents.git "$AGENTS_DIR" || {
print_color "✗ Failed to clone repository. Please check your internet connection." "$RED"
exit 1
}
print_color "✓ Agents cloned successfully" "$GREEN"
fi
# Generate agents configuration
print_header "Generating Configuration"
cd "$AGENTS_DIR"
# Create agents.json from markdown files
print_color "Scanning for agent files..." "$YELLOW"
cat > "$AGENTS_DIR/agents.json" << 'EOF'
{
"agents": [
EOF
FIRST=true
for file in *.md; do
# Skip README and LICENSE files
if [[ "$file" == "README.md" ]] || [[ "$file" == "LICENSE.md" ]]; then
continue
fi
# Extract agent ID from filename
AGENT_ID="${file%.md}"
# Convert ID to title case for name
AGENT_NAME=$(echo "$AGENT_ID" | sed 's/-/ /g' | sed 's/\b\(.\)/\u\1/g')
# Extract first meaningful line from file as description
DESCRIPTION=$(grep -m 1 "^[A-Z]" "$file" 2>/dev/null | head -c 100 || echo "Specialized agent for $AGENT_NAME")
DESCRIPTION="${DESCRIPTION//\"/\\\"}"
if [ "$FIRST" = true ]; then
FIRST=false
else
echo "," >> "$AGENTS_DIR/agents.json"
fi
cat >> "$AGENTS_DIR/agents.json" << EOF
{
"id": "$AGENT_ID",
"name": "$AGENT_NAME",
"description": "$DESCRIPTION",
"file": "$file"
}
EOF
done
cat >> "$AGENTS_DIR/agents.json" << 'EOF'
]
}
EOF
AGENT_COUNT=$(grep -c '"id":' "$AGENTS_DIR/agents.json")
print_color "✓ Found and configured $AGENT_COUNT agents" "$GREEN"
# Update Claude Code configuration
print_header "Updating Claude Code Configuration"
# Backup existing configuration
if [ -f "$CONFIG_FILE" ]; then
create_backup "$CONFIG_FILE"
# Check if agents configuration already exists
if grep -q '"agents"' "$CONFIG_FILE" 2>/dev/null; then
print_color "⚠ Agents configuration already exists in claude_code_config.json" "$YELLOW"
read -p "Would you like to update it? (y/n): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
print_color "Skipping configuration update." "$YELLOW"
else
# Update existing configuration
if [ "$USE_JQ" = true ]; then
jq '.agents = {"directory": "./agents", "config": "./agents/agents.json"}' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
print_color "✓ Updated agents configuration" "$GREEN"
else
print_color "⚠ Manual configuration update required (jq not available)" "$YELLOW"
fi
fi
else
# Add agents configuration
if [ "$USE_JQ" = true ]; then
jq '. + {"agents": {"directory": "./agents", "config": "./agents/agents.json"}}' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
print_color "✓ Added agents configuration" "$GREEN"
else
# Manual JSON modification without jq
sed -i.tmp '1a\
"agents": {\
"directory": "./agents",\
"config": "./agents/agents.json"\
},' "$CONFIG_FILE"
rm -f "$CONFIG_FILE.tmp"
print_color "✓ Added agents configuration (manual method)" "$GREEN"
fi
fi
else
# Create new configuration file
cat > "$CONFIG_FILE" << 'EOF'
{
"name": "Claude Code Configuration",
"agents": {
"directory": "./agents",
"config": "./agents/agents.json"
}
}
EOF
print_color "✓ Created new claude_code_config.json with agents configuration" "$GREEN"
fi
# Create quick reference
print_header "Creating Quick Reference"
cat > "$AGENTS_DIR/QUICK_REFERENCE.md" << 'EOF'
# Claude Code Agents Quick Reference
## Available Agents
To use an agent, simply describe your task and Claude Code will automatically select the appropriate agent, or you can explicitly request a specific agent.
### Development & Architecture
- **backend-architect** - API design, microservices, databases
- **frontend-developer** - React, responsive layouts, state management
- **mobile-developer** - React Native, Flutter, native integrations
- **ui-ux-designer** - Interface design, wireframes, design systems
### Programming Languages
- **python-pro** - Advanced Python features and optimizations
- **typescript-pro** - TypeScript with strict type safety
- **golang-pro** - Go with goroutines and channels
- **rust-pro** - Rust ownership and lifetimes
- **java-pro** - Modern Java with streams and concurrency
### Infrastructure & DevOps
- **devops-troubleshooter** - Debug production issues
- **cloud-architect** - AWS/Azure/GCP infrastructure
- **kubernetes-architect** - K8s and cloud-native design
- **deployment-engineer** - CI/CD pipelines, Docker
### Quality & Security
- **code-reviewer** - Code quality and security review
- **security-auditor** - Vulnerability assessment, OWASP
- **test-automator** - Unit, integration, e2e tests
- **debugger** - Error diagnosis and fixes
### Data & AI
- **data-scientist** - SQL, BigQuery, data analysis
- **ai-engineer** - LLM applications, RAG systems
- **ml-engineer** - ML pipelines, model serving
## Usage Examples
1. "Review my code for security issues" → Activates security-auditor
2. "Help me optimize this Python function" → Activates python-pro
3. "Design a REST API for user management" → Activates backend-architect
4. "Debug this production error" → Activates devops-troubleshooter
## Commands
- List agents: `/agents`
- Get help: `/help`
EOF
print_color "✓ Created quick reference at $AGENTS_DIR/QUICK_REFERENCE.md" "$GREEN"
# Final summary
print_header "Installation Complete!"
print_color "✅ Successfully installed $AGENT_COUNT Claude Code agents" "$GREEN"
echo ""
print_color "📁 Agents location: $AGENTS_DIR" "$BLUE"
print_color "📋 Configuration: $CONFIG_FILE" "$BLUE"
print_color "📖 Quick reference: $AGENTS_DIR/QUICK_REFERENCE.md" "$BLUE"
echo ""
print_color "🚀 Your Claude Code agents are now ready to use!" "$GREEN"
print_color " Restart Claude Code to load the new configuration." "$YELLOW"
echo ""
print_color "💡 Tip: View the quick reference to see all available agents and usage examples" "$YELLOW"
echo ""
# Cleanup
unset RED GREEN YELLOW BLUE NC CLAUDE_DIR AGENTS_DIR CONFIG_FILE BACKUP_SUFFIX USE_JQ