Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Task 4: Enhance Rails Project Detection Logic #5

@GoodPie

Description

@GoodPie

Issue

As a developer using rails-active-mcp from any directory, I need robust Rails project detection that can find Rails applications from subdirectories and handle various project structures while providing clear error messages for invalid paths.

The current find_rails_root function works but needs enhancement to support the new CLI patterns and be more resilient to different Rails project configurations and edge cases.

Proposed Solution

Enhance the existing Rails project detection logic by improving the find_rails_root function, integrating it with Thor CLI options for explicit paths and auto-detection, and adding better validation for various Rails project indicators and error handling for edge cases.

Breakdown

  • Extract and enhance existing find_rails_root logic
  • Implement determine_rails_path method to handle CLI option logic
  • Improve rails_project? validation to check multiple indicators:
    • config/application.rb (primary)
    • Gemfile with rails dependency (secondary)
    • Additional Rails indicators for edge cases
  • Add error handling for invalid paths and permissions
  • Integrate with Thor CLI options (--project, --auto-detect)
  • Maintain existing directory change behavior

Success Criteria

  • Enhanced project detection finds Rails projects from subdirectories
  • Explicit project paths work with absolute and relative paths
  • Invalid paths rejected with helpful error messages
  • Multiple Rails project indicators properly detected
  • Directory traversal stops at filesystem root safely
  • Integration with existing Rails loading logic preserved

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions