Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/nooa/skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def _parse_skill_md(path: Path) -> tuple[str, str, str]:

props = _read_skill_properties(path)
description = props.description or path.name
_, body = _parse_frontmatter(skill_md.read_text())
_, body = _parse_frontmatter(skill_md.read_text(encoding="utf-8"))
return skill_id, description, body.strip()


Expand Down
15 changes: 15 additions & 0 deletions tests/unit/test_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,27 @@ def test_skill_path_loads_id(skill_dir):


def test_skill_path_creates_dynamic_subclass(skill_dir):
"""A path-loaded skill exposes its description through a generated skill subclass."""
skill = TextSkill(path=skill_dir)
assert type(skill).__name__ != "Skill"
assert "Best practices for Git" in (type(skill).__doc__ or "")


def test_skill_body_preserves_utf8_with_legacy_default(skill_dir, monkeypatch):
"""UTF-8 instructions reach the skill docstring unchanged under a legacy locale."""
body = "Budget: 50€ → café 中文 🚀"
(skill_dir / "SKILL.md").write_text(
f"---\nname: git-workflow\ndescription: Unicode instructions\n---\n{body}\n",
encoding="utf-8",
)
monkeypatch.setattr("io.text_encoding", lambda encoding, stacklevel=2: encoding or "cp1252")
skill = TextSkill(path=skill_dir)
assert skill.description == "Unicode instructions"
assert (type(skill).__doc__ or "").split("\n---\n", 1)[1] == body


def test_skill_content_constructor():
"""Direct text construction exposes the provided instructions in the skill docstring."""
skill = Skill(content="A helpful skill.")
assert "A helpful skill." in (type(skill).__doc__ or "")

Expand Down
Loading