#!/usr/bin/env bash
set -eu
# Run from either installed checkout; supply an empty synthetic workspace and a configured model.
: "${EVIDENCE_MODEL:?}"
: "${EVIDENCE_WORKSPACE:?}"
mkdir -p .t3/userdata "$EVIDENCE_WORKSPACE"
python3 - <<'PY'
import json, os
p='.t3/userdata/settings.json'
try:
    with open(p) as f: settings=json.load(f)
except FileNotFoundError: settings={}
settings.update(continueThreadsAfterServerUpdate=True, enableProviderUpdateChecks=False,
                defaultModelSelection={'instanceId':'codex','model':os.environ['EVIDENCE_MODEL']})
with open(p,'w') as f: json.dump(settings,f)
PY
git -C "$EVIDENCE_WORKSPACE" init -q
git -C "$EVIDENCE_WORKSPACE" -c user.name=Evidence -c user.email=evidence@example.invalid commit --allow-empty -qm Initial
# Start with T3CODE_DEV_SEED=0 vp run dev, then register the workspace through the running app:
# node apps/server/src/bin.ts project add "$EVIDENCE_WORKSPACE" --title 'Restart command evidence' --base-dir .t3
# driver.py restarts its own dev server and creates a fresh thread through this same CLI.
