sxh 4abba38734
fix(skills): recognise eval fixture paths behind an earlier evals segment (#6271)
is_eval_fixture_path returned on the first 'evals' segment, so a path whose
'evals/fixtures/' came after a plain 'evals' segment read as a non-fixture.
Move the 'fixtures' test into the loop condition so every segment is checked.

Co-authored-by: sxh313 <sxh313@users.noreply.github.com>
2026-10-04 20:47:15 +08:00

25 lines
851 B
Python

"""Shared helpers for skill-package relative paths."""
from __future__ import annotations
from pathlib import PurePosixPath
def _parts(path: str | PurePosixPath) -> tuple[str, ...]:
return PurePosixPath(str(path).replace("\\", "/")).parts
def is_eval_fixture_path(path: str | PurePosixPath) -> bool:
"""Return whether a path is under an eval fixture directory."""
parts = _parts(path)
for index, part in enumerate(parts[:-1]):
if part == "evals" and len(parts) > index + 2 and parts[index + 1] == "fixtures":
return True
return False
def is_eval_fixture_skill_md(path: str | PurePosixPath) -> bool:
"""Return whether a path is an eval fixture's nested SKILL.md file."""
parts = _parts(path)
return bool(parts) and parts[-1] == "SKILL.md" and is_eval_fixture_path(PurePosixPath(*parts[:-1]))