Module: Legion::Extensions::Agentic::Self::Metacognition::Helpers::NarratorBridge

Defined in:
lib/legion/extensions/agentic/self/metacognition/helpers/narrator_bridge.rb

Class Method Summary collapse

Class Method Details

.narrate_architecture(arch) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/legion/extensions/agentic/self/metacognition/helpers/narrator_bridge.rb', line 28

def narrate_architecture(arch)
  return nil unless arch.is_a?(Hash)

  loaded = arch[:loaded_count] || 0
  total = arch[:total_extensions] || 0
  unloaded = arch[:unloaded] || []

  base = "#{loaded} of #{total} extensions are active."
  if unloaded.empty?
    base
  else
    "#{base} Missing: #{unloaded.first(3).join(', ')}#{'...' if unloaded.size > 3}."
  end
end

.narrate_capabilities(capabilities) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/legion/extensions/agentic/self/metacognition/helpers/narrator_bridge.rb', line 71

def narrate_capabilities(capabilities)
  return nil unless capabilities.is_a?(Hash)

  active_cats = capabilities.select { |_, v| v[:active] }.keys
  return nil if active_cats.empty?

  "Active capabilities: #{active_cats.join(', ')}."
end

.narrate_cognitive(cognitive) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/legion/extensions/agentic/self/metacognition/helpers/narrator_bridge.rb', line 43

def narrate_cognitive(cognitive)
  return nil unless cognitive.is_a?(Hash)
  return 'No tick data available.' if cognitive[:status] == :no_tick_data

  parts = []
  parts << "Operating in #{cognitive[:mode]} mode." if cognitive[:mode] && cognitive[:mode] != :unknown
  parts << "Running #{cognitive[:phases_run]} phases per tick." if cognitive[:phases_run]

  if cognitive[:health]
    label = SelfModel.health_label(cognitive[:health])
    parts << "Cognitive health: #{label} (#{(cognitive[:health] * 100).round}%)."
  end

  parts << "Active drives: #{cognitive[:active_drives].join(', ')}." if cognitive[:active_drives]&.any?

  if cognitive[:attention]
    att = cognitive[:attention]
    parts << "#{att[:spotlight] || 0} signals in spotlight focus." if att[:spotlight]
  end

  if cognitive[:curiosity]
    cur = cognitive[:curiosity]
    parts << "#{cur[:open_wonders] || 0} open questions." if cur[:open_wonders]
  end

  parts.join(' ')
end

.narrate_identity(identity) ⇒ Object



21
22
23
24
25
26
# File 'lib/legion/extensions/agentic/self/metacognition/helpers/narrator_bridge.rb', line 21

def narrate_identity(identity)
  return nil unless identity.is_a?(Hash)

  "I am a #{identity[:model]} #{identity[:role]} built on #{identity[:framework]} " \
    "with #{identity[:extensions]} extension slots."
end

.narrate_self_model(model) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/legion/extensions/agentic/self/metacognition/helpers/narrator_bridge.rb', line 12

def narrate_self_model(model)
  parts = []
  parts << narrate_identity(model[:identity])
  parts << narrate_architecture(model[:architecture])
  parts << narrate_cognitive(model[:cognitive])
  parts << narrate_capabilities(model[:capabilities])
  parts.compact.join(' ')
end