chasm-cli 1.5.4

Universal chat session manager - harvest, merge, and analyze AI chat history from VS Code, Cursor, and other editors
Documentation
"""Check what's inside the chatEditingSessions directories."""
import os, json

WS_BASE = r"C:\Users\adamm\AppData\Roaming\Code\User\workspaceStorage"

# Check a working session's chatEditingSessions
working_hash = "82cdabb21413f2ff42168423e82c8bdf"
broken_hash = "5ec71800c69c79b96b06a37e38537907"

# Working: 44f0cf62 (has a chatSessions .jsonl and a chatEditingSessions dir)
# Broken: 6be29cba (same)
# Injected test: e1f50715 
# Injected copy: 18bc4b1b

for label, ws_hash, session_id in [
    ("WORKING 44f0cf62", working_hash, "44f0cf62-331e-43c9-b32c-25d91ebab0b8"),
    ("WORKING bc6d5655", working_hash, "bc6d5655-0778-4d67-8d68-660821103ca8"),
    ("BROKEN 6be29cba", broken_hash, "6be29cba-331e-4aa4-bc58-659cc20f4800"),
    ("BROKEN 1aab540b", broken_hash, "1aab540b-8230-44c5-b6c1-3248fa997cac"),
    ("INJECTED TEST e1f50715", broken_hash, "e1f50715-8971-412f-943d-70bf0d7b5718"),
    ("INJECTED COPY 18bc4b1b", broken_hash, "18bc4b1b-b98c-42e6-9317-3bfecfccc4c3"),
]:
    ces_dir = os.path.join(WS_BASE, ws_hash, "chatEditingSessions", session_id)
    print(f"\n{'='*70}")
    print(f"{label}")
    print(f"{'='*70}")
    
    if not os.path.exists(ces_dir):
        print(f"  chatEditingSessions dir: DOES NOT EXIST")
    else:
        print(f"  chatEditingSessions dir exists:")
        for f in sorted(os.listdir(ces_dir)):
            fpath = os.path.join(ces_dir, f)
            size = os.path.getsize(fpath)
            print(f"    {f} ({size:,} bytes)")
            
            # Read contents of small files
            if size < 5000:
                try:
                    with open(fpath, 'r', encoding='utf-8') as fh:
                        content = fh.read()
                    # Try to parse as JSON
                    try:
                        parsed = json.loads(content)
                        print(f"      JSON: keys={sorted(parsed.keys()) if isinstance(parsed, dict) else type(parsed).__name__}")
                        if isinstance(parsed, dict):
                            for k, v in sorted(parsed.items()):
                                if isinstance(v, (str, int, float, bool, type(None))):
                                    vstr = json.dumps(v)
                                    if len(vstr) > 200:
                                        vstr = vstr[:200] + "..."
                                    print(f"        {k}: {vstr}")
                                elif isinstance(v, list):
                                    print(f"        {k}: list[{len(v)}]")
                                elif isinstance(v, dict):
                                    print(f"        {k}: dict({len(v)} keys)")
                    except:
                        # Not JSON, show raw content
                        print(f"      Raw: {content[:200]}")
                except:
                    print(f"      (could not read)")
            elif size > 0:
                try:
                    with open(fpath, 'r', encoding='utf-8') as fh:
                        first_line = fh.readline()[:200]
                    print(f"      First line: {first_line}")
                except:
                    pass