Skip to content

Commit dfd643c

Browse files
committed
Add machine info to prompt Environment Context section
Rename the "Project Environment Context" heading to "Environment Context" and add OS, default shell, username and home directory. These help with shell command syntax and path resolution and aren't reliably inferable by the model. Values are read from the host running ECA.
1 parent 5e49c46 commit dfd643c

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
## Unreleased
44

5-
- Prompt now renders context as labeled `## Static Contexts` and `## Dynamic Contexts` sections, with Project Environment Context no longer wedged between them.
5+
- Prompt now renders context as labeled `## Static Contexts` and `## Dynamic Contexts` sections, with Environment Context no longer wedged between them.
6+
- System prompt's Environment Context section now includes OS, default shell, username and home directory.
67

78
## 0.136.1
89

resources/prompts/additional_system_info.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
## Project Environment Context
1+
## Environment Context
22

3+
OS: {{osName}}
4+
Default shell: {{shell}}
5+
User: {{userName}}
6+
Home directory: {{homeDir}}
37
Workspaces: {{workspaceRoots}}
48

59
**Path Resolution & Context:**

src/eca/features/prompt.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@
9999
([all-tools chat-id db]
100100
(merge
101101
{:workspaceRoots (shared/workspaces-as-str db)
102+
:osName (str (System/getProperty "os.name") " " (System/getProperty "os.version"))
103+
:shell (or (System/getenv "SHELL") (System/getenv "ComSpec"))
104+
:userName (System/getProperty "user.name")
105+
:homeDir (System/getProperty "user.home")
102106
:isSubagent (boolean (get-in db [:chats chat-id :subagent]))}
103107
(reduce
104108
(fn [m tool]

test/eca/features/prompt_test.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@
164164
(is (= "static" (prompt/instructions->str {:static "static" :dynamic nil})))))
165165

166166
(deftest build-instructions-context-sections-ordering-test
167-
(testing "Static contexts are labeled and rendered after Project Environment Context"
167+
(testing "Static contexts are labeled and rendered after Environment Context"
168168
(let [refined-contexts [{:type :file :path "foo.clj" :content "(ns foo)"}]
169169
{:keys [static]} (build-instructions refined-contexts [] [] [] (delay "TREE") "code" {} nil [] (h/db))]
170170
(is (string/includes? static "## Static Contexts"))
171-
(is (string/includes? static "## Project Environment Context"))
172-
(is (< (string/index-of static "## Project Environment Context")
171+
(is (string/includes? static "## Environment Context"))
172+
(is (< (string/index-of static "## Environment Context")
173173
(string/index-of static "## Static Contexts")))))
174174
(testing "Static contexts come before Dynamic contexts in the flattened prompt"
175175
(let [refined-contexts [{:type :file :path "foo.clj" :content "(ns foo)"}

0 commit comments

Comments
 (0)