#!/usr/bin/env bash
# Run in each checkout after vp i and T3CODE_DEV_SEED=0 vp run dev.
# Argument: an empty synthetic Git workspace. All state goes through the real CLI.
set -eu
workspace=$1
node apps/server/src/bin.ts project add "$workspace" --title 'Stop and rewind proof' --base-dir .t3
launch='Use T3 delegate_task exactly once to start a background child using Claude Haiku. Its task: use Bash to run sleep 900 in the background and wait for it; do not finish early. After delegating, use your own Bash to run sleep 600 in the background and wait. Keep both running until I press Stop. Do not use native Agent. Do not read files.'
node apps/server/src/bin.ts thread start "$workspace" "$launch" --provider claudeAgent --model claude-haiku-5-5 --title 'Delivery turn rewind' --base-dir .t3 --json
node apps/server/src/bin.ts thread start "$workspace" 'OPEN-F: reply READY only.' --provider claudeAgent --model claude-haiku-5-5 --title 'Source turn rewind' --base-dir .t3 --wait --json
# Send "LAUNCH-F: $launch" to the second thread with `thread send`.
# In Chromium, light theme, 1280x800 CSS px; hide sidebar/details before recording.
# On each thread wait for "Waiting on 1 subagent and 1 command", press Stop,
# then wait for the app-owned child to be interrupted with delivery disposed.
# Delivery case: send FOLLOWUP below, confirm note; Edit from here on FOLLOWUP,
# Revert and keep changes, replace composer text with REPLACEMENT and submit.
# Source case: Edit from here on LAUNCH-F, Revert and keep changes, replace with UNRELATED.
# FOLLOWUP-1: Copy verbatim every Note: line and its task bullets that were prepended to THIS user message. If none were prepended, write NO-NOTE. Do not use tools.
# REPLACEMENT-2: Which delegated tasks were interrupted? Copy verbatim every Note: line and its task bullets that were prepended to THIS user message. If none were prepended, write NO-NOTE. Do not use tools or infer a note from earlier messages.
# UNRELATED-4: What is 2 + 2? Before the answer, copy verbatim every Note: line and its task bullets that were prepended to THIS user message. If none were prepended, write NO-NOTE. Do not use tools.
# Record Stop -> Edit from here -> replacement reply on both commits.
