aiautocommit


Nameaiautocommit JSON
Version 0.7.0 PyPI version JSON
download
home_pageNone
SummaryAI generated commit messages
upload_time2024-11-15 16:06:31
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords git commit automation ai openai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Release Notes](https://img.shields.io/github/release/iloveitaly/aiautocommit)](https://github.com/iloveitaly/aiautocommit/releases) [![Downloads](https://static.pepy.tech/badge/aiautocommit/month)](https://pepy.tech/project/aiautocommit) [![Python Versions](https://img.shields.io/pypi/pyversions/aiautocommit)](https://pypi.org/project/aiautocommit) ![GitHub CI Status](https://github.com/iloveitaly/aiautocommit/actions/workflows/build_and_publish.yml/badge.svg) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

# aiautocommit

Generate intelligent commit messages using AI. aiautocommit analyzes your staged changes and creates conventional commit messages, handling both small tweaks and large changesets effectively.

Yes, there are a lot of these. Main ways this is different:

* Simple codebase
* Ability to easily customize prompts on a per-repo basis

## Installation

```shell
pip install aiautocommit
```

## Features

* Generates conventional commit messages
* Customizable prompts and exclusions
* Pre-commit hook integration
* Supports custom config directories

## Getting Started

Set your OpenAI API key:

```
export OPENAI_API_KEY=<YOUR API KEY>
```

Stage your changes and run aiautocommit:

```
git add .
# this will generate a commit message and commit the changes
aiautocommit commit

# or, just to see what it will do
aiautocommit commit --print-message
```

## Customization

### Logging

First, you'll want to enable logging so you can extract the diff and prompt and iterate on it in ChatGPT:

```shell
export AIAUTOCOMMIT_LOG_LEVEL=DEBUG
export AIAUTOCOMMIT_LOG_FILE=aiautocommit.log
```

Now, you'll have a nice log you can tail and fiddle with from there.

### Using Config Directory

aiautocommit looks for configuration files in these locations (in priority order):

* .aiautocommit/ in current directory
* $XDG_CONFIG_HOME/aiautocommit/ (defaults to ~/.config/aiautocommit/)
* Custom path via aiautocommit_CONFIG environment variable

To get started with customization:

```shell
aiautocommit dump-prompts
```

This creates a `.aiautocommit/` directory with:

* `diff_prompt.txt`: Template for generating diff summaries
* `commit_prompt.txt`: Template for generating commit messages
* `exclusions.txt`: List of files to exclude from processing
* `commit_suffix.txt`: Static suffix to append to commit messages. Useful for trailers.

### Installing Pre-commit Hook

To automatically generate commit messages during git commits:

```
aiautocommit install-pre-commit
```

[Learn more about git hooks here.](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks)


#### Lefthook Configuration

Lefthook is an excellent tool for managing git hooks. To use aiautocommit with lefthook, add the following to your `.lefthook.yml`:

```yaml
prepare-commit-msg:
  commands:
    aiautocommit:
      run: aiautocommit commit --output-file "{1}"
      interactive: true
      env:
        # without this, lefthook will run in an infinite loop
        LEFTHOOK: 0
        # ensures that LOG_LEVEL config of the current project does not interfere with aiautocommit
        LOG_LEVEL: info
        OPENAI_LOG: warn
      skip:
        merge:
        rebase:
        # only run this if the tool exists
        run: ! which aiautocommit > /dev/null
```

### Environment Variables

* `OPENAI_API_KEY`: Your OpenAI API key
* `AIAUTOCOMMIT_OPENAI_API_KEY`: Unique API key for OpenAI, overrides `OPENAI_API_KEY` (useful for tracking or costing purposes)
* `AIAUTOCOMMIT_MODEL`: AI model to use (default: gpt-4-mini)
* `AIAUTOCOMMIT_CONFIG`: Custom config directory path
* `LOG_LEVEL`: Logging verbosity
* `AIAUTOCOMMIT_LOG_PATH`: Custom log file path

## Privacy Disclaimer

`gpt-commit` uses the [OpenAI API](https://platform.openai.com/docs) to generate commit messages. Both file names and contents from files that contain staged changes will be shared with OpenAI when using `gpt-commit`. OpenAI will process this data according to their [terms of use](https://openai.com/policies/terms-of-use) and [API data usage policies](https://openai.com/policies/api-data-usage-policies). On March 1st 2023 OpenAI pledged that by default, they would not use data submitted by customers via their API to train or improve their models, and that this data will be retained for a maximum of 30 days, after which it will be deleted.

## Special Thanks

[This project](https://github.com/markuswt/gpt-commit) inspired this project. It had a very simple codebase. I've taken the idea and expanded it to include a lot more features, specifically per-project prompt customization.

## Related Projects

I looked at a bunch of projects before building this one.

- https://github.com/abi/aiautocommit - python, inactive. Many files, not simple.
- https://github.com/Sett17/turboCommit - rust, inactive.
- https://github.com/Nutlope/aicommits - typescript. Node is so slow and I hate working with it.
- https://github.com/Elhameed/aicommits - python
- https://github.com/zurawiki/gptcommit - active, rust. Too complicated and no prompt customization.
- https://github.com/ywkim/gpt-commit - lisp, inactive.
- https://github.com/markuswt/gpt-commit - single file, python based. No commits > 1yr. Very simple codebase.
- https://github.com/josenerydev/gpt-commit - also python
- https://github.com/di-sukharev/opencommit - has conventional commit structure

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "aiautocommit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "git, commit, automation, ai, openai",
    "author": null,
    "author_email": "Michael Bianco <mike@mikebian.co>",
    "download_url": "https://files.pythonhosted.org/packages/92/5b/a7afa8c8adf178c702fda1af08af8fa83efe7f17998057856f62f694c374/aiautocommit-0.7.0.tar.gz",
    "platform": null,
    "description": "[![Release Notes](https://img.shields.io/github/release/iloveitaly/aiautocommit)](https://github.com/iloveitaly/aiautocommit/releases) [![Downloads](https://static.pepy.tech/badge/aiautocommit/month)](https://pepy.tech/project/aiautocommit) [![Python Versions](https://img.shields.io/pypi/pyversions/aiautocommit)](https://pypi.org/project/aiautocommit) ![GitHub CI Status](https://github.com/iloveitaly/aiautocommit/actions/workflows/build_and_publish.yml/badge.svg) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n# aiautocommit\n\nGenerate intelligent commit messages using AI. aiautocommit analyzes your staged changes and creates conventional commit messages, handling both small tweaks and large changesets effectively.\n\nYes, there are a lot of these. Main ways this is different:\n\n* Simple codebase\n* Ability to easily customize prompts on a per-repo basis\n\n## Installation\n\n```shell\npip install aiautocommit\n```\n\n## Features\n\n* Generates conventional commit messages\n* Customizable prompts and exclusions\n* Pre-commit hook integration\n* Supports custom config directories\n\n## Getting Started\n\nSet your OpenAI API key:\n\n```\nexport OPENAI_API_KEY=<YOUR API KEY>\n```\n\nStage your changes and run aiautocommit:\n\n```\ngit add .\n# this will generate a commit message and commit the changes\naiautocommit commit\n\n# or, just to see what it will do\naiautocommit commit --print-message\n```\n\n## Customization\n\n### Logging\n\nFirst, you'll want to enable logging so you can extract the diff and prompt and iterate on it in ChatGPT:\n\n```shell\nexport AIAUTOCOMMIT_LOG_LEVEL=DEBUG\nexport AIAUTOCOMMIT_LOG_FILE=aiautocommit.log\n```\n\nNow, you'll have a nice log you can tail and fiddle with from there.\n\n### Using Config Directory\n\naiautocommit looks for configuration files in these locations (in priority order):\n\n* .aiautocommit/ in current directory\n* $XDG_CONFIG_HOME/aiautocommit/ (defaults to ~/.config/aiautocommit/)\n* Custom path via aiautocommit_CONFIG environment variable\n\nTo get started with customization:\n\n```shell\naiautocommit dump-prompts\n```\n\nThis creates a `.aiautocommit/` directory with:\n\n* `diff_prompt.txt`: Template for generating diff summaries\n* `commit_prompt.txt`: Template for generating commit messages\n* `exclusions.txt`: List of files to exclude from processing\n* `commit_suffix.txt`: Static suffix to append to commit messages. Useful for trailers.\n\n### Installing Pre-commit Hook\n\nTo automatically generate commit messages during git commits:\n\n```\naiautocommit install-pre-commit\n```\n\n[Learn more about git hooks here.](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks)\n\n\n#### Lefthook Configuration\n\nLefthook is an excellent tool for managing git hooks. To use aiautocommit with lefthook, add the following to your `.lefthook.yml`:\n\n```yaml\nprepare-commit-msg:\n  commands:\n    aiautocommit:\n      run: aiautocommit commit --output-file \"{1}\"\n      interactive: true\n      env:\n        # without this, lefthook will run in an infinite loop\n        LEFTHOOK: 0\n        # ensures that LOG_LEVEL config of the current project does not interfere with aiautocommit\n        LOG_LEVEL: info\n        OPENAI_LOG: warn\n      skip:\n        merge:\n        rebase:\n        # only run this if the tool exists\n        run: ! which aiautocommit > /dev/null\n```\n\n### Environment Variables\n\n* `OPENAI_API_KEY`: Your OpenAI API key\n* `AIAUTOCOMMIT_OPENAI_API_KEY`: Unique API key for OpenAI, overrides `OPENAI_API_KEY` (useful for tracking or costing purposes)\n* `AIAUTOCOMMIT_MODEL`: AI model to use (default: gpt-4-mini)\n* `AIAUTOCOMMIT_CONFIG`: Custom config directory path\n* `LOG_LEVEL`: Logging verbosity\n* `AIAUTOCOMMIT_LOG_PATH`: Custom log file path\n\n## Privacy Disclaimer\n\n`gpt-commit` uses the [OpenAI API](https://platform.openai.com/docs) to generate commit messages. Both file names and contents from files that contain staged changes will be shared with OpenAI when using `gpt-commit`. OpenAI will process this data according to their [terms of use](https://openai.com/policies/terms-of-use) and [API data usage policies](https://openai.com/policies/api-data-usage-policies). On March 1st 2023 OpenAI pledged that by default, they would not use data submitted by customers via their API to train or improve their models, and that this data will be retained for a maximum of 30 days, after which it will be deleted.\n\n## Special Thanks\n\n[This project](https://github.com/markuswt/gpt-commit) inspired this project. It had a very simple codebase. I've taken the idea and expanded it to include a lot more features, specifically per-project prompt customization.\n\n## Related Projects\n\nI looked at a bunch of projects before building this one.\n\n- https://github.com/abi/aiautocommit - python, inactive. Many files, not simple.\n- https://github.com/Sett17/turboCommit - rust, inactive.\n- https://github.com/Nutlope/aicommits - typescript. Node is so slow and I hate working with it.\n- https://github.com/Elhameed/aicommits - python\n- https://github.com/zurawiki/gptcommit - active, rust. Too complicated and no prompt customization.\n- https://github.com/ywkim/gpt-commit - lisp, inactive.\n- https://github.com/markuswt/gpt-commit - single file, python based. No commits > 1yr. Very simple codebase.\n- https://github.com/josenerydev/gpt-commit - also python\n- https://github.com/di-sukharev/opencommit - has conventional commit structure\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "AI generated commit messages",
    "version": "0.7.0",
    "project_urls": {
        "Repository": "https://github.com/iloveitaly/aiautocommit"
    },
    "split_keywords": [
        "git",
        " commit",
        " automation",
        " ai",
        " openai"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "01d34eff9183083257eae12eea140b360beb49abbcbc468922bccc9e47c2eae4",
                "md5": "a8c03f01b4889dd2715e82e08402b58d",
                "sha256": "d26b0334112fd48d6fa1f66f96efb8b10b892804a94e3ab285975c1ab0b6edbc"
            },
            "downloads": -1,
            "filename": "aiautocommit-0.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a8c03f01b4889dd2715e82e08402b58d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 9730,
            "upload_time": "2024-11-15T16:06:30",
            "upload_time_iso_8601": "2024-11-15T16:06:30.082419Z",
            "url": "https://files.pythonhosted.org/packages/01/d3/4eff9183083257eae12eea140b360beb49abbcbc468922bccc9e47c2eae4/aiautocommit-0.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "925ba7afa8c8adf178c702fda1af08af8fa83efe7f17998057856f62f694c374",
                "md5": "26218b41c531b2895ede345a403f0f98",
                "sha256": "d9848ce60fa95dcf25c1bd6d2a099d9b9279849e8b555c4c27d8f307ba49678f"
            },
            "downloads": -1,
            "filename": "aiautocommit-0.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "26218b41c531b2895ede345a403f0f98",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 9330,
            "upload_time": "2024-11-15T16:06:31",
            "upload_time_iso_8601": "2024-11-15T16:06:31.399080Z",
            "url": "https://files.pythonhosted.org/packages/92/5b/a7afa8c8adf178c702fda1af08af8fa83efe7f17998057856f62f694c374/aiautocommit-0.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-15 16:06:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "iloveitaly",
    "github_project": "aiautocommit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aiautocommit"
}
        
Elapsed time: 0.44431s