Class: Rubino::Commands::Executor
- Inherits:
-
Object
- Object
- Rubino::Commands::Executor
- Defined in:
- lib/rubino/commands/executor.rb
Overview
Executes a slash command, rendering its template and feeding it to the agent.
‘runner:` (optional) is the live Agent::Runner for the interactive REPL. When present, `/status` and `/sessions` can read the current session / model straight off it. It is nil for non-interactive callers (and unit tests that don’t exercise those commands), in which case those commands degrade gracefully instead of raising.
Constant Summary collapse
- MODEL_LIST_LIMIT =
How many model ids the bare ‘/model` listing renders before deferring the rest to the completion dropdown.
12
Class Method Summary collapse
-
.welcome(runner: nil, ui: nil) ⇒ Object
Renders the welcome variant on first interactive boot.
Instance Method Summary collapse
-
#initialize(loader: nil, ui: nil, runner: nil) ⇒ Executor
constructor
A new instance of Executor.
-
#try_execute(input) ⇒ Object
Attempts to execute input as a slash command.
Constructor Details
Class Method Details
.welcome(runner: nil, ui: nil) ⇒ Object
Renders the welcome variant on first interactive boot. Best-effort: a welcome banner must never block the REPL from starting, so any assembler hiccup degrades to no banner rather than a crash. The boot header (workspace/branch/model) is printed by the chat command; this adds only the orientation, with no duplicate identity/session-id renderings.
51 52 53 54 55 |
# File 'lib/rubino/commands/executor.rb', line 51 def self.welcome(runner: nil, ui: nil) new(ui: ui, runner: runner).send(:show_welcome) rescue StandardError nil end |
Instance Method Details
#try_execute(input) ⇒ Object
Attempts to execute input as a slash command. Returns the rendered prompt if it’s a command, nil otherwise.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rubino/commands/executor.rb', line 25 def try_execute(input) return nil unless @loader.slash_command?(input) name, arguments = @loader.parse(input) return nil unless name # Check built-in commands first built_in_result = handle_built_in(name, arguments) return built_in_result if built_in_result # Look up custom command command = @loader.find(name) unless command @ui.error("unknown command: /#{name}") @ui.info("Available: #{help_handler.available_commands.join(", ")}") return :handled # Signal that it was handled (even if failed) end run_custom_command(command, name, arguments) end |