Skip to content

Commit b782880

Browse files
author
Bruce Hauman
committed
Update cli-assist profiles: enable clojure_edit_replace_sexp and disable project info resource
- Remove clojure_edit_replace_sexp from disable-tools list in both profiles - Add fallback tool description for clojure_edit_replace_sexp (same pattern as clojure_edit) - Disable "Clojure Project Info" resource in both profiles
1 parent 4f52f2c commit b782880

2 files changed

Lines changed: 186 additions & 10 deletions

File tree

resources/clojure_mcp/configs/cli-assist-agent.edn

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
;; Enabled tools:
44
;; - clojure_eval (REPL evaluation)
55
;; - clojure_edit_agent (agent-based editing - fallback for Edit tool)
6+
;; - clojure_edit_replace_sexp (sexp replacement - fallback for Edit tool)
67
;; - list_nrepl_ports (discover running nREPL servers)
78
;;
89
;; Enabled resources:
9-
;; - clojure-project-info (deps.edn/project.clj analysis)
10+
;; (none)
1011

1112
{:disable-tools
1213
[:read_file
1314
:grep
1415
:glob_files
1516
:bash
16-
:clojure_edit_replace_sexp
1717
:file_edit
1818
:file_write
1919
:scratch_pad
@@ -38,11 +38,12 @@
3838
["PROJECT_SUMMARY.md"
3939
"README.md"
4040
"CLAUDE.md"
41-
"LLM_CODE_STYLE.md"]
41+
"LLM_CODE_STYLE.md"
42+
"Clojure Project Info"]
4243

4344
:write-file-guard false
4445

45-
:tools-config
46+
:tools-config
4647
{:clojure_edit_agent
4748
{:description
4849
"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
100101
;; ... rest of file ...
101102
```
102103
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."}}}

resources/clojure_mcp/configs/cli-assist.edn

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
;; Enabled tools:
44
;; - clojure_eval (REPL evaluation)
55
;; - clojure_edit (structural form editing - fallback for Edit tool)
6+
;; - clojure_edit_replace_sexp (sexp replacement - fallback for Edit tool)
67
;; - list_nrepl_ports (discover running nREPL servers)
78
;;
89
;; Enabled resources:
9-
;; - clojure-project-info (deps.edn/project.clj analysis)
10+
;; (none)
1011

1112
{:disable-tools
1213
[:read_file
1314
:grep
1415
:glob_files
1516
:bash
16-
:clojure_edit_replace_sexp
1717
:file_edit
1818
:file_write
1919
:scratch_pad
@@ -38,11 +38,12 @@
3838
["PROJECT_SUMMARY.md"
3939
"README.md"
4040
"CLAUDE.md"
41-
"LLM_CODE_STYLE.md"]
41+
"LLM_CODE_STYLE.md"
42+
"Clojure Project Info"]
4243

4344
:write-file-guard false
4445

45-
:tools-config
46+
:tools-config
4647
{:clojure_edit
4748
{:description
4849
"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).
@@ -107,4 +108,91 @@ Note: For `defmethod` forms, be sure to include the dispatch value (`area :recta
107108
- content: \"(def inches-per-foot 12)\"
108109
109110
The tool will find the form, perform the requested operation, and format the result.
110-
It returns a diff showing the changes made to the file."}}}
111+
It returns a diff showing the changes made to the file."}
112+
113+
:clojure_edit_replace_sexp
114+
{:description
115+
"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).
116+
117+
The Edit tool works 99% of the time and is preferred for its UI integration. Always try Edit first.
118+
119+
After using this tool to work around an Edit error, resume using the Edit tool for subsequent edits.
120+
121+
Replaces Clojure expressions in a file.
122+
123+
This tool provides targeted replacement of Clojure expressions within forms. For complete top-level form operations, use `clojure_edit` instead.
124+
125+
KEY BENEFITS:
126+
- Syntax-aware matching that understands Clojure code structure
127+
- Ignores whitespace differences by default, focusing on actual code meaning
128+
- Matches expressions regardless of formatting, indentation, or spacing
129+
- Prevents errors from mismatched text or irrelevant formatting differences
130+
- Can replace all occurrences with replace_all: true
131+
132+
CONSTRAINTS:
133+
- match_form must contain one or more complete Clojure expressions
134+
- new_form must contain zero or more complete Clojure expressions
135+
- Both match_form and new_form must be valid Clojure code that can be parsed
136+
137+
A complete Clojure expression is any form that Clojure can read as a complete unit:
138+
- Symbols: foo, my-var, clojure.core/map
139+
- Numbers: 42, 3.14
140+
- Strings: \"hello\"
141+
- Keywords: :keyword, ::namespaced
142+
- Collections: [1 2 3], {:a 1}, #{:a :b}
143+
- Function calls: (println \"hello\")
144+
- Special forms: (if true 1 2)
145+
146+
WARNING: The following are NOT valid Clojure expressions and will cause errors:
147+
- Incomplete forms: (defn foo, (try, (let [x 1]
148+
- Partial function definitions: (defn foo [x]
149+
- Just the opening of a form: (if condition
150+
- Mixed data without collection: :a 1 :b 2
151+
- Unmatched parentheses: (+ 1 2))
152+
153+
COMMON APPLICATIONS:
154+
- Renaming symbols throughout the file:
155+
match_form: old-name
156+
new_form: new-name
157+
replace_all: true
158+
159+
- Replacing multiple expressions with a single form:
160+
match_form: (validate x) (transform x) (save x)
161+
new_form: (-> x validate transform save)
162+
163+
- Wrapping code in try-catch:
164+
match_form: (risky-op-1) (risky-op-2)
165+
new_form: (try
166+
(risky-op-1)
167+
(risky-op-2)
168+
(catch Exception e
169+
(log/error e \"Operations failed\")))
170+
171+
- Removing debug statements:
172+
match_form: (println \"Debug 1\") (println \"Debug 2\")
173+
new_form:
174+
175+
- Converting imperative style to functional:
176+
match_form: (def result (calculate x)) (println result) result
177+
new_form: (doto (calculate x) println)
178+
179+
- Transforming let bindings:
180+
match_form: [x (get-value) y (process x)]
181+
new_form: [x (get-value)
182+
_ (log/debug \"got value\" x)
183+
y (process x)]
184+
185+
Other Examples:
186+
- Replace a calculation:
187+
match_form: (+ x 2)
188+
new_form: (* x 2)
189+
190+
- Clean up code by removing intermediate steps:
191+
match_form: (let [temp (process x)] (use temp))
192+
new_form: (use (process x))
193+
194+
- Change function calls:
195+
match_form: (println \"Processing\" x)
196+
new_form: (log/info \"Processing item\" x)
197+
198+
Returns a diff showing the changes made to the file."}}}

0 commit comments

Comments
 (0)