Package com.tnsai.memory.advanced
Class SkillMemoryStore
java.lang.Object
com.tnsai.memory.advanced.SkillMemoryStore
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 Summary
ConstructorsConstructorDescriptionSkillMemoryStore(Path directory) Creates a skill store backed by the given directory. -
Method Summary
Modifier and TypeMethodDescriptionfindByTags(Collection<String> tags) Finds skills matching any of the given tags.Retrieves a skill by name and updates its lastUsed timestamp.getAll()Returns all stored skills.booleanRemoves a skill by name.voidStores or updates a skill.intsize()Returns the number of stored skills.
-
Constructor Details
-
SkillMemoryStore
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
Stores or updates a skill.- Parameters:
skill- the skill to store- Throws:
IOException- if the file cannot be written
-
get
Retrieves a skill by name and updates its lastUsed timestamp.- Parameters:
name- the skill name- Returns:
- the skill, or empty if not found
-
findByTags
Finds skills matching any of the given tags.- Parameters:
tags- the tags to search for- Returns:
- matching skills, sorted by lastUsed descending
-
getAll
Returns all stored skills. -
remove
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.
-