Skip to main content

parse_session_file

Function parse_session_file 

Source
pub fn parse_session_file(
    path: &Path,
    is_agent: bool,
) -> Result<(Vec<ValidatedTurn>, DataQuality, SessionMetadata, Vec<HookUsage>)>
Expand description

Parse a session JSONL file into validated turns, quality metrics, session metadata, and aggregated hook usage.

Pipeline: JSON parse → type filter → validation → content extraction → deduplication. Also collects metadata from non-assistant/user entries (titles, tags, mode, PR links, etc.) and aggregates system/stop_hook_summary entries into per-command HookUsage records (Claude Code 2.1.104+).

The returned Vec<HookUsage> is keyed by hookInfos[].command. It is always empty for agent files (subagent JSONL files have no system entries in observed data); callers should still accept the value for symmetry.