git-ai-tool
v1.0.9
Published
A CLI tool to automate git commit and push using React Terminal
Readme
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 or Ollama
- 🖥️ 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 for OpenAI
export OPENAI_API_KEY="your-openai-api-key"
export GITHUB_TOKEN="your-github-token" # Optional, for PR detectionUsage
Navigate to any Git repository and run:
git-ai-tool commitBy default, the tool uses OpenAI. To use Ollama instead:
git-ai-tool commit --provider ollamaThe 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
Command Line Options
Options:
-V, --version output the version number
-p, --provider <provider> AI provider to use (openai or ollama) (default: "openai")
--openai-api-key <key> OpenAI API key
--openai-model <model> OpenAI model to use (default: "gpt-3.5-turbo")
--ollama-host <host> Ollama host URL (default: "http://127.0.0.1:11434")
--ollama-model <model> Ollama model to use (default: "llama3.1")
-h, --help display help for commandRequirements
- Node.js 16.0.0 or higher
- Git installed and configured
- OpenAI API key (if using OpenAI provider)
- Ollama running locally or remotely (if using Ollama provider)
- GitHub token (optional) for PR detection
Environment Variables
| Variable | Required | Description |
| ---------------- | ---------- | -------------------------------------------------- |
| OPENAI_API_KEY | For OpenAI | 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.
Using Ollama
To use Ollama instead of OpenAI:
- Make sure you have Ollama installed and running
- Run the tool with the
--provider ollamaflag - Optionally specify a different model with
--ollama-model <model>(default is llama3.1) - Optionally specify a different host with
--ollama-host <host>(default is http://127.0.0.1:11434)
Example:
git-ai-tool commit --provider ollama --ollama-model codellamaDevelopment
Clone the repository and install dependencies:
git clone https://github.com/yourusername/git-ai-tool.git
cd git-ai-tool
npm installRun in development mode:
npm run devBuild the project:
npm run buildHow It Works
- Repository Check: Verifies you're in a valid Git repository
- Change Detection: Identifies staged and unstaged changes
- AI Generation: Uses OpenAI or Ollama 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
- Ollama - Local AI models
- Commander.js - Command-line interface
Made with ❤️ by [Your Name]
This README provides:
1. A clear description of what the tool does
2. Installation and usage instructions
3. Required environment variables
4. Development setup
5. How the tool works
6. Contributing guidelines
7. License information
8. Acknowledgments
You should replace the placeholder image URL with an actual screenshot or GIF of your tool in action once you have one, and update the GitHub repository URL and your name in the appropriate places.