"""Seed the real app, then follow the recorded browser steps below.
Usage: python3 seed-and-reproduce.py CHECKOUT PROJECT_PATH PROVIDER_INSTANCE_ID
Configure the local ACP provider with executable opencode and argument acp first.
Start CHECKOUT with T3CODE_DEV_SEED=0 vp run dev.
"""
import pathlib, subprocess, sys
checkout, workspace, provider = sys.argv[1:]
workspace = pathlib.Path(workspace).resolve()
workspace.mkdir(parents=True, exist_ok=True)
(workspace / "README.md").write_text("Synthetic conversation demo.\n")
def run(*args):
    return subprocess.run(args, cwd=checkout, check=True)
run("git", "init", "-q", "-b", "main", str(workspace))
run("git", "-C", str(workspace), "add", ".")
run("git", "-C", str(workspace), "-c", "user.name=Demo", "-c", "user.email=demo@example.invalid", "commit", "-qm", "Initial")
cli = ["node", "apps/server/src/bin.ts"]
run(*cli, "project", "add", str(workspace), "--title", "Memory demo", "--base-dir", ".t3")
run(*cli, "thread", "start", str(workspace), "My favourite colour is teal. Reply with only the word: noted", "--provider", provider, "--model", "openai/gpt-6-luna", "--title", "ACP retained conversation", "--wait", "--json", "--base-dir", ".t3")
# Use the returned threadId:
# node apps/server/src/bin.ts thread send THREAD_ID 'My favourite animal is an otter. Reply with only the word: noted' --wait --json --base-dir .t3
# Open the thread by /ENVIRONMENT_ID/URL_ENCODED_THREAD_ID in the paired browser.
# Viewport: 1440 x 1000 CSS pixels, device scale 2, dark theme.
# Hide thread details and sidebar before recording.
# The same preview tool actions were used on base and head:
# preview_recording_start({})
# preview_act({action:"click", locator:"button:has-text('My favourite animal is an otter')"})
# preview_act({action:"click", locator:"button[aria-label='Edit from here']"})
# preview_act({action:"click", locator:"button:has-text('Revert and keep changes')"})
# preview_act({action:"click", locator:"[role=textbox][contenteditable=true]"})
# preview_act({action:"press", key:"ControlOrMeta+A"})
# preview_act({action:"type", locator:"[role=textbox][contenteditable=true]", text:"What did I say first?"})
# preview_act({action:"click", locator:"button[aria-label='Submit message']"})
# Wait for completion and read the reply.
# preview_act({action:"type", locator:"[role=textbox][contenteditable=true]", text:"Did I ever mention an animal? Answer yes or no."})
# preview_act({action:"click", locator:"button[aria-label='Submit message']"})
# Wait for completion, read reply, stop recording, capture final conversation.
# Observed base: Your first message was: “What did I say first?” / No
# Observed head: You said your favourite colour is teal. / No
