Class: Kward::PluginRegistry::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/kward/plugin_registry.rb

Overview

DSL object yielded by Kward.plugin blocks.

Instance Method Summary collapse

Constructor Details

#initialize(registry, path) ⇒ DSL

Creates an object for trusted plugin loading and dispatch.



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

def initialize(registry, path)
  @registry = registry
  @path = path
end

Instance Method Details

#command(name, description: "", argument_hint: "") {|args, ctx| ... } ⇒ Object

Registers a slash command.

Parameters:

  • name (String, #to_s)

    command name without the leading slash

  • description (String) (defaults to: "")

    short text shown in command listings

  • argument_hint (String) (defaults to: "")

    optional usage hint for arguments

Yield Parameters:

  • args (String)

    text after the command name

  • ctx (Context)

    plugin execution context



113
114
115
# File 'lib/kward/plugin_registry.rb', line 113

def command(name, description: "", argument_hint: "", &block)
  @registry.register_command(name, description: description, argument_hint: argument_hint, path: @path, &block)
end

Registers or replaces the custom footer renderer.

Yield Parameters:

  • ctx (Context)

    plugin execution context



120
121
122
# File 'lib/kward/plugin_registry.rb', line 120

def footer(&block)
  @registry.register_footer(path: @path, &block)
end

#on_transcript_event {|event, ctx| ... } ⇒ Object

Registers a live transcript event observer.

Yield Parameters:



128
129
130
# File 'lib/kward/plugin_registry.rb', line 128

def on_transcript_event(&block)
  @registry.register_transcript_event(path: @path, &block)
end

#prompt_context {|ctx| ... } ⇒ Object

Registers prompt context text injected into future system prompts.

Yield Parameters:

  • ctx (Context)

    plugin execution context



135
136
137
# File 'lib/kward/plugin_registry.rb', line 135

def prompt_context(&block)
  @registry.register_prompt_context(path: @path, &block)
end