AI-powered Git commit analyzer and rewriter with conventional commit standards support
npm install @honga/repoA powerful TypeScript tool that analyzes, categorizes, and can rewrite git commit messages using AI to help standardize your commit history according to conventional commit standards.
- π€ AI-Powered Analysis: Uses OpenRouter API to classify commit messages intelligently
- π Commit Message Rewriting: Actually rewrite git history with conventional prefixes (DESTRUCTIVE!)
- π Comprehensive Documentation: Includes detailed conventional commits guide with examples
- π Comprehensive Reporting: Generates detailed analysis reports with statistics
- π§ Rule Generation: Automatically creates transformation rules for standardizing commits
- β‘ Adaptive Batch Processing: Optimizes API usage with intelligent batch sizing
- π― Rate Limiting: Built-in rate limiting to respect API quotas
- π‘οΈ Safety Features: Automatic backups, dry-run mode, and interactive confirmations
- π§ͺ Synthetic Testing: Test mode for development and validation
- π Progress Tracking: Real-time progress indicators for long-running analyses
Install the tool globally to use it from anywhere:
``bashInstall globally from npm (if published)
npm install -g git-commit-categories
After global installation, you can use either command:
-
git-commit-analyzer (full name)
- gca (short alias)$3
Clone and build locally:
`bash
git clone
cd git-commit-categories
npm install
npm run build
`Configuration
1. Copy the example environment file:
`bash
cp .env.example .env
`2. Edit
.env and add your OpenRouter API key:`bash
OPENROUTER_API_KEY=your_api_key_here
`3. (Optional) Customize other settings in
.env:`bash
AI Models
AI_CLASSIFICATION_MODEL=deepseek/deepseek-r1-distill-llama-70b
RULE_GENERATION_MODEL=deepseek/deepseek-r1-distill-llama-70bProcessing Limits
MAX_COMMITS_TO_ANALYZE=500
MAX_COMMITS_TO_PROCESS=1000
INITIAL_BATCH_SIZE=16
DIFF_CONCURRENCY=4API Configuration
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1/chat/completions
HTTP_REFERER=https://github.com/your-org/your-repo
X_TITLE=Your Project Commit Analyzer
`Usage
$3
`bash
Analyze a repository (global installation)
git-commit-analyzer /path/to/your/repoOr using the short alias
gca /path/to/your/repoLocal usage
npm start /path/to/your/repo
`$3
`bash
Analyze only the last 100 commits
gca /path/to/repo --max-commits 100Custom batch size and concurrency
gca /path/to/repo --batch-size 32 --concurrency 8Run synthetic tests
gca --synthetic-testGet help
gca --help
`$3
β οΈ WARNING: These operations modify git history and are DESTRUCTIVE! Always use --dry-run first and ensure you have backups.
`bash
Preview what would be changed (SAFE)
gca /path/to/repo --dry-runActually rewrite commit messages (DESTRUCTIVE!)
gca /path/to/repo --rewriteRewrite without backup (VERY DANGEROUS!)
gca /path/to/repo --rewrite --no-backupNon-interactive rewrite
gca /path/to/repo --rewrite --no-interactive
`$3
`bash
Generate conventional commits guide only
gca --generate-guideInclude guide in target repository after analysis
gca /path/to/repo --include-guide
`$3
#### Analysis Options
| Option | Short | Description | Default |
| ------------------ | ----- | ------------------------------------ | ------- |
|
--help | -h | Show help message | - |
| --max-commits | -m | Maximum commits to analyze | all |
| --max-process | -p | Maximum commits to process for rules | all |
| --batch-size | -b | Initial batch size for API calls | 16 |
| --concurrency | -c | Concurrent git operations | 4 |
| --synthetic-test | -t | Run synthetic tests | false |#### Rewrite Options (β οΈ DESTRUCTIVE!)
| Option | Short | Description | Default |
| ------------------ | ----- | -------------------------------- | ------- |
|
--rewrite | -r | Actually rewrite commit messages | false |
| --dry-run | -d | Preview changes without applying | false |
| --no-backup | - | Skip creating backup branch | false |
| --no-interactive | - | Skip interactive confirmations | false |
| --branch | -B | Specify target branch name | current |#### Documentation Options
| Option | Short | Description | Default |
| ------------------ | ----- | ----------------------------------- | ------- |
|
--generate-guide | -g | Generate conventional commits guide | false |
| --include-guide | - | Include guide in target repository | false |Output
The tool generates comprehensive reports including:
- Prefix Distribution: Current vs. suggested commit prefixes
- Conformance Analysis: Percentage of commits following conventional standards
- Transformation Rules: AI-generated rules for standardizing commits
- Recommendations: Actionable suggestions for improving commit practices
$3
`
π COMMIT ANALYSIS REPORT
================================================================================π Current Prefix Distribution:
βββββββββββ¬ββββββββ¬ββββββββ
β (index) β prefixβ count β
βββββββββββΌββββββββΌββββββββ€
β 0 β 'none'β 45 β
β 1 β 'feat'β 23 β
β 2 β 'fix' β 18 β
βββββββββββ΄ββββββββ΄ββββββββ
π― Suggested Prefix Distribution:
βββββββββββ¬ββββββββ¬ββββββββ
β (index) β prefixβ count β
βββββββββββΌββββββββΌββββββββ€
β 0 β 'feat'β 35 β
β 1 β 'fix' β 28 β
β 2 β 'chore'β 15 β
βββββββββββ΄ββββββββ΄ββββββββ
β
Conforming commits: 41/86 (48%)
β Non-conforming commits: 45/86 (52%)
`Development
$3
`bash
npm run build
`$3
`bash
npm run lint # Run ESLint
npm run format # Format with Prettier
npm run lint:knip # Check for unused dependencies
npm run check # Run all checks
`$3
`bash
Run synthetic tests
npm start -- --synthetic-testOr set environment variable
SYNTHETIC_TEST_MODE=true npm start
`Environment Variables
| Variable | Description | Default |
| ------------------------- | ---------------------------------- | ----------------------------------------------- |
|
OPENROUTER_API_KEY | Your OpenRouter API key (required) | - |
| OPENROUTER_BASE_URL | OpenRouter API endpoint | https://openrouter.ai/api/v1/chat/completions |
| AI_CLASSIFICATION_MODEL | Model for commit classification | deepseek/deepseek-r1-distill-llama-70b |
| RULE_GENERATION_MODEL | Model for rule generation | deepseek/deepseek-r1-distill-llama-70b |
| MAX_COMMITS_TO_ANALYZE | Max commits to analyze | all |
| MAX_COMMITS_TO_PROCESS | Max commits to process | all |
| INITIAL_BATCH_SIZE | Starting batch size | 16 |
| MIN_BATCH_SIZE | Minimum batch size | 2 |
| MAX_BATCH_SIZE | Maximum batch size | 128 |
| CONTEXT_LIMIT_THRESHOLD | Token limit threshold | 30000 |
| DIFF_CONCURRENCY | Concurrent git operations | 4 |
| SYNTHETIC_TEST_MODE | Enable test mode | false |
| OUTPUT_JSON | Output JSON report | false |Conventional Commit Standards
The tool analyzes commits against conventional commit standards:
-
feat: - New features
- fix: - Bug fixes
- docs: - Documentation changes
- style: - Code style changes (formatting, etc.)
- refactor: - Code refactoring
- test: - Adding or updating tests
- chore: - Maintenance tasks
- build: - Build system changes
- ci: - CI/CD changes
- perf: - Performance improvements
- revert: - Reverting changesAPI Requirements
π NEW: Automatic API Key Management!
The tool now automatically obtains temporary API keys from OpenRouter when none is provided! No manual setup required for basic usage.
$3
- Just run the tool - it will automatically get a temporary API key
- Limited usage but perfect for trying out the tool
- No manual configuration needed
$3
For unlimited usage and better rate limits:
1. Sign up at OpenRouter
2. Get your API key from the dashboard
3. Add credits to your account (free tier available)
4. Set the
OPENROUTER_API_KEY environment variableThe tool will automatically detect and use your manual API key if provided, otherwise it falls back to automatic temporary keys.
Troubleshooting
$3
1. Missing API Key: Ensure
OPENROUTER_API_KEY is set in your .env file
2. Rate Limiting: The tool handles rate limits automatically, but you may need to wait or upgrade your plan
3. Large Repositories: Use --max-commits to limit analysis scope for very large repos
4. Memory Issues: Reduce --batch-size and --concurrency for resource-constrained environments$3
Set
DEBUG=1 to enable verbose logging:`bash
DEBUG=1 gca /path/to/repo
`Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Run tests and linting:
npm run check`ISC License - see LICENSE file for details.
- Initial release
- AI-powered commit classification
- Adaptive batch processing
- Comprehensive reporting
- Global CLI tool support