"""Synthetic setup for the two-host Compose regression.
Run from the checkout under test after both fresh servers listen.
Usage: python3 reproduce.py <scratch> <host-a-home> <host-b-home>
Then follow the UI steps in the accompanying evidence.
"""
import pathlib, subprocess, sys
root, host_a, host_b = map(pathlib.Path, sys.argv[1:])
for name in ('shared-repo', 'shared-repo-b', 'other'):
    project = root / 'projects' / name
    project.mkdir(parents=True, exist_ok=True)
    subprocess.run(['git', 'init', '-q', str(project)], check=True)
    if name != 'other':
        subprocess.run(['git', '-C', str(project), 'remote', 'add', 'origin',
                        'https://github.com/example/shared-repo.git'], check=True)
for home, name in ((host_a, 'shared-repo'), (host_b, 'shared-repo-b'), (host_b, 'other')):
    subprocess.run(['node', 'apps/server/src/bin.ts', 'project', 'add',
                    str(root / 'projects' / name), '--title', name,
                    '--base-dir', str(home)], check=True)
