import json,sys,re
p=r'C:\Users\epilectrik\.claude\projects\C--git-bt411\09bf24bb-f92d-423a-b815-1eb662736f58\subagents\workflows\wf_35445603-8db\journal.jsonl'
out=[]
for line in open(p,encoding='utf-8',errors='replace'):
    try: d=json.loads(line)
    except: continue
    if d.get('type')=='result':
        out.append(str(d.get('result') or d.get('value') or ''))
for i,r in enumerate(out):
    # guess widget by keyword frequency
    w={'PrepEngr':r.count('PrepEngr'),'SectorDisplay':r.count('SectorDisplay'),'MessageBoard':r.count('MessageBoard')}
    widget=max(w,key=w.get)
    kind='verify' if ('VERDICT' in r or 'adversarial' in r[:400].lower() or 'CONFIRMED' in r[:400]) else 'decode'
    fn=f'scratchpad/wf_{i}_{widget}_{kind}.md'
    open(fn,'w',encoding='utf-8').write(r)
    print(f'{i}: {widget:16} {kind:7} len={len(r):6} -> {fn}')
