#!/usr/bin/env python3
"""Run from each checkout after starting its dev app with T3CODE_DEV_SEED=0.
Usage: python3 seed.py <isolated T3 home> <empty synthetic workspace>
Open the returned thread in the web client. Wait until its parent turn ends
and the Waiting background-command row appears. Hover its sidebar row and
click Settle. On base it settles; on head it refuses with wait/Stop guidance.
"""
import pathlib, subprocess, sys
home, workspace = map(lambda x: str(pathlib.Path(x).resolve()), sys.argv[1:3])
pathlib.Path(workspace).mkdir(parents=True, exist_ok=True)
subprocess.run(["git", "init", "-q", workspace], check=True)
cli = ["node", "apps/server/src/bin.ts"]
subprocess.run(cli + ["project", "add", workspace, "--title", "Settle demo", "--base-dir", home], check=True)
prompt = "Launch Bash with run_in_background=true running sleep 300. Load and call t3_background_wait with its task ID. Then end this turn with only: Background task launched; waiting for completion. Do not wait synchronously or stop the task."
subprocess.run(cli + ["thread", "start", workspace, prompt, "--title", "Background work proof", "--provider", "claudeAgent", "--model", "claude-haiku-5-5", "--base-dir", home, "--json"], check=True)
