MCPcopy
hub / github.com/OpenHands/OpenHands / _parse_skill_frontmatter

Function _parse_skill_frontmatter

openhands/app_server/user/skills_router.py:35–56  ·  view source on GitHub ↗

Parse YAML frontmatter from a skill markdown file. Returns the frontmatter dict, or None if parsing fails.

(file_path: Path)

Source from the content-addressed store, hash-verified

33
34
35def _parse_skill_frontmatter(file_path: Path) -> dict | None:
36 """Parse YAML frontmatter from a skill markdown file.
37
38 Returns the frontmatter dict, or None if parsing fails.
39 """
40 try:
41 text = file_path.read_text(encoding='utf-8')
42 except Exception:
43 return None
44
45 if not text.startswith('---'):
46 return None
47
48 end = text.find('---', 3)
49 if end == -1:
50 return None
51
52 try:
53 return yaml.safe_load(text[3:end])
54 except yaml.YAMLError as e:
55 logger.warning(f'Invalid YAML frontmatter in {file_path}: {e}')
56 return None
57
58
59def _load_skills_from_dir(skills_dir: Path, source: str) -> list[SkillInfo]:

Callers 1

_load_skills_from_dirFunction · 0.85

Calls 1

warningMethod · 0.80

Tested by

no test coverage detected