- coordinator: use `ulid.new().str` (ulid-py 1.x API), not `ULID()` - coordinator._submit: swallow tmux errors so game logic continues - app: split first-prompt dispatch into POST /api/dispatch-first - start.sh: POST /api/dispatch-first ~12s after tmux create - test_coordinator: isolate GAMES_DIR via tmp_path
59 lines
2.0 KiB
Bash
Executable File
59 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# scripts/start.sh — install deps, run backend, open tmux session "chess"
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
echo "[ai-chess] checking deps"
|
|
which stockfish >/dev/null || { echo "[ai-chess] installing stockfish"; brew install stockfish; }
|
|
which tmux >/dev/null || { echo "[ai-chess] installing tmux"; brew install tmux; }
|
|
which uv >/dev/null || { echo "[ai-chess] installing uv"; brew install uv; }
|
|
|
|
if [ ! -d .venv ]; then
|
|
uv venv
|
|
fi
|
|
# shellcheck disable=SC1091
|
|
source .venv/bin/activate
|
|
uv pip install -e ".[dev]" >/dev/null
|
|
|
|
echo "[ai-chess] fetching vendor JS"
|
|
"$ROOT/scripts/fetch-vendor.sh"
|
|
|
|
# kill existing
|
|
tmux kill-session -t chess 2>/dev/null || true
|
|
pkill -f 'python -m ai_chess' 2>/dev/null || true
|
|
sleep 0.3
|
|
|
|
# start backend
|
|
LOGS="$ROOT/logs"; mkdir -p "$LOGS"
|
|
nohup python -m ai_chess >"$LOGS/backend.log" 2>&1 &
|
|
backend_pid=$!
|
|
echo "[ai-chess] backend pid=$backend_pid; tail: $LOGS/backend.log"
|
|
|
|
# wait for backend
|
|
for _ in $(seq 1 40); do
|
|
if curl -fsS http://127.0.0.1:7833/api/state >/dev/null 2>&1; then break; fi
|
|
sleep 0.25
|
|
done
|
|
|
|
# bootstrap a new game so bindings exist before panes start
|
|
curl -fsS -X POST http://127.0.0.1:7833/api/new-game >/dev/null || {
|
|
echo "[ai-chess] failed to start new game; aborting"; exit 1;
|
|
}
|
|
|
|
# create tmux session: pane 0 (white, left), pane 1 (black, right), pane 2 (log, bottom)
|
|
tmux new-session -d -s chess -x 220 -y 60 "$ROOT/scripts/pane-agent.sh white"
|
|
tmux split-window -h -p 50 -t chess:0.0 "$ROOT/scripts/pane-agent.sh black"
|
|
tmux split-window -v -p 15 -t chess:0 "tail -F $LOGS/backend.log"
|
|
|
|
# Give claude/codex ~12s to boot in their panes, then ask coordinator to
|
|
# inject the first prompt to the white pane.
|
|
( sleep 12 && curl -fsS -X POST http://127.0.0.1:7833/api/dispatch-first >/dev/null ) &
|
|
|
|
echo
|
|
echo "[ai-chess] open: http://127.0.0.1:7833/"
|
|
echo "[ai-chess] attach: tmux attach -t chess"
|
|
echo "[ai-chess] first prompt fires in ~12s (after agents boot)"
|
|
echo
|
|
tmux attach -t chess
|