mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 01:59:46 +08:00
fix(skills): list a skill's files with forward slashes on every OS
When read_skill asks for a file the skill does not hold, the tool names the files it does hold so the model can ask again. list_skill_files built those names with str(relative_to(...)) and sorted Path objects, so on Windows the model saw "references\outline.md" in case-insensitive order, not the "references/outline.md" form SKILL.md links use. Return relative_to(...).as_posix() and sort the strings.
This commit is contained in:
@@ -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) ─────────────────────────────
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user