AiCommitMessage 0.12.5

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global AiCommitMessage --version 0.12.5                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local AiCommitMessage --version 0.12.5                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=AiCommitMessage&version=0.12.5                
nuke :add-package AiCommitMessage --version 0.12.5                

GIT Hooks + OpenAI - Generate GIT commit messages from OpenAI

🧠 🤖 This tool generates AI-powered commit messages via Git hooks, automating meaningful message suggestions from OpenAI and others to improve commit quality and efficiency.

GitHub last commit GitHub license time tracker

Build Continuous Integration Infisical secrets check Linter check


What this tool does

Generates a commit message based on the git diff result using the OpenAI API.


Requirements


Getting started

AICommitMessage NuGet Version AICommitMessage NuGet Downloads

This repository is available at NuGet under the name AICommitMessage.

Installation

  1. Install the tool globally (or per project/repository).
  2. Move to the project folder.
  3. Install the Git hook on the default hooks directory.
dotnet tool install -g AiCommitMessage
cd my-project/
dotnet-aicommitmessage install-hook
git add .
git commit -m ""

Use git log -1 to review the last commit details and find the automatically generated commit message.


Model Configuration and Settings

To configure and use models with dotnet-aicommitmessage, users need to set their settings once. This setup involves specifying the model, API key, and API URL. These settings will be stored as environment variables for future use.

Initial Setup

Run the following commands to configure the model and related settings:

dotnet-aicommitmessage set-settings -m gpt-4o-mini -k {api-key} -u {api-url}
dotnet-aicommitmessage set-settings -m llama-3-1-405b-instruct -k {api-key} -u {api-url}

Replace {api-key} with your API key and {api-url} with the URL of your API provider.

Switching Models

After the initial setup, you can easily switch between models without needing to provide the API key or URL again:

dotnet-aicommitmessage set-settings -m gpt-4o-mini
dotnet-aicommitmessage set-settings -m llama-3-1-405b-instruct

This allows for quick model changes while retaining your previously configured API details.


Supported Models

Currently supported models are gpt-4o-mini and llama-3-1-405b-instruct.


Commit message pattern

The training model for the AI used is designed using as reference these guidelines:


Sequence of Execution

Here’s a flow diagram showing the sequence of execution of the prepare-commit-msg hook and its integration with dotnet-aicommitmessage to generate commit messages using the OpenAI API:

graph TD
    A[Git Commit] --> B[prepare-commit-msg Hook Trigger]
    B --> C[Invoke dotnet-aicommitmessage Tool]
    C --> D[Send Data to OpenAI API]
    D --> E[Generate Commit Message]
    E --> F[Check and append pre-defined commands to Commit Message]
    F --> G[Return Generated Commit Message]
    G --> H[Insert Commit Message into Git Commit]
    H --> I[Finalize Commit]

Commands

This tool accepts an argument as the command to execute. Here is a list of available commands:

Command Description
install-hook Installs GIT hooks in the default .git/hooks directory or in the custom directory configured in GIT settings.
generate-message Generates a commit message based on the current changes (git diff context).
set-settings Set the OpenAI settings.
help Display information about this program.
version Display version information.

Example output

Here is an example of the commit messages generated in a real-world project:

example

Debug

You can run the message generation manually to debug it, but it will not commit the content to your GIT repository. If you also want to check the OpenAI JSON response, append the -D parameter.

Manually generating the commit message

To manually generate a commit message without committing the staged changes, run the following command:

dotnet-aicommitmessage generate-message -m "."

Saving the OpenAI JSON response

If you want to persist the OpenAI JSON response, add the -D parameter, and a debug.json file will be created with the response JSON.

dotnet-aicommitmessage generate-message -Dm "."

Here is a sample debug.json content:

{
  "Value": {
    "CreatedAt": "2024-11-20T12:54:03+00:00",
    "FinishReason": 0,
    "ContentTokenLogProbabilities": [],
    "RefusalTokenLogProbabilities": [],
    "Role": 2,
    "Content": [
      {
        "Kind": 0,
        "Text": "feat - add reactivation handling for refunds due today",
        "ImageUri": null,
        "ImageBytes": null,
        "ImageBytesMediaType": null,
        "ImageDetailLevel": null,
        "Refusal": null
      }
    ],
    "ToolCalls": [],
    "Refusal": null,
    "FunctionCall": null,
    "Id": "chatcmpl-[[REDACTED]]",
    "Model": "gpt-4o-mini-2024-07-18",
    "SystemFingerprint": "fp-[[REDACTED]]",
    "Usage": {
      "OutputTokenCount": 10,
      "InputTokenCount": 6229,
      "TotalTokenCount": 6239,
      "OutputTokenDetails": {
        "ReasoningTokenCount": 0
      }
    }
  }
}

Contributors

<table> <tbody> <tr> <td align="center"> <a href="https://github.com/guibranco"> <img src="https://avatars.githubusercontent.com/u/3362854?v=4" width="100;" alt="guibranco"/> <br /> <sub><b>Guilherme Branco Stracini</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Malay-dev"> <img src="https://avatars.githubusercontent.com/u/91375797?v=4" width="100;" alt="Malay-dev"/> <br /> <sub><b>Malay Kumar</b></sub> </a> </td> <td align="center"> <a href="https://github.com/RyanFloresTT"> <img src="https://avatars.githubusercontent.com/u/53247675?v=4" width="100;" alt="RyanFloresTT"/> <br /> <sub><b>Ryan Flores</b></sub> </a> </td> </tr> <tbody> </table>

