Class: RubyCoded::Chat::CommandHandler
- Inherits:
-
Object
- Object
- RubyCoded::Chat::CommandHandler
- Includes:
- AgentCommands, CustomCommands, HistoryCommands, LoginCommands, ModelCommands, PlanCommands, TokenCommands, TokenFormatting
- Defined in:
- lib/ruby_coded/chat/command_handler.rb,
lib/ruby_coded/chat/command_handler/plan_commands.rb,
lib/ruby_coded/chat/command_handler/agent_commands.rb,
lib/ruby_coded/chat/command_handler/login_commands.rb,
lib/ruby_coded/chat/command_handler/model_commands.rb,
lib/ruby_coded/chat/command_handler/token_commands.rb,
lib/ruby_coded/chat/command_handler/custom_commands.rb,
lib/ruby_coded/chat/command_handler/history_commands.rb,
lib/ruby_coded/chat/command_handler/token_formatting.rb
Overview
Handles slash commands entered in the chat input. Commands are resolved from a unified command catalog, which may include core commands, plugin commands, and markdown commands.
Defined Under Namespace
Modules: AgentCommands, CustomCommands, HistoryCommands, LoginCommands, ModelCommands, PlanCommands, TokenCommands, TokenFormatting
Constant Summary collapse
- HELP_TEXT =
File.read(File.join(__dir__, "help.txt")).freeze
Instance Method Summary collapse
- #handle(raw_input) ⇒ Object
-
#initialize(state, llm_bridge:, command_catalog: nil, **deps) ⇒ CommandHandler
constructor
A new instance of CommandHandler.
Constructor Details
#initialize(state, llm_bridge:, command_catalog: nil, **deps) ⇒ CommandHandler
Returns a new instance of CommandHandler.
31 32 33 34 35 36 37 38 39 |
# File 'lib/ruby_coded/chat/command_handler.rb', line 31 def initialize(state, llm_bridge:, command_catalog: nil, **deps) @state = state @llm_bridge = llm_bridge @user_config = deps[:user_config] @credentials_store = deps[:credentials_store] @auth_manager = deps[:auth_manager] @command_catalog = command_catalog @commands = build_command_map end |
Instance Method Details
#handle(raw_input) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/ruby_coded/chat/command_handler.rb', line 41 def handle(raw_input) stripped = raw_input.strip return if stripped.empty? command, rest = stripped.split(" ", 2) dispatch_command(command, rest) end |