#!/bin/bash # Setup script for GitHub Copilot SDK Development Environment # This script automates the installation of prerequisites for agentic app development set -e # Exit on error # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Helper functions print_header() { echo -e "\n${BLUE}======================================${NC}" echo -e "${BLUE}$1${NC}" echo -e "${BLUE}======================================${NC}\n" } print_success() { echo -e "${GREEN}✓${NC} $1" } print_warning() { echo -e "${YELLOW}⚠${NC} $1" } print_error() { echo -e "${RED}✗${NC} $1" } check_command() { if command -v "$1" &> /dev/null; then return 0 else return 1 fi } # Detect OS detect_os() { if [[ "$OSTYPE" == "linux-gnu"* ]]; then echo "linux" elif [[ "$OSTYPE" == "darwin"* ]]; then echo "macos" elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then echo "windows" else echo "unknown" fi } # Main setup print_header "GitHub Copilot SDK - Development Environment Setup" OS=$(detect_os) echo "Detected OS: $OS" # Check for GitHub CLI print_header "Checking Prerequisites" if check_command gh; then print_success "GitHub CLI (gh) is installed" gh --version else print_warning "GitHub CLI (gh) not found" echo "Installing GitHub CLI..." if [[ "$OS" == "macos" ]]; then if check_command brew; then brew install gh else print_error "Homebrew not found. Please install from https://brew.sh" exit 1 fi elif [[ "$OS" == "linux" ]]; then # Install gh on Linux curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null sudo apt update sudo apt install -y gh else print_error "Please install GitHub CLI manually: https://cli.github.com/" exit 1 fi print_success "GitHub CLI installed" fi # Check for Copilot CLI print_header "Checking Copilot CLI" if check_command copilot; then print_success "Copilot CLI is installed" copilot --version || true else print_warning "Copilot CLI not found" echo "Installing Copilot CLI extension..." gh extension install github/gh-copilot || gh extension upgrade github/gh-copilot print_success "Copilot CLI extension installed" fi # Check authentication print_header "Checking GitHub Authentication" if gh auth status &> /dev/null; then print_success "GitHub CLI is authenticated" else print_warning "GitHub CLI is not authenticated" echo "Please authenticate now..." gh auth login fi # Ask user which SDKs to set up print_header "SDK Selection" echo "Which SDKs would you like to set up? (You can select multiple)" echo "" read -p "Set up Node.js/TypeScript SDK? (y/n): " setup_nodejs read -p "Set up Python SDK? (y/n): " setup_python read -p "Set up Go SDK? (y/n): " setup_go read -p "Set up .NET SDK? (y/n): " setup_dotnet # Node.js Setup if [[ "$setup_nodejs" =~ ^[Yy]$ ]]; then print_header "Setting up Node.js/TypeScript SDK" if check_command node; then NODE_VERSION=$(node -v) print_success "Node.js is installed: $NODE_VERSION" else print_error "Node.js not found. Please install from https://nodejs.org/" fi if check_command npm; then print_success "npm is installed: $(npm -v)" else print_error "npm not found" fi fi # Python Setup if [[ "$setup_python" =~ ^[Yy]$ ]]; then print_header "Setting up Python SDK" if check_command python3; then PYTHON_VERSION=$(python3 --version) print_success "Python is installed: $PYTHON_VERSION" else print_error "Python3 not found. Please install from https://www.python.org/" fi if check_command pip3; then print_success "pip is installed: $(pip3 --version)" else print_error "pip not found" fi # Check for uv (recommended) if check_command uv; then print_success "uv is installed: $(uv --version)" else print_warning "uv not found (recommended for faster Python package management)" read -p "Install uv? (y/n): " install_uv if [[ "$install_uv" =~ ^[Yy]$ ]]; then curl -LsSf https://astral.sh/uv/install.sh | sh print_success "uv installed" fi fi fi # Go Setup if [[ "$setup_go" =~ ^[Yy]$ ]]; then print_header "Setting up Go SDK" if check_command go; then GO_VERSION=$(go version) print_success "Go is installed: $GO_VERSION" else print_error "Go not found. Please install from https://go.dev/doc/install" fi fi # .NET Setup if [[ "$setup_dotnet" =~ ^[Yy]$ ]]; then print_header "Setting up .NET SDK" if check_command dotnet; then DOTNET_VERSION=$(dotnet --version) print_success ".NET is installed: $DOTNET_VERSION" else print_error ".NET not found. Please install from https://dotnet.microsoft.com/download" fi fi # Additional tools print_header "Checking Additional Development Tools" if check_command git; then print_success "Git is installed: $(git --version)" else print_warning "Git not found. Please install Git" fi if check_command code; then print_success "VS Code is installed" else print_warning "VS Code not found. Recommended for development: https://code.visualstudio.com/" fi # Summary print_header "Setup Summary" echo "Your development environment has been checked and configured!" echo "" echo "Next steps:" echo "1. Create a new project directory" echo "2. Install the SDK for your chosen language" echo "3. Follow the Getting Started guide: docs/getting-started.md" echo "" echo "Quick start examples:" if [[ "$setup_nodejs" =~ ^[Yy]$ ]]; then echo "" echo "Node.js/TypeScript:" echo " mkdir my-app && cd my-app" echo " npm init -y" echo " npm install @github/copilot-sdk tsx" fi if [[ "$setup_python" =~ ^[Yy]$ ]]; then echo "" echo "Python:" echo " mkdir my-app && cd my-app" echo " python3 -m venv venv" echo " source venv/bin/activate" echo " pip install github-copilot-sdk" fi if [[ "$setup_go" =~ ^[Yy]$ ]]; then echo "" echo "Go:" echo " mkdir my-app && cd my-app" echo " go mod init my-app" echo " go get github.com/github/copilot-sdk/go" fi if [[ "$setup_dotnet" =~ ^[Yy]$ ]]; then echo "" echo ".NET:" echo " dotnet new console -n MyApp" echo " cd MyApp" echo " dotnet add package GitHub.Copilot.SDK" fi echo "" print_success "Setup complete! Happy coding! 🚀"