The commit-ai
is a command-line interface tool designed for generating semantic commit using AI. It leverages the power of Google's Gemini AI model to analyze and suggest commit messages based on code differences pulled from Git repositories.
- Commit: Analyze and suggest commit messages with AI.
- Add API Key: Configure your Gemini API key for authentication.
- Easy Setup: Simple commands to manage your API key and perform code reviews.
-
Clone the Repository
git clone https://github.com/vieiraeduardos/commit-ai.git cd commit-ai
-
Install Dependencies Ensure you have Node.js installed. Then, install the required packages:
npm install
-
Build Compile TypeScript code to JavaScript:
npm run build
To use the Gemini AI model, you need to set up your API key. Follow these steps to add your API key:
-
Obtain a Gemini API Key
- Go to the Google Cloud Console.
- Navigate to the APIs & Services section.
- Select Credentials from the menu.
- Click on Create Credentials and choose API Key.
- Copy the generated API key.
-
Add the API Key to Your Project
Use the
add-key
command to save the API key:npm run start add-key "your-gemini-api-key"
This command saves the API key in a .env file. Make sure to replace "your-gemini-api-key" with your actual API key.
To generate semantic commit using the AI model, use the commit command:
npm run start commit
This command retrieves the code diff from the current Git repository and sends it to the Gemini AI model for analysis. Ensure that your API key is set before running this command.
add-key <apiKey>
: Add your Gemini API key. Replace with your actual API key.commit
: Generate semantic commit based code diff in the current Git repository.
The .env file is used to store the API key. The file will be automatically created or updated when you run the add-key command. Ensure this file is included in your .gitignore to keep your API key secure.
- Error: API key is not set: Ensure that you have added the API key using the add-key command and that the .env file is in the project root.
- Command not found: Ensure you have built the project using npm run build and that you're running the command from the correct directory.
Contributions are welcome! Please submit a pull request or open an issue if you find bugs or have feature requests.
This project is licensed under the MIT License.
If you find this project useful and would like to support its development, consider making a donation via Pix. Your support helps cover development costs and keep the project active.
Pix: 98992073959
Thank you for your support! 👍