From 92819ca980f9be28a448b171c82c2fc11bb87702 Mon Sep 17 00:00:00 2001 From: AlexFucuson9 Date: Thu, 16 Jul 2026 14:24:36 +0700 Subject: [PATCH] fix: add encoding="utf-8" to write_text calls with ensure_ascii=False in skills_hub.py 3 write_text calls produce UTF-8 content (ensure_ascii=False) but omit the encoding parameter. On Windows, write_text defaults to the system codepage (cp1252), corrupting non-ASCII skill names and descriptions. PR #64822 already fixes the paired read_text calls. This commit fixes the write side to complete the encoding round-trip. - _write_index_cache(): cache_file.write_text (line 1147) - _write_stale_index_cache(): cache_file.write_text (line 3366) - SkillLockStore.save(): self.path.write_text (line 3406) --- tools/skills_hub.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/skills_hub.py b/tools/skills_hub.py index 755b32fcbbe2..ac4749c9b113 100644 --- a/tools/skills_hub.py +++ b/tools/skills_hub.py @@ -1144,7 +1144,7 @@ def _write_cache(self, key: str, data: list) -> None: index_cache_dir.mkdir(parents=True, exist_ok=True) cache_file = index_cache_dir / f"{key}.json" try: - cache_file.write_text(json.dumps(data, ensure_ascii=False)) + cache_file.write_text(json.dumps(data, ensure_ascii=False), encoding="utf-8") except OSError as e: logger.debug("Could not write cache: %s", e) @@ -3363,7 +3363,7 @@ def _write_index_cache(key: str, data: Any) -> None: pass cache_file = index_cache_dir / f"{key}.json" try: - cache_file.write_text(json.dumps(data, ensure_ascii=False, default=str)) + cache_file.write_text(json.dumps(data, ensure_ascii=False, default=str), encoding="utf-8") except OSError as e: logger.debug("Could not write cache: %s", e) @@ -3403,7 +3403,7 @@ def load(self) -> dict: def save(self, data: dict) -> None: self.path.parent.mkdir(parents=True, exist_ok=True) - self.path.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n") + self.path.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") def record_install( self,