@@ -317,9 +317,16 @@ func opencodeToolFields(input map[string]interface{}, completed bool) map[string
317317 }
318318
319319 if path := opencodeToolPath (toolInput ); path != "" {
320+ operation := fileOperation (toolName )
321+ if operation == "" {
322+ lower := strings .ToLower (toolName )
323+ if strings .Contains (lower , "glob" ) || strings .Contains (lower , "grep" ) || strings .Contains (lower , "search" ) {
324+ operation = "read"
325+ }
326+ }
320327 fields ["file" ] = map [string ]interface {}{
321328 "path" : path ,
322- "operation" : fileOperation ( toolName ) ,
329+ "operation" : operation ,
323330 "language" : strings .TrimPrefix (filepath .Ext (path ), "." ),
324331 }
325332 fields ["tool" ] = mergeNested (fields ["tool" ], map [string ]interface {}{"name" : toolName , "path" : path })
@@ -398,12 +405,14 @@ func opencodeDecision(input map[string]interface{}) string {
398405
399406func opencodeToolAction (input map [string ]interface {}) (string , string ) {
400407 name := strings .ToLower (opencodeToolName (input ))
408+ toolInput := opencodeMap (input , "tool_input" , "toolInput" )
401409 switch {
402410 case strings .Contains (name , "mcp" ) || strings .HasPrefix (name , "list_mcp_" ) || strings .HasPrefix (name , "read_mcp_" ):
403411 return "mcp.tool_invoked" , "mcp"
404412 case name == "bash" || strings .Contains (name , "shell" ) || strings .Contains (name , "terminal" ):
405413 return "command.executed" , "command"
406- case strings .Contains (name , "read" ):
414+ case strings .Contains (name , "read" ) ||
415+ ((strings .Contains (name , "glob" ) || strings .Contains (name , "grep" ) || strings .Contains (name , "search" )) && opencodeToolPath (toolInput ) != "" ):
407416 return "file.read" , "file"
408417 case strings .Contains (name , "edit" ) || strings .Contains (name , "write" ) || strings .Contains (name , "patch" ):
409418 return "file.modified" , "file"
0 commit comments