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 event | Canonical event |
|---|---|
SessionStart | SessionStart { cwd } |
BeforeAgent | SessionStart { cwd } * |
AfterAgent | Stop |
AfterTool | PostToolUse { … } |
SessionEnd | SessionEnd |
BeforeTool | no-op (pre-execution noise) |
PreCompress | no-op |
| Notification | no-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§
- Gemini
CliAdapter - Zero-sized marker — no adapter state.