# Quick Reference - Copilot SDK Setup Quick commands and references for setting up and using the GitHub Copilot SDK. ## Prerequisites Checklist ```bash # Check if prerequisites are installed gh --version # GitHub CLI copilot --version # Copilot CLI node -v # Node.js (optional) python3 --version # Python (optional) go version # Go (optional) dotnet --version # .NET (optional) ``` ## One-Line Installations ### GitHub CLI ```bash # macOS brew install gh # Linux (Debian/Ubuntu) curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/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 gh # Windows (PowerShell) winget install --id GitHub.cli ``` ### Copilot CLI ```bash gh extension install github/gh-copilot ``` ### Runtime Environments ```bash # Node.js - visit https://nodejs.org/ # macOS: brew install node # Python - visit https://python.org/ # macOS: brew install python # Go - visit https://go.dev/ # macOS: brew install go # .NET - visit https://dotnet.microsoft.com/ # macOS: brew install --cask dotnet-sdk ``` ## Automated Setup ```bash # Run automated setup (Linux/macOS) bash scripts/setup-dev-env.sh # Run automated setup (Windows PowerShell) .\scripts\setup-dev-env.ps1 # Validate your environment bash scripts/validate-env.sh ``` ## Quick Start Commands ### TypeScript Project ```bash # Create from template cp -r templates/typescript-quickstart my-app cd my-app # Setup npm install cp ../../templates/.env.example .env # Run npm start ``` ### Python Project ```bash # Create from template cp -r templates/python-quickstart my-app cd my-app # Setup python3 -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt cp ../../templates/.env.example .env # Run python src/main.py ``` ### Go Project ```bash mkdir my-app && cd my-app go mod init my-app go get github.com/github/copilot-sdk/go ``` ### .NET Project ```bash dotnet new console -n MyApp cd MyApp dotnet add package GitHub.Copilot.SDK dotnet run ``` ## SDK Installation ```bash # Node.js/TypeScript npm install @github/copilot-sdk tsx # Python pip install github-copilot-sdk # Python with uv (faster) uv pip install github-copilot-sdk # Go go get github.com/github/copilot-sdk/go # .NET dotnet add package GitHub.Copilot.SDK ``` ## Authentication ```bash # Login to GitHub gh auth login # Refresh Copilot token gh auth refresh -s copilot # Check auth status gh auth status ``` ## Environment Variables Create `.env` file: ```env COPILOT_MODEL=gpt-4.1 COPILOT_STREAMING=true LOG_LEVEL=info ``` ## Testing Your Setup ### CLI Test ```bash copilot "what is 2+2?" ``` ### TypeScript Test ```typescript import { CopilotClient } from "@github/copilot-sdk"; const client = new CopilotClient(); const session = await client.createSession({ model: "gpt-4.1" }); const response = await session.sendAndWait({ prompt: "Hello!" }); if (response?.data.content) { console.log(response.data.content); } await client.stop(); ``` ```bash npx tsx test.ts ``` ### Python Test ```python import asyncio from copilot import CopilotClient async def main(): client = CopilotClient() await client.start() session = await client.create_session({"model": "gpt-4.1"}) response = await session.send_and_wait({"prompt": "Hello!"}) print(response.data.content) await client.stop() asyncio.run(main()) ``` ```bash python test.py ``` ## Common Issues ### `copilot: command not found` ```bash gh extension install github/gh-copilot # Add to PATH if needed export PATH="$PATH:$HOME/.local/bin" ``` ### Authentication Errors ```bash gh auth login gh auth refresh -s copilot ``` ### Port Already in Use ```bash # The SDK handles this automatically # If issues persist, find and kill processes ps aux | grep copilot kill ``` ### Module Not Found (Node.js) ```bash npm install ``` ### Module Not Found (Python) ```bash source venv/bin/activate # or .venv/bin/activate pip install -r requirements.txt ``` ## Available Models Check available models: ```bash copilot models ``` Common models: - `gpt-4.1` - Latest GPT-4 (recommended) - `gpt-4o` - GPT-4 Optimized - `claude-3.5-sonnet` - Claude 3.5 Sonnet ## Directory Structure ``` my-agentic-app/ ├── .env # Environment variables ├── .gitignore # Git ignore rules ├── src/ # Source code │ ├── agents/ # Custom agent definitions │ ├── tools/ # Custom tool implementations │ └── main.[ts|py] # Entry point └── tests/ # Test files ``` ## Useful Links - [Environment Setup Guide](../docs/environment-setup.md) - [Getting Started Guide](../docs/getting-started.md) - [Project Templates](../templates/README.md) - [Cookbook Examples](../cookbook/README.md) - [GitHub Copilot Docs](https://docs.github.com/en/copilot) ## Getting Help - **Issues**: https://github.com/github/copilot-sdk/issues - **Discussions**: https://github.com/github/copilot-sdk/discussions - **Documentation**: Main README.md ## Scripts Overview | Script | Purpose | Usage | |--------|---------|-------| | `scripts/setup-dev-env.sh` | Automated setup (Linux/macOS) | `bash scripts/setup-dev-env.sh` | | `scripts/setup-dev-env.ps1` | Automated setup (Windows) | `.\scripts\setup-dev-env.ps1` | | `scripts/validate-env.sh` | Validate installation | `bash scripts/validate-env.sh` | ## Template Overview | Template | Language | Features | |----------|----------|----------| | `typescript-quickstart` | TypeScript | Interactive CLI, Custom tools, Hot reload | | `python-quickstart` | Python | Interactive CLI, Custom tools, Async/await | ## Next Steps After Setup 1. ✅ Validate environment: `bash scripts/validate-env.sh` 2. ✅ Choose a template: `cd templates/typescript-quickstart` 3. ✅ Install dependencies: `npm install` or `pip install -r requirements.txt` 4. ✅ Create `.env`: `cp ../../templates/.env.example .env` 5. ✅ Run: `npm start` or `python src/main.py` 6. ✅ Customize tools and build your app!