skillFromText function
Skill?
skillFromText(
- String text, {
- required String filePath,
- required String fallbackName,
- required SkillScope scope,
- required SkillSource source,
- String? embeddedText,
Parses one SKILL.md text into a Skill (shared by disk discovery and the compiled-in built-ins, issue #1151). Returns null when the name is empty.
Implementation
Skill? skillFromText(
String text, {
required String filePath,
required String fallbackName,
required SkillScope scope,
required SkillSource source,
String? embeddedText,
}) {
final (frontmatter, body) = parseFrontmatterTyped(text);
final manifest = SkillManifest.fromFrontmatter(
frontmatter,
skillName: fallbackName,
);
final name = ('${frontmatter['name'] ?? fallbackName}').trim();
if (name.isEmpty) return null;
return Skill(
name: name,
description: _skillDescription(manifest, body),
filePath: filePath,
scope: scope,
source: source,
manifest: manifest,
embeddedText: embeddedText,
);
}