MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / list_dir

Method list_dir

core/filesystem.py:380–412  ·  view source on GitHub ↗

List directory contents. Args: path: Directory path (default: workspace root) Returns: List of file/directory names Raises: FilesystemAccessError: If directory cannot be listed

(self, path: Union[str, Path] = ".")

Source from the content-addressed store, hash-verified

378 return False
379
380 def list_dir(self, path: Union[str, Path] = ".") -> List[str]:
381 """
382 List directory contents.
383
384 Args:
385 path: Directory path (default: workspace root)
386
387 Returns:
388 List of file/directory names
389
390 Raises:
391 FilesystemAccessError: If directory cannot be listed
392 """
393 try:
394 path = self._validate_path(path)
395
396 if not path.is_dir():
397 raise FilesystemAccessError(f"Not a directory: {path}")
398
399 entries = [e.name for e in path.iterdir()]
400 entries.sort()
401
402 try:
403 rel = path.relative_to(self.workspace)
404 except ValueError:
405 rel = path
406 info(f"Listed {rel} ({len(entries)} entries)")
407 return entries
408
409 except FilesystemAccessError:
410 raise
411 except Exception as e:
412 raise FilesystemAccessError(f"Failed to list {path}: {e}")
413
414 def _generate_diff(self, filename: str, old_lines: List[str], new_lines: List[str]) -> str:
415 """Generate unified diff between old and new content."""

Callers 1

tool_list_dirFunction · 0.80

Calls 4

_validate_pathMethod · 0.95
infoFunction · 0.90
is_dirMethod · 0.80

Tested by

no test coverage detected