on main help sign in
fix(ls): properly handle limits (#1230)
9ffa587Carlos Alexandro Becker
internal/config/config.go+2−2
@@ -143,7 +143,7 @@ type Completions struct {
143}
143}
144
144
145func (c Completions) Limits() (depth, items int) {
145func (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)
147}
147}
148
148
149type Permissions struct {
149type Permissions struct {
@@ -269,7 +269,7 @@ type ToolLs struct {
269}
269}
270
270
271func (t ToolLs) Limits() (depth, items int) {
271func (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)
273}
273}
274
274
275// Config holds the configuration for crush.
275// 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
157
157
158 ls := config.Get().Tools.Ls
158 ls := config.Get().Tools.Ls
159 depth, limit := ls.Limits()
159 depth, limit := ls.Limits()
160− maxFiles := min(limit, maxLSFiles)
160+ maxFiles := cmp.Or(limit, maxLSFiles)
161 files, truncated, err := fsext.ListDirectory(
161 files, truncated, err := fsext.ListDirectory(
162 searchPath,
162 searchPath,
163 params.Ignore,
163 params.Ignore,