Skip to content

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

use cascade hooks

Justin D'Souza4d52fa903c73
diff --git a/README.md b/README.md
index a4a6e816..5fa82309 100644
--- a/README.md
+++ b/README.md
@@ -85,7 +85,7 @@ Claude Cowork, OpenClaw).
| [Codex CLI](https://docs.asymptotelabs.ai/cli/supported-runtimes-codex-cli) | Local OpenTelemetry configuration |
| [Cursor](https://docs.asymptotelabs.ai/cli/supported-runtimes-cursor) | Beacon hook adapter |
| [Devin CLI](https://docs.asymptotelabs.ai/cli/supported-runtimes-devin) | Beacon hook adapter |
-| Devin Desktop | Beacon hook adapter |
+| Devin Desktop | Beacon hook adapter via Cascade/Windsurf hooks |
| [Factory Droid](https://docs.asymptotelabs.ai/cli/supported-runtimes-factory-droid) | Local OpenTelemetry configuration and optional hook adapter |
| [Gemini CLI](https://docs.asymptotelabs.ai/cli/supported-runtimes-gemini-cli) | Opt-in local OpenTelemetry configuration |
| [GitHub Copilot CLI](https://docs.asymptotelabs.ai/cli/supported-runtimes-github-copilot-cli) | MDM-managed OpenTelemetry (OTLP HTTP) |
diff --git a/cli/beacon-hooks/cmd/cascade.go b/cli/beacon-hooks/cmd/cascade.go
new file mode 100644
index 00000000..a886390b
--- /dev/null
+++ b/cli/beacon-hooks/cmd/cascade.go
@@ -0,0 +1,139 @@
+package cmd
+
+import (
+ "strings"
+
+ "github.com/asymptote-labs/agent-beacon/cli/beacon-hooks/internal/config"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon-hooks/internal/diff"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon-hooks/internal/logging"
+)
+
+func cascadeActionName(input map[string]interface{}) string {
+ return getFirstStr(input, "agent_action_name", "hook_event_name", "hookEventName")
+}
+
+func cascadeExecutionID(input map[string]interface{}) string {
+ return getFirstStr(input, "execution_id", "executionId")
+}
+
+func cascadeToolInfo(input map[string]interface{}) map[string]interface{} {
+ if info, ok := input["tool_info"].(map[string]interface{}); ok {
+ return info
+ }
+ if info, ok := input["toolInfo"].(map[string]interface{}); ok {
+ return info
+ }
+ return nil
+}
+
+func cascadePrompt(input map[string]interface{}) string {
+ if info := cascadeToolInfo(input); info != nil {
+ if prompt := firstToolString(info, "user_prompt", "userPrompt", "prompt", "text"); prompt != "" {
+ return prompt
+ }
+ }
+ return getFirstStr(input, "user_prompt", "userPrompt", "prompt", "text")
+}
+
+func cascadeToolName(input map[string]interface{}) string {
+ if info := cascadeToolInfo(input); info != nil {
+ if name := firstToolString(info, "tool_name", "toolName", "name", "command_name"); name != "" {
+ return name
+ }
+ }
+ switch cascadeActionName(input) {
+ case "post_run_command", "pre_run_command":
+ return "run_command"
+ case "post_mcp_tool_use", "pre_mcp_tool_use":
+ return "mcp_tool"
+ case "post_read_code", "pre_read_code":
+ return "read_code"
+ case "post_write_code", "pre_write_code":
+ return "write_code"
+ case "pre_user_prompt":
+ return "user_prompt"
+ default:
+ return cascadeActionName(input)
+ }
+}
+
+func cascadeMetadataFields(sessionID string, input map[string]interface{}) map[string]interface{} {
+ fields := sessionFields(sessionID, input)
+ if executionID := cascadeExecutionID(input); executionID != "" {
+ fields["session"] = mergeNested(fields["session"], map[string]interface{}{"execution_id": executionID})
+ }
+ fields["raw"] = mergeNested(fields["raw"], map[string]interface{}{"cascade": input})
+ return fields
+}
+
+func cascadeToolEventFields(input map[string]interface{}) map[string]interface{} {
+ sessionID := resolveSessionID(input, platformFlag)
+ fields := cascadeMetadataFields(sessionID, input)
+ toolName := cascadeToolName(input)
+ toolInfo := cascadeToolInfo(input)
+ for key, value := range toolFields(toolName, toolInfo) {
+ fields[key] = value
+ }
+ if action := cascadeActionName(input); action != "" {
+ fields["tool"] = mergeNested(fields["tool"], map[string]interface{}{"action": action})
+ }
+ if executionID := cascadeExecutionID(input); executionID != "" {
+ fields["tool"] = mergeNested(fields["tool"], map[string]interface{}{"execution_id": executionID})
+ }
+ return fields
+}
+
+func emitCascadePostToolObserved(logger *logging.Logger, input map[string]interface{}) {
+ actionName := cascadeActionName(input)
+ action, category, message := cascadeEventClassification(actionName, cascadeToolName(input))
+ emitHookEvent(logger, action, category, "info", message, input, cascadeToolEventFields(input))
+}
+
+func cascadeEventClassification(actionName, toolName string) (action, category, message string) {
+ switch actionName {
+ case "post_run_command":
+ return "command.executed", "command", "Shell command executed"
+ case "post_mcp_tool_use":
+ return "mcp.tool_invoked", "mcp", "MCP tool invocation observed"
+ case "post_read_code":
+ return "file.read", "file", "File read observed"
+ case "post_write_code":
+ return "file.modified", "file", "File edit observed"
+ }
+ if strings.Contains(strings.ToLower(toolName), "mcp") {
+ return "mcp.tool_invoked", "mcp", "MCP tool invocation observed"
+ }
+ return actionForTool(actionName, toolName), "tool", "Tool execution observed"
+}
+
+func parseCascadeWriteInput(input map[string]interface{}, logger *logging.Logger) *evaluationParams {
+ if cascadeActionName(input) != "post_write_code" {
+ return nil
+ }
+ toolInfo := cascadeToolInfo(input)
+ if toolInfo == nil {
+ return nil
+ }
+ filePath := firstToolString(toolInfo, "file_path", "filePath", "path")
+ filePath = diff.NormalizePath(filePath)
+ if filePath == "" || !config.IsScannableFile(filePath) {
+ return nil
+ }
+ edits, _ := toolInfo["edits"].([]interface{})
+ if len(edits) == 0 {
+ logger.Debug("No Cascade edits in input, skipping", "file_path", filePath)
+ return nil
+ }
+ diffStr := diff.FromCursorEdits(filePath, edits)
+ if diffStr == "" {
+ logger.Debug("Could not construct diff from Cascade edits, skipping", "file_path", filePath)
+ return nil
+ }
+ return &evaluationParams{
+ sessionID: resolveSessionID(input, platformFlag),
+ toolName: cascadeToolName(input),
+ filePath: filePath,
+ diffStr: diffStr,
+ extraFields: cascadeMetadataFields(resolveSessionID(input, platformFlag), input),
+ }
+}
diff --git a/cli/beacon-hooks/cmd/endpoint_events.go b/cli/beacon-hooks/cmd/endpoint_events.go
index 7229107e..ada10307 100644
--- a/cli/beacon-hooks/cmd/endpoint_events.go
+++ b/cli/beacon-hooks/cmd/endpoint_events.go
@@ -21,6 +21,9 @@ func emitHookEvent(logger *logging.Logger, action, category, severity, message s
if platformFlag == "vscode" {
fields["raw"] = mergeNested(fields["raw"], map[string]interface{}{"vscode": input})
}
+ if isCascadePlatform(platformFlag) {
+ fields["raw"] = mergeNested(fields["raw"], map[string]interface{}{"cascade": input})
+ }
if model := getFirstStr(input, "model"); model != "" {
fields["model"] = model
}
diff --git a/cli/beacon-hooks/cmd/helpers.go b/cli/beacon-hooks/cmd/helpers.go
index cd601cfc..88e52f5e 100644
--- a/cli/beacon-hooks/cmd/helpers.go
+++ b/cli/beacon-hooks/cmd/helpers.go
@@ -29,7 +29,11 @@ func outputJSONAndExit(data map[string]interface{}) {
var emptyResponse = map[string]interface{}{}
func isDevinLikePlatform(platform string) bool {
- return platform == "devin" || platform == "devin-cli" || platform == "devin-desktop"
+ return platform == "devin" || platform == "devin-cli"
+}
+
+func isCascadePlatform(platform string) bool {
+ return platform == "devin-desktop"
}
// getFirstStr returns the first non-empty string value from input for the given keys.
@@ -59,8 +63,10 @@ func resolveSessionID(input map[string]interface{}, platform string) string {
return getFirstStr(input, "conversation_id")
case "vscode":
return getFirstStr(input, "sessionId", "session_id", "conversation_id", "gen_ai.conversation.id")
- case "devin", "devin-cli", "devin-desktop":
+ case "devin", "devin-cli":
return getFirstStr(input, "session_id", "sessionId", "conversation_id")
+ case "devin-desktop":
+ return getFirstStr(input, "trajectory_id", "session_id", "sessionId", "conversation_id")
case "grok":
return getFirstStr(input, "sessionId", "session_id", "sessionID")
case "opencode":
@@ -94,10 +100,14 @@ func resolveSessionIDWithTranscript(input map[string]interface{}, platform strin
sessionID = getFirstStr(input, "sessionId", "session_id", "conversation_id", "gen_ai.conversation.id")
transcriptPath = getFirstStr(input, "transcript_path", "transcriptPath")
return
- case "devin", "devin-cli", "devin-desktop":
+ case "devin", "devin-cli":
sessionID = getFirstStr(input, "session_id", "sessionId", "conversation_id")
transcriptPath = getFirstStr(input, "transcript_path", "transcriptPath")
return
+ case "devin-desktop":
+ sessionID = getFirstStr(input, "trajectory_id", "session_id", "sessionId", "conversation_id")
+ transcriptPath = getFirstStr(input, "transcript_path", "transcriptPath")
+ return
case "grok":
sessionID = getFirstStr(input, "sessionId", "session_id", "sessionID")
return
@@ -179,6 +189,17 @@ func resolveCwd(input map[string]interface{}, platform string) string {
}
return os.Getenv("DEVIN_PROJECT_DIR")
}
+ if isCascadePlatform(platform) {
+ if cwd := getFirstStr(input, "cwd", "workspace_path", "project_path"); cwd != "" {
+ return cwd
+ }
+ if info := cascadeToolInfo(input); info != nil {
+ if cwd := firstToolString(info, "cwd", "workspace_path", "project_path", "directory", "working_directory"); cwd != "" {
+ return cwd
+ }
+ }
+ return os.Getenv("DEVIN_PROJECT_DIR")
+ }
if platform == "grok" {
if cwd := getFirstStr(input, "workspaceRoot", "workspace_root", "cwd"); cwd != "" {
return cwd
diff --git a/cli/beacon-hooks/cmd/post_tool.go b/cli/beacon-hooks/cmd/post_tool.go
index b11fd6d0..a9dd5d49 100644
--- a/cli/beacon-hooks/cmd/post_tool.go
+++ b/cli/beacon-hooks/cmd/post_tool.go
@@ -25,10 +25,11 @@ func init() {
// evaluationParams holds the platform-independent fields needed for local hook handling.
type evaluationParams struct {
- sessionID string
- toolName string
- filePath string
- diffStr string
+ sessionID string
+ toolName string
+ filePath string
+ diffStr string
+ extraFields map[string]interface{}
}
func runPostTool(cmd *cobra.Command, args []string) {
@@ -49,7 +50,14 @@ func runPostTool(cmd *cobra.Command, args []string) {
var params *evaluationParams
- if platformFlag == "cursor" {
+ if isCascadePlatform(platformFlag) {
+ params = parseCascadeWriteInput(input, logger)
+ if params == nil {
+ emitCascadePostToolObserved(logger, input)
+ outputJSON(emptyResponse)
+ return
+ }
+ } else if platformFlag == "cursor" {
// Cursor fires two hook types through post-tool:
// - afterFileEdit: has "edits" array and top-level "file_path" (no output supported)
// - postToolUse: has "tool_name" and "tool_input" (supports additional_context/followup via stop)
@@ -187,12 +195,15 @@ func parseClaudeCopilotInput(input map[string]interface{}, logger *logging.Logge
func recordLocalEdit(params *evaluationParams, logger *logging.Logger) {
logger.Info("File edit observed", "file_path", params.filePath, "tool_name", params.toolName)
fields := map[string]interface{}{}
+ for key, value := range params.extraFields {
+ fields[key] = value
+ }
for key, value := range diffFields(params.filePath, params.diffStr) {
fields[key] = value
}
- fields["tool"] = map[string]interface{}{"name": params.toolName, "path": params.filePath}
+ fields["tool"] = mergeNested(fields["tool"], map[string]interface{}{"name": params.toolName, "path": params.filePath})
if params.sessionID != "" {
- fields["session"] = map[string]interface{}{"id": params.sessionID}
+ fields["session"] = mergeNested(fields["session"], map[string]interface{}{"id": params.sessionID})
}
logger.EndpointEvent("file.modified", "file", "info", "File edit observed", fields)
}
@@ -311,6 +322,10 @@ func isFileEditTool(platform, toolName string) bool {
lower := strings.ToLower(toolName)
return lower == "edit" || lower == "write"
}
+ if isCascadePlatform(platform) {
+ lower := strings.ToLower(toolName)
+ return lower == "post_write_code" || lower == "write_code"
+ }
if platform == "grok" {
lower := strings.ToLower(toolName)
return lower == "search_replace" || lower == "write_file" || strings.Contains(lower, "edit") || strings.Contains(lower, "write")
diff --git a/cli/beacon-hooks/cmd/post_tool_test.go b/cli/beacon-hooks/cmd/post_tool_test.go
index 6b8e91c0..bd0347a3 100644
--- a/cli/beacon-hooks/cmd/post_tool_test.go
+++ b/cli/beacon-hooks/cmd/post_tool_test.go
@@ -201,13 +201,19 @@ func TestRunPostToolEmitsDevinDesktopFileModifiedEvent(t *testing.T) {
t.Setenv("BEACON_ENDPOINT_LOG", logPath)
out := runHookWithInput(t, runPostTool, map[string]interface{}{
- "cwd": "/repo",
- "tool_name": "write",
- "tool_input": map[string]interface{}{
- "file_path": "/repo/main.go",
- "content": "new token=devin-secret",
+ "agent_action_name": "post_write_code",
+ "trajectory_id": "cascade-session",
+ "execution_id": "cascade-turn",
+ "tool_info": map[string]interface{}{
+ "file_path": "/repo/main.go",
+ "workspace_path": "/repo",
+ "edits": []interface{}{
+ map[string]interface{}{
+ "old_string": "old",
+ "new_string": "new token=devin-secret",
+ },
+ },
},
- "tool_response": map[string]interface{}{"success": true},
})
if len(out) != 0 {
t.Fatalf("post-tool response = %#v, want empty response", out)
@@ -220,10 +226,9 @@ func TestRunPostToolEmitsDevinDesktopFileModifiedEvent(t *testing.T) {
if harness := event["harness"].(map[string]interface{})["name"]; harness != "devin-desktop" {
t.Fatalf("harness = %q, want devin-desktop", harness)
}
- if session, ok := event["session"].(map[string]interface{}); ok {
- if _, hasID := session["id"]; hasID {
- t.Fatalf("devin desktop file event should not include empty session id: %#v", session)
- }
+ session := event["session"].(map[string]interface{})
+ if session["id"] != "cascade-session" || session["execution_id"] != "cascade-turn" {
+ t.Fatalf("session = %#v, want Cascade trajectory and execution IDs", session)
}
file := event["file"].(map[string]interface{})
if file["path"] != "/repo/main.go" {
@@ -232,6 +237,71 @@ func TestRunPostToolEmitsDevinDesktopFileModifiedEvent(t *testing.T) {
if _, ok := file["diff_hash"]; !ok {
t.Fatalf("file diff_hash missing: %#v", file)
}
+ if _, ok := event["raw"].(map[string]interface{})["cascade"]; !ok {
+ t.Fatalf("raw.cascade missing: %#v", event["raw"])
+ }
+}
+
+func TestRunPostToolEmitsDevinDesktopCascadeObservedEvents(t *testing.T) {
+ tests := []struct {
+ name string
+ actionName string
+ toolInfo map[string]interface{}
+ wantAction string
+ wantField string
+ }{
+ {
+ name: "command",
+ actionName: "post_run_command",
+ toolInfo: map[string]interface{}{"command": "go test ./...", "workspace_path": "/repo"},
+ wantAction: "command.executed",
+ wantField: "command",
+ },
+ {
+ name: "mcp",
+ actionName: "post_mcp_tool_use",
+ toolInfo: map[string]interface{}{"server_name": "linear", "tool_name": "issue-get", "workspace_path": "/repo"},
+ wantAction: "mcp.tool_invoked",
+ wantField: "mcp",
+ },
+ {
+ name: "read",
+ actionName: "post_read_code",
+ toolInfo: map[string]interface{}{"file_path": "/repo/main.go", "workspace_path": "/repo"},
+ wantAction: "file.read",
+ wantField: "file",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ setupHookConfigDirs(t)
+ platformFlag = "devin-desktop"
+ logPath := filepath.Join(t.TempDir(), "runtime.jsonl")
+ t.Setenv("BEACON_ENDPOINT_LOG", logPath)
+
+ out := runHookWithInput(t, runPostTool, map[string]interface{}{
+ "agent_action_name": tt.actionName,
+ "trajectory_id": "cascade-session",
+ "execution_id": "cascade-turn",
+ "tool_info": tt.toolInfo,
+ })
+ if len(out) != 0 {
+ t.Fatalf("post-tool response = %#v, want empty response", out)
+ }
+
+ event := lastEndpointEvent(t, logPath)
+ if action := event["event"].(map[string]interface{})["action"]; action != tt.wantAction {
+ t.Fatalf("event.action = %q, want %q", action, tt.wantAction)
+ }
+ if _, ok := event[tt.wantField]; !ok {
+ t.Fatalf("event missing %q field: %#v", tt.wantField, event)
+ }
+ tool := event["tool"].(map[string]interface{})
+ if tool["execution_id"] != "cascade-turn" || tool["action"] != tt.actionName {
+ t.Fatalf("tool = %#v, want Cascade action and execution IDs", tool)
+ }
+ })
+ }
}
func TestRunPostToolEmitsFactoryFileModifiedEvent(t *testing.T) {
diff --git a/cli/beacon-hooks/cmd/pre_tool_test.go b/cli/beacon-hooks/cmd/pre_tool_test.go
index 25881648..17951e77 100644
--- a/cli/beacon-hooks/cmd/pre_tool_test.go
+++ b/cli/beacon-hooks/cmd/pre_tool_test.go
@@ -290,11 +290,15 @@ func TestRunPromptSubmitEmitsDevinDesktopPromptWithDesktopHarness(t *testing.T)
logPath := filepath.Join(t.TempDir(), "runtime.jsonl")
t.Setenv("BEACON_ENDPOINT_LOG", logPath)
t.Setenv("BEACON_CONTENT_RETENTION", "full")
- t.Setenv("DEVIN_PROJECT_DIR", "/repo")
out := runHookWithInput(t, runPromptSubmit, map[string]interface{}{
- "hook_event_name": "UserPromptSubmit",
- "prompt": "summarize token=desktop-secret",
+ "agent_action_name": "pre_user_prompt",
+ "trajectory_id": "cascade-session",
+ "execution_id": "cascade-turn",
+ "tool_info": map[string]interface{}{
+ "user_prompt": "summarize token=desktop-secret",
+ "workspace_path": "/repo",
+ },
})
if len(out) != 0 {
t.Fatalf("devin desktop prompt response = %#v, want empty response", out)
@@ -307,8 +311,40 @@ func TestRunPromptSubmitEmitsDevinDesktopPromptWithDesktopHarness(t *testing.T)
if harness := event["harness"].(map[string]interface{})["name"]; harness != "devin-desktop" {
t.Fatalf("harness = %q, want devin-desktop", harness)
}
+ session := event["session"].(map[string]interface{})
+ if session["id"] != "cascade-session" || session["execution_id"] != "cascade-turn" {
+ t.Fatalf("session = %#v, want Cascade trajectory and execution IDs", session)
+ }
if got := event["repository"]; got != "/repo" {
- t.Fatalf("repository = %q, want DEVIN_PROJECT_DIR", got)
+ t.Fatalf("repository = %q, want Cascade workspace path", got)
+ }
+}
+
+func TestRunPromptSubmitOmitsDevinDesktopPromptForMetadataRetention(t *testing.T) {
+ setupHookConfigDirs(t)
+ platformFlag = "devin-desktop"
+ logPath := filepath.Join(t.TempDir(), "runtime.jsonl")
+ t.Setenv("BEACON_ENDPOINT_LOG", logPath)
+ t.Setenv("BEACON_CONTENT_RETENTION", "metadata")
+
+ out := runHookWithInput(t, runPromptSubmit, map[string]interface{}{
+ "agent_action_name": "pre_user_prompt",
+ "trajectory_id": "cascade-session",
+ "tool_info": map[string]interface{}{
+ "user_prompt": "summarize token=desktop-secret",
+ },
+ })
+ if len(out) != 0 {
+ t.Fatalf("devin desktop prompt response = %#v, want empty response", out)
+ }
+
+ event := lastEndpointEvent(t, logPath)
+ if _, ok := event["prompt"]; ok {
+ t.Fatalf("metadata retention should omit prompt: %#v", event["prompt"])
+ }
+ content := event["content"].(map[string]interface{})
+ if content["included"] != false {
+ t.Fatalf("content = %#v, want included=false", content)
}
}
diff --git a/cli/beacon-hooks/cmd/prompt_submit.go b/cli/beacon-hooks/cmd/prompt_submit.go
index 3ca170e8..5c806a7d 100644
--- a/cli/beacon-hooks/cmd/prompt_submit.go
+++ b/cli/beacon-hooks/cmd/prompt_submit.go
@@ -42,7 +42,13 @@ func runPromptSubmit(cmd *cobra.Command, args []string) {
logger.Debug("Prompt submit observed")
fields := sessionFields(sessionID, input)
+ if isCascadePlatform(platformFlag) {
+ fields = cascadeMetadataFields(sessionID, input)
+ }
prompt := getFirstStr(input, "prompt", "user_prompt", "userPrompt", "text", "promptText", "input")
+ if isCascadePlatform(platformFlag) {
+ prompt = cascadePrompt(input)
+ }
hasPrompt := prompt != ""
if hasPrompt && config.ContentRetentionMode() != config.ContentRetentionMetadata {
fields["prompt"] = map[string]interface{}{"text": prompt}
diff --git a/cli/beacon-hooks/cmd/root.go b/cli/beacon-hooks/cmd/root.go
index 68a90e47..63f6d57f 100644
--- a/cli/beacon-hooks/cmd/root.go
+++ b/cli/beacon-hooks/cmd/root.go
@@ -21,7 +21,7 @@ Use --platform to specify the calling platform (default: claude).`,
}
func init() {
- rootCmd.PersistentFlags().StringVar(&platformFlag, "platform", "claude", "Platform context: claude, antigravity, copilot, cursor, vscode, devin, factory, grok, or opencode")
+ rootCmd.PersistentFlags().StringVar(&platformFlag, "platform", "claude", "Platform context: claude, antigravity, copilot, cursor, vscode, devin, devin-cli, devin-desktop, factory, grok, or opencode")
}
// Execute runs the root command
diff --git a/cli/beacon/README.md b/cli/beacon/README.md
index d028928e..86a6e274 100644
--- a/cli/beacon/README.md
+++ b/cli/beacon/README.md
@@ -248,10 +248,14 @@ use `.devin/hooks.v1.json`; user-level installs use
local Go hook binary and write normalized prompt, tool, command, file, approval,
and session events to the configured runtime JSONL log.
-Devin Desktop is exposed separately as `devin-desktop` and uses the same
-Devin-compatible hook file format with `--platform devin-desktop` event
-attribution. After installation, generate a Devin Desktop event and check the
-Beacon runtime log to validate that the Desktop app executed the hook file.
+Devin Desktop is exposed separately as `devin-desktop` and uses Devin
+Desktop-compatible Cascade/Windsurf hooks. User-level installs write
+`~/.codeium/windsurf/hooks.json`; project-level installs write
+`.windsurf/hooks.json`, which may also affect Windsurf/Cascade in that
+workspace. Beacon installs visibility-only hooks for prompt submission, file
+writes, command execution, MCP tool use, and file reads; the hooks do not block
+or enforce policy. After installation, generate a Devin Desktop event and check
+the Beacon runtime log to validate that the Desktop app executed the hook file.
The main `beacon endpoint install --harness ...` path also handles hook-backed
Devin targets, so `--harness claude,codex,devin-cli,devin-desktop` configures
OTLP-backed Claude/Codex telemetry and Devin hook telemetry in one flow.
diff --git a/cli/beacon/internal/embedded/hooks.bin b/cli/beacon/internal/embedded/hooks.bin
old mode 100644
new mode 100755
index 00b1ea2f..56463edc
Binary files a/cli/beacon/internal/embedded/hooks.bin and b/cli/beacon/internal/embedded/hooks.bin differ
diff --git a/cli/beacon/internal/endpoint/harness/harness.go b/cli/beacon/internal/endpoint/harness/harness.go
index 10ce62dc..da417b81 100644
--- a/cli/beacon/internal/endpoint/harness/harness.go
+++ b/cli/beacon/internal/endpoint/harness/harness.go
@@ -268,14 +268,17 @@ func DiscoverDevinDesktop() Harness {
h.Detected = true
h.ExecutablePath = appPath
}
- userConfig := filepath.Join(home, ".config", "devin", "config.json")
- projectConfig := filepath.Join(".devin", "hooks.v1.json")
+ userConfig := filepath.Join(home, ".codeium", "windsurf", "hooks.json")
+ projectConfig := filepath.Join(".windsurf", "hooks.json")
h.ConfigPath = userConfig
if fileExists(projectConfig) {
h.ConfigPath = projectConfig
}
+ if !h.Detected && (dirExists(filepath.Join(home, ".codeium", "windsurf")) || dirExists(".windsurf")) {
+ h.Detected = true
+ }
if fileExists(h.ConfigPath) {
- status, msg := devinStatus(h.ConfigPath, "devin-desktop")
+ status, msg := windsurfCascadeStatus(h.ConfigPath, "devin-desktop")
h.TelemetryStatus = status
if status == TelemetryEnabled {
h.Message = msg + "; generate a Devin Desktop event and check the Beacon runtime log to validate hook execution"
@@ -284,7 +287,7 @@ func DiscoverDevinDesktop() Harness {
}
} else {
h.TelemetryStatus = TelemetryMissing
- h.Message = "Devin Desktop-compatible endpoint hooks were not found"
+ h.Message = "Devin Desktop Cascade/Windsurf hooks.json was not found"
}
return h
}
@@ -561,6 +564,38 @@ func hasBeaconDevinHooks(data []byte, platforms ...string) (bool, error) {
return false, nil
}
+func windsurfCascadeStatus(path string, platform string) (TelemetryStatus, string) {
+ data, err := os.ReadFile(path)
+ if err != nil {
+ return TelemetryMissing, err.Error()
+ }
+ if hasHooks, err := hasBeaconWindsurfHooks(data, platform); err != nil {
+ return TelemetryMisconfigured, "Cascade/Windsurf hooks JSON is invalid"
+ } else if hasHooks {
+ return TelemetryEnabled, "Devin Desktop Cascade/Windsurf endpoint hooks are configured"
+ }
+ return TelemetryDisabled, "Cascade/Windsurf hooks exist but Devin Desktop endpoint hooks were not found"
+}
+
+func hasBeaconWindsurfHooks(data []byte, platform string) (bool, error) {
+ var root struct {
+ Hooks map[string][]struct {
+ Command string `json:"command"`
+ } `json:"hooks"`
+ }
+ 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) {
+ return true, nil
+ }
+ }
+ }
+ return false, nil
+}
+
func commandHasPlatform(command, platform string) bool {
fields := strings.Fields(command)
for i, field := range fields {
diff --git a/cli/beacon/internal/endpoint/harness/harness_test.go b/cli/beacon/internal/endpoint/harness/harness_test.go
index efe22637..54fe8b0e 100644
--- a/cli/beacon/internal/endpoint/harness/harness_test.go
+++ b/cli/beacon/internal/endpoint/harness/harness_test.go
@@ -569,6 +569,9 @@ func TestDiscoverDevinDesktopDetectsAppSupport(t *testing.T) {
if h.ExecutablePath != appSupport && h.ExecutablePath != "/Applications/Devin.app" {
t.Fatalf("ExecutablePath = %q, want app support or app path", h.ExecutablePath)
}
+ if h.ConfigPath != filepath.Join(home, ".codeium", "windsurf", "hooks.json") {
+ t.Fatalf("ConfigPath = %q, want Windsurf user hooks path", h.ConfigPath)
+ }
}
func TestDevinStatusVariants(t *testing.T) {
@@ -603,13 +606,13 @@ func TestDevinStatusVariants(t *testing.T) {
func TestDevinDesktopStatusVariants(t *testing.T) {
path := filepath.Join(t.TempDir(), "desktop.json")
- body := `{"hooks":{"PreToolUse":[{"hooks":[{"type":"command","command":"BEACON_ENDPOINT_MODE=1 beacon-hooks --platform devin-desktop pre-tool"}]}]}}`
+ body := `{"hooks":{"post_write_code":[{"command":"BEACON_ENDPOINT_MODE=1 beacon-hooks --platform devin-desktop post-tool"}]}}`
if err := os.WriteFile(path, []byte(body), 0600); err != nil {
t.Fatalf("write fixture: %v", err)
}
- status, _ := devinStatus(path, "devin-desktop")
+ status, _ := windsurfCascadeStatus(path, "devin-desktop")
if status != TelemetryEnabled {
- t.Fatalf("devinStatus desktop = %q, want enabled", status)
+ t.Fatalf("windsurfCascadeStatus desktop = %q, want enabled", status)
}
}
diff --git a/cli/beacon/internal/endpoint/hooks/devin.go b/cli/beacon/internal/endpoint/hooks/devin.go
index 370d982c..5eb2f7af 100644
--- a/cli/beacon/internal/endpoint/hooks/devin.go
+++ b/cli/beacon/internal/endpoint/hooks/devin.go
@@ -37,6 +37,16 @@ type devinHookRef struct {
Timeout int `json:"timeout,omitempty"`
}
+type windsurfHookRef struct {
+ Command string `json:"command"`
+ ShowOutput *bool `json:"show_output,omitempty"`
+}
+
+type windsurfHooksFile struct {
+ values map[string]json.RawMessage
+ hooks map[string][]windsurfHookRef
+}
+
type devinConfig struct {
values map[string]json.RawMessage
hooks map[string][]devinHookGroup
@@ -52,8 +62,8 @@ var devinRuntime = hookRuntime{
}
var devinDesktopRuntime = hookRuntime{
- displayName: "Devin Desktop",
- configPath: devinConfigPath,
+ displayName: "Devin Desktop via Cascade/Windsurf",
+ configPath: devinDesktopConfigPath,
install: installDevinDesktopHooks,
uninstall: removeDevinDesktopEndpointHooks,
isInstalled: isDevinDesktopInstalledAt,
@@ -117,7 +127,27 @@ func installDevinCLIHooks(path, binaryPath, logPath, configPath string) error {
}
func installDevinDesktopHooks(path, binaryPath, logPath, configPath string) error {
- return installDevinHooksForPlatform(path, binaryPath, logPath, configPath, "devin-desktop", []string{"devin-desktop"})
+ config, err := readWindsurfHooks(path)
+ if err != nil {
+ return err
+ }
+ prefix := endpointCommandPrefix("devin-desktop", binaryPath, logPath, configPath)
+ hideOutput := false
+ endpointHooks := map[string]windsurfHookRef{
+ "pre_user_prompt": {Command: prefix + " prompt-submit", ShowOutput: &hideOutput},
+ "post_write_code": {Command: prefix + " post-tool", ShowOutput: &hideOutput},
+ "post_run_command": {Command: prefix + " post-tool", ShowOutput: &hideOutput},
+ "post_mcp_tool_use": {Command: prefix + " post-tool", ShowOutput: &hideOutput},
+ "post_read_code": {Command: prefix + " post-tool", ShowOutput: &hideOutput},
+ }
+ for eventName, hook := range endpointHooks {
+ config.hooks[eventName] = mergeWindsurfEndpointHook(config.hooks[eventName], hook, "devin-desktop")
+ }
+ data, err := config.marshal()
+ if err != nil {
+ return err
+ }
+ return os.WriteFile(path, data, 0600)
}
func installDevinHooks(path, binaryPath, logPath, configPath string) error {
@@ -180,6 +210,47 @@ func readDevinConfig(path string) (devinConfig, error) {
return config, nil
}
+func readWindsurfHooks(path string) (windsurfHooksFile, error) {
+ config := windsurfHooksFile{
+ values: map[string]json.RawMessage{},
+ hooks: map[string][]windsurfHookRef{},
+ }
+ data, err := os.ReadFile(path)
+ if err == nil {
+ if err := json.Unmarshal(data, &config.values); err != nil {
+ return windsurfHooksFile{}, err
+ }
+ if rawHooks, ok := config.values["hooks"]; ok {
+ if err := json.Unmarshal(rawHooks, &config.hooks); err != nil {
+ return windsurfHooksFile{}, err
+ }
+ }
+ } else if !os.IsNotExist(err) {
+ return windsurfHooksFile{}, err
+ }
+ if config.hooks == nil {
+ config.hooks = map[string][]windsurfHookRef{}
+ }
+ return config, nil
+}
+
+func (config windsurfHooksFile) marshal() ([]byte, error) {
+ out := make(map[string]json.RawMessage, len(config.values)+1)
+ for key, value := range config.values {
+ if key != "hooks" {
+ out[key] = value
+ }
+ }
+ if len(config.hooks) > 0 {
+ data, err := json.Marshal(config.hooks)
+ if err != nil {
+ return nil, err
+ }
+ out["hooks"] = data
+ }
+ return json.MarshalIndent(out, "", " ")
+}
+
func (config devinConfig) marshal() ([]byte, error) {
if config.standalone {
if len(config.hooks) == 0 {
@@ -217,6 +288,17 @@ func mergeDevinEndpointHook(existing []devinHookGroup, group devinHookGroup, pla
return append(out, group)
}
+func mergeWindsurfEndpointHook(existing []windsurfHookRef, hook windsurfHookRef, platform string) []windsurfHookRef {
+ out := make([]windsurfHookRef, 0, len(existing)+1)
+ for _, item := range existing {
+ if isWindsurfEndpointHookCommand(item.Command, platform) {
+ continue
+ }
+ out = append(out, item)
+ }
+ return append(out, hook)
+}
+
func removeDevinEndpointHooks(path string) (bool, error) {
return removeDevinEndpointHooksForPlatforms(path, "devin")
}
@@ -226,7 +308,37 @@ func removeDevinCLIEndpointHooks(path string) (bool, error) {
}
func removeDevinDesktopEndpointHooks(path string) (bool, error) {
- return removeDevinEndpointHooksForPlatforms(path, "devin-desktop")
+ config, err := readWindsurfHooks(path)
+ if err != nil {
+ if os.IsNotExist(err) {
+ return false, nil
+ }
+ return false, err
+ }
+ changed := false
+ for eventName, hooks := range config.hooks {
+ filtered := hooks[:0]
+ for _, hook := range hooks {
+ if isWindsurfEndpointHookCommand(hook.Command, "devin-desktop") {
+ changed = true
+ continue
+ }
+ filtered = append(filtered, hook)
+ }
+ if len(filtered) == 0 {
+ delete(config.hooks, eventName)
+ } else {
+ config.hooks[eventName] = filtered
+ }
+ }
+ if !changed {
+ return false, nil
+ }
+ out, err := config.marshal()
+ if err != nil {
+ return false, err
+ }
+ return true, os.WriteFile(path, out, 0600)
}
func removeDevinEndpointHooksForPlatforms(path string, platforms ...string) (bool, error) {
@@ -301,7 +413,18 @@ func isDevinCLIInstalledAt(path string) bool {
}
func isDevinDesktopInstalledAt(path string) bool {
- return isDevinInstalledAtPlatforms(path, "devin-desktop")
+ config, err := readWindsurfHooks(path)
+ if err != nil {
+ return false
+ }
+ for _, hooks := range config.hooks {
+ for _, hook := range hooks {
+ if isWindsurfEndpointHookCommand(hook.Command, "devin-desktop") {
+ return true
+ }
+ }
+ }
+ return false
}
func isDevinInstalledAtPlatforms(path string, platforms ...string) bool {
@@ -331,6 +454,10 @@ func isDevinEndpointHookCommand(command string, platforms ...string) bool {
return false
}
+func isWindsurfEndpointHookCommand(command, platform string) bool {
+ return isEndpointHookCommand(command, platform)
+}
+
func devinConfigPath(level Level) (string, error) {
switch level {
case LevelProject:
@@ -349,3 +476,22 @@ func devinConfigPath(level Level) (string, error) {
return "", fmt.Errorf("unknown hook level %q", level)
}
}
+
+func devinDesktopConfigPath(level Level) (string, error) {
+ switch level {
+ case LevelProject:
+ cwd, err := os.Getwd()
+ if err != nil {
+ return "", err
+ }
+ return filepath.Join(cwd, ".windsurf", "hooks.json"), nil
+ case "", LevelUser:
+ home, err := os.UserHomeDir()
+ if err != nil {
+ return "", err
+ }
+ return filepath.Join(home, ".codeium", "windsurf", "hooks.json"), nil
+ default:
+ return "", fmt.Errorf("unknown hook level %q", level)
+ }
+}
diff --git a/cli/beacon/internal/endpoint/hooks/devin_test.go b/cli/beacon/internal/endpoint/hooks/devin_test.go
index baee9440..170be9c0 100644
--- a/cli/beacon/internal/endpoint/hooks/devin_test.go
+++ b/cli/beacon/internal/endpoint/hooks/devin_test.go
@@ -1,6 +1,7 @@
package hooks
import (
+ "encoding/json"
"os"
"path/filepath"
"strings"
@@ -61,6 +62,58 @@ func TestInstallDevinUserConfigPreservesUnrelatedKeys(t *testing.T) {
}
}
+func TestInstallDevinUserConfigPreservesImportConfig(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "config.json")
+ existing := `{"theme":"dark","read_config_from":{"cursor":true,"windsurf":false,"claude":true}}`
+ if err := os.WriteFile(path, []byte(existing), 0600); err != nil {
+ t.Fatal(err)
+ }
+
+ if err := installDevinCLIHooks(path, "/tmp/beacon-hooks", "/tmp/runtime.jsonl", "/tmp/config.json"); err != nil {
+ t.Fatalf("installDevinCLIHooks returned error: %v", err)
+ }
+ data, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatalf("read config: %v", err)
+ }
+ var config map[string]interface{}
+ if err := json.Unmarshal(data, &config); err != nil {
+ t.Fatalf("unmarshal config: %v\n%s", err, data)
+ }
+ readConfigFrom := config["read_config_from"].(map[string]interface{})
+ if readConfigFrom["claude"] != true {
+ t.Fatalf("read_config_from.claude = %#v, want preserved true", readConfigFrom["claude"])
+ }
+ if readConfigFrom["cursor"] != true || readConfigFrom["windsurf"] != false {
+ t.Fatalf("read_config_from did not preserve other values: %#v", readConfigFrom)
+ }
+ if config["theme"] != "dark" {
+ t.Fatalf("theme = %#v, want preserved dark", config["theme"])
+ }
+}
+
+func TestInstallDevinDesktopHooksUsesCascadeEvents(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "hooks.json")
+ if err := installDevinDesktopHooks(path, "/tmp/beacon-hooks", "/tmp/runtime.jsonl", "/tmp/config.json"); err != nil {
+ t.Fatalf("installDevinDesktopHooks returned error: %v", err)
+ }
+ data, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatalf("read hooks: %v", err)
+ }
+ text := string(data)
+ for _, want := range []string{"pre_user_prompt", "post_write_code", "post_run_command", "post_mcp_tool_use", "post_read_code", "--platform devin-desktop", "prompt-submit", "post-tool"} {
+ if !strings.Contains(text, want) {
+ t.Fatalf("Devin Desktop hooks missing %q:\n%s", want, text)
+ }
+ }
+ for _, notWant := range []string{"PreToolUse", "PostToolUse", "SessionStart", "read_config_from"} {
+ if strings.Contains(text, notWant) {
+ t.Fatalf("Devin Desktop hooks should not contain %q:\n%s", notWant, text)
+ }
+ }
+}
+
func TestInstallDevinHooksReplacesOldBeaconHooks(t *testing.T) {
path := filepath.Join(t.TempDir(), "hooks.v1.json")
existing := `{"PostToolUse":[{"hooks":[{"type":"command","command":"BEACON_ENDPOINT_MODE=1 old-beacon-hooks --platform devin post-tool"}]},{"hooks":[{"type":"command","command":"echo keep"}]}]}`
@@ -108,8 +161,8 @@ func TestInstallDevinCLIHooksReplacesLegacyHooksWithExplicitPlatform(t *testing.
}
func TestInstallDevinDesktopHooksDoesNotRemoveCLIHooks(t *testing.T) {
- path := filepath.Join(t.TempDir(), "hooks.v1.json")
- existing := `{"PostToolUse":[{"hooks":[{"type":"command","command":"BEACON_ENDPOINT_MODE=1 beacon-hooks --platform devin-cli post-tool"}]}]}`
+ path := filepath.Join(t.TempDir(), "hooks.json")
+ existing := `{"hooks":{"post_write_code":[{"command":"BEACON_ENDPOINT_MODE=1 beacon-hooks --platform devin-cli post-tool"}]}}`
if err := os.WriteFile(path, []byte(existing), 0600); err != nil {
t.Fatal(err)
}
@@ -155,8 +208,8 @@ func TestRemoveDevinEndpointHooksPreservesOtherHooks(t *testing.T) {
}
func TestRemoveDevinDesktopEndpointHooksPreservesCLIHooks(t *testing.T) {
- path := filepath.Join(t.TempDir(), "hooks.v1.json")
- existing := `{"SessionStart":[{"hooks":[{"type":"command","command":"BEACON_ENDPOINT_MODE=1 beacon-hooks --platform devin-cli session-start"}]},{"hooks":[{"type":"command","command":"BEACON_ENDPOINT_MODE=1 beacon-hooks --platform devin-desktop session-start"}]}]}`
+ path := filepath.Join(t.TempDir(), "hooks.json")
+ existing := `{"hooks":{"post_write_code":[{"command":"BEACON_ENDPOINT_MODE=1 beacon-hooks --platform devin-cli post-tool"},{"command":"BEACON_ENDPOINT_MODE=1 beacon-hooks --platform devin-desktop post-tool"}]}}`
if err := os.WriteFile(path, []byte(existing), 0600); err != nil {
t.Fatal(err)
}
@@ -228,11 +281,11 @@ func TestDevinHookStatusDetectsInstalled(t *testing.T) {
func TestDevinDesktopHookStatusDetectsInstalled(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
- path := filepath.Join(home, ".config", "devin", "config.json")
+ path := filepath.Join(home, ".codeium", "windsurf", "hooks.json")
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
t.Fatal(err)
}
- if err := os.WriteFile(path, []byte(`{"hooks":{"Stop":[{"hooks":[{"type":"command","command":"BEACON_ENDPOINT_MODE=1 beacon-hooks --platform devin-desktop stop"}]}]}}`), 0600); err != nil {
+ if err := os.WriteFile(path, []byte(`{"hooks":{"post_write_code":[{"command":"BEACON_ENDPOINT_MODE=1 beacon-hooks --platform devin-desktop post-tool"}]}}`), 0600); err != nil {
t.Fatal(err)
}
@@ -244,3 +297,16 @@ func TestDevinDesktopHookStatusDetectsInstalled(t *testing.T) {
t.Fatalf("ConfigPath = %q, want %q", status.ConfigPath, path)
}
}
+
+func TestDevinDesktopConfigPathProjectLevel(t *testing.T) {
+ dir := t.TempDir()
+ t.Chdir(dir)
+
+ target, err := devinDesktopConfigPath(LevelProject)
+ if err != nil {
+ t.Fatalf("devinDesktopConfigPath returned error: %v", err)
+ }
+ if got, want := target, filepath.Join(dir, ".windsurf", "hooks.json"); got != want {
+ t.Fatalf("project config path = %q, want %q", got, want)
+ }
+}
diff --git a/cli/beacon/internal/endpoint/hooks/settings_hooks.go b/cli/beacon/internal/endpoint/hooks/settings_hooks.go
index 14c26d01..3b089987 100644
--- a/cli/beacon/internal/endpoint/hooks/settings_hooks.go
+++ b/cli/beacon/internal/endpoint/hooks/settings_hooks.go
@@ -12,9 +12,10 @@ type settingsHookGroup struct {
}
type settingsHookRef struct {
- Type string `json:"type"`
- Command string `json:"command"`
- Timeout int `json:"timeout,omitempty"`
+ Type string `json:"type,omitempty"`
+ Command string `json:"command"`
+ Timeout int `json:"timeout,omitempty"`
+ ShowOutput *bool `json:"show_output,omitempty"`
}
type settingsHooksFile struct {