Class WorkspaceSkillRepository

java.lang.Object
io.agentscope.harness.agent.skill.WorkspaceSkillRepository
All Implemented Interfaces:
io.agentscope.core.skill.repository.AgentSkillRepository, io.agentscope.core.skill.repository.RuntimeContextSkillRepository, LazyResourceCapable, AutoCloseable

public class WorkspaceSkillRepository extends Object implements io.agentscope.core.skill.repository.RuntimeContextSkillRepository, LazyResourceCapable
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 Details

    • WorkspaceSkillRepository

      public WorkspaceSkillRepository(AbstractFilesystem filesystem, String skillsRelativeDir)
      Creates a read-only repository scoped to the default namespace; context-less operations resolve to RuntimeContext.empty() unless a request context is passed explicitly.
    • WorkspaceSkillRepository

      public WorkspaceSkillRepository(AbstractFilesystem filesystem, String skillsRelativeDir, String source)
      Creates a writable repository (matches the legacy WritableFilesystemSkillRepository default), 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

      public io.agentscope.core.skill.AgentSkill getSkill(String name)
      Specified by:
      getSkill in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • getAllSkillNames

      public List<String> getAllSkillNames()
      Specified by:
      getAllSkillNames in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • getAllSkills

      public List<io.agentscope.core.skill.AgentSkill> getAllSkills()
      Specified by:
      getAllSkills in interface io.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:
      getAllSkills in interface io.agentscope.core.skill.repository.RuntimeContextSkillRepository
    • skillExists

      public boolean skillExists(String skillName)
      Specified by:
      skillExists in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • skillExists

      public boolean skillExists(String skillName, io.agentscope.core.agent.RuntimeContext context)
      Variant of skillExists(String) scoped to the supplied request context; null uses the default namespace.
    • getRepositoryInfo

      public io.agentscope.core.skill.repository.AgentSkillRepositoryInfo getRepositoryInfo()
      Specified by:
      getRepositoryInfo in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • getSource

      public String getSource()
      Specified by:
      getSource in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • isWriteable

      public boolean isWriteable()
      Specified by:
      isWriteable in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • setWriteable

      public void setWriteable(boolean writeable)
      Specified by:
      setWriteable in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • resourcesFor

      public SkillResources resourcesFor(String skillName, io.agentscope.core.agent.RuntimeContext ctx)
      Description copied from interface: LazyResourceCapable
      Returns a lazy resource accessor for the named skill.

      The returned accessor MUST capture or honor the given ctx so per-user namespacing remains correct across calls.

      Specified by:
      resourcesFor in interface LazyResourceCapable
      Parameters:
      skillName - the skill's name (not skillId)
      ctx - current runtime context; never null (callers pass RuntimeContext.empty() when no context is available)
      Returns:
      accessor for that skill's resource tree, never null (return SkillResources.empty() if the skill does not belong to this repository)
    • save

      public boolean save(List<io.agentscope.core.skill.AgentSkill> skills, boolean force)
      Specified by:
      save in interface io.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 of save(List, boolean) scoped to the supplied request context; null uses the default namespace.
    • delete

      public boolean delete(String skillName)
      Specified by:
      delete in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • delete

      public boolean delete(String skillName, io.agentscope.core.agent.RuntimeContext context)
      Variant of delete(String) scoped to the supplied request context; null uses the default namespace.
    • readSkillFile

      public String readSkillFile(String skillName, String relPath)
      Reads a single raw file under <skillsRelativeDir>/<skillName>/<relPath>. Returns null when the file does not exist or read fails.
    • readSkillFile

      public String readSkillFile(String skillName, String relPath, io.agentscope.core.agent.RuntimeContext context)
      Variant of readSkillFile(String, String) scoped to the supplied request context; null uses the default namespace.
    • writeSkillFile

      public boolean writeSkillFile(String skillName, String relPath, String content)
      Writes (or overwrites) a single raw file under <skillsRelativeDir>/<skillName>/<relPath>. Caller is responsible for validating relPath (allowed subdirs, path traversal, size limits). Returns true on success.
    • writeSkillFile

      public boolean writeSkillFile(String skillName, String relPath, String content, io.agentscope.core.agent.RuntimeContext context)
      Variant of writeSkillFile(String, String, String) scoped to the supplied request context; null uses the default namespace.
    • deleteSkillFile

      public boolean deleteSkillFile(String skillName, String relPath)
      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 of deleteSkillFile(String, String) scoped to the supplied request context; null uses the default namespace.
    • resolveSkillRoot

      public String resolveSkillRoot(String skillName)
      Returns the relative skill root path for callers building sub-paths.
    • filesystem

      public AbstractFilesystem filesystem()
    • skillsRelativeDir

      public String skillsRelativeDir()