Class: ClaudeOnRails::Generators::SwarmGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ClaudeOnRails::Generators::SwarmGenerator
- Defined in:
- lib/generators/claude_on_rails/swarm/swarm_generator.rb
Instance Method Summary collapse
- #analyze_project ⇒ Object
- #create_agent_prompts ⇒ Object
- #create_claude_md ⇒ Object
- #create_swarm_config ⇒ Object
- #display_next_steps ⇒ Object
- #update_gitignore ⇒ Object
Instance Method Details
#analyze_project ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/generators/claude_on_rails/swarm/swarm_generator.rb', line 26 def analyze_project say 'Analyzing Rails project structure...', :green @project_analysis = ClaudeOnRails.analyze_project(Rails.root) # Auto-detect features @api_only = [:api_only] || @project_analysis[:api_only] @has_graphql = [:graphql] || @project_analysis[:has_graphql] @has_turbo = [:turbo] && !@api_only @skip_tests = [:skip_tests] @test_framework = @project_analysis[:test_framework] # Check for Rails MCP Server @include_mcp_server = [:mcp_server] && ClaudeOnRails::MCPSupport.available? say "Project type: #{@api_only ? 'API-only' : 'Full-stack Rails'}", :cyan say "Test framework: #{@test_framework}", :cyan if @test_framework say "GraphQL detected: #{@has_graphql ? 'Yes' : 'No'}", :cyan say "Rails MCP Server: #{@include_mcp_server ? 'Available' : 'Not available'}", :cyan # Offer MCP setup if enabled but not available offer_mcp_setup if [:mcp_server] && !@include_mcp_server # Show which agents will be created say "\nAgents to be created:", :yellow agents.each do |agent| say " - #{agent}", :cyan end end |
#create_agent_prompts ⇒ Object
83 84 85 86 |
# File 'lib/generators/claude_on_rails/swarm/swarm_generator.rb', line 83 def create_agent_prompts say 'Setting up agent-specific prompts...', :green directory 'prompts', '.claude-on-rails/prompts' end |
#create_claude_md ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/generators/claude_on_rails/swarm/swarm_generator.rb', line 60 def create_claude_md # Always create the ClaudeOnRails context file template 'claude_on_rails_context.md', '.claude-on-rails/context.md' if File.exist?('CLAUDE.md') say 'CLAUDE.md already exists - adding ClaudeOnRails file reference...', :yellow existing_content = File.read('CLAUDE.md') # Check if file reference already exists if existing_content.include?('.claude-on-rails/context.md') say '✓ CLAUDE.md already references ClaudeOnRails context', :green else file_reference = "\n/file:.claude-on-rails/context.md\n" append_to_file 'CLAUDE.md', file_reference say '✓ Added ClaudeOnRails context reference to existing CLAUDE.md', :green end else say 'Creating CLAUDE.md configuration...', :green template 'CLAUDE.md.erb', 'CLAUDE.md' end end |
#create_swarm_config ⇒ Object
55 56 57 58 |
# File 'lib/generators/claude_on_rails/swarm/swarm_generator.rb', line 55 def create_swarm_config say 'Generating swarm configuration...', :green template 'swarm.yml.erb', 'claude-swarm.yml' end |
#display_next_steps ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/generators/claude_on_rails/swarm/swarm_generator.rb', line 98 def display_next_steps say "\n✅ ClaudeOnRails swarm configuration created!", :green say "\nNext steps:", :yellow # Remove this section since we now handle it interactively in analyze_project say '1. Review and customize claude-swarm.yml for your project' say '2. Start your Rails development swarm:' say ' claude-swarm', :cyan say "\nOnce the swarm is running, just describe what you want to build:" say ' > Add user authentication with social login', :cyan say "\nThe swarm will automatically coordinate the implementation across all layers!" end |
#update_gitignore ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/generators/claude_on_rails/swarm/swarm_generator.rb', line 88 def update_gitignore say 'Updating .gitignore...', :green gitignore_path = Rails.root.join('.gitignore') # Create .gitignore if it doesn't exist create_file '.gitignore', '' unless File.exist?(gitignore_path) append_to_file '.gitignore', "\n# ClaudeOnRails\n.claude-on-rails/sessions/\n.claude-swarm/\nclaude-swarm.log\n" end |