Files
gabrielvidalandClaude Opus 5.5 fd871bd128 refactor(parse): a neutral event layer between transcript records and the fold
Readers (parse/readers/) turn each record into the v1 events of
parse/events.py; ParserState.feed hands the record to its reader and
folds the events (apply). Claude Code's record shapes and text
conventions (claude.py, claudetext.py), the hub's envelopes
(hubtext.py) and the pi / opencode / agy converters' quirks (legacy.py)
left the fold; the ResourceMiner, Code Mode, task notifications, Bash
hooks and commits are fed from events. No _raw pass-through.

Verified: parse-ab --base e85a2ff2 500 files x 2 modes 0 differing;
--chunked 0 mismatches; pricing-dump identical; test_parse_fixtures OK;
parser test modules in the service image same as e85a2ff2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 00:56:13 +01:00

29 lines
1.2 KiB
Python

"""Readers: a harness's native records → the neutral events of
``events.py``. One resumable object per transcript, fed one complete record
at a time (``feed(record) -> list[event]``, one batch per record).
- ``claude.ClaudeReader`` — Claude Code's JSONL, read in place;
- ``legacy.LegacyReader`` — the same plus the quirks of the pi / opencode /
agy transcripts the hub's converters wrote in Claude Code's format;
- ``v1.V1Reader`` — lines that already are v1 events;
- ``hubtext`` / ``claudetext`` — the text conventions they unwrap.
``reader_for`` picks one from the first record, in one place."""
from ..events import is_v1_header
from .claude import ClaudeReader
from .legacy import LegacyReader
from .v1 import V1Reader
__all__ = ["ClaudeReader", "LegacyReader", "V1Reader", "reader_for"]
def reader_for(first: dict, full: bool = True):
"""The reader for a transcript whose first record is ``first``: a v1
header (a ``t`` key with a ``v``) ⇒ ``V1Reader``; anything else is
Claude Code's format, possibly written by one of the hub's converters
⇒ ``LegacyReader``."""
if is_v1_header(first):
return V1Reader(full)
return LegacyReader(full)