An intelligent Git commit message generator using AI to automatically create clear, conventional commit messages from your staged changes.
Writing clear and consistent git commit messages is crucial for maintaining readable project history and collaboration. This project solves that by using AI to analyze your code changes and generate standardized, high-quality commit messages automatically.
| Category | Technology Used |
|---|---|
| Programming Language | Node.js (TypeScript) |
| Framework | NestJS |
| AI Engine | OpenAI GPT-4o / GPT-4o-mini |
| Environment | dotenv |
| Version Control | Git diff output |
- True Multi-Agent System: Specialized agents working in coordination
- AI-Powered Analysis: Uses OpenAI's GPT models to understand code changes
- Conventional Commits: Generates messages following conventional commit format
- Dynamic Task Allocation: Agents adapt their workload based on complexity
- Agent Negotiation: Agents can collaborate and refine each other's outputs
- Rate Limiting: Built-in delays to respect OpenAI API limits
- Error Handling: Robust error handling with fallback messages
- Batch Processing: Handles multiple staged files efficiently
- Comprehensive Logging: Detailed execution tracking and monitoring
- Unit Testing: Comprehensive test suite for all agents and services
- Performance Metrics: Processing time and confidence tracking
- Extensible Architecture: Easy to add new agents and capabilities
The project implements a true Multi-Agent System with specialized agents working in coordination:
- GitService: Extracts staged changes from git
- PreprocessorAgent: Cleans and normalizes git diffs
- DiffAnalysisAgent: Analyzes code changes and determines change type
- SummaryAgent: Generates human-readable summaries
- FormatterAgent: Formats output as conventional commits
- MultiAgentService: Orchestrates the entire workflow
- OpenAIService: Handles AI model interactions
Git Staged Changes → PreprocessorAgent → DiffAnalysisAgent → SummaryAgent → FormatterAgent → Final Commit Message
↓
OpenAI API (for analysis and summary)
| Agent | Role | Input | Output |
|---|---|---|---|
| PreprocessorAgent | Input Normalizer | Raw git diffs | Cleaned, structured diffs |
| DiffAnalysisAgent | Change Analyzer | Cleaned diffs | Change type and analysis |
| SummaryAgent | Natural Language Generator | Analysis | Human-readable summary |
| FormatterAgent | Commit Composer | Analysis + Summary | Conventional commit message |
Traditional single-agent systems suffer from several critical limitations:
- Cognitive Overload: One agent must handle all aspects of commit message generation
- Limited Specialization: No deep expertise in specific domains (preprocessing, analysis, formatting)
- Brittle Architecture: Single point of failure affects the entire system
- Poor Scalability: Difficult to add new capabilities or modify existing ones
- Inconsistent Quality: Output quality varies based on the single agent's current state
| MAS Principle | Application in Commit Generation | Business Value |
|---|---|---|
| Specialization | Each agent masters one aspect (preprocessing, analysis, formatting) | Higher quality, more accurate commit messages |
| Modularity | Agents can be updated independently without affecting others | Easy maintenance and feature additions |
| Fault Tolerance | If one agent fails, others can still provide partial results | Improved system reliability |
| Scalability | New agents can be added for specific needs (security analysis, performance impact) | Future-proof architecture |
| Collaboration | Agents can negotiate and refine each other's outputs | Better decision-making through collective intelligence |
| Dynamic Allocation | Workload distributed based on complexity and agent capabilities | Optimal resource utilization |
- Quality Assurance: Multiple agents validate and refine outputs
- Adaptability: System can handle different types of changes (features, bugs, refactors)
- Maintainability: Clear separation of concerns makes debugging easier
- Extensibility: Easy to add new agents for specific requirements
- Transparency: Clear visibility into each step of the process
- Reliability: Redundancy and error handling at multiple levels
| Aspect | Single Agent | Multi-Agent System |
|---|---|---|
| Code Quality | Mixed, depends on prompt engineering | Consistently high, specialized expertise |
| Maintainability | Monolithic, hard to modify | Modular, easy to update individual components |
| Debugging | Difficult to isolate issues | Clear agent-level debugging |
| Scalability | Limited by single agent capacity | Horizontally scalable |
| Error Handling | Single point of failure | Distributed error handling |
| Future Growth | Requires complete rewrites | Add new agents incrementally |
# Run all tests
npm test
# Run only unit tests
npm run test:unit
# Run only agent tests
npm run test:agents
# Run only service tests
npm run test:services
# Run tests with coverage
npm run test:cov
# Run tests in watch mode
npm run test:watch
# Run all tests (unit + e2e)
npm run test:allThe project includes comprehensive unit tests for:
- Agent Classes: Individual agent functionality and error handling
- Service Classes: Multi-agent orchestration and task allocation
- Error Scenarios: Network failures, invalid inputs, edge cases
- Integration Points: Agent-to-agent communication and negotiation
test/
├── agents/
│ ├── preprocessor.agent.spec.ts
│ ├── diff-analysis.agent.spec.ts
│ ├── summary.agent.spec.ts
│ └── formatter.agent.spec.ts
├── services/
│ ├── multi-agent.service.spec.ts
│ ├── git.service.spec.ts
│ └── openai.service.spec.ts
└── e2e/
└── app.e2e-spec.ts
- Node.js v18+ (recommended: v20+ for better performance)
- npm or yarn package manager
- Git installed and configured
- OpenAI API key with sufficient credits
- Internet connection for API calls
- Git repository with staged changes
Node.js Configuration:
# Check Node.js version
node --version # Should be v18+
# Check npm version
npm --version # Should be v8+Git Configuration:
# Ensure git is installed and configured
git --version
# Configure git user (if not already done)
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"- Clone the repository:
git clone <repository-url>
cd AutoCommitAI- Install dependencies:
npm install
# or
yarn install- Environment Configuration:
Create a
.envfile in the root directory:
# Required: OpenAI API Key
OPENAI_API_KEY=sk-your-openai-api-key-here
# Optional: Custom model configuration
OPENAI_MODEL=gpt-4o-mini
# Optional: Rate limiting configuration
RATE_LIMIT_DELAY=2000
# Optional: Debug mode
DEBUG_MODE=falseGit Configuration Issues:
# If you get "fatal: not a git repository" error
git init
git add .
git commit -m "Initial commit"
# If you get permission errors
git config --global --unset credential.helper
git config --global credential.helper storeNetwork Access Issues:
- Ensure firewall allows outbound HTTPS connections
- Check corporate proxy settings if applicable
- Verify OpenAI API access from your network
API Key Issues:
- Verify API key is valid and has sufficient credits
- Check API key permissions and rate limits
- Ensure no extra spaces or characters in the key
Node.js Version Issues:
# If using nvm, switch to correct version
nvm use 20
# If using n, switch to correct version
n 20- Stage your changes:
git add .- Run the multi-agent system:
npm run start:multi-agent- Copy the generated message and use it in your commit:
git commit -m "feat: add user authentication with JWT tokens"- Stage your changes:
git add .- Run the single-agent system:
npm start| Command | Description |
|---|---|
npm run start:multi-agent |
Run the full multi-agent system |
npm run start:multi-agent:dev |
Run multi-agent system in dev mode |
npm start |
Run the legacy single-agent system |
npm run start:dev |
Run single-agent system in development mode |
npm run build |
Build the project |
npm run lint |
Run ESLint |
npm test |
Run tests |
src/
├── agents/
│ ├── diff-analysis.agent.ts # Analyzes code changes
│ ├── formatter.agent.ts # Formats conventional commits
│ ├── preprocessor.agent.ts # Cleans and normalizes diffs
│ └── summary.agent.ts # Generates human-readable summaries
├── services/
│ ├── git.service.ts # Git operations
│ ├── openai.service.ts # OpenAI API integration
│ └── multi-agent.service.ts # Orchestrates the MAS workflow
├── app.module.ts # NestJS module configuration
├── main.ts # Single-agent entry point
└── main-multi-agent.ts # Multi-agent system entry point
Staged changes in auth.service.ts and user.controller.ts
feat: add JWT authentication and user profile endpoints
| Variable | Description | Required |
|---|---|---|
OPENAI_API_KEY |
Your OpenAI API key | Yes |
The system includes built-in rate limiting with 5-second delays between API calls to respect OpenAI's rate limits.
- OpenAI Dependency: Requires OpenAI API key and internet connection
- Rate Limits: Built-in delays to prevent API rate limit issues
- Local LLM Support: Currently only supports OpenAI API (local LLM integration was attempted but removed)
- Local LLM Support: Add support for local language models to reduce API dependency
- Custom Templates: Allow project-specific commit message templates
- GitHub Integration: Direct integration with GitHub for automated PR descriptions
- Language Support: Multi-language commit message generation
- Agent Monitoring: Add detailed logging and monitoring for each agent
- Parallel Processing: Optimize agent execution for better performance
- Custom Agent Types: Allow users to define custom agent behaviors
npm run start:devnpm run build
npm run start:prodnpm run lintThe system includes comprehensive error handling:
- API Errors: Graceful handling of OpenAI API failures
- Git Errors: Proper error messages for git-related issues
- Rate Limiting: Automatic delays to prevent API overuse
- Fallback Messages: Default messages when AI generation fails
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
This project is licensed under the UNLICENSED license.
Navarathinam Cenrayan
Backend Developer (Node.js | NestJS | TypeScript)
Multi-Agent System Evaluation Project
This project was created as part of a multi-agent system evaluation and demonstrates AI-powered automation for developer workflows.