geminicli

package
v0.74.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package geminicli provides an adapter for Gemini CLI that parses JSON session files with project-specific conversation tracking.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWatcher

func NewWatcher(chatsDir string) (<-chan adapter.Event, io.Closer, error)

NewWatcher creates a watcher for Gemini CLI session changes.

Types

type Adapter

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

Adapter implements the adapter.Adapter interface for Gemini CLI sessions.

func New

func New() *Adapter

New creates a new Gemini CLI adapter.

func (*Adapter) Capabilities

func (a *Adapter) Capabilities() adapter.CapabilitySet

Capabilities returns the supported features.

func (*Adapter) Detect

func (a *Adapter) Detect(projectRoot string) (bool, error)

Detect checks if Gemini CLI sessions exist for the given project.

func (*Adapter) ID

func (a *Adapter) ID() string

ID returns the adapter identifier.

func (*Adapter) Icon

func (a *Adapter) Icon() string

Icon returns the adapter icon for badge display.

func (*Adapter) Messages

func (a *Adapter) Messages(sessionID string) ([]adapter.Message, error)

Messages returns all messages for the given session.

func (*Adapter) Name

func (a *Adapter) Name() string

Name returns the human-readable adapter name.

func (*Adapter) SearchMessages

func (a *Adapter) SearchMessages(sessionID, query string, opts adapter.SearchOptions) ([]adapter.MessageMatch, error)

SearchMessages searches message content within a session. Implements adapter.MessageSearcher interface.

func (*Adapter) Sessions

func (a *Adapter) Sessions(projectRoot string) ([]adapter.Session, error)

Sessions returns all sessions for the given project, sorted by update time.

func (*Adapter) Usage

func (a *Adapter) Usage(sessionID string) (*adapter.UsageStats, error)

Usage returns aggregate usage stats for the given session.

func (*Adapter) Watch

func (a *Adapter) Watch(projectRoot string) (<-chan adapter.Event, io.Closer, error)

Watch returns a channel that emits events when session data changes.

type Message

type Message struct {
	ID        string     `json:"id"`
	Timestamp time.Time  `json:"timestamp"`
	Type      string     `json:"type"` // "user", "gemini", "info"
	Content   string     `json:"content"`
	Model     string     `json:"model,omitempty"`
	Tokens    *Tokens    `json:"tokens,omitempty"`
	ToolCalls []ToolCall `json:"toolCalls,omitempty"`
	Thoughts  []Thought  `json:"thoughts,omitempty"`
}

Message represents a message in a Gemini CLI session.

type Session

type Session struct {
	SessionID   string    `json:"sessionId"`
	ProjectHash string    `json:"projectHash"`
	StartTime   time.Time `json:"startTime"`
	LastUpdated time.Time `json:"lastUpdated"`
	Messages    []Message `json:"messages"`
}

Session represents a Gemini CLI session JSON file.

type SessionMetadata

type SessionMetadata struct {
	Path             string
	SessionID        string
	ProjectHash      string
	StartTime        time.Time
	LastUpdated      time.Time
	MsgCount         int
	TotalTokens      int
	EstCost          float64
	PrimaryModel     string
	FirstUserMessage string // Content of the first user message (for title)
}

SessionMetadata holds parsed metadata about a session file.

type Thought

type Thought struct {
	Subject     string `json:"subject"`
	Description string `json:"description"`
	Timestamp   string `json:"timestamp,omitempty"`
}

Thought represents a thinking step from Gemini.

type Tokens

type Tokens struct {
	Input    int `json:"input"`
	Output   int `json:"output"`
	Cached   int `json:"cached"`
	Thoughts int `json:"thoughts"`
	Tool     int `json:"tool"`
	Total    int `json:"total"`
}

Tokens holds token usage for a message.

type ToolCall

type ToolCall struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Args        any    `json:"args,omitempty"`
	Result      any    `json:"result,omitempty"`
	Status      string `json:"status"`
	Timestamp   string `json:"timestamp,omitempty"`
	DisplayName string `json:"displayName,omitempty"`
}

ToolCall represents a tool invocation.

Jump to

Keyboard shortcuts

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