The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix: limit OpenCode file events to agent tools
Cursor Agentf1a3ef9f02ce
diff --git a/cli/beacon-hooks/cmd/opencode_event.go b/cli/beacon-hooks/cmd/opencode_event.goindex a2f2e034..3223d67b 100644--- a/cli/beacon-hooks/cmd/opencode_event.go+++ b/cli/beacon-hooks/cmd/opencode_event.go@@ -138,31 +138,6 @@ func opencodeEndpointEvents(input map[string]interface{}, sessionID string) []opreturn one("session.error", "session", "high", "opencode session error", fields)case "session.diff":return opencodeDiffEvents(input, fields)- case "file.edited", "file.watcher.updated":- properties := opencodeProperties(input)- path := getFirstStr(properties, "file", "path", "file_path", "filePath")- if path == "" || sessionID == "" {- return nil- }- operation := "modify"- if getFirstStr(properties, "event") == "unlink" {- operation = "delete"- }- fields["file"] = map[string]interface{}{- "path": path,- "operation": operation,- "language": strings.TrimPrefix(filepath.Ext(path), "."),- }- if callID := getFirstStr(properties, "callID", "call_id"); callID != "" {- fields["gen_ai"] = map[string]interface{}{- "operation": map[string]interface{}{"name": "execute_tool"},- "tool": map[string]interface{}{- "name": "file_watcher",- "call": map[string]interface{}{"id": callID},- },- }- }- return one("file.modified", "file", "info", "opencode file change observed", fields)case "command.execute.before":if command := opencodeCommand(input); command != "" {fields["command"] = map[string]interface{}{"command": command}@@ -209,8 +184,6 @@ func supportedOpenCodeEventTypes() []string {"chat.message","command.execute.before","command.executed",- "file.edited",- "file.watcher.updated","message.part.delta","message.part.updated","message.updated",diff --git a/cli/beacon-hooks/cmd/opencode_event_test.go b/cli/beacon-hooks/cmd/opencode_event_test.goindex 2dd20058..3c699add 100644--- a/cli/beacon-hooks/cmd/opencode_event_test.go+++ b/cli/beacon-hooks/cmd/opencode_event_test.go@@ -396,30 +396,6 @@ func TestOpenCodeBashCapturesExitMetadata(t *testing.T) {}}-func TestOpenCodeWatcherUnlinkNormalizesFileDeletion(t *testing.T) {- action, category, _, _, fields := opencodeEndpointEvent(map[string]interface{}{- "type": "file.watcher.updated",- "session_id": "ses_test",- "properties": map[string]interface{}{- "sessionID": "ses_test",- "file": "/repo/.tmp/e2e.txt",- "event": "unlink",- "callID": "call_rm",- },- }, "ses_test")- if action != "file.modified" || category != "file" {- t.Fatalf("event = %s/%s", action, category)- }- file := fields["file"].(map[string]interface{})- if file["operation"] != "delete" || file["path"] != "/repo/.tmp/e2e.txt" {- t.Fatalf("file = %#v", file)- }- call := fields["gen_ai"].(map[string]interface{})["tool"].(map[string]interface{})["call"].(map[string]interface{})- if call["id"] != "call_rm" {- t.Fatalf("call = %#v", call)- }-}-func TestOpenCodeSuccessfulRMEmitsCorrelatedFileDeletion(t *testing.T) {input := map[string]interface{}{"type": "tool.execute.after",diff --git a/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts b/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.tsindex ad37c21c..94b24591 100644--- a/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts+++ b/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts@@ -12,8 +12,6 @@ const directHookTypes = new Set(["tool.execute.after",])const forwardedEvents = new Set([- "file.edited",- "file.watcher.updated","message.part.updated","message.part.delta","message.updated",@@ -377,14 +375,6 @@ export const BeaconEndpointPlugin = async ({ project, directory, worktree, clienif (filtered.length === 0) returnproperties.diff = filtered}- if (type === "file.edited" || type === "file.watcher.updated") {- const seen = recentFilePaths.get(filePath(properties))- if (seen && Date.now() - seen.time < 5000) return- // OpenCode watcher events are filesystem-scoped and commonly omit a- // session. Never guess an active session: ambient IDE/user changes- // must not be attributed to an agent trace.- if (!sid) return- }const queued = enqueue(payload(type, {session_id: sessionID(properties) || sid,diff --git a/plugins/opencode-beacon/src/beacon.ts b/plugins/opencode-beacon/src/beacon.tsindex ad37c21c..94b24591 100644--- a/plugins/opencode-beacon/src/beacon.ts+++ b/plugins/opencode-beacon/src/beacon.ts@@ -12,8 +12,6 @@ const directHookTypes = new Set(["tool.execute.after",])const forwardedEvents = new Set([- "file.edited",- "file.watcher.updated","message.part.updated","message.part.delta","message.updated",@@ -377,14 +375,6 @@ export const BeaconEndpointPlugin = async ({ project, directory, worktree, clienif (filtered.length === 0) returnproperties.diff = filtered}- if (type === "file.edited" || type === "file.watcher.updated") {- const seen = recentFilePaths.get(filePath(properties))- if (seen && Date.now() - seen.time < 5000) return- // OpenCode watcher events are filesystem-scoped and commonly omit a- // session. Never guess an active session: ambient IDE/user changes- // must not be attributed to an agent trace.- if (!sid) return- }const queued = enqueue(payload(type, {session_id: sessionID(properties) || sid,