"""Usage: python3 setup-proof.py T3_HOME SYNTHETIC_REPO AGENT_MJS OUTPUT_JSON
Run before starting the isolated real server. Then start it with:
T3CODE_DEV_SEED=0 node scripts/dev-runner.ts dev:server --home-dir T3_HOME --no-seed --port PORT --dev-url http://127.0.0.1:PORT
Finally run seed-and-run.py CHECKOUT T3_HOME SYNTHETIC_REPO.
Use a fresh T3_HOME and SYNTHETIC_REPO per commit. Never use live app data.
"""
import pathlib,json,subprocess,sys,shutil
home,repo,agent,output=map(pathlib.Path,sys.argv[1:])
(home/'userdata').mkdir(parents=True,exist_ok=True)
settings={'providerInstances':{'proofAgent':{'driver':'acpRegistry','displayName':'Ref cache proof','config':{'source':'local','commandPath':shutil.which('node'),'commandArgs':[str(agent.resolve()),str(output.resolve())]}}}}
(home/'userdata/settings.json').write_text(json.dumps(settings))
repo.mkdir();(repo/'README.md').write_text('Synthetic ref cache evidence\n')
for args in [['init','-q','-b','main'],['add','.'],['-c','user.name=Evidence','-c','user.email=evidence@example.invalid','commit','-qm','Initial commit']]:subprocess.run(['git',*args],cwd=repo,check=True)
