Skip to content

Commit fccb968

Browse files
ericdalloeca-agent
andcommitted
Fix @mention regex to ignore email addresses in prompts
Tighten context-pattern regex to require the first character after @ to be /, ~, or . so only valid path references are captured. Previously, text like user@example.com would extract the domain as a context path, causing a URISyntaxException. Fixes #379 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca <git@eca.dev>
1 parent 7126ba9 commit fccb968

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Fix MCP OAuth browser not opening on Windows by using `cmd /c start` instead of `java.awt.Desktop`, which is unavailable in the native image.
77
- Improve server shutdown speed for remote MCP servers.
88
- Extract git/gh instructions from `shell_command` into a dedicated `git` tool with a condensed prompt, reducing per-turn token overhead.
9+
- Fix crash when `@` signs in prompts (e.g. email addresses) are misinterpreted as context mentions. #379
910

1011
## 0.117.1
1112

src/eca/features/context.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
Parse lines if present in contexts like @/path/to/file:L1-L4"
127127
[prompt db]
128128
(let [ ;; Capture @<path> with optional :L<start>-L<end>
129-
context-pattern #"@([^\s:]+)(?::L(\d+)-L(\d+))?"
129+
context-pattern #"@([/~\.][^\s:]+)(?::L(\d+)-L(\d+))?"
130130
matches (re-seq context-pattern prompt)
131131
raw-contexts (mapv (fn [[_ path s e]]
132132
(assoc-some {:type (if (fs/directory? path) "directory" "file")

test/eca/features/context_test.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@
343343
(is (match?
344344
nil
345345
(f.context/contexts-str-from-prompt "check /path/to/file" (h/db)))))
346+
(testing "email address is not a context mention"
347+
(is (match?
348+
nil
349+
(f.context/contexts-str-from-prompt "send email to user@example.com" (h/db)))))
346350
(testing "Context mention"
347351
(with-redefs [fs/readable? (constantly true)
348352
llm-api/refine-file-context (constantly "Some content")]

0 commit comments

Comments
 (0)