Package Exports
- orcommit
- orcommit/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (orcommit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ORCommit Git Manager
AI-powered Git commit message generator with efficient chunk processing for large files
A sophisticated CLI tool that generates meaningful, contextual commit messages using ORCommit and OpenAI APIs. Designed with a modular TypeScript architecture and optimized for handling large codebases through intelligent diff chunking.
โจ Features
- ๐ค AI-Powered: Generate commit messages using ORCommit and OpenAI models
- ๐ฆ Token-Aware Chunking: Intelligently split large diffs based on actual token limits
- ๐ Smart Push Integration: Interactive push prompts with automatic upstream setup
- ๐จ Elegant UI: Structured progress with phase indicators and timing
- โก Lightning Fast: Intelligent caching with memory and disk persistence
- ๐ง Highly Configurable: Extensive CLI options and provider settings
- ๐ Secure: Safe storage of API keys with proper file permissions (600)
- ๐ฏ Conventional Commits: Full support for conventional commit format with emoji
- ๐ก๏ธ Robust: Comprehensive error handling with timeouts and auto-recovery
- ๐ง Smart Filtering: Automatically filters generated files and whitespace
- ๐งช Production Ready: Comprehensive test suite with 90%+ coverage
๐ Installation
Install globally via npm:
npm install -g orcommitOr use directly with npx:
npx orcommit๐ Quick Start
Set up your API key:
orc config set openrouter your-api-key-here # or for OpenAI orc config set openai your-openai-key-here
Stage your changes:
git add .
Generate and create commit:
orc commit
That's it! The tool will analyze your staged changes and generate an appropriate commit message.
๐ Commands
orc commit (default)
Generate and create a commit message for staged changes.
Options:
Basic Options:
-y, --yes- Skip confirmation and auto-commit-d, --dry-run- Generate message without creating commit-v, --verbose- Enable verbose logging-w, --watch- Watch for changes and auto-generate commits
Commit Format:
-s, --scope <scope>- Specify commit scope (e.g., auth, ui, api)-t, --type <type>- Specify commit type (feat, fix, docs, etc.)-b, --breaking- Mark as breaking change--emoji- Include appropriate emoji in commit message--one-line- Generate single-line commit message--description-length <length>- Maximum description length
Provider & Processing:
-p, --provider <provider>- Specify AI provider (openrouter|openai)--max-files <count>- Maximum number of files to analyze--ignore-generated- Ignore auto-generated files (default: true)--ignore-whitespace- Ignore whitespace-only changes (default: true)
Caching:
--no-cache- Disable caching for this commit--clear-cache- Clear cache before generating
Git Integration:
--push- Push changes to remote after commit--auto-push- Automatically push all future commits
Examples:
# Basic usage with interactive push prompt
orc commit
# Auto-confirm and push
orc commit --yes --push
# Generate with emoji and one-line format
orc commit --emoji --one-line
# Specify type, scope and auto-push
orc commit --type feat --scope auth --auto-push
# Dry run to see generated message
orc commit --dry-run --verbose
# Breaking change with description limit
orc commit --breaking --type feat --description-length 50
# Clear cache and use specific provider
orc commit --clear-cache --provider openai
# Process only 5 files with no caching
orc commit --max-files 5 --no-cacheorc config
Manage configuration settings.
Subcommands:
# Set API key
orc config set openrouter sk-your-key-here
orc config set openai sk-your-openai-key
# Set default model
orc config model openrouter anthropic/claude-3-haiku:beta
orc config model openai gpt-4
# View configuration
orc config get
orc config get openrouter
# Show config file path
orc config pathorc cache
Manage intelligent caching system.
# Show cache statistics
orc cache stats
# Clear all cached data
orc cache clear
# Clean up expired entries
orc cache cleanuporc test
Test API connection for configured providers.
# Test default provider
orc test
# Test specific provider
orc test openrouter
orc test openaiโ๏ธ Configuration
Configuration is stored in ~/.config/orcommit.json with secure 600 permissions.
Default Configuration
{
"providers": {
"openrouter": {
"baseUrl": "https://openrouter.ai/api/v1",
"timeout": 60000
},
"openai": {
"baseUrl": "https://api.openai.com/v1",
"timeout": 60000
}
},
"preferences": {
"defaultProvider": "openrouter",
"maxTokens": 500,
"temperature": 0.6,
"autoConfirm": false,
"language": "en",
"commitFormat": "conventional"
}
}Supported Commit Types
When using --type option, these conventional commit types are supported:
feat- New featuresfix- Bug fixesdocs- Documentation changesstyle- Code style changes (formatting, etc.)refactor- Code refactoringtest- Adding or updating testschore- Maintenance tasksperf- Performance improvementsci- CI/CD changesbuild- Build system changesrevert- Reverting previous commits
๐ Architecture
The tool is built with a modular TypeScript architecture:
Core Modules
- CLI Module: Command-line interface using Commander.js with @clack/prompts
- Config Module: Secure configuration management with file permissions (600)
- Git Module: Advanced Git repository interaction with intelligent diff parsing
- API Module: Robust HTTP client with exponential backoff and concurrency control
- Logger Module: Elegant progress indicators with timing and structured output
- Tokenizer Module: Token-aware chunking using tiktoken for accurate processing
- Cache Module: Two-level caching (memory + disk) with TTL and cleanup
- Diff Filter Module: Smart filtering of generated files and irrelevant changes
- Core Orchestrator: Main coordination with phase-based processing
Key Features
- Token-Based Chunking: Uses tiktoken to respect actual model token limits
- Intelligent Caching: Memory + disk caching with automatic cleanup and TTL
- Smart Filtering: Automatically filters out generated files, lock files, and whitespace-only changes
- Interactive Push: Prompts user for push with automatic upstream configuration
- Elegant UI: Phase-based progress with emojis, timing, and structured output
- Robust Error Handling: Comprehensive error types with timeout protection
- Type Safety: Full TypeScript coverage with strict mode enabled
- Production Ready: Extensive test suite with unit and integration tests
๐ง Advanced Usage
Environment Variables
You can set API keys via environment variables:
export OPENROUTER_API_KEY="your-key-here"
export OPENAI_API_KEY="your-openai-key"Smart File Processing
The tool intelligently processes large codebases:
Token-Aware Chunking:
- Uses tiktoken for accurate token counting
- Respects model-specific token limits (GPT-4: 8K, Claude: 100K)
- Preserves context at logical boundaries (files, functions)
- Dynamic chunk sizing based on available tokens
Intelligent Filtering:
- Auto-detects and skips generated files (dist/, build/, .lock files)
- Filters out whitespace-only changes
- Relevancy scoring to focus on meaningful changes
- Configurable file size limits (default: 1MB per file)
Performance:
- Memory + disk caching for instant repeated requests
- Concurrent API processing (up to 3 parallel requests)
- Exponential backoff for rate limit handling
Custom Models
Configure specific models for each provider:
# ORCommit models
orc config model openrouter anthropic/claude-3-haiku:beta
orc config model openrouter openai/gpt-4-turbo-preview
# OpenAI models
orc config model openai gpt-4
orc config model openai gpt-3.5-turboInteractive Experience
Elegant Progress Display:
๐ Analyzing changes...
โ Found 15 staged files
โ Ready to analyze 12 files
๐ค Generating commit message...
โ Commit message generated (1.2s)
๐พ Creating commit...
โ Commit created
โ Commit: feat(ui): add interactive push prompts
Do you want to push to remote? โบ Yes
๐ Pushing to remote...
โ Pushed to main (2.1s)
โ Changes pushed successfullySmart Push Integration:
- Interactive prompts for push decisions
- Automatic upstream branch setup
- Support for multiple remotes
- Graceful handling of push failures
๐งช Development
Setup
git clone <repository>
cd orcommit
npm installAvailable Scripts
npm run build # Build TypeScript
npm run dev # Run in development mode
npm run test # Run tests
npm run test:watch # Run tests in watch mode
npm run lint # Run ESLint
npm run format # Format code with PrettierTesting
The project includes comprehensive tests:
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run specific test file
npm test -- utils.test.ts๐ Requirements
- Node.js >= 16.0.0
- Git repository
- ORCommit or OpenAI API key
๐ Security
- API keys are stored with 600 file permissions (owner read/write only)
- No API keys are logged or exposed in error messages
- Secure HTTP client with proper timeout and retry handling
๐ Troubleshooting
Common Issues
"Not in a git repository"
- Ensure you're running the command inside a Git repository
"No staged changes found"
- Use
git addto stage files before generating commits - Check if files are in .gitignore
"API key not configured"
- Set your API key:
orc config set openrouter your-key - Verify with:
orc config get
"All changes were filtered out"
- Check if only generated files were changed
- Try with
--ignore-generated=falseto include all files - Use
--verboseto see what was filtered
"Operation timed out"
- Large repositories may take time - operations auto-timeout at 30s
- Try with
--max-files 10to limit scope - Check your internet connection and API key validity
"Push failed"
- Ensure you have push permissions to the repository
- Check if upstream branch is configured:
git branch -vv - Try manual push first:
git push
Debug Mode
Use verbose logging for detailed information:
orc commit --verbose๐ License
MIT License - see LICENSE file for details.
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
๐ Support
- GitHub Issues: Report bugs or request features
- Documentation: Additional guides and examples
๐ Acknowledgments
- OpenRouter for providing access to multiple AI models
- OpenAI for their powerful language models
- The open-source community for the excellent tools and libraries used in this project
Built with โค๏ธ using TypeScript, Commander.js, and cutting-edge AI technology.