类 SkillFileSystemHelper
java.lang.Object
io.agentscope.core.skill.util.SkillFileSystemHelper
已过时。
since 2.0.0. The skill package is removed; manage markdown skill catalogs in
application code.
Utility class for file system operations related to skills.
This class provides reusable operations for loading, listing, saving, and deleting skills on the file system. It is designed to be shared by multiple repositories such as file system and Git based repositories.
-
方法概要
修饰符和类型方法说明static voiddeleteDirectory(Path directory) 已过时。Recursively deletes a directory and all its contents.static booleandeleteSkill(Path baseDir, String skillName) 已过时。Deletes a skill by name based on SKILL.md metadata.getAllSkillNames(Path baseDir) 已过时。Retrieves all skill names by parsing SKILL.md metadata in each skill folder.static List<AgentSkill> getAllSkills(Path baseDir, String source) 已过时。Retrieves all skills from the base directory with resources pre-loaded into memory.static List<AgentSkill> getAllSkills(Path baseDir, String source, boolean includeResources) 已过时。Retrieves all skills from the base directory.static booleanhasSkillFile(Path dir) 已过时。Checks if a directory contains a SKILL.md file.static AgentSkill已过时。Loads a skill by name from the given base directory.static AgentSkillloadSkillFromDirectory(Path skillDir, String source) 已过时。Loads a skill from a specific directory, eagerly reading every non-hidden file in the skill tree into memory.static AgentSkillloadSkillFromDirectory(Path skillDir, String source, boolean includeResources) 已过时。Loads a skill from a specific directory.static ThreadregisterTempDirectoryCleanup(Path directory) 已过时。Registers a shutdown hook to delete the given directory on JVM exit.static booleansaveSkills(Path baseDir, List<AgentSkill> skills, boolean force) 已过时。Saves skills to the base directory.static booleanskillExists(Path baseDir, String skillName) 已过时。Checks whether a skill exists by scanning SKILL.md metadata.static PathvalidateAndResolvePath(Path baseDir, String skillName) 已过时。Validates that a resolved path is within the base directory.
-
方法详细资料
-
loadSkill
已过时。Loads a skill by name from the given base directory.- 参数:
baseDir- The base directory containing skill foldersskillName- The skill name to loadsource- The source identifier for the created skill- 返回:
- The loaded AgentSkill
- 抛出:
IllegalArgumentException- if the skill cannot be found or is invalid
-
loadSkillFromDirectory
已过时。Loads a skill from a specific directory, eagerly reading every non-hidden file in the skill tree into memory. Equivalent toloadSkillFromDirectory(skillDir, source, true). -
loadSkillFromDirectory
public static AgentSkill loadSkillFromDirectory(Path skillDir, String source, boolean includeResources) 已过时。Loads a skill from a specific directory.The returned skill always carries an absolute
originDirmatchingskillDir, so callers (prompt provider, load tool) can address files on disk without a second copy.- 参数:
skillDir- The directory containing SKILL.mdsource- The source identifier for the created skillincludeResources- whentrue, all non-hidden files underskillDirare pre-loaded into the skill's in-memory resource map (legacy behavior). Whenfalse, only SKILL.md is read; callers fall back to disk throughoriginDiron demand.- 返回:
- The loaded AgentSkill (with
originDirpopulated) - 抛出:
IllegalArgumentException- if SKILL.md is missing or invalid
-
getAllSkillNames
已过时。Retrieves all skill names by parsing SKILL.md metadata in each skill folder.- 参数:
baseDir- The base directory containing skill folders- 返回:
- A list of skill names sorted alphabetically
-
getAllSkills
已过时。Retrieves all skills from the base directory with resources pre-loaded into memory. Equivalent togetAllSkills(baseDir, source, true). -
getAllSkills
已过时。Retrieves all skills from the base directory.- 参数:
baseDir- The base directory containing skill folderssource- The source identifier for created skillsincludeResources- whenfalse, each skill's resource map is left empty and callers must rely on the skill'soriginDirfor disk-side reads- 返回:
- A list of skills
-
saveSkills
已过时。Saves skills to the base directory.- 参数:
baseDir- The base directory to save skillsskills- The skills to saveforce- Whether to overwrite existing skills- 返回:
- true if all skills were saved, false otherwise
-
deleteSkill
已过时。Deletes a skill by name based on SKILL.md metadata.- 参数:
baseDir- The base directory containing skill foldersskillName- The skill name to delete- 返回:
- true if deleted, false if not found
-
skillExists
已过时。Checks whether a skill exists by scanning SKILL.md metadata.- 参数:
baseDir- The base directory containing skill foldersskillName- The skill name to check- 返回:
- true if a matching skill exists
-
validateAndResolvePath
已过时。Validates that a resolved path is within the base directory.- 参数:
baseDir- The base directory to constrain resolutionskillName- The skill name to resolve- 返回:
- The validated absolute path
- 抛出:
IllegalArgumentException- if the path escapes the base directory
-
hasSkillFile
已过时。Checks if a directory contains a SKILL.md file.- 参数:
dir- The directory to check- 返回:
- true if SKILL.md exists in the directory
-
deleteDirectory
已过时。Recursively deletes a directory and all its contents.- 参数:
directory- The directory to delete- 抛出:
IOException- if deletion fails
-
registerTempDirectoryCleanup
已过时。Registers a shutdown hook to delete the given directory on JVM exit.- 参数:
directory- The directory to delete at shutdown
-