class Riffer::Skills::Context
Skills context for an agent generation cycle — coordinates discovery, activation, and prompt rendering, caching activations to avoid redundant backend reads. Exposed to tools via context.skills.
Attributes
The skill adapter used for this context.
Optional callback invoked when a skill is first activated.
Skill catalog indexed by name.
Public Class Methods
Source
# File lib/riffer/skills/context.rb, line 22 def initialize(backend:, skills:, adapter:) @backend = backend @skills = skills @adapter = adapter @activated = {} #: Hash[String, String] end
Public Instance Methods
Source
# File lib/riffer/skills/context.rb, line 62 def activatable? available_skills.any? end
Returns whether any skill is available for the model to activate.
Source
# File lib/riffer/skills/context.rb, line 35 def activate(name) raise Riffer::ArgumentError, "Unknown skill: '#{name}'" unless skills.key?(name) return @activated[name] if @activated.key?(name) @activated[name] = @backend.read_skill(name) @on_activate&.call(name) @activated[name] end
Activates a skill by name. Returns the cached body on re-activation.
Raises Riffer::ArgumentError if the skill is not in the catalog.
Source
# File lib/riffer/skills/context.rb, line 47 def activated?(name) @activated.key?(name) end
Returns whether a skill has been activated.
Source
# File lib/riffer/skills/context.rb, line 54 def model_invocable?(name) skill = skills[name] !skill.nil? && !skill.disable_model_invocation end
Returns whether a skill exists and may be activated by the model.
Source
# File lib/riffer/skills/context.rb, line 70 def system_prompt available = available_skills parts = [] #: Array[String] parts << @adapter.render_catalog(available) unless available.empty? @activated.each_value { |body| parts << body } parts.join("\n\n") end
Returns the complete skills section for the system prompt — the catalog plus any pre-activated skill bodies.