#!/usr/bin/env python3 """transcript_dump.py — condense a Claude Code session transcript (JSONL) into readable text (P32 T3 recovery, 2026-09-05). WHY. When a session dies without a checkpoint (context overflow mid-wave), the successor must reconstruct what it did from `~/.claude/projects//.jsonl` — 6 MB of JSON that cannot be read raw. This prints, in order, every assistant text/thinking, every tool call (Bash commands in full, Edit/Write/Agent inputs abbreviated) and every tool result truncated (agent verdicts kept longer), with timestamps, so a successor can read the session in ~150 KB and find the last checkpoint write, the commits, and what was in flight. python3 tools/transcript_dump.py Then `grep -n` the output for the last checkpoint/commit and read from there. Pair with tools/agent_verdicts.py, tools/agent_reports.py and tools/agent_drafts_restore.py for the subagents. """ import json,sys,re f=sys.argv[1]; out=open(sys.argv[2],'w') def trunc(s,n): s=s if isinstance(s,str) else json.dumps(s) return s if len(s)<=n else s[:n]+f' …[+{len(s)-n} chars]' msgs=[] for line in open(f): try: o=json.loads(line) except: continue t=o.get('type') if t not in ('user','assistant','system'): continue msgs.append(o) for o in msgs: ts=(o.get('timestamp') or '')[11:19] t=o['type'] m=o.get('message') or {} content=m.get('content') if isinstance(m,dict) else m if t=='system': out.write(f"\n[{ts}] SYSTEM: {trunc(o.get('content') or json.dumps(m),400)}\n"); continue if isinstance(content,str): if t=='user': out.write(f"\n[{ts}] USER: {trunc(content,3000)}\n") else: out.write(f"\n[{ts}] ASSISTANT: {content}\n") continue for c in content or []: ct=c.get('type') if ct=='text': if t=='user': txt=c['text'] if txt.startswith('') or txt.startswith('