from PIL import Image,ImageDraw,ImageFont
import pathlib,json
root=pathlib.Path(__file__).parent
font='/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf'
for side in ['before','after']:
 d=json.loads((root/(side+'-log-summary.json')).read_text())
 image=Image.new('RGB',(1200,820),'#10151f');draw=ImageDraw.Draw(image);f=ImageFont.truetype(font,23);title=ImageFont.truetype(font,30)
 draw.text((36,26),side.upper()+' — persisted Cursor native log',font=title,fill='white')
 lines=['Commit: '+d['commit'][:10],'Real dev server / Chromium / Linux / Composer 2.5','Fresh synthetic project; original reproduction prompt','',f"Native records: {d['nativeRecords']:,}    Native bytes: {d['nativeBytes']:,}",f"Transient records: {d['transientRecords']:,}    Bytes: {d['transientBytes']:,}",'','Update type                       Records      Bytes']
 for t in ['text-delta','thinking-delta','token-delta','shell-output-delta','partial-tool-call','tool-call-started','tool-call-completed','thinking-completed','step-completed','turn-ended','run.completed']:
  lines.append(f"{t:33} {d['counts'].get(t,0):7,} {d['bytesByType'].get(t,0):10,}")
 lines+=['','Turn completed; notes.md has 60 fruit entries; seq ends at 400.','Analysis of the actual persisted log; payload content omitted.']
 for i,line in enumerate(lines): draw.text((36,85+i*31),line,font=f,fill=('#ffb4a4' if 'Transient records' in line and side=='before' else '#c9d8e9'))
 image.save(root/(side+'-diagnostics.png'))
