-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·621 lines (507 loc) · 21.5 KB
/
install.sh
File metadata and controls
executable file
·621 lines (507 loc) · 21.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
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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
#!/bin/bash
#
# GStack to CodeBuddy - One Command Install
# =========================================
# Installs Garry Tan's GStack (31 AI development skills) to CodeBuddy IDE
#
# Usage:
# # Quick install (project-level)
# curl -sSL https://raw.githubusercontent.com/[YOUR-USER]/gstack-codebuddy/master/install.sh | bash
#
# # Project-level install
# curl -sSL https://raw.githubusercontent.com/[YOUR-USER]/gstack-codebuddy/master/install.sh | bash -s -- --project
#
# # User-level install (all projects)
# curl -sSL https://raw.githubusercontent.com/[YOUR-USER]/gstack-codebuddy/master/install.sh | bash -s -- --user
#
# # Update existing installation
# curl -sSL https://raw.githubusercontent.com/[YOUR-USER]/gstack-codebuddy/master/install.sh | bash -s -- --update
#
set -euo pipefail
# ═══════════════════════════════════════════════════════════════
# Configuration
# ═══════════════════════════════════════════════════════════════
GSTACK_REPO="https://github.com/garrytan/gstack.git"
GSTACK_BRANCH="main"
SCRIPT_VERSION="1.0.0"
# Colors (disabled if not a terminal)
if [[ -t 1 ]]; then
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
else
RED='' GREEN='' YELLOW='' BLUE='' CYAN='' BOLD='' NC=''
fi
# ═══════════════════════════════════════════════════════════════
# Usage Information
# ═══════════════════════════════════════════════════════════════
usage() {
cat << EOF
GStack for CodeBuddy Installer v${SCRIPT_VERSION}
Usage: $(basename "$0") [OPTIONS]
Options:
--project Install to current project (.codebuddy/skills)
--user Install to user home (~/.codebuddy/skills)
--update Update existing installation
--force Force reinstall even if exists
--repo URL Custom GStack repository URL
--branch BRANCH Git branch to use (default: main)
-h, --help Show this help message
Examples:
# Project-level install
$(basename "$0") --project
# User-level install
$(basename "$0") --user
# Update existing
$(basename "$0") --update
# One-liner (project)
curl -sSL https://raw.githubusercontent.com/[USER]/gstack-codebuddy/master/install.sh | bash -s -- --project
# One-liner (user)
curl -sSL https://raw.githubusercontent.com/[USER]/gstack-codebuddy/master/install.sh | bash -s -- --user
EOF
exit 0
}
# ═══════════════════════════════════════════════════════════════
# Utility Functions
# ═══════════════════════════════════════════════════════════════
log_info() { echo -e "${BLUE}[INFO]${NC} $*"; }
log_success() { echo -e "${GREEN}[OK]${NC} $*"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
# Print step number
STEP=0
log_step() {
STEP=$((STEP + 1))
echo -e "\n${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BOLD}${CYAN}Step $STEP: $1${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
}
# Detect if running in terminal
is_terminal() { [[ -t 1 ]]; }
# Check command exists
command_exists() { command -v "$1" &>/dev/null; }
# ═══════════════════════════════════════════════════════════════
# Banner
# ═══════════════════════════════════════════════════════════════
print_banner() {
if ! is_terminal; then return; fi
cat << 'EOF'
╔═══════════════════════════════════════════════════════════════╗
║ ║
║ █████╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ║
║ ██╔══██╗██║ ██╔════╝ ██╔═══██╗██╔══██╗╚██╗ ██╔╝ ║
║ ███████║██║ ██║ ███╗██║ ██║██████╔╝ ╚████╔╝ ║
║ ██╔══██║██║ ██║ ██║██║ ██║██╔══██╗ ╚██╔╝ ║
║ ██║ ██║███████╗╚██████╔╝╚██████╔╝██║ ██║ ██║ ║
║ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ║
║ ║
║ for CodeBuddy IDE ║
║ ║
║ Garry Tan's AI Development Workflow ║
║ 31 Specialized AI Agents ║
║ ║
╚═══════════════════════════════════════════════════════════════╝
EOF
}
# ═══════════════════════════════════════════════════════════════
# Prerequisites Check
# ═══════════════════════════════════════════════════════════════
check_prerequisites() {
log_step "Checking prerequisites"
local missing=0
# Check git
if command_exists git; then
log_success "Git: $(git --version)"
else
log_error "Git is required but not installed"
missing=1
fi
# Check for codebuddy directory
if [[ -d "$HOME/.codebuddy" ]] || [[ -d "$(pwd)/.codebuddy" ]]; then
log_success "CodeBuddy config directory found"
else
log_warn "No CodeBuddy config directory found (will be created)"
fi
if [[ $missing -eq 1 ]]; then
log_error "Missing required dependencies"
exit 1
fi
}
# ═══════════════════════════════════════════════════════════════
# Parse Arguments
# ═══════════════════════════════════════════════════════════════
parse_args() {
local install_type=""
local force=false
while [[ $# -gt 0 ]]; do
case $1 in
--project)
install_type="project"
shift
;;
--user)
install_type="user"
shift
;;
--update)
install_type="update"
shift
;;
--force)
force=true
shift
;;
--repo)
GSTACK_REPO="$2"
shift 2
;;
--branch)
GSTACK_BRANCH="$2"
shift 2
;;
-h|--help)
usage
;;
*)
log_error "Unknown option: $1"
usage
;;
esac
done
# If no install type specified, auto-detect
if [[ -z "$install_type" ]]; then
if [[ -d "$(pwd)/.codebuddy" ]]; then
install_type="project"
elif [[ -d "$HOME/.codebuddy" ]]; then
install_type="user"
else
install_type="project"
fi
fi
INSTALL_TYPE="$install_type"
FORCE="$force"
}
# ═══════════════════════════════════════════════════════════════
# Determine Installation Location
# ═══════════════════════════════════════════════════════════════
get_install_dir() {
case "$INSTALL_TYPE" in
project)
INSTALL_DIR="$(pwd)/.codebuddy/skills/gstack"
;;
user)
INSTALL_DIR="$HOME/.codebuddy/skills/gstack"
;;
update)
# Auto-detect existing installation
if [[ -d "$(pwd)/.codebuddy/skills/gstack" ]]; then
INSTALL_DIR="$(pwd)/.codebuddy/skills/gstack"
INSTALL_TYPE="project"
elif [[ -d "$HOME/.codebuddy/skills/gstack" ]]; then
INSTALL_DIR="$HOME/.codecodebuddy/skills/gstack"
INSTALL_TYPE="user"
else
log_error "No existing GStack installation found"
log_info "Use --project or --user to install"
exit 1
fi
;;
esac
}
# ═══════════════════════════════════════════════════════════════
# Clone or Update GStack
# ═══════════════════════════════════════════════════════════════
fetch_gstack() {
log_step "Fetching GStack"
# Check if it's an update
if [[ "$INSTALL_TYPE" == "update" ]]; then
log_info "Updating existing installation..."
cd "$INSTALL_DIR"
if [[ -d .git ]]; then
local current_remote
current_remote=$(git remote get-url origin 2>/dev/null || echo "")
if [[ -n "$current_remote" ]]; then
log_info "Current remote: $current_remote"
fi
git fetch --depth 1 origin "$GSTACK_BRANCH" 2>/dev/null || true
git checkout "$GSTACK_BRANCH" 2>/dev/null || true
git pull origin "$GSTACK_BRANCH" 2>/dev/null || true
log_success "GStack updated to latest"
return 0
else
log_warn "Not a git repository, cannot update. Reinstalling..."
fi
fi
# Create parent directory
local parent_dir
parent_dir=$(dirname "$INSTALL_DIR")
mkdir -p "$parent_dir"
# Check if already exists
if [[ -d "$INSTALL_DIR" ]]; then
if [[ "$FORCE" == "true" ]]; then
log_warn "Force reinstalling..."
rm -rf "$INSTALL_DIR"
else
log_error "Installation already exists at: $INSTALL_DIR"
log_info "Use --force to reinstall or --update to update"
exit 1
fi
fi
# Clone GStack
log_info "Cloning from: $GSTACK_REPO"
log_info "Branch: $GSTACK_BRANCH"
if git clone --depth 1 --branch "$GSTACK_BRANCH" "$GSTACK_REPO" "$INSTALL_DIR"; then
log_success "GStack cloned successfully"
else
log_error "Failed to clone GStack"
exit 1
fi
}
# ═══════════════════════════════════════════════════════════════
# Convert to CodeBuddy Format
# ║══════════════════════════════════════════════════════════════
convert_to_codebuddy() {
log_step "Converting to CodeBuddy format"
cd "$INSTALL_DIR"
# Create skills directory
mkdir -p skills
# The main SKILL.md needs to be formatted for CodeBuddy
# CodeBuddy reads SKILL.md at the root of each skill
# Backup original
if [[ -f "SKILL.md" ]] && [[ ! -f "SKILL.md.original" ]]; then
cp SKILL.md SKILL.md.original
fi
# Create CodeBuddy-compatible SKILL.md
cat > SKILL.md << 'EOF'
# GStack
GStack transforms AI coding assistants into a virtual engineering team with 31 specialized roles.
## Overview
GStack provides an opinionated development workflow inspired by Garry Tan (Y Combinator CEO). It includes skills for product planning, design, development, testing, release, and more.
## Skills (31 Total)
### Product Planning
- `/office-hours` - YC-style product brainstorming
- `/plan-ceo-review` - Product strategy review
- `/plan-eng-review` - Technical architecture review
- `/plan-design-review` - Design quality review
- `/autoplan` - Automated planning pipeline
### Design
- `/design-consultation` - Design partner consultation
- `/design-shotgun` - Design exploration
- `/design-html` - HTML generation
- `/design-review` - Design review
### Development
- `/review` - Code review
- `/investigate` - Debugging
- `/codex` - Codex second opinion
- `/cso` - Security audit
### Testing
- `/qa` - QA testing
- `/qa-only` - Bug reporting
- `/browse` - Browser automation
### Release
- `/ship` - Open PR
- `/land-and-deploy` - Deploy
- `/canary` - Monitoring
- `/benchmark` - Performance
### Documentation
- `/document-release` - Documentation
### Process
- `/retro` - Team retro
- `/learn` - Memory
### Safety
- `/careful` - Warnings
- `/freeze` - Lock
- `/guard` - Full safety
- `/unfreeze` - Unlock
### Tools
- `/connect-chrome` - Chrome control
- `/setup-browser-cookies` - Cookies
- `/setup-deploy` - Deploy config
- `/gstack-upgrade` - Updater
## Installation
This skill is automatically installed via the setup script.
## Credit
Created by Garry Tan (Y Combinator)
https://github.com/garrytan/gstack
MIT License
EOF
# Extract individual skills from README if available
if [[ -f "README.md" ]]; then
# GStack has skill definitions in README
log_info "Processing skill definitions..."
fi
log_success "Conversion complete"
}
# ═══════════════════════════════════════════════════════════════
# Create Setup Scripts
# ═══════════════════════════════════════════════════════════════
create_scripts() {
log_step "Creating setup and update scripts"
cd "$INSTALL_DIR"
# Setup script
cat > setup-codebuddy << 'SETUP_EOF'
#!/bin/bash
#
# GStack for CodeBuddy - Setup Script
# Run this to configure GStack for CodeBuddy IDE
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "Setting up GStack for CodeBuddy..."
# Detect CodeBuddy config directory
if [[ -d "$SCRIPT_DIR/../../.codebuddy" ]]; then
# Project-level
CODEBUDDY_DIR="$SCRIPT_DIR/../../.codebuddy"
elif [[ -d "$HOME/.codebuddy" ]]; then
# User-level
CODEBUDDY_DIR="$HOME/.codebuddy"
else
# Create new
mkdir -p "$HOME/.codebuddy"
CODEBUDDY_DIR="$HOME/.codebuddy"
fi
# Create skills directory
mkdir -p "$CODEBUDDY_DIR/skills"
# Create symlink
SKILL_LINK="$CODEBUDDY_DIR/skills/gstack"
if [[ -L "$SKILL_LINK" ]]; then
rm "$SKILL_LINK"
elif [[ -d "$SKILL_LINK" ]]; then
echo "Warning: $SKILL_LINK is a directory"
fi
ln -sf "$SCRIPT_DIR" "$SKILL_LINK"
echo "✓ Created: $SKILL_LINK -> $SCRIPT_DIR"
echo ""
echo "✓ Setup complete!"
echo ""
echo "Restart CodeBuddy IDE to use GStack skills."
SETUP_EOF
chmod +x setup-codebuddy
log_success "Created: setup-codebuddy"
# Update script
cat > update-gstack << 'UPDATE_EOF'
#!/bin/bash
#
# GStack Update Script
# Run this to update GStack when new versions are released
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "Updating GStack..."
if [[ ! -d .git ]]; then
echo "Error: Not a git repository"
echo "Reinstall using the install script"
exit 1
fi
# Check for updates
if git rev-parse --verify HEAD &>/dev/null; then
echo "Current version: $(git describe --tags --always HEAD 2>/dev/null || echo 'unknown')"
fi
# Pull latest
git fetch origin --depth 1
git checkout main 2>/dev/null || git checkout master 2>/dev/null || true
git pull origin main 2>/dev/null || git pull origin master 2>/dev/null || true
echo ""
echo "✓ GStack updated!"
echo ""
echo "Restart CodeBuddy to use updated skills."
UPDATE_EOF
chmod +x update-gstack
log_success "Created: update-gstack"
}
# ═══════════════════════════════════════════════════════════════
# Run Setup
# ═══════════════════════════════════════════════════════════════
run_setup() {
log_step "Running CodeBuddy setup"
cd "$INSTALL_DIR"
# Run the setup script
if ./setup-codebuddy; then
log_success "CodeBuddy setup complete"
else
log_warn "Setup script failed (this is normal for initial install)"
fi
}
# ═══════════════════════════════════════════════════════════════
# Verification
# ═══════════════════════════════════════════════════════════════
verify() {
log_step "Verifying installation"
cd "$INSTALL_DIR"
local errors=0
# Check SKILL.md
if [[ -f "SKILL.md" ]]; then
log_success "SKILL.md exists"
else
log_error "SKILL.md missing"
errors=$((errors + 1))
fi
# Check setup script
if [[ -x "setup-codebuddy" ]]; then
log_success "setup-codebuddy is executable"
else
log_error "setup-codebuddy not executable"
errors=$((errors + 1))
fi
# Check update script
if [[ -x "update-gstack" ]]; then
log_success "update-gstack is executable"
else
log_error "update-gstack not executable"
errors=$((errors + 1))
fi
if [[ $errors -gt 0 ]]; then
log_error "Verification failed with $errors errors"
exit 1
fi
}
# ═══════════════════════════════════════════════════════════════
# Print Completion
# ═══════════════════════════════════════════════════════════════
print_completion() {
echo ""
echo -e "${GREEN}╔═══════════════════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ INSTALLATION COMPLETE! ║${NC}"
echo -e "${GREEN}╚═══════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${BOLD}Location:${NC} $INSTALL_DIR"
echo -e "${BOLD}Type:${NC} $INSTALL_TYPE"
echo ""
echo -e "${BOLD}Next Steps:${NC}"
echo " 1. Restart CodeBuddy IDE"
echo " 2. GStack skills will be available automatically"
echo ""
echo -e "${BOLD}Available Skills:${NC} 31"
echo ""
echo -e "${BOLD}To Update Later:${NC}"
echo " cd $INSTALL_DIR && ./update-gstack"
echo ""
echo -e "${BLUE}GStack for CodeBuddy v${SCRIPT_VERSION}${NC}"
}
# ═══════════════════════════════════════════════════════════════
# Main
# ═══════════════════════════════════════════════════════════════
main() {
print_banner
# Parse arguments
parse_args "$@"
# Get installation directory
get_install_dir
log_info "Install type: $INSTALL_TYPE"
log_info "Install directory: $INSTALL_DIR"
# Run installation steps
check_prerequisites
fetch_gstack
convert_to_codebuddy
create_scripts
run_setup
verify
print_completion
}
# Run main
main "$@"