MCPcopy Index your code
hub / github.com/wshobson/agents / parse_agent

Function parse_agent

plugins/plugin-eval/src/plugin_eval/parser.py:121–150  ·  view source on GitHub ↗

Parse an agent markdown file.

(agent_path: Path)

Source from the content-addressed store, hash-verified

119
120
121def parse_agent(agent_path: Path) -> ParsedAgent:
122 """Parse an agent markdown file."""
123 content = agent_path.read_text(encoding="utf-8")
124 frontmatter, body = _split_frontmatter(content)
125
126 tools_raw = frontmatter.get("tools", "")
127 if isinstance(tools_raw, list):
128 tools = [str(t).strip() for t in tools_raw]
129 elif isinstance(tools_raw, str) and tools_raw:
130 tools = [t.strip() for t in tools_raw.split(",")]
131 else:
132 tools = []
133
134 description = frontmatter.get("description", "")
135 has_proactive = bool(re.search(r"use proactively", description, re.IGNORECASE))
136
137 skill_refs = re.findall(r"(?:skill|skills)/([a-z0-9-]+)", body)
138
139 return ParsedAgent(
140 path=agent_path,
141 name=frontmatter.get("name", agent_path.stem),
142 description=description,
143 model=frontmatter.get("model"),
144 has_tools_restriction=bool(tools),
145 tools=tools,
146 has_proactive_trigger=has_proactive,
147 skill_references=skill_refs,
148 raw_content=content,
149 frontmatter=frontmatter,
150 )
151
152
153def parse_plugin(plugin_dir: Path) -> ParsedPlugin:

Calls 2

_split_frontmatterFunction · 0.85
ParsedAgentClass · 0.85