类 SkillUtil
This class provides factory methods to create AgentSkill objects from various sources, particularly from markdown content with YAML frontmatter.
Usage example:
// Create skill from markdown with default source
String skillMd = "---\nname: my_skill\ndescription: Does something\n---\nContent here";
Map<String, String> resources = Map.of("file1.txt", "content1");
AgentSkill skill = SkillUtil.createFrom(skillMd, resources);
// Create skill from markdown with custom source
AgentSkill skill2 = SkillUtil.createFrom(skillMd, resources, "github");
-
方法概要
修饰符和类型方法说明static AgentSkillcreateFrom(String skillMd, Map<String, String> resources) Creates an AgentSkill from markdown with YAML frontmatter.static AgentSkillCreates an AgentSkill from markdown with YAML frontmatter and custom source.static AgentSkillcreateFromZip(byte[] zipBytes) Creates an AgentSkill from a skill package zip.static AgentSkillcreateFromZip(byte[] zipBytes, String source) Creates an AgentSkill from a skill package zip with custom source.static AgentSkillcreateFromZip(byte[] zipBytes, String source, Charset charset) Creates an AgentSkill from a skill package zip with custom source and charset.static AgentSkillcreateFromZip(InputStream zipStream) Creates an AgentSkill from a skill package zip input stream.static AgentSkillcreateFromZip(InputStream zipStream, String source) Creates an AgentSkill from a skill package zip input stream with custom source.static AgentSkillcreateFromZip(InputStream zipStream, String source, Charset charset) Creates an AgentSkill from a skill package zip input stream with custom source and charset.static AgentSkillcreateFromZip(Path zipPath) Creates an AgentSkill from a skill package zip file path.static AgentSkillcreateFromZip(Path zipPath, String source) Creates an AgentSkill from a skill package zip file path with custom source.static AgentSkillcreateFromZip(Path zipPath, String source, Charset charset) Creates an AgentSkill from a skill package zip file path with custom source and charset.static AgentSkillcreateFromZip(Path zipPath, Charset charset) Creates an AgentSkill from a skill package zip file path using the given charset.
-
方法详细资料
-
createFrom
Creates an AgentSkill from markdown with YAML frontmatter.Parses the markdown to extract metadata (name, description) from YAML frontmatter and content. Uses "custom" as the default source.
- 参数:
skillMd- Markdown content with YAML frontmatter containing name and descriptionresources- Supporting resources referenced by the skill (can be null)- 返回:
- Created AgentSkill instance
- 抛出:
IllegalArgumentException- if name or description is missing, or if content is empty
-
createFrom
Creates an AgentSkill from markdown with YAML frontmatter and custom source.Parses the markdown to extract metadata (name, description) from YAML frontmatter and content. The source parameter indicates where the skill originated from.
- 参数:
skillMd- Markdown content with YAML frontmatter containing name and descriptionresources- Supporting resources referenced by the skill (can be null)source- Source identifier for the skill (null defaults to "custom")- 返回:
- Created AgentSkill instance
- 抛出:
IllegalArgumentException- if name or description is missing, or if content is empty
-
createFromZip
Creates an AgentSkill from a skill package zip.The package must contain a "SKILL.md" entry and any optional resource files. The .skill and .zip extensions are aliases for the same package format.
- 参数:
zipBytes- Zip content as bytes- 返回:
- Created AgentSkill instance
- 抛出:
IllegalArgumentException- if zipBytes is null/empty, if no SKILL.md is found, or if zip entries are invalid
-
createFromZip
Creates an AgentSkill from a skill package zip file path.The package must contain a "SKILL.md" entry and any optional resource files. The .skill and .zip extensions are aliases for the same package format.
- 参数:
zipPath- Zip file path- 返回:
- Created AgentSkill instance
- 抛出:
IllegalArgumentException- if zipPath is nullRuntimeException- if the zip file cannot be read
-
createFromZip
Creates an AgentSkill from a skill package zip file path using the given charset.The package must contain a "SKILL.md" entry and any optional resource files. The .skill and .zip extensions are aliases for the same package format.
- 参数:
zipPath- Zip file pathcharset- Charset used to decode zip entry names and file contents (null defaults to UTF-8). Use this when the zip was created with a non-UTF-8 charset such as GBK/GB18030 and the default overload fails during zip entry decoding with errors likemalformed input- 返回:
- Created AgentSkill instance
-
createFromZip
Creates an AgentSkill from a skill package zip input stream.The package must contain a "SKILL.md" entry and any optional resource files. The .skill and .zip extensions are aliases for the same package format.
- 参数:
zipStream- Zip content stream- 返回:
- Created AgentSkill instance
- 抛出:
IllegalArgumentException- if zipStream is null
-
createFromZip
Creates an AgentSkill from a skill package zip with custom source.The package must contain a "SKILL.md" entry and any optional resource files. The .skill and .zip extensions are aliases for the same package format.
- 参数:
zipBytes- Zip content as bytessource- Source identifier for the skill (null defaults to "custom")- 返回:
- Created AgentSkill instance
- 抛出:
IllegalArgumentException- if zipBytes is null/empty, if no SKILL.md is found, or if zip entries are invalid
-
createFromZip
Creates an AgentSkill from a skill package zip with custom source and charset.The package must contain a "SKILL.md" entry and any optional resource files. The .skill and .zip extensions are aliases for the same package format.
- 参数:
zipBytes- Zip content as bytessource- Source identifier for the skill (null defaults to "custom")charset- Charset used to decode zip entry names and file contents (null defaults to UTF-8). Use this when the zip was created with a non-UTF-8 charset such as GBK/GB18030 and the default overload fails during zip entry decoding with errors likemalformed input- 返回:
- Created AgentSkill instance
- 抛出:
IllegalArgumentException- if zipBytes is null/empty, if no SKILL.md is found, or if zip entries are invalid
-
createFromZip
Creates an AgentSkill from a skill package zip file path with custom source.The package must contain a "SKILL.md" entry and any optional resource files. The .skill and .zip extensions are aliases for the same package format.
- 参数:
zipPath- Zip file pathsource- Source identifier for the skill (null defaults to "custom")- 返回:
- Created AgentSkill instance
- 抛出:
IllegalArgumentException- if zipPath is nullRuntimeException- if the zip file cannot be read
-
createFromZip
Creates an AgentSkill from a skill package zip file path with custom source and charset.The package must contain a "SKILL.md" entry and any optional resource files. The .skill and .zip extensions are aliases for the same package format.
- 参数:
zipPath- Zip file pathsource- Source identifier for the skill (null defaults to "custom")charset- Charset used to decode zip entry names and file contents (null defaults to UTF-8). Use this when the zip was created with a non-UTF-8 charset such as GBK/GB18030 and the default overload fails during zip entry decoding with errors likemalformed input- 返回:
- Created AgentSkill instance
- 抛出:
IllegalArgumentException- if zipPath is nullRuntimeException- if the zip file cannot be read
-
createFromZip
Creates an AgentSkill from a skill package zip input stream with custom source.The package must contain a "SKILL.md" entry and any optional resource files. The .skill and .zip extensions are aliases for the same package format.
- 参数:
zipStream- Zip content streamsource- Source identifier for the skill (null defaults to "custom")- 返回:
- Created AgentSkill instance
- 抛出:
IllegalArgumentException- if zipStream is nullRuntimeException- if the zip content cannot be read
-
createFromZip
Creates an AgentSkill from a skill package zip input stream with custom source and charset.The package must contain a "SKILL.md" entry and any optional resource files. The .skill and .zip extensions are aliases for the same package format.
- 参数:
zipStream- Zip content streamsource- Source identifier for the skill (null defaults to "custom")charset- Charset used to decode zip entry names and file contents (null defaults to UTF-8). Use this when the zip was created with a non-UTF-8 charset such as GBK/GB18030 and the default overload fails during zip entry decoding with errors likemalformed input- 返回:
- Created AgentSkill instance
- 抛出:
IllegalArgumentException- if zipStream is nullRuntimeException- if the zip content cannot be read
-