Skip to content

Commit 04fff6c

Browse files
committed
trim command summaries
1 parent a61ffb2 commit 04fff6c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/eca/features/tools/shell.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@
137137
(let [max-length (get-in config [:toolCall :shellCommand :summaryMaxLength])
138138
workspace-folders (:workspace-folders db)]
139139
(if-let [command (some-> (get args "command")
140-
(strip-workspace-cd-prefix workspace-folders))]
140+
(strip-workspace-cd-prefix workspace-folders)
141+
(string/replace #"\n" " ")
142+
string/trim)]
141143
(if (> (count command) max-length)
142144
(format "$ %s..." (subs command 0 max-length))
143145
(format "$ %s" command))

test/eca/features/tools/shell_test.clj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,14 @@
184184
(is (= (format "$ cd %s && clojure -M:test" (h/file-path "/project/foo"))
185185
(summary-fn {:args {"command" (str "cd " (h/file-path "/project/foo") " && clojure -M:test")}
186186
:config config
187-
:db nil}))))))
187+
:db nil}))))
188+
(testing "trims newlines in command"
189+
(is (= "$ echo hello && echo world"
190+
(summary-fn {:args {"command" "echo hello\n&& echo world"}
191+
:config config
192+
:db db}))))
193+
(testing "trims leading and trailing whitespace"
194+
(is (= "$ echo hello"
195+
(summary-fn {:args {"command" "\n echo hello \n"}
196+
:config config
197+
:db db}))))))

0 commit comments

Comments
 (0)