diff --git a/internal/acp/sink.go b/internal/acp/sink.go index 8628e89fc728b918bc020f0771688ef487bc94a7..1b31f689e4ff0f495fae219782abb4eeac76ee6b 100644 --- a/internal/acp/sink.go +++ b/internal/acp/sink.go @@ -341,6 +341,8 @@ func (s *Sink) translateToolResult(tr message.ToolResult) *acp.SessionUpdate { // For edit tools with metadata, emit diff content. content := []acp.ToolCallContent{acp.ToolContent(acp.TextBlock(tr.Content))} + var locations []acp.ToolCallLocation + if !tr.IsError && tr.Metadata != "" { switch tr.Name { case "edit", "multiedit", "write": @@ -350,13 +352,24 @@ func (s *Sink) translateToolResult(tr message.ToolResult) *acp.SessionUpdate { acp.ToolDiffContent(meta.FilePath, meta.NewContent, meta.OldContent), } } + case "ls": + var meta struct { + Path string `json:"path"` + } + if err := json.Unmarshal([]byte(tr.Metadata), &meta); err == nil && meta.Path != "" { + locations = []acp.ToolCallLocation{{Path: meta.Path}} + } } } - update := acp.UpdateToolCall( - acp.ToolCallId(tr.ToolCallID), + opts := []acp.ToolCallUpdateOpt{ acp.WithUpdateStatus(status), acp.WithUpdateContent(content), - ) + } + if len(locations) > 0 { + opts = append(opts, acp.WithUpdateLocations(locations)) + } + + update := acp.UpdateToolCall(acp.ToolCallId(tr.ToolCallID), opts...) return &update } diff --git a/internal/agent/tools/ls.go b/internal/agent/tools/ls.go index 2a6627741256339a319ec734c4ff766b041e5670..5f90cd97253149f4d2fe4ce30a8754dded1ffe6e 100644 --- a/internal/agent/tools/ls.go +++ b/internal/agent/tools/ls.go @@ -36,8 +36,9 @@ type TreeNode struct { } type LSResponseMetadata struct { - NumberOfFiles int `json:"number_of_files"` - Truncated bool `json:"truncated"` + Path string `json:"path"` + NumberOfFiles int `json:"number_of_files"` + Truncated bool `json:"truncated"` } const ( @@ -126,6 +127,7 @@ func ListDirectoryTree(searchPath string, params LSParams, lsConfig config.ToolL } metadata := LSResponseMetadata{ + Path: searchPath, NumberOfFiles: len(files), Truncated: truncated, }