1.0.7 • Published 4 months ago
git-ai-tool v1.0.7
git-ai-tool
A CLI tool to automate git commit and push using a React Terminal interface.
Features
- 🤖 AI-Powered Commit Messages: Generates semantic commit messages using OpenAI
- 🖥️ Interactive UI: Beautiful terminal interface built with React Ink
- 🔍 Smart Change Detection: Automatically detects staged and unstaged changes
- 🔄 Streamlined Workflow: Guides you through the commit and push process
- 🔗 PR Integration: Provides pull request URLs after pushing
- 📊 Operation Summary: Shows a summary of all actions taken
Installation
# Install globally
npm install -g git-ai-tool
# Set required environment variables
export OPENAI_API_KEY="your-openai-api-key"
export GITHUB_TOKEN="your-github-token" # Optional, for PR detection
Usage
Navigate to any Git repository and run:
git-ai-tool commit
The interactive terminal UI will guide you through:
- Reviewing staged and unstaged changes
- Staging changes if needed
- Generating and confirming a commit message
- Pushing changes to remote
- Providing a PR URL if applicable
Requirements
- Node.js 16.0.0 or higher
- Git installed and configured
- OpenAI API key for commit message generation
- GitHub token (optional) for PR detection
Environment Variables
Variable | Required | Description |
---|---|---|
OPENAI_API_KEY | Yes | Your OpenAI API key for generating commit messages |
GITHUB_TOKEN | No | GitHub token for detecting existing PRs |
You can set these in your shell profile or use a tool like direnv
to manage them per project.
Development
Clone the repository and install dependencies:
git clone https://github.com/yourusername/git-ai-tool.git
cd git-ai-tool
npm install
Run in development mode:
npm run dev
Build the project:
npm run build
How It Works
- Repository Check: Verifies you're in a valid Git repository
- Change Detection: Identifies staged and unstaged changes
- AI Generation: Uses OpenAI to create a semantic commit message
- Commit Process: Commits changes with the generated message
- Push Handling: Pushes to remote and checks for PR opportunities
- Summary: Provides a summary of all actions taken
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Ink - React for CLIs
- OpenAI - AI-powered commit message generation
- Commander.js - Command-line interface
Made with ❤️ by Sam