Kaynağa Gözat

chore: fix homedir

Kujtim Hoxha 8 ay önce
ebeveyn
işleme
4eaa13a7fb
2 değiştirilmiş dosya ile 9 ekleme ve 1 silme
  1. 1 1
      internal/fsext/ls.go
  2. 8 0
      internal/llm/tools/ls.go

+ 1 - 1
internal/fsext/ls.go

@@ -156,7 +156,7 @@ func ListDirectory(initialPath string, ignorePatterns []string, limit int) ([]st
 
 		return nil
 	})
-	if err != nil {
+	if err != nil && len(results) == 0 {
 		return nil, truncated, err
 	}
 

+ 8 - 0
internal/llm/tools/ls.go

@@ -121,6 +121,14 @@ func (l *lsTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error) {
 		searchPath = l.workingDir
 	}
 
+	if searchPath == "~" {
+		homeDir, err := os.UserHomeDir()
+		if err != nil {
+			return ToolResponse{}, fmt.Errorf("error resolving home directory: %w", err)
+		}
+		searchPath = homeDir
+	}
+
 	if !filepath.IsAbs(searchPath) {
 		searchPath = filepath.Join(l.workingDir, searchPath)
 	}