#!/usr/bin/env python3
"""Prepare only fresh, disposable T3 homes; run with both checkout paths and a scratch workspace path.
Run while the test servers are stopped, after each server has initialized its fresh settings.
"""
import json
import pathlib
import subprocess
import sys

head, base, workspace = map(pathlib.Path, sys.argv[1:4])
for checkout in (head, base):
    settings = checkout / ".t3/userdata/settings.json"
    value = json.loads(settings.read_text())
    value["linkedEnvironmentsEnabled"] = True
    settings.write_text(json.dumps(value, indent=2))
workspace.mkdir(parents=True, exist_ok=True)
(workspace / "README.md").write_text("Synthetic workspace for linked-task verification.\n")
subprocess.run(["git", "init", str(workspace)], check=True)
