AS AgentScopeAPI 手册 / API Reference

ClasspathSkillRepository

public class ClasspathSkillRepository implements AgentSkillRepository
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:78–368

Classpath 技能仓库,负责持久化与读取数据。位于 io.agentscope.core.skill.repository 包,实现 AgentSkillRepository。核心成员包括 getSkill、getAllSkillNames、getAllSkills、save、delete、skillExists。

ClasspathSkillRepository - Loads skills from classpath resources and JAR files.

This repository bridges the gap between JAR resources and file system based skill loading by:

  • Creating a virtual file system for resources within JAR files

  • Obtaining Path objects for skill directories

  • Delegating skill I/O to SkillFileSystemHelper

Important: Skills must be organized in a parent directory structure. You should pass the parent directory name (not individual skill paths). This is required because the repository scans a directory for multiple skill subdirectories.

Directory Structure:


resources/
└── skills/ ← Pass "skills" to repository
├── skill-a/
│ └── SKILL.md
├── skill-b/
│ └── SKILL.md
└── skill-c/
└── SKILL.md

Usage example:

`// Load from parent directory containing multiple skills
try (ClasspathSkillRepository repository = new ClasspathSkillRepository("skills")) {
// Get all available skill names
List<String> skillNames = repository.getAllSkillNames();

// Load a specific skill
AgentSkill skillA = repository.getSkill("skill-a");

// Load all skills at once
List<AgentSkill> allSkills = repository.getAllSkills();
}
`

构造器摘要Constructor Summary

构造器Constructor说明Description
public ClasspathSkillRepository(String resourcePath) throws IOException
初始化 `ClasspathSkillRepository` 实例。
Creates a repository for loading skills from resources.
public ClasspathSkillRepository(String resourcePath, String source) throws IOException
初始化 `ClasspathSkillRepository` 实例。
Creates a repository for loading skills from resources with a custom source.
protected ClasspathSkillRepository(String resourcePath, ClassLoader classLoader) throws IOException
初始化 `ClasspathSkillRepository` 实例。
Creates a repository for loading skills from resources using a specific ClassLoader.
protected ClasspathSkillRepository(String resourcePath, String source, ClassLoader classLoader) throws IOException
初始化 `ClasspathSkillRepository` 实例。
Creates a repository for loading skills from resources using a specific ClassLoader.

方法摘要Method Summary

方法Method说明Description
public AgentSkill getSkill(String skillName)
获取技能通过名称。
Gets a skill by name.
public List<String> getAllSkillNames()
获取 `getAllSkillNames`。
Gets all skill names available in the repository.
public List<AgentSkill> getAllSkills()
获取所有技能可用 in 仓库。
Gets all skills available in the repository.
public boolean save(List<AgentSkill> skills, boolean force)
保存数据到持久化存储。
Performs the save operation.
public boolean delete(String skillName)
删除数据。
Performs the delete operation.
public boolean skillExists(String skillName)
设置该参数。
Performs the skill exists operation.
public AgentSkillRepositoryInfo getRepositoryInfo()
获取仓库信息。
Returns the repository info.
public String getSource()
获取来源。
Returns the source.
public void setWriteable(boolean writeable)
设置 `setWriteable`。
Sets the writeable.
public boolean isWriteable()
判断是否 `isWriteable`。
Returns whether the writeable.
public boolean isJarEnvironment()
检查if 运行中,使用 JAR 环境。
Checks if running in a JAR environment.
public void close()
关闭连接并释放相关资源。
Closes the file system (if in JAR environment).

构造器详情Constructor Detail

ClasspathSkillRepository

public ClasspathSkillRepository(String resourcePath) throws IOException

初始化 ClasspathSkillRepository 实例。

Creates a repository for loading skills from resources.

参数Parameters
名称Name类型Type说明Description
resourcePathString资源路径(类型 `String`)。The path to the skill under resources, e.g., "writing-skills"
抛出Throws
  • IOException 可能抛出 `IOException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:100–102

ClasspathSkillRepository

public ClasspathSkillRepository(String resourcePath, String source) throws IOException

初始化 ClasspathSkillRepository 实例。

Creates a repository for loading skills from resources with a custom source.

参数Parameters
名称Name类型Type说明Description
resourcePathString资源路径(类型 `String`)。The path to the skill under resources, e.g., "writing-skills"
sourceString来源(类型 `String`)。The custom source identifier (null to use default)
抛出Throws
  • IOException 可能抛出 `IOException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:111–113

