Read Claude CLI transcript history from on-disk JSONL files.
This module mirrors the upstream Agent SDK session-history behavior:
it reads ~/.claude/projects/<sanitized-cwd>/<session-id>.jsonl,
reconstructs the canonical conversation chain, and returns history metadata
or visible user/assistant messages.
Summary
Functions
Reads visible conversation messages from a CLI transcript.
Lists CLI transcript sessions.
Sanitizes a project path to the directory format used by Claude CLI.
Produces the same base-36 hash used by the upstream session-storage logic.
Functions
@spec get_session_messages( String.t(), keyword() ) :: [ClaudeAgentSDK.Session.SessionMessage.t()]
Reads visible conversation messages from a CLI transcript.
Options:
:directory- project path to search in:limit- max number of messages to return:offset- number of messages to skip from the start:projects_dir- override the Claude projects directory (primarily for tests)
@spec list_sessions(keyword()) :: [ClaudeAgentSDK.Session.SessionInfo.t()]
Lists CLI transcript sessions.
Options:
:directory- project path to scan:limit- max number of sessions to return:include_worktrees- include git worktree transcript directories (default:true):projects_dir- override the Claude projects directory (primarily for tests)
Sanitizes a project path to the directory format used by Claude CLI.
Produces the same base-36 hash used by the upstream session-storage logic.