"""Seed the real-app reproduction. Run from either isolated checkout after
T3CODE_DEV_SEED=0 vp run dev has created fresh state. No provider is mocked.
Pass a synthetic workspace directory as the only argument.
After 'started', record the web conversation, restart the retained dev terminal,
and observe for at least 45 seconds. Use the same prompt on both commits.
"""
import json
import pathlib
import subprocess
import sys

workspace = pathlib.Path(sys.argv[1]).resolve()
workspace.mkdir(parents=True, exist_ok=True)
settings = pathlib.Path('.t3/userdata/settings.json')
config = json.loads(settings.read_text())
config.setdefault('providerInstances', {})['claude'] = {
    'driver': 'claudeAgent', 'enabled': True, 'config': {}
}
settings.write_text(json.dumps(config, indent=2))

def cli(*args):
    return subprocess.check_output(
        ['node', 'apps/server/src/bin.ts', *args], text=True
    ).strip()

print(cli('project', 'add', '--base-dir', '.t3', '--title', 'Timer comparison', str(workspace)))
thread = cli('thread', 'start', '--base-dir', '.t3', '--provider', 'claude',
    '--model', 'haiku', '--title', 'Leading-dot timer', str(workspace),
    'Run exactly sleep .5m; date using Bash with run_in_background: true. '
    'Do not change the command spelling. Then reply only started and end your turn. '
    'When it completes, report the output.')
print(thread)
print('Inspect with: node apps/server/src/bin.ts thread show --base-dir .t3 --json ' + thread)