Bots

<table> <tbody> <tr> <td align="center"> <a href="https://github.com/dependabot[bot]"> <img src="https://avatars.githubusercontent.com/in/29110?v=4" width="100;" alt="dependabot[bot]"/> <br /> <sub><b>dependabot[bot]</b></sub> </a> </td> <td align="center"> <a href="https://github.com/penify-dev[bot]"> <img src="https://avatars.githubusercontent.com/in/399279?v=4" width="100;" alt="penify-dev[bot]"/> <br /> <sub><b>penify-dev[bot]</b></sub> </a> </td> <td align="center"> <a href="https://github.com/gitauto-ai[bot]"> <img src="https://avatars.githubusercontent.com/in/844909?v=4" width="100;" alt="gitauto-ai[bot]"/> <br /> <sub><b>gitauto-ai[bot]</b></sub> </a> </td> <td align="center"> <a href="https://github.com/snyk-bot"> <img src="https://avatars.githubusercontent.com/u/19733683?v=4" width="100;" alt="snyk-bot"/> <br /> <sub><b>Snyk bot</b></sub> </a> </td> <td align="center"> <a href="https://github.com/codefactor-io"> <img src="https://avatars.githubusercontent.com/u/11671095?v=4" width="100;" alt="codefactor-io"/> <br /> <sub><b>CodeFactor</b></sub> </a> </td> </tr> <tbody> </table>

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
0.12.6 42 12/25/2024
0.12.5 36 12/25/2024
0.12.4 36 12/25/2024
0.12.3 63 12/23/2024
0.12.2 66 12/23/2024
0.12.1 81 12/16/2024
0.12.0 104 12/12/2024
0.11.12 79 12/9/2024
0.11.11 80 12/9/2024
0.11.10 78 12/3/2024
0.11.9 74 12/3/2024
0.11.8 74 12/2/2024
0.11.7 83 12/2/2024
0.11.6 87 12/2/2024
0.11.5 77 12/2/2024
0.11.4 85 11/26/2024
0.11.3 80 11/26/2024
0.11.2 78 11/26/2024
0.11.1 85 11/25/2024
0.11.0 79 11/23/2024
0.10.2 86 11/23/2024
0.10.1 77 11/23/2024
0.10.0 98 11/20/2024
0.9.1 92 11/20/2024
0.9.0 82 11/20/2024
0.8.8 87 11/18/2024
0.8.7 82 11/18/2024
0.8.6 83 11/15/2024
0.8.5 79 11/15/2024
0.8.4 91 11/12/2024
0.8.3 97 11/11/2024
0.8.2 95 11/11/2024
0.8.1 85 11/4/2024
0.8.0 95 11/1/2024
0.7.9 86 11/1/2024
0.7.8 86 11/1/2024
0.7.7 82 11/1/2024
0.7.6 86 11/1/2024
0.7.5 95 11/1/2024
0.7.4 86 10/28/2024
0.7.3 92 10/28/2024
0.7.2 84 10/28/2024
0.7.1 85 10/27/2024
0.7.0 86 10/26/2024
0.6.1 86 10/26/2024
0.6.0 85 10/22/2024
0.5.1 80 10/22/2024
0.5.0 77 10/22/2024
0.4.23 88 10/22/2024
0.4.22 81 10/22/2024
0.4.21 100 10/21/2024
0.4.20 168 10/19/2024
0.4.19 113 10/19/2024
0.4.18 116 10/19/2024
0.4.17 115 10/19/2024
0.4.16 110 10/19/2024
0.4.15 116 10/19/2024
0.4.14 127 10/19/2024
0.4.13 126 10/19/2024
0.4.12 125 10/19/2024
0.4.11 126 10/19/2024
0.4.10 123 10/19/2024
0.4.9 90 10/14/2024
0.4.8 90 10/14/2024
0.4.7 116 10/14/2024
0.4.6 101 10/8/2024
0.4.5 89 10/8/2024
0.4.4 93 10/8/2024
0.4.3 91 10/8/2024
0.4.2 91 10/8/2024
0.4.1 88 10/8/2024
0.4.0 93 10/8/2024
0.3.11 94 10/8/2024
0.3.10 129 10/8/2024
0.3.9 95 10/8/2024
0.3.8 101 10/8/2024
0.3.7 97 10/8/2024
0.3.6 92 10/8/2024
0.3.5 89 10/7/2024
0.3.4 91 10/7/2024
0.3.3 128 9/30/2024
0.3.2 100 9/30/2024
0.3.1 98 9/25/2024
0.3.0 87 9/25/2024
0.2.7 98 9/23/2024
0.2.6 98 9/23/2024
0.2.5 98 9/23/2024
0.2.4 96 9/23/2024
0.2.3 95 9/23/2024
0.2.2 135 9/23/2024
0.2.1 91 9/21/2024
0.2.0 98 9/20/2024
0.1.29 93 9/20/2024
0.1.28 87 9/20/2024
0.1.27 90 9/20/2024
0.1.26 95 9/20/2024
0.1.25 97 9/20/2024
0.1.24 104 9/20/2024
0.1.23 115 9/17/2024
0.1.22 107 9/17/2024
0.1.21 101 9/17/2024
0.1.20 103 9/17/2024
0.1.19 109 9/17/2024
0.1.18 103 9/17/2024
0.1.17 109 9/17/2024
0.1.16 106 9/16/2024
0.1.15 159 9/16/2024
0.1.14 101 9/16/2024
0.1.12 103 9/16/2024
0.1.11 104 9/16/2024