Skip to content

Commit 31d65c8

Browse files
committed
Improve system prompt to add project env context.
1 parent 307b91c commit 31d65c8

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Improve system prompt to add project env context.
6+
57
## 0.79.0
68

79
- Fix absolute paths being interpreted as commands. #199
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Project Environment Context
2+
3+
Workspaces: {workspaceRoots}
4+
5+
**Path Resolution & Context:**
6+
*Workspaces:* Directories containing code or data relevant to this session.
7+
*Rule:* Use Workspaces as the base to resolve relative paths into absolute paths when required by tools.
8+

resources/prompts/agent_behavior.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
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}
54

65
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.
76

src/eca/features/prompt.clj

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

42-
(defn ^:private eca-chat-prompt [behavior config db]
42+
(defn ^:private eca-chat-prompt [behavior config]
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-
(replace-vars
50-
(cond
51-
;; Custom behavior with absolute path
52-
(and prompt-file (string/starts-with? prompt-file "/"))
53-
(slurp prompt-file)
49+
(cond
50+
;; Custom behavior with absolute path
51+
(and prompt-file (string/starts-with? prompt-file "/"))
52+
(slurp prompt-file)
5453

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

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

6462
(defn contexts-str [refined-contexts repo-map*]
6563
(multi-str
@@ -91,7 +89,7 @@
9189

9290
(defn build-chat-instructions [refined-contexts rules repo-map* behavior config db]
9391
(multi-str
94-
(eca-chat-prompt behavior config db)
92+
(eca-chat-prompt behavior config)
9593
(when (seq rules)
9694
["<rules description=\"Rules defined by user\">\n"
9795
(reduce
@@ -102,7 +100,11 @@
102100
"</rules>"])
103101
""
104102
(when (seq refined-contexts)
105-
[(contexts-str refined-contexts repo-map*)])))
103+
[(contexts-str refined-contexts repo-map*)])
104+
""
105+
(replace-vars
106+
(load-builtin-prompt "additional_system_info.md")
107+
{:workspaceRoots (shared/workspaces-as-str db)})))
106108

107109
(defn build-rewrite-instructions [text path full-text range config]
108110
(let [prompt-file (-> config :rewrite :systemPromptFile)

0 commit comments

Comments
 (0)