"""Create isolated login-shell fixture. Usage: python3 setup-proof.py <scratch-directory>.
Then set PATH_PROOF_DIR to it, SHELL to its shell, T3CODE_DEV_SEED=0, and
T3_SCENARIO_INHERIT_ENV=SHELL,T3CODE_DEV_SEED before scenarios:prove.
The scenario uses real local claude/codex binaries; it never starts a model turn.
"""
import pathlib
import shutil
import sys

root = pathlib.Path(sys.argv[1]).resolve()
root.mkdir(parents=True, exist_ok=True)
(root / "late").mkdir(exist_ok=True)
(root / "profile").write_text("")
for name in ("claude", "codex"):
    target = shutil.which(name)
    if target is None:
        raise RuntimeError(f"Install {name} before running this proof")
    (root / "late" / f"{name}-late").symlink_to(target)
(root / "shell").write_text(
    '#!/bin/sh\n'
    '. "$(dirname "$0")/profile"\n'
    'printf "read\\n" >> "$(dirname "$0")/reads"\n'
    'if [ "$1" = "-ilc" ]; then shift; exec /bin/sh -c "$1"; fi\n'
    'exec /bin/sh "$@"\n'
)
(root / "shell").chmod(0o755)
