fix(skills): ignore support docs in skill discovery

Support files under references/, templates/, assets/, and scripts/ are progressive-disclosure data loaded through skill_view(..., file_path=...). They should not be treated as standalone skills during discovery or collision checks.

This prevents archived skill packages or support markdown files inside a real skill from shadowing active skills with the same name while still allowing top-level categories named scripts/templates/assets/references.

Tests cover:
- pruning nested SKILL.md files inside skill support directories
- preserving support-named top-level categories
- avoiding skill_view collisions from support markdown
- keeping archived package SKILL.md files accessible only through file_path
This commit is contained in:
Wolfram Ravenwolf
2026-06-16 13:08:34 -07:00
committed by Teknium
parent 7493de7fc3
commit 9137b86a52
4 changed files with 211 additions and 15 deletions
+47
View File
@@ -6,6 +6,8 @@ from agent.skill_utils import (
extract_skill_conditions,
get_disabled_skill_names,
get_external_skills_dirs,
is_excluded_skill_path,
is_skill_support_path,
iter_skill_index_files,
resolve_skill_config_values,
skill_matches_platform,
@@ -166,6 +168,51 @@ def test_skill_config_raw_cache_invalidates_on_config_edit(tmp_path, monkeypatch
os.utime(config_path, None)
assert get_disabled_skill_names() == {"new-skill"}
def test_iter_skill_index_files_prunes_skill_support_dirs(tmp_path):
"""Archived package SKILL.md files under support dirs are not active skills."""
real = tmp_path / "umbrella"
real.mkdir()
(real / "SKILL.md").write_text("---\nname: umbrella\n---\n", encoding="utf-8")
package = real / "references" / "old-skill-package"
package.mkdir(parents=True)
(package / "SKILL.md").write_text("---\nname: old-skill\n---\n", encoding="utf-8")
(package / "DESCRIPTION.md").write_text(
"---\ndescription: archived package\n---\n", encoding="utf-8"
)
script_package = real / "scripts" / "helper-skill"
script_package.mkdir(parents=True)
(script_package / "SKILL.md").write_text("---\nname: helper\n---\n", encoding="utf-8")
found = list(iter_skill_index_files(tmp_path, "SKILL.md"))
desc_found = list(iter_skill_index_files(tmp_path, "DESCRIPTION.md"))
assert found == [real / "SKILL.md"]
assert desc_found == []
assert is_skill_support_path(package / "SKILL.md") is True
assert is_excluded_skill_path(package / "SKILL.md") is True
def test_iter_skill_index_files_keeps_support_named_categories(tmp_path):
"""A category named scripts/templates/assets/references is still valid."""
scripts_skill = tmp_path / "scripts" / "bash-helper"
scripts_skill.mkdir(parents=True)
(scripts_skill / "SKILL.md").write_text(
"---\nname: bash-helper\n---\n", encoding="utf-8"
)
templates_skill = tmp_path / "templates" / "deck-template"
templates_skill.mkdir(parents=True)
(templates_skill / "SKILL.md").write_text(
"---\nname: deck-template\n---\n", encoding="utf-8"
)
found = list(iter_skill_index_files(tmp_path, "SKILL.md"))
assert found == [scripts_skill / "SKILL.md", templates_skill / "SKILL.md"]
assert is_skill_support_path(scripts_skill / "SKILL.md") is False
assert is_excluded_skill_path(scripts_skill / "SKILL.md") is False
# ── skill_matches_platform on Termux ──────────────────────────────────────