39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
"""Metadata bridge for the bundled Codex Game Studio project plugin.
|
|
|
|
The manifest and bundled ``SKILL.md`` files are the source of truth. This
|
|
module only exposes their descriptions to a compatible plugin host and keeps
|
|
the project resource bundle free of runtime-specific behavior.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
def _read_description(skill_md: Path) -> str:
|
|
try:
|
|
text = skill_md.read_text(encoding="utf-8")[:4000]
|
|
except Exception:
|
|
return ""
|
|
if text.startswith("---"):
|
|
end = text.find("\n---", 3)
|
|
if end != -1:
|
|
frontmatter = text[3:end]
|
|
for line in frontmatter.splitlines():
|
|
if line.strip().startswith("description:"):
|
|
return line.split(":", 1)[1].strip().strip("\"'")
|
|
return ""
|
|
|
|
|
|
def register(ctx) -> None:
|
|
root = Path(__file__).resolve().parent
|
|
skills_root = root / "skills"
|
|
if not skills_root.exists():
|
|
return
|
|
for skill_md in sorted(skills_root.glob("*/SKILL.md")):
|
|
ctx.register_skill(
|
|
name=skill_md.parent.name,
|
|
path=skill_md,
|
|
description=_read_description(skill_md),
|
|
)
|