|
3 | 3 | ;; Enabled tools: |
4 | 4 | ;; - clojure_eval (REPL evaluation) |
5 | 5 | ;; - clojure_edit_agent (agent-based editing - fallback for Edit tool) |
| 6 | +;; - clojure_edit_replace_sexp (sexp replacement - fallback for Edit tool) |
6 | 7 | ;; - list_nrepl_ports (discover running nREPL servers) |
7 | 8 | ;; |
8 | 9 | ;; Enabled resources: |
9 | | -;; - clojure-project-info (deps.edn/project.clj analysis) |
| 10 | +;; (none) |
10 | 11 |
|
11 | 12 | {:disable-tools |
12 | 13 | [:read_file |
13 | 14 | :grep |
14 | 15 | :glob_files |
15 | 16 | :bash |
16 | | - :clojure_edit_replace_sexp |
17 | 17 | :file_edit |
18 | 18 | :file_write |
19 | 19 | :scratch_pad |
|
38 | 38 | ["PROJECT_SUMMARY.md" |
39 | 39 | "README.md" |
40 | 40 | "CLAUDE.md" |
41 | | - "LLM_CODE_STYLE.md"] |
| 41 | + "LLM_CODE_STYLE.md" |
| 42 | + "Clojure Project Info"] |
42 | 43 |
|
43 | 44 | :write-file-guard false |
44 | 45 |
|
45 | | -:tools-config |
| 46 | + :tools-config |
46 | 47 | {:clojure_edit_agent |
47 | 48 | {:description |
48 | 49 | "FALLBACK TOOL: Only use this tool when the Edit tool returns the error 'String to replace not found in file' or similar errors while editing a Clojure file (.clj, .cljs, .cljc, .edn). |
@@ -100,4 +101,91 @@ instructions: Add validation to calculate function and make add handle nil value |
100 | 101 | ;; ... rest of file ... |
101 | 102 | ``` |
102 | 103 |
|
103 | | -The agent will read the file, identify the locations to change based on context, apply the changes using clojure_edit tools, and return a summary with diffs showing all modifications."}}} |
| 104 | +The agent will read the file, identify the locations to change based on context, apply the changes using clojure_edit tools, and return a summary with diffs showing all modifications."} |
| 105 | + |
| 106 | + :clojure_edit_replace_sexp |
| 107 | + {:description |
| 108 | + "FALLBACK TOOL: Only use this tool when the Edit tool returns the error 'String to replace not found in file' or similar errors while editing a Clojure file (.clj, .cljs, .cljc, .edn). |
| 109 | +
|
| 110 | +The Edit tool works 99% of the time and is preferred for its UI integration. Always try Edit first. |
| 111 | +
|
| 112 | +After using this tool to work around an Edit error, resume using the Edit tool for subsequent edits. |
| 113 | +
|
| 114 | +Replaces Clojure expressions in a file. |
| 115 | +
|
| 116 | +This tool provides targeted replacement of Clojure expressions within forms. For complete top-level form operations, use `clojure_edit` instead. |
| 117 | +
|
| 118 | +KEY BENEFITS: |
| 119 | +- Syntax-aware matching that understands Clojure code structure |
| 120 | +- Ignores whitespace differences by default, focusing on actual code meaning |
| 121 | +- Matches expressions regardless of formatting, indentation, or spacing |
| 122 | +- Prevents errors from mismatched text or irrelevant formatting differences |
| 123 | +- Can replace all occurrences with replace_all: true |
| 124 | +
|
| 125 | +CONSTRAINTS: |
| 126 | +- match_form must contain one or more complete Clojure expressions |
| 127 | +- new_form must contain zero or more complete Clojure expressions |
| 128 | +- Both match_form and new_form must be valid Clojure code that can be parsed |
| 129 | +
|
| 130 | +A complete Clojure expression is any form that Clojure can read as a complete unit: |
| 131 | +- Symbols: foo, my-var, clojure.core/map |
| 132 | +- Numbers: 42, 3.14 |
| 133 | +- Strings: \"hello\" |
| 134 | +- Keywords: :keyword, ::namespaced |
| 135 | +- Collections: [1 2 3], {:a 1}, #{:a :b} |
| 136 | +- Function calls: (println \"hello\") |
| 137 | +- Special forms: (if true 1 2) |
| 138 | +
|
| 139 | +WARNING: The following are NOT valid Clojure expressions and will cause errors: |
| 140 | +- Incomplete forms: (defn foo, (try, (let [x 1] |
| 141 | +- Partial function definitions: (defn foo [x] |
| 142 | +- Just the opening of a form: (if condition |
| 143 | +- Mixed data without collection: :a 1 :b 2 |
| 144 | +- Unmatched parentheses: (+ 1 2)) |
| 145 | +
|
| 146 | +COMMON APPLICATIONS: |
| 147 | +- Renaming symbols throughout the file: |
| 148 | + match_form: old-name |
| 149 | + new_form: new-name |
| 150 | + replace_all: true |
| 151 | +
|
| 152 | +- Replacing multiple expressions with a single form: |
| 153 | + match_form: (validate x) (transform x) (save x) |
| 154 | + new_form: (-> x validate transform save) |
| 155 | +
|
| 156 | +- Wrapping code in try-catch: |
| 157 | + match_form: (risky-op-1) (risky-op-2) |
| 158 | + new_form: (try |
| 159 | + (risky-op-1) |
| 160 | + (risky-op-2) |
| 161 | + (catch Exception e |
| 162 | + (log/error e \"Operations failed\"))) |
| 163 | +
|
| 164 | +- Removing debug statements: |
| 165 | + match_form: (println \"Debug 1\") (println \"Debug 2\") |
| 166 | + new_form: |
| 167 | +
|
| 168 | +- Converting imperative style to functional: |
| 169 | + match_form: (def result (calculate x)) (println result) result |
| 170 | + new_form: (doto (calculate x) println) |
| 171 | +
|
| 172 | +- Transforming let bindings: |
| 173 | + match_form: [x (get-value) y (process x)] |
| 174 | + new_form: [x (get-value) |
| 175 | + _ (log/debug \"got value\" x) |
| 176 | + y (process x)] |
| 177 | +
|
| 178 | +Other Examples: |
| 179 | +- Replace a calculation: |
| 180 | + match_form: (+ x 2) |
| 181 | + new_form: (* x 2) |
| 182 | +
|
| 183 | +- Clean up code by removing intermediate steps: |
| 184 | + match_form: (let [temp (process x)] (use temp)) |
| 185 | + new_form: (use (process x)) |
| 186 | +
|
| 187 | +- Change function calls: |
| 188 | + match_form: (println \"Processing\" x) |
| 189 | + new_form: (log/info \"Processing item\" x) |
| 190 | +
|
| 191 | +Returns a diff showing the changes made to the file."}}} |
0 commit comments