25 lines
878 B
Python
25 lines
878 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from typing import Iterable
|
|
|
|
|
|
class SkillStore:
|
|
"""Minimal skill loader kept for the same extension point as the reference project."""
|
|
|
|
def __init__(self, skill_dirs: Iterable[str | Path] | None = None) -> None:
|
|
self.skill_dirs = [Path(path) for path in (skill_dirs or [])]
|
|
|
|
def build_prompt_fragment(self, active_skills: Iterable[str]) -> str:
|
|
fragments: list[str] = []
|
|
active = set(active_skills)
|
|
if not active:
|
|
return ""
|
|
for directory in self.skill_dirs:
|
|
if not directory.exists():
|
|
continue
|
|
for skill_file in directory.glob("*/SKILL.md"):
|
|
if skill_file.parent.name in active:
|
|
fragments.append(skill_file.read_text(encoding="utf-8"))
|
|
return "\n\n".join(fragments)
|