From 9ffa58723de56761baef45b595f0a9e48266aa6d Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 14 Oct 2025 16:15:51 -0300 Subject: [PATCH] fix(ls): properly handle limits (#1230) Signed-off-by: Carlos Alexandro Becker --- internal/config/config.go | 4 ++-- internal/llm/tools/ls.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index b37b98cad717e789ad16237b3ca250a2f1555ba9..ff948b874ea1613ca126053547dcf9b7d4cc3297 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -143,7 +143,7 @@ type Completions struct { } func (c Completions) Limits() (depth, items int) { - return ptrValOr(c.MaxDepth, -1), ptrValOr(c.MaxItems, -1) + return ptrValOr(c.MaxDepth, 0), ptrValOr(c.MaxItems, 0) } type Permissions struct { @@ -269,7 +269,7 @@ type ToolLs struct { } func (t ToolLs) Limits() (depth, items int) { - return ptrValOr(t.MaxDepth, -1), ptrValOr(t.MaxItems, -1) + return ptrValOr(t.MaxDepth, 0), ptrValOr(t.MaxItems, 0) } // Config holds the configuration for crush. diff --git a/internal/llm/tools/ls.go b/internal/llm/tools/ls.go index 305f7f10249594ff06ac008a8bf81145d7d834de..af25259dd8c69ff8d52d467e20532612681b51b1 100644 --- a/internal/llm/tools/ls.go +++ b/internal/llm/tools/ls.go @@ -157,7 +157,7 @@ func ListDirectoryTree(searchPath string, params LSParams) (string, LSResponseMe ls := config.Get().Tools.Ls depth, limit := ls.Limits() - maxFiles := min(limit, maxLSFiles) + maxFiles := cmp.Or(limit, maxLSFiles) files, truncated, err := fsext.ListDirectory( searchPath, params.Ignore,