"""Usage: python3 seed.py CHECKOUT PREFIX NPM_CACHE
Run the checkout once with T3CODE_DEV_SEED=0, stop it, then run this seed.
Start registry-proxy.py and restart the checkout with T3CODE_DEV_SEED=0 vp run dev.
Use separate fresh checkouts and npm caches, and reset the same prefix on both sides.
"""
import json, subprocess, sys
from pathlib import Path
checkout,prefix,cache=map(Path,sys.argv[1:])
subprocess.run(['npm','install','-g','--prefix',str(prefix),'--allow-scripts=opencode-ai','opencode-ai@1.2.10'],check=True)
p=checkout/'.t3/userdata/settings.json'
s=json.loads(p.read_text())
s['providerInstances']={
 'opencode': {'driver':'opencode','displayName':'Update evidence','enabled':True,
  'config':{'binaryPath':str(prefix/'bin/opencode')},
  'environment':[{'name':'npm_config_registry','value':'http://127.0.0.1:18761','sensitive':False},
                 {'name':'npm_config_cache','value':str(cache),'sensitive':False}]},
 'codex':{'driver':'codex','enabled':False},
 'claudeAgent':{'driver':'claudeAgent','enabled':False}}
p.write_text(json.dumps(s))
