Skip to content

Commit 9cbc07a

Browse files
committed
Support compactPromptFile config
1 parent 10f8b19 commit 9cbc07a

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

docs/configuration.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ ECA allows to totally customize the prompt sent to LLM via the `behavior` config
419419
}};
420420
defaultBehavior?: string;
421421
welcomeMessage?: string;
422+
compactPromptFile?: string;
422423
index?: {
423424
ignoreFiles: [{
424425
type: string;
@@ -480,8 +481,9 @@ ECA allows to totally customize the prompt sent to LLM via the `behavior` config
480481
".*-c\\s+[\"'].*open.*[\"']w[\"'].*",
481482
".*bash.*-c.*>.*"]}}}}}}
482483
}
483-
"defaultBehavior": "agent"
484-
"welcomeMessage" : "Welcome to ECA!\n\nType '/' for commands\n\n"
484+
"defaultBehavior": "agent",
485+
"welcomeMessage" : "Welcome to ECA!\n\nType '/' for commands\n\n",
486+
"compactPromptFile": "prompts/compact.md",
485487
"index" : {
486488
"ignoreFiles" : [ {
487489
"type" : "gitignore"

src/eca/config.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
:lspTimeoutSeconds 30
9191
:mcpServers {}
9292
:welcomeMessage "Welcome to ECA!\n\nType '/' for commands\n\n"
93+
:compactPromptFile "prompts/compact.md"
9394
:index {:ignoreFiles [{:type :gitignore}]
9495
:repoMap {:maxTotalEntries 800
9596
:maxEntriesPerDir 50}}})

src/eca/features/commands.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
:role :system
191191
:content (merge {:type :usage}
192192
usage)})))
193-
:prompt (f.prompt/compact-prompt (string/join " " args))})
193+
:prompt (f.prompt/compact-prompt (string/join " " args) config)})
194194
"login" (do (f.login/handle-step {:message (or (first args) "")
195195
:chat-id chat-id}
196196
db*

src/eca/features/prompt.clj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(ns eca.features.prompt
22
(:require
3+
[babashka.fs :as fs]
34
[clojure.java.io :as io]
45
[clojure.string :as string]
56
[eca.features.tools.mcp :as f.mcp]
@@ -21,7 +22,11 @@
2122
(defn ^:private init-prompt-template* [] (slurp (io/resource "prompts/init.md")))
2223
(def ^:private init-prompt-template (memoize init-prompt-template*))
2324

24-
(defn ^:private compact-prompt-template* [] (slurp (io/resource "prompts/compact.md")))
25+
(defn ^:private compact-prompt-template* [file-path]
26+
(if (fs/relative? file-path)
27+
(slurp (io/resource file-path))
28+
(slurp (io/file file-path))))
29+
2530
(def ^:private compact-prompt-template (memoize compact-prompt-template*))
2631

2732
(defn ^:private replace-vars [s vars]
@@ -87,9 +92,9 @@
8792
(init-prompt-template)
8893
{:workspaceFolders (string/join ", " (map (comp shared/uri->filename :uri) (:workspace-folders db)))}))
8994

90-
(defn compact-prompt [additional-input]
95+
(defn compact-prompt [additional-input config]
9196
(replace-vars
92-
(compact-prompt-template)
97+
(compact-prompt-template (:compactPromptFile config))
9398
{:addionalUserInput (if additional-input
9499
(format "You MUST respect this user input in the summarization: %s." additional-input)
95100
"")}))

0 commit comments

Comments
 (0)