deer-flow/backend/tests/test_skills_bundled.py
Huixin615 65afc9b1d2
fix(skills): apply allowed-tools only to active skills (#4098)
* fix(skills): scope allowed-tools to active skills

* fix(skills): tolerate stale active skill paths

* chore: retrigger CI

* fix(skills): document policy activation limits

* perf(skills): reuse per-step tool policy decisions

* fix(skills): harden runtime tool policy contracts

* fix(skills): redact cached policy decisions

* fix(skills): make slash tool policy authoritative

* fix(skills): preserve policy-safe discovery tools

* test(skills): cover explicit task delegation policy
2026-07-16 14:12:02 +08:00

44 lines
1.7 KiB
Python

"""Validate every bundled SKILL.md under skills/public/.
Catches regressions like #2443 — a SKILL.md whose YAML front-matter fails to
parse (e.g. an unquoted description containing a colon, which YAML interprets
as a nested mapping). Each bundled skill is checked individually so the
failure message identifies the exact file.
"""
from pathlib import Path
import pytest
from deerflow.skills.package_paths import is_eval_fixture_skill_md
from deerflow.skills.storage import get_or_new_skill_storage
from deerflow.skills.validation import _validate_skill_frontmatter
SKILLS_PUBLIC_DIR = Path(__file__).resolve().parents[2] / "skills" / "public"
BUNDLED_SKILL_DIRS = sorted(p.parent for p in SKILLS_PUBLIC_DIR.rglob("SKILL.md") if not is_eval_fixture_skill_md(p.relative_to(SKILLS_PUBLIC_DIR)))
@pytest.mark.parametrize(
"skill_dir",
BUNDLED_SKILL_DIRS,
ids=lambda p: str(p.relative_to(SKILLS_PUBLIC_DIR)),
)
def test_bundled_skill_frontmatter_is_valid(skill_dir: Path) -> None:
valid, msg, name = _validate_skill_frontmatter(skill_dir)
assert valid, f"{skill_dir.relative_to(SKILLS_PUBLIC_DIR)}: {msg}"
assert name, f"{skill_dir.relative_to(SKILLS_PUBLIC_DIR)}: no name extracted"
def test_skills_public_dir_has_skills() -> None:
assert BUNDLED_SKILL_DIRS, f"no SKILL.md found under {SKILLS_PUBLIC_DIR}"
def test_runtime_registry_excludes_skill_reviewer_eval_fixtures() -> None:
skills = get_or_new_skill_storage(skills_path=SKILLS_PUBLIC_DIR.parent).load_skills(enabled_only=False)
names = {skill.name for skill in skills}
assert "skill-reviewer" in names
assert all("evals/fixtures" not in skill.skill_file.as_posix() for skill in skills)