"""Portable form of the synthetic fixture used for this proof.
Usage: python3 setup.py NEW_EMPTY_DIRECTORY
Run gateway.mjs in that directory's parent, then start each app with
T3CODE_DEV_SEED=0 and --home-dir <directory>/<head|base>.
Add an empty git workspace with `t3 project add`, then run:
t3 thread start <workspace> 'Please reply with a short confirmation.' \
 --title 'Custom model reasoning' --provider opencode --model proof/custom-model \
 --base-dir <directory>/<head|base> --wait --json
"""
import json,pathlib,shutil,sys
root=pathlib.Path(sys.argv[1]).resolve()
model={'name':'Custom Model','limit':{'context':32000,'output':4096},'variants':{x:{'reasoningEffort':x} for x in ['low','medium','high']}}
provider={'npm':'@ai-sdk/openai-compatible','name':'Proof Gateway','options':{'baseURL':'http://127.0.0.1:18273/v1','apiKey':'synthetic'},'models':{'custom-model':model}}
config={'$schema':'https://opencode.ai/config.json','enabled_providers':['proof'],'provider':{'proof':provider}}
root.mkdir(parents=True,exist_ok=True)
(root/'opencode.json').write_text(json.dumps(config,indent=2))
for side in ['head','base']:
 home=root/side
 p=home/'userdata';p.mkdir(parents=True,exist_ok=True)
 instances={x:{'driver':x,'enabled':x=='opencode'} for x in ['codex','claudeAgent','cursor','grok','muse','pi','opencode','antigravity']}
 env={'OPENCODE_CONFIG':str(root/'opencode.json'),'OPENCODE_CONFIG_CONTENT':json.dumps(config),'XDG_DATA_HOME':str(home/'opencode-data')}
 instances['opencode'].update(config={'binaryPath':shutil.which('opencode')},environment=[{'name':k,'value':v,'sensitive':False} for k,v in env.items()])
 (p/'settings.json').write_text(json.dumps({'defaultModelSelection':{'instanceId':'opencode','model':'proof/custom-model'},'providerInstances':instances},indent=2))
