Skip to content

The agent that grows with you

fix: read text files with encoding=utf-8-sig in modules merged from main

ethernet119bc61c3b8a
diff --git a/hermes_cli/plugin_validate_desktop.py b/hermes_cli/plugin_validate_desktop.py
index 177bc6f33cb..17e19fe3777 100644
--- a/hermes_cli/plugin_validate_desktop.py
+++ b/hermes_cli/plugin_validate_desktop.py
@@ -50,7 +50,7 @@ def check_desktop_surface(report, plugin_dir: Path) -> None:
hits: List[str] = []
for js in sorted(desktop.rglob("*.js")):
try:
- source = js.read_text(encoding="utf-8", errors="replace")
+ source = js.read_text(encoding="utf-8-sig", errors="replace")
except OSError:
continue
rel = js.relative_to(plugin_dir).as_posix()
diff --git a/scripts/check_no_tmp_literals.py b/scripts/check_no_tmp_literals.py
index 892c94acf09..a7cfc485ee7 100644
--- a/scripts/check_no_tmp_literals.py
+++ b/scripts/check_no_tmp_literals.py
@@ -204,7 +204,7 @@ def scan(paths=None, root: Path | None = None) -> dict[str, list[tuple[int, str]
if paths and _skip_file(path):
continue
try:
- text = path.read_text(encoding="utf-8", errors="ignore")
+ text = path.read_text(encoding="utf-8-sig", errors="ignore")
except OSError:
continue
found = list(_iter_lines_with_hits(text, path.suffix))
diff --git a/tools/plugin_guard.py b/tools/plugin_guard.py
index 70133beb673..8851c64cc7b 100644
--- a/tools/plugin_guard.py
+++ b/tools/plugin_guard.py
@@ -205,7 +205,7 @@ def _comment_severity(f: Finding) -> str:
def _file_lines(file_path: Path) -> List[str]:
"""Full source lines (``Finding.match`` is truncated to 120 chars); unreadable → []."""
try:
- return file_path.read_text(encoding="utf-8").split("\n")
+ return file_path.read_text(encoding="utf-8-sig").split("\n")
except (OSError, UnicodeDecodeError):
return []
diff --git a/tools/skill_ledger.py b/tools/skill_ledger.py
index 03516481d02..c5099867a98 100644
--- a/tools/skill_ledger.py
+++ b/tools/skill_ledger.py
@@ -337,7 +337,7 @@ def gc_blobs() -> Tuple[int, int]:
return 0, 0
referenced: set = set()
try:
- lines = ledger_path().read_text(encoding="utf-8").splitlines()
+ lines = ledger_path().read_text(encoding="utf-8-sig").splitlines()
except OSError:
lines = []
for line in lines: