Class: RosettAi::Thor::Tasks::Plugins

Inherits:
Thor
  • Object
show all
Defined in:
lib/rosett_ai/thor/tasks/plugins.rb

Overview

Thor task for plugin management (list, install, remove).

Author:

  • hugo

  • claude

Constant Summary collapse

VALID_TYPES =

Returns Set of permitted type values.

Returns:

  • (Array)

    Set of permitted type values.

['engine', 'gui', 'mcp'].freeze

Instance Method Summary collapse

Instance Method Details

#install(type, name) ⇒ void

This method returns an undefined value.

Install the component.

Parameters:

  • type (Object)

    the type

  • name (Object)

    the name



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/rosett_ai/thor/tasks/plugins.rb', line 71

def install(type, name)
  validate_type!(type)
  package = plugin_package_name(type, name)

  warn t('installing', package: package)
  pm = select_package_manager

  if pm.install(package)
    RosettAi::Plugins::Registry.reset!
    RosettAi::Plugins::Registry.discover!
    warn Rainbow(t('installed', package: package)).green
  else
    warn Rainbow(t('install_failed', package: package)).red
    exit 1
  end
end

#list(type) ⇒ void

This method returns an undefined value.

List available items.

Parameters:

  • type (Object)

    the type



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rosett_ai/thor/tasks/plugins.rb', line 36

def list(type)
  validate_type!(type)
  type_sym = type.to_sym
  names = RosettAi::Plugins::Registry.available(type_sym)

  if names.empty?
    warn t('no_plugins', type: type)
    return
  end

  if tty_output?
    print_list_tty(type_sym, names)
  else
    print_list_json(type_sym, names)
  end
end

#remove(type, name) ⇒ void

This method returns an undefined value.

Remove the component.

Parameters:

  • type (Object)

    the type

  • name (Object)

    the name



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/rosett_ai/thor/tasks/plugins.rb', line 103

def remove(type, name)
  validate_type!(type)
  package = plugin_package_name(type, name)

  warn t('removing', package: package)
  pm = select_package_manager

  if pm.remove(package)
    RosettAi::Plugins::Registry.reset!
    RosettAi::Plugins::Registry.discover!
    warn Rainbow(t('removed', package: package)).green
  else
    warn Rainbow(t('remove_failed', package: package)).red
    exit 1
  end
end