Class ClassPathSkillLoader
Each skill must reside in its own directory containing a SKILL.md file.
The file must have a YAML front matter block that declares the skill's name
and description. The body of the file (below the front matter) becomes the
skill's content.
Any additional files in the skill directory are loaded as SkillResources,
except SKILL.md itself and any files under a scripts/ subdirectory.
Empty files are silently skipped.
When skills are loaded from a plain directory on the classpath (not from a JAR),
symbolic links inside a skill directory are followed only when they point to a file inside
the same skill directory. Symbolic links to directories inside a skill are not followed.
If SKILL.md or a resource is a symbolic link to a file outside of the skill directory,
loading fails with an IllegalArgumentException.
The skill directory itself may be a symbolic link; in that case, the files of the directory
it points to are loaded.
-
Method Summary
Modifier and TypeMethodDescriptionstatic SkillLoads a single skill from the given classpath directory.static SkillloadSkill(String skillDirectoryOnClasspath, ClassLoader classLoader) Loads a single skill from the given classpath directory.loadSkills(String directoryOnClasspath) Loads all skills found in immediate subdirectories of the given classpath directory.loadSkills(String directoryOnClasspath, ClassLoader classLoader) Loads all skills found in immediate subdirectories of the given classpath directory.
-
Method Details
-
loadSkills
Loads all skills found in immediate subdirectories of the given classpath directory. Uses the thread's context class loader.- Parameters:
directoryOnClasspath- the classpath directory whose immediate subdirectories are scanned for skills- Returns:
- the list of loaded skills
- Throws:
IllegalArgumentException- if the directory is not found on the classpath, or if a skill'sSKILL.mdor resource is a symbolic link to a file outside of its skill directory
-
loadSkills
Loads all skills found in immediate subdirectories of the given classpath directory.- Parameters:
directoryOnClasspath- the classpath directory whose immediate subdirectories are scanned for skillsclassLoader- the class loader to use- Returns:
- the list of loaded skills
- Throws:
IllegalArgumentException- if the directory is not found on the classpath, or if a skill'sSKILL.mdor resource is a symbolic link to a file outside of its skill directory
-
loadSkill
Loads a single skill from the given classpath directory. Uses the thread's context class loader.- Parameters:
skillDirectoryOnClasspath- the classpath path to the skill directory- Returns:
- the loaded skill
- Throws:
IllegalArgumentException- if the skill directory or itsSKILL.mdis not found, or ifSKILL.mdor a resource is a symbolic link to a file outside of the skill directory
-
loadSkill
Loads a single skill from the given classpath directory.- Parameters:
skillDirectoryOnClasspath- the classpath path to the skill directoryclassLoader- the class loader to use- Returns:
- the loaded skill
- Throws:
IllegalArgumentException- if the skill directory or itsSKILL.mdis not found, or ifSKILL.mdor a resource is a symbolic link to a file outside of the skill directory
-