Class: Pikuri::Skill::Extension

Inherits:
Object
  • Object
show all
Includes:
Agent::Extension
Defined in:
lib/pikuri/skill/extension.rb

Overview

An Agent::Extension that auto-wires the Agent Skills standard onto an agent: appends the catalog’s <available_skills> block to the system prompt and registers the skill tool so the LLM can load skill bodies on demand.

Usage

Pass the extension via the Agent.new block:

catalog = Pikuri::Skill::Catalog::Bundled.discover
Pikuri::Agent.new(transport: ..., system_prompt: ...) do |c|
  c.add_extension Pikuri::Skill::Extension.new(catalog: catalog)
end

The configure hook is agent-agnostic — it appends a snippet and adds a tool, both of which sub-agents inherit verbatim through the existing snapshot mechanism. There is no per-agent state, so this extension does not implement bind (inherits the empty default from Agent::Extension).

Empty catalog

When the catalog is Catalog#empty?, the extension is a no-op — no snippet, no tool. Same semantics as the legacy skill_catalog: kwarg on Agent#initialize, which still routes through this extension as a transition layer until Step 5 of the gem-split refactor (see IDEAS.md).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(catalog:) ⇒ Extension

Returns a new instance of Extension.

Parameters:



41
42
43
# File 'lib/pikuri/skill/extension.rb', line 41

def initialize(catalog:)
  @catalog = catalog
end

Instance Attribute Details

#catalogPikuri::Skill::Catalog (readonly)



46
47
48
# File 'lib/pikuri/skill/extension.rb', line 46

def catalog
  @catalog
end

Instance Method Details

#configure(c) ⇒ void

This method returns an undefined value.

Append <available_skills> to the system prompt and register the skill tool. No-op when the catalog is empty.

The catalog’s format_for_prompt historically returns a snippet with leading blank lines (designed for the old system_prompt format_for_prompt+ concatenation). The Configurator handles the separator between base and snippet itself (Configurator#append_system_prompt drains with a nn join), so we lstrip to avoid doubling up the blank lines.

Parameters:

  • c (Pikuri::Agent::Configurator)


61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/pikuri/skill/extension.rb', line 61

def configure(c)
  return if @catalog.empty?

  if c.tools.any?(Pikuri::Skill::SkillTool)
    raise 'Pikuri::Skill::SkillTool cannot be pre-registered (in tools: or via c.add_tool) ' \
          'when adding Pikuri::Skill::Extension — the extension auto-registers it from the catalog.'
  end

  c.append_system_prompt(@catalog.format_for_prompt.lstrip)
  c.add_tool(Pikuri::Skill::SkillTool.new(catalog: @catalog))
  nil
end