# Run from each isolated checkout after T3CODE_DEV_SEED=0 vp run dev.
# Usage: python3 seed.py <new-output-directory>
import pathlib, subprocess, json, sys, shutil
out=pathlib.Path(sys.argv[1]).resolve(); out.mkdir(parents=True,exist_ok=True)
repo=out/'fallback-proof';repo.mkdir()
def git(*args):return subprocess.run(['git','-C',str(repo),*args],check=True,capture_output=True,text=True)
git('init','-b','main');git('config','user.name','Proof');git('config','user.email','proof@example.com')
(repo/'a.txt').write_text('hello\n');git('add','.');git('commit','-m','Initial sample')
(repo/'a.txt').write_text('hello\nworld\n');(repo/'b.txt').write_text('world\n')
wrapper=out/'claude-record'
wrapper.write_text('''#!/usr/bin/env python3
import os,sys,json
from pathlib import Path
args=sys.argv[1:]
if '--model' in args:
    with open(str(Path(__file__).with_name('models.jsonl')),'a') as f:
        f.write(json.dumps({'model':args[args.index('--model')+1], 'effort':args[args.index('--effort')+1] if '--effort' in args else None})+'\\n')
os.execv(REAL_CLAUDE,['claude',*args])
'''.replace('REAL_CLAUDE',repr(shutil.which('claude'))))
wrapper.chmod(0o755)
p=pathlib.Path('.t3/userdata/settings.json');s=json.loads(p.read_text())
for driver in ['codex','claudeAgent','cursor','grok','muse','pi','antigravity']:
 s['providerInstances'][driver]={'driver':driver,'enabled':False}
s['providerInstances']['opencode']={'driver':'claudeAgent','displayName':'Claude Work','enabled':True,'config':{'binaryPath':str(wrapper)}}
p.write_text(json.dumps(s,indent=2))
subprocess.run(['node','apps/server/src/bin.ts','project','add',str(repo),'--title','Fallback proof','--base-dir','.t3'],check=True)
subprocess.run(['node','apps/server/src/bin.ts','thread','start',str(repo),'Ready for commit proof.','--provider','devReplay','--model','command-output','--title','Commit fallback proof','--base-dir','.t3','--json'],check=True)
