"""Export only synthetic user messages and public assistant text/tool calls.
No reasoning, signatures, environment metadata, credentials, or local paths.
"""
import json
from pathlib import Path

ROOT = Path(__file__).parent
COMMITS = {'base': 'f313d0a6cb843551fb60e57a454a71e71a3a8c04', 'head': '7907760acad83e5aa7c52870453681ec65fa58ca'}
for side, sha in COMMITS.items():
    directory = Path.home() / '.claude/projects' / f'-tmp-{ROOT.name}-{side}-skill-demo'
    transcript = next(directory.glob('*.jsonl'))
    records = []
    for line in transcript.read_text().splitlines():
        event = json.loads(line)
        role = event.get('type')
        if role not in ('user', 'assistant'):
            continue
        content = event.get('message', {}).get('content')
        if isinstance(content, list):
            content = [block for block in content if block.get('type') in ('text', 'tool_use', 'tool_result')]
        if not content:
            continue
        value = json.dumps(content, ensure_ascii=False, indent=2) if not isinstance(content, str) else content
        value = value.replace(str(ROOT / side / 'skill-demo'), '<synthetic-project>')
        records.append(f'--- {role.upper()} ---\n{value}')
    text = f'Claude native runtime transcript: {side}\nCommit: {sha}\nUser/assistant public content only; synthetic project paths redacted.\n\n' + '\n\n'.join(records) + '\n'
    (ROOT / f'{side}-native-transcript.txt').write_text(text)
    print(side, 'native command records:', text.count('<command-name>/my-skill</command-name>'))
    print(side, 'history dollar preserved:', '$my-skill do something' in text)
