Fix: Disable agent hooks when Entire is not active#656
Conversation
Entire-Checkpoint: 3abce9c62df3
Entire-Checkpoint: 8037f00020b4
PR SummaryLow Risk Overview This reduces unnecessary file I/O/log setup on agent hook invocations while leaving the underlying hook execution path unchanged. Written by Cursor Bugbot for commit 089f952. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
| PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { | ||
| if !settings.IsSetUpAndEnabled(cmd.Context()) { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
Agent hooks still execute when Entire never set up
Medium Severity
The new IsSetUpAndEnabled guard in PersistentPreRunE only skips logging initialization but doesn't prevent the child command's RunE from running. Unlike the git hooks pattern which uses a gitHooksDisabled flag checked in each child command, agent hooks have no equivalent. When Entire was never set up, executeAgentHook's IsEnabled() returns (true, err) with non-nil err, so the condition err == nil && !enabled is false and the hook proceeds to execute (parsing events, dispatching lifecycle, etc.). The fix doesn't achieve its stated goal for the "never set up" case.
Additional Locations (1)
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent agent hook commands (Claude Code, Gemini CLI, etc.) from doing work—especially initializing hook logging—when Entire is not active (not set up or disabled via .entire/settings.json).
Changes:
- Added a
settings.IsSetUpAndEnabled(ctx)guard to the agent hooks parent command’sPersistentPreRunEto skip hook logging initialization when Entire is inactive.
| PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { | ||
| if !settings.IsSetUpAndEnabled(cmd.Context()) { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
With the new early-return, agentHookLogCleanup is no longer overwritten when Entire isn’t set up/enabled. Because it’s a package-level var and PersistentPostRunE will still run, this can call a stale cleanup function from a previous command execution (notably in tests that execute multiple commands in-process). Consider explicitly resetting agentHookLogCleanup (e.g., set to nil or a no-op) before returning early, and/or nil it out after calling it in PersistentPostRunE.
| PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { | ||
| if !settings.IsSetUpAndEnabled(cmd.Context()) { | ||
| return nil | ||
| } | ||
| agentHookLogCleanup = initHookLogging(cmd.Context()) |
There was a problem hiding this comment.
Returning nil from PersistentPreRunE only skips logging init; the hook subcommand RunE will still execute. In repos where .entire/settings.json is missing, IsEnabled() defaults to true (via settings.Load), so executeAgentHook will still run lifecycle logic and can print the “Powered by Entire” banner / touch state. If the goal is to disable agent hooks when Entire isn’t active, add an early settings.IsSetUpAndEnabled(ctx) return in executeAgentHook (covers both built-in subcommands and the external-agent RunE fallback).


Fix: Disable agent hooks when Entire is not active
Problem
When Entire was disabled via
.entire/settings.json("enabled": false) or never set up in a repository, agent hooks (Claude Code, Gemini CLI, etc.) still initialized logging on every invocation. Git hooks already had an early-exit guard viasettings.IsSetUpAndEnabled()+ agitHooksDisabledflag, but agent hooks were missing an equivalent check in theirPersistentPreRunE.Additionally,
IsEnabled()(used byexecuteAgentHook) returnstrueby default when no settings file exists — meaning agent hooks could proceed past the enabled check in repos where Entire was never set up.Changes
cmd/entire/cli/hook_registry.goAdded a
settings.IsSetUpAndEnabled(ctx)guard in thePersistentPreRunEofnewAgentHooksCmd. When Entire is not set up or is disabled, the function returnsnilearly — skippinginitHookLogging()and avoiding unnecessary file I/O and log initialization. The child command'sRunE(executeAgentHook) still runs but bails out via its ownIsEnabled()check.