refactor(indentation): Apply codebase-wide 1-space ultra-compact refactor. Formatted 21 core modules and tests.

This commit is contained in:
2026-02-28 19:36:38 -05:00
parent 8bfc41ddba
commit 173ea96fb4
21 changed files with 917 additions and 930 deletions

View File

@@ -2,13 +2,11 @@ import os
import re
with open('mcp_client.py', 'r', encoding='utf-8') as f:
content: str = f.read()
# 1. Add import os if not there
content: str = f.read()
# 1. Add import os if not there
if 'import os' not in content:
content: str = content.replace('import summarize', 'import os\nimport summarize')
# 2. Add the functions before "# ------------------------------------------------------------------ web tools"
content: str = content.replace('import summarize', 'import os\nimport summarize')
# 2. Add the functions before "# ------------------------------------------------------------------ web tools"
functions_code: str = r'''
def py_find_usages(path: str, name: str) -> str:
"""Finds exact string matches of a symbol in a given file or directory."""
@@ -184,11 +182,10 @@ content: str = content.replace('# ----------------------------------------------
# 3. Update TOOL_NAMES
old_tool_names_match: re.Match | None = re.search(r'TOOL_NAMES\s*=\s*\{([^}]*)\}', content)
if old_tool_names_match:
old_names: str = old_tool_names_match.group(1)
new_names: str = old_names + ', "py_find_usages", "py_get_imports", "py_check_syntax", "py_get_hierarchy", "py_get_docstring", "get_tree"'
content: str = content.replace(old_tool_names_match.group(0), f'TOOL_NAMES = {{{new_names}}}')
# 4. Update dispatch
old_names: str = old_tool_names_match.group(1)
new_names: str = old_names + ', "py_find_usages", "py_get_imports", "py_check_syntax", "py_get_hierarchy", "py_get_docstring", "get_tree"'
content: str = content.replace(old_tool_names_match.group(0), f'TOOL_NAMES = {{{new_names}}}')
# 4. Update dispatch
dispatch_additions: str = r'''
if tool_name == "py_find_usages":
return py_find_usages(tool_input.get("path", ""), tool_input.get("name", ""))
@@ -205,7 +202,7 @@ dispatch_additions: str = r'''
return f"ERROR: unknown MCP tool '{tool_name}'"
'''
content: str = re.sub(
r' return f"ERROR: unknown MCP tool \'{tool_name}\'"', dispatch_additions.strip(), content)
r' return f"ERROR: unknown MCP tool \'{tool_name}\'"', dispatch_additions.strip(), content)
# 5. Update MCP_TOOL_SPECS
mcp_tool_specs_addition: str = r'''
@@ -283,9 +280,9 @@ mcp_tool_specs_addition: str = r'''
'''
content: str = re.sub(
r'\]\s*$', mcp_tool_specs_addition.strip(), content)
r'\]\s*$', mcp_tool_specs_addition.strip(), content)
with open('mcp_client.py', 'w', encoding='utf-8') as f:
f.write(content)
f.write(content)
print("Injected new tools.")