parser

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFileModifyingTool

func IsFileModifyingTool(name string) bool

func IsTestCommand

func IsTestCommand(toolInput string) bool

Types

type ClaudeParser

type ClaudeParser struct {
	// contains filtered or unexported fields
}

func NewClaudeParser

func NewClaudeParser() *ClaudeParser

func (*ClaudeParser) Parse

func (p *ClaudeParser) Parse(line []byte) ([]*ParsedEvent, error)

type CodexParser

type CodexParser struct {
	// contains filtered or unexported fields
}

func NewCodexParser

func NewCodexParser() *CodexParser

func (*CodexParser) Parse

func (p *CodexParser) Parse(line []byte) ([]*ParsedEvent, error)

type ContentType

type ContentType int
const (
	ContentToolUse ContentType = iota
	ContentToolResult
	ContentText
	ContentThinking
	ContentUnknown
)

type GeminiParser

type GeminiParser struct {
	// contains filtered or unexported fields
}

GeminiParser parses Gemini CLI session logs. Gemini CLI writes sessions in two co-existing formats:

  • Legacy: session-*.json — a single monolithic JSON object holding the full conversation, rewritten in full on every turn. The watcher delivers the entire file content as one "line" on each rewrite (see internal/watcher.Tailer's whole-file mode for .json paths).
  • Current: session-*.jsonl — append-only JSONL, one record per line.

Parse auto-detects which of the two shapes a given chunk is: a JSONL record carries a non-empty "type" field, while the legacy conversation object carries a top-level "messages" array and no "type" field.

NOTE: The exact JSONL schema below reflects Gemini CLI's session log format as documented at the time this parser was written. Some fields (per-line timestamp, per-line model name) are not present in every known sample and are handled defensively with graceful fallbacks (current time, FallbackContextWindow) rather than assumed to always be populated. If a future Gemini CLI release changes the schema, update the structs below.

func NewGeminiParser

func NewGeminiParser() *GeminiParser

func (*GeminiParser) Parse

func (p *GeminiParser) Parse(line []byte) ([]*ParsedEvent, error)

type ParsedEvent

type ParsedEvent struct {
	SessionID    string
	RequestID    string
	UUID         string
	Timestamp    time.Time
	EntryType    string // "assistant", "user", "system", etc.
	Model        string
	ContentType  ContentType
	ToolName     string
	ToolInput    string
	ToolResult   string
	IsError      bool
	ErrorMsg     string
	Tokens       TokenUsage
	FilesChanged []string
}

type Parser

type Parser interface {
	Parse(line []byte) ([]*ParsedEvent, error)
}

type TokenUsage

type TokenUsage struct {
	InputTokens      int
	OutputTokens     int
	CacheReadTokens  int
	CacheWriteTokens int
}

func (TokenUsage) Total

func (t TokenUsage) Total() int

Jump to

Keyboard shortcuts

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