Class: RobotLab::AgentSkillCatalog
- Inherits:
-
Object
- Object
- RobotLab::AgentSkillCatalog
- Defined in:
- lib/robot_lab/agent_skill_catalog.rb
Overview
Singleton registry that scans ~/.prompts/skills/ and provides AgentSkill lookup by ID.
Skills are loaded lazily on first access (thread-safe via Mutex). Bad SKILL.md files (missing name/description) are skipped with a warning.
Constant Summary collapse
- SKILLS_ROOT =
Pathname.new(File.("~/.prompts/skills"))
Class Method Summary collapse
-
.instance ⇒ Object
The process-level singleton instance (uses SKILLS_ROOT).
-
.reset! ⇒ Object
Reset the singleton (used in tests to swap the skills root).
Instance Method Summary collapse
-
#all ⇒ Array<AgentSkill>
All discovered AgentSkill objects.
-
#find(id) ⇒ AgentSkill?
Return the AgentSkill for the given ID, or nil if not found.
-
#initialize(skills_root = SKILLS_ROOT) ⇒ AgentSkillCatalog
constructor
A new instance of AgentSkillCatalog.
Constructor Details
#initialize(skills_root = SKILLS_ROOT) ⇒ AgentSkillCatalog
Returns a new instance of AgentSkillCatalog.
25 26 27 28 29 30 |
# File 'lib/robot_lab/agent_skill_catalog.rb', line 25 def initialize(skills_root = SKILLS_ROOT) @skills_root = Pathname.new(skills_root) @skills = {} @mutex = Mutex.new @loaded = false end |
Class Method Details
.instance ⇒ Object
The process-level singleton instance (uses SKILLS_ROOT).
14 15 16 |
# File 'lib/robot_lab/agent_skill_catalog.rb', line 14 def instance @instance ||= new(SKILLS_ROOT) end |
.reset! ⇒ Object
Reset the singleton (used in tests to swap the skills root).
19 20 21 |
# File 'lib/robot_lab/agent_skill_catalog.rb', line 19 def reset! @instance = nil end |
Instance Method Details
#all ⇒ Array<AgentSkill>
All discovered AgentSkill objects.
44 45 46 47 |
# File 'lib/robot_lab/agent_skill_catalog.rb', line 44 def all load! @skills.values end |
#find(id) ⇒ AgentSkill?
Return the AgentSkill for the given ID, or nil if not found.
36 37 38 39 |
# File 'lib/robot_lab/agent_skill_catalog.rb', line 36 def find(id) load! @skills[id.to_sym] end |