Class: RobotLab::AgentSkill

Inherits:
Object
  • Object
show all
Defined in:
lib/robot_lab/agent_skill.rb

Overview

Value object representing an AgentSkills.io skill folder.

A skill is a directory containing SKILL.md with required front matter fields (name, description) and optional scripts/, references/, assets/.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(skill_md_path) ⇒ AgentSkill

Returns a new instance of AgentSkill.

Parameters:

  • skill_md_path (String, Pathname)

    path to the SKILL.md file

Raises:



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/robot_lab/agent_skill.rb', line 15

def initialize(skill_md_path)
  @path = Pathname.new(skill_md_path).dirname
  content = File.read(skill_md_path)
  front_matter, @_body = parse_skill_md(content)

  @name         = front_matter["name"]
  @description  = front_matter["description"]
  @capabilities = Capabilities.from_front_matter(front_matter)

  raise ConfigurationError, "SKILL.md at #{skill_md_path} missing 'name'"        if @name.to_s.strip.empty?
  raise ConfigurationError, "SKILL.md at #{skill_md_path} missing 'description'" if @description.to_s.strip.empty?
end

Instance Attribute Details

#capabilitiesObject (readonly)

Returns the value of attribute capabilities.



11
12
13
# File 'lib/robot_lab/agent_skill.rb', line 11

def capabilities
  @capabilities
end

#descriptionObject (readonly)

Returns the value of attribute description.



11
12
13
# File 'lib/robot_lab/agent_skill.rb', line 11

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/robot_lab/agent_skill.rb', line 11

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'lib/robot_lab/agent_skill.rb', line 11

def path
  @path
end

Instance Method Details

#instructionsObject

Full instruction text from the SKILL.md body (below the front matter).



29
30
31
# File 'lib/robot_lab/agent_skill.rb', line 29

def instructions
  @instructions ||= @_body.strip
end

#script_toolsObject

RobotLab::Tool instances wrapping each executable script. Non-executable scripts are skipped with a warning.



43
44
45
46
47
# File 'lib/robot_lab/agent_skill.rb', line 43

def script_tools
  @script_tools ||= scripts.filter_map do |script_path|
    ScriptTool.from_path(script_path, capabilities: @capabilities, skill_dir: @path.to_s)
  end
end

#scriptsObject

Pathnames of all files inside the scripts/ subdirectory, sorted.



34
35
36
37
38
39
# File 'lib/robot_lab/agent_skill.rb', line 34

def scripts
  @scripts ||= begin
    dir = @path.join("scripts")
    dir.directory? ? dir.children.select(&:file?).sort : []
  end
end