Class: Rubino::CLI::ToolsCommand
- Inherits:
-
Object
- Object
- Rubino::CLI::ToolsCommand
- Defined in:
- lib/rubino/cli/tools_command.rb
Overview
Lists available tools and their status
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubino/cli/tools_command.rb', line 7 def execute ui = Rubino.ui config = Rubino.configuration ui.info("Available Tools:") ui.blank_line # The registry is populated lazily when an agent runner boots; the bare # `rubino tools` command never boots one, so without this the table # is empty (F6). Registering the defaults is idempotent and matches what # ChatCommand#ensure_setup! does before a turn. Tools::Registry.register_defaults! if Tools::Registry.all.empty? # Report against the SAME config gate the registry enforces: each row # is a `tools.<config_key>` group, resolved exactly like # Registry#tool_enabled_in_config? (opt-out — absent key = enabled). # Deriving the rows from the registered tools' #config_key (rather # than a hardcoded list) means the displayed state can never drift # from reality — `web` no longer shows "disabled" while webfetch/ # websearch stay live, and the dead `browser` key is gone. # MCP wrappers are excluded here: they are dynamic (no `tools.<key>` # config gate) and get their own section below instead of fake rows # in the config-group table. builtins = Tools::Registry.all.grep_v(MCP::MCPToolWrapper) config_keys = builtins.map(&:config_key).uniq rows = config_keys.sort.map do |key| value = config.dig("tools", key) enabled = value.nil? || value == true [key, enabled ? "enabled" : "disabled"] end ui.table(headers: %w[Tool Status], rows: rows) print_enable_hint(rows) print_mcp_tools end |