|
| 1 | +# Copilot SDK Playground |
| 2 | + |
| 3 | +An interactive web-based playground for testing and exploring the GitHub Copilot SDK. Create sessions, send messages, and watch responses stream in real-time. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +**Prerequisites:** [Install the Copilot CLI](https://docs.github.com/en/copilot/how-tos/set-up/install-copilot-cli) |
| 8 | + |
| 9 | +```bash |
| 10 | +cd demos/playground |
| 11 | +npm install |
| 12 | +npm start |
| 13 | +``` |
| 14 | + |
| 15 | +Open **http://localhost:5173** in your browser. |
| 16 | + |
| 17 | +### Point at a specific repo |
| 18 | + |
| 19 | +```bash |
| 20 | +COPILOT_CWD=/path/to/your/repo npm start |
| 21 | +``` |
| 22 | + |
| 23 | +## Features |
| 24 | + |
| 25 | +- **Session Management** - Create and manage multiple SDK sessions |
| 26 | +- **Interactive Chat** - Send messages and receive streaming responses |
| 27 | +- **Tool Execution** - Watch tool calls execute with collapsible details |
| 28 | +- **Custom Providers** - Use your own API keys (OpenAI, Azure, Anthropic) |
| 29 | +- **Multiple Models** - Test with GPT-5, Claude, Gemini, and more |
| 30 | + |
| 31 | +## Usage |
| 32 | + |
| 33 | +1. **Create a Session** - Select a model and click "Create Session" |
| 34 | +2. **Send Messages** - Type in the input area and press Enter |
| 35 | +3. **View Responses** - Watch the assistant respond in real-time |
| 36 | +4. **Inspect Tools** - Click on tool cards to expand arguments/results |
| 37 | + |
| 38 | +### Custom Providers (BYOK) |
| 39 | + |
| 40 | +Expand "Provider Config" when creating a session to use your own API: |
| 41 | + |
| 42 | +| Provider | Base URL | Notes | |
| 43 | +|----------|----------|-------| |
| 44 | +| OpenAI | `https://api.openai.com/v1` | Use your OpenAI API key | |
| 45 | +| Azure | `https://your-resource.openai.azure.com` | Supports bearer token auth | |
| 46 | +| Anthropic | `https://api.anthropic.com` | Use your Anthropic API key | |
| 47 | +| Ollama | `http://localhost:11434/v1` | No API key needed | |
| 48 | + |
| 49 | +## Architecture |
| 50 | + |
| 51 | +``` |
| 52 | +React App (Vite) |
| 53 | + ↓ HTTP API |
| 54 | +Express Server |
| 55 | + ↓ TypeScript SDK |
| 56 | +Copilot CLI (stdio) |
| 57 | +``` |
| 58 | + |
| 59 | +The playground uses the SDK to communicate with the CLI process via JSON-RPC over stdio. All session state is managed by the SDK. |
| 60 | + |
| 61 | +## Development |
| 62 | + |
| 63 | +```bash |
| 64 | +# Run with custom CLI path (for local development) |
| 65 | +COPILOT_CLI_PATH=/path/to/cli npm start |
| 66 | + |
| 67 | +# Build for production |
| 68 | +npm run build |
| 69 | +``` |
| 70 | + |
| 71 | +## Project Structure |
| 72 | + |
| 73 | +``` |
| 74 | +src/ |
| 75 | +├── App.tsx # Main app component |
| 76 | +├── App.css # Styles |
| 77 | +├── api.ts # API client |
| 78 | +├── types.ts # TypeScript types |
| 79 | +├── hooks/ |
| 80 | +│ └── useCopilotSDK.ts # Main SDK hook |
| 81 | +└── components/ |
| 82 | + ├── Sidebar.tsx # Session list + form |
| 83 | + ├── ChatArea.tsx # Messages + input |
| 84 | + ├── Message.tsx # User/assistant message |
| 85 | + ├── ToolMessage.tsx # Tool execution card |
| 86 | + └── StatusBar.tsx # Connection status |
| 87 | +``` |
| 88 | + |
| 89 | +The `useCopilotSDK` hook encapsulates all SDK interaction logic - a good starting point for understanding how to integrate the SDK into your own React application. |
0 commit comments