Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·454 lines (377 loc) · 13.5 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·454 lines (377 loc) · 13.5 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
#!/usr/bin/env bash
# OpenCode Agent Team Installer
# https://github.com/BrightEra/opencode-agent-team
# MIT License - Justin Carlson / BrightEra
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
MAGENTA='\033[0;35m'
NC='\033[0m' # No Color
# Configuration
INSTALL_DIR="${HOME}/.config/opencode"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VERSION="1.0.0"
BACKUP_DIR="${HOME}/.config/opencode.backup.$(date +%Y%m%d_%H%M%S)"
# Files to install (relative to SCRIPT_DIR)
declare -a FILES_TO_INSTALL=(
"opencode.json"
"AGENTS.md"
".opencode/prompts/plan.md"
".opencode/prompts/build.md"
)
#==============================================================================
# Output Functions
#==============================================================================
print_banner() {
echo -e "${CYAN}"
cat << "EOF"
___ ____ _
/ _ \ _ __ ___ _ __ / ___|___ __| | ___
| | | | '_ \ / _ \ '_ \| | / _ \ / _` |/ _ \
| |_| | |_) | __/ | | | |__| (_) | (_| | __/
\___/| .__/ \___|_| |_|\____\___/ \__,_|\___|
|_|
_ _ _____
/ \ __ _ ___ _ __ | |_ |_ _|__ __ _ _ __ ___
/ _ \ / _` |/ _ \ '_ \| __| | |/ _ \/ _` | '_ ` _ \
/ ___ \ (_| | __/ | | | |_ | | __/ (_| | | | | | |
/_/ \_\__, |\___|_| |_|\__| |_|\___|\__,_|_| |_| |_|
|___/
EOF
echo -e "${NC}"
echo -e "${BLUE}Version ${VERSION}${NC}"
echo -e "${BLUE}https://github.com/BrightEra/opencode-agent-team${NC}"
echo ""
}
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
print_error() {
echo -e "${RED}✗${NC} $1" >&2
}
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
}
print_info() {
echo -e "${BLUE}ℹ${NC} $1"
}
print_step() {
echo -e "${MAGENTA}▸${NC} $1"
}
#==============================================================================
# Utility Functions
#==============================================================================
check_prerequisites() {
print_step "Checking prerequisites..."
# Check if opencode CLI is installed
if command -v opencode &> /dev/null; then
local version=$(opencode --version 2>/dev/null || echo "unknown")
print_success "OpenCode CLI found (${version})"
else
print_warning "OpenCode CLI not found"
echo ""
echo -e "${YELLOW}The OpenCode CLI is required to use this agent team.${NC}"
echo -e "Install it from: ${CYAN}https://opencode.ai${NC}"
echo ""
read -p "Continue installation anyway? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
print_error "Installation cancelled"
exit 1
fi
fi
# Check if git is available (for better context)
if command -v git &> /dev/null; then
print_success "Git found"
else
print_warning "Git not found (optional, but recommended)"
fi
echo ""
}
backup_existing() {
if [ -d "$INSTALL_DIR" ]; then
print_step "Backing up existing configuration..."
# Create backup directory
mkdir -p "$BACKUP_DIR"
# Copy existing files
cp -r "$INSTALL_DIR"/* "$BACKUP_DIR/" 2>/dev/null || true
print_success "Backup created at: ${BACKUP_DIR}"
echo ""
fi
}
verify_source_files() {
print_step "Verifying source files..."
local missing_files=()
for file in "${FILES_TO_INSTALL[@]}"; do
if [ ! -f "$SCRIPT_DIR/$file" ] && [ ! -d "$SCRIPT_DIR/$file" ]; then
missing_files+=("$file")
fi
done
if [ ${#missing_files[@]} -gt 0 ]; then
print_error "Missing source files:"
for file in "${missing_files[@]}"; do
echo " - $file"
done
exit 1
fi
print_success "All source files found"
echo ""
}
#==============================================================================
# Installation Functions
#==============================================================================
install_copy() {
print_step "Installing files (copy mode)..."
echo ""
# Create installation directory
mkdir -p "$INSTALL_DIR"
mkdir -p "$INSTALL_DIR/.opencode/prompts"
# Copy each file
for file in "${FILES_TO_INSTALL[@]}"; do
local source="$SCRIPT_DIR/$file"
local target="$INSTALL_DIR/$file"
local target_dir=$(dirname "$target")
# Create target directory if needed
mkdir -p "$target_dir"
# Copy file
if cp "$source" "$target"; then
print_success "Copied: $file"
else
print_error "Failed to copy: $file"
exit 1
fi
done
echo ""
print_success "Installation complete (copy mode)"
}
install_symlink() {
print_step "Installing files (symlink mode)..."
echo ""
# Create installation directory
mkdir -p "$INSTALL_DIR"
mkdir -p "$INSTALL_DIR/.opencode/prompts"
# Create symlinks for each file
for file in "${FILES_TO_INSTALL[@]}"; do
local source="$SCRIPT_DIR/$file"
local target="$INSTALL_DIR/$file"
local target_dir=$(dirname "$target")
# Create target directory if needed
mkdir -p "$target_dir"
# Remove existing file/symlink if present
if [ -e "$target" ] || [ -L "$target" ]; then
rm -f "$target"
fi
# Create symlink
if ln -s "$source" "$target"; then
print_success "Linked: $file → $source"
else
print_error "Failed to link: $file"
exit 1
fi
done
echo ""
print_success "Installation complete (symlink mode)"
print_info "Files are linked to: $SCRIPT_DIR"
print_info "Pull updates with: cd $SCRIPT_DIR && git pull"
}
uninstall() {
print_step "Uninstalling OpenCode Agent Team..."
echo ""
if [ ! -d "$INSTALL_DIR" ]; then
print_warning "No installation found at: $INSTALL_DIR"
exit 0
fi
# Show what will be removed
echo -e "${YELLOW}The following will be removed:${NC}"
echo " - $INSTALL_DIR/opencode.json"
echo " - $INSTALL_DIR/AGENTS.md"
echo " - $INSTALL_DIR/.opencode/prompts/"
echo ""
# Confirm
read -p "Are you sure you want to uninstall? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
print_info "Uninstall cancelled"
exit 0
fi
# Create backup before removing
backup_existing
# Remove installed files
for file in "${FILES_TO_INSTALL[@]}"; do
local target="$INSTALL_DIR/$file"
if [ -e "$target" ] || [ -L "$target" ]; then
rm -f "$target"
print_success "Removed: $file"
fi
done
# Remove empty directories
rmdir "$INSTALL_DIR/.opencode/prompts" 2>/dev/null || true
rmdir "$INSTALL_DIR/.opencode" 2>/dev/null || true
# Check if INSTALL_DIR is empty (except for other user files)
if [ -z "$(ls -A $INSTALL_DIR 2>/dev/null)" ]; then
rmdir "$INSTALL_DIR"
print_success "Removed directory: $INSTALL_DIR"
else
print_info "Kept directory (contains other files): $INSTALL_DIR"
fi
echo ""
print_success "Uninstall complete"
print_info "Backup available at: $BACKUP_DIR"
}
#==============================================================================
# Post-Install Instructions
#==============================================================================
show_post_install() {
echo ""
echo -e "${GREEN}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ Installation Successful! ║${NC}"
echo -e "${GREEN}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${CYAN}📋 Next Steps:${NC}"
echo ""
echo -e "${YELLOW}1. Set up your Anthropic API key${NC}"
echo " The agent team requires an Anthropic API key to function."
echo ""
echo " Option A - Environment variable (recommended):"
echo -e " ${BLUE}export ANTHROPIC_API_KEY='your-api-key-here'${NC}"
echo ""
echo " Option B - Secrets file:"
echo -e " ${BLUE}echo 'ANTHROPIC_API_KEY=your-api-key-here' >> ~/.secrets${NC}"
echo ""
echo -e "${YELLOW}2. (Optional) Set up enhanced search capabilities${NC}"
echo " For better documentation search and code context:"
echo ""
echo " Exa API (web search & code context):"
echo -e " ${BLUE}export EXA_API_KEY='your-exa-key'${NC}"
echo -e " Get a key at: ${CYAN}https://exa.ai${NC}"
echo ""
echo " Ref API (documentation search):"
echo -e " ${BLUE}export REF_API_KEY='your-ref-key'${NC}"
echo -e " Get a key at: ${CYAN}https://ref.tools${NC}"
echo ""
echo -e "${YELLOW}3. Start using the agent team${NC}"
echo " Navigate to any project directory and run:"
echo -e " ${BLUE}opencode${NC}"
echo ""
echo " Or start with a specific agent:"
echo -e " ${BLUE}opencode --agent plan${NC}"
echo -e " ${BLUE}opencode --agent build${NC}"
echo ""
echo -e "${CYAN}📚 Available Agents:${NC}"
echo ""
echo " Primary Agents:"
echo " @plan - Strategic planning and coordination (Opus 4.5)"
echo " @build - Full implementation with all tools (Sonnet 4.5)"
echo ""
echo " Specialist Agents:"
echo " @scout - Fast codebase exploration (Haiku 4.5)"
echo " @research - Documentation and API lookup"
echo " @reviewer - Code quality review"
echo " @tester - Test creation and execution"
echo " @refactor - Code structure improvement"
echo " @debug - Bug investigation"
echo " @devops - Infrastructure and CI/CD"
echo " @security - Security auditing"
echo " @docs - Documentation writing (Haiku 4.5)"
echo ""
echo -e "${CYAN}💡 Quick Tips:${NC}"
echo ""
echo " • Start with @plan for complex tasks - it will coordinate subagents"
echo " • Use @build (or Tab) when you're ready to write code"
echo " • Agents can work in parallel for independent tasks"
echo " • Check AGENTS.md for workflow patterns and best practices"
echo ""
echo -e "${CYAN}📖 Documentation:${NC}"
echo " • Agent guide: $INSTALL_DIR/AGENTS.md"
echo " • Configuration: $INSTALL_DIR/opencode.json"
echo " • Project repo: https://github.com/BrightEra/opencode-agent-team"
echo ""
echo -e "${GREEN}Happy coding! 🚀${NC}"
echo ""
}
#==============================================================================
# Help
#==============================================================================
show_help() {
cat << EOF
OpenCode Agent Team Installer v${VERSION}
USAGE:
./install.sh [MODE]
MODES:
--copy Copy files to ~/.config/opencode (default)
Files are independent of the source repository.
--symlink Create symlinks to source files
Files stay in sync with the repository.
Useful for development or easy updates via git pull.
--uninstall Remove the installation
Creates a backup before removing files.
--help Show this help message
EXAMPLES:
# Install with copy (default)
./install.sh
./install.sh --copy
# Install with symlinks (for easy updates)
./install.sh --symlink
# Remove installation
./install.sh --uninstall
INSTALLATION DIRECTORY:
${INSTALL_DIR}
FILES INSTALLED:
- opencode.json (Agent configuration)
- AGENTS.md (Workflow guide)
- .opencode/prompts/plan.md (Plan agent prompt)
- .opencode/prompts/build.md (Build agent prompt)
REQUIREMENTS:
- OpenCode CLI (https://opencode.ai)
- Anthropic API key
OPTIONAL:
- Exa API key (enhanced search)
- Ref API key (documentation search)
MORE INFO:
https://github.com/BrightEra/opencode-agent-team
EOF
}
#==============================================================================
# Main
#==============================================================================
main() {
local mode="${1:-copy}"
# Parse arguments
case "$mode" in
--copy|copy)
print_banner
check_prerequisites
verify_source_files
backup_existing
install_copy
show_post_install
;;
--symlink|symlink)
print_banner
check_prerequisites
verify_source_files
backup_existing
install_symlink
show_post_install
;;
--uninstall|uninstall)
print_banner
uninstall
;;
--help|help|-h)
show_help
;;
*)
print_error "Unknown mode: $mode"
echo ""
echo "Run './install.sh --help' for usage information"
exit 1
;;
esac
}
# Run main function
main "$@"