import pathlib,subprocess,sys
checkout,side=sys.argv[1:]
root=pathlib.Path(__file__).parent/side
repo=root/'repo'
(repo/'packages/app').mkdir(parents=True)
(repo/'packages/app/README.md').write_text('Synthetic branch occupancy reproduction.\n')
def run(args,cwd=None):
 return subprocess.run(args,cwd=cwd,check=True,text=True,capture_output=True).stdout
run(['git','init','-b','main',str(repo)])
run(['git','add','.'],repo)
run(['git','-c','user.name=Evidence','-c','user.email=evidence@example.invalid','commit','-m','Initial commit'],repo)
run(['git','worktree','add','-b','feature/linked',str(root/'repo-linked')],repo)
home=str(pathlib.Path(checkout)/'.t3')
def cli(args): return run(['node','apps/server/src/bin.ts',*args,'--base-dir',home],checkout)
print(cli(['project','add',str(repo/'packages/app'),'--title','app (subdir)']))
