AutoCure

Self-Healing Flutter Agent
An autonomous agent that automatically detects, analyzes, and fixes runtime errors in Flutter apps.

Flutter Dart Platform License

한국어


Supported Platforms

PlatformSupportedNotes
AndroidAndroid 5.0 (API 21)+
iOSiOS 12.0+
macOSmacOS 10.14+
Linuxx64
WindowsWindows 10+
WebChrome, Firefox, Safari, Edge

Overview

Runtime error occurs
    |
    v
[VM Service] Capture error (RenderFlex, Null, setState, etc.)
    |
    v
[ErrorAnalyzer] Root cause analysis + fix strategy selection
    |
    v
[CodeFixer] Apply one of 7 auto-fix strategies
    |
    v
[Verification] Verify with dart analyze + flutter test
    |
    v
  Pass? ──Yes──> [CI/CD] Create PR on autofix/* branch
    |                        |
   No                   GitHub Actions
    |                   analysis/test pass
    v                        |
 Auto-rollback          Auto-merge

Architecture

lib/
├── core/
│   ├── mcp/                    # MCP server integration
│   │   ├── mcp_server.dart     # JSON-RPC MCP server (widget tree/source access)
│   │   └── widget_inspector.dart # VM Service widget tree inspector
│   ├── self_healing/           # Self-healing engine
│   │   ├── agent.dart          # Main orchestrator
│   │   ├── error_analyzer.dart # Error pattern analysis + root cause tracing
│   │   ├── code_fixer.dart     # 7 auto-fix strategies
│   │   └── verification.dart   # dart analyze + flutter test verification
│   └── vm_service/             # Runtime monitoring
│       ├── vm_connector.dart   # Flutter VM Service connection
│       └── error_stream.dart   # Real-time error stream
├── models/                     # Data models
├── services/                   # Service layer
│   ├── agent_provider.dart     # Flutter UI <-> Agent bridge
│   └── ci_cd_service.dart      # GitHub API + auto PR creation
├── screens/                    # Admin dashboard
├── theme/
│   └── app_theme.dart          # Design system (colors, themes)
└── main.dart                   # App entry point

tools/
└── mcp_server/bin/server.dart  # Standalone MCP server

.github/
└── workflows/
    └── self-heal.yml           # CI/CD auto-merge pipeline

Features

1. MCP Server Integration

A Dart-based MCP (Model Context Protocol) server provides project access to the agent.

ToolDescription
get_widget_treeInspect the running app's widget tree structure
get_source_codeRead Dart source files with line numbers
analyze_fileRun dart analyze and return diagnostics
apply_fixAuto-fix a specified code region

2. Runtime Monitoring

Connects to a running app via Flutter VM Service Protocol and captures errors in real time:

  • RenderFlex overflowed - Layout overflow
  • RenderBox was not laid out - Unlaid render box
  • Null check operator on null value - Null reference
  • setState() called after dispose() - setState after dispose
  • Type errors - Type casting failures

3. Self-Healing Workflow

Applies 7 automatic fix strategies based on error patterns:

StrategyTarget ErrorFix Applied
WrapWithExpandedRenderFlex overflowWrap child widget with Expanded
WrapWithSingleChildScrollViewContent overflowWrap with SingleChildScrollView
AddFlexibleFlex overflowAdd Flexible widget
AddNullCheckNull referenceApply ?. and null safety
AddMountedChecksetState after disposeInsert if (!mounted) return; guard
WrapWithSafeAreaSystem UI intrusionWrap with SafeArea
AddConstraintsUnbounded sizeAdd SizedBox/ConstrainedBox

After applying a fix, it verifies with dart analyze + flutter test and auto-rollbacks on failure.

4. CI/CD Integration

  • Auto-creates autofix/{error-type}-{timestamp} branches
  • Creates PRs via GitHub API (with error description, root cause, code diff)
  • Auto-approves + squash merges on test pass
  • Posts failure comment + closes PR on test failure
  • Supports external CI webhooks (e.g., Semaphore CI)

5. Admin Dashboard

A real-time monitoring dashboard available on mobile, desktop, and web:

  • Overview tab - Agent status, error/fix/verified/PR counts, success rate chart
  • Timeline tab - Chronological view of error and fix events
  • Errors tab - Live error log (severity, stack trace, widget path)
  • Fixes tab - Fix history (original/fixed code diff, test results, PR links)
  • Notifications - Real-time alerts (error detected, fix applied, PR created)
  • Settings - VM Service connection, GitHub/CI config, agent behavior, notification settings

6. Design System

Custom color palette with a unified design system:

UsageColorHex
PrimaryPurple#6C5CE7
AccentCyan#00D2D3
SuccessMint Green#00B894
WarningSoft Orange#FDAA5E
ErrorCoral Red#FF6B6B
InfoSky Blue#54A0FF

Full light/dark mode support, gradient bar charts, glowing timeline effects, and modern UI throughout.


Usage

Step 1: Installation

git clone https://github.com/kimdzhekhon/Auto_Cure.git
cd Auto_Cure
flutter pub get

Step 2: Run the AutoCure Dashboard

flutter run              # Mobile
flutter run -d macos     # macOS
flutter run -d windows   # Windows
flutter run -d linux     # Linux
flutter run -d chrome    # Web

Step 3: Connect to a Target Flutter App

cd /path/to/your/flutter/app
flutter run --debug

Find the VM Service URI in the terminal output:

An Observatory debugger and profiler on ... is available at:
http://127.0.0.1:XXXXX/XXXXXX=/

Tap Start Agent in the AutoCure dashboard and enter the URI.

Step 4: Enable Auto-Healing

  1. Turn on the Agent ON/OFF toggle in the dashboard.
  2. The agent starts monitoring the target app's runtime errors in real time.
  3. When an error occurs, it automatically analyzes, fixes, verifies, and creates a PR.

Step 5: MCP Server (Optional)

dart run tools/mcp_server/bin/server.dart

Step 6: CI/CD Setup (Optional)

export GITHUB_TOKEN=your_token
export AUTOCURE_REPO_OWNER=kimdzhekhon
export AUTOCURE_REPO_NAME=Auto_Cure

Tech Stack

AreaTechnology
FrameworkFlutter 3.11+ / Dart 3.11+
Runtime Monitoringvm_service, web_socket_channel
State Managementprovider
Chartsfl_chart
CI/CDGitHub Actions, GitHub API
MCP CommunicationJSON-RPC 2.0 over stdin/stdout
Process Managementprocess_run

License

This project is licensed under the MIT License.