python3 - <<'PY'
import json
from pathlib import Path
src = Path("/home/golem/.codex/sessions/2026/06/29/rollout-2026-06-29T18-33-18-019f143a-6170-7643-8675-6a36166ce8ba.jsonl")
dst = Path("/tmp/conversation.md")
count = 0
with src.open(encoding="utf-8") as f, dst.open("w", encoding="utf-8") as out:
out.write("# Codex conversation transcript\n\n")
for line in f:
try:
obj = json.loads(line)
except json.JSONDecodeError:
continue
# Chceme skutečné message položky, ne event_msg ani compacted history
if obj.get("type") != "response_item":
continue
p = obj.get("payload", {})
if p.get("type") != "message":
continue
role = p.get("role")
if role not in ("user", "assistant"):
continue
texts = []
for item in p.get("content", []):
if item.get("type") in ("input_text", "output_text"):
text = item.get("text", "")
if text:
texts.append(text)
if not texts:
continue
heading = "USER" if role == "user" else "CODEX"
out.write(f"## {heading}\n\n")
out.write("\n\n".join(texts))
out.write("\n\n---\n\n")
count += 1
print(f"Exported {count} messages")
print(f"Written to: {dst}")
PY