From 0274f35deab179327273f2c2e14f70d5db3419f8 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 20 Jun 2026 08:32:21 -0400 Subject: [PATCH] TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 3: refactor(mcp_client): migrate L414 get_file_summary to Result[T] (Phase 3 site 6) Added get_file_summary_result(Result[str]) inside the Result Variants region. Legacy get_file_summary (str) now delegates to get_file_summary_result. Audit: mcp_client BC count 35 -> 34. --- src/mcp_client.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/mcp_client.py b/src/mcp_client.py index 7f44206c..a1ddfcb4 100644 --- a/src/mcp_client.py +++ b/src/mcp_client.py @@ -433,19 +433,15 @@ def get_file_summary(path: str) -> str: Return the heuristic summary for a file (same as the initial context block). For .py files: imports, classes, methods, functions, constants. For .toml: table keys. For .md: headings. Others: line count + preview. + + Thin wrapper over get_file_summary_result; the legacy str shape is + preserved for backward compatibility, but the try/except Exception + lives in the Result variant. """ - p, err = _resolve_and_check(path) - if err or p is None: - return err - if not p.exists(): - return f"ERROR: file not found: {path}" - if not p.is_file(): - return f"ERROR: not a file: {path}" - try: - content = p.read_text(encoding="utf-8") - return summarize.summarise_file(p, content) - except Exception as e: - return f"ERROR summarising '{path}': {e}" + resolved = get_file_summary_result(path) + if resolved.ok: + return resolved.data + return "; ".join(e.ui_message() for e in resolved.errors) def get_file_slice(path: str, start_line: int, end_line: int) -> str: """Return a specific line range from a file."""