Class: RobotLab::AgentSkillCatalog

Inherits:
Object
  • Object
show all
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.expand_path("~/.prompts/skills"))

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(skills_root = SKILLS_ROOT) ⇒ AgentSkillCatalog

Returns a new instance of AgentSkillCatalog.

Parameters:

  • skills_root (String, Pathname) (defaults to: SKILLS_ROOT)

    directory to scan for skill folders



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

.instanceObject

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

#allArray<AgentSkill>

All discovered AgentSkill objects.

Returns:



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.

Parameters:

  • id (Symbol, String)

    skill folder name

Returns:



36
37
38
39
# File 'lib/robot_lab/agent_skill_catalog.rb', line 36

def find(id)
  load!
  @skills[id.to_sym]
end