Class WorkspaceSkillRepository
- All Implemented Interfaces:
io.agentscope.core.skill.repository.AgentSkillRepository,io.agentscope.core.skill.repository.RuntimeContextSkillRepository,LazyResourceCapable,AutoCloseable
AgentSkillRepository backed by an AbstractFilesystem, with lazy resource
access via LazyResourceCapable. Supersedes the legacy
FilesystemBackedSkillRepository + WritableFilesystemSkillRepository pair:
writability is now a constructor parameter rather than a subclass.
Skills are discovered by globbing SKILL.md under skillsRelativeDir. Only
the SKILL.md text is read at registration time; resources (references, scripts, assets) are
fetched on demand through resourcesFor(String, RuntimeContext) and consumed by the
harness skill runtime when load_skill_through_path misses the in-memory map.
Per-user namespacing and sandbox routing are honored transparently because every
filesystem call passes the explicitly supplied RuntimeContext. Context-less operations
use the default namespace and never infer a user from another active agent call.
Deletes are non-destructive: skill directories are moved under
.archive/<name>-<ts>/ rather than removed, matching the curator's never-delete
invariant.
-
Constructor Summary
ConstructorsConstructorDescriptionWorkspaceSkillRepository(AbstractFilesystem filesystem, String skillsRelativeDir) Creates a read-only repository scoped to the default namespace; context-less operations resolve toRuntimeContext.empty()unless a request context is passed explicitly.WorkspaceSkillRepository(AbstractFilesystem filesystem, String skillsRelativeDir, String source) Creates a writable repository (matches the legacyWritableFilesystemSkillRepositorydefault), scoped to the default namespace.WorkspaceSkillRepository(AbstractFilesystem filesystem, String skillsRelativeDir, String source, boolean writable) Creates a repository with explicit source and writability, scoped to the default namespace. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanVariant ofdelete(String)scoped to the supplied request context;nulluses the default namespace.booleandeleteSkillFile(String skillName, String relPath) Deletes a single raw file under<skillsRelativeDir>/<skillName>/<relPath>.booleandeleteSkillFile(String skillName, String relPath, io.agentscope.core.agent.RuntimeContext context) Variant ofdeleteSkillFile(String, String)scoped to the supplied request context;nulluses the default namespace.List<io.agentscope.core.skill.AgentSkill>List<io.agentscope.core.skill.AgentSkill>getAllSkills(io.agentscope.core.agent.RuntimeContext context) Lists skills using the caller's request-scoped context.io.agentscope.core.skill.repository.AgentSkillRepositoryInfoio.agentscope.core.skill.AgentSkillbooleanreadSkillFile(String skillName, String relPath) Reads a single raw file under<skillsRelativeDir>/<skillName>/<relPath>.readSkillFile(String skillName, String relPath, io.agentscope.core.agent.RuntimeContext context) Variant ofreadSkillFile(String, String)scoped to the supplied request context;nulluses the default namespace.resolveSkillRoot(String skillName) Returns the relative skill root path for callers building sub-paths.resourcesFor(String skillName, io.agentscope.core.agent.RuntimeContext ctx) Returns a lazy resource accessor for the named skill.booleanbooleansave(List<io.agentscope.core.skill.AgentSkill> skills, boolean force, io.agentscope.core.agent.RuntimeContext context) Variant ofsave(List, boolean)scoped to the supplied request context;nulluses the default namespace.voidsetWriteable(boolean writeable) booleanskillExists(String skillName) booleanskillExists(String skillName, io.agentscope.core.agent.RuntimeContext context) Variant ofskillExists(String)scoped to the supplied request context;nulluses the default namespace.booleanwriteSkillFile(String skillName, String relPath, String content) Writes (or overwrites) a single raw file under<skillsRelativeDir>/<skillName>/<relPath>.booleanwriteSkillFile(String skillName, String relPath, String content, io.agentscope.core.agent.RuntimeContext context) Variant ofwriteSkillFile(String, String, String)scoped to the supplied request context;nulluses the default namespace.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.agentscope.core.skill.repository.AgentSkillRepository
closeMethods inherited from interface io.agentscope.core.skill.repository.RuntimeContextSkillRepository
getSkill
-
Constructor Details
-
WorkspaceSkillRepository
Creates a read-only repository scoped to the default namespace; context-less operations resolve toRuntimeContext.empty()unless a request context is passed explicitly. -
WorkspaceSkillRepository
public WorkspaceSkillRepository(AbstractFilesystem filesystem, String skillsRelativeDir, String source) Creates a writable repository (matches the legacyWritableFilesystemSkillRepositorydefault), scoped to the default namespace. -
WorkspaceSkillRepository
public WorkspaceSkillRepository(AbstractFilesystem filesystem, String skillsRelativeDir, String source, boolean writable) Creates a repository with explicit source and writability, scoped to the default namespace.
-
-
Method Details
-
getSkill
- Specified by:
getSkillin interfaceio.agentscope.core.skill.repository.AgentSkillRepository
-
getAllSkillNames
- Specified by:
getAllSkillNamesin interfaceio.agentscope.core.skill.repository.AgentSkillRepository
-
getAllSkills
- Specified by:
getAllSkillsin interfaceio.agentscope.core.skill.repository.AgentSkillRepository
-
getAllSkills
public List<io.agentscope.core.skill.AgentSkill> getAllSkills(io.agentscope.core.agent.RuntimeContext context) Lists skills using the caller's request-scoped context.- Specified by:
getAllSkillsin interfaceio.agentscope.core.skill.repository.RuntimeContextSkillRepository
-
skillExists
- Specified by:
skillExistsin interfaceio.agentscope.core.skill.repository.AgentSkillRepository
-
skillExists
Variant ofskillExists(String)scoped to the supplied request context;nulluses the default namespace. -
getRepositoryInfo
public io.agentscope.core.skill.repository.AgentSkillRepositoryInfo getRepositoryInfo()- Specified by:
getRepositoryInfoin interfaceio.agentscope.core.skill.repository.AgentSkillRepository
-
getSource
- Specified by:
getSourcein interfaceio.agentscope.core.skill.repository.AgentSkillRepository
-
isWriteable
public boolean isWriteable()- Specified by:
isWriteablein interfaceio.agentscope.core.skill.repository.AgentSkillRepository
-
setWriteable
public void setWriteable(boolean writeable) - Specified by:
setWriteablein interfaceio.agentscope.core.skill.repository.AgentSkillRepository
-
resourcesFor
Description copied from interface:LazyResourceCapableReturns a lazy resource accessor for the named skill.The returned accessor MUST capture or honor the given
ctxso per-user namespacing remains correct across calls.- Specified by:
resourcesForin interfaceLazyResourceCapable- Parameters:
skillName- the skill'sname(notskillId)ctx- current runtime context; nevernull(callers passRuntimeContext.empty()when no context is available)- Returns:
- accessor for that skill's resource tree, never
null(returnSkillResources.empty()if the skill does not belong to this repository)
-
save
- Specified by:
savein interfaceio.agentscope.core.skill.repository.AgentSkillRepository
-
save
public boolean save(List<io.agentscope.core.skill.AgentSkill> skills, boolean force, io.agentscope.core.agent.RuntimeContext context) Variant ofsave(List, boolean)scoped to the supplied request context;nulluses the default namespace. -
delete
- Specified by:
deletein interfaceio.agentscope.core.skill.repository.AgentSkillRepository
-
delete
Variant ofdelete(String)scoped to the supplied request context;nulluses the default namespace. -
readSkillFile
Reads a single raw file under<skillsRelativeDir>/<skillName>/<relPath>. Returnsnullwhen the file does not exist or read fails. -
readSkillFile
public String readSkillFile(String skillName, String relPath, io.agentscope.core.agent.RuntimeContext context) Variant ofreadSkillFile(String, String)scoped to the supplied request context;nulluses the default namespace. -
writeSkillFile
Writes (or overwrites) a single raw file under<skillsRelativeDir>/<skillName>/<relPath>. Caller is responsible for validatingrelPath(allowed subdirs, path traversal, size limits). Returnstrueon success. -
writeSkillFile
public boolean writeSkillFile(String skillName, String relPath, String content, io.agentscope.core.agent.RuntimeContext context) Variant ofwriteSkillFile(String, String, String)scoped to the supplied request context;nulluses the default namespace. -
deleteSkillFile
Deletes a single raw file under<skillsRelativeDir>/<skillName>/<relPath>. Idempotent: missing files are treated as success. -
deleteSkillFile
public boolean deleteSkillFile(String skillName, String relPath, io.agentscope.core.agent.RuntimeContext context) Variant ofdeleteSkillFile(String, String)scoped to the supplied request context;nulluses the default namespace. -
resolveSkillRoot
Returns the relative skill root path for callers building sub-paths. -
filesystem
-
skillsRelativeDir
-