Skip to content

Commit 003c272

Browse files
committed
Fix system prompt to mention the user workspace roots.
1 parent 6ae7c7f commit 003c272

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Fix absolute paths being interpreted as commands. #199
66
- Remove non used sync models code during initialize. #100
7+
- Fix system prompt to mention the user workspace roots.
78

89
## 0.78.4
910

resources/prompts/agent_behavior.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
You are ECA (Editor Code Assistant), an AI coding assistant that operates on an editor.
22

33
You are pair programming with a USER to solve their coding task. Each time the USER sends a message, we may automatically attach some context information about their current state, such as passed contexts, rules defined by USER, project structure, and more. This information may or may not be relevant to the coding task, it is up for you to decide.
4+
The user workspace root(s) are: {workspaceRoots}
45

56
You are an agent - please keep going until the user's query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability before coming back to the user.
67

src/eca/features/chat.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,8 @@
973973
rules
974974
repo-map*
975975
selected-behavior
976-
config)
976+
config
977+
db)
977978
image-contents (->> refined-contexts
978979
(filter #(= :image (:type %))))
979980
expanded-prompt-contexts (when-let [contexts-str (some-> (f.context/contexts-str-from-prompt message db)

src/eca/features/prompt.clj

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,27 @@
3939
s
4040
vars))
4141

42-
(defn ^:private eca-chat-prompt [behavior config]
42+
(defn ^:private eca-chat-prompt [behavior config db]
4343
(let [behavior-config (get-in config [:behavior behavior])
4444
;; Use systemPromptFile from behavior config, or fall back to built-in
4545
prompt-file (or (:systemPromptFile behavior-config)
4646
;; For built-in behaviors without explicit config
4747
(when (#{"agent" "plan"} behavior)
4848
(str "prompts/" behavior "_behavior.md")))]
49-
(cond
50-
;; Custom behavior with absolute path
51-
(and prompt-file (string/starts-with? prompt-file "/"))
52-
(slurp prompt-file)
49+
(replace-vars
50+
(cond
51+
;; Custom behavior with absolute path
52+
(and prompt-file (string/starts-with? prompt-file "/"))
53+
(slurp prompt-file)
5354

54-
;; Built-in or resource path
55-
prompt-file
56-
(load-builtin-prompt (some-> prompt-file (string/replace-first #"prompts/" "")))
55+
;; Built-in or resource path
56+
prompt-file
57+
(load-builtin-prompt (some-> prompt-file (string/replace-first #"prompts/" "")))
5758

58-
;; Fallback for unknown behavior
59-
:else
60-
(load-builtin-prompt "agent_behavior.md"))))
59+
;; Fallback for unknown behavior
60+
:else
61+
(load-builtin-prompt "agent_behavior.md"))
62+
{:workspaceRoots (shared/workspaces-as-str db)})))
6163

6264
(defn contexts-str [refined-contexts repo-map*]
6365
(multi-str
@@ -87,9 +89,9 @@
8789
refined-contexts)
8890
"</contexts>"))
8991

90-
(defn build-chat-instructions [refined-contexts rules repo-map* behavior config]
92+
(defn build-chat-instructions [refined-contexts rules repo-map* behavior config db]
9193
(multi-str
92-
(eca-chat-prompt behavior config)
94+
(eca-chat-prompt behavior config db)
9395
(when (seq rules)
9496
["<rules description=\"Rules defined by user\">\n"
9597
(reduce

test/eca/features/prompt_test.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
(:require
33
[clojure.string :as string]
44
[clojure.test :refer [deftest is testing]]
5-
[eca.features.prompt :as prompt]))
5+
[eca.features.prompt :as prompt]
6+
[eca.test-helper :as h]))
67

78
(deftest build-instructions-test
89
(testing "Should create instructions with rules, contexts, and behavior"
@@ -14,7 +15,7 @@
1415
{:name "rule2" :content "Second rule"}]
1516
fake-repo-map (delay "TREE")
1617
behavior "agent"
17-
result (prompt/build-chat-instructions refined-contexts rules fake-repo-map behavior {})]
18+
result (prompt/build-chat-instructions refined-contexts rules fake-repo-map behavior {} (h/db))]
1819
(is (string/includes? result "You are ECA"))
1920
(is (string/includes? result "<rules description=\"Rules defined by user\">"))
2021
(is (string/includes? result "<rule name=\"rule1\">First rule</rule>"))
@@ -35,7 +36,7 @@
3536
{:name "rule2" :content "Second rule"}]
3637
fake-repo-map (delay "TREE")
3738
behavior "plan"
38-
result (prompt/build-chat-instructions refined-contexts rules fake-repo-map behavior {})]
39+
result (prompt/build-chat-instructions refined-contexts rules fake-repo-map behavior {} (h/db))]
3940
(is (string/includes? result "You are ECA"))
4041
(is (string/includes? result "<rules description=\"Rules defined by user\">"))
4142
(is (string/includes? result "<rule name=\"rule1\">First rule</rule>"))

0 commit comments

Comments
 (0)