Skip to content

Add a checked-in Gemini CLI hook manifest (#456) - #531

Merged
fdaviddpt merged 3 commits into
mainfrom
fix/456
Sep 4, 2026
Merged

fdaviddpt merged 3 commits into
mainfrom
fix/456

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

What this does

Checks in .gemini/settings.json, the manifest gemini hooks migrate --from-claude produces when fed this repo's real hooks/hooks.json -- observed against a real, installed gemini-cli 0.57.0 (npm install -g @google/gemini-cli), not reconstructed from #456's prose paraphrase. Event mapping: SessionStart->SessionStart, SessionEnd->SessionEnd, UserPromptSubmit->BeforeAgent, PostToolUse->AfterTool; the remaining Gemini-documented events (BeforeTool, AfterAgent, Notification, PreCompress, BeforeModel, AfterModel, BeforeToolSelection) are empty arrays, matching the migration tool's own output shape.

One deliberate edit over the raw migration output: every ${CLAUDE_PLUGIN_ROOT} the migration carries verbatim is rewritten to the vendor-neutral ${PLUGIN_ROOT}, the same convention #407 already gave scripts/resolve-paths.sh and pipeline/host.py's PLUGIN_ROOT_VARS. This is naming hygiene, not a verified fix -- pipeline/host.py's own GEMINI Host declares no plugin_root_vars at all, because Gemini CLI is not known to set either name. Whether Gemini CLI expands ${PLUGIN_ROOT} inside a hook command at all is unverified and stated as such in both the README and the test docstring.

tests/test_gemini_manifest_456.py pins the manifest's shape (event mapping, unbound-events-as-empty-arrays, ${PLUGIN_ROOT}-only, every referenced script exists and is reused from hooks/hooks.json) -- a manifest lint only, the same limit tests/test_codex_manifest_410.py states for the Codex manifest: no gemini binary runs in CI, so this proves the file is well-formed and correctly shaped, never that Gemini CLI actually loads it or fires a hook.

The hidden judgment call, settled

Whether .gemini/settings.json is really where Gemini CLI reads project-scope hook config (versus a gemini-extension.json manifest) was flagged as genuinely open by #456 itself. Settled by reading the bundled docs shipped inside the installed @google/gemini-cli npm package (bundle/docs/hooks/index.md): project settings at .gemini/settings.json in the current directory outrank user settings, system settings, and hooks bundled by an installed extension, in that order. An installed extension CAN also bundle hooks (lowest precedence) -- unused here, since this ships as a plain project-scope manifest, not an extension.

Scope, deliberately narrower than #456

Out of scope, staying open for follow-up issues: installing and driving a live Gemini session, the transcript envelope question (pipeline/host.sniff_envelope()), the stdout-contract question (UserPromptSubmit/BeforeAgent), and extension packaging beyond the settings.json question above. This PR does not resolve the whole of #456 -- it is a partial step, tracked as part of #456.

Self-review

Two independent spawns against the initial commit (878be13): Explore found one real issue (README prose implying the ${PLUGIN_ROOT} rewrite was a verified fix rather than naming hygiene); oss:auditor found one real issue (four tests in the new file asserted only inside a loop body with no found_any sentinel, so they would pass vacuously if the manifest's hooks were emptied -- test_every_gemini_settings_script_reference_exists already used the right pattern, just not applied to the other four). Both fixed in a follow-up commit (2889041) rather than filed -- same file, one sentence to state, no design decision needed. Full reviewer transcripts and disposition reasoning are in the developer's note (see report note_path).

Below-bar note

No below-bar findings this run -- both self-review findings were fixed, not deferred.

Tests

tests/test_gemini_manifest_456.py: red before the manifest existed (AssertionError: missing .../.gemini/settings.json, 9 failed), green after (9 passed). Targeted suite after the review fixup: tests/test_gemini_manifest_456.py, tests/test_hooks_json.py, tests/test_codex_manifest_410.py, tests/test_readme_reference_move_505.py -- 35 passed, 40 skipped (pwsh/git-bash absent on this macOS box, pre-existing skip pattern, not caused by this diff). Full test_command (pytest) was not run locally, per this repo's own CLAUDE.md and the developer brief -- CI is the gate.

Part of #456.

.gemini/settings.json is the output `gemini hooks migrate --from-claude`
produces when fed this repo's real hooks/hooks.json (observed against a
live gemini-cli 0.57.0 install), with every ${CLAUDE_PLUGIN_ROOT} the raw
migration output carries verbatim rewritten to ${PLUGIN_ROOT} (#407).

tests/test_gemini_manifest_456.py pins the manifest's shape: the event
mapping (UserPromptSubmit->BeforeAgent, PostToolUse->AfterTool,
SessionStart/SessionEnd unchanged), unbound events as empty arrays, and
that every command spells ${PLUGIN_ROOT} and never ${CLAUDE_PLUGIN_ROOT}.
Manifest lint only, same limit as tests/test_codex_manifest_410.py: no
gemini binary runs in CI.

Scoped down from the fuller #456: installing and driving a live Gemini
session, the transcript envelope, and the stdout-contract question all
stay open for follow-up issues.

Co-Authored-By: Max <noreply>
oss:auditor: 4 loop-body-only assertions in
tests/test_gemini_manifest_456.py would pass vacuously if
.gemini/settings.json's hooks dict were emptied out -- add a found_any
sentinel to each, matching the pattern
test_every_gemini_settings_script_reference_exists already used.

Explore reviewer: README's "since Gemini CLI never sets the Claude-only
name" implied the ${PLUGIN_ROOT} rewrite fixes path resolution on a live
Gemini install. pipeline/host.py's own GEMINI Host declares no
plugin_root_vars at all -- Gemini CLI is not known to set either
CLAUDE_PLUGIN_ROOT or PLUGIN_ROOT. Reworded to state this is naming
hygiene consistent with #407's convention, not a verified fix, and added
the same caveat to the docstring of
test_gemini_settings_never_spells_claude_plugin_root.

Co-Authored-By: Max <noreply>
Bash tool cwd resets between calls; running tree_snapshot.py snapshot in
one call and its compare pair in a later call without a same-call cd read
the main clone instead of the worktree and reported a false "mutated"
verdict. Logged for the curator rather than decided here.

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt merged commit a170a6c into main Sep 4, 2026
13 checks passed
@fdaviddpt
fdaviddpt deleted the fix/456 branch September 4, 2026 13:59
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.

1 participant