Class: RubynCode::Tools::LoadSkill

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyn_code/tools/load_skill.rb

Constant Summary collapse

TOOL_NAME =
'load_skill'
DESCRIPTION =
'Loads a best-practice skill document into context. ' \
'Pass the skill name (e.g. "shared-examples", "adapter", "request-specs").'
PARAMETERS =
{
  name: { type: :string, required: true,
          description: 'Skill name, e.g. "adapter", "shared-examples", "request-specs"' }
}.freeze
RISK_LEVEL =
:read
REQUIRES_CONFIRMATION =
false

Instance Attribute Summary

Attributes inherited from Base

#project_root

Instance Method Summary collapse

Methods inherited from Base

description, parameters, requires_confirmation?, risk_level, #safe_path, summarize, to_schema, tool_name, #truncate

Constructor Details

#initialize(project_root:, skill_loader: nil) ⇒ LoadSkill

Returns a new instance of LoadSkill.



19
20
21
22
# File 'lib/rubyn_code/tools/load_skill.rb', line 19

def initialize(project_root:, skill_loader: nil)
  super(project_root: project_root)
  @skill_loader = skill_loader
end

Instance Method Details

#execute(name:) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/rubyn_code/tools/load_skill.rb', line 24

def execute(name:)
  # Strip leading slash — LLM sometimes sends /skill-name
  cleaned = name.to_s.sub(%r{\A/+}, '').strip
  return 'Error: skill name required' if cleaned.empty?

  loader = @skill_loader || default_loader
  loader.load(cleaned)
end