Class SkillMemoryStore

java.lang.Object
com.tnsai.memory.advanced.SkillMemoryStore

public final class SkillMemoryStore extends Object
File-based store for structured Markdown skill files.

Each skill is persisted as a .md file in a configurable directory. Skills can be retrieved by name or by tag. The file format includes a YAML-like header for metadata.

File format:

 ---
 tags: tag1, tag2
 lastUsed: 2025-01-01T00:00:00Z
 ---
 (markdown content)
 
  • Constructor Details

    • SkillMemoryStore

      public SkillMemoryStore(Path directory) throws IOException
      Creates a skill store backed by the given directory. The directory is created if it does not exist.
      Parameters:
      directory - the directory to store skill files in
      Throws:
      IOException - if the directory cannot be created
  • Method Details

    • save

      public void save(Skill skill) throws IOException
      Stores or updates a skill.
      Parameters:
      skill - the skill to store
      Throws:
      IOException - if the file cannot be written
    • get

      public Optional<Skill> get(String name)
      Retrieves a skill by name and updates its lastUsed timestamp.
      Parameters:
      name - the skill name
      Returns:
      the skill, or empty if not found
    • findByTags

      public List<Skill> findByTags(Collection<String> tags)
      Finds skills matching any of the given tags.
      Parameters:
      tags - the tags to search for
      Returns:
      matching skills, sorted by lastUsed descending
    • getAll

      public List<Skill> getAll()
      Returns all stored skills.
    • remove

      public boolean remove(String name) throws IOException
      Removes a skill by name.
      Parameters:
      name - the skill name
      Returns:
      true if the skill was present and removed
      Throws:
      IOException - if the file cannot be deleted
    • size

      public int size()
      Returns the number of stored skills.