#!/usr/bin/env python3
"""Usage: seed.py OUTPUT_DIRECTORY OPENCODE_2_3_BINARY
Creates fresh synthetic Go-key-only credentials and T3 settings per commit.
Run T3 with T3CODE_DEV_SEED=0 vp run dev --home-dir OUTPUT_DIRECTORY/home.
Optional deterministic usage: set NODE_OPTIONS=--import=<go-usage-fixture.mjs>
and GO_FIXTURE_TRANSCRIPT=<new transcript path> identically on each side.
The fixture replaces only the Go HTTP usage response; OpenCode serve is real.
Open /usage, choose Limits, and refresh. No Console workspace is configured.
"""
import json, sys
from pathlib import Path
root, binary = Path(sys.argv[1]).resolve(), str(Path(sys.argv[2]).resolve())
for directory in ['xdg/data/opencode','xdg/config','xdg/cache','home/userdata']:
    (root/directory).mkdir(parents=True, exist_ok=True)
(root/'xdg/data/opencode/auth.json').write_text(json.dumps({'opencode-go':{'type':'api','key':'synthetic-invalid-go-key'}}))
instances = {k:{'driver':k,'enabled':False} for k in ['codex','claudeAgent','cursor','grok','muse','pi','antigravity']}
instances['opencode'] = {'driver':'opencode','enabled':True,'environment':[
    {'name':f'XDG_{k.upper()}_HOME','value':str(root/'xdg'/k),'sensitive':False}
    for k in ['data','config','cache']], 'config':{'binaryPath':binary}}
(root/'home/userdata/settings.json').write_text(json.dumps({'providerInstances':instances}, indent=2))
