geminilegacy

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package geminilegacy reads Gemini CLI transcripts stored in checkpoints written before Gemini CLI support was removed.

Entire no longer captures Gemini sessions, but checkpoints tagged agent.AgentTypeGemini still exist in users' metadata branches. Their transcripts are a single JSON document ({"messages":[...]}) rather than JSONL, so explain, summaries, and chunk reassembly need this parser to read them. Nothing here writes a Gemini transcript.

Index

Constants

View Source
const (
	MessageTypeUser   = "user"
	MessageTypeGemini = "gemini"
)

Message type constants for Gemini transcripts.

Variables

This section is empty.

Functions

func ReassembleChunks

func ReassembleChunks(chunks [][]byte) ([]byte, error)

ReassembleChunks merges Gemini JSON chunks by combining their message arrays. Transcripts over the chunk size limit were stored as several {"messages":[...]} documents; concatenating them as JSONL would produce invalid JSON. Messages are carried as raw JSON, not decoded into Message, so fields this package does not model survive reassembly byte for byte.

func SliceFromMessage

func SliceFromMessage(data []byte, startMessageIndex int) ([]byte, error)

SliceFromMessage returns a Gemini transcript scoped to messages starting from startMessageIndex. This is the Gemini equivalent of transcript.SliceFromLine — for Gemini's single JSON blob, scoping is done by message index rather than line offset. Returns the original data if startMessageIndex <= 0. Returns nil, nil if startMessageIndex exceeds the number of messages.

Types

type Message

type Message struct {
	ID        string     `json:"id,omitempty"` // UUID for the message
	Type      string     `json:"type"`         // MessageTypeUser or MessageTypeGemini
	Content   string     `json:"content,omitempty"`
	ToolCalls []ToolCall `json:"toolCalls,omitempty"`
}

Message is a single message in the transcript.

func (*Message) UnmarshalJSON

func (m *Message) UnmarshalJSON(data []byte) error

UnmarshalJSON handles both string and array content formats in Gemini transcripts. User messages use: "content": [{"text": "..."}] (array of objects) Gemini messages use: "content": "response text" (string)

type ToolCall

type ToolCall struct {
	ID     string                 `json:"id"`
	Name   string                 `json:"name"`
	Args   map[string]interface{} `json:"args"`
	Status string                 `json:"status,omitempty"`
}

ToolCall is a tool call in a gemini message.

type Transcript

type Transcript struct {
	Messages []Message `json:"messages"`
}

Transcript is the top-level structure of a Gemini session file.

func ParseTranscript

func ParseTranscript(data []byte) (*Transcript, error)

ParseTranscript parses raw JSON content into a transcript structure.

Jump to

Keyboard shortcuts

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