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
# 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"]

  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

#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).



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

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

#script_toolsObject

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



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

def script_tools
  @script_tools ||= scripts.filter_map do |script_path|
    ScriptTool.from_path(script_path)
  end
end

#scriptsObject

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



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

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