"""Create the synthetic terminal proof project and one replay-backed thread through T3's CLI.
Usage: python3 seed-terminal.py CHECKOUT T3_HOME WORKSPACE
Start each checkout first with:
  T3CODE_DEV_SEED=0 node scripts/scenarios/start-app.ts web T3_HOME 127.0.0.1 PORT
The start script creates fresh state, disables paid providers, and writes the pairing path locally.
Pair a dedicated browser session before running capture-terminal.py; do not publish the pairing path.
"""
import pathlib, subprocess, sys
checkout, home, workspace = map(pathlib.Path, sys.argv[1:])
workspace.mkdir(parents=True, exist_ok=True)
def run(args, cwd):
    subprocess.run(args, cwd=cwd, check=True, capture_output=True, text=True)
if not (workspace / '.git').exists():
    run(['git', 'init', '--quiet', '--initial-branch=main'], workspace)
    run(['git', '-c', 'user.name=Scenario', '-c', 'user.email=scenario@example.invalid',
         'commit', '--allow-empty', '--quiet', '--message', 'Initial commit'], workspace)
cli = ['node', 'apps/server/src/bin.ts']
run([*cli, 'project', 'add', str(workspace), '--title', 'terminal-grid', '--base-dir', str(home)], checkout)
# This public replay fixture runs no paid model.
run([*cli, 'thread', 'start', str(workspace), 'Ready', '--title', 'Wide glyph grid',
     '--provider', 'devReplay', '--model', 'multi-turn', '--wait', '--json', '--base-dir', str(home)], checkout)
print('Synthetic project and completed replay thread created.')
