"""Create a synthetic fixture and configure an already-running isolated T3 checkout.
Usage: python3 seed.py CHECKOUT PROJECT OPENCODE_BINARY
Start the checkout with T3CODE_DEV_SEED=0 vp run dev before running this script.
"""
import json, pathlib, subprocess, sys
checkout, project, binary = map(pathlib.Path,sys.argv[1:])
project.mkdir(parents=True,exist_ok=True)
(project/'opencode.json').write_text(json.dumps({'experimental':{'subagent_depth':2}}))
(project/'README.md').write_text('Synthetic nested background continuation demonstration.\n')
subprocess.run(['git','init','-q',str(project)],check=True)
subprocess.run(['git','-C',str(project),'add','.'],check=True)
subprocess.run(['git','-C',str(project),'-c','user.name=Evidence','-c','user.email=evidence@example.com','commit','-qm','Synthetic fixture'],check=True)
settings=checkout/'.t3/userdata/settings.json'
data=json.loads(settings.read_text())
data.setdefault('providerInstances',{})['opencode']={'driver':'opencode','enabled':True,'config':{'binaryPath':str(binary)}}
settings.write_text(json.dumps(data))
subprocess.run(['node','apps/server/src/bin.ts','project','add','--base-dir','.t3','--title','Continuation demo',str(project)],cwd=checkout,check=True)
