code_healer 0.1.12 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c3f51b2e61939becd7c68f57c2f70cb9dacf3b98f8ff62cfa2b3593dc745cfe
4
- data.tar.gz: 8acbfcd6a4e3abae5cb96a2f451c01f6dc8ac40ada877fba4ed673962e87ab83
3
+ metadata.gz: a0eb37a96fca96ae0321a1ee24addb93e3dee8d0755ca5df8934c04420ef3548
4
+ data.tar.gz: b49f5a80ae6cc86b5bc0cd1ccd798a7279ea5d444be32894fb5514599cd13482
5
5
  SHA512:
6
- metadata.gz: 892a29730e66d2e207460dd2ede2c93b42114760a509ff05b7e17b5a28545ecb7fe1be0078d16cf7ff1f88a106a99d9e20af8ffd0baa53b8442ce2898363e1e0
7
- data.tar.gz: a89f5fccbc969fd0eccc468896c0ff0532868fb9ceb6a22a1e731319f2da2f602e2917f61add01424ea4c1fb869fef47d28b7e78e379d0c52d02e9666e65663e
6
+ metadata.gz: 98e5125e4f561073f31a8f263b5aba7b4ec62dba1d7a9c6b3dca818aa412c5f4578a55ff28dc95dd27768aa86dc61353050c43960ed29d8cc2499790bccef987
7
+ data.tar.gz: 52611005c0b0e47e16e86fb6f0d62ff0aea6a338e42de0b725e5de7a1d77713f3e89494db821d5f06c350283bf6027d629c859a3515e8dcb7cdb0cda113823f7
data/CHANGELOG.md CHANGED
@@ -5,156 +5,126 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [0.1.12] - 2025-01-14
8
+ ## [0.1.15] - 2025-08-21
9
9
 
10
10
  ### Fixed
11
- - **Duplicate PR creation** - Prevents duplicate pull requests when evolution handler already creates one
12
- - **PR workflow optimization** - Skips redundant PR creation in healing workspace manager
11
+ - **Dashboard Template Loading**: Fixed template loading issues by explicitly specifying view paths
12
+ - **Engine Views Configuration**: Properly configured engine views path to resolve template missing errors
13
+ - **Controller Template Rendering**: Updated render calls to use explicit template paths
13
14
 
14
- ## [0.1.11] - 2025-01-14
15
+ ### Changed
16
+ - **Template Rendering**: Changed from implicit template rendering to explicit template path specification
17
+ - **View Path Configuration**: Enhanced engine configuration for proper view loading
15
18
 
16
- ### Fixed
17
- - **Repository cloning** - Now clones from GitHub remote URL instead of local path
18
- - **Git remote configuration** - Ensures workspace has correct GitHub remote for PR creation
19
- - **Debug information** - Added Git remote and branch debugging in workspace operations
19
+ ## [0.1.14] - 2025-08-21
20
20
 
21
- ## [0.1.10] - 2025-01-14
21
+ ### Added
22
+ - **Dashboard UI Improvements**: Enhanced dashboard with proper HTML layout and styling
23
+ - **Charts and Visualizations**: Added Chart.js integration for data visualization
24
+ - **Detailed Views**: Enhanced healing details and performance metrics views
25
+ - **Responsive Design**: Mobile-friendly dashboard interface
26
+
27
+ ### Fixed
28
+ - **SQL Compatibility**: Replaced raw SQL with Rails-native methods for better database compatibility
29
+ - **Dashboard Controller**: Fixed controller loading and routing issues
30
+ - **Engine Integration**: Simplified engine structure to avoid conflicts
22
31
 
23
32
  ### Changed
24
- - **Complete workspace isolation** - All Git operations now happen in isolated workspace only
25
- - **No file copying** - Removed file copying between workspace and main repo
26
- - **Direct PR creation** - Pull requests are created directly from the isolated workspace
27
- - **Main repo protection** - Main repository is never touched, only the isolated workspace
33
+ - **Metrics Collection**: Improved performance of dashboard metrics queries
34
+ - **UI Rendering**: Replaced plain text dashboard with proper HTML views
28
35
 
29
- ### Fixed
30
- - **Git commit workflow** - Added proper change detection before committing
31
- - **Empty branch prevention** - Delete healing branches when no changes are detected
32
- - **Enhanced debugging** - Added Git status and diff logging throughout the process
36
+ ## [0.1.13] - 2025-08-21
37
+
38
+ ### Added
39
+ - **Automatic Dashboard Integration**: Rails Engine automatically mounts dashboard routes
40
+ - **Database Migrations**: Automatic migration copying and execution
41
+ - **Dashboard Components**: Complete dashboard system with metrics, trends, and performance views
42
+ - **API Endpoints**: JSON API for dashboard data integration
33
43
 
34
- ## [0.1.8] - 2025-01-14
44
+ ### Fixed
45
+ - **Git Operations**: All Git operations now occur within isolated healing workspaces
46
+ - **PR Creation**: Fixed duplicate PR creation and repository targeting issues
47
+ - **Workspace Management**: Improved isolated healing environment with proper cleanup
35
48
 
36
49
  ### Changed
37
- - **Production safety** - Healing workspace no longer modifies main directory directly
38
- - **Git workflow** - Changes are applied to isolated healing branches only
39
- - **Pull request automation** - Automatic PR creation when configured
40
- - **Method renaming** - `merge_fixes_back` → `create_healing_branch` for clarity
50
+ - **Healing Workflow**: Complete isolation of healing operations from main repository
51
+ - **Dashboard Installation**: Fully automatic dashboard setup via Rails Engine
52
+
53
+ ## [0.1.12] - 2025-08-20
41
54
 
42
55
  ### Fixed
43
- - **Git operations in isolated healing workspace** - Preserved .git directory during cloning for proper Git operations
44
- - **Branch creation and commit operations** now work correctly in the isolated workspace
45
- - **Workspace cleanup** properly removes .git directory to prevent conflicts
56
+ - **Duplicate PR Creation**: Prevented duplicate PR creation when evolution handler already creates PRs
57
+ - **Workspace Cleanup**: Improved cleanup of healing workspaces
46
58
 
47
- ## [0.1.6] - 2025-01-14
48
-
49
- ### Added
50
- - **Code heal directory permission validation** during interactive setup
51
- - **Repository access testing** to ensure the directory can clone and push to the target repo
52
- - **Write permission verification** for the code heal directory
53
- - **Automatic directory creation** if it doesn't exist
54
- - **Comprehensive error messages** with troubleshooting tips for permission issues
59
+ ## [0.1.11] - 2025-08-20
55
60
 
56
61
  ### Fixed
57
- - **Duplicate HealingJob class definition** that was preventing isolated healing workspace system from working
58
- - **Class loading conflict** between old and new healing logic
59
- - **Isolated healing workspace system** now properly activated
62
+ - **Repository Cloning**: Fixed incorrect repository cloning by using GitHub remote URL instead of local path
63
+ - **Git Remote**: Ensured workspace has correct remote origin for proper Git operations
60
64
 
61
- ## [0.1.4] - 2025-01-14
65
+ ## [0.1.10] - 2025-08-20
62
66
 
63
- ### Added
64
- - **Comprehensive logging** for isolated healing workspace system
65
- - **Detailed workspace creation logs** showing each step of the process
66
- - **Clone operation logging** with success/failure status
67
- - **Fix application logging** in isolated environment
68
- - **Workspace cleanup logging** for debugging
67
+ ### Changed
68
+ - **Git Operations**: All Git operations (branching, committing, pushing, PR creation) now occur strictly within isolated workspace
69
+ - **File Operations**: Removed direct file copying to main repository for complete isolation
70
+
71
+ ## [0.1.9] - 2025-08-20
69
72
 
70
73
  ### Fixed
71
- - **Workspace configuration reading** to handle both string and symbol keys
72
- - **Branch name sanitization** to prevent invalid Git branch names
74
+ - **Git Commit Issues**: Added proper change detection before committing in isolated workspace
75
+ - **File Comparison**: Enhanced file comparison logic to only copy changed files
73
76
 
74
- ## [0.1.3] - 2025-01-14
77
+ ## [0.1.8] - 2025-08-20
75
78
 
76
- ### Added
77
- - **Future Plans & Roadmap section** to README
78
- - Jira integration plans for business context automation
79
- - Confluence docs integration for domain knowledge extraction
80
- - PRD parsing capabilities for feature specifications
81
- - Git commit message analysis for business context learning
82
- - Slack/Teams integration for business discussions capture
83
- - Intelligent context discovery from existing code patterns
79
+ ### Fixed
80
+ - **Workspace Cleanup**: Improved cleanup process to prevent Git conflicts
84
81
 
85
- ## [0.1.2] - 2025-01-14
82
+ ## [0.1.7] - 2025-08-20
86
83
 
87
- ### Changed
88
- - **Final README improvements and personalization**
89
- - Updated contact email to deepan.ppgit@gmail.com
90
- - Added LinkedIn profile link for professional networking
91
- - Enhanced acknowledgments to include Claude AI
92
- - Personalized team references to Deepan Kumar
93
- - Added personal signature with LinkedIn link
84
+ ### Fixed
85
+ - **Git Working Tree**: Preserved .git directory during cloning and only removed during cleanup
94
86
 
95
- ## [0.1.1] - 2025-01-14
87
+ ## [0.1.6] - 2025-08-20
96
88
 
97
- ### Changed
98
- - **Significantly improved README documentation**
99
- - Enhanced setup instructions with interactive bash script guidance
100
- - Added comprehensive configuration explanations for all 50+ options
101
- - Included detailed markdown file creation guide for business context
102
- - Added best practices and troubleshooting sections
103
- - Improved installation and configuration examples
104
- - Enhanced advanced configuration strategies documentation
89
+ ### Fixed
90
+ - **Branch Name Sanitization**: Improved branch name handling for Git operations
91
+
92
+ ## [0.1.5] - 2025-08-20
105
93
 
106
94
  ### Fixed
107
- - Updated repository URLs in gemspec to point to correct GitHub repo
108
- - Fixed executable path configuration in gemspec
95
+ - **Duplicate Class Definition**: Removed duplicate HealingJob class definition causing Sidekiq errors
109
96
 
110
- ## [Unreleased]
97
+ ## [0.1.4] - 2025-08-20
111
98
 
112
- ### Added
113
- - Initial gem release
114
- - AI-powered error analysis and code generation
115
- - Multiple healing strategies (API, Claude Code, Hybrid)
116
- - Business context awareness and integration
117
- - Automated Git operations and PR creation
118
- - Background job processing with Sidekiq
119
- - Comprehensive YAML configuration
120
- - Business requirements integration from markdown files
121
- - Rails integration via Railtie
99
+ ### Fixed
100
+ - **Workspace Logging**: Added comprehensive logging to isolated healing workspace system
122
101
 
123
- ### Changed
124
- - Converted from standalone Rails application to gem
125
- - Refactored for modular architecture
126
- - Improved error handling and logging
127
- - Renamed from CodeHealer to CodeHealer
102
+ ## [0.1.3] - 2025-08-20
128
103
 
129
- ### Deprecated
130
- - None
104
+ ### Fixed
105
+ - **Configuration Keys**: Updated HealingWorkspaceManager to handle both string and symbol keys
131
106
 
132
- ### Removed
133
- - None
107
+ ## [0.1.2] - 2025-08-20
134
108
 
135
109
  ### Fixed
136
- - Business context loading from markdown files
137
- - Template placeholder substitution in PR creation
138
- - Sidekiq job serialization issues
110
+ - **Git Operations**: Fixed Git operations in isolated healing workspaces
111
+
112
+ ## [0.1.1] - 2025-08-20
139
113
 
140
- ### Security
141
- - Class restriction system for security
142
- - Environment variable support for sensitive data
143
- - Business rule validation
114
+ ### Fixed
115
+ - **Production Safety**: Enhanced production safety with isolated healing workspaces
116
+ - **Git Integration**: Improved Git integration within isolated environments
144
117
 
145
- ## [0.1.0] - 2025-01-13
118
+ ## [0.1.0] - 2025-08-20
146
119
 
147
120
  ### Added
148
- - Initial release of CodeHealer gem
149
- - Core healing engine
150
- - OpenAI API integration
151
- - Claude Code terminal integration
152
- - Business context management
153
- - Git operations automation
154
- - Sidekiq background processing
155
- - Comprehensive documentation
156
- - Example configurations
157
- - Test suite setup
121
+ - **AI-Powered Code Healing**: Automatic code error detection and repair
122
+ - **Multiple AI Providers**: Support for OpenAI API and Claude Code Terminal
123
+ - **Business Context Integration**: MCP-powered intelligent healing with business rules
124
+ - **Git Integration**: Automatic branch creation, commits, and pull requests
125
+ - **Isolated Healing**: Safe code modification in isolated workspaces
126
+ - **Dashboard System**: Metrics collection and visualization
127
+ - **Rails Integration**: Automatic Rails application integration via Railtie
158
128
 
159
129
  ---
160
130
 
