auto-gitmoji 0.1.2

A Rust CLI tool that automatically prepends appropriate gitmoji to your commit messages based on intelligent keyword matching.
Documentation

Auto-Gitmoji ๐Ÿš€

A Rust CLI tool that automatically prepends appropriate gitmoji to your commit messages based on intelligent keyword matching.

โœจ Features

  • ๐ŸŽฏ Simple KeywordMatching: Enhanced first-word keyword matching with 200+ keyword mappings
  • ๐ŸŽฏ LLM KeywordMatching: AI-powered matching with LLM(now only support SiliconFlow)
  • ๐ŸŽจ Comprehensive Emoji Support: All 69 official gitmojis from the gitmoji standard
  • โšก Git Integration: Seamless integration with your Git workflow
  • ๐Ÿ‘€ Dry Run Mode: Preview commits before executing
  • ๐Ÿ“‹ Emoji Display: View all available gitmojis with Unicode rendering
  • ๐Ÿ›ก๏ธ Robust Error Handling: Validates staged changes and Git repository status
  • ๐Ÿงช Comprehensive Testing: 65 tests covering unit, integration, and edge cases
  • ๐Ÿ“Š Enhanced CLI Experience: ANSI colors, progress indicators, and user-friendly output

๐Ÿ”ฎ Future Features

  • Support for more LLM APIs
  • Custom keyword mapping configuration
  • Integration with commit message templates

๐Ÿš€ Installation

Prerequisites

  • Rust 1.70+ with Cargo
  • Git installed and configured

From Source

git clone https://github.com/yourusername/auto-gitmoji.git
cd auto-gitmoji
cargo build --release
cargo install --path .

From Crates.io

cargo install auto-gitmoji
# or with your own API_KEY
cargo install auto-gitmoji --features llm

๐Ÿ“‹ Usage

Basic Usage

# Commit with automatic gitmoji selection
amoji "add new user authentication feature"
# Output: โœจ :sparkles: add new user authentication feature

# Preview without committing (dry run)
amoji "fix login validation bug" --dry-run
# Output: ๐Ÿ› :bug: fix login validation bug

# Show all available emojis
amoji --show-emoji

# Get detailed help with examples
amoji --help-message

Complete Examples

# Feature additions
amoji "add user profile page"
# Result: โœจ :sparkles: add user profile page

# Bug fixes
amoji "fix memory leak in data processor"
# Result: ๐Ÿ› :bug: fix memory leak in data processor

# Hotfixes
amoji "hotfix critical authentication vulnerability"
# Result: ๐Ÿš‘๏ธ :ambulance: hotfix critical authentication vulnerability

# Documentation
amoji "docs update installation guide"
# Result: ๐Ÿ“ :memo: docs update installation guide

# Refactoring
amoji "refactor authentication module"
# Result: โ™ป๏ธ :recycle: refactor authentication module

# Performance improvements
amoji "optimize database query performance"
# Result: โšก :zap: optimize database query performance

# Testing
amoji "test user registration flow"
# Result: ๐Ÿงช :test_tube: test user registration flow

# Dependencies
amoji "update package dependencies"
# Result: ๐Ÿ“ฆ :package: update package dependencies

# Security
amoji "security fix for JWT validation"
# Result: ๐Ÿ”’ :lock: security fix for JWT validation

๐ŸŽฏ How It Works

Enhanced Keyword Matching Strategy

  1. ๐Ÿ” Analysis: Commit message analyzed word by word
  2. ๐Ÿงน Cleaning: Non-alphanumeric characters replaced with spaces for better word extraction
  3. ๐Ÿ“ Extraction: Words split by whitespace and normalized to lowercase
  4. ๐ŸŽฏ Matching: First word matched against comprehensive keyword database
  5. โœจ Formatting: Complete commit message formatted with appropriate gitmoji

Keyword Categories

