Module: Protege::Manifested::ClassMethods

Defined in:
lib/protege/extensions/manifested.rb

Overview

Class-level metadata surface added to every extension base.

Instance Method Summary collapse

Instance Method Details

#description(value = nil) ⇒ String?

A natural-language description of the extension: the declared value, or nil when unset. Pass a value to set it. For a tool this is the LLM-facing text published in the model's tool schema — verbose and model-directed. For a short, human-facing dashboard blurb, use #summary instead.

Parameters:

  • value (String, nil) (defaults to: nil)

    the description to set, or nil to read

Returns:

  • (String, nil)

    the description



54
55
56
57
58
# File 'lib/protege/extensions/manifested.rb', line 54

def description(value = nil)
  return @description if value.nil?

  @description = value
end

#display_name(value = nil) ⇒ String

A human-readable label for the dashboard: the declared name, or the titleized id by default. Pass a value to set it.

Parameters:

  • value (String, nil) (defaults to: nil)

    the display name to set, or nil to read

Returns:

  • (String)

    the display name



42
43
44
45
46
# File 'lib/protege/extensions/manifested.rb', line 42

def display_name(value = nil)
  return @display_name || id.to_s.titleize if value.nil?

  @display_name = value
end

#idSymbol

The extension's stable symbolic id — the manifest key a binding references and the dashboard shows. Defaults to the class basename with a trailing +Tool+/+Provider+/+Hook+/+Resolver+ suffix stripped and the rest snake_cased; override with #manifest_id when the id must be explicit (a provider, whose id is matched against config.provider_id). Memoized per class.

Returns:

  • (Symbol)

    the extension id



25
26
27
# File 'lib/protege/extensions/manifested.rb', line 25

def id
  @id ||= name.demodulize.sub(/(?:Tool|Provider|Hook|Resolver)\z/, '').underscore.to_sym
end

#manifest_id(value) ⇒ Symbol

Declare an explicit id, overriding the name-derived default.

Parameters:

  • value (Symbol, String)

    the explicit id

Returns:

  • (Symbol)

    the stored id



33
34
35
# File 'lib/protege/extensions/manifested.rb', line 33

def manifest_id(value)
  @id = value.to_sym
end

#registeredArray<Class>

The loaded, named concrete subclasses of this extension base — its registry. Anonymous classes (nil name) are skipped; descendant-based so it survives Zeitwerk reloads without bookkeeping.

Returns:

  • (Array<Class>)

    the registered extension classes



76
77
78
# File 'lib/protege/extensions/manifested.rb', line 76

def registered
  descendants.reject { _1.name.nil? }
end

#summary(value = nil) ⇒ String?

A short, human-facing one-liner for the dashboard — what an operator reads when picking this extension. Distinct from #description, which for tools is the verbose text sent to the model. The declared value, or nil when unset. Pass a value to set it.

Parameters:

  • value (String, nil) (defaults to: nil)

    the summary to set, or nil to read

Returns:

  • (String, nil)

    the summary



66
67
68
69
70
# File 'lib/protege/extensions/manifested.rb', line 66

def summary(value = nil)
  return @summary if value.nil?

  @summary = value
end