skill.base¶
Core data model and SKILL.md parsing.
Module Attributes
Top-level frontmatter keys |
Functions
|
Scan a skill directory for bundled resource subdirectories. |
|
Parse YAML frontmatter delimited by |
|
Parse a SKILL.md string into (SkillMeta, body). |
|
Render a dict as YAML frontmatter block. |
|
Render a SKILL.md string from meta and body. |
Classes
|
A fully parsed skill: frontmatter + body + resource manifest. |
|
Lightweight metadata for search results (no body). |
|
Parsed YAML frontmatter from a SKILL.md file. |
- skill.base.KNOWN_FRONTMATTER_KEYS = frozenset({'allowed-tools', 'audience', 'compatibility', 'description', 'license', 'metadata', 'name'})¶
Top-level frontmatter keys
SkillMetamodels as named fields. Anything else is an unknown/namespaced key (e.g. another tool’scoact:block) and is kept verbatim inSkillMeta.extraso it survives a parse→render round-trip.
- class skill.base.Skill(meta, body, resources=<factory>, source_path=None)[source]¶
Bases:
objectA fully parsed skill: frontmatter + body + resource manifest.
>>> s = Skill(meta=SkillMeta(name='test', description='A test'), body='# Hello') >>> s.meta.name 'test'- classmethod from_path(path)[source]¶
Load a Skill from a directory containing SKILL.md.
pathshould be the skill directory (containing SKILL.md).- Return type:
- class skill.base.SkillInfo(canonical_key, name, description, source, url=None, owner=None, installed=False)[source]¶
Bases:
objectLightweight metadata for search results (no body).
>>> si = SkillInfo(canonical_key='owner/test', name='test', description='A test', source='local') >>> si.canonical_key 'owner/test'
- class skill.base.SkillMeta(name, description, audience=None, license=None, compatibility=None, metadata=<factory>, allowed_tools=<factory>, extra=<factory>)[source]¶
Bases:
objectParsed YAML frontmatter from a SKILL.md file.
>>> m = SkillMeta(name='test', description='A test skill') >>> m.name 'test'Unknown/namespaced top-level keys are preserved in
extraand re-emitted on render, so a tool’s additive frontmatter block isn’t silently dropped:>>> m = SkillMeta(name='t', description='d', extra={'coact': {'model': 'sonnet'}}) >>> m.to_dict()['coact'] {'model': 'sonnet'}
- skill.base.discover_resources(path)[source]¶
Scan a skill directory for bundled resource subdirectories.
>>> import tempfile >>> with tempfile.TemporaryDirectory() as d: ... p = Path(d) ... (p / 'scripts').mkdir() ... (p / 'scripts' / 'run.py').touch() ... r = discover_resources(p) ... r['scripts'] ['run.py']
- skill.base.parse_frontmatter(content)[source]¶
Parse YAML frontmatter delimited by
---from markdown content.>>> meta, body = parse_frontmatter("---\nname: test\ndescription: A test\n---\n# Hello") >>> meta['name'] 'test' >>> body.strip() '# Hello' >>> parse_frontmatter("no frontmatter here") ({}, 'no frontmatter here')
- skill.base.parse_skill_md(content)[source]¶
Parse a SKILL.md string into (SkillMeta, body).
>>> meta, body = parse_skill_md("---\nname: foo\ndescription: bar\n---\nHello") >>> meta.name 'foo' >>> body 'Hello'