on main help sign in
fix(ls): properly handle limits (#1230)

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

commit9ffa58723de56761baef45b595f0a9e48266aa6d authorCarlos Alexandro Becker <caarlos0@users.noreply.github.com> dateTue 14 Oct 2025, 16:15 (1 year ago) parent3fc3ec7
2 files changed+3−3
internal/config/config.go+2−2 internal/llm/tools/ls.go+1−1
internal/config/config.go+2−2
@@ -143,7 +143,7 @@ type Completions struct {
143143}
144144
145145func (c Completions) Limits() (depth, items int) {
146− return ptrValOr(c.MaxDepth, -1), ptrValOr(c.MaxItems, -1)
146+ return ptrValOr(c.MaxDepth, 0), ptrValOr(c.MaxItems, 0)
147147}
148148
149149type Permissions struct {
@@ -269,7 +269,7 @@ type ToolLs struct {
269269}
270270
271271func (t ToolLs) Limits() (depth, items int) {
272− return ptrValOr(t.MaxDepth, -1), ptrValOr(t.MaxItems, -1)
272+ return ptrValOr(t.MaxDepth, 0), ptrValOr(t.MaxItems, 0)
273273}
274274
275275// Config holds the configuration for crush.
internal/llm/tools/ls.go+1−1
@@ -157,7 +157,7 @@ func ListDirectoryTree(searchPath string, params LSParams) (string, LSResponseMe
157157
158158 ls := config.Get().Tools.Ls
159159 depth, limit := ls.Limits()
160− maxFiles := min(limit, maxLSFiles)
160+ maxFiles := cmp.Or(limit, maxLSFiles)
161161 files, truncated, err := fsext.ListDirectory(
162162 searchPath,
163163 params.Ignore,