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 ¶
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) Parse ¶
func (s *GeminiSource) Parse(ctx context.Context, h source.SessionHandle, c source.Cursor) (source.SourceUpdate, source.Cursor, error)
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.