"""Synthetic seed equivalent to the fixture used for the two app runs.
Usage: python3 seed.py OUTPUT_DIRECTORY
Start stub.py separately. Start each checkout with T3CODE_DEV_SEED=0,
PI_CODING_AGENT_DIR=<output>/pi, and vp run dev --home-dir <output>/<side> --no-seed.
Use the app CLI to project add <side>/status-demo, then thread start that project
with --provider devReplay --model multi-turn --wait --title "HTTP status demo".
In Settings > Threads choose the Pi text generation model; source-control writer
selection remains unset. Open the thread and click Commit without a message.
Repeat with google/gemini-2.5-flash and mistral/mistral-small-latest on both sides.
"""
from pathlib import Path
import json, subprocess, sys
root = Path(sys.argv[1]).resolve()
(root / "pi").mkdir(parents=True, exist_ok=True)
(root / "pi/models.json").write_text(json.dumps({"providers": {
    "google": {"baseUrl": "http://127.0.0.1:19734/v1beta", "apiKey": "synthetic-key"},
    "mistral": {"baseUrl": "http://127.0.0.1:19734", "apiKey": "synthetic-key"}}}))
(root / "pi/settings.json").write_text(json.dumps({"retry": {"enabled": False}}))
for side in ["base", "head"]:
    home = root / side / "userdata"
    home.mkdir(parents=True, exist_ok=True)
    (home / "settings.json").write_text(json.dumps({
        "textGenerationModelSelection": {"instanceId": "pi", "model": "google/gemini-2.5-flash"},
        "providerInstances": {k: {"driver": k, "enabled": k == "pi"} for k in
            ["codex", "claudeAgent", "cursor", "grok", "muse", "pi", "opencode", "antigravity"]}}))
    repo = root / side / "status-demo"
    repo.mkdir()
    (repo / "README.md").write_text("A small status demonstration.\n")
    def git(*args):
        subprocess.run(["git", *args], cwd=repo, check=True)
    git("init", "-b", "main")
    git("add", ".")
    git("-c", "user.name=Demo", "-c", "user.email=demo@example.invalid", "commit", "-m", "Initial commit")
    (repo / "README.md").write_text("A small status demonstration.\nHTTP errors should include their status.\n")
