Expand description
Session log parsing for AI coding agents.
Parses session logs from various AI coding agents:
- Claude Code (JSONL)
- Gemini CLI (JSON)
- OpenAI Codex CLI (JSONL)
- Normalize Agent (JSONL)
§Architecture
This crate separates parsing from analysis:
- Parsing:
LogFormat::parse()converts format-specific logs into a unifiedSessiontype - Analysis: Consumers compute their own metrics from
Sessiondata
Each log format implements the LogFormat trait for format detection and parsing.
§Example
ⓘ
use normalize_chat_sessions::{parse_session, Session};
let session = parse_session("~/.claude/projects/foo/session.jsonl")?;
for turn in &session.turns {
for msg in &turn.messages {
println!("{}: {} blocks", msg.role, msg.content.len());
}
}Structs§
- Claude
Code Format - Claude Code session log format (JSONL).
- Codex
Format - OpenAI Codex CLI session log format (JSONL).
- Format
Registry - Registry of available log formats.
- Gemini
CliFormat - Gemini CLI session log format (JSON with messages array).
- Message
- A message from a participant.
- Normalize
Agent Format - Normalize agent session log format (JSONL).
- Session
- A parsed session in unified format.
- Session
File - Session file with metadata.
- Session
Metadata - Session metadata extracted from the log.
- Token
Usage - Token usage for an API call.
- Turn
- A single turn in the conversation (typically one user message + assistant response).
Enums§
- Content
Block - A content block within a message.
- Parse
Error - Error type for session log parsing operations.
- Role
- Message sender role.
Traits§
- LogFormat
- Trait for session log format plugins.
Functions§
- detect_
format - Auto-detect format for a file using the global registry.
- get_
format - Get a format by name from the global registry.
- list_
formats - List all available format names from the global registry.
- list_
jsonl_ sessions - Default implementation: list .jsonl files in a directory.
- list_
subagent_ sessions - List subagent sessions from
<session-uuid>/subagents/directories. - parse_
session - Parse a session log with auto-format detection.
- parse_
session_ with_ format - Parse a session log with explicit format.
- project_
metadata_ roots - Returns all external metadata directories for the given project across all known formats.
- register
- Register a custom log format plugin.