|
47 | 47 | (string/join "\n")))] |
48 | 48 | (tools.util/single-text-content content)))) |
49 | 49 |
|
| 50 | +(defn ^:private read-file-summary [args] |
| 51 | + (if-let [path (get args "path")] |
| 52 | + (str "Reading file " (fs/file-name (fs/file path))) |
| 53 | + "Reading file")) |
| 54 | + |
50 | 55 | (defn ^:private write-file [arguments {:keys [db]}] |
51 | 56 | (or (tools.util/invalid-arguments arguments [["path" (partial allowed-path? db) (str "Access denied - path $path outside allowed directories: " (tools.util/workspace-roots-strs db))]]) |
52 | 57 | (let [path (get arguments "path") |
|
55 | 60 | (spit path content) |
56 | 61 | (tools.util/single-text-content (format "Successfully wrote to %s" path))))) |
57 | 62 |
|
| 63 | +(defn ^:private write-file-summary [args] |
| 64 | + (if-let [path (get args "path")] |
| 65 | + (str "Creating file " (fs/file-name (fs/file path))) |
| 66 | + "Creating file")) |
| 67 | + |
58 | 68 | (defn ^:private run-ripgrep [path pattern include] |
59 | 69 | (let [cmd (cond-> ["rg" "--files-with-matches" "--no-heading"] |
60 | 70 | include (concat ["--glob" include]) |
|
147 | 157 | (tools.util/single-text-content (string/join "\n" paths)) |
148 | 158 | (tools.util/single-text-content "No files found for given pattern" :error))))) |
149 | 159 |
|
| 160 | +(defn grep-summary [args] |
| 161 | + (if-let [pattern (get args "pattern")] |
| 162 | + (format "Searching for '%s'" pattern) |
| 163 | + "Searching for files")) |
| 164 | + |
150 | 165 | (defn file-change-full-content [path original-content new-content all?] |
151 | 166 | (let [original-full-content (slurp path) |
152 | 167 | new-full-content (if all? |
|
193 | 208 | "limit" {:type "integer" |
194 | 209 | :description "Maxium number of entries to show (default: 100)"}} |
195 | 210 | :required ["path"]} |
196 | | - :handler #'directory-tree} |
| 211 | + :handler #'directory-tree |
| 212 | + :summary-fn (constantly "Listing file tree")} |
197 | 213 | "eca_read_file" |
198 | 214 | {:description (str "Read the contents of a file from the file system. " |
199 | 215 | "Use this tool when you need to examine " |
|
209 | 225 | "limit" {:type "integer" |
210 | 226 | :description (str "Maximum lines to read (default: " read-file-max-lines ")")}} |
211 | 227 | :required ["path"]} |
212 | | - :handler #'read-file} |
| 228 | + :handler #'read-file |
| 229 | + :summary-fn #'read-file-summary} |
213 | 230 | "eca_write_file" |
214 | 231 | {:description (str "Create a new file or completely overwrite an existing file with new content. " |
215 | 232 | "This tool will automatically create any necessary parent directories if they don't exist. " |
|
223 | 240 | "content" {:type "string" |
224 | 241 | :description "The complete content to write to the file"}} |
225 | 242 | :required ["path" "content"]} |
226 | | - :handler #'write-file} |
| 243 | + :handler #'write-file |
| 244 | + :summary-fn #'write-file-summary} |
227 | 245 | "eca_edit_file" |
228 | 246 | {:description (str "Replace a specific string or content block in a file with new content. " |
229 | 247 | "Finds the exact original content and replaces it with new content. " |
|
240 | 258 | "all_occurrences" {:type "boolean" |
241 | 259 | :description "Whether to replace all occurences of the file or just the first one (default)"}} |
242 | 260 | :required ["path" "original_content" "new_content"]} |
243 | | - :handler #'edit-file} |
| 261 | + :handler #'edit-file |
| 262 | + :summary-fn (constantly "Editting file")} |
244 | 263 | "eca_move_file" |
245 | 264 | {:description (str "Move or rename files and directories. Can move files between directories " |
246 | 265 | "and rename them in a single operation. If the destination exists, the " |
|
253 | 272 | "destination" {:type "string" |
254 | 273 | :description "The new absolute file path to move to."}} |
255 | 274 | :required ["source" "destination"]} |
256 | | - :handler #'move-file} |
| 275 | + :handler #'move-file |
| 276 | + :summary-fn (constantly "Moving file")} |
257 | 277 | "eca_grep" |
258 | 278 | {:description (str "Fast content search tool that works with any codebase size. " |
259 | 279 | "Finds the paths to files that have matching contents using regular expressions. " |
|
271 | 291 | "max_results" {:type "integer" |
272 | 292 | :description "Maximum number of results to return (default: 1000)"}} |
273 | 293 | :required ["path" "pattern"]} |
274 | | - :handler #'grep}}) |
| 294 | + :handler #'grep |
| 295 | + :summary-fn #'grep-summary}}) |
0 commit comments