#!/usr/bin/env bash
set -eu
: "${T3_CHECKOUT:?}" "${T3_HOME:?}" "${EVIDENCE_WORKSPACE:?}" "${EVIDENCE_MODEL:?}"
cd "$T3_CHECKOUT"
mkdir -p "$EVIDENCE_WORKSPACE"
git -C "$EVIDENCE_WORKSPACE" init -q
git -C "$EVIDENCE_WORKSPACE" -c user.name=Verification -c user.email=verification@example.invalid commit --allow-empty -qm 'Synthetic verification workspace'
node apps/server/src/bin.ts project add --base-dir "$T3_HOME" --title 'Fork recovery' "$EVIDENCE_WORKSPACE"
node apps/server/src/bin.ts thread start --base-dir "$T3_HOME" --provider opencode --model "$EVIDENCE_MODEL" --title 'Stopped source' --wait --json "$EVIDENCE_WORKSPACE" 'Reply with exactly: Ready to fork.'
