Skip to main content

Module gemini_cli

Module gemini_cli 

Source
Expand description

Gemini CLI hook adapter.

Gemini CLI supports 11 lifecycle hooks; DiffLore maps 4 to canonical HookEvent variants and ignores the remaining 7 as not actionable:

Gemini eventCanonical event
SessionStartSessionStart { cwd }
BeforeAgentSessionStart { cwd } *
AfterAgentStop
AfterToolPostToolUse { … }
SessionEndSessionEnd
BeforeToolno-op (pre-execution noise)
PreCompressno-op
Notificationno-op

* BeforeAgent is treated as a session-start so DiffLore’s per-session warmup also fires when users resume sessions; this costs nothing extra — ensure_ready is cached per process.

Example stdin (verified against Gemini CLI’s published hook schema):

{
  "session_id": "...",
  "cwd": "/path/to/repo",
  "hook_event_name": "AfterTool",
  "tool_name": "WriteFile",
  "tool_input":  { "path": "src/foo.py", "content": "..." },
  "tool_response": { "success": true, "output": "…" },
  "transcript_path": "/abs/path/to/transcript.jsonl"
}

ANSI escape stripping: Gemini CLI is known to leak raw ANSI color sequences through tool output into system messages. Our format_output path strips them out of systemMessage before shipping so the user doesn’t see \x1b[31m garbage in their UI.

Structs§

GeminiCliAdapter
Zero-sized marker — no adapter state.