"""Synthetic fixture used for the cold-start comparison.
Usage: python3 seed.py <fresh-output-directory> <checkout> <opencode-binary>
Run once per side, before T3CODE_DEV_SEED=0 vp run dev in that checkout.
Then use the app CLI to add <output>/skill-demo with title 'Skill discovery'.
In the web app create a draft in that project, select OpenCode, type /, then /s1,
reload, and type /s1 again. No model turn is sent.
"""
import json
import pathlib
import subprocess
import sys

out, checkout, binary = [pathlib.Path(p).resolve() for p in sys.argv[1:]]
out.mkdir(parents=True, exist_ok=False)
for name in ['config', 'data', 'cache', 'state']:
    (out / name).mkdir()
state = checkout / '.t3' / 'userdata'
state.mkdir(parents=True, exist_ok=True)
settings = {'providerInstances': {'opencode': {
    'driver': 'opencode', 'enabled': True,
    'config': {'binaryPath': str(binary)},
    'environment': [{'name': 'XDG_' + n.upper() + '_HOME',
                     'value': str(out / n), 'sensitive': False}
                    for n in ['config', 'data', 'cache', 'state']]
}}}
(state / 'settings.json').write_text(json.dumps(settings))
project = out / 'skill-demo'
for i in range(1, 133):
    d = project / '.claude' / 'skills' / f's{i}'
    d.mkdir(parents=True)
    (d / 'SKILL.md').write_text(
        f'---\nname: s{i}\ndescription: Synthetic skill {i} for cold-start verification.\n---\n\nPrint skill {i}.\n')
subprocess.run(['git', 'init', '-q', str(project)], check=True)
subprocess.run(['git', '-C', str(project), 'add', '.'], check=True)
subprocess.run(['git', '-C', str(project), '-c', 'user.name=Evidence',
                '-c', 'user.email=evidence@example.invalid', 'commit', '-qm',
                'Synthetic skills'], check=True)
