"""Run from the checkout under test, against its fresh running dev server.
Usage: python3 reproduce.py T3_HOME DEMO_DIRECTORY
Then open the returned thread in the paired web client. After the three Read
calls and while Claude is thinking/writing, type into the composer and press Enter:
Unrelated: also tell me in one short sentence what 2+2 is.
Wait for the run to settle; inspect the collapsed Continued for group, then expand it.
Use the same 1440x1000 light web viewport on both commits.
"""
import pathlib, subprocess, sys
home, demo = map(pathlib.Path, sys.argv[1:])
demo.mkdir(parents=True, exist_ok=True)
for i, text in enumerate([
    "Design a collaborative document editor with offline support.",
    "Users need shared workspaces, version history, and comments.",
    "Prefer a simple architecture with clear consistency and recovery guarantees.",
], 1):
    (demo / f"m{i}.txt").write_text(text + "\n")
def run(*args):
    return subprocess.run(args, check=True)
run("git", "init", "-q", str(demo))
run("git", "-C", str(demo), "add", ".")
run("git", "-C", str(demo), "-c", "user.name=Demo", "-c", "user.email=demo@example.invalid", "commit", "-qm", "Initial files")
def cli(*args):
    run("node", "apps/server/src/bin.ts", *args, "--base-dir", str(home))
cli("project", "add", str(demo), "--title", "Design demo")
cli("thread", "start", "--provider", "claudeAgent", "--model", "claude-haiku-5-5",
    "--title", "Late steer design answer", str(demo),
    "Read m1.txt, m2.txt and m3.txt one at a time with separate tool calls. Then, without further tool calls, write a very detailed design document (at least 5000 words) for the system described in those files. Include architecture, data model, synchronization, consistency, failure recovery, security, testing, rollout, and tradeoffs. Write the full document in your answer, not in a file.", "--json")
