Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Unreleased
- Improved file contexts: now use :lines-range

- BREAKING ECA now only supports standard plain-text netrc as credential file reading. Drop authinfo and gpg decryption support. Users can choose to pass in their own provisioned netrc file from various secure source with `:netrcFile` in ECA config.

Expand Down
2 changes: 1 addition & 1 deletion src/eca/features/context.clj
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
{:type :file
:path path
:content (llm-api/refine-file-context path lines-range)}
:partial (some? lines-range)))))
:lines-range lines-range))))

(defn raw-contexts->refined [contexts db]
(mapcat (fn [{:keys [type path lines-range position uri]}]
Expand Down
12 changes: 8 additions & 4 deletions src/eca/features/prompt.clj
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@

(defn contexts-str [refined-contexts repo-map*]
(multi-str
"<contexts description=\"Manually Provided by user. Their content is current and accurate. You MUST use this information first before using tools to read them.\">"
"<contexts description=\"User-Provided Snippet. This content is current and accurate. Treat this as sufficient context for answering the query.\">"
(reduce
(fn [context-str {:keys [type path position content partial uri]}]
(fn [context-str {:keys [type path position content lines-range uri]}]
(str context-str (case type
:file (if partial
(format "<file partial=true path=\"%s\">...\n%s\n...</file>\n" path content)
:file (if lines-range
(format "<file line-start=%s line-end=%s path=\"%s\">%s</file>\n"
(:start lines-range)
(:end lines-range)
path
content)
(format "<file path=\"%s\">%s</file>\n" path content))
:agents-file (multi-str
(format "<agents-file description=\"Instructions following AGENTS.md spec.\" path=\"%s\">" path)
Expand Down
4 changes: 2 additions & 2 deletions test/eca/features/context_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
(with-redefs [llm-api/refine-file-context (constantly "Some content")]
(is (match?
[{:type :file
:path "/path/to/file"
:partial true
:path (h/file-path "/path/to/file")
:lines-range {:start 1 :end 4}
:content "Some content"}]
(f.context/contexts-str-from-prompt "check @/path/to/file:L1-L4" (h/db)))))))
12 changes: 6 additions & 6 deletions test/eca/features/prompt_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
(deftest build-instructions-test
(testing "Should create instructions with rules, contexts, and behavior"
(let [refined-contexts [{:type :file :path "foo.clj" :content "(ns foo)"}
{:type :file :path "bar.clj" :content "(def a 1)" :partial true}
{:type :file :path "bar.clj" :content "(def a 1)" :lines-range {:start 1 :end 1}}
{:type :repoMap}
{:type :mcpResource :uri "custom://my-resource" :content "some-cool-content"}]
rules [{:name "rule1" :content "First rule"}
Expand All @@ -19,16 +19,16 @@
(is (string/includes? result "<rules description=\"Rules defined by user\">"))
(is (string/includes? result "<rule name=\"rule1\">First rule</rule>"))
(is (string/includes? result "<rule name=\"rule2\">Second rule</rule>"))
(is (string/includes? result "<contexts description=\"Manually Provided by user. Their content is current and accurate. You MUST use this information first before using tools to read them.\">"))
(is (string/includes? result "<contexts description=\"User-Provided Snippet. This content is current and accurate. Treat this as sufficient context for answering the query.\">"))
(is (string/includes? result "<file path=\"foo.clj\">(ns foo)</file>"))
(is (string/includes? result "<file partial=true path=\"bar.clj\">...\n(def a 1)\n...</file>"))
(is (string/includes? result "<file line-start=1 line-end=1 path=\"bar.clj\">(def a 1)</file>"))
(is (string/includes? result "<repoMap description=\"Workspaces structure in a tree view, spaces represent file hierarchy\" >TREE</repoMap>"))
(is (string/includes? result "<resource uri=\"custom://my-resource\">some-cool-content</resource>"))
(is (string/includes? result "</contexts>"))
(is (string? result))))
(testing "Should create instructions with rules, contexts, and plan behavior"
(let [refined-contexts [{:type :file :path "foo.clj" :content "(ns foo)"}
{:type :file :path "bar.clj" :content "(def a 1)" :partial true}
{:type :file :path "bar.clj" :content "(def a 1)" :lines-range {:start 1 :end 1}}
{:type :repoMap}
{:type :mcpResource :uri "custom://my-resource" :content "some-cool-content"}]
rules [{:name "rule1" :content "First rule"}
Expand All @@ -40,9 +40,9 @@
(is (string/includes? result "<rules description=\"Rules defined by user\">"))
(is (string/includes? result "<rule name=\"rule1\">First rule</rule>"))
(is (string/includes? result "<rule name=\"rule2\">Second rule</rule>"))
(is (string/includes? result "<contexts description=\"Manually Provided by user. Their content is current and accurate. You MUST use this information first before using tools to read them.\">"))
(is (string/includes? result "<contexts description=\"User-Provided Snippet. This content is current and accurate. Treat this as sufficient context for answering the query.\">"))
(is (string/includes? result "<file path=\"foo.clj\">(ns foo)</file>"))
(is (string/includes? result "<file partial=true path=\"bar.clj\">...\n(def a 1)\n...</file>"))
(is (string/includes? result "<file line-start=1 line-end=1 path=\"bar.clj\">(def a 1)</file>"))
(is (string/includes? result "<repoMap description=\"Workspaces structure in a tree view, spaces represent file hierarchy\" >TREE</repoMap>"))
(is (string/includes? result "<resource uri=\"custom://my-resource\">some-cool-content</resource>"))
(is (string/includes? result "</contexts>"))
Expand Down
Loading