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
A new instance of Context.
-
#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
Returns a new instance of Context.
46 47 48 49 50 51 52 |
# File 'lib/kward/plugin_registry.rb', line 46 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.
44 45 46 |
# File 'lib/kward/plugin_registry.rb', line 44 def args @args end |
#workspace_root ⇒ Object (readonly)
Returns the value of attribute workspace_root.
44 45 46 |
# File 'lib/kward/plugin_registry.rb', line 44 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.
84 85 86 87 |
# File 'lib/kward/plugin_registry.rb', line 84 def @conversation. if @conversation.respond_to?(:refresh_system_message!) nil end |
#say(message) ⇒ nil
Emits command output to the active frontend when available.
63 64 65 66 |
# File 'lib/kward/plugin_registry.rb', line 63 def say() @say_callback&.call(.to_s) nil end |
#session_id ⇒ Object
68 69 70 |
# File 'lib/kward/plugin_registry.rb', line 68 def session_id @session&.id end |
#session_name ⇒ Object
72 73 74 |
# File 'lib/kward/plugin_registry.rb', line 72 def session_name @session&.name end |
#session_path ⇒ Object
76 77 78 |
# File 'lib/kward/plugin_registry.rb', line 76 def session_path @session&.path end |
#transcript ⇒ Transcript
Returns read-only transcript wrapper.
55 56 57 |
# File 'lib/kward/plugin_registry.rb', line 55 def transcript Transcript.new(@conversation) end |