#!/usr/bin/env python3
"""Synthetic project used identically for both manual web reproductions.
Usage: seed.py CHECKOUT ISOLATED_T3_HOME
Start each checkout with T3CODE_DEV_SEED=0 and --home-dir ISOLATED_T3_HOME.
"""
import pathlib
import subprocess
import sys

checkout, home = map(pathlib.Path, sys.argv[1:])
project = home / 'workspaces' / 'handoff-demo'
project.mkdir(parents=True)
(project / 'README.md').write_text('Synthetic worktree handoff demo.\n')
def git(*args):
    subprocess.run(['git', *args], cwd=project, check=True)
git('init', '-q', '-b', 'main')
git('add', '.')
git('-c', 'user.name=Scenario', '-c', 'user.email=scenario@example.invalid',
    'commit', '-qm', 'Initial commit')
git('branch', 'dev')
git('remote', 'add', 'origin', str(project))
git('fetch', 'origin')
subprocess.run(['node', 'apps/server/src/bin.ts', 'project', 'add', str(project),
                '--title', 'handoff-demo', '--base-dir', str(home)], cwd=checkout, check=True)
