"""Scratch instrumentation only: expose this synthetic replay session to the MCP driver.
Usage: python3 prepare-replay.py <checkout> <private-session-json-path>
Then run T3CODE_DEV_SEED=0 vp run dev in that checkout, add the synthetic HTML
folder with t3 project add, and t3 thread start it with --provider devReplay
--model showcase. Run record.mjs during the five-minute active turn.
Never upload the session JSON: it contains the ephemeral MCP credential.
The recording code is left untouched.
"""
import json, sys
from pathlib import Path
checkout, session_file = sys.argv[1:]
p = Path(checkout) / 'apps/server/scripts/dev-replay-agent.ts'
s = p.read_text()
s = s.replace('const cwd = typeof params.cwd',
    f'NodeFS.writeFileSync({json.dumps(session_file)}, JSON.stringify(params), {{ mode: 0o600 }});\n        const cwd = typeof params.cwd')
s = s.replace('case "session/prompt": {',
    'case "session/prompt": {\n        await new Promise(resolve => setTimeout(resolve, 300000));')
p.write_text(s)
