A real-time chess AI commentary system powered by GitHub Copilot SDK. As you play, AI analyzes and comments on every move like a professional commentator.
- π€ Real-time AI Commentary: Professional game commentary using GitHub Copilot's advanced models (GPT-5, Claude Sonnet 4.5)
- βοΈ Complete Chess Engine: Full chess engine based on chess.js
- π¨ Clean UI: Modern, responsive interface built with React + CSS
- π‘ Real-time Communication: Low-latency bidirectional communication via WebSocket
- ποΈ Streaming Response: AI commentary displayed in real-time with typewriter effect
- π§ Custom Tools: Integrated professional tools for game state queries
- π Game Analysis: Automatic identification of opening, middlegame, and endgame phases
- π¬ Game Summary: Generate complete game summaries and reviews
- Node.js: >= 18.0.0
- GitHub Copilot CLI: Installed and authenticated
- GitHub Copilot Subscription: Valid paid subscription required
# Install via npm
npm install -g @github/copilot-cli
# Or use GitHub CLI extension
gh extension install github/gh-copilot
# Authenticate
copilot auth login
# Verify installation
copilot --versionnpm install# Copy example configuration
cp .env.example .env
# Edit .env file (optional)
# PORT=3000
# LOG_LEVEL=info# Start in development mode (concurrent frontend and backend)
npm run dev
# Or start separately
npm run dev:client # Frontend dev server (Vite)
npm run dev:server # Backend server (Node.js with tsx)Application will run at:
- Frontend: http://localhost:5173
- Backend: http://localhost:3000
- WebSocket: ws://localhost:3000
- Start Commentary: The AI commentator is ready when you open the app
- Make Moves: Click a piece to select it, then click the target square to move
- Real-time Commentary: After each move, AI provides real-time analysis and commentary
- Generate Summary: After at least 5 moves, click "Summary" to get game review
- Reset Game: Click "Reset" to start a new game
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β βοΈ Cyber Chess Roast β
β Real-time Chess AI Commentary β
βββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Game Info β AI Commentary Panel β
β βββββββββββ β ββββββββββββββββββββββββββββ β
β β Round: 5 β β β π€ AI Commentary β Connected β β
β β Moves: 9 β β β β β
β β Phase:Midβ β β [Streaming content...] β β
β βββββββββββ β β β β β
β β ββββββββββββββββββββββββββββ β
β βββββββββββ β β
β β β β β
β β Board β β β
β β β β β
β βββββββββββ β β
β β β
β βββββββββββ βββββββββββββ β
β βπ Reset β βπ Summary β β
β βββββββββββ βββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
cyber-chess-roast/
βββ src/
β βββ client/ # React frontend
β β βββ components/ # React components
β β β βββ Chessboard.tsx
β β β βββ Chessboard.css
β β β βββ Commentary.tsx
β β β βββ Commentary.css
β β βββ hooks/ # React Hooks
β β β βββ useChessGame.ts
β β β βββ useStockfish.ts
β β β βββ useWebSocket.ts
β β βββ App.tsx
β β βββ App.css
β β βββ main.tsx
β β βββ index.css
β β
β βββ server/ # Node.js backend
β βββ commentator.ts # Copilot SDK integration
β βββ websocket.ts # WebSocket server
β βββ types.ts # TypeScript type definitions
β βββ index.ts # Server entry point
β
βββ public/ # Static assets
βββ index.html # HTML template
βββ package.json
βββ tsconfig.json
βββ tsconfig.node.json
βββ vite.config.ts
βββ .env.example
βββ README.md
- React 18: UI framework
- TypeScript: Type safety
- chess.js: Chess logic engine
- Vite: Build tool
- WebSocket Client: Real-time communication
- Node.js: Runtime environment
- TypeScript: Type safety
- Express: Web framework
- Socket.IO: WebSocket server
- GitHub Copilot SDK: AI engine
- chess.js: Game validation
import { CopilotClient } from "@github/copilot-sdk";
const client = new CopilotClient({
logLevel: "warning",
autoStart: true,
autoRestart: true
});
await client.start();const session = await client.createSession({
model: "gpt-4o",
streaming: true,
tools: [getGameStateTool, analyzePositionTool],
systemMessage: {
content: "You are a professional chess commentator..."
}
});session.on((event) => {
if (event.type === "assistant.message_delta") {
// Handle incremental content
process.stdout.write(event.data.deltaContent);
}
if (event.type === "session.idle") {
// Commentary complete
console.log("Commentary complete");
}
});
await session.sendAndWait({ prompt: "Comment on this move..." });Project includes custom tools:
const getGameStateTool = {
name: "get_game_state",
description: "Get current game state and move history",
parameters: { type: "object", properties: {} },
handler: async () => ({
currentFEN: getCurrentFEN(),
moveCount: getMoveCount(),
lastMoves: getLastMoves(5),
gamePhase: determinePhase()
})
};const analyzePositionTool = {
name: "analyze_position",
description: "Analyze current board position",
parameters: {
type: "object",
properties: {
depth: { type: "number", description: "Analysis depth" }
}
},
handler: async ({ depth = 3 }) => ({
evaluation: calculateEval(),
threats: identifyThreats(),
suggestions: getSuggestions()
})
};- Session Management: Automatic cleanup and session reuse
- Error Handling: Comprehensive error catching and user feedback
- Timeout Control: Prevent long-running operations
- Resource Cleanup: Proper cleanup of Copilot client resources
- Type Safety: Comprehensive TypeScript type definitions
- β‘ Streaming Response: Reduce time to first byte
- π Session Reuse: Avoid repeated initialization
- π¦ Code Splitting: Vite code splitting
- π¨ CSS Optimization: Use CSS variables and minimal styles
# Enable verbose logging
LOG_LEVEL=debug npm run dev:server
# View Copilot CLI output
COPILOT_CLI_ARGS=--verbose npm run dev:server# Build frontend
npm run build
# Start production server
npm start# Check TypeScript types
npm run type-check# Check if CLI is installed
copilot --version
# Check PATH environment variable
echo $PATH | grep copilot
# Manually specify path
echo "COPILOT_CLI_PATH=/path/to/copilot" >> .env# Re-login
copilot auth logout
copilot auth login
# Check auth status
copilot auth status- Ensure backend server is running
- Check firewall settings
- Verify port is not in use
| Variable | Default | Description |
|---|---|---|
PORT |
3000 |
Backend server port |
NODE_ENV |
development |
Runtime environment |
COPILOT_CLI_PATH |
copilot |
CLI executable path |
LOG_LEVEL |
info |
Logging level |
Contributions are welcome! Feel free to submit Pull Requests.
MIT License - see LICENSE file for details
- GitHub Copilot SDK - AI engine
- chess.js - Chess logic
- React - UI framework
- Vite - Build tool
For questions or suggestions, please submit an Issue.
Made with β€οΈ for Chess and AI Enthusiasts