Skip to content

feat(gemini): register all 11 hook events from the current spec#50

Merged
scotthavird merged 1 commit into
mainfrom
claude/support-envelope-v1.2-Gzsge
May 16, 2026
Merged

feat(gemini): register all 11 hook events from the current spec#50
scotthavird merged 1 commit into
mainfrom
claude/support-envelope-v1.2-Gzsge

Conversation

@scotthavird
Copy link
Copy Markdown
Contributor

Summary

Brings Gemini CLI coverage up to spec. Before: we registered 5 of 11 documented events. Now: 11 of 11.

Canonical reference: packages/core/src/hooks/types.ts HookEventName enum and docs/hooks/reference.md.

Already registered (no changes): BeforeAgent, BeforeTool, AfterTool, SessionStart, SessionEnd. All still current; no renames or deprecations.

Newly added (6):

Event When it fires
AfterAgent Model produces a final turn response (Gemini's equivalent of Claude's Stop)
BeforeModel Before each LLM call
AfterModel Per response chunk during streaming — see volume note below
BeforeToolSelection Before the model decides which tools to call
PreCompress Before history summarization (Gemini's equivalent of PreCompact)
Notification When the CLI emits a system alert

Volume note on AfterModel

AfterModel fires per streamed response chunk, so it can be high-volume on long turns. Registered for completeness; if it floods the pipeline in practice we can either filter at the platform side or carve out a sampling matcher here. Called out in the commit message and as a code comment in buildGeminiHooks.

Idempotency

installGemini already inherited the idempotency cleanup added in #48: re-running promptconduit install gemini strips any of our stale entries while leaving user-owned hooks alone. Re-verified end-to-end.

Test plan

  • go build ./... && go vet ./... && go test ./... clean
  • Smoke: promptconduit install gemini against a fake $HOME writes 11 hook entries to ~/.gemini/settings.json
  • Smoke: planted a stale OldDeprecatedEvent entry pointing at our binary + a user-owned UserCustomHook, re-ran install gemini. Result: stale entry removed (11 → going from 13 with planted entries down to 12: 11 ours + 1 user), UserCustomHook preserved
  • Run against a real Gemini CLI install and confirm events arrive at the platform end-to-end

Up next (per session-running plan)

This is the first of three planned hook-coverage follow-ups:

  1. Gemini CLI ← this PR
  2. Claude Code WorktreeCreate (requires the generic hook handler in cmd/hook.go to detect that event and return a valid worktree path instead of {"continue": true})
  3. Codex CLI / GitHub Copilot CLI hooks (currently sync-only)

https://claude.ai/code/session_019CWBC2E8pQuShejfsKYrvp


Generated by Claude Code

Diffed buildGeminiHooks against Gemini CLI's hooks reference at
https://github.com/google-gemini/gemini-cli/blob/main/docs/hooks/reference.md
(authoritative source: packages/core/src/hooks/types.ts HookEventName).

Was registering 5 events:
  BeforeAgent, BeforeTool, AfterTool, SessionStart, SessionEnd

Now registers all 11:
  - Session lifecycle:     SessionStart, SessionEnd
  - Per-turn lifecycle:    BeforeAgent, AfterAgent
  - Model interaction:     BeforeModel, AfterModel, BeforeToolSelection
  - Tool execution:        BeforeTool, AfterTool (matcher = tool-name regex)
  - Context compaction:    PreCompress
  - System alerts:         Notification

All 5 we already registered are still valid and unchanged in the
current spec — no renames or deprecations. Pure additions.

NOTE: AfterModel fires per response chunk during streaming, so it
can be high-volume on long Gemini turns. Registered for completeness;
downstream filtering at the platform or via `promptconduit watch`
remains an option if volume becomes a problem in practice.

installGemini already ships the idempotency cleanup added in PR #48:
re-running `promptconduit install gemini` strips any stale event keys
we no longer register while preserving user-owned hooks. Verified
end-to-end against a fake $HOME: planted a stale entry + a user hook,
re-installed, stale entry removed, user hook untouched.

Coverage: 11 of 11 documented Gemini CLI hook events.

https://claude.ai/code/session_019CWBC2E8pQuShejfsKYrvp
@scotthavird scotthavird marked this pull request as ready for review May 16, 2026 12:29
@scotthavird scotthavird merged commit 0a561d7 into main May 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants