diff --git a/src/mcp_client.py b/src/mcp_client.py index a79f7032..e2d39a66 100644 --- a/src/mcp_client.py +++ b/src/mcp_client.py @@ -209,29 +209,16 @@ def search_files(path: str, pattern: str) -> str: return "; ".join(e.ui_message() for e in resolved.errors) def list_directory(path: str) -> str: - """List entries in a directory. Returns a compact text table.""" - p, err = _resolve_and_check(path) - if err or p is None: - return err - if not p.exists(): return f"ERROR: path not found: {path}" - if not p.is_dir(): return f"ERROR: not a directory: {path}" - try: - entries = sorted(p.iterdir(), key=lambda e: (e.is_file(), e.name.lower())) - lines = [f"Directory: {p}", ""] - count = 0 - for entry in entries: - # Blacklist check - name = entry.name.lower() - if name == "history.toml" or name.endswith("_history.toml"): - continue - kind = "file" if entry.is_file() else "dir " - size = f"{entry.stat().st_size:>10,} bytes" if entry.is_file() else "" - lines.append(f" [{kind}] {entry.name:<40} {size}") - count += 1 - lines.append(f" ({count} entries)") - return "\n".join(lines) - except Exception as e: - return f"ERROR listing '{path}': {e}" + """List entries in a directory. Returns a compact text table. + + Thin wrapper over list_directory_result; the legacy str shape is + preserved for backward compatibility, but the try/except Exception + lives in the Result variant. + """ + resolved = list_directory_result(path) + if resolved.ok: + return resolved.data + return "; ".join(e.ui_message() for e in resolved.errors) def read_file(path: str) -> str: """Return the UTF-8 content of a file, or an error string."""