import json
import os
import subprocess
import sys
import tempfile
from datetime import datetime
from pathlib import Path
ROOT = Path(tempfile.mkdtemp()) / "projects"
SESSIONS = {
"sess-9f2c": ("2026-06-09T15", "/Users/dev/webapp"),
"sess-41aa": ("2026-06-08T11", "/Users/dev/webapp"),
"sess-c3d7": ("2026-06-09T09", "/Users/dev/api"),
}
def envelope(session, n, **fields):
hour, cwd = SESSIONS[session]
return {"uuid": f"{session}-{n}", "parentUuid": None, "sessionId": session,
"timestamp": f"{hour}:{n:02d}:00+00:00", "cwd": cwd, "gitBranch": "main",
"version": "2.1.0", "isSidechain": False, "entrypoint": "cli"} | fields
def user(session, n, text):
return envelope(session, n, type="user", message={"role": "user", "content": text})
def assistant(session, n, content, stop_reason="end_turn"):
return envelope(session, n, type="assistant", message={
"role": "assistant", "model": "claude-opus-4-7",
"stop_reason": stop_reason, "content": content})
def tool_result(session, n, tool_use_id, content, is_error=False):
return envelope(session, n, type="user", message={"role": "user", "content": [
{"type": "tool_result", "tool_use_id": tool_use_id,
"content": content, "is_error": is_error}]})
def write(relpath, entries, stamp):
path = ROOT / relpath
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text("\n".join(json.dumps(entry) for entry in entries) + "\n")
os.utime(path, (mtime := datetime.fromisoformat(stamp).timestamp(), mtime))
return path
fix_login = [
user("sess-9f2c", 0, "the login test is failing on main - can you fix it?"),
assistant("sess-9f2c", 1, [
{"type": "thinking", "thinking": "Probably the new password argument. Read the test first."},
{"type": "tool_use", "id": "toolu_01", "name": "Read",
"input": {"file_path": "/Users/dev/webapp/tests/test_login.py"}},
], stop_reason="tool_use"),
tool_result("sess-9f2c", 2, "toolu_01", 'def test_login():\n assert authenticate("alice")'),
assistant("sess-9f2c", 3, [
{"type": "tool_use", "id": "toolu_02", "name": "Bash",
"input": {"command": "uv run pytest tests/test_login.py"}},
], stop_reason="tool_use"),
tool_result("sess-9f2c", 4, "toolu_02",
"FAILED tests/test_login.py::test_login - TypeError: "
"authenticate() missing 1 required positional argument: 'password'",
is_error=True),
assistant("sess-9f2c", 5, [{"type": "text", "text":
"The call site predates the password argument - I'll give authenticate() a default."}]),
user("sess-9f2c", 6, "<system-reminder>The user opened tests/test_login.py in the IDE.</system-reminder>"),
user("sess-9f2c", 7, "[Request interrupted by user]"),
user("sess-9f2c", 8, "no - update the test to pass a password, a default would mask real bugs"),
assistant("sess-9f2c", 9, [{"type": "text", "text":
'Updated: the test now calls authenticate("alice", password="pw") and passes.'}]),
]
healthz = [
user("sess-41aa", 0, "add a /healthz endpoint that returns the build sha"),
assistant("sess-41aa", 1, [
{"type": "text", "text": "Adding it to the router."},
{"type": "tool_use", "id": "toolu_11", "name": "Edit",
"input": {"file_path": "/Users/dev/webapp/app/routes.py"}},
], stop_reason="tool_use"),
tool_result("sess-41aa", 2, "toolu_11", "ok"),
assistant("sess-41aa", 3, [{"type": "text", "text": "/healthz now returns the version and sha."}]),
]
deploy = [
user("sess-c3d7", 0, "why does deploy.sh exit 1 on staging?"),
assistant("sess-c3d7", 1, [
{"type": "tool_use", "id": "toolu_21", "name": "Bash",
"input": {"command": "bash -x deploy.sh staging"}},
], stop_reason="tool_use"),
tool_result("sess-c3d7", 2, "toolu_21",
"+ aws s3 sync ./dist s3://api-staging\nfatal: bucket does not exist",
is_error=True),
assistant("sess-c3d7", 3, [{"type": "text", "text":
"deploy.sh still targets the old api-staging bucket."}]),
]
write("-Users-dev-webapp/sess-41aa.jsonl", healthz, "2026-06-08T11:04")
write("-Users-dev-api/sess-c3d7.jsonl", deploy, "2026-06-09T09:04")
MAIN = write("-Users-dev-webapp/sess-9f2c.jsonl", fix_login, "2026-06-09T15:10")
def cc(*args):
cli = Path(sys.executable).parent / "cc-transcript"
return subprocess.run([str(cli), *args],
capture_output=True, text=True).stdout
sorted(str(path.relative_to(ROOT.parent)) for path in ROOT.rglob("*.jsonl"))
# -> ['projects/-Users-dev-api/sess-c3d7.jsonl',
# 'projects/-Users-dev-webapp/sess-41aa.jsonl',
# 'projects/-Users-dev-webapp/sess-9f2c.jsonl']