from PIL import Image,ImageDraw,ImageFont
from pathlib import Path
import json
root=Path(__file__).parent
font=ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf',18)
for side in ['base','head']:
 p=json.loads((root/(side+'-proof.json')).read_text())
 excerpt={'toolResult.title':p['toolResult']['threads'][0]['title'],'cli.thread.title':p['cliReadBack']['thread']['title'],'cli.initialMessage':p['cliReadBack']['initialMessage']['text']}
 lines=[('Before' if side=='base' else 'After')+' | '+p['commit'][:10],'Runtime transcript excerpt (rendered from captured JSON)','Linux | OpenCode 2.4.2 | anthropic/claude-haiku-5-5','Fresh database | empty git project | child completed','','create_threads: one thread; title omitted', 'prompt = "Review the auth flow\\n\\nPay special attention to token renewal."','',*json.dumps(excerpt,indent=2).splitlines()]
 # Wrap only long JSON lines without changing their text.
 import textwrap
 lines=[part for line in lines for part in (textwrap.wrap(line,width=96,replace_whitespace=False,drop_whitespace=False) or [''])]
 im=Image.new('RGB',(1180,640),'#10151c'); d=ImageDraw.Draw(im)
 for i,line in enumerate(lines):d.text((26,24+i*27),line,font=font,fill='#e2e8f0' if i else '#8ed5b0')
 im.save(root/(side+'.png'))
