gemini

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package gemini provides the Gemini CLI source for agentwatch.

A GeminiSource discovers sessions by scanning a directory of Gemini CLI session directories (typically ~/.gemini/tmp). Each session directory contains a checkpoint.json file that Gemini rewrites in full on every update — unlike Claude, which appends to JSONL files.

Because Gemini rewrites files rather than appending, the source uses file mtime as its cursor instead of a byte offset. The cursor also encodes previous message and tool-call totals so that deltas can be computed correctly across rewrites.

Use New with WithRoot to configure the session root directory. Process scanning for hash-to-working-dir mapping is source-private in v1.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) (source.Source, error)

New returns a new GeminiSource configured by opts.

func Register

func Register(r *source.Registry, opts ...Option) error

Register adds a GeminiSource constructor to r under the name "gemini".

Types

type GeminiSource

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

GeminiSource discovers and parses Gemini CLI session checkpoint files. The zero value is usable but discovers no sessions until configured with a non-empty root via WithRoot.

func (*GeminiSource) Discover

func (s *GeminiSource) Discover(ctx context.Context) ([]source.SessionHandle, error)

Discover scans the configured root for Gemini CLI session directories. Each subdirectory that contains a checkpoint.json is returned as a SessionHandle. The session ID is the subdirectory name (the Gemini hash). WorkingDir is populated via process inspection when a matching gemini process is found; otherwise it is left empty.

func (*GeminiSource) Name

func (s *GeminiSource) Name() string

Name returns "gemini".

func (*GeminiSource) Parse

Parse reads the session's checkpoint.json and returns a SourceUpdate.

Because Gemini rewrites the file on every update, the cursor encodes both the file mtime and the message/tool counts observed on the previous poll. If the mtime has not changed since the last cursor, no new data is returned. When the file is rewritten, Parse re-reads the entire file and returns only the delta relative to what the cursor recorded.

type Option

type Option func(*GeminiSource)

Option configures a GeminiSource.

func WithRoot

func WithRoot(path string) Option

WithRoot sets the root directory to scan for Gemini CLI session directories. Discover walks this directory one level deep, treating each subdirectory as a session keyed by its directory name (the Gemini session hash). If root is empty, Discover returns no sessions.

Jump to

Keyboard shortcuts

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