Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions agents/s05_skill_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import re
import subprocess
from pathlib import Path

import yaml
from anthropic import Anthropic
from dotenv import load_dotenv

Expand Down Expand Up @@ -71,16 +71,15 @@ def _load_all(self):
self.skills[name] = {"meta": meta, "body": body, "path": str(f)}

def _parse_frontmatter(self, text: str) -> tuple:
"""Parse YAML frontmatter between --- delimiters."""
match = re.match(r"^---\n(.*?)\n---\n(.*)", text, re.DOTALL)
if not match:
return {}, text
meta = {}
for line in match.group(1).strip().splitlines():
if ":" in line:
key, val = line.split(":", 1)
meta[key.strip()] = val.strip()
return meta, match.group(2).strip()
try:
meta = yaml.safe_load(match.group(1))
except yaml.YAMLError:
meta = {}
return meta or {}, match.group(2).strip()


def get_descriptions(self) -> str:
"""Layer 1: short descriptions for the system prompt."""
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
anthropic>=0.25.0
python-dotenv>=1.0.0
pyyaml>=6.0