Return ``(metadata_dict, body)`` from a markdown file with YAML frontmatter delimited by ``---`` lines. Files without frontmatter return ``({}, full_text)``.
(text: str)
| 55 | |
| 56 | |
| 57 | def _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 | |
| 77 | def scan_local_skills( |
no outgoing calls