From 4eaa13a7fb48425f11c8335f07244886b4cf6665 Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Tue, 29 Jul 2025 16:05:24 +0200 Subject: [PATCH] chore: fix homedir --- internal/fsext/ls.go | 2 +- internal/llm/tools/ls.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/fsext/ls.go b/internal/fsext/ls.go index a9ff2a6645d6531fc0037b1fe1a87563abdc3a85..2c08fd1c294cd35e8dfc436e8272004b68098b68 100644 --- a/internal/fsext/ls.go +++ b/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 } diff --git a/internal/llm/tools/ls.go b/internal/llm/tools/ls.go index 2a14c7b667a41ece209c11149254fa1a3da03e3e..559758c05c97e6540b8c63053a58ba2ee682d9a4 100644 --- a/internal/llm/tools/ls.go +++ b/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) }