#!/usr/bin/env bash
set -euo pipefail
# Consolidated commands from the manual Linux/bash reproduction.
# Usage: reproduce.sh prepare|start|install WORKTREE ISOLATED_HOME RUNTIME_BIN
# RUNTIME_BIN must contain vp/node and must not contain claude.
mode=$1
checkout=$2
isolated_home=$3
runtime_bin=$4
baseline="/usr/bin:/bin:$runtime_bin"
case "$mode" in
  prepare)
    mkdir -p "$isolated_home"
    printf 'export PATH=%q\n' "$baseline" > "$isolated_home/.bash_profile"
    ;;
  start)
    cd "$checkout"
    env HOME="$isolated_home" SHELL=/bin/bash PATH="$baseline" T3CODE_DEV_SEED=0 vp run dev
    ;;
  install)
    curl -fsSL https://claude.ai/install.sh -o "$isolated_home/install-claude.sh"
    env HOME="$isolated_home" SHELL=/bin/bash PATH=/usr/bin:/bin /bin/bash "$isolated_home/install-claude.sh"
    printf '%s\n' 'export PATH="$HOME/.local/bin:$PATH"' >> "$isolated_home/.bash_profile"
    env HOME="$isolated_home" /bin/bash -ilc 'command -v claude; claude --version'
    ;;
esac
# Browser, on each side: pair using its startup link, then open
# /settings/providers?instanceId=claudeAgent at 1280x800, light theme.
# Start a recording and click the button containing "Refresh provider status".
# Base stays Not found. Head displays v2.1.322 and Not authenticated.
# Leave Binary path as the default "claude". Do not restart during install/refresh.