ClasspathSkillRepository

protected ClasspathSkillRepository(String resourcePath, ClassLoader classLoader) throws IOException

初始化 ClasspathSkillRepository 实例。

Creates a repository for loading skills from resources using a specific ClassLoader.

参数Parameters
名称Name类型Type说明Description
resourcePathString资源路径(类型 `String`)。The path to the skill under resources, e.g., "writing-skills"
classLoaderClassLoader类加载器(类型 `ClassLoader`)。The ClassLoader to use for loading resources
抛出Throws
  • IOException 可能抛出 `IOException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:122–125

ClasspathSkillRepository

protected ClasspathSkillRepository(String resourcePath, String source, ClassLoader classLoader) throws IOException

初始化 ClasspathSkillRepository 实例。

Creates a repository for loading skills from resources using a specific ClassLoader.

参数Parameters
名称Name类型Type说明Description
resourcePathString资源路径(类型 `String`)。The path to the skill under resources, e.g., "writing-skills"
sourceString来源(类型 `String`)。The custom source identifier (null to use default)
classLoaderClassLoader类加载器(类型 `ClassLoader`)。The ClassLoader to use for loading resources
抛出Throws
  • IOException 可能抛出 `IOException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:135–169

方法详情Method Detail

getSkill

public AgentSkill getSkill(String skillName)

获取技能通过名称。

Gets a skill by name.

参数Parameters
名称Name类型Type说明Description
skillNameString技能名称(来自技能.md 元数据)。The skill name (from SKILL.md metadata)
返回Returns AgentSkill
已加载 AgentSkill 对象。The loaded AgentSkill object
抛出Throws
  • IllegalStateException 可能抛出 `IllegalStateException`。if the repository has been closed
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:178–182

getAllSkillNames

public List<String> getAllSkillNames()

获取 getAllSkillNames。

Gets all skill names available in the repository.

返回Returns List<String>
返回列出。A sorted list of skill names
抛出Throws
  • IllegalStateException 可能抛出 `IllegalStateException`。if the repository has been closed
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:190–194

getAllSkills

public List<AgentSkill> getAllSkills()

获取所有技能可用 in 仓库。

Gets all skills available in the repository.

返回Returns List<AgentSkill>
返回列出。A list of all loaded AgentSkill objects
抛出Throws
  • IllegalStateException 可能抛出 `IllegalStateException`。if the repository has been closed
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:202–206

save

public boolean save(List<AgentSkill> skills, boolean force)

保存数据到持久化存储。

Performs the save operation.

参数Parameters
名称Name类型Type说明Description
skillsList<AgentSkill>技能(类型 `List`)。The skills.
forcebooleanforce(类型 `boolean`)。The force.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:208–212

delete

public boolean delete(String skillName)

删除数据。

Performs the delete operation.

参数Parameters
名称Name类型Type说明Description
skillNameString技能名称(类型 `String`)。The skill name.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:214–218

skillExists

public boolean skillExists(String skillName)

设置该参数。

Performs the skill exists operation.

参数Parameters
名称Name类型Type说明Description
skillNameString技能名称(类型 `String`)。The skill name.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:220–224

getRepositoryInfo

public AgentSkillRepositoryInfo getRepositoryInfo()

获取仓库信息。

Returns the repository info.

返回Returns AgentSkillRepositoryInfo
返回AgentSkillRepositoryInfo。Returns agent skill repository info.
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:226–229

getSource

public String getSource()

获取来源。

Returns the source.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:231–234

setWriteable

public void setWriteable(boolean writeable)

设置 setWriteable。

Sets the writeable.

参数Parameters
名称Name类型Type说明Description
writeablebooleanwriteable(类型 `boolean`)。The writeable.
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:260–263

isWriteable

public boolean isWriteable()

判断是否 isWriteable。

Returns whether the writeable.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:265–268

isJarEnvironment

public boolean isJarEnvironment()

检查if 运行中,使用 JAR 环境。

Checks if running in a JAR environment.

返回Returns boolean
返回布尔值,表示判断结果。true if running from JAR, false if in development environment
源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:275–277

close

public void close()

关闭连接并释放相关资源。

Closes the file system (if in JAR environment).

源码Source io/agentscope/core/skill/repository/ClasspathSkillRepository.java:343–355
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.