(_ context.Context, args map[string]any)
| 63 | func (p *FileReadDiffProvider) Tool() Tool { return FileReadDiff } |
| 64 | |
| 65 | func (p *FileReadDiffProvider) Execute(_ context.Context, args map[string]any) (string, error) { |
| 66 | pathArray, _ := args["path_array"].([]any) |
| 67 | if len(pathArray) == 0 { |
| 68 | return "Error: no files found", nil |
| 69 | } |
| 70 | |
| 71 | var sb strings.Builder |
| 72 | var missing []string |
| 73 | for _, item := range pathArray { |
| 74 | path, ok := item.(string) |
| 75 | if !ok { |
| 76 | continue |
| 77 | } |
| 78 | if d, exists := p.diffMap.Get(path); exists { |
| 79 | sb.WriteString("==== FILE: ") |
| 80 | sb.WriteString(path) |
| 81 | sb.WriteString(" ====\n") |
| 82 | sb.WriteString(d) |
| 83 | sb.WriteString("\n") |
| 84 | continue |
| 85 | } |
| 86 | missing = append(missing, path) |
| 87 | } |
| 88 | |
| 89 | if len(missing) > 0 { |
| 90 | if sb.Len() > 0 { |
| 91 | sb.WriteString("\n") |
| 92 | } |
| 93 | sb.WriteString(p.notFoundMessage(missing)) |
| 94 | } |
| 95 | |
| 96 | result := sb.String() |
| 97 | if result == "" { |
| 98 | return "Error: diff not found for the requested paths", nil |
| 99 | } |
| 100 | return result, nil |
| 101 | } |
| 102 | |
| 103 | // notFoundMessage names the paths that had no diff and, when the snapshot |
| 104 | // holds other paths, names those too: a request for a path outside the change |
nothing calls this directly
no test coverage detected