import json, pathlib, subprocess, sys
# Run once for each isolated app checkout. No live state is copied.
checkout, project = map(pathlib.Path, sys.argv[1:])
project.mkdir(parents=True, exist_ok=True)
(project/'notes.txt').write_text('Synthetic permission proof.\n')
config=json.loads(pathlib.Path(__file__).with_name('review-agent.json').read_text())
for destination in [project/'opencode.json', checkout/'apps/server/opencode.json']:
    destination.write_text(json.dumps(config,indent=2)+'\n')
subprocess.run(['git','init','-q',str(project)],check=True)
subprocess.run(['node','apps/server/src/bin.ts','project','add','--base-dir','.t3','--title','Permission proof',str(project)],cwd=checkout,check=True)
# Start with T3CODE_DEV_SEED=0 vp run dev, add the OpenCode provider in Settings,
# then refresh provider status and wait for the catalog refresh to finish.
