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

Skip to content

moinsen-dev/dart_ment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 dart_ment

AI-Powered Code Repair & Refactoring for Dart

pub package style: very good analysis License: MIT Powered by Gemini Dart Platform

Transform your Dart code from messy to magnificent with AI-powered automated fixes! πŸš€

Quick Start β€’ Demo β€’ Features β€’ Installation β€’ Usage β€’ Configuration


🎯 What is dart_ment?

dart_ment is your AI-powered companion that automatically fixes linting issues, improves code quality, and provides intelligent suggestions for your Dart/Flutter projects. Think of it as having a senior Dart developer reviewing and fixing your code 24/7!

πŸ€” Why dart_ment?

  • Save Hours: Stop manually fixing repetitive linting issues
  • Learn Best Practices: Get AI-powered suggestions based on Dart/Flutter guidelines
  • Improve Code Quality: Maintain consistent, clean code across your project
  • Boost Productivity: Focus on features, not formatting

πŸ“Έ Demo

$ ment analyze

πŸ” Starting code analysis...
βœ“ Found 142 Dart files
βœ“ Analysis complete: 23 issues, 47 suggestions

πŸ“„ lib/src/user_service.dart
  Issues (3):
    ❌ Missing type annotation for 'data'
    ❌ Avoid using 'dynamic' as a type
    ❌ Prefer const constructors
  Suggestions (2):
    πŸ’‘ Consider using a more specific return type
    πŸ’‘ Extract this logic into a separate method

$ ment fix

πŸ› οΈ Starting fix process...
βœ“ Found 23 issues in 8 files
  Generating fix... βœ“ Fix applied
  Generating fix... βœ“ Fix applied
βœ“ Fixed 23 issues. Run "dart analyze" to verify the fixes.

✨ Features

πŸ€– AI-Powered Intelligence

Leverages Google Gemini's understanding of Dart/Flutter to provide context-aware fixes

πŸ” Deep Code Analysis

Comprehensive static analysis that catches issues dart analyze might miss

πŸ›‘οΈ Safe Refactoring

Preview changes with --dry-run before applying them to your codebase

⚑ Lightning Fast

Analyzes and fixes hundreds of files in seconds with smart token optimization

🎨 Style Consistency

Enforces consistent code style across your entire project

πŸ“Š Smart Suggestions

Get improvement recommendations beyond just linting fixes

πŸ“ Flexible Targeting

Analyze and fix specific directories without changing your working directory

πŸ’° Token Efficient

Only analyzes files with errors by default, saving API costs

πŸš€ Quick Start

# 1. Install dart_ment globally
dart pub global activate dart_ment

# 2. Get your Gemini API key (free)
# Visit: https://makersuite.google.com/app/apikey

# 3. Run in your Dart/Flutter project
cd your_project
ment fix --api-key YOUR_GEMINI_API_KEY

# That's it! πŸŽ‰

πŸ“¦ Installation

Prerequisites

Global Installation (Recommended)

dart pub global activate dart_ment

Add to Project

dev_dependencies:
  dart_ment: ^0.2.0

πŸ’» Usage

πŸ” Analyze Your Code

Get a comprehensive analysis of your codebase with AI-powered suggestions:

# Basic analysis
ment analyze

# Analyze a specific directory
ment analyze lib/src
ment analyze example

# With custom configuration
ment analyze --config analysis_config.yaml

# Disable AI suggestions (faster)
ment analyze --no-suggestions

# Analyze all files with AI (including files without errors)
ment analyze --all-files

# Analyze and automatically apply fixes
ment analyze --apply-fixes

πŸ› οΈ Fix Issues Automatically

Let AI fix your linting issues intelligently:

# Fix with API key as parameter
ment fix --api-key YOUR_KEY

# Fix issues in a specific directory
ment fix lib
ment fix test

# Fix with environment variable
export GEMINI_API_KEY=YOUR_KEY
ment fix

# Preview fixes without applying
ment fix --dry-run

# Select a different AI model
ment fix --model gemini-1.5-pro

# Set maximum fix iterations (default: 3)
ment fix --max-iterations 5

πŸ€– Manage AI Models

List and select from available Gemini models:

# List all available models
ment models --list

# Select a model interactively
ment models --select

# Set a specific model
ment models --set gemini-1.5-pro

βš™οΈ Configuration Management

Manage your dart_ment configuration:

# Show current configuration
ment config show

# Set configuration values
ment config set model gemini-1.5-flash

# Show configuration file paths
ment config path

πŸ”„ Update dart_ment

Keep dart_ment up to date with the latest improvements:

ment update

βš™οΈ Configuration

dart_ment stores configuration in your home directory at ~/.dart_ment/ for easy access across all projects.

1. API Key Setup

Set your Gemini API key using one of these methods:

# Option 1: Using config command (stored securely)
ment config set gemini_api_key YOUR_API_KEY

# Option 2: Environment variable
export GEMINI_API_KEY=your_api_key_here

# Option 3: Edit ~/.dart_ment/api_keys.yaml directly

2. Configuration File

Configuration is stored at ~/.dart_ment/config.yaml:

# Default AI model
model: gemini-1.5-flash

# Analysis Settings
analysis:
  include:
    - lib/**/*.dart
    - bin/**/*.dart
    - test/**/*.dart
  exclude:
    - "**/*.g.dart"
    - "**/*.freezed.dart"

# Fix Settings
fixes:
  backup: true          # Create .backup files
  interactive: false    # Auto-apply fixes
  max_suggestions: 3    # Suggestions per issue

3. Command Line Flags

ment fix \
  --api-key YOUR_KEY \
  --config custom_config.yaml \
  --dry-run

🎯 When to Use dart_ment

Perfect for:

  • πŸ“± Flutter Projects: Optimized for Flutter-specific patterns
  • 🏒 Large Codebases: Fix hundreds of files in one command
  • πŸ‘₯ Team Projects: Enforce consistent code style
  • πŸŽ“ Learning: Understand why fixes are suggested
  • ⏰ CI/CD Pipelines: Automated code quality checks

Use Cases:

  1. Before Code Reviews: Clean up your code automatically
  2. Legacy Code: Modernize old Dart code to current standards
  3. After Major Refactoring: Ensure consistency across changes
  4. New Team Members: Help them follow project conventions

🀝 Contributing

We love contributions! See our Contributing Guide for details.

# Clone the repo
git clone https://github.com/yourusername/dart_ment.git

# Install dependencies
dart pub get

# Run tests
dart test

# Make your changes and submit a PR!

πŸš€ Releasing

New releases are automatically created when version tags are pushed:

# Tag a new version
git tag v0.1.0
git push origin v0.1.0

This will automatically:

  • Create a GitHub release with changelog
  • Publish to pub.dev (if credentials are configured)

See .github/workflows/README.md for details.

πŸ“Š Roadmap

  • VS Code Extension
  • Custom Lint Rules
  • Team Style Guides
  • Local LLM Support
  • Fix History & Rollback
  • Performance Metrics

πŸ™ Acknowledgments

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with πŸ’™ by the Dart community

Report Bug β€’ Request Feature

About

AI-powered automated code repair and refactoring tool for Dart.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages