5 Commits
Author SHA1 Message Date
ai-chess 6ee91d1a57 throttle repeated pg-boss errors; docker log rotation 2026-10-22 05:54:43 +03:00
ai-chess 5be4bd1da4 rewrite: TS monorepo — pi SDK stateless agents, Postgres+pg-boss, SvelteKit themed UI; legacy moved to legacy/ 2026-10-18 15:32:39 +03:00
ai-chess 2038ec95c9 fix(tmux): non-blocking subprocess + stable pane indexing
Two issues kept the deployed container from finishing the tmux rebuild:

1. asyncio's subprocess.communicate() blocked forever on `tmux new-session`
   and `tmux split-window` because the spawned pane child (pane-agent.sh
   → claude/codex) inherited the wrapper's stdout/stderr pipe fds and kept
   them open. _run() now uses DEVNULL for stdin/stdout/stderr by default
   (capture_stdout=True for the lone capture-pane call), and stderr is no
   longer collected — exit code is enough for upstream.

2. tmux re-indexes panes in layout-traversal order after every split, so
   the original 'split black off white horizontally, then split log off
   white vertically' sequence ended with indices 0=white, 1=log, 2=black —
   but the coordinator's pane_for hardcoded black=1, so prompts to codex
   landed on the log pane instead. Reorder: split log off the bottom of
   white FIRST (gives 0=white,1=log), THEN split black off the right of
   white (now indices 0=white,1=black,2=log, matching the hardcoded map).

Plus a small docker-compose change: ~/.codex needs to be writable so
codex can persist its history/session state — without rw the CLI exits
immediately with 'Read-only file system'.
2026-05-15 02:33:26 +03:00
ai-chess 51e63a8c7a feat(docker): bake claude+codex CLI + auth into image, non-root user
Dockerfile additions:
- Node 20 (NodeSource repo) + @anthropic-ai/claude-code@2.1.141 via npm.
- codex 0.130.0 musl tarball from github releases, dropped into
  /usr/local/bin/codex.
- jq + xz-utils + gnupg apt packages.
- Symlink /usr/games/stockfish → /usr/local/bin/stockfish (Debian
  puts it under /usr/games which isn't on the default PATH).
- Non-root user 'chess' (uid 1000) because claude-code refuses to run
  with --dangerously-skip-permissions as root; HOME=/home/chess.
- Pre-seeded /home/chess/.claude/settings.json + /home/chess/.claude.json:
  - hasCompletedOnboarding=true / lastOnboardingVersion='2.1.141'
  - projects['/app'].hasTrustDialogAccepted=true (mirrors the user's
    claude-trust-current-dir helper, but baked since cwd is always /app)
  - permissions.defaultMode='bypassPermissions'
  - skipDangerousModePermissionPrompt=true
  Without these, every fresh tmux pane hangs on the theme picker, then
  the workspace-trust dialog, never reaching its first MCP call.

docker-compose.yml:
- ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN env (loaded from /opt/chessai/.env).
- ./secrets/codex mounted read-only at /home/chess/.codex so the user's
  cliproxyapi-flavored codex config + auth.json travel with the deploy
  but stay outside the image layers.

deploy/codex/config.toml:
- Minimal codex config (cliproxyapi provider, gpt-5.5 xhigh fast,
  chess MCP url placeholder overridden per-side by pane-agent.sh).

scripts/pane-agent.sh:
- Use CLAUDE_BIN / CODEX_BIN from PATH (mac vs linux dynamics);
  the inline -c mcp_servers.chess.url override removes the need for
  'codex mcp add/remove' that polluted ~/.codex/config.toml on Mac runs.

Verified end-to-end on chess.danosito.com: AI-vs-AI game starts,
claude (white) inside the container makes the first move with a
toxic russian comment, MCP HTTP roundtrip works.
2026-05-15 02:05:18 +03:00
ai-chess c2d3a47d4b feat: docker container + deploy on chess.danosito.com
Container:
- Dockerfile: python:3.12-slim with stockfish + tmux apt; src copied
  before pip install -e so the editable wheel actually finds ai_chess.
  fetch-vendor.sh runs at build time so the image is self-contained.
- docker-compose.yml: two networks (default + caddy-network), alias
  'chessai' on caddy-network, AI_CHESS_HOST=0.0.0.0 env so uvicorn
  listens on all interfaces (Caddy reverse-proxies over the network),
  volumes for games/, logs/, config/ to persist across rebuilds.
- __main__.py reads AI_CHESS_HOST + AI_CHESS_PORT from env (falls back
  to 127.0.0.1:7833 for local dev).
- .dockerignore excludes .git, .venv, runtime dirs, screenshots.
- deploy/chess.danosito.com.caddy: site snippet, imports header_common,
  reverse_proxy chessai:7833.

Live game UX fixes that landed alongside the deploy:
- Snap viewPly to null on every move event so an accidental
  history-scrub no longer leaves the board locked; previously the only
  way out was a hard refresh.
- movable.events.after wired in chessground constructor (instead of
  top-level events.move) so user moves are submitted only when they
  pass chessground's own legality check.
- Hide stockfish entirely in human-vs-AI: no eval bar, no best-move
  arrow, no pv string. AI-vs-AI keeps the full spectator HUD.

Coordinator / tmux:
- New-game rebuilds the 'chess' tmux session from scratch so
  pane-agent.sh picks up the new bindings (different agent on a side
  / human side) instead of running with stale state.
- /api/dispatch-first now queues the dispatch in a background task and
  sleeps 12 s first to let claude/codex finish booting inside the
  panes — paste-buffer was landing on a still-booting bash before.
2026-05-15 01:31:55 +03:00