Category Keywords Emoji
Features add, new, create, implement, introduce, feat โœจ :sparkles:
Bug Fixes fix, repair, resolve, correct, patch ๐Ÿ› :bug:
Hotfixes hotfix, urgent, critical ๐Ÿš‘๏ธ :ambulance:
Documentation docs, documentation, readme, comment ๐Ÿ“ :memo:
Refactoring refactor, restructure, reorganize, cleanup โ™ป๏ธ :recycle:
Performance optimize, performance, speed, cache, perf โšก :zap:
Testing test, testing, spec, coverage ๐Ÿงช :test_tube:
Security security, vulnerability, auth, permission ๐Ÿ”’ :lock:
Styling style, format, lint, prettier ๐Ÿ’„ :lipstick:
Dependencies deps, dependency, package, upgrade ๐Ÿ“ฆ :package:
Configuration config, configuration, settings, env โš™๏ธ :gear:

Architecture

The tool uses a clean strategy pattern with pluggable matchers:

pub trait GitmojiMatcher {
    fn match_emoji(&self, message: &str) -> Result<MatcherResult>;
    fn name(&self) -> &'static str;
}

pub type MatcherResult = Option<(String, String)>; // (emoji_code, formatted_message)

Current Matchers:

  • SimpleMatcher: Keyword-based matching with 200+ keywords
  • LLMMatcher: AI-powered matching (optional feature)

๐Ÿ› ๏ธ CLI Options

amoji [OPTIONS] [MESSAGE]

ARGUMENTS:
  [MESSAGE]  The commit message

OPTIONS:
  -d, --dry-run        Show what would be committed without actually committing
  -s, --show-emoji     Show available emoji codes
  -m, --help-message   Show help message with usage examples
  -h, --help           Print help
  -V, --version        Print version

๐Ÿงช Development

Building

# Debug build
cargo build

# Release build
cargo build --release

Testing

# Run all tests
cargo test

# Run with output
cargo test -- --nocapture

# Run specific test module
cargo test matcher::tests

Running

# Development
cargo run -- "your commit message"

# With features
cargo run --features llm -- "your commit message"

# Dry run
cargo run -- "your commit message" --dry-run

Project Structure

src/
โ”œโ”€โ”€ main.rs              # CLI application entry point
โ”œโ”€โ”€ lib.rs               # Library exports and integration tests
โ”œโ”€โ”€ commit.rs            # Git commit operations
โ”œโ”€โ”€ emoji.rs             # Emoji lookup and mapping
โ””โ”€โ”€ matcher/
    โ”œโ”€โ”€ mod.rs           # Matcher trait and factory
    โ”œโ”€โ”€ simple.rs        # Keyword-based matcher
    โ””โ”€โ”€ llm.rs           # LLM-based matcher (feature gated)
tests/
โ”œโ”€โ”€ integration_tests.rs # Full workflow integration tests
fixtures/
โ”œโ”€โ”€ gitmojis.json        # Official gitmoji data (69 emojis)
โ””โ”€โ”€ keyword_map.json     # Keyword to emoji mappings (200+ keywords)

๐Ÿ”ง Features & Configuration

Optional Features

[features]
default = []
llm = ["reqwest", "tokio", "dotenvy"]

To enable LLM support:

cargo build --features llm

Environment Variables

# For LLM feature
export API_KEY="your-api-key"

๐Ÿ“Š Quality Metrics

  • Test Coverage: 65 tests (56 unit + 9 integration)
  • Performance: < 100ms for typical operations
  • Reliability: Comprehensive error handling and edge case coverage
  • Compatibility: Works with all major terminals and Git workflows

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with tests
  4. Ensure all tests pass: cargo test
  5. Submit a pull request

Code Style

  • Use cargo fmt for formatting
  • Use cargo clippy for linting
  • Follow Rust 2024 edition standards
  • Add tests for new functionality

๐Ÿ“„ License

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

๐Ÿ™ Acknowledgments

  • Gitmoji for the comprehensive emoji standard
  • The Rust community for excellent tooling and libraries
  • Contributors and users who provide feedback and improvements