MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / _parse_frontmatter

Function _parse_frontmatter

openkb/agent/skills.py:57–74  ·  view source on GitHub ↗

Return ``(metadata_dict, body)`` from a markdown file with YAML frontmatter delimited by ``---`` lines. Files without frontmatter return ``({}, full_text)``.

(text: str)

Source from the content-addressed store, hash-verified

55
56
57def _parse_frontmatter(text: str) -> Tuple[dict, str]:
58 """Return ``(metadata_dict, body)`` from a markdown file with YAML
59 frontmatter delimited by ``---`` lines. Files without frontmatter
60 return ``({}, full_text)``.
61 """
62 lines = text.splitlines()
63 if not lines or lines[0].strip() != "---":
64 return {}, text
65 try:
66 end = lines.index("---", 1)
67 except ValueError:
68 return {}, text
69 try:
70 meta = yaml.safe_load("\n".join(lines[1:end])) or {}
71 except yaml.YAMLError:
72 meta = {}
73 body = "\n".join(lines[end + 1 :])
74 return meta if isinstance(meta, dict) else {}, body
75
76
77def scan_local_skills(

Calls

no outgoing calls