Class: Kward::PluginRegistry::Context
- Inherits:
-
Object
- Object
- Kward::PluginRegistry::Context
- Defined in:
- lib/kward/plugin_registry.rb
Overview
Runtime context passed to plugin commands, footers, prompt context renderers, and transcript event handlers.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#workspace_root ⇒ Object
readonly
Returns the value of attribute workspace_root.
Instance Method Summary collapse
-
#initialize(conversation:, args: "", session: nil, workspace_root: Dir.pwd, say_callback: nil) ⇒ Context
constructor
Creates an object for trusted plugin loading and dispatch.
-
#refresh_system_message! ⇒ nil
Requests that the conversation rebuild its system message after plugin state changes that affect prompt context.
-
#say(message) ⇒ nil
Emits command output to the active frontend when available.
- #session_id ⇒ Object
- #session_name ⇒ Object
- #session_path ⇒ Object
-
#transcript ⇒ Transcript
Read-only transcript wrapper.
Constructor Details
#initialize(conversation:, args: "", session: nil, workspace_root: Dir.pwd, say_callback: nil) ⇒ Context
Creates an object for trusted plugin loading and dispatch.
63 64 65 66 67 68 69 |
# File 'lib/kward/plugin_registry.rb', line 63 def initialize(conversation:, args: "", session: nil, workspace_root: Dir.pwd, say_callback: nil) @conversation = conversation @args = args.to_s @session = session @workspace_root = workspace_root @say_callback = say_callback end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
60 61 62 |
# File 'lib/kward/plugin_registry.rb', line 60 def args @args end |
#workspace_root ⇒ Object (readonly)
Returns the value of attribute workspace_root.
60 61 62 |
# File 'lib/kward/plugin_registry.rb', line 60 def workspace_root @workspace_root end |
Instance Method Details
#refresh_system_message! ⇒ nil
Requests that the conversation rebuild its system message after plugin state changes that affect prompt context.
101 102 103 104 |
# File 'lib/kward/plugin_registry.rb', line 101 def @conversation. if @conversation.respond_to?(:refresh_system_message!) nil end |
#say(message) ⇒ nil
Emits command output to the active frontend when available.
80 81 82 83 |
# File 'lib/kward/plugin_registry.rb', line 80 def say() @say_callback&.call(.to_s) nil end |
#session_id ⇒ Object
85 86 87 |
# File 'lib/kward/plugin_registry.rb', line 85 def session_id @session&.id end |
#session_name ⇒ Object
89 90 91 |
# File 'lib/kward/plugin_registry.rb', line 89 def session_name @session&.name end |
#session_path ⇒ Object
93 94 95 |
# File 'lib/kward/plugin_registry.rb', line 93 def session_path @session&.path end |
#transcript ⇒ Transcript
Returns read-only transcript wrapper.
72 73 74 |
# File 'lib/kward/plugin_registry.rb', line 72 def transcript Transcript.new(@conversation) end |