import json, sys
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
want = sys.argv[1] if len(sys.argv)>1 else 'aggregate'
p=r"C:\Users\epilectrik\.claude\projects\C--git-bt411\09bf24bb-f92d-423a-b815-1eb662736f58\subagents\workflows\wf_1f336584-654\journal.jsonl"
for line in open(p,encoding='utf-8'):
    try: o=json.loads(line)
    except: continue
    if o.get('type')!='result': continue
    r=o.get('result')
    if not isinstance(r,dict) or 'cluster' not in r: continue
    if want.lower() not in r.get('cluster','').lower(): continue
    print('CLUSTER:', r.get('cluster'))
    print('CONF:', r.get('confidence'))
    for it in (r.get('items') or []):
        print('\n'+'='*66)
        print('ITEM:', it.get('item'))
        if it.get('classLayout'): print('\n--- LAYOUT ---\n', it.get('classLayout'))
        if it.get('methodDescription'): print('\n--- METHODDESC/REG ---\n', it.get('methodDescription'))
        if it.get('attributeTable'): print('\n--- ATTR TABLE ---\n', it.get('attributeTable'))
        if it.get('factoryWiring'): print('\n--- FACTORY ---\n', it.get('factoryWiring'))
        for f in (it.get('functions') or []):
            print('\n--- FN:', f.get('name'), '@', f.get('address'), '---')
            print(f.get('cpp'))
        if it.get('checklist'):
            print('\n--- CHECKLIST ---')
            for x in it.get('checklist'): print(' -', x)
    print('\nOPEN:', r.get('openQuestions'))
