Class: Insika::Tools::LoadSkill

Inherits:
RubyLLM::Tool
  • Object
show all
Defined in:
lib/insika/tools/load_skill.rb

Overview

Level 2 of progressive disclosure: loads the full SKILL.md body on demand. Respects the agent's allowlist (the model does not load a skill that the policy did not expose).

require "ruby_llm" stays in THIS file (it inherits from RubyLLM::Tool), which is why it does NOT enter lib/insika.rb: the Executor loads it lazily inside create_chat.

Instance Method Summary collapse

Constructor Details

#initialize(catalog, allowed_names) ⇒ LoadSkill

Returns a new instance of LoadSkill.



25
26
27
28
29
# File 'lib/insika/tools/load_skill.rb', line 25

def initialize(catalog, allowed_names)
  @catalog = catalog
  @allowed = Array(allowed_names).map(&:to_s)
  super()
end

Instance Method Details

#execute(name:) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/insika/tools/load_skill.rb', line 31

def execute(name:)
  return { error: "skill '#{name}' not available for this agent" } unless @allowed.include?(name.to_s)

  skill = @catalog.find(name)
  return { error: "skill '#{name}' not found" } unless skill

  skill.body
end

#nameObject

RubyLLM::Tool#name derives from self.class.name — for a nested class it produces "insika--tools--load_skill", not "load_skill" (which wire_callbacks/ :skill_activated and SkillCatalog#format_for_prompt assume). Explicit override. Coexists with param :name (verified: the param is still present).



23
# File 'lib/insika/tools/load_skill.rb', line 23

def name = "load_skill"