Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/entire/cli/hook_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/entireio/cli/cmd/entire/cli/agent/types"
"github.com/entireio/cli/cmd/entire/cli/logging"
"github.com/entireio/cli/cmd/entire/cli/paths"
"github.com/entireio/cli/cmd/entire/cli/settings"
"github.com/entireio/cli/cmd/entire/cli/strategy"
"github.com/entireio/cli/perf"

Expand Down Expand Up @@ -53,6 +54,9 @@ func newAgentHooksCmd(agentName types.AgentName, handler agent.HookSupport) *cob
Short: handler.Description() + " hook handlers",
Hidden: true,
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
if !settings.IsSetUpAndEnabled(cmd.Context()) {
return nil
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Fix in Cursor Fix in Web

Comment on lines 56 to +59
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
agentHookLogCleanup = initHookLogging(cmd.Context())
Comment on lines 56 to 60
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
return nil
},
Expand Down