fix(gemini): strip non-array values from hooks to fix Gemini CLI 0.33+#714
fix(gemini): strip non-array values from hooks to fix Gemini CLI 0.33+#714peyton-alt wants to merge 3 commits intomainfrom
Conversation
PR SummaryLow Risk Overview Adjusts Written by Cursor Bugbot for commit 7935f4a. Configure here. |
There was a problem hiding this comment.
Pull request overview
Fixes Gemini CLI hook installation/uninstallation by sanitizing .gemini/settings.json hook entries so they conform to Gemini CLI 0.33+ validation requirements (hooks values must be arrays), while preserving user hooks.
Changes:
- Strip non-array fields from the
hooksobject (e.g., legacyhooks.enabled: true) during install/uninstall. - Adjust idempotency behavior to ensure sanitized settings are written.
- Add unit tests covering legacy
hooks.enabledcleanup scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
cmd/entire/cli/agent/geminicli/hooks.go |
Adds hook-map sanitization to remove non-array values and tweaks idempotency to still write cleaned settings. |
cmd/entire/cli/agent/geminicli/hooks_test.go |
Adds tests ensuring legacy hooks.enabled is removed and user hooks are preserved. |
Comments suppressed due to low confidence (1)
cmd/entire/cli/agent/geminicli/hooks.go:141
- In the legacy-cleanup case (
cleanupDone == true) this bypasses the idempotency return andInstallHookswill proceed to remove/re-add all Entire hooks and returncount=12, even when hooks were already installed. Callers (e.g., setup flow) treat0as "already installed", so this can cause misleading output and unnecessary rewrites/reordering. Consider: if the expected hook command is already present, just write the cleaned settings (and any hooksConfig changes) and return 0 instead of reinstalling everything.
if !force && !cleanupDone {
existingCmd := getFirstEntireHookCommand(sessionStart)
expectedCmd := cmdPrefix + "session-start"
if existingCmd == expectedCmd {
return 0, nil // Already installed with same mode
|
@BugBot review |
…+ validation Entire-Checkpoint: 332b287f14ea
…hooks When InstallHooks strips legacy non-array fields (cleanupDone) but hooks are already correctly installed, write the cleaned file but return 0 so callers correctly see "no hooks added" rather than 12. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Entire-Checkpoint: e01d2929e2d9
Gemini CLI reads systemMessage JSON from hook stdout on session-start. Implementing HookResponseWriter on GeminiCLIAgent enables the "Powered by Entire" banner to appear at the start of each Gemini session. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Entire-Checkpoint: 172bf278620e
077ae15 to
04c3b25
Compare
validation
Entire-Checkpoint: 332b287f14ea