Skip to content

Commit ab6ba84

Browse files
committed
fix: handle "." path in list_directory for both local and GitHub backends
LLMs naturally call list_dir(".") to list root directory. Previously sanitize_path rejected "." as invalid. Now ".", "./" and "/" are treated as root (same as empty string) in list_directory. Agent-Id: agent-01069cef-6b08-41f1-a15d-29feb2ccaea1
1 parent 3315221 commit ab6ba84

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

npx/python/cli/local_repo_tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ async def list_directory(self, path: str = "") -> list[dict[str, Any]]:
101101
102102
Returns structured entries: [{path, type, size}]
103103
"""
104-
abs_path = self._resolve_path(path) if path else self.root_path
104+
# Treat ".", "./", "/" same as "" (root directory)
105+
abs_path = self._resolve_path(path) if path and path.strip() not in (".", "./", "/") else self.root_path
105106
if abs_path is None:
106107
return [{"error": "invalid path"}]
107108

npx/python/cli/repo_tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ async def list_directory(self, path: str = "") -> list[dict[str, Any]]:
219219
220220
Returns structured entries: [{path, type, size}]
221221
"""
222-
clean_path = sanitize_path(path) if path else ""
222+
# Treat ".", "./", "/" same as "" (root directory)
223+
clean_path = sanitize_path(path) if path and path.strip() not in (".", "./", "/") else ""
223224
if clean_path is None:
224225
return [{"error": "invalid path"}]
225226

0 commit comments

Comments
 (0)