"""Configure the current-main scenario harness; production application files stay untouched.
Set T3_EVIDENCE_OPENCODE to the absolute path of the isolated OpenCode wrapper.
Set T3_EVIDENCE_SURFACE to web or ios, then run scenarios:prove normally.
"""
import os
import subprocess
from pathlib import Path
surface = os.environ.get('T3_EVIDENCE_SURFACE', 'web')
assert surface in ('web', 'ios')
p = Path('scripts/scenarios/start-app.ts')
s = subprocess.check_output(['git', 'show', 'HEAD:'+str(p)], text=True)
s = s.replace('enabled: false,', 'enabled: driver === "opencode",')
s = s.replace('...(driver === "codex" ? { config: { binaryPath: noModel } } : {}),', '...(driver === "codex" ? { config: { binaryPath: noModel } } : driver === "opencode" ? { config: { binaryPath: process.env.T3_EVIDENCE_OPENCODE } } : {}),')
p.write_text(s)
p = Path('scripts/e2e.config.ts')
s = subprocess.check_output(['git', 'show', 'HEAD:'+str(p)], text=True)
if surface == 'web':
 start=s.index('    {\n      name: "ios",'); end=s.index('\n  ],', start)
else:
 start=s.index('    {\n      name: "web",'); end=s.index('    {\n      name: "ios",', start)
p.write_text((s[:start]+s[end:]).replace("  timeout: 300_000,", "  timeout: 600_000,\n  cleanupTimeout: 180_000,\n  actionTimeout: 180_000,"))
