refactor(sdm): Global pass with refined 'External Only' SDM tags. Pruned redundant internal references and fixed indentation logic in injector. Verified full project compilation.

This commit is contained in:
2026-05-09 14:32:44 -04:00
parent 696c08692e
commit 8c06c1767b
142 changed files with 2352 additions and 990 deletions
+25 -1
View File
@@ -36,6 +36,9 @@ def parse_diff_header(line: str) -> tuple[Optional[str], Optional[str], Optional
return None, None, None
def parse_hunk_header(line: str) -> Optional[tuple[int, int, int, int]]:
"""
[C: tests/test_diff_viewer.py:test_parse_hunk_header]
"""
if not line.startswith("@@"):
return None
@@ -57,6 +60,9 @@ def parse_hunk_header(line: str) -> Optional[tuple[int, int, int, int]]:
return (old_start, old_count, new_start, new_count)
def parse_diff(diff_text: str) -> List[DiffFile]:
"""
[C: src/gui_2.py:App.request_patch_from_tier4, tests/test_diff_viewer.py:test_diff_line_classification, tests/test_diff_viewer.py:test_parse_diff_empty, tests/test_diff_viewer.py:test_parse_diff_none, tests/test_diff_viewer.py:test_parse_diff_with_context, tests/test_diff_viewer.py:test_parse_multiple_files, tests/test_diff_viewer.py:test_parse_simple_diff, tests/test_diff_viewer.py:test_render_diff_text_immediate]
"""
if not diff_text or not diff_text.strip():
return []
@@ -132,6 +138,9 @@ def format_diff_for_display(diff_files: List[DiffFile]) -> str:
return "\n".join(output)
def get_line_color(line: str) -> Optional[str]:
"""
[C: tests/test_diff_viewer.py:test_get_line_color]
"""
if line.startswith("+"):
return "green"
elif line.startswith("-"):
@@ -141,6 +150,9 @@ def get_line_color(line: str) -> Optional[str]:
return None
def render_diff_text_immediate(diff_files: List[DiffFile]) -> List[tuple[str, Optional[str]]]:
"""
[C: tests/test_diff_viewer.py:test_render_diff_text_immediate]
"""
output: List[tuple[str, Optional[str]]] = []
for df in diff_files:
output.append((f"File: {df.old_path}", "white"))
@@ -152,6 +164,9 @@ def render_diff_text_immediate(diff_files: List[DiffFile]) -> List[tuple[str, Op
return output
def create_backup(file_path: str) -> Optional[str]:
"""
[C: tests/test_diff_viewer.py:test_create_backup, tests/test_diff_viewer.py:test_create_backup_nonexistent]
"""
path = Path(file_path)
if not path.exists():
return None
@@ -160,6 +175,9 @@ def create_backup(file_path: str) -> Optional[str]:
return str(backup_path)
def apply_patch_to_file(patch_text: str, base_dir: str = ".") -> Tuple[bool, str]:
"""
[C: src/gui_2.py:App._apply_pending_patch, tests/test_diff_viewer.py:test_apply_patch_simple, tests/test_diff_viewer.py:test_apply_patch_with_context]
"""
import difflib
diff_files = parse_diff(patch_text)
@@ -207,6 +225,9 @@ def apply_patch_to_file(patch_text: str, base_dir: str = ".") -> Tuple[bool, str
return True, "\n".join(results)
def restore_from_backup(file_path: str) -> bool:
"""
[C: tests/test_diff_viewer.py:test_restore_from_backup]
"""
backup_path = Path(str(file_path) + ".backup")
if not backup_path.exists():
return False
@@ -215,6 +236,9 @@ def restore_from_backup(file_path: str) -> bool:
return True
def cleanup_backup(file_path: str) -> None:
"""
[C: tests/test_diff_viewer.py:test_cleanup_backup]
"""
backup_path = Path(str(file_path) + ".backup")
if backup_path.exists():
backup_path.unlink()
backup_path.unlink()