#!/usr/bin/env bash
set -eu
# Run from the checkout being captured. All arguments refer to disposable synthetic state.
proof_home=$1
sample_project=$2
device_host=$3
pair_file=$4
mkdir -p "$sample_project"
git init -q --initial-branch=main "$sample_project"
git -C "$sample_project" -c user.name=Scenario -c user.email=scenario@example.invalid commit --allow-empty -qm 'Initial commit'
T3CODE_PORT=14990 node apps/server/src/bin.ts project add "$sample_project" --title 'Sample project' --base-dir "$proof_home"
T3CODE_PORT=14990 node apps/server/src/bin.ts thread start "$sample_project" 'Create a small example' --title 'Earlier work' --provider devReplay --model multi-turn --wait --json --base-dir "$proof_home"
T3CODE_PORT=14990 node apps/server/src/bin.ts auth pairing create --ttl 30m --label scenario --base-url "http://$device_host:14991" --base-dir "$proof_home" > "$pair_file"
