#!/usr/bin/env bash
set -euo pipefail
# Run from either installed checkout, with its unseeded dev server already running.
# Usage: bash reproduce.sh <absolute-checkout> <new-output-directory>
checkout=$1
out=$2
mkdir -p "$out"
cd "$checkout"
cli=(node apps/server/src/bin.ts)
message='Create a three-step plan with your plan/todo tool, then perform the steps one at a time and mark each complete in the plan as you go. Steps: 1) run pwd, 2) run ls | head -5, 3) run git log -1 --oneline. Do not modify any files.'
"${cli[@]}" project add . --title 'Codex plan proof' --base-dir "$checkout/.t3"
"${cli[@]}" thread start . "$message" --provider codex --model gpt-6-luna --title 'Plan snapshot completion proof' --base-dir "$checkout/.t3" --wait --json > "$out/runtime.json"
thread=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["threadId"])' "$out/runtime.json")
python3 "$(dirname "$0")/inspect.py" "$checkout" "$thread" "$(git rev-parse HEAD)" proof > "$out/projections.json"
# Open that thread in the paired web client; expand Worked for, then Tasks 3/3.
# runtime.json contains local command output: redact paths before sharing it.
