File tree Expand file tree Collapse file tree 6 files changed +36
-9
lines changed
Expand file tree Collapse file tree 6 files changed +36
-9
lines changed Original file line number Diff line number Diff line change 33## Unreleased
44
55- Fix custom tools to support argument numbers.
6+ - Improve read_file summary to mention offset being read.
67
78## 0.84.2
89
Original file line number Diff line number Diff line change 11## Project Environment Context
22
3- Workspaces: {workspaceRoots}
3+ Workspaces: {{ workspaceRoots} }
44
55** Path Resolution & Context:**
66* Workspaces:* Directories containing code or data relevant to this session.
Original file line number Diff line number Diff line change 3535(defn ^:private replace-vars [s vars]
3636 (reduce
3737 (fn [p [k v]]
38- (string/replace p (str " {" (name k) " }" ) (str v)))
38+ (string/replace p (str " {{ " (name k) " } }" ) (str v)))
3939 s
4040 vars))
4141
Original file line number Diff line number Diff line change 33 eca native tools and MCP servers."
44 (:require
55 [clojure.string :as string]
6+ [clojure.walk :as walk]
67 [eca.features.tools.chat :as f.tools.chat]
78 [eca.features.tools.custom :as f.tools.custom]
89 [eca.features.tools.editor :as f.tools.editor]
3839 (fn [tool]
3940 (assoc-some tool :disabled (contains? disabled-tools (:name tool))))))
4041
42+ (defn ^:private replace-string-values-with-vars
43+ " walk through config parsing dynamic string contents if value is a string."
44+ [m vars]
45+ (walk/postwalk
46+ (fn [x]
47+ (if (string? x)
48+ (reduce
49+ (fn [s [k v]]
50+ (string/replace s (str " {{" (name k) " }}" ) (str v)))
51+ x
52+ vars)
53+ x))
54+ m))
55+
4156(defn ^:private native-definitions [db config]
4257 (into
4358 {}
4459 (map (fn [[name tool]]
4560 [name (-> tool
4661 (assoc :name name)
47- (update :description #(-> %
48- (string/replace #"\{ workspaceRoots\} " (constantly (tools.util/workspace-roots-strs db))))))]))
62+ (replace-string-values-with-vars
63+ {:workspaceRoots (tools.util/workspace-roots-strs db)
64+ :readFileMaxLines (get-in config [:toolCall :readFile :maxLines ])}))]))
4965 (merge {}
5066 f.tools.filesystem/definitions
5167 f.tools.shell/definitions
Original file line number Diff line number Diff line change 7070 [" path" (complement fs/directory?) " $path is a directory, not a file" ]]))
7171 (let [line-offset (or (get arguments " line_offset" ) 0 )
7272 limit (->> [(get arguments " limit" )
73- (get-in config [:toolCall :readFile :maxLines ] 2000 )]
73+ (get-in config [:toolCall :readFile :maxLines ])]
7474 (filter number?)
7575 (apply min))
7676 full-content-lines (string/split-lines (slurp (fs/file (fs/canonicalize (get arguments " path" )))))
8989 " parameter to read more content." )
9090 content)))))
9191
92- (defn ^:private read-file-summary [{:keys [args]}]
92+ (defn ^:private read-file-summary [{:keys [args config ]}]
9393 (if-let [path (get args " path" )]
94- (str " Reading file " (fs/file-name (fs/file path)))
94+ (let [line-offset (get args " line_offset" 0 )
95+ limit (get args " limit" (get-in config [:toolCall :readFile :maxLines ]))
96+ sub-read (or line-offset limit)]
97+ (format " Reading file %s %s"
98+ (fs/file-name (fs/file path))
99+ (str
100+ (when sub-read
101+ (format " (%s-%s)"
102+ line-offset
103+ limit))
104+ )))
95105 " Reading file" ))
96106
97107(defn ^:private write-file [arguments _]
321331 " line_offset" {:type " integer"
322332 :description " Line to start reading from (default: 0)" }
323333 " limit" {:type " integer"
324- :description " Maximum lines to read (default: configured in tools.readFile.maxLines, defaults to 2000 )" }}
334+ :description " Maximum lines to read (default: {{readFileMaxLines}} )" }}
325335 :required [" path" ]}
326336 :handler #'read-file
327337 :require-approval-fn (tools.util/require-approval-when-outside-workspace [" path" ])
Original file line number Diff line number Diff line change 6161 :description (format " Only in %s" (h/file-path " /path/to/project/foo" ))
6262 :parameters some?
6363 :origin :native }])
64- (with-redefs [f.tools.filesystem/definitions {" directory_tree" {:description " Only in {workspaceRoots}"
64+ (with-redefs [f.tools.filesystem/definitions {" directory_tree" {:description " Only in {{ workspaceRoots} }"
6565 :parameters {}}}]
6666 (f.tools/all-tools " 123" " agent" {:workspace-folders [{:name " foo" :uri (h/file-uri " file:///path/to/project/foo" )}]}
6767 {}))))))
You can’t perform that action at this time.
0 commit comments