Routes:
- GET / → menu.html (new home/menu).
- GET /ai-vs-ai → old index.html (AI-vs-AI live game).
- GET /play → same index.html; app.js detects the human side from
bindings and enables chessground move input on that side only.
- GET /games → unchanged.
Backend:
- coordinator: 'human' is now an allowed agent type alongside claude/codex.
start_new_game accepts overrides[side].agent = 'human'. _send_first /
_send_turn / watchdog skip human sides.
- POST /api/human-move: humans submit moves from the browser (UCI/SAN
+ optional comment); rejected if it's not their turn or side isn't human.
- /api/options now also returns 'all_agents' = AI agents + 'human' for the
human-vs-AI configurator.
- pane-agent.sh: when binding agent is 'human', the pane just prints a
note and sleeps — no claude/codex is launched for that side.
Frontend menu (new public/menu.{html,css,js}):
- 'underground tournament' aesthetic: Major Mono Display title, JetBrains
Mono body (Google Fonts), warm gold (#c0a060) / crimson (#c04040)
accents, subtle film-grain overlay.
- Three big mode cards: 01 AI×AI, 02 HUMAN×AI, 03 GAMES·STATS.
- Inline configurator below the cards: WHITE / VS / BLACK columns with
agent / model / persona selects, persona description preview, swap +
randomize tools, abort-current warning that links to /api/abort-game.
- Start button routes to /ai-vs-ai or /play depending on whether a human
side was picked. Enter submits.
- HUD strip with tmux / stockfish / games-played counters.
app.js changes:
- Chessground constructed with viewOnly toggling; renderBoard rebuilds
movable.color + dests = legal moves at the live FEN from chess.js for
the human's turn only; board is read-only when scrubbing history,
during the AI's turn, or in AI-vs-AI.
- humanSide() helper reads bindings; orientation auto-flips when the
human plays black.
98 lines
2.8 KiB
Bash
Executable File
98 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# scripts/pane-agent.sh <white|black>
|
|
# Launched in a tmux pane; talks to backend on 127.0.0.1:7833 to figure out
|
|
# which agent (claude|codex) plays this side, writes per-side config files
|
|
# under ./config/, then exec's the agent TUI.
|
|
set -euo pipefail
|
|
|
|
side="${1:?usage: pane-agent.sh <white|black>}"
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
CFG="$ROOT/config"
|
|
mkdir -p "$CFG"
|
|
|
|
# wait until backend ready
|
|
for _ in $(seq 1 120); do
|
|
if curl -fsS "http://127.0.0.1:7833/api/state" >/dev/null 2>&1; then break; fi
|
|
sleep 0.5
|
|
done
|
|
|
|
# poll agent binding (start.sh POSTs /api/new-game before creating panes)
|
|
agent=""
|
|
for _ in $(seq 1 120); do
|
|
agent="$(curl -fsS "http://127.0.0.1:7833/api/agent-binding/${side}" 2>/dev/null \
|
|
| python3 -c 'import sys,json;
|
|
try: print(json.load(sys.stdin).get("agent",""))
|
|
except Exception: print("")' 2>/dev/null || true)"
|
|
if [ -n "$agent" ]; then break; fi
|
|
sleep 0.5
|
|
done
|
|
|
|
if [ -z "$agent" ]; then
|
|
echo "[pane-agent] no agent binding for $side after 60s — dropping to shell"
|
|
exec bash
|
|
fi
|
|
|
|
case "$side" in
|
|
white) claude_theme='light' ; codex_theme='Catppuccin Latte' ;;
|
|
black) claude_theme='dark' ; codex_theme='Catppuccin Mocha' ;;
|
|
*) echo "bad side: $side"; exec bash ;;
|
|
esac
|
|
|
|
echo "[pane-agent] side=$side agent=$agent claude_theme=$claude_theme codex_theme=\"$codex_theme\""
|
|
|
|
if [ "$agent" = "human" ]; then
|
|
cat <<EOF
|
|
[pane-agent] $side is controlled by a human — playing through the browser.
|
|
Nothing to run here. You can leave this pane attached or detach.
|
|
EOF
|
|
exec sleep infinity
|
|
fi
|
|
|
|
cd "$ROOT"
|
|
|
|
case "$agent" in
|
|
claude)
|
|
cat > "$CFG/claude-settings.${side}.json" <<EOF
|
|
{
|
|
"theme": "${claude_theme}",
|
|
"permissions": { "allow": ["*"], "defaultMode": "bypassPermissions" }
|
|
}
|
|
EOF
|
|
cat > "$CFG/claude-mcp.${side}.json" <<EOF
|
|
{
|
|
"mcpServers": {
|
|
"chess": {
|
|
"type": "http",
|
|
"url": "http://127.0.0.1:7833/mcp/${side}"
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
exec /Users/dan/.local/bin/claude \
|
|
--model opus \
|
|
--effort max \
|
|
--mcp-config "$CFG/claude-mcp.${side}.json" \
|
|
--settings "$CFG/claude-settings.${side}.json" \
|
|
--strict-mcp-config \
|
|
--dangerously-skip-permissions
|
|
;;
|
|
|
|
codex)
|
|
# Register MCP HTTP server in ~/.codex/config.toml (idempotent).
|
|
# Clean up on exit so we don't leave the user's config polluted.
|
|
/opt/homebrew/bin/codex mcp remove chess >/dev/null 2>&1 || true
|
|
/opt/homebrew/bin/codex mcp add chess --url "http://127.0.0.1:7833/mcp/${side}"
|
|
trap '/opt/homebrew/bin/codex mcp remove chess >/dev/null 2>&1 || true' EXIT
|
|
|
|
exec /opt/homebrew/bin/codex \
|
|
-c 'model="gpt-5.5"' \
|
|
-c 'model_reasoning_effort="xhigh"' \
|
|
-c 'service_tier="fast"' \
|
|
-c "tui.theme=\"${codex_theme}\"" \
|
|
--dangerously-bypass-approvals-and-sandbox
|
|
;;
|
|
|
|
*)
|
|
echo "unknown agent: $agent"; exec bash ;;
|
|
esac
|