Class: Pikuri::Skill::Activation::Sealed

Inherits:
Object
  • Object
show all
Defined in:
lib/pikuri/skill/activation/sealed.rb

Overview

An Pikuri::Skill::Activation with the door welded shut: gated skills stay withheld for the whole run, and promoting one raises.

sealed = Activation::Sealed.new(catalog: catalog)
sealed.get('data-viz')      # => #<Skill …> — ungated skills load normally
sealed.get('writing-rdoc')  # => nil — gated, and nothing can change that
sealed.activate([rdoc])     # => raises

What a spawned sub-agent's skill tool resolves against. A sub-agent inherits no extension, so no listener ever fires for it, and its prompt carries no catalog at all — a gated skill is a name it was never told, and reaching one through the parent's promotions would make the child's surface depend on which files the parent happened to read.

The raise is an assertion, not a policy: nothing can legitimately promote here, so a caller that turns up is a wiring bug worth seeing.

Thread-safe.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(catalog:) ⇒ Sealed

Returns a new instance of Sealed.

Parameters:



26
27
28
# File 'lib/pikuri/skill/activation/sealed.rb', line 26

def initialize(catalog:)
  @catalog = catalog
end

Instance Attribute Details

#catalogPikuri::Skill::Catalog (readonly)

Returns the unfiltered catalog behind this view.

Returns:



31
32
33
# File 'lib/pikuri/skill/activation/sealed.rb', line 31

def catalog
  @catalog
end

Instance Method Details

#activate(skills) ⇒ void

This method returns an undefined value.

Returns never returns.

Parameters:

Raises:

  • (RuntimeError)

    always



55
56
57
58
# File 'lib/pikuri/skill/activation/sealed.rb', line 55

def activate(skills)
  raise "a sealed Activation cannot promote #{skills.map(&:name).join(', ')}" \
        'nothing should path-activate a skill inside a sub-agent'
end

#get(name) ⇒ Pikuri::Skill::Catalog::Skill?

Returns nil for a gated skill, the same answer a name that exists nowhere gets.

Parameters:

  • name (String)

Returns:



43
44
45
# File 'lib/pikuri/skill/activation/sealed.rb', line 43

def get(name)
  in_play?(name) ? @catalog.get(name) : nil
end

#in_play?(name) ⇒ Boolean

Returns true only for a skill that declared no gate.

Parameters:

  • name (String)

Returns:

  • (Boolean)

    true only for a skill that declared no gate



35
36
37
38
# File 'lib/pikuri/skill/activation/sealed.rb', line 35

def in_play?(name)
  skill = @catalog.get(name)
  !skill.nil? && !skill.gated?
end

#namesArray<String>

Returns sorted names of the ungated skills.

Returns:

  • (Array<String>)

    sorted names of the ungated skills



48
49
50
# File 'lib/pikuri/skill/activation/sealed.rb', line 48

def names
  @catalog.list.reject(&:gated?).map(&:name).sort
end

#resetvoid

This method returns an undefined value.

Returns no-op: there is never anything to clear.



61
# File 'lib/pikuri/skill/activation/sealed.rb', line 61

def reset = nil