ba-auto-daily/README.md

5.0 KiB

ba-auto-daily

Personal automation for Blue Archive JP daily tasks (mailbox, cafe, ...), driven by desktop control (xdotool/scrot) against the real PC/Steam/Proton client.

How it's wired together

Two machines are involved:

  • nik-macbookair (this Mac) — where the code is edited. The game does not run here and none of this can be tested locally.
  • nik-gpu (Linux) — where the actual Blue Archive client runs under Steam/Proton, and where every command below actually executes.

Call path once deployed to nik-gpu:

~/ba_dailies.sh [command]      <- thin Bash launcher, no game logic
      |
      v
~/ba_daily.py [command]        <- Python CLI, dispatches to a task
      |
      v
~/ba_auto/tasks/<command>.py   <- the actual click/verify logic

ba_dailies.sh only picks the venv Python and execs ba_daily.py. All real logic — clicking, screenshotting, verifying game state — lives in Python under ba_auto/.

Current task status:

Command Implementation
mailbox Real Python (ba_auto/tasks/mailbox.py). Verifies the mailbox panel actually opened (via a pixel-color probe, driver.color_at) before clicking "claim all" or pressing any further keys. Retries the open-click up to 3 times before giving up safely.
cafe Still a bridge: ba_auto/tasks/cafe.py shells out to scripts/ba_dailies_legacy.sh cafe, the original unverified fixed-coordinate click sequence, unchanged. Not yet hardened — see "Known issue" below.

Prerequisites on nik-gpu

One-time, or after a dependency change:

ssh nik-gpu
which xdotool scrot          # both must be installed

setup.sh (see below) creates the Python venv and checks these for you.

Deploying your changes

From nik-macbookair, in the repo root:

rsync -av --delete \
  --exclude='.git/' --exclude='__pycache__/' --exclude='*.pyc' \
  --exclude='.claude/settings.local.json' --exclude='graphify-out/' \
  --exclude='screenshots/' \
  ./ nik-gpu:~/repo/ba-auto-daily/

ssh nik-gpu "cd ~/repo/ba-auto-daily && ./setup.sh"

setup.sh copies the synced files into the fixed runtime paths (~/ba_dailies.sh, ~/ba_daily.py, ~/ba_auto/, ~/ba_scripts/, ~/ba_assets/) and (re)installs the venv. Re-run both commands any time you change code — there is no auto-deploy.

Running it

The game must already be running on nik-gpu (window titled BlueArchive). Then, on nik-gpu:

~/ba_dailies.sh            # default: mailbox, then cafe
~/ba_dailies.sh mailbox    # just mailbox
~/ba_dailies.sh cafe       # just cafe

You can also run these remotely without a separate ssh login step:

ssh nik-gpu "~/ba_dailies.sh mailbox"

Exit code 0 means the script ran to completion — it does not by itself guarantee the in-game action succeeded (mailbox checks and logs this explicitly; cafe currently does not).

How to watch/verify it

  • Easiest: watch it live. If you have Moonlight (or similar) streaming nik-gpu's desktop, just open that and run the command from another terminal — you'll see the clicks happen in real time.
  • No stream handy: pull a screenshot after the fact.
    ssh nik-gpu "DISPLAY=:0 XAUTHORITY=/run/user/1000/gdm/Xauthority scrot -o /tmp/check.png"
    scp nik-gpu:/tmp/check.png .
    open check.png
    
  • Read the log output. Each task prints what it's doing, e.g. mailbox prints panel not detected after click (attempt N/3) if a click misses, and nothing to claim vs claiming all depending on what it found.

Known issue: don't trust cafe unattended yet

Live-testing mailbox surfaced a real bug in the original, unverified click sequence (see plan.md Phase 5 for the full writeup): a slightly-off icon coordinate caused a missed click, and the fixed sequence blindly kept going — clicking, pressing Enter, pressing Escape — with no idea whether any of it landed. The trailing Escape ended up hitting the bare home screen, which triggers Blue Archive's own "Exit the game?" confirmation dialog.

mailbox.py now guards against this (verifies state before acting, retries, aborts safely instead of guessing). cafe still uses the old unverified bridge and has the same failure mode. If you run ~/ba_dailies.sh cafe and something looks off, check the screen before pressing anything — if you see an unexpected confirmation dialog, press Escape/Cancel, never Enter/OK, until you've confirmed what it's asking.

Local checks (nik-macbookair)

The game can't run here, so this only catches syntax errors, not behavior:

bash -n ba_dailies.sh
bash -n scripts/ba_dailies_legacy.sh
python3 -m py_compile ba_daily.py ba_auto/*.py ba_auto/tasks/*.py

Real verification only happens by actually running against the live game on nik-gpu, per "How to watch/verify it" above.

More detail

  • CLAUDE.md — architecture rules and conventions for this repo.
  • plan.md — feature-by-feature migration status and backlog, including the mailbox bug writeup.
  • ba_auto/reference_notes/mapping.md — maps each feature to its baas-reference source.