#!/usr/bin/env bash
set -eu
# Run from either isolated checkout. EVIDENCE_MODEL is supplied privately.
# Start its server first with T3CODE_DEV_SEED=0 vp run dev.
: "${EVIDENCE_MODEL:?Supply an available Pi model}"
case_name=${1:-custom}
output_root=${2:?Supply a scratch output directory}
run_dir="$output_root/$(date -u +%Y%m%dT%H%M%S)-$case_name"
mkdir -p "$run_dir"
question='{"header":"Area","question":"Which area should we work on?","options":[{"label":"Docker/Compose","description":"Review or edit Compose projects"},{"label":"Home Assistant","description":"Automations, dashboards or YAML"}]}'
if [ "$case_name" = preview ]; then
 question='{"header":"Area","question":"Which area should we work on?","options":[{"label":"Docker/Compose","description":"Review or edit Compose projects","preview":"services:\n  web:\n    image: nginx:alpine"},{"label":"Home Assistant","description":"Automations, dashboards or YAML"}]},{"header":"Area","question":"Which area should we work on? Next task","options":[{"label":"Docker/Compose","description":"Review or edit Compose projects"},{"label":"Home Assistant","description":"Automations, dashboards or YAML"}]}'
fi
prompt="Call ask_user_question now with exactly this JSON: {\"questions\":[$question]}. After I answer, report the exact tool result verbatim. Do not call any other tools."
printf '%s\n' "$prompt" > "$run_dir/prompt.txt"
node apps/server/src/bin.ts thread start --base-dir .t3 --title "Area $case_name" --provider pi --model "$EVIDENCE_MODEL" . "$prompt" --json | tee "$run_dir/thread.json"
# Browser: 1280x900, dark theme, details panel closed.
# selection: click Docker/Compose, then Submit.
# custom: type literal 2 in the custom-answer textbox, then Submit.
# preview: inspect preview; type 2, Submit; inspect full second title; select Docker/Compose, Submit.
# Record each interaction through completion and inspect the exact tool result.
