mirror of
https://github.com/shareAI-lab/learn-claude-code.git
synced 2026-08-04 21:40:05 +00:00
Merge e7e2dd1133 into a9cafe953a
This commit is contained in:
commit
37dbffca9d
4 changed files with 24 additions and 14 deletions
|
|
@ -70,8 +70,8 @@ def _scan_skills():
|
|||
if manifest.exists():
|
||||
raw = manifest.read_text()
|
||||
meta, body = _parse_frontmatter(raw)
|
||||
name = meta.get("name", d.name)
|
||||
desc = meta.get("description", raw.split("\n")[0].lstrip("#").strip())
|
||||
name = meta.get("name") or d.name
|
||||
desc = meta.get("description") or body.split("\n", 1)[0].lstrip("#").strip()
|
||||
SKILL_REGISTRY[name] = {"name": name, "description": desc, "content": raw}
|
||||
|
||||
_scan_skills() # runs once at startup
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ def _scan_skills():
|
|||
if manifest.exists():
|
||||
raw = manifest.read_text()
|
||||
meta, body = _parse_frontmatter(raw)
|
||||
name = meta.get("name", d.name)
|
||||
desc = meta.get("description", raw.split("\n")[0].lstrip("#").strip())
|
||||
name = meta.get("name") or d.name
|
||||
desc = meta.get("description") or body.split("\n", 1)[0].lstrip("#").strip()
|
||||
SKILL_REGISTRY[name] = {"name": name, "description": desc, "content": raw}
|
||||
|
||||
_scan_skills() # runs once at startup
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ def _scan_skills():
|
|||
if manifest.exists():
|
||||
raw = manifest.read_text()
|
||||
meta, body = _parse_frontmatter(raw)
|
||||
name = meta.get("name", d.name)
|
||||
desc = meta.get("description", raw.split("\n")[0].lstrip("#").strip())
|
||||
name = meta.get("name") or d.name
|
||||
desc = meta.get("description") or body.split("\n", 1)[0].lstrip("#").strip()
|
||||
SKILL_REGISTRY[name] = {"name": name, "description": desc, "content": raw}
|
||||
|
||||
_scan_skills() # runs once at startup
|
||||
|
|
|
|||
|
|
@ -52,16 +52,26 @@ CURRENT_TODOS: list[dict] = []
|
|||
# s07: Skill catalog scan (used by build_system below)
|
||||
def _parse_frontmatter(text: str) -> tuple[dict, str]:
|
||||
"""Parse YAML frontmatter from SKILL.md. Returns (meta, body)."""
|
||||
if not text.startswith("---"):
|
||||
if not (text.startswith("---\n") or text.startswith("---\r\n")):
|
||||
return {}, text
|
||||
parts = text.split("---", 2)
|
||||
if len(parts) < 3:
|
||||
|
||||
lines = text.splitlines(keepends=True)
|
||||
closing_index = None
|
||||
for index, line in enumerate(lines[1:], start=1):
|
||||
if line.strip() == "---":
|
||||
closing_index = index
|
||||
break
|
||||
if closing_index is None:
|
||||
return {}, text
|
||||
|
||||
frontmatter = "".join(lines[1:closing_index])
|
||||
body = "".join(lines[closing_index + 1 :]).strip()
|
||||
try:
|
||||
meta = yaml.safe_load(parts[1]) or {}
|
||||
loaded = yaml.safe_load(frontmatter) or {}
|
||||
except yaml.YAMLError:
|
||||
meta = {}
|
||||
return meta, parts[2].strip()
|
||||
loaded = {}
|
||||
meta = loaded if isinstance(loaded, dict) else {}
|
||||
return meta, body
|
||||
|
||||
# Build skill registry at startup (used for safe lookup in load_skill)
|
||||
SKILL_REGISTRY: dict[str, dict] = {}
|
||||
|
|
@ -77,8 +87,8 @@ def _scan_skills():
|
|||
if manifest.exists():
|
||||
raw = manifest.read_text()
|
||||
meta, body = _parse_frontmatter(raw)
|
||||
name = meta.get("name", d.name)
|
||||
desc = meta.get("description", raw.split("\n")[0].lstrip("#").strip())
|
||||
name = meta.get("name") or d.name
|
||||
desc = meta.get("description") or body.split("\n", 1)[0].lstrip("#").strip()
|
||||
SKILL_REGISTRY[name] = {"name": name, "description": desc, "content": raw}
|
||||
|
||||
_scan_skills()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue