Skip to content
Kward Search API index

Class: Kward::PluginRegistry::Context

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#argsObject (readonly)

Returns the value of attribute args.



60
61
62
# File 'lib/kward/plugin_registry.rb', line 60

def args
  @args
end

#workspace_rootObject (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.

Returns:

  • (nil)


101
102
103
104
# File 'lib/kward/plugin_registry.rb', line 101

def refresh_system_message!
  @conversation.refresh_system_message! if @conversation.respond_to?(:refresh_system_message!)
  nil
end

#say(message) ⇒ nil

Emits command output to the active frontend when available.

Parameters:

  • message (#to_s)

    message to display

Returns:

  • (nil)


80
81
82
83
# File 'lib/kward/plugin_registry.rb', line 80

def say(message)
  @say_callback&.call(message.to_s)
  nil
end

#session_idObject



85
86
87
# File 'lib/kward/plugin_registry.rb', line 85

def session_id
  @session&.id
end

#session_nameObject



89
90
91
# File 'lib/kward/plugin_registry.rb', line 89

def session_name
  @session&.name
end

#session_pathObject



93
94
95
# File 'lib/kward/plugin_registry.rb', line 93

def session_path
  @session&.path
end

#transcriptTranscript

Returns read-only transcript wrapper.

Returns:



72
73
74
# File 'lib/kward/plugin_registry.rb', line 72

def transcript
  Transcript.new(@conversation)
end