(self, params: dict[str, Any])
| 40 | } |
| 41 | |
| 42 | def execute(self, params: dict[str, Any]) -> ToolResult: |
| 43 | pattern = params["pattern"] |
| 44 | directory = Path(params.get("directory", ".")).expanduser().resolve() |
| 45 | |
| 46 | if not directory.is_dir(): |
| 47 | return ToolResult(output=f"Error: directory not found: {directory}", is_error=True) |
| 48 | |
| 49 | if not pattern.startswith("**/") and "/" not in pattern: |
| 50 | pattern = f"**/{pattern}" |
| 51 | |
| 52 | try: |
| 53 | matches = sorted(directory.glob(pattern), key=lambda p: p.stat().st_mtime, reverse=True) |
| 54 | except Exception as exc: |
| 55 | return ToolResult(output=f"Error: {exc}", is_error=True) |
| 56 | |
| 57 | if not matches: |
| 58 | return ToolResult(output="No files matched.") |
| 59 | |
| 60 | lines = [str(p) for p in matches[:MAX_RESULTS]] |
| 61 | if len(matches) > MAX_RESULTS: |
| 62 | lines.append(f"... and {len(matches) - MAX_RESULTS} more") |
| 63 | return ToolResult(output="\n".join(lines)) |
nothing calls this directly
no test coverage detected