diff --git a/deeptutor/services/skill/service.py b/deeptutor/services/skill/service.py index b46517291..392025191 100644 --- a/deeptutor/services/skill/service.py +++ b/deeptutor/services/skill/service.py @@ -482,11 +482,13 @@ class SkillService: if resolved is None: raise SkillNotFoundError(name) skill_dir, _source = resolved + # POSIX form, sorted as text: the model asks for files the way SKILL.md + # links them ("references/outline.md"), whatever the server's OS. files: list[str] = [] - for path in sorted(skill_dir.rglob("*")): + for path in skill_dir.rglob("*"): if path.is_file() and not path.name.startswith("."): - files.append(str(path.relative_to(skill_dir))) - return files + files.append(path.relative_to(skill_dir).as_posix()) + return sorted(files) # ── runtime loading (manifest + always) ───────────────────────────── diff --git a/tests/tools/builtin/test_read_skill_tool.py b/tests/tools/builtin/test_read_skill_tool.py index a5fa2bc8c..be5d169cc 100644 --- a/tests/tools/builtin/test_read_skill_tool.py +++ b/tests/tools/builtin/test_read_skill_tool.py @@ -50,6 +50,24 @@ async def test_missing_file_names_the_existing_skill( assert "SKILL.md, references/outline.md" in result.content +def test_skill_file_list_uses_forward_slashes_and_text_order(tmp_path: Path) -> None: + root = tmp_path / "skills" + _write_skill(root, "ncea-tutor") + for rel in ("references/Zeta.md", "references/alpha.md", "templates/deep/card.md"): + target = root / "ncea-tutor" / rel + target.parent.mkdir(parents=True, exist_ok=True) + target.write_text(rel) + + files = SkillService(root=root, builtin_root=None).list_skill_files("ncea-tutor") + + assert files == [ + "SKILL.md", + "references/Zeta.md", + "references/alpha.md", + "templates/deep/card.md", + ] + + @pytest.mark.asyncio async def test_missing_skill_lists_available_skills( tmp_path: Path, monkeypatch: pytest.MonkeyPatch