{"id":13433639,"url":"https://github.com/di-sukharev/opencommit","last_synced_at":"2025-05-14T07:07:46.796Z","repository":{"id":117355241,"uuid":"610217037","full_name":"di-sukharev/opencommit","owner":"di-sukharev","description":"GPT wrapper for git — generate commit messages with an LLM in 1 sec — works best with Claude 3.5 — supports local models too","archived":false,"fork":false,"pushed_at":"2025-05-03T09:06:21.000Z","size":10843,"stargazers_count":6618,"open_issues_count":162,"forks_count":355,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-05-07T06:38:33.788Z","etag":null,"topics":["ai","ai-commit","ai-commits","artificial-intelligence","chatgpt","git","gpt","productivity"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/opencommit","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/di-sukharev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-06T10:30:51.000Z","updated_at":"2025-05-07T06:18:47.000Z","dependencies_parsed_at":"2023-11-27T05:24:12.563Z","dependency_job_id":"81fc4b7a-22b2-4aa8-8302-eeae8ef2d3b8","html_url":"https://github.com/di-sukharev/opencommit","commit_stats":{"total_commits":435,"total_committers":72,"mean_commits":6.041666666666667,"dds":"0.27356321839080455","last_synced_commit":"25105e4c3a8e04e08235349912ff29681dba1e9c"},"previous_names":[],"tags_count":164,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/di-sukharev%2Fopencommit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/di-sukharev%2Fopencommit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/di-sukharev%2Fopencommit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/di-sukharev%2Fopencommit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/di-sukharev","download_url":"https://codeload.github.com/di-sukharev/opencommit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092648,"owners_count":22013290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ai-commit","ai-commits","artificial-intelligence","chatgpt","git","gpt","productivity"],"created_at":"2024-07-31T02:01:31.597Z","updated_at":"2025-05-14T07:07:46.770Z","avatar_url":"https://github.com/di-sukharev.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cdiv\u003e\n    \u003cimg src=\".github/logo-grad.svg\" alt=\"OpenCommit logo\"/\u003e\n    \u003ch1 align=\"center\"\u003eOpenCommit\u003c/h1\u003e\n    \u003ch4 align=\"center\"\u003eAuthor \u003ca href=\"https://twitter.com/_sukharev_\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/_sukharev_?style=flat\u0026label=_sukharev_\u0026logo=twitter\u0026color=0bf\u0026logoColor=fff\" align=\"center\"\u003e\u003c/a\u003e\n  \u003c/div\u003e\n\t\u003ch2\u003eAuto-generate meaningful commits in a second\u003c/h2\u003e\n\t\u003cp\u003eKilling lame commits with AI 🤯🔫\u003c/p\u003e\n\t\u003ca href=\"https://www.npmjs.com/package/opencommit\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/opencommit\" alt=\"Current version\"\u003e\u003c/a\u003e\n  \u003ch4 align=\"center\"\u003e🪩 Winner of \u003ca href=\"https://twitter.com/_sukharev_/status/1683448136973582336\"\u003eGitHub 2023 hackathon\u003c/a\u003e 🪩\u003c/h4\u003e\n\u003c/div\u003e\n\n---\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".github/opencommit-example.png\" alt=\"OpenCommit example\"/\u003e\n\u003c/div\u003e\n\nAll the commits in this repo are authored by OpenCommit — look at [the commits](https://github.com/di-sukharev/opencommit/commit/eae7618d575ee8d2e9fff5de56da79d40c4bc5fc) to see how OpenCommit works. Emojis and long commit descriptions are configurable, basically everything is.\n\n## Setup OpenCommit as a CLI tool\n\nYou can use OpenCommit by simply running it via the CLI like this `oco`. 2 seconds and your staged changes are committed with a meaningful message.\n\n1. Install OpenCommit globally to use in any repository:\n\n   ```sh\n   npm install -g opencommit\n   ```\n\n2. Get your API key from [OpenAI](https://platform.openai.com/account/api-keys) or other supported LLM providers (we support them all). Make sure that you add your OpenAI payment details to your account, so the API works.\n\n3. Set the key to OpenCommit config:\n\n   ```sh\n   oco config set OCO_API_KEY=\u003cyour_api_key\u003e\n   ```\n\n   Your API key is stored locally in the `~/.opencommit` config file.\n\n## Usage\n\nYou can call OpenCommit with `oco` command to generate a commit message for your staged changes:\n\n```sh\ngit add \u003cfiles...\u003e\noco\n```\n\nRunning `git add` is optional, `oco` will do it for you.\n\n### Running locally with Ollama\n\nYou can also run it with local model through ollama:\n\n- install and start ollama\n- run `ollama run mistral` (do this only once, to pull model)\n- run (in your project directory):\n\n```sh\ngit add \u003cfiles...\u003e\noco config set OCO_AI_PROVIDER='ollama' OCO_MODEL='llama3:8b'\n```\n\nDefault model is `mistral`.\n\nIf you have ollama that is set up in docker/ on another machine with GPUs (not locally), you can change the default endpoint url.\n\nYou can do so by setting the `OCO_API_URL` environment variable as follows:\n\n```sh\noco config set OCO_API_URL='http://192.168.1.10:11434/api/chat'\n```\n\nwhere 192.168.1.10 is example of endpoint URL, where you have ollama set up.\n\n### Flags\n\nThere are multiple optional flags that can be used with the `oco` command:\n\n#### Use Full GitMoji Specification\n\nLink to the GitMoji specification: https://gitmoji.dev/\n\nThis flag can only be used if the `OCO_EMOJI` configuration item is set to `true`. This flag allows users to use all emojis in the GitMoji specification, By default, the GitMoji full specification is set to `false`, which only includes 10 emojis (🐛✨📝🚀✅♻️⬆️🔧🌐💡).\n\nThis is due to limit the number of tokens sent in each request. However, if you would like to use the full GitMoji specification, you can use the `--fgm` flag.\n\n```\noco --fgm\n```\n\n#### Skip Commit Confirmation\n\nThis flag allows users to automatically commit the changes without having to manually confirm the commit message. This is useful for users who want to streamline the commit process and avoid additional steps. To use this flag, you can run the following command:\n\n```\noco --yes\n```\n\n## Configuration\n\n### Local per repo configuration\n\nCreate a `.env` file and add OpenCommit config variables there like this:\n\n```env\n...\nOCO_AI_PROVIDER=\u003copenai (default), anthropic, azure, ollama, gemini, flowise, deepseek\u003e\nOCO_API_KEY=\u003cyour OpenAI API token\u003e // or other LLM provider API token\nOCO_API_URL=\u003cmay be used to set proxy path to OpenAI api\u003e\nOCO_API_CUSTOM_HEADERS=\u003cJSON string of custom HTTP headers to include in API requests\u003e\nOCO_TOKENS_MAX_INPUT=\u003cmax model token limit (default: 4096)\u003e\nOCO_TOKENS_MAX_OUTPUT=\u003cmax response tokens (default: 500)\u003e\nOCO_DESCRIPTION=\u003cpostface a message with ~3 sentences description of the changes\u003e\nOCO_EMOJI=\u003cboolean, add GitMoji\u003e\nOCO_MODEL=\u003ceither 'gpt-4o', 'gpt-4', 'gpt-4-turbo', 'gpt-3.5-turbo' (default), 'gpt-3.5-turbo-0125', 'gpt-4-1106-preview', 'gpt-4-turbo-preview' or 'gpt-4-0125-preview' or any Anthropic or Ollama model or any string basically, but it should be a valid model name\u003e\nOCO_LANGUAGE=\u003clocale, scroll to the bottom to see options\u003e\nOCO_MESSAGE_TEMPLATE_PLACEHOLDER=\u003cmessage template placeholder, default: '$msg'\u003e\nOCO_PROMPT_MODULE=\u003ceither conventional-commit or @commitlint, default: conventional-commit\u003e\nOCO_ONE_LINE_COMMIT=\u003cone line commit message, default: false\u003e\n```\n\nGlobal configs are same as local configs, but they are stored in the global `~/.opencommit` config file and set with `oco config set` command, e.g. `oco config set OCO_MODEL=gpt-4o`.\n\n### Global config for all repos\n\nLocal config still has more priority than Global config, but you may set `OCO_MODEL` and `OCO_LOCALE` globally and set local configs for `OCO_EMOJI` and `OCO_DESCRIPTION` per repo which is more convenient.\n\nSimply set any of the variables above like this:\n\n```sh\noco config set OCO_MODEL=gpt-4o-mini\n```\n\nConfigure [GitMoji](https://gitmoji.dev/) to preface a message.\n\n```sh\noco config set OCO_EMOJI=true\n```\n\nTo remove preface emojis:\n\n```sh\noco config set OCO_EMOJI=false\n```\n\nOther config options are behaving the same.\n\n### Output WHY the changes were done (WIP)\n\nYou can set the `OCO_WHY` config to `true` to have OpenCommit output a short description of WHY the changes were done after the commit message. Default is `false`.\n\nTo make this perform accurate we must store 'what files do' in some kind of an index or embedding and perform a lookup (kinda RAG) for the accurate git commit message. If you feel like building this comment on this ticket https://github.com/di-sukharev/opencommit/issues/398 and let's go from there together.\n\n```sh\noco config set OCO_WHY=true\n```\n\n### Switch to GPT-4 or other models\n\nBy default, OpenCommit uses `gpt-4o-mini` model.\n\nYou may switch to gpt-4o which performs better, but costs more 🤠\n\n```sh\noco config set OCO_MODEL=gpt-4o\n```\n\nor for as a cheaper option:\n\n```sh\noco config set OCO_MODEL=gpt-3.5-turbo\n```\n\n### Switch to other LLM providers with a custom URL\n\nBy default OpenCommit uses [OpenAI](https://openai.com).\n\nYou could switch to [Azure OpenAI Service](https://learn.microsoft.com/azure/cognitive-services/openai/) or Flowise or Ollama.\n\n```sh\noco config set OCO_AI_PROVIDER=azure OCO_API_KEY=\u003cyour_azure_api_key\u003e OCO_API_URL=\u003cyour_azure_endpoint\u003e\n\noco config set OCO_AI_PROVIDER=flowise OCO_API_KEY=\u003cyour_flowise_api_key\u003e OCO_API_URL=\u003cyour_flowise_endpoint\u003e\n\noco config set OCO_AI_PROVIDER=ollama OCO_API_KEY=\u003cyour_ollama_api_key\u003e OCO_API_URL=\u003cyour_ollama_endpoint\u003e\n```\n\n### Locale configuration\n\nTo globally specify the language used to generate commit messages:\n\n```sh\n# de, German, Deutsch\noco config set OCO_LANGUAGE=de\noco config set OCO_LANGUAGE=German\noco config set OCO_LANGUAGE=Deutsch\n\n# fr, French, française\noco config set OCO_LANGUAGE=fr\noco config set OCO_LANGUAGE=French\noco config set OCO_LANGUAGE=française\n```\n\nThe default language setting is **English**\nAll available languages are currently listed in the [i18n](https://github.com/di-sukharev/opencommit/tree/master/src/i18n) folder\n\n### Push to git (gonna be deprecated)\n\nA prompt for pushing to git is on by default but if you would like to turn it off just use:\n\n```sh\noco config set OCO_GITPUSH=false\n```\n\nand it will exit right after commit is confirmed without asking if you would like to push to remote.\n\n### Switch to `@commitlint`\n\nOpenCommit allows you to choose the prompt module used to generate commit messages. By default, OpenCommit uses its conventional-commit message generator. However, you can switch to using the `@commitlint` prompt module if you prefer. This option lets you generate commit messages in respect with the local config.\n\nYou can set this option by running the following command:\n\n```sh\noco config set OCO_PROMPT_MODULE=\u003cmodule\u003e\n```\n\nReplace `\u003cmodule\u003e` with either `conventional-commit` or `@commitlint`.\n\n#### Example:\n\nTo switch to using the `'@commitlint` prompt module, run:\n\n```sh\noco config set OCO_PROMPT_MODULE=@commitlint\n```\n\nTo switch back to the default conventional-commit message generator, run:\n\n```sh\noco config set OCO_PROMPT_MODULE=conventional-commit\n```\n\n#### Integrating with `@commitlint`\n\nThe integration between `@commitlint` and OpenCommit is done automatically the first time OpenCommit is run with `OCO_PROMPT_MODULE` set to `@commitlint`. However, if you need to force set or reset the configuration for `@commitlint`, you can run the following command:\n\n```sh\noco commitlint force\n```\n\nTo view the generated configuration for `@commitlint`, you can use this command:\n\n```sh\noco commitlint get\n```\n\nThis allows you to ensure that the configuration is set up as desired.\n\nAdditionally, the integration creates a file named `.opencommit-commitlint` which contains the prompts used for the local `@commitlint` configuration. You can modify this file to fine-tune the example commit message generated by OpenAI. This gives you the flexibility to make adjustments based on your preferences or project guidelines.\n\nOpenCommit generates a file named `.opencommit-commitlint` in your project directory which contains the prompts used for the local `@commitlint` configuration. You can modify this file to fine-tune the example commit message generated by OpenAI. If the local `@commitlint` configuration changes, this file will be updated the next time OpenCommit is run.\n\nThis offers you greater control over the generated commit messages, allowing for customization that aligns with your project's conventions.\n\n## Git flags\n\nThe `opencommit` or `oco` commands can be used in place of the `git commit -m \"${generatedMessage}\"` command. This means that any regular flags that are used with the `git commit` command will also be applied when using `opencommit` or `oco`.\n\n```sh\noco --no-verify\n```\n\nis translated to :\n\n```sh\ngit commit -m \"${generatedMessage}\" --no-verify\n```\n\nTo include a message in the generated message, you can utilize the template function, for instance:\n\n```sh\noco '#205: $msg’\n```\n\n\u003e opencommit examines placeholders in the parameters, allowing you to append additional information before and after the placeholders, such as the relevant Issue or Pull Request. Similarly, you have the option to customize the OCO_MESSAGE_TEMPLATE_PLACEHOLDER configuration item, for example, simplifying it to $m!\"\n\n### Message Template Placeholder Config\n\n#### Overview\n\nThe `OCO_MESSAGE_TEMPLATE_PLACEHOLDER` feature in the `opencommit` tool allows users to embed a custom message within the generated commit message using a template function. This configuration is designed to enhance the flexibility and customizability of commit messages, making it easier for users to include relevant information directly within their commits.\n\n#### Implementation Details\n\nIn our codebase, the implementation of this feature can be found in the following segment:\n\n```javascript\ncommitMessage = messageTemplate.replace(\n  config.OCO_MESSAGE_TEMPLATE_PLACEHOLDER,\n  commitMessage\n);\n```\n\nThis line is responsible for replacing the placeholder in the `messageTemplate` with the actual `commitMessage`.\n\n#### Usage\n\nFor instance, using the command `oco '$msg #205’`, users can leverage this feature. The provided code represents the backend mechanics of such commands, ensuring that the placeholder is replaced with the appropriate commit message.\n\n#### Committing with the Message\n\nOnce users have generated their desired commit message, they can proceed to commit using the generated message. By understanding the feature's full potential and its implementation details, users can confidently use the generated messages for their commits.\n\n### Ignore files\n\nYou can remove files from being sent to OpenAI by creating a `.opencommitignore` file. For example:\n\n```ignorelang\npath/to/large-asset.zip\n**/*.jpg\n```\n\nThis helps prevent opencommit from uploading artifacts and large files.\n\nBy default, opencommit ignores files matching: `*-lock.*` and `*.lock`\n\n## Git hook (KILLER FEATURE)\n\nYou can set OpenCommit as Git [`prepare-commit-msg`](https://git-scm.com/docs/githooks#_prepare_commit_msg) hook. Hook integrates with your IDE Source Control and allows you to edit the message before committing.\n\nTo set the hook:\n\n```sh\noco hook set\n```\n\nTo unset the hook:\n\n```sh\noco hook unset\n```\n\nTo use the hook:\n\n```sh\ngit add \u003cfiles...\u003e\ngit commit\n```\n\nOr follow the process of your IDE Source Control feature, when it calls `git commit` command — OpenCommit will integrate into the flow.\n\n## Setup OpenCommit as a GitHub Action (BETA) 🔥\n\nOpenCommit is now available as a GitHub Action which automatically improves all new commits messages when you push to remote!\n\nThis is great if you want to make sure all commits in all of your repository branches are meaningful and not lame like `fix1` or `done2`.\n\nCreate a file `.github/workflows/opencommit.yml` with the contents below:\n\n```yml\nname: 'OpenCommit Action'\n\non:\n  push:\n    # this list of branches is often enough,\n    # but you may still ignore other public branches\n    branches-ignore: [main master dev development release]\n\njobs:\n  opencommit:\n    timeout-minutes: 10\n    name: OpenCommit\n    runs-on: ubuntu-latest\n    permissions: write-all\n    steps:\n      - name: Setup Node.js Environment\n        uses: actions/setup-node@v2\n        with:\n          node-version: '16'\n      - uses: actions/checkout@v3\n        with:\n          fetch-depth: 0\n      - uses: di-sukharev/opencommit@github-action-v1.0.4\n        with:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n\n        env:\n          # set openAI api key in repo actions secrets,\n          # for openAI keys go to: https://platform.openai.com/account/api-keys\n          # for repo secret go to: \u003cyour_repo_url\u003e/settings/secrets/actions\n          OCO_API_KEY: ${{ secrets.OCO_API_KEY }}\n\n          # customization\n          OCO_TOKENS_MAX_INPUT: 4096\n          OCO_TOKENS_MAX_OUTPUT: 500\n          OCO_OPENAI_BASE_PATH: ''\n          OCO_DESCRIPTION: false\n          OCO_EMOJI: false\n          OCO_MODEL: gpt-4o\n          OCO_LANGUAGE: en\n          OCO_PROMPT_MODULE: conventional-commit\n```\n\nThat is it. Now when you push to any branch in your repo — all NEW commits are being improved by your never-tired AI.\n\nMake sure you exclude public collaboration branches (`main`, `dev`, `etc`) in `branches-ignore`, so OpenCommit does not rebase commits there while improving the messages.\n\nInteractive rebase (`rebase -i`) changes commits' SHA, so the commit history in remote becomes different from your local branch history. This is okay if you work on the branch alone, but may be inconvenient for other collaborators.\n\n## Payments\n\nYou pay for your requests to OpenAI API on your own.\n\nOpenCommit stores your key locally.\n\nOpenCommit by default uses 3.5-turbo model, it should not exceed $0.10 per casual working day.\n\nYou may switch to gpt-4, it's better, but more expensive.\n","funding_links":[],"categories":["AI Сервисы для разработки ПО","JavaScript","CLIs","A01_文本生成_文本对话","CLI \u0026 Local Workflows","🤖 AI \u0026 Machine Learning","Websites","精选开源项目合集","AI Git","chatgpt","UIs","ChatGPT 工具"],"sub_categories":["Генерация кода, тестов, документации и code review","大语言对话模型及数据","GPT工具","MCP Servers","Command-line(shell) interface","程序猿专区"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdi-sukharev%2Fopencommit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdi-sukharev%2Fopencommit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdi-sukharev%2Fopencommit/lists"}