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

Function extract_frontmatter

openkb/skill/__init__.py:52–67  ·  view source on GitHub ↗

Return the YAML body between the first two ``---`` lines, or ``None``. Canonical parser for SKILL.md frontmatter — every consumer in this package should route through here so edge cases (CRLF, missing close, body containing ``---``) behave identically across the validator, evaluator

(text: str)

Source from the content-addressed store, hash-verified

50
51
52def extract_frontmatter(text: str) -> str | None:
53 """Return the YAML body between the first two ``---`` lines, or ``None``.
54
55 Canonical parser for SKILL.md frontmatter — every consumer in this
56 package should route through here so edge cases (CRLF, missing close,
57 body containing ``---``) behave identically across the validator,
58 evaluator, marketplace, and workspace modules.
59 """
60 lines = text.splitlines()
61 if not lines or lines[0].strip() != "---":
62 return None
63 try:
64 end = lines.index("---", 1)
65 except ValueError:
66 return None
67 return "\n".join(lines[1:end])
68
69
70def extract_body(text: str) -> str:

Callers 2

_read_descriptionFunction · 0.90
extract_descriptionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected