Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

status: recognize the hook commands install writes

shukieshah117f81d174a4
diff --git a/cli/beacon/internal/endpoint/harness/harness.go b/cli/beacon/internal/endpoint/harness/harness.go
index 117086b6..6eb02a4b 100644
--- a/cli/beacon/internal/endpoint/harness/harness.go
+++ b/cli/beacon/internal/endpoint/harness/harness.go
@@ -287,7 +287,7 @@ func DiscoverCursor() Harness {
}
if fileExists(h.ConfigPath) {
data, _ := os.ReadFile(h.ConfigPath)
- if strings.Contains(string(data), "BEACON_ENDPOINT_MODE=1") {
+ if configured, _ := hooks.ConfigHasEndpointHook(data, "cursor"); configured {
h.TelemetryStatus = TelemetryEnabled
h.Message = "Cursor endpoint hooks are configured"
} else {
@@ -650,22 +650,20 @@ func hasBeaconDevinHooks(data []byte, platforms ...string) (bool, error) {
if raw, ok := root["hooks"]; ok {
rawHooks = raw
}
- var hooks map[string][]struct {
+ var events map[string][]struct {
Hooks []struct {
Command string `json:"command"`
} `json:"hooks"`
}
- if err := json.Unmarshal(rawHooks, &hooks); err != nil {
+ if err := json.Unmarshal(rawHooks, &events); err != nil {
return false, nil
}
- for _, groups := range hooks {
+ for _, groups := range events {
for _, group := range groups {
for _, hook := range group.Hooks {
- if strings.Contains(hook.Command, "BEACON_ENDPOINT_MODE=1") {
- for _, platform := range platforms {
- if commandHasPlatform(hook.Command, platform) {
- return true, nil
- }
+ for _, platform := range platforms {
+ if hooks.IsEndpointHookCommand(hook.Command, platform) {
+ return true, nil
}
}
}
@@ -696,9 +694,9 @@ func hasBeaconWindsurfHooks(data []byte, platform string) (bool, error) {
if err := json.Unmarshal(data, &root); err != nil {
return false, err
}
- for _, hooks := range root.Hooks {
- for _, hook := range hooks {
- if strings.Contains(hook.Command, "BEACON_ENDPOINT_MODE=1") && commandHasPlatform(hook.Command, platform) {
+ for _, refs := range root.Hooks {
+ for _, hook := range refs {
+ if hooks.IsEndpointHookCommand(hook.Command, platform) {
return true, nil
}
}
@@ -735,7 +733,7 @@ func hasBeaconHermesHooks(data []byte) (bool, error) {
}
for _, refs := range root.Hooks {
for _, ref := range refs {
- if strings.Contains(ref.Command, "BEACON_ENDPOINT_MODE=1") && commandHasPlatform(ref.Command, "hermes") {
+ if hooks.IsEndpointHookCommand(ref.Command, "hermes") {
return true, nil
}
}
@@ -743,19 +741,6 @@ func hasBeaconHermesHooks(data []byte) (bool, error) {
return false, nil
}
-func commandHasPlatform(command, platform string) bool {
- fields := strings.Fields(command)
- for i, field := range fields {
- if field == "--platform" && i+1 < len(fields) {
- return strings.Trim(fields[i+1], `"'`) == platform
- }
- if strings.HasPrefix(field, "--platform=") {
- return strings.Trim(strings.TrimPrefix(field, "--platform="), `"'`) == platform
- }
- }
- return false
-}
-
func antigravityStatus(path string) (TelemetryStatus, string) {
data, err := os.ReadFile(path)
if err != nil {
@@ -776,12 +761,7 @@ func hasBeaconAntigravityHooks(data []byte) (bool, error) {
if err := json.Unmarshal(data, &blocks); err != nil {
return false, err
}
- for _, raw := range blocks {
- if strings.Contains(string(raw), "BEACON_ENDPOINT_MODE=1") && strings.Contains(string(raw), "--platform antigravity") {
- return true, nil
- }
- }
- return false, nil
+ return hooks.ConfigHasEndpointHook(data, "antigravity")
}
func shellExportValue(text, key string) string {
diff --git a/cli/beacon/internal/endpoint/harness/installed_hooks_test.go b/cli/beacon/internal/endpoint/harness/installed_hooks_test.go
new file mode 100644
index 00000000..8f690288
--- /dev/null
+++ b/cli/beacon/internal/endpoint/harness/installed_hooks_test.go
@@ -0,0 +1,58 @@
+package harness
+
+import (
+ "path/filepath"
+ "testing"
+
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/testenv"
+)
+
+// Status and doctor must recognize exactly the hooks the installer writes. They once looked only
+// for the BEACON_ENDPOINT_MODE=1 prefix, which install stopped writing when the settings moved to
+// --log/--config flags, so every fresh install reported these runtimes' hooks as missing.
+func TestDiscoveryRecognizesTheHooksInstallWrites(t *testing.T) {
+ home := t.TempDir()
+ testenv.SetHome(t, home)
+ t.Setenv("PATH", t.TempDir())
+ t.Setenv("HERMES_HOME", filepath.Join(home, ".hermes"))
+ logPath := filepath.Join(home, ".beacon", "endpoint", "logs", "runtime.jsonl")
+
+ cases := []struct {
+ name string
+ install func() error
+ discover func() Harness
+ }{
+ {"cursor", func() error {
+ _, err := hooks.InstallCursor(hooks.CursorOptions{Level: hooks.LevelUser, LogPath: logPath, UserMode: true})
+ return err
+ }, DiscoverCursor},
+ {"antigravity", func() error {
+ _, err := hooks.InstallAntigravity(hooks.AntigravityOptions{Level: hooks.LevelUser, LogPath: logPath, UserMode: true})
+ return err
+ }, DiscoverAntigravity},
+ {"hermes", func() error {
+ _, err := hooks.InstallHermes(hooks.HermesOptions{Level: hooks.LevelUser, LogPath: logPath, UserMode: true})
+ return err
+ }, DiscoverHermes},
+ {"devin", func() error {
+ _, err := hooks.InstallDevin(hooks.DevinOptions{Level: hooks.LevelUser, LogPath: logPath, UserMode: true})
+ return err
+ }, DiscoverDevin},
+ {"devin desktop", func() error {
+ _, err := hooks.InstallDevinDesktop(hooks.DevinDesktopOptions{Level: hooks.LevelUser, LogPath: logPath, UserMode: true})
+ return err
+ }, DiscoverDevinDesktop},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ if err := tc.install(); err != nil {
+ t.Fatalf("install: %v", err)
+ }
+ got := tc.discover()
+ if got.TelemetryStatus != TelemetryEnabled {
+ t.Fatalf("after install, status = %s (%s), want enabled", got.TelemetryStatus, got.Message)
+ }
+ })
+ }
+}
diff --git a/cli/beacon/internal/endpoint/hooks/runtime.go b/cli/beacon/internal/endpoint/hooks/runtime.go
index 526a917b..e87f1028 100644
--- a/cli/beacon/internal/endpoint/hooks/runtime.go
+++ b/cli/beacon/internal/endpoint/hooks/runtime.go
@@ -1,6 +1,7 @@
package hooks
import (
+ "encoding/json"
"fmt"
"os"
"path/filepath"
@@ -9,6 +10,7 @@ import (
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/embedded"
endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config"
+ "gopkg.in/yaml.v3"
)
type RuntimeOptions struct {
@@ -193,6 +195,52 @@ func isEndpointHookCommand(command, platform string) bool {
return hasLegacyBinary && hasPlatform
}
+// IsEndpointHookCommand reports whether command is a hook an endpoint install wrote for platform
+// ("" for any platform). Status, doctor and inventory use it so they recognize exactly the hooks
+// install writes, repairs and removes, in both spellings described at
+// commandCarriesEndpointSettings.
+func IsEndpointHookCommand(command, platform string) bool {
+ return isEndpointHookCommand(command, platform)
+}
+
+// ConfigHasEndpointHook reports whether a runtime's JSON or YAML hooks config holds a command
+// IsEndpointHookCommand accepts for platform. Every string under a "command" key is checked,
+// wherever the runtime nests it. The error is the document's parse error.
+func ConfigHasEndpointHook(data []byte, platform string) (bool, error) {
+ var doc any
+ var err error
+ if json.Valid(data) {
+ err = json.Unmarshal(data, &doc)
+ } else {
+ err = yaml.Unmarshal(data, &doc)
+ }
+ if err != nil {
+ return false, err
+ }
+ return hasEndpointCommand(doc, platform), nil
+}
+
+func hasEndpointCommand(node any, platform string) bool {
+ switch typed := node.(type) {
+ case map[string]any:
+ for key, value := range typed {
+ if command, ok := value.(string); ok && key == "command" && isEndpointHookCommand(command, platform) {
+ return true
+ }
+ if hasEndpointCommand(value, platform) {
+ return true
+ }
+ }
+ case []any:
+ for _, value := range typed {
+ if hasEndpointCommand(value, platform) {
+ return true
+ }
+ }
+ }
+ return false
+}
+
// commandCarriesEndpointSettings reports whether a command was written by an endpoint install, as
// opposed to being some other invocation of the same binary.
//
diff --git a/cli/beacon/internal/endpoint/hooks/runtime_test.go b/cli/beacon/internal/endpoint/hooks/runtime_test.go
new file mode 100644
index 00000000..243daf7c
--- /dev/null
+++ b/cli/beacon/internal/endpoint/hooks/runtime_test.go
@@ -0,0 +1,37 @@
+package hooks
+
+import (
+ "encoding/json"
+ "testing"
+)
+
+func TestConfigHasEndpointHookFindsCommandsAtAnyDepth(t *testing.T) {
+ flags := `'/home/u/.beacon/endpoint/hooks/beacon-hooks' --platform cursor --log '/home/u/runtime.jsonl' pre-tool`
+ legacy := `BEACON_ENDPOINT_MODE=1 /home/u/.beacon/endpoint/hooks/beacon-hooks --platform cursor pre-tool`
+ other := `/usr/local/bin/some-linter --platform cursor`
+ for name, tc := range map[string]struct {
+ doc string
+ platform string
+ want bool
+ }{
+ "flags form, nested JSON": {`{"version":1,"hooks":{"beforeShellExecution":[{"command":` + jsonQuote(flags) + `}]}}`, "cursor", true},
+ "legacy prefix": {`{"hooks":{"stop":[{"command":` + jsonQuote(legacy) + `}]}}`, "cursor", true},
+ "another platform": {`{"hooks":{"stop":[{"command":` + jsonQuote(flags) + `}]}}`, "antigravity", false},
+ "any platform": {`{"hooks":{"stop":[{"command":` + jsonQuote(flags) + `}]}}`, "", true},
+ "someone else's hook": {`{"hooks":{"stop":[{"command":` + jsonQuote(other) + `}]}}`, "cursor", false},
+ "YAML": {"hooks:\n pre_tool_call:\n - command: " + jsonQuote(flags) + "\n", "cursor", true},
+ } {
+ got, err := ConfigHasEndpointHook([]byte(tc.doc), tc.platform)
+ if err != nil || got != tc.want {
+ t.Errorf("%s: got %v, err %v, want %v", name, got, err, tc.want)
+ }
+ }
+ if _, err := ConfigHasEndpointHook([]byte("{not json"), "cursor"); err == nil {
+ t.Error("an unparsable config must return its error")
+ }
+}
+
+func jsonQuote(s string) string {
+ data, _ := json.Marshal(s)
+ return string(data)
+}
diff --git a/cli/beacon/internal/endpoint/inventory/installed_hooks_test.go b/cli/beacon/internal/endpoint/inventory/installed_hooks_test.go
new file mode 100644
index 00000000..a6ef0285
--- /dev/null
+++ b/cli/beacon/internal/endpoint/inventory/installed_hooks_test.go
@@ -0,0 +1,38 @@
+package inventory
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/testenv"
+)
+
+// A hooks file the installer wrote is reported as Beacon-managed. Hooks written since the
+// settings moved to --log/--config flags carry no BEACON_ENDPOINT_MODE=1 prefix.
+func TestBeaconManagedRecognizesTheHooksInstallWrites(t *testing.T) {
+ home := t.TempDir()
+ testenv.SetHome(t, home)
+ logPath := filepath.Join(home, ".beacon", "endpoint", "logs", "runtime.jsonl")
+ cursor, err := hooks.InstallCursor(hooks.CursorOptions{Level: hooks.LevelUser, LogPath: logPath, UserMode: true})
+ if err != nil {
+ t.Fatal(err)
+ }
+ antigravity, err := hooks.InstallAntigravity(hooks.AntigravityOptions{Level: hooks.LevelUser, LogPath: logPath, UserMode: true})
+ if err != nil {
+ t.Fatal(err)
+ }
+ for runtime, path := range map[string]string{"cursor": cursor.HooksJSONPath, "antigravity_cli": antigravity.ConfigPath} {
+ data, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !beaconManaged(candidate{runtime: runtime}, data) {
+ t.Errorf("%s hooks the installer wrote at %s are not reported as Beacon-managed", runtime, path)
+ }
+ }
+ if beaconManaged(candidate{runtime: "cursor"}, []byte(`{"version":1,"hooks":{"stop":[{"command":"/usr/local/bin/notify --done"}]}}`)) {
+ t.Error("someone else's Cursor hook is reported as Beacon-managed")
+ }
+}
diff --git a/cli/beacon/internal/endpoint/inventory/inventory.go b/cli/beacon/internal/endpoint/inventory/inventory.go
index fe666862..d994b518 100644
--- a/cli/beacon/internal/endpoint/inventory/inventory.go
+++ b/cli/beacon/internal/endpoint/inventory/inventory.go
@@ -1039,6 +1039,10 @@ func beaconManaged(item candidate, data []byte) bool {
if strings.Contains(text, "BEACON_ENDPOINT_MODE=1") {
return true
}
+ // Hooks written since the settings moved to --log/--config flags carry no prefix.
+ if managed, _ := hooks.ConfigHasEndpointHook(data, ""); managed {
+ return true
+ }
case "opencode":
return strings.Contains(text, "beacon-managed-opencode-plugin:v1")
case "cline":
diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdx
index 4026bd8a..4cbb253d 100644
--- a/docs/changelog/cli.mdx
+++ b/docs/changelog/cli.mdx
@@ -17,6 +17,8 @@ Stay up to date with the latest changes to the Agent Beacon CLI.
## October 2026
+- **Status and doctor recognize the hooks install writes** · Since v1.2.0, install writes hook commands with `--log` and `--config` flags in place of the `BEACON_ENDPOINT_MODE=1` prefix, but `beacon endpoint status`, `beacon endpoint doctor` and discovery still looked for the prefix. Every fresh install therefore reported Cursor, Antigravity CLI, Devin CLI, Devin Desktop and Hermes Agent as "hooks exist but endpoint hooks were not found", with telemetry disabled, though the hooks were correct and running, and inventory marked their hooks files as not Beacon-managed. They now use the same check install, repair and uninstall use, which accepts both spellings.
+
### v1.3.44 · October 19, 2026
- **Setup ends at the dashboard** · Confirming Beacon Cloud in the `beacon endpoint install` wizard used to end on some forty lines of file paths, connect details, an MCP table and per-runtime steps, and nothing pointed to the hosted dashboard. It now ends on four lines: the account, device and privacy mode; the session backfill; the dashboard URL; and where Beacon Cloud MCP was added. Beacon then opens the dashboard in your browser, except with `--no-browser`, over SSH, or on Linux without a display. The sign-in wait screen now also asks you to open the URL in the browser where you are signed in to beacon.sh, and cancelling the wizard says that nothing was installed and how to start again. `beacon endpoint connect` and `beacon mcp connect` print the same output as before. See [Onboarding](/cli/endpoint-onboarding#when-setup-finishes).