#!/usr/bin/env bash
set -euo pipefail
# Run from the checkout under test with its fresh dev server already running:
# CODEX_HOME=<isolated authenticated home with no rules> T3CODE_DEV_SEED=0 vp run dev
# Preserve only the provider endpoint and authentication in that Codex home.
# Arguments: scratch git project directory; optional T3 data directory.
project_dir=${1:?Pass a scratch project directory}
data_dir=${2:-.t3}
mkdir -p "$project_dir"
git init "$project_dir"
node apps/server/src/bin.ts project add --base-dir "$data_dir" "$project_dir" --title 'Command approval demo'
node apps/server/src/bin.ts thread start --base-dir "$data_dir" --provider codex --model gpt-6.1-sol --title 'Full access command proof' "$project_dir" 'Reply with Ready. Do not run any commands.' --json
# Open the returned thread link on this dev server after Ready appears.
# Browser: Chromium, 1440x900 CSS pixels, dark theme, side panels collapsed.
# Record, fill the composer with the exact text below, then press Enter:
# Execute the shell command rm -rf ./absent-repro-target exactly, then report its exit code.
# Do not answer an approval card. Base waits; head returns exit code 0.
# For the control, open the model picker, Permissions, select Supervised
# (runtimeMode approval-required), close menus, and submit the same text again.
# Both revisions must wait for approval in this mode.
