npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ai-commit-review

v1.0.4

Published

AI-powered commit and code analysis from the local Git repository

Readme

AI Commit Report

A command-line tool powered by AI for creating or analyzing Git commits and code directly from your local Git repository.

Table of Contents

Introduction

AI Commit Report is a robust tool that utilizes the OpenAI API to assist with creating commits and analyzing code changes in Git repositories. It delivers detailed insights into modifications, evaluates adherence to best practices, and offers suggestions for improving code quality. By enhancing development efficiency, this tool also supports AI-driven commit creation, simplifying and optimizing your Git workflow.

Installation

Global Installation

To install the tool globally on your system, use the following command:

npm install -g ai-commit-review

This method simplifies the installation, eliminating the need to clone the repository and manually install dependencies.

Update

To update the tool to the latest version, use the command:

npm update -g ai-commit-review

This ensures that you are using the latest features and bug fixes available.

Uninstallation

To uninstall the tool globally, use the command:

npm uninstall -g ai-commit-review

Getting Started

Before using the tool, you must set your OpenAI API key, the desired model, and the response language.

Set the API Key

Use the set_config command:

acr set_config OPENAI_API_KEY=sk-your-key

Set the OpenAI Model

Use the set_config command:

acr set_config OPENAI_API_MODEL=gpt-4

Available Models:

The tool currently integrates only with OpenAI’s ChatGPT models:

  • gpt-4o
  • gpt-4o-mini
  • gpt-4
  • gpt-4-turbo
  • gpt-3.5-turbo
  • o1-preview
  • o1-mini

Set the Response Language

Use the set_config command:

acr set_config OPENAI_RESPONSE_LANGUAGE=en-US

Available Languages:

  • EN_US: English (US)
  • EN_GB: English (UK)
  • ES: Spanish
  • ZH: Mandarin
  • HI: Hindi
  • AR: Arabic
  • FR: French
  • RU: Russian
  • PT_BR: Portuguese (Brazil)
  • PT_PT: Portuguese (Portugal)

Usage

Analyze Commits

To analyze commits, navigate to the repository directory and run:

acr analyze

The tool will list the last 5 commits and prompt you to select the commits to be analyzed. Follow the instructions displayed:

  • Controls: Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed.

Create a Commit

To create a new commit with AI assistance, use:

acr create

Workflow:

  1. Confirm or Switch Branch: Ensures you are on the correct branch before making changes.
  2. Pull: Pull the latest changes from the remote repository.
  3. Clear the Stage: Clears the staging area to start fresh.
  4. Check for Conflicts: Verifies there are no merge conflicts.
  5. Stage All Changes: Stages all modified files.
  6. Generate Commit Message:
    • AI Assistance: Generates a commit message based on the staged changes.
    • Manual Entry: Allows you to write your own commit message.
  7. Edit Commit Message: Opens your default editor to finalize the commit message.
  8. Push to Remote: Optionally pushes the commit to the remote repository.

Show Help

To display help and view all available commands:

acr help

Examples

  • Analyze Commits:

    acr analyze

    Follow the instructions to select commits for analysis.

  • Create a New Commit with AI Assistance:

    acr create

    Follow the interactive prompts to generate or write your commit message.

  • Set the OpenAI API Key:

    acr set_config OPENAI_API_KEY=your-key
  • Set the OpenAI Model:

    acr set_config OPENAI_API_MODEL=gpt-4o-mini
  • Set the Response Language:

    acr set_config OPENAI_RESPONSE_LANGUAGE=en-US
  • Update AI Commit Report:

    npm update -g ai-commit-review

    Updates the tool to the latest available version on npm.

Dependencies

  • Node.js (version 14 or higher)
  • npm

Contributing

Contributions are welcome! Feel free to open issues and pull requests in the repository.

How to Contribute

  1. Fork the Project.

  2. Create a New Branch:

    git checkout -b my-feature
  3. Make Your Changes.

  4. Commit Your Changes:

    git commit -m 'My new feature'
  5. Push to the Remote Branch:

    git push origin my-feature
  6. Open a Pull Request.

    Navigate to your fork on GitHub and click the "Compare & pull request" button to submit your changes for review.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Notes and Suggestions

  • Focused Analysis: The tool analyzes only the changes (diffs) made in the selected commits, making the process more efficient and targeted.
  • API Limitations: Be mindful of OpenAI API token limits. Analyzing only diffs helps avoid exceeding these limits.
  • Sensitive Configurations: Do not expose your API key in public or in files that will be committed.
  • Future Improvements:
    • Implement unit tests to ensure code quality.
    • Add support for additional OpenAI models as they become available.
    • Enhance error handling and user messages.
  • Support: If you encounter issues or have questions, open an issue on GitHub.

Additional Tips

  • Efficiency: Analyzing only the changes speeds up the process and reduces API resource consumption.
  • Focus on Changes: The analysis is more precise when focused on recent changes, helping to identify potential issues introduced.
  • Security: Ensure no sensitive information is included in diffs or logs.
  • Updates: Keep your dependencies up-to-date to benefit from improvements and security fixes.

Frequently Asked Questions (FAQs)

Q: Can I use this tool with AI models other than OpenAI's ChatGPT?
A: Currently, the tool supports only OpenAI’s ChatGPT models. Support for additional models may be added in future updates.


Q: What should I do if I encounter an error during installation?
A: Ensure you have the required dependencies installed and the appropriate permissions. Check error messages for specific details and consider opening an issue on GitHub if the problem persists.

Q: How do I protect my API key when using this tool?
A: Never share your API key publicly. Use environment variables and avoid committing keys to the repository. Consider using secret management tools for added security.

Q: What languages are available for analysis responses?
A: Responses can be configured in the following languages:

  • English (US) - en-US
  • English (UK) - en-GB
  • Spanish - es
  • Mandarin - zh
  • Hindi - hi
  • Arabic - ar
  • French - fr
  • Russian - ru
  • Portuguese (Brazil) - pt-BR
  • Portuguese (Portugal) - pt-PT