Class: RubyLlmAgents::AgentGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- RubyLlmAgents::AgentGenerator
- Defined in:
- lib/generators/ruby_llm_agents/agent_generator.rb
Overview
Agent generator for creating new agents
Usage:
rails generate ruby_llm_agents:agent SearchIntent query:required limit:10
This will create:
- app/agents/search_intent_agent.rb
Parameter syntax:
name - Optional parameter
name:required - Required parameter
name:default - Optional with default value (e.g., limit:10)
Defined Under Namespace
Classes: ParsedParam
Instance Method Summary collapse
Instance Method Details
#create_agent_file ⇒ Object
50 51 52 53 54 |
# File 'lib/generators/ruby_llm_agents/agent_generator.rb', line 50 def create_agent_file # Support nested paths: "chat/support" -> "app/agents/chat/support_agent.rb" agent_path = name.underscore template "agent.rb.tt", "app/agents/#{agent_path}_agent.rb" end |
#ensure_base_class_and_skill_file ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/generators/ruby_llm_agents/agent_generator.rb', line 31 def ensure_base_class_and_skill_file agents_dir = "app/agents" # Create directory if needed empty_directory agents_dir # Create base class if it doesn't exist base_class_path = "#{agents_dir}/application_agent.rb" unless File.exist?(File.join(destination_root, base_class_path)) template "application_agent.rb.tt", base_class_path end # Create skill file if it doesn't exist skill_file_path = "#{agents_dir}/AGENTS.md" unless File.exist?(File.join(destination_root, skill_file_path)) template "skills/AGENTS.md.tt", skill_file_path end end |
#show_usage ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/generators/ruby_llm_agents/agent_generator.rb', line 56 def show_usage # Build full class name from path (e.g., "chat/support" -> "Chat::SupportAgent") agent_class_name = name.split("/").map(&:camelize).join("::") full_class_name = "#{agent_class_name}Agent" say "" say "Agent #{full_class_name} created!", :green say "" say "Usage:" say " #{full_class_name}.call(#{usage_params})" say " #{full_class_name}.call(#{usage_params}, dry_run: true)" say "" end |