Use UTF-8 for skill creator file I/O (#63343)

Python's default text encoding can vary by environment, causing non-ASCII
skill text to be misread or fail to encode.

Read `SKILL.md` as UTF-8 in both the validator and the metadata generator,
and write `agents/openai.yaml` as UTF-8.

GitOrigin-RevId: d21ad0c653056ec0517d95b7b18e77f66489a9a2
This commit is contained in:
Charlie Marsh
2026-11-23 13:55:01 +00:00
committed by copyberry
parent 2c77888b21
commit 93f105d29b
2 changed files with 3 additions and 3 deletions
@@ -106,7 +106,7 @@ def read_frontmatter_name(skill_dir):
if not skill_md.exists():
print(f"[ERROR] SKILL.md not found in {skill_dir}")
return None
content = skill_md.read_text()
content = skill_md.read_text(encoding="utf-8")
match = re.match(r"^---\n(.*?)\n---", content, re.DOTALL)
if not match:
print("[ERROR] Invalid SKILL.md frontmatter format.")
@@ -187,7 +187,7 @@ def write_openai_yaml(skill_dir, skill_name, raw_overrides):
agents_dir = Path(skill_dir) / "agents"
agents_dir.mkdir(parents=True, exist_ok=True)
output_path = agents_dir / "openai.yaml"
output_path.write_text("\n".join(interface_lines) + "\n")
output_path.write_text("\n".join(interface_lines) + "\n", encoding="utf-8")
print(f"[OK] Created agents/openai.yaml")
return output_path
@@ -20,7 +20,7 @@ def validate_skill(skill_path):
if not skill_md.exists():
return False, "SKILL.md not found"
content = skill_md.read_text()
content = skill_md.read_text(encoding="utf-8")
if not content.startswith("---"):
return False, "No YAML frontmatter found"