|
| 1 | +# Quick Reference - Copilot SDK Setup |
| 2 | + |
| 3 | +Quick commands and references for setting up and using the GitHub Copilot SDK. |
| 4 | + |
| 5 | +## Prerequisites Checklist |
| 6 | + |
| 7 | +```bash |
| 8 | +# Check if prerequisites are installed |
| 9 | +gh --version # GitHub CLI |
| 10 | +copilot --version # Copilot CLI |
| 11 | +node -v # Node.js (optional) |
| 12 | +python3 --version # Python (optional) |
| 13 | +go version # Go (optional) |
| 14 | +dotnet --version # .NET (optional) |
| 15 | +``` |
| 16 | + |
| 17 | +## One-Line Installations |
| 18 | + |
| 19 | +### GitHub CLI |
| 20 | + |
| 21 | +```bash |
| 22 | +# macOS |
| 23 | +brew install gh |
| 24 | + |
| 25 | +# Linux (Debian/Ubuntu) |
| 26 | +curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && \ |
| 27 | +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 && \ |
| 28 | +sudo apt update && sudo apt install gh |
| 29 | + |
| 30 | +# Windows (PowerShell) |
| 31 | +winget install --id GitHub.cli |
| 32 | +``` |
| 33 | + |
| 34 | +### Copilot CLI |
| 35 | + |
| 36 | +```bash |
| 37 | +gh extension install github/gh-copilot |
| 38 | +``` |
| 39 | + |
| 40 | +### Runtime Environments |
| 41 | + |
| 42 | +```bash |
| 43 | +# Node.js - visit https://nodejs.org/ |
| 44 | +# macOS: brew install node |
| 45 | + |
| 46 | +# Python - visit https://python.org/ |
| 47 | +# macOS: brew install python |
| 48 | + |
| 49 | +# Go - visit https://go.dev/ |
| 50 | +# macOS: brew install go |
| 51 | + |
| 52 | +# .NET - visit https://dotnet.microsoft.com/ |
| 53 | +# macOS: brew install --cask dotnet-sdk |
| 54 | +``` |
| 55 | + |
| 56 | +## Automated Setup |
| 57 | + |
| 58 | +```bash |
| 59 | +# Run automated setup (Linux/macOS) |
| 60 | +bash scripts/setup-dev-env.sh |
| 61 | + |
| 62 | +# Run automated setup (Windows PowerShell) |
| 63 | +.\scripts\setup-dev-env.ps1 |
| 64 | + |
| 65 | +# Validate your environment |
| 66 | +bash scripts/validate-env.sh |
| 67 | +``` |
| 68 | + |
| 69 | +## Quick Start Commands |
| 70 | + |
| 71 | +### TypeScript Project |
| 72 | + |
| 73 | +```bash |
| 74 | +# Create from template |
| 75 | +cp -r templates/typescript-quickstart my-app |
| 76 | +cd my-app |
| 77 | + |
| 78 | +# Setup |
| 79 | +npm install |
| 80 | +cp ../../templates/.env.example .env |
| 81 | + |
| 82 | +# Run |
| 83 | +npm start |
| 84 | +``` |
| 85 | + |
| 86 | +### Python Project |
| 87 | + |
| 88 | +```bash |
| 89 | +# Create from template |
| 90 | +cp -r templates/python-quickstart my-app |
| 91 | +cd my-app |
| 92 | + |
| 93 | +# Setup |
| 94 | +python3 -m venv venv |
| 95 | +source venv/bin/activate # Windows: venv\Scripts\activate |
| 96 | +pip install -r requirements.txt |
| 97 | +cp ../../templates/.env.example .env |
| 98 | + |
| 99 | +# Run |
| 100 | +python src/main.py |
| 101 | +``` |
| 102 | + |
| 103 | +### Go Project |
| 104 | + |
| 105 | +```bash |
| 106 | +mkdir my-app && cd my-app |
| 107 | +go mod init my-app |
| 108 | +go get github.com/github/copilot-sdk/go |
| 109 | +``` |
| 110 | + |
| 111 | +### .NET Project |
| 112 | + |
| 113 | +```bash |
| 114 | +dotnet new console -n MyApp |
| 115 | +cd MyApp |
| 116 | +dotnet add package GitHub.Copilot.SDK |
| 117 | +dotnet run |
| 118 | +``` |
| 119 | + |
| 120 | +## SDK Installation |
| 121 | + |
| 122 | +```bash |
| 123 | +# Node.js/TypeScript |
| 124 | +npm install @github/copilot-sdk tsx |
| 125 | + |
| 126 | +# Python |
| 127 | +pip install github-copilot-sdk |
| 128 | + |
| 129 | +# Python with uv (faster) |
| 130 | +uv pip install github-copilot-sdk |
| 131 | + |
| 132 | +# Go |
| 133 | +go get github.com/github/copilot-sdk/go |
| 134 | + |
| 135 | +# .NET |
| 136 | +dotnet add package GitHub.Copilot.SDK |
| 137 | +``` |
| 138 | + |
| 139 | +## Authentication |
| 140 | + |
| 141 | +```bash |
| 142 | +# Login to GitHub |
| 143 | +gh auth login |
| 144 | + |
| 145 | +# Refresh Copilot token |
| 146 | +gh auth refresh -s copilot |
| 147 | + |
| 148 | +# Check auth status |
| 149 | +gh auth status |
| 150 | +``` |
| 151 | + |
| 152 | +## Environment Variables |
| 153 | + |
| 154 | +Create `.env` file: |
| 155 | + |
| 156 | +```env |
| 157 | +COPILOT_MODEL=gpt-4.1 |
| 158 | +COPILOT_STREAMING=true |
| 159 | +LOG_LEVEL=info |
| 160 | +``` |
| 161 | + |
| 162 | +## Testing Your Setup |
| 163 | + |
| 164 | +### CLI Test |
| 165 | + |
| 166 | +```bash |
| 167 | +copilot "what is 2+2?" |
| 168 | +``` |
| 169 | + |
| 170 | +### TypeScript Test |
| 171 | + |
| 172 | +```typescript |
| 173 | +import { CopilotClient } from "@github/copilot-sdk"; |
| 174 | + |
| 175 | +const client = new CopilotClient(); |
| 176 | +const session = await client.createSession({ model: "gpt-4.1" }); |
| 177 | +const response = await session.sendAndWait({ prompt: "Hello!" }); |
| 178 | +console.log(response?.data.content); |
| 179 | +await client.stop(); |
| 180 | +``` |
| 181 | + |
| 182 | +```bash |
| 183 | +npx tsx test.ts |
| 184 | +``` |
| 185 | + |
| 186 | +### Python Test |
| 187 | + |
| 188 | +```python |
| 189 | +import asyncio |
| 190 | +from copilot import CopilotClient |
| 191 | + |
| 192 | +async def main(): |
| 193 | + client = CopilotClient() |
| 194 | + await client.start() |
| 195 | + session = await client.create_session({"model": "gpt-4.1"}) |
| 196 | + response = await session.send_and_wait({"prompt": "Hello!"}) |
| 197 | + print(response.data.content) |
| 198 | + await client.stop() |
| 199 | + |
| 200 | +asyncio.run(main()) |
| 201 | +``` |
| 202 | + |
| 203 | +```bash |
| 204 | +python test.py |
| 205 | +``` |
| 206 | + |
| 207 | +## Common Issues |
| 208 | + |
| 209 | +### `copilot: command not found` |
| 210 | + |
| 211 | +```bash |
| 212 | +gh extension install github/gh-copilot |
| 213 | +# Add to PATH if needed |
| 214 | +export PATH="$PATH:$HOME/.local/bin" |
| 215 | +``` |
| 216 | + |
| 217 | +### Authentication Errors |
| 218 | + |
| 219 | +```bash |
| 220 | +gh auth login |
| 221 | +gh auth refresh -s copilot |
| 222 | +``` |
| 223 | + |
| 224 | +### Port Already in Use |
| 225 | + |
| 226 | +```bash |
| 227 | +# The SDK handles this automatically |
| 228 | +# If issues persist, find and kill processes |
| 229 | +ps aux | grep copilot |
| 230 | +kill <PID> |
| 231 | +``` |
| 232 | + |
| 233 | +### Module Not Found (Node.js) |
| 234 | + |
| 235 | +```bash |
| 236 | +npm install |
| 237 | +``` |
| 238 | + |
| 239 | +### Module Not Found (Python) |
| 240 | + |
| 241 | +```bash |
| 242 | +source venv/bin/activate # or .venv/bin/activate |
| 243 | +pip install -r requirements.txt |
| 244 | +``` |
| 245 | + |
| 246 | +## Available Models |
| 247 | + |
| 248 | +Check available models: |
| 249 | + |
| 250 | +```bash |
| 251 | +copilot models |
| 252 | +``` |
| 253 | + |
| 254 | +Common models: |
| 255 | +- `gpt-4.1` - Latest GPT-4 (recommended) |
| 256 | +- `gpt-4o` - GPT-4 Optimized |
| 257 | +- `claude-3.5-sonnet` - Claude 3.5 Sonnet |
| 258 | + |
| 259 | +## Directory Structure |
| 260 | + |
| 261 | +``` |
| 262 | +my-agentic-app/ |
| 263 | +├── .env # Environment variables |
| 264 | +├── .gitignore # Git ignore rules |
| 265 | +├── src/ # Source code |
| 266 | +│ ├── agents/ # Custom agent definitions |
| 267 | +│ ├── tools/ # Custom tool implementations |
| 268 | +│ └── main.[ts|py] # Entry point |
| 269 | +└── tests/ # Test files |
| 270 | +``` |
| 271 | + |
| 272 | +## Useful Links |
| 273 | + |
| 274 | +- [Environment Setup Guide](../docs/environment-setup.md) |
| 275 | +- [Getting Started Guide](../docs/getting-started.md) |
| 276 | +- [Project Templates](../templates/README.md) |
| 277 | +- [Cookbook Examples](../cookbook/README.md) |
| 278 | +- [GitHub Copilot Docs](https://docs.github.com/en/copilot) |
| 279 | + |
| 280 | +## Getting Help |
| 281 | + |
| 282 | +- **Issues**: https://github.com/github/copilot-sdk/issues |
| 283 | +- **Discussions**: https://github.com/github/copilot-sdk/discussions |
| 284 | +- **Documentation**: Main README.md |
| 285 | + |
| 286 | +## Scripts Overview |
| 287 | + |
| 288 | +| Script | Purpose | Usage | |
| 289 | +|--------|---------|-------| |
| 290 | +| `scripts/setup-dev-env.sh` | Automated setup (Linux/macOS) | `bash scripts/setup-dev-env.sh` | |
| 291 | +| `scripts/setup-dev-env.ps1` | Automated setup (Windows) | `.\scripts\setup-dev-env.ps1` | |
| 292 | +| `scripts/validate-env.sh` | Validate installation | `bash scripts/validate-env.sh` | |
| 293 | + |
| 294 | +## Template Overview |
| 295 | + |
| 296 | +| Template | Language | Features | |
| 297 | +|----------|----------|----------| |
| 298 | +| `typescript-quickstart` | TypeScript | Interactive CLI, Custom tools, Hot reload | |
| 299 | +| `python-quickstart` | Python | Interactive CLI, Custom tools, Async/await | |
| 300 | + |
| 301 | +## Next Steps After Setup |
| 302 | + |
| 303 | +1. ✅ Validate environment: `bash scripts/validate-env.sh` |
| 304 | +2. ✅ Choose a template: `cd templates/typescript-quickstart` |
| 305 | +3. ✅ Install dependencies: `npm install` or `pip install -r requirements.txt` |
| 306 | +4. ✅ Create `.env`: `cp ../../templates/.env.example .env` |
| 307 | +5. ✅ Run: `npm start` or `python src/main.py` |
| 308 | +6. ✅ Customize tools and build your app! |
0 commit comments