#!/usr/bin/env bash
set -eu
# Supply a NEW scratch directory. All credentials below are synthetic.
proof_root="$1"
mkdir -p "$proof_root/home" "$proof_root/data" "$proof_root/config"
npm install --prefix "$proof_root/cli" @opencode/cli@2.3.2
export XDG_DATA_HOME="$proof_root/data"
export XDG_CONFIG_HOME="$proof_root/config"
printf '%s' '[{"id":"console-only","integrationID":"opencode","label":"Console","active":true,"value":{"type":"key","key":"invalid-console-token","metadata":{"orgID":"org_synthetic","server":"https://opencode.ai/console"}}}]' | "$proof_root/cli/node_modules/.bin/opencode" auth import --standalone
"$proof_root/cli/node_modules/.bin/opencode" auth list --standalone
# In each isolated checkout, with these XDG variables:
# T3CODE_DEV_SEED=0 vp run dev
# Pair web client, then Settings > Providers > Add provider > OpenCode > Next > Next.
# Set Binary path to the installed CLI above; Add instance.
# Verify v2.3.2 / Authenticated. Open /usage, select Limits.
# Keep All environments / All providers; click Refresh limits.
# Browser: Chromium, dark appearance, viewport 1440x1000 CSS pixels, DPR 2.
# Capture interaction (same preview_* calls on both sides):
# preview_recording_start({})
# preview_act({action:"click",selector:"button[aria-label='Refresh limits']:visible"})
# preview_act({action:"hover",selector:"h1:has-text('Usage')"})
# Wait for refresh to finish; take two screenshots at least 500ms apart,
# compare pixels, then preview_recording_stop({}).
# OpenCode may return either Console budgets 401 or Go usage 401 with an invalid key.
# Both are real upstream failures; the final after still/video shows Console budgets.
