feat(gemini): register all 11 hook events from the current spec#50
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
HookEventNameenum and docs/hooks/reference.md.Already registered (no changes):
BeforeAgent,BeforeTool,AfterTool,SessionStart,SessionEnd. All still current; no renames or deprecations.Newly added (6):
AfterAgentStop)BeforeModelAfterModelBeforeToolSelectionPreCompressPreCompact)NotificationVolume note on
AfterModelAfterModelfires 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 inbuildGeminiHooks.Idempotency
installGeminialready inherited the idempotency cleanup added in #48: re-runningpromptconduit install geministrips any of our stale entries while leaving user-owned hooks alone. Re-verified end-to-end.Test plan
go build ./... && go vet ./... && go test ./...cleanpromptconduit install geminiagainst a fake$HOMEwrites 11 hook entries to~/.gemini/settings.jsonOldDeprecatedEvententry pointing at our binary + a user-ownedUserCustomHook, re-raninstall gemini. Result: stale entry removed (11 → going from 13 with planted entries down to 12: 11 ours + 1 user),UserCustomHookpreservedUp next (per session-running plan)
This is the first of three planned hook-coverage follow-ups:
WorktreeCreate(requires the generic hook handler incmd/hook.goto detect that event and return a valid worktree path instead of{"continue": true})https://claude.ai/code/session_019CWBC2E8pQuShejfsKYrvp
Generated by Claude Code