#!/usr/bin/env python3
"""Usage: seed-runtime.py WORKTREE [--handshake 1.5.0|1.5.9]. Linux x64 only.
Use a fresh isolated checkout. Install dependencies and have agy on PATH first.
The wrapper forwards real ACP to agy and changes only initialize agentInfo.version.
The managed install record stays at 1.5.0 throughout the reproduction.
"""
from pathlib import Path
import argparse,json,shutil
p=argparse.ArgumentParser();p.add_argument('worktree',type=Path);p.add_argument('--handshake',default='1.5.0');a=p.parse_args()
assert shutil.which('agy'), 'agy must be on PATH'
rid='a'*64
d=a.worktree/'.t3/tools/antigravity-acp/linux-x64';v=d/'versions'/rid
v.mkdir(parents=True,exist_ok=True)
code=Path(__file__).with_name('runtime-wrapper.py').read_text()
(v/'antigravity').write_text(code);(v/'antigravity').chmod(0o755)
(v/'handshake-version').write_text(a.handshake)
(v/'.install-complete.json').write_text(json.dumps({'releaseId':rid,'version':'1.5.0','executable':{'name':'antigravity','bytes':len(code.encode())}}))
(d/'active.json').write_text(json.dumps({'releaseId':rid}))
