refactor: unify skill source model

This commit is contained in:
2026-07-30 12:11:25 +08:00
parent 076d87e303
commit 7d1994cf93
18 changed files with 669 additions and 527 deletions
+15 -7
View File
@@ -9,7 +9,7 @@ from typing import Any
from skiff import yaml_io
from skiff.paths import CONFIG_FILE, SOURCES_DIR
RESERVED_SOURCES = {"owned", "registry"}
RESERVED_SOURCES = {"builtin", "catalog", "owned", "registry"}
def validate_source_name(name: str) -> None:
@@ -68,15 +68,23 @@ def source_skills_root(name: str, entry: dict[str, Any]) -> Path:
return root
def list_source_skills(name: str, entry: dict[str, Any]) -> list[str]:
def discover_source_skills(name: str, entry: dict[str, Any]) -> dict[str, Path]:
root = source_skills_root(name, entry)
if (root / "SKILL.md").is_file():
return {name: root}
if not root.is_dir():
return []
return [
item.name
return {}
return {
item.name: item
for item in sorted(root.iterdir())
if item.is_dir() and not item.name.startswith("_") and (item / "SKILL.md").is_file()
]
if item.is_dir()
and not item.name.startswith("_")
and (item / "SKILL.md").is_file()
}
def list_source_skills(name: str, entry: dict[str, Any]) -> list[str]:
return list(discover_source_skills(name, entry))
def fetch_source(name: str, entry: dict[str, Any]) -> Path: