Something went wrong. Try again.
The atchess bot. Monitors the firehose, indexes games, plays via Stockfish.
Something went wrong. Try again.
Files
- TypeScript 99%
- Docker <1%
README.md
checkmate.blue Bot #
Persistent Node.js service that monitors the AT Protocol firehose, indexes chess games, plays against human opponents via Stockfish, and posts results to the @checkmate.blue Bluesky feed.
Companion project to checkmate.blue, a federated chess platform on the ATmosphere.
What it does #
- Game discovery -- indexes all
blue.checkmate.gamerecords from the firehose into MySQL, exposed via REST API - Result verification -- replays PGNs through chess.js to independently verify game results
- Chess engine -- plays against humans via Stockfish at configurable difficulty levels
- Bluesky posting -- posts verified game results with @mentions and link embeds, with anti-spam protections
- Variant support -- handles standard chess, Chess960, and Really Bad Chess (reads starting FEN from PGN headers)
Quick start (Docker) #
cp config.example.json config.json
# Edit config.json with your AT Protocol credentials
docker compose up
Stockfish is bundled in the container. The bot connects to your host MySQL instance. The API is available at http://localhost:3000.
Prerequisites (without Docker) #
- Node.js 18+
- MySQL 8+
- Stockfish binary (
brew install stockfishorapt install stockfish)
Setup (without Docker) #
npm install
cp config.example.json config.json
# Edit config.json with your credentials, MySQL connection, and Stockfish path
AT Protocol accounts #
The bot uses multiple Bluesky accounts:
| Account | Purpose |
|---|---|
Main account (e.g., checkmate.blue) |
Monitors firehose, indexes games, posts results |
Engine accounts (e.g., easy.checkmate.blue) |
Play chess against humans at configurable difficulty |
Each engine account needs:
- A Bluesky account with an app password
- A DNS TXT record at
_atproto.<subdomain>pointing to the account's DID - An entry in the
enginesarray inconfig.json
The engines array is variable-length -- you can have one engine or ten.
MySQL #
Create a database and user:
CREATE DATABASE checkmate_bot;
CREATE USER 'checkmate_bot'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON checkmate_bot.* TO 'checkmate_bot'@'localhost';
Tables are created automatically on first startup.
Running #
# Docker (recommended)
docker compose up # development with auto-reload
docker compose up -d # detached
# Without Docker
npm run dev # development with auto-reload
npm run build && npm start # production
Configuration #
All config lives in config.json (gitignored). See config.example.json for the full structure.
Key sections:
bot-- main account handle, DID, and app passwordengines-- array of difficulty levels with handle, DID, app password, Stockfish depth, delay range, and concurrent game limitmysql-- database connectionstockfish.path-- path to Stockfish binaryposting.dryRun-- set totrueto log posts instead of publishing them
API #
| Endpoint | Description |
|---|---|
GET /health |
Service health: database, firehose, engine, poster status |
GET /games/active |
Active games, sorted by last activity |
GET /games/recent |
Recently completed games |
GET /games/player/:did |
Games for a specific player |
GET /players/:did/stats |
Win/loss/draw stats (computed from verified games) |
GET /challenges/open |
Open challenges |
Testing #
npm test
License #
MIT