#!/usr/bin/env python3
"""Create the synthetic plugin fixture used for the manual two-commit proof.
Usage: python3 seed.py ROOT
Configure real Codex credentials and the model endpoint separately; this script contains none.
"""
import json
import os
from pathlib import Path
import subprocess
import sys

root = Path(sys.argv[1]).resolve()
shared = root / 'shared'
marketplace = shared / '.tmp/bundled-marketplaces/openai-bundled'
plugin = marketplace / 'plugins/zebra-facts'
(marketplace / '.agents/plugins').mkdir(parents=True, exist_ok=True)
(plugin / '.codex-plugin').mkdir(parents=True, exist_ok=True)
(plugin / 'skills/zebra-facts').mkdir(parents=True, exist_ok=True)
(marketplace / '.agents/plugins/marketplace.json').write_text(json.dumps({
    'name': 'openai-bundled',
    'plugins': [{'name': 'zebra-facts', 'source': './plugins/zebra-facts',
                 'description': 'Zebra facts proof skill'}],
}))
(plugin / '.codex-plugin/plugin.json').write_text(json.dumps({
    'name': 'zebra-facts', 'version': '1.0.0', 'description': 'Zebra facts proof skill',
}))
(plugin / 'skills/zebra-facts/SKILL.md').write_text(
    '---\nname: zebra-facts\ndescription: Facts about zebras for plugin visibility verification.\n---\nZebras have stripes.\n')
(shared / 'config.toml').write_text(
    '[marketplaces.openai-bundled]\nsource = ' + json.dumps(str(marketplace)) + '\n')
env = dict(os.environ, CODEX_HOME=str(shared))
subprocess.run(['codex', 'plugin', 'marketplace', 'add', str(marketplace), '--json'], env=env, check=True)
subprocess.run(['codex', 'plugin', 'add', 'zebra-facts@openai-bundled', '--json'], env=env, check=True)
for name in ['shadow-base', 'shadow-head', 'shadow-explicit']:
    (root / name).mkdir(exist_ok=True)
print('Fixture ready. Configure each provider with shared home and its separate shadow home.')
