logs

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package logs provides session log parsing for AI agents (Codex, Claude).

Index

Constants

View Source
const TruncateLimit = 200

TruncateLimit is the default character limit for truncation. When NoTrunc is true, this limit is not applied.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClaudeParser

type ClaudeParser struct{}

ClaudeParser parses Claude Code session JSONL files stored under ~/.claude/projects.

func (*ClaudeParser) FindSessionFile

func (p *ClaudeParser) FindSessionFile(sessionID string) (string, error)

FindSessionFile finds the session file for a given session ID. Searches ~/.claude/projects/ recursively.

func (*ClaudeParser) ParseFile

func (p *ClaudeParser) ParseFile(path string, cb func(LogEntry)) (*SessionInfo, error)

ParseFile parses a Claude session file and emits entries via callback.

type CodexParser

type CodexParser struct{}

CodexParser parses Codex session JSONL files.

func (*CodexParser) FindSessionFile

func (p *CodexParser) FindSessionFile(sessionID string) (string, error)

FindSessionFile finds the session file for a given session ID. Searches ~/.codex/sessions/ recursively.

func (*CodexParser) ParseFile

func (p *CodexParser) ParseFile(path string, cb func(LogEntry)) (*SessionInfo, error)

ParseFile parses a Codex session file and emits entries via callback.

type EntryKind

type EntryKind string

EntryKind categorizes log entries for display.

const (
	KindUserMessage  EntryKind = "user"
	KindAgentMessage EntryKind = "agent"
	KindReasoning    EntryKind = "reasoning"
	KindToolCall     EntryKind = "tool_call"
	KindToolOutput   EntryKind = "tool_output"
	KindError        EntryKind = "error"
	KindSessionStart EntryKind = "session_start"
	KindTurnContext  EntryKind = "turn_context"
)

type Formatter

type Formatter struct {
	Pretty     bool      // Use colors and styling
	Timestamps bool      // Show timestamps
	NoTrunc    bool      // Don't truncate output
	StartTime  time.Time // Reference time for relative timestamps
}

Formatter formats log entries for display.

func (*Formatter) Format

func (f *Formatter) Format(e LogEntry) string

Format formats a single log entry.

func (*Formatter) FormatSessionHeader

func (f *Formatter) FormatSessionHeader(info *SessionInfo) string

FormatSessionHeader formats session info as a header.

type Locator

type Locator interface {
	FindSessionFile(sessionID string) (string, error)
}

Locator can find the session file for a given session ID.

type LogEntry

type LogEntry struct {
	Time    time.Time
	Kind    EntryKind
	Summary string // Short, truncated summary for display

	// Tool-specific fields
	ToolName   string
	ToolCallID string
	ExitCode   *int // For command outputs
}

LogEntry is a normalized log entry for display.

type Parser

type Parser interface {
	// ParseFile parses a session file and emits entries via the callback.
	// Streams efficiently without loading everything into memory.
	// Returns SessionInfo if found.
	ParseFile(path string, cb func(LogEntry)) (*SessionInfo, error)
}

Parser can parse session logs from a specific harness.

type SessionInfo

type SessionInfo struct {
	ID         string
	StartTime  time.Time
	Model      string
	CWD        string
	CLIVersion string
}

SessionInfo holds metadata about a session.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL