code_healer 0.1.12 → 0.1.14
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 +4 -4
- data/CHANGELOG.md +72 -113
- data/DASHBOARD_README.md +157 -0
- data/lib/code_healer/controllers/dashboard_controller.rb +92 -0
- data/lib/code_healer/engine.rb +19 -0
- data/lib/code_healer/installer.rb +51 -0
- data/lib/code_healer/models/healing_metric.rb +116 -0
- data/lib/code_healer/routes.rb +20 -0
- data/lib/code_healer/services/metrics_collector.rb +135 -0
- data/lib/code_healer/version.rb +1 -1
- data/lib/code_healer/views/dashboard/index.html.erb +161 -0
- data/lib/code_healer.rb +36 -0
- data/lib/generators/code_healer/install_generator.rb +48 -0
- data/lib/generators/code_healer/templates/create_healing_metrics.rb +56 -0
- metadata +11 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f357d294ca82a2aaed146acf5f716b20c3839d2cd64ec72345589a794f5b32eb
|
4
|
+
data.tar.gz: e4b6fff984ed96c58bf693b5252aa9747e87213cc97e80972a7cd4bbb0c1a488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d5f0ee58ddf888178218cf6f06dfc98ca72548938c452a31acf7fc6e59c7a22041c3c2c08a44e8e8dd28eb8406952211d78219b9ec057679a1d5fb808cf4f0c
|
7
|
+
data.tar.gz: 63e2cac8eceda44157e6c7afa12fbe4406ca9a5c39994298028662f1752cbf74d1be8aba566950646eeb2f4af0b9d2798e08f8f1931c328e21d9a137e0fb26e5
|
data/CHANGELOG.md
CHANGED
@@ -5,156 +5,115 @@ 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.
|
8
|
+
## [0.1.14] - 2025-08-21
|
9
9
|
|
10
|
-
###
|
11
|
-
- **
|
12
|
-
- **
|
13
|
-
|
14
|
-
|
10
|
+
### Added
|
11
|
+
- **Dashboard UI Improvements**: Enhanced dashboard with proper HTML layout and styling
|
12
|
+
- **Charts and Visualizations**: Added Chart.js integration for data visualization
|
13
|
+
- **Detailed Views**: Enhanced healing details and performance metrics views
|
14
|
+
- **Responsive Design**: Mobile-friendly dashboard interface
|
15
15
|
|
16
16
|
### Fixed
|
17
|
-
- **
|
18
|
-
- **
|
19
|
-
- **
|
20
|
-
|
21
|
-
## [0.1.10] - 2025-01-14
|
17
|
+
- **SQL Compatibility**: Replaced raw SQL with Rails-native methods for better database compatibility
|
18
|
+
- **Dashboard Controller**: Fixed controller loading and routing issues
|
19
|
+
- **Engine Integration**: Simplified engine structure to avoid conflicts
|
22
20
|
|
23
21
|
### Changed
|
24
|
-
- **
|
25
|
-
- **
|
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
|
22
|
+
- **Metrics Collection**: Improved performance of dashboard metrics queries
|
23
|
+
- **UI Rendering**: Replaced plain text dashboard with proper HTML views
|
28
24
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
- **
|
25
|
+
## [0.1.13] - 2025-08-21
|
26
|
+
|
27
|
+
### Added
|
28
|
+
- **Automatic Dashboard Integration**: Rails Engine automatically mounts dashboard routes
|
29
|
+
- **Database Migrations**: Automatic migration copying and execution
|
30
|
+
- **Dashboard Components**: Complete dashboard system with metrics, trends, and performance views
|
31
|
+
- **API Endpoints**: JSON API for dashboard data integration
|
33
32
|
|
34
|
-
|
33
|
+
### Fixed
|
34
|
+
- **Git Operations**: All Git operations now occur within isolated healing workspaces
|
35
|
+
- **PR Creation**: Fixed duplicate PR creation and repository targeting issues
|
36
|
+
- **Workspace Management**: Improved isolated healing environment with proper cleanup
|
35
37
|
|
36
38
|
### Changed
|
37
|
-
- **
|
38
|
-
- **
|
39
|
-
- **Pull request automation** - Automatic PR creation when configured
|
40
|
-
- **Method renaming** - `merge_fixes_back` → `create_healing_branch` for clarity
|
39
|
+
- **Healing Workflow**: Complete isolation of healing operations from main repository
|
40
|
+
- **Dashboard Installation**: Fully automatic dashboard setup via Rails Engine
|
41
41
|
|
42
|
-
|
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
|
42
|
+
## [0.1.12] - 2025-08-20
|
46
43
|
|
47
|
-
|
44
|
+
### Fixed
|
45
|
+
- **Duplicate PR Creation**: Prevented duplicate PR creation when evolution handler already creates PRs
|
46
|
+
- **Workspace Cleanup**: Improved cleanup of healing workspaces
|
48
47
|
|
49
|
-
|
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
|
48
|
+
## [0.1.11] - 2025-08-20
|
55
49
|
|
56
50
|
### Fixed
|
57
|
-
- **
|
58
|
-
- **
|
59
|
-
- **Isolated healing workspace system** now properly activated
|
51
|
+
- **Repository Cloning**: Fixed incorrect repository cloning by using GitHub remote URL instead of local path
|
52
|
+
- **Git Remote**: Ensured workspace has correct remote origin for proper Git operations
|
60
53
|
|
61
|
-
## [0.1.
|
54
|
+
## [0.1.10] - 2025-08-20
|
62
55
|
|
63
|
-
###
|
64
|
-
- **
|
65
|
-
- **
|
66
|
-
|
67
|
-
|
68
|
-
- **Workspace cleanup logging** for debugging
|
56
|
+
### Changed
|
57
|
+
- **Git Operations**: All Git operations (branching, committing, pushing, PR creation) now occur strictly within isolated workspace
|
58
|
+
- **File Operations**: Removed direct file copying to main repository for complete isolation
|
59
|
+
|
60
|
+
## [0.1.9] - 2025-08-20
|
69
61
|
|
70
62
|
### Fixed
|
71
|
-
- **
|
72
|
-
- **
|
63
|
+
- **Git Commit Issues**: Added proper change detection before committing in isolated workspace
|
64
|
+
- **File Comparison**: Enhanced file comparison logic to only copy changed files
|
73
65
|
|
74
|
-
## [0.1.
|
66
|
+
## [0.1.8] - 2025-08-20
|
75
67
|
|
76
|
-
###
|
77
|
-
- **
|
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
|
68
|
+
### Fixed
|
69
|
+
- **Workspace Cleanup**: Improved cleanup process to prevent Git conflicts
|
84
70
|
|
85
|
-
## [0.1.
|
71
|
+
## [0.1.7] - 2025-08-20
|
86
72
|
|
87
|
-
###
|
88
|
-
- **
|
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
|
73
|
+
### Fixed
|
74
|
+
- **Git Working Tree**: Preserved .git directory during cloning and only removed during cleanup
|
94
75
|
|
95
|
-
## [0.1.
|
76
|
+
## [0.1.6] - 2025-08-20
|
96
77
|
|
97
|
-
###
|
98
|
-
- **
|
99
|
-
|
100
|
-
|
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
|
78
|
+
### Fixed
|
79
|
+
- **Branch Name Sanitization**: Improved branch name handling for Git operations
|
80
|
+
|
81
|
+
## [0.1.5] - 2025-08-20
|
105
82
|
|
106
83
|
### Fixed
|
107
|
-
-
|
108
|
-
- Fixed executable path configuration in gemspec
|
84
|
+
- **Duplicate Class Definition**: Removed duplicate HealingJob class definition causing Sidekiq errors
|
109
85
|
|
110
|
-
## [
|
86
|
+
## [0.1.4] - 2025-08-20
|
111
87
|
|
112
|
-
###
|
113
|
-
-
|
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
|
88
|
+
### Fixed
|
89
|
+
- **Workspace Logging**: Added comprehensive logging to isolated healing workspace system
|
122
90
|
|
123
|
-
|
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
|
91
|
+
## [0.1.3] - 2025-08-20
|
128
92
|
|
129
|
-
###
|
130
|
-
-
|
93
|
+
### Fixed
|
94
|
+
- **Configuration Keys**: Updated HealingWorkspaceManager to handle both string and symbol keys
|
131
95
|
|
132
|
-
|
133
|
-
- None
|
96
|
+
## [0.1.2] - 2025-08-20
|
134
97
|
|
135
98
|
### Fixed
|
136
|
-
-
|
137
|
-
|
138
|
-
|
99
|
+
- **Git Operations**: Fixed Git operations in isolated healing workspaces
|
100
|
+
|
101
|
+
## [0.1.1] - 2025-08-20
|
139
102
|
|
140
|
-
###
|
141
|
-
-
|
142
|
-
-
|
143
|
-
- Business rule validation
|
103
|
+
### Fixed
|
104
|
+
- **Production Safety**: Enhanced production safety with isolated healing workspaces
|
105
|
+
- **Git Integration**: Improved Git integration within isolated environments
|
144
106
|
|
145
|
-
## [0.1.0] - 2025-
|
107
|
+
## [0.1.0] - 2025-08-20
|
146
108
|
|
147
109
|
### Added
|
148
|
-
-
|
149
|
-
-
|
150
|
-
-
|
151
|
-
-
|
152
|
-
-
|
153
|
-
-
|
154
|
-
-
|
155
|
-
- Comprehensive documentation
|
156
|
-
- Example configurations
|
157
|
-
- Test suite setup
|
110
|
+
- **AI-Powered Code Healing**: Automatic code error detection and repair
|
111
|
+
- **Multiple AI Providers**: Support for OpenAI API and Claude Code Terminal
|
112
|
+
- **Business Context Integration**: MCP-powered intelligent healing with business rules
|
113
|
+
- **Git Integration**: Automatic branch creation, commits, and pull requests
|
114
|
+
- **Isolated Healing**: Safe code modification in isolated workspaces
|
115
|
+
- **Dashboard System**: Metrics collection and visualization
|
116
|
+
- **Rails Integration**: Automatic Rails application integration via Railtie
|
158
117
|
|
159
118
|
---
|
160
119
|
|
data/DASHBOARD_README.md
ADDED
@@ -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! 🎯
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module CodeHealer
|
2
|
+
class DashboardController < ActionController::Base
|
3
|
+
def index
|
4
|
+
@summary = MetricsCollector.dashboard_summary
|
5
|
+
@recent_healings = HealingMetric.order(created_at: :desc).limit(10)
|
6
|
+
|
7
|
+
respond_to do |format|
|
8
|
+
format.html { render_dashboard }
|
9
|
+
format.json { render json: @summary }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def metrics
|
14
|
+
@metrics = HealingMetric.order(created_at: :desc)
|
15
|
+
|
16
|
+
# Apply filters
|
17
|
+
@metrics = @metrics.by_class(params[:class_name]) if params[:class_name].present?
|
18
|
+
@metrics = @metrics.by_evolution_method(params[:evolution_method]) if params[:evolution_method].present?
|
19
|
+
@metrics = @metrics.by_ai_provider(params[:ai_provider]) if params[:ai_provider].present?
|
20
|
+
@metrics = @metrics.recent(params[:days].to_i) if params[:days].present?
|
21
|
+
|
22
|
+
respond_to do |format|
|
23
|
+
format.html { render :metrics }
|
24
|
+
format.json { render json: @metrics }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def healing_details
|
29
|
+
@healing = HealingMetric.find_by(healing_id: params[:healing_id])
|
30
|
+
|
31
|
+
if @healing
|
32
|
+
render json: {
|
33
|
+
healing: @healing,
|
34
|
+
timing: {
|
35
|
+
total_duration: @healing.duration_seconds,
|
36
|
+
ai_processing: @healing.ai_processing_seconds,
|
37
|
+
git_operations: @healing.git_operations_seconds
|
38
|
+
},
|
39
|
+
status: {
|
40
|
+
success: @healing.success_status,
|
41
|
+
evolution_method: @healing.evolution_method_display,
|
42
|
+
ai_provider: @healing.ai_provider_display
|
43
|
+
}
|
44
|
+
}
|
45
|
+
else
|
46
|
+
render json: { error: 'Healing not found' }, status: :not_found
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def trends
|
51
|
+
days = params[:days]&.to_i || 30
|
52
|
+
|
53
|
+
trends = {
|
54
|
+
daily: HealingMetric.daily_healing_trend(days),
|
55
|
+
hourly: HealingMetric.hourly_healing_distribution,
|
56
|
+
evolution_methods: HealingMetric.evolution_method_distribution,
|
57
|
+
ai_providers: HealingMetric.ai_provider_distribution,
|
58
|
+
error_classes: HealingMetric.top_error_classes(10),
|
59
|
+
classes_healed: HealingMetric.top_classes_healed(10)
|
60
|
+
}
|
61
|
+
|
62
|
+
render json: trends
|
63
|
+
end
|
64
|
+
|
65
|
+
def performance
|
66
|
+
performance_data = {
|
67
|
+
average_resolution_time: HealingMetric.average_resolution_time,
|
68
|
+
success_rate: HealingMetric.success_rate,
|
69
|
+
ai_success_rate: HealingMetric.where(ai_success: true).count.to_f / HealingMetric.count * 100,
|
70
|
+
test_pass_rate: HealingMetric.where(tests_passed: true).count.to_f / HealingMetric.count * 100,
|
71
|
+
syntax_valid_rate: HealingMetric.where(syntax_valid: true).count.to_f / HealingMetric.count * 100
|
72
|
+
}
|
73
|
+
|
74
|
+
render json: performance_data
|
75
|
+
end
|
76
|
+
|
77
|
+
def summary
|
78
|
+
render json: MetricsCollector.dashboard_summary
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def render_dashboard
|
84
|
+
# This will be replaced with actual dashboard view
|
85
|
+
render plain: "CodeHealer Dashboard - Coming Soon!\n\n" \
|
86
|
+
"Total Healings: #{@summary[:total_healing]}\n" \
|
87
|
+
"Success Rate: #{@summary[:success_rate]}%\n" \
|
88
|
+
"Healings Today: #{@summary[:healings_today]}\n" \
|
89
|
+
"Healings This Week: #{@summary[:healings_this_week]}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,19 @@
|
|
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
|
+
# Copy migrations
|
11
|
+
initializer "code_healer.copy_migrations" do |app|
|
12
|
+
if app.root.to_s.match root.to_s
|
13
|
+
config.paths["db/migrate"].expanded.each do |expanded_path|
|
14
|
+
app.config.paths["db/migrate"] << expanded_path
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module CodeHealer
|
2
|
+
class HealingMetric < ActiveRecord::Base
|
3
|
+
self.table_name = 'healing_metrics'
|
4
|
+
|
5
|
+
# Validations
|
6
|
+
validates :healing_id, presence: true, uniqueness: true
|
7
|
+
validates :class_name, presence: true
|
8
|
+
validates :method_name, presence: true
|
9
|
+
validates :error_class, presence: true
|
10
|
+
|
11
|
+
# Scopes for common queries
|
12
|
+
scope :successful, -> { where(healing_successful: true) }
|
13
|
+
scope :failed, -> { where(healing_successful: false) }
|
14
|
+
scope :recent, ->(days = 30) { where('created_at >= ?', days.days.ago) }
|
15
|
+
scope :by_evolution_method, ->(method) { where(evolution_method: method) }
|
16
|
+
scope :by_ai_provider, ->(provider) { where(ai_provider: provider) }
|
17
|
+
scope :by_class, ->(class_name) { where(class_name: class_name) }
|
18
|
+
|
19
|
+
# Class methods for dashboard metrics
|
20
|
+
class << self
|
21
|
+
def total_healings
|
22
|
+
count
|
23
|
+
end
|
24
|
+
|
25
|
+
def success_rate
|
26
|
+
return 0 if count.zero?
|
27
|
+
(successful.count.to_f / count * 100).round(2)
|
28
|
+
end
|
29
|
+
|
30
|
+
def healings_today
|
31
|
+
where('created_at >= ?', Date.current.beginning_of_day).count
|
32
|
+
end
|
33
|
+
|
34
|
+
def healings_this_week
|
35
|
+
where('created_at >= ?', Date.current.beginning_of_week).count
|
36
|
+
end
|
37
|
+
|
38
|
+
def healings_this_month
|
39
|
+
where('created_at >= ?', Date.current.beginning_of_month).count
|
40
|
+
end
|
41
|
+
|
42
|
+
def average_resolution_time
|
43
|
+
successful.where.not(total_duration_ms: nil).average(:total_duration_ms)&.round(2)
|
44
|
+
end
|
45
|
+
|
46
|
+
def evolution_method_distribution
|
47
|
+
group(:evolution_method).count
|
48
|
+
end
|
49
|
+
|
50
|
+
def ai_provider_distribution
|
51
|
+
group(:ai_provider).count
|
52
|
+
end
|
53
|
+
|
54
|
+
def top_error_classes(limit = 10)
|
55
|
+
group(:error_class).order('count_all DESC').limit(limit).count
|
56
|
+
end
|
57
|
+
|
58
|
+
def top_classes_healed(limit = 10)
|
59
|
+
group(:class_name).order('count_all DESC').limit(limit).count
|
60
|
+
end
|
61
|
+
|
62
|
+
def daily_healing_trend(days = 30)
|
63
|
+
# Use Rails date methods instead of raw SQL
|
64
|
+
start_date = days.days.ago.to_date
|
65
|
+
end_date = Date.current
|
66
|
+
|
67
|
+
trend_data = {}
|
68
|
+
(start_date..end_date).each do |date|
|
69
|
+
count = where('DATE(created_at) = ?', date).count
|
70
|
+
trend_data[date.strftime('%Y-%m-%d')] = count
|
71
|
+
end
|
72
|
+
trend_data
|
73
|
+
end
|
74
|
+
|
75
|
+
def hourly_healing_distribution
|
76
|
+
# Use Rails to group by hour without raw SQL
|
77
|
+
distribution = {}
|
78
|
+
(0..23).each do |hour|
|
79
|
+
start_time = Time.current.beginning_of_day + hour.hours
|
80
|
+
end_time = start_time + 1.hour
|
81
|
+
count = where(created_at: start_time..end_time).count
|
82
|
+
distribution[hour.to_s.rjust(2, '0')] = count
|
83
|
+
end
|
84
|
+
distribution
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Instance methods
|
89
|
+
def duration_seconds
|
90
|
+
return nil unless total_duration_ms
|
91
|
+
(total_duration_ms / 1000.0).round(2)
|
92
|
+
end
|
93
|
+
|
94
|
+
def ai_processing_seconds
|
95
|
+
return nil unless ai_processing_time_ms
|
96
|
+
(ai_processing_time_ms / 1000.0).round(2)
|
97
|
+
end
|
98
|
+
|
99
|
+
def git_operations_seconds
|
100
|
+
return nil unless git_operations_time_ms
|
101
|
+
(git_operations_time_ms / 1000.0).round(2)
|
102
|
+
end
|
103
|
+
|
104
|
+
def success_status
|
105
|
+
healing_successful ? '✅ Success' : '❌ Failed'
|
106
|
+
end
|
107
|
+
|
108
|
+
def evolution_method_display
|
109
|
+
evolution_method&.titleize || 'Unknown'
|
110
|
+
end
|
111
|
+
|
112
|
+
def ai_provider_display
|
113
|
+
ai_provider&.titleize || 'Unknown'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# CodeHealer Dashboard Routes
|
2
|
+
Rails.application.routes.draw do
|
3
|
+
namespace :code_healer do
|
4
|
+
# Dashboard
|
5
|
+
get '/dashboard', to: 'dashboard#index'
|
6
|
+
get '/dashboard/metrics', to: 'dashboard#metrics'
|
7
|
+
get '/dashboard/trends', to: 'dashboard#trends'
|
8
|
+
get '/dashboard/performance', to: 'dashboard#performance'
|
9
|
+
get '/dashboard/healing/:healing_id', to: 'dashboard#healing_details'
|
10
|
+
|
11
|
+
# API endpoints (JSON only)
|
12
|
+
namespace :api do
|
13
|
+
get '/dashboard/summary', to: 'dashboard#summary'
|
14
|
+
get '/dashboard/metrics', to: 'dashboard#metrics'
|
15
|
+
get '/dashboard/trends', to: 'dashboard#trends'
|
16
|
+
get '/dashboard/performance', to: 'dashboard#performance'
|
17
|
+
get '/dashboard/healing/:healing_id', to: 'dashboard#healing_details'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
module CodeHealer
|
2
|
+
class MetricsCollector
|
3
|
+
def self.track_healing_start(healing_id, class_name, method_name, error_class, error_message, file_path)
|
4
|
+
metric = HealingMetric.find_or_initialize_by(healing_id: healing_id)
|
5
|
+
|
6
|
+
metric.assign_attributes(
|
7
|
+
class_name: class_name,
|
8
|
+
method_name: method_name,
|
9
|
+
error_class: error_class,
|
10
|
+
error_message: error_message,
|
11
|
+
file_path: file_path,
|
12
|
+
healing_started_at: Time.current
|
13
|
+
)
|
14
|
+
|
15
|
+
metric.save!
|
16
|
+
metric
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.track_ai_processing(healing_id, evolution_method, ai_provider, ai_response, tokens_used = nil, cost = nil)
|
20
|
+
metric = HealingMetric.find_by(healing_id: healing_id)
|
21
|
+
return unless metric
|
22
|
+
|
23
|
+
metric.update!(
|
24
|
+
evolution_method: evolution_method,
|
25
|
+
ai_provider: ai_provider,
|
26
|
+
ai_response: ai_response,
|
27
|
+
ai_tokens_used: tokens_used,
|
28
|
+
ai_cost: cost,
|
29
|
+
ai_success: true
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.track_ai_failure(healing_id, evolution_method, ai_provider, failure_reason)
|
34
|
+
metric = HealingMetric.find_by(healing_id: healing_id)
|
35
|
+
return unless metric
|
36
|
+
|
37
|
+
metric.update!(
|
38
|
+
evolution_method: evolution_method,
|
39
|
+
ai_provider: ai_provider,
|
40
|
+
ai_success: false,
|
41
|
+
failure_reason: failure_reason
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.track_workspace_creation(healing_id, workspace_path)
|
46
|
+
metric = HealingMetric.find_by(healing_id: healing_id)
|
47
|
+
return unless metric
|
48
|
+
|
49
|
+
metric.update!(workspace_path: workspace_path)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.track_git_operations(healing_id, healing_branch, pull_request_url, pr_created)
|
53
|
+
metric = HealingMetric.find_by(healing_id: healing_id)
|
54
|
+
return unless metric
|
55
|
+
|
56
|
+
metric.update!(
|
57
|
+
healing_branch: healing_branch,
|
58
|
+
pull_request_url: pull_request_url,
|
59
|
+
pr_created: pr_created
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.track_healing_completion(healing_id, success, tests_passed, syntax_valid, failure_reason = nil)
|
64
|
+
metric = HealingMetric.find_by(healing_id: healing_id)
|
65
|
+
return unless metric
|
66
|
+
|
67
|
+
# Calculate timing
|
68
|
+
total_duration = if metric.healing_started_at
|
69
|
+
((Time.current - metric.healing_started_at) * 1000).round
|
70
|
+
else
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
|
74
|
+
metric.update!(
|
75
|
+
healing_completed_at: Time.current,
|
76
|
+
total_duration_ms: total_duration,
|
77
|
+
healing_successful: success,
|
78
|
+
tests_passed: tests_passed,
|
79
|
+
syntax_valid: syntax_valid,
|
80
|
+
failure_reason: failure_reason
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.track_timing(healing_id, ai_processing_time_ms, git_operations_time_ms)
|
85
|
+
metric = HealingMetric.find_by(healing_id: healing_id)
|
86
|
+
return unless metric
|
87
|
+
|
88
|
+
metric.update!(
|
89
|
+
ai_processing_time_ms: ai_processing_time_ms,
|
90
|
+
git_operations_time_ms: git_operations_time_ms
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.track_business_context(healing_id, business_context, jira_issue_id = nil, confluence_page_id = nil)
|
95
|
+
metric = HealingMetric.find_by(healing_id: healing_id)
|
96
|
+
return unless metric
|
97
|
+
|
98
|
+
metric.update!(
|
99
|
+
business_context_used: business_context,
|
100
|
+
jira_issue_id: jira_issue_id,
|
101
|
+
confluence_page_id: confluence_page_id
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.track_error_occurrence(healing_id, error_occurred_at)
|
106
|
+
metric = HealingMetric.find_by(healing_id: healing_id)
|
107
|
+
return unless metric
|
108
|
+
|
109
|
+
metric.update!(error_occurred_at: error_occurred_at)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Generate unique healing ID
|
113
|
+
def self.generate_healing_id
|
114
|
+
"healing_#{Time.current.to_i}_#{SecureRandom.hex(8)}"
|
115
|
+
end
|
116
|
+
|
117
|
+
# Get dashboard summary
|
118
|
+
def self.dashboard_summary
|
119
|
+
{
|
120
|
+
total_healings: HealingMetric.total_healings,
|
121
|
+
success_rate: HealingMetric.success_rate,
|
122
|
+
healings_today: HealingMetric.healings_today,
|
123
|
+
healings_this_week: HealingMetric.healings_this_week,
|
124
|
+
healings_this_month: HealingMetric.healings_this_month,
|
125
|
+
average_resolution_time: HealingMetric.average_resolution_time,
|
126
|
+
evolution_methods: HealingMetric.evolution_method_distribution,
|
127
|
+
ai_providers: HealingMetric.ai_provider_distribution,
|
128
|
+
top_error_classes: HealingMetric.top_error_classes(5),
|
129
|
+
top_classes_healed: HealingMetric.top_classes_healed(5),
|
130
|
+
daily_trend: HealingMetric.daily_healing_trend(7),
|
131
|
+
hourly_distribution: HealingMetric.hourly_healing_distribution
|
132
|
+
}
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
data/lib/code_healer/version.rb
CHANGED
@@ -0,0 +1,161 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CodeHealer Dashboard</title>
|
5
|
+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
6
|
+
<style>
|
7
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 0; padding: 20px; background: #f5f5f5; }
|
8
|
+
.container { max-width: 1200px; margin: 0 auto; }
|
9
|
+
.header { background: white; padding: 20px; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
10
|
+
.header h1 { margin: 0; color: #2c3e50; }
|
11
|
+
.header p { margin: 10px 0 0 0; color: #7f8c8d; }
|
12
|
+
|
13
|
+
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 20px; }
|
14
|
+
.metric-card { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
15
|
+
.metric-card h3 { margin: 0 0 10px 0; color: #2c3e50; font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; }
|
16
|
+
.metric-card .value { font-size: 32px; font-weight: bold; color: #3498db; margin: 0; }
|
17
|
+
.metric-card .label { color: #7f8c8d; font-size: 12px; margin: 5px 0 0 0; }
|
18
|
+
|
19
|
+
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
|
20
|
+
.chart-card { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
21
|
+
.chart-card h3 { margin: 0 0 20px 0; color: #2c3e50; }
|
22
|
+
|
23
|
+
.recent-healings { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
24
|
+
.recent-healings h3 { margin: 0 0 20px 0; color: #2c3e50; }
|
25
|
+
.healing-item { padding: 15px; border-bottom: 1px solid #ecf0f1; }
|
26
|
+
.healing-item:last-child { border-bottom: none; }
|
27
|
+
.healing-item .class-method { font-weight: bold; color: #2c3e50; }
|
28
|
+
.healing-item .error { color: #e74c3c; font-size: 14px; }
|
29
|
+
.healing-item .status { color: #27ae60; font-size: 12px; }
|
30
|
+
.healing-item .time { color: #7f8c8d; font-size: 12px; }
|
31
|
+
|
32
|
+
.success { color: #27ae60; }
|
33
|
+
.warning { color: #f39c12; }
|
34
|
+
.danger { color: #e74c3c; }
|
35
|
+
</style>
|
36
|
+
</head>
|
37
|
+
<body>
|
38
|
+
<div class="container">
|
39
|
+
<div class="header">
|
40
|
+
<h1>🏥 CodeHealer Dashboard</h1>
|
41
|
+
<p>Intelligent Code Healing Analytics & Insights</p>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
<div class="metrics-grid">
|
45
|
+
<div class="metric-card">
|
46
|
+
<h3>Total Healings</h3>
|
47
|
+
<div class="value"><%= @summary[:total_healings] %></div>
|
48
|
+
<div class="label">All time</div>
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div class="metric-card">
|
52
|
+
<h3>Success Rate</h3>
|
53
|
+
<div class="value <%= @summary[:success_rate] >= 80 ? 'success' : (@summary[:success_rate] >= 60 ? 'warning' : 'danger') %>">
|
54
|
+
<%= @summary[:success_rate] %>%
|
55
|
+
</div>
|
56
|
+
<div class="label">Healing success</div>
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div class="metric-card">
|
60
|
+
<h3>Today</h3>
|
61
|
+
<div class="value"><%= @summary[:healings_today] %></div>
|
62
|
+
<div class="label">Healings today</div>
|
63
|
+
</div>
|
64
|
+
|
65
|
+
<div class="metric-card">
|
66
|
+
<h3>This Week</h3>
|
67
|
+
<div class="value"><%= @summary[:healings_this_week] %></div>
|
68
|
+
<div class="label">Healings this week</div>
|
69
|
+
</div>
|
70
|
+
|
71
|
+
<div class="metric-card">
|
72
|
+
<h3>This Month</h3>
|
73
|
+
<div class="value"><%= @summary[:healings_this_month] %></div>
|
74
|
+
<div class="label">Healings this month</div>
|
75
|
+
</div>
|
76
|
+
|
77
|
+
<div class="metric-card">
|
78
|
+
<h3>Avg Resolution</h3>
|
79
|
+
<div class="value">
|
80
|
+
<%= @summary[:average_resolution_time] ? "#{(@summary[:average_resolution_time] / 1000.0).round(2)}s" : "N/A" %>
|
81
|
+
</div>
|
82
|
+
<div class="label">Average time to fix</div>
|
83
|
+
</div>
|
84
|
+
</div>
|
85
|
+
|
86
|
+
<div class="charts-grid">
|
87
|
+
<div class="chart-card">
|
88
|
+
<h3>Daily Healing Trend (Last 7 Days)</h3>
|
89
|
+
<canvas id="dailyTrendChart"></canvas>
|
90
|
+
</div>
|
91
|
+
|
92
|
+
<div class="chart-card">
|
93
|
+
<h3>Evolution Method Distribution</h3>
|
94
|
+
<canvas id="evolutionMethodsChart"></canvas>
|
95
|
+
</div>
|
96
|
+
</div>
|
97
|
+
|
98
|
+
<div class="recent-healings">
|
99
|
+
<h3>Recent Healings</h3>
|
100
|
+
<% @recent_healings.each do |healing| %>
|
101
|
+
<div class="healing-item">
|
102
|
+
<div class="class-method"><%= healing.class_name %>#<%= healing.method_name %></div>
|
103
|
+
<div class="error"><%= healing.error_class %>: <%= healing.error_message&.truncate(100) %></div>
|
104
|
+
<div class="status">
|
105
|
+
<%= healing.success_status %> |
|
106
|
+
<%= healing.evolution_method_display %> |
|
107
|
+
<%= healing.ai_provider_display %>
|
108
|
+
</div>
|
109
|
+
<div class="time"><%= healing.created_at.strftime("%Y-%m-%d %H:%M:%S") %></div>
|
110
|
+
</div>
|
111
|
+
<% end %>
|
112
|
+
</div>
|
113
|
+
</div>
|
114
|
+
|
115
|
+
<script>
|
116
|
+
// Daily Trend Chart
|
117
|
+
const dailyTrendCtx = document.getElementById('dailyTrendChart').getContext('2d');
|
118
|
+
new Chart(dailyTrendCtx, {
|
119
|
+
type: 'line',
|
120
|
+
data: {
|
121
|
+
labels: <%= raw @summary[:daily_trend].keys.map { |date| Date.parse(date).strftime("%m/%d") }.to_json %>,
|
122
|
+
datasets: [{
|
123
|
+
label: 'Healings',
|
124
|
+
data: <%= raw @summary[:daily_trend].values.to_json %>,
|
125
|
+
borderColor: '#3498db',
|
126
|
+
backgroundColor: 'rgba(52, 152, 219, 0.1)',
|
127
|
+
tension: 0.4
|
128
|
+
}]
|
129
|
+
},
|
130
|
+
options: {
|
131
|
+
responsive: true,
|
132
|
+
plugins: {
|
133
|
+
legend: { display: false }
|
134
|
+
},
|
135
|
+
scales: {
|
136
|
+
y: { beginAtZero: true, ticks: { stepSize: 1 } }
|
137
|
+
}
|
138
|
+
}
|
139
|
+
});
|
140
|
+
|
141
|
+
// Evolution Methods Chart
|
142
|
+
const evolutionMethodsCtx = document.getElementById('evolutionMethodsChart').getContext('2d');
|
143
|
+
new Chart(evolutionMethodsCtx, {
|
144
|
+
type: 'doughnut',
|
145
|
+
data: {
|
146
|
+
labels: <%= raw @summary[:evolution_methods].keys.map(&:titleize).to_json %>,
|
147
|
+
datasets: [{
|
148
|
+
data: <%= raw @summary[:evolution_methods].values.to_json %>,
|
149
|
+
backgroundColor: ['#3498db', '#e74c3c', '#2ecc71', '#f39c12', '#9b59b6']
|
150
|
+
}]
|
151
|
+
},
|
152
|
+
options: {
|
153
|
+
responsive: true,
|
154
|
+
plugins: {
|
155
|
+
legend: { position: 'bottom' }
|
156
|
+
}
|
157
|
+
}
|
158
|
+
});
|
159
|
+
</script>
|
160
|
+
</body>
|
161
|
+
</html>
|
data/lib/code_healer.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "code_healer/version"
|
4
|
+
require_relative "code_healer/engine"
|
4
5
|
|
5
6
|
# Require external gems explicitly
|
6
7
|
require 'openai'
|
@@ -28,6 +29,12 @@ autoload :McpTools, "code_healer/mcp_tools"
|
|
28
29
|
autoload :McpPrompts, "code_healer/mcp_prompts"
|
29
30
|
autoload :MCP, "code_healer/mcp"
|
30
31
|
|
32
|
+
# Dashboard components - load them explicitly to avoid autoload issues
|
33
|
+
require_relative "code_healer/models/healing_metric"
|
34
|
+
require_relative "code_healer/services/metrics_collector"
|
35
|
+
require_relative "code_healer/controllers/dashboard_controller"
|
36
|
+
autoload :Installer, "code_healer/installer"
|
37
|
+
|
31
38
|
# Rails integration
|
32
39
|
if defined?(Rails)
|
33
40
|
require "rails"
|
@@ -64,5 +71,34 @@ if defined?(Rails)
|
|
64
71
|
puts " Run 'code_healer-setup' to configure CodeHealer"
|
65
72
|
end
|
66
73
|
end
|
74
|
+
|
75
|
+
# Mount the engine to provide dashboard routes
|
76
|
+
initializer "code_healer.mount_engine" do |app|
|
77
|
+
app.routes.prepend do
|
78
|
+
mount CodeHealer::Engine => "/code_healer"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Add dashboard routes directly to the host app
|
83
|
+
initializer "code_healer.add_dashboard_routes" do |app|
|
84
|
+
app.routes.prepend do
|
85
|
+
namespace :code_healer do
|
86
|
+
get '/dashboard', to: 'dashboard#index'
|
87
|
+
get '/dashboard/metrics', to: 'dashboard#metrics'
|
88
|
+
get '/dashboard/trends', to: 'dashboard#trends'
|
89
|
+
get '/dashboard/performance', to: 'dashboard#performance'
|
90
|
+
get '/dashboard/healing/:healing_id', to: 'dashboard#healing_details'
|
91
|
+
|
92
|
+
# API endpoints (JSON only)
|
93
|
+
namespace :api do
|
94
|
+
get '/dashboard/summary', to: 'dashboard#summary'
|
95
|
+
get '/dashboard/metrics', to: 'dashboard#metrics'
|
96
|
+
get '/dashboard/trends', to: 'dashboard#trends'
|
97
|
+
get '/dashboard/performance', to: 'dashboard#performance'
|
98
|
+
get '/dashboard/healing/:healing_id', to: 'dashboard#healing_details'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
67
103
|
end
|
68
104
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module CodeHealer
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('templates', __dir__)
|
5
|
+
|
6
|
+
desc "Installs CodeHealer dashboard and required components"
|
7
|
+
|
8
|
+
def install_dashboard
|
9
|
+
# Generate migration
|
10
|
+
generate_migration
|
11
|
+
|
12
|
+
# Add routes
|
13
|
+
inject_routes
|
14
|
+
|
15
|
+
# Create initializer
|
16
|
+
create_initializer
|
17
|
+
|
18
|
+
# Copy dashboard assets
|
19
|
+
copy_dashboard_assets
|
20
|
+
|
21
|
+
puts "✅ CodeHealer dashboard installed successfully!"
|
22
|
+
puts "🚀 Run 'rails db:migrate' to create the database tables"
|
23
|
+
puts "🌐 Access your dashboard at: /code_healer/dashboard"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def generate_migration
|
29
|
+
migration_template "create_healing_metrics.rb", "db/migrate/create_healing_metrics.rb"
|
30
|
+
end
|
31
|
+
|
32
|
+
def inject_routes
|
33
|
+
route "mount CodeHealer::Engine => '/code_healer'"
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_initializer
|
37
|
+
copy_file "code_healer.rb", "config/initializers/code_healer.rb"
|
38
|
+
end
|
39
|
+
|
40
|
+
def copy_dashboard_assets
|
41
|
+
copy_file "dashboard_controller.rb", "app/controllers/code_healer/dashboard_controller.rb"
|
42
|
+
copy_file "healing_metric.rb", "app/models/code_healer/healing_metric.rb"
|
43
|
+
copy_file "metrics_collector.rb", "app/services/code_healer/metrics_collector.rb"
|
44
|
+
copy_file "dashboard_index.html.erb", "app/views/code_healer/dashboard/index.html.erb"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class CreateHealingMetrics < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
2
|
+
def change
|
3
|
+
create_table :healing_metrics do |t|
|
4
|
+
# Basic healing info
|
5
|
+
t.string :healing_id, null: false, index: true
|
6
|
+
t.string :class_name, null: false
|
7
|
+
t.string :method_name, null: false
|
8
|
+
t.string :error_class, null: false
|
9
|
+
t.text :error_message
|
10
|
+
t.string :file_path
|
11
|
+
|
12
|
+
# AI and evolution details
|
13
|
+
t.string :evolution_method # claude_code_terminal, api, hybrid
|
14
|
+
t.string :ai_provider # claude, openai
|
15
|
+
t.boolean :ai_success, default: false
|
16
|
+
t.text :ai_response
|
17
|
+
t.integer :ai_tokens_used
|
18
|
+
t.decimal :ai_cost, precision: 10, scale: 4
|
19
|
+
|
20
|
+
# Workspace and Git details
|
21
|
+
t.string :workspace_path
|
22
|
+
t.string :healing_branch
|
23
|
+
t.string :pull_request_url
|
24
|
+
t.boolean :pr_created, default: false
|
25
|
+
|
26
|
+
# Timing and performance
|
27
|
+
t.datetime :error_occurred_at
|
28
|
+
t.datetime :healing_started_at
|
29
|
+
t.datetime :healing_completed_at
|
30
|
+
t.integer :total_duration_ms
|
31
|
+
t.integer :ai_processing_time_ms
|
32
|
+
t.integer :git_operations_time_ms
|
33
|
+
|
34
|
+
# Success metrics
|
35
|
+
t.boolean :healing_successful, default: false
|
36
|
+
t.boolean :tests_passed, default: false
|
37
|
+
t.boolean :syntax_valid, default: false
|
38
|
+
t.text :failure_reason
|
39
|
+
|
40
|
+
# Business context
|
41
|
+
t.text :business_context_used
|
42
|
+
t.string :jira_issue_id
|
43
|
+
t.string :confluence_page_id
|
44
|
+
|
45
|
+
# Metadata
|
46
|
+
t.json :additional_metadata
|
47
|
+
t.timestamps
|
48
|
+
end
|
49
|
+
|
50
|
+
# Indexes for performance
|
51
|
+
add_index :healing_metrics, [:class_name, :method_name]
|
52
|
+
add_index :healing_metrics, [:evolution_method, :ai_provider]
|
53
|
+
add_index :healing_metrics, [:healing_successful, :created_at]
|
54
|
+
add_index :healing_metrics, :created_at
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_healer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Deepan Kumar
|
@@ -345,6 +345,7 @@ extensions: []
|
|
345
345
|
extra_rdoc_files: []
|
346
346
|
files:
|
347
347
|
- CHANGELOG.md
|
348
|
+
- DASHBOARD_README.md
|
348
349
|
- GEM_SUMMARY.md
|
349
350
|
- README.md
|
350
351
|
- code_healer.gemspec
|
@@ -363,17 +364,23 @@ files:
|
|
363
364
|
- lib/code_healer/claude_error_monitor.rb
|
364
365
|
- lib/code_healer/config_manager.rb
|
365
366
|
- lib/code_healer/context_aware_prompt_builder.rb
|
367
|
+
- lib/code_healer/controllers/dashboard_controller.rb
|
366
368
|
- lib/code_healer/core.rb
|
369
|
+
- lib/code_healer/engine.rb
|
367
370
|
- lib/code_healer/error_handler.rb
|
368
371
|
- lib/code_healer/evolution_job.rb
|
369
372
|
- lib/code_healer/global_handler.rb
|
370
373
|
- lib/code_healer/healing_job.rb
|
371
374
|
- lib/code_healer/healing_workspace_manager.rb
|
375
|
+
- lib/code_healer/installer.rb
|
372
376
|
- lib/code_healer/mcp.rb
|
373
377
|
- lib/code_healer/mcp_prompts.rb
|
374
378
|
- lib/code_healer/mcp_server.rb
|
375
379
|
- lib/code_healer/mcp_tools.rb
|
380
|
+
- lib/code_healer/models/healing_metric.rb
|
376
381
|
- lib/code_healer/pull_request_creator.rb
|
382
|
+
- lib/code_healer/routes.rb
|
383
|
+
- lib/code_healer/services/metrics_collector.rb
|
377
384
|
- lib/code_healer/setup.rb
|
378
385
|
- lib/code_healer/simple_evolution.rb
|
379
386
|
- lib/code_healer/simple_global_handler.rb
|
@@ -381,6 +388,9 @@ files:
|
|
381
388
|
- lib/code_healer/terminal_integration.rb
|
382
389
|
- lib/code_healer/usage_analyzer.rb
|
383
390
|
- lib/code_healer/version.rb
|
391
|
+
- lib/code_healer/views/dashboard/index.html.erb
|
392
|
+
- lib/generators/code_healer/install_generator.rb
|
393
|
+
- lib/generators/code_healer/templates/create_healing_metrics.rb
|
384
394
|
homepage: https://github.com/deepan-g2/code-healer
|
385
395
|
licenses:
|
386
396
|
- MIT
|