Class: RobotLab::AgentSkill
- Inherits:
-
Object
- Object
- RobotLab::AgentSkill
- 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
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(skill_md_path) ⇒ AgentSkill
constructor
A new instance of AgentSkill.
-
#instructions ⇒ Object
Full instruction text from the SKILL.md body (below the front matter).
-
#script_tools ⇒ Object
RobotLab::Tool instances wrapping each executable script.
-
#scripts ⇒ Object
Pathnames of all files inside the scripts/ subdirectory, sorted.
Constructor Details
#initialize(skill_md_path) ⇒ AgentSkill
Returns a new instance of AgentSkill.
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
#description ⇒ Object (readonly)
Returns the value of attribute description.
11 12 13 |
# File 'lib/robot_lab/agent_skill.rb', line 11 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/robot_lab/agent_skill.rb', line 11 def name @name end |
#path ⇒ Object (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
#instructions ⇒ Object
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_tools ⇒ Object
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 |
#scripts ⇒ Object
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 |