Explorar o código

fix(ls): properly handle limits (#1230)

Signed-off-by: Carlos Alexandro Becker <[email protected]>
Carlos Alexandro Becker hai 4 meses
pai
achega
9ffa58723d
Modificáronse 2 ficheiros con 3 adicións e 3 borrados
  1. 2 2
      internal/config/config.go
  2. 1 1
      internal/llm/tools/ls.go

+ 2 - 2
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.

+ 1 - 1
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,