@@ -0,0 +1,157 @@
1
+ # 🎯 CodeHealer Dashboard - Core Metrics & Analytics
2
+
3
+ ## 🚀 **Phase 1: Core Dashboard Implementation**
4
+
5
+ The CodeHealer Dashboard provides real-time insights into your intelligent code healing system. This is the foundation for comprehensive analytics and monitoring.
6
+
7
+ ## 📊 **What's Included**
8
+
9
+ ### **Core Metrics Dashboard**
10
+ - **Total Healings**: Count of all successful code fixes
11
+ - **Success Rate**: Percentage of successful vs failed healings
12
+ - **Daily/Weekly/Monthly Counts**: Healing activity over time
13
+ - **Average Resolution Time**: How long fixes take to complete
14
+ - **AI Performance**: Success rates by evolution method and AI provider
15
+
16
+ ### **Real-Time Analytics**
17
+ - **Daily Healing Trends**: Line charts showing healing activity
18
+ - **Evolution Method Distribution**: Doughnut charts for AI strategy usage
19
+ - **Recent Healings**: Detailed list of latest healing operations
20
+ - **Performance Metrics**: System health and efficiency indicators
21
+
22
+ ## 🛠 **Setup Instructions**
23
+
24
+ ### **1. Database Migration**
25
+ ```bash
26
+ # Run the migration to create the healing_metrics table
27
+ rails generate migration CreateHealingMetrics
28
+ # Copy the migration content from db/migrate/001_create_healing_metrics.rb
29
+ rails db:migrate
30
+ ```
31
+
32
+ ### **2. Routes Integration**
33
+ Add to your `config/routes.rb`:
34
+ ```ruby
35
+ # CodeHealer Dashboard Routes
36
+ namespace :code_healer do
37
+ get '/dashboard', to: 'dashboard#index'
38
+ get '/dashboard/metrics', to: 'dashboard#metrics'
39
+ get '/dashboard/trends', to: 'dashboard#trends'
40
+ get '/dashboard/performance', to: 'dashboard#performance'
41
+ get '/dashboard/healing/:healing_id', to: 'dashboard#healing_details'
42
+
43
+ # API endpoints (JSON only)
44
+ namespace :api do
45
+ get '/dashboard/summary', to: 'dashboard#summary'
46
+ get '/dashboard/metrics', to: 'dashboard#metrics'
47
+ get '/dashboard/trends', to: 'dashboard#trends'
48
+ get '/dashboard/performance', to: 'dashboard#performance'
49
+ get '/dashboard/healing/:healing_id', to: 'dashboard#healing_details'
50
+ end
51
+ end
52
+ ```
53
+
54
+ ### **3. Access the Dashboard**
55
+ Visit: `http://your-app.com/code_healer/dashboard`
56
+
57
+ ## 📈 **Dashboard Features**
58
+
59
+ ### **Metrics Cards**
60
+ - **Total Healings**: All-time count with visual indicators
61
+ - **Success Rate**: Color-coded (Green: ≥80%, Yellow: 60-79%, Red: <60%)
62
+ - **Activity Counts**: Today, this week, this month
63
+ - **Performance**: Average resolution time in seconds
64
+
65
+ ### **Interactive Charts**
66
+ - **Daily Trend Chart**: Line chart showing healing activity over 7 days
67
+ - **Evolution Methods**: Doughnut chart showing AI strategy distribution
68
+ - **Real-time Updates**: Charts refresh with latest data
69
+
70
+ ### **Recent Healings List**
71
+ - **Class & Method**: Which code was healed
72
+ - **Error Details**: Error class and message
73
+ - **Status Information**: Success/failure, AI method, provider
74
+ - **Timestamps**: When the healing occurred
75
+
76
+ ## 🔌 **API Endpoints**
77
+
78
+ ### **Dashboard Summary**
79
+ ```bash
80
+ GET /code_healer/api/dashboard/summary
81
+ # Returns: total_healings, success_rate, daily_counts, etc.
82
+ ```
83
+
84
+ ### **Detailed Metrics**
85
+ ```bash
86
+ GET /code_healer/api/dashboard/metrics
87
+ # Returns: filtered healing metrics with pagination
88
+ ```
89
+
90
+ ### **Trends & Analytics**
91
+ ```bash
92
+ GET /code_healer/api/dashboard/trends
93
+ # Returns: daily trends, hourly distribution, top errors
94
+ ```
95
+
96
+ ### **Performance Data**
97
+ ```bash
98
+ GET /code_healer/api/dashboard/performance
99
+ # Returns: success rates, resolution times, AI performance
100
+ ```
101
+
102
+ ### **Individual Healing Details**
103
+ ```bash
104
+ GET /code_healer/api/dashboard/healing/{healing_id}
105
+ # Returns: complete healing information with timing breakdown
106
+ ```
107
+
108
+ ## 🎨 **Customization**
109
+
110
+ ### **Styling**
111
+ The dashboard uses a clean, modern design with:
112
+ - Responsive grid layout
113
+ - Card-based metric display
114
+ - Chart.js for visualizations
115
+ - Color-coded success indicators
116
+
117
+ ### **Adding New Metrics**
118
+ Extend the `MetricsCollector` service to track additional data:
119
+ ```ruby
120
+ def self.track_custom_metric(healing_id, metric_name, value)
121
+ metric = HealingMetric.find_by(healing_id: healing_id)
122
+ metric.update!(additional_metadata: metric.additional_metadata.merge(metric_name => value))
123
+ end
124
+ ```
125
+
126
+ ## 🔮 **Future Enhancements (Phase 2+)**
127
+
128
+ - **Advanced Analytics**: ML-powered insights and predictions
129
+ - **Team Performance**: Developer-specific metrics
130
+ - **Business Impact**: Cost savings and productivity metrics
131
+ - **Real-time Alerts**: Notifications for critical issues
132
+ - **Export & Reporting**: PDF reports and scheduled exports
133
+
134
+ ## 🐛 **Troubleshooting**
135
+
136
+ ### **Common Issues**
137
+ 1. **Migration Errors**: Ensure Rails version compatibility
138
+ 2. **Route Conflicts**: Check for existing `/dashboard` routes
139
+ 3. **Database Connection**: Verify database connectivity
140
+ 4. **Asset Loading**: Ensure Chart.js loads correctly
141
+
142
+ ### **Debug Mode**
143
+ Enable detailed logging:
144
+ ```ruby
145
+ # In your environment
146
+ ENV['CODE_HEALER_DEBUG'] = 'true'
147
+ ```
148
+
149
+ ## 📚 **Next Steps**
150
+
151
+ This core dashboard provides the foundation for:
152
+ - **Performance Monitoring**: Track healing efficiency
153
+ - **AI Optimization**: Improve success rates
154
+ - **Resource Planning**: Understand system usage
155
+ - **Business Reporting**: Demonstrate ROI
156
+
157
+ The dashboard transforms CodeHealer from a **tool** into a **strategic asset** with data-driven insights! 🎯
data/config/routes.rb ADDED
@@ -0,0 +1,16 @@
1
+ CodeHealer::Engine.routes.draw do
2
+ get '/dashboard', to: 'dashboard#index'
3
+ get '/dashboard/metrics', to: 'dashboard#metrics'
4
+ get '/dashboard/trends', to: 'dashboard#trends'
5
+ get '/dashboard/performance', to: 'dashboard#performance'
6
+ get '/dashboard/healing/:healing_id', to: 'dashboard#healing_details'
7
+
8
+ # API endpoints (JSON only)
9
+ namespace :api do
10
+ get '/dashboard/summary', to: 'dashboard#summary'
11
+ get '/dashboard/metrics', to: 'dashboard#metrics'
12
+ get '/dashboard/trends', to: 'dashboard#trends'
13
+ get '/dashboard/performance', to: 'dashboard#performance'
14
+ get '/dashboard/healing/:healing_id', to: 'dashboard#healing_details'
15
+ end
16
+ end
@@ -0,0 +1,89 @@
1
+ module CodeHealer
2
+ class DashboardController < ActionController::Base
3
+ # Set the view path to look in the engine's views directory
4
+ self.view_paths = ["#{CodeHealer::Engine.root}/lib/code_healer/views"]
5
+
6
+ def index
7
+ @summary = MetricsCollector.dashboard_summary
8
+ @recent_healings = HealingMetric.order(created_at: :desc).limit(10)
9
+
10
+ respond_to do |format|
11
+ format.html { render template: "dashboard/index" }
12
+ format.json { render json: @summary }
13
+ end
14
+ end
15
+
16
+ def metrics
17
+ @metrics = HealingMetric.order(created_at: :desc)
18
+
19
+ # Apply filters
20
+ @metrics = @metrics.by_class(params[:class_name]) if params[:class_name].present?
21
+ @metrics = @metrics.by_evolution_method(params[:evolution_method]) if params[:evolution_method].present?
22
+ @metrics = @metrics.by_ai_provider(params[:ai_provider]) if params[:ai_provider].present?
23
+ @metrics = @metrics.recent(params[:days].to_i) if params[:days].present?
24
+
25
+ respond_to do |format|
26
+ format.html { render template: "dashboard/metrics" }
27
+ format.json { render json: @metrics }
28
+ end
29
+ end
30
+
31
+ def healing_details
32
+ @healing = HealingMetric.find_by(healing_id: params[:healing_id])
33
+
34
+ respond_to do |format|
35
+ format.html { render template: "dashboard/healing_details" }
36
+ format.json do
37
+ if @healing
38
+ render json: {
39
+ healing: @healing,
40
+ timing: {
41
+ total_duration: @healing.duration_seconds,
42
+ ai_processing: @healing.ai_processing_seconds,
43
+ git_operations: @healing.git_operations_seconds
44
+ },
45
+ status: {
46
+ success: @healing.success_status,
47
+ evolution_method: @healing.evolution_method_display,
48
+ ai_provider: @healing.ai_provider_display
49
+ }
50
+ }
51
+ else
52
+ render json: { error: 'Healing not found' }, status: :not_found
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ def trends
59
+ days = params[:days]&.to_i || 30
60
+
61
+ trends = {
62
+ daily: HealingMetric.daily_healing_trend(days),
63
+ hourly: HealingMetric.hourly_healing_distribution,
64
+ evolution_methods: HealingMetric.evolution_method_distribution,
65
+ ai_providers: HealingMetric.ai_provider_distribution,
66
+ error_classes: HealingMetric.top_error_classes(10),
67
+ classes_healed: HealingMetric.top_classes_healed(10)
68
+ }
69
+
70
+ render json: trends
71
+ end
72
+
73
+ def performance
74
+ performance_data = {
75
+ average_resolution_time: HealingMetric.average_resolution_time,
76
+ success_rate: HealingMetric.success_rate,
77
+ ai_success_rate: HealingMetric.where(ai_success: true).count.to_f / HealingMetric.count * 100,
78
+ test_pass_rate: HealingMetric.where(tests_passed: true).count.to_f / HealingMetric.count * 100,
79
+ syntax_valid_rate: HealingMetric.where(syntax_valid: true).count.to_f / HealingMetric.count * 100
80
+ }
81
+
82
+ render json: performance_data
83
+ end
84
+
85
+ def summary
86
+ render json: MetricsCollector.dashboard_summary
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,31 @@
1
+ module CodeHealer
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace CodeHealer
4
+
5
+ # Load dashboard components
6
+ initializer "code_healer.load_dashboard" do |app|
7
+ app.config.autoload_paths += %W(#{config.root}/lib/code_healer)
8
+ end
9
+
10
+ # Add views path to the main app
11
+ initializer "code_healer.add_views_path" do |app|
12
+ app.config.paths["app/views"] << "#{config.root}/lib/code_healer/views"
13
+ end
14
+
15
+ # Copy migrations
16
+ initializer "code_healer.copy_migrations" do |app|
17
+ if app.root.to_s.match root.to_s
18
+ config.paths["db/migrate"].expanded.each do |expanded_path|
19
+ app.config.paths["db/migrate"] << expanded_path
20
+ end
21
+ end
22
+ end
23
+
24
+ # Ensure the engine is properly loaded
25
+ config.autoload_paths += %W(#{config.root}/lib)
26
+ config.eager_load_paths += %W(#{config.root}/lib)
27
+
28
+ # Configure the engine's own paths
29
+ config.paths["app/views"] = ["#{config.root}/lib/code_healer/views"]
30
+ end
31
+ end
@@ -0,0 +1,51 @@
1
+ module CodeHealer
2
+ class Installer
3
+ def self.install_dashboard
4
+ puts "🏥 CodeHealer Dashboard Installation"
5
+ puts "=================================="
6
+
7
+ # Check if we're in a Rails app
8
+ unless defined?(Rails)
9
+ puts "❌ This command must be run from within a Rails application"
10
+ return false
11
+ end
12
+
13
+ # Check if dashboard is already installed
14
+ if dashboard_installed?
15
+ puts "✅ Dashboard is already installed!"
16
+ puts "🌐 Access it at: /code_healer/dashboard"
17
+ return true
18
+ end
19
+
20
+ puts "🚀 Installing CodeHealer Dashboard..."
21
+
22
+ # The engine will automatically handle:
23
+ # - Routes mounting
24
+ # - Migration copying
25
+ # - Asset loading
26
+
27
+ puts "✅ Dashboard installation completed!"
28
+ puts "🚀 Run 'rails db:migrate' to create the database tables"
29
+ puts "🌐 Access your dashboard at: /code_healer/dashboard"
30
+ puts ""
31
+ puts "📊 Dashboard Features:"
32
+ puts " - Real-time healing metrics"
33
+ puts " - AI performance analytics"
34
+ puts " - Success rate tracking"
35
+ puts " - Interactive charts and graphs"
36
+
37
+ true
38
+ end
39
+
40
+ private
41
+
42
+ def self.dashboard_installed?
43
+ # Check if the routes are already mounted
44
+ Rails.application.routes.routes.any? do |route|
45
+ route.path.spec.to_s.include?('code_healer')
46
+ end
47
+ rescue
48
+ false
49
+ end
50
+ end
51
+ end