Files
opencommit/README.md
di-sukharev 01e6646b30 * 🎨 style(README.md): update OpenCommit logo filename
* 📝 docs(README.md): add examples section
The OpenCommit logo filename has been updated to match the new filename. The README.md file now includes an examples section that provides a link to the commits on the OpenCommit GitHub repository. This section also mentions that the emoji and long commit description text are configurable.

* 📝 chore(TODO.md): update TODO list
* 🐛 fix(TODO.md): add missing checkbox for a TODO item
The TODO list has been updated with new items. The bundle size can be reduced by properly configuring esbuild. The code has some TODOs that need to be addressed. Small files can be batched in one request to improve performance. Tests need to be added to ensure the code works as expected. Finally, a hook needs to be made to work.

* ⬆️ chore(package.json): update version to 0.0.21
* 🐛 fix(package.json): change cli file extension from .mjs to .cjs
* 🚀 feat(package.json): add repository and deploy scripts
The version number has been updated to 0.0.21. The cli file extension has been changed from .mjs to .cjs to improve compatibility with Node.js. A repository field has been added to the package.json file to specify the location of the project's repository. A deploy script has been added to build the project, increment the patch version number, and publish the package to the npm registry.

* 🎨 style(api.ts): remove unused import and commented code
* 🐛 fix(api.ts): remove prompt for OPENAI_API_KEY and add instructions to set it manually
The unused import of `ChatCompletionRequestMessage` and `ChatCompletionResponseMessage` has been removed. The commented code for prompting the user for `OPENAI_API_KEY` has also been removed. Instead, instructions have been added to set the `OPENAI_API_KEY` manually by running `oc config set OPENAI_API_KEY=<your token>`. This improves the user experience by providing clear instructions on how to set the `OPENAI_API_KEY` and removes the unnecessary prompt.

* 🐛 fix(cli.ts): remove assert statement from packageJSON import
The assert statement is not necessary for importing the package.json file. Removing it improves the readability of the code.

* 🐛 fix(githook.ts): use __filename instead of fileURLToPath(new URL('cli.mjs', import.meta.url))
*  feat(githook.ts): add error handling for fs.realpath call
The fileURLToPath function is not necessary as __filename already provides the path to the current file. The error handling for the fs.realpath call is added to prevent the program from crashing if the symlink does not exist.

* 🐛 fix(generateCommitMessageFromGitDiff.ts): fix length calculation for prompt messages
* 💄 style(generateCommitMessageFromGitDiff.ts): add whitespace to improve readability
The length calculation for the prompt messages was incorrect, causing the maximum request token limit to be exceeded. This has been fixed by correctly calculating the length of the prompt messages. Additionally, whitespace has been added to improve the readability of the code.

* 🐛 fix(generateCommitMessageWithChatCompletion): fix commit message length check
* 🚀 chore(generateCommitMessageWithChatCompletion): add TODO for edge case handling
The commit message length check has been fixed to include the length of the initial messages prompt. This ensures that the commit message length is correctly calculated and prevents the commit message from exceeding the maximum required tokens. A TODO has been added to handle an edge case.

* 🐛 fix(tsconfig.json): remove commented out rootDir property
* 🚀 chore(tsconfig.json): update compiler options
The rootDir property was commented out and not being used, so it was removed. The compiler options were updated to target ES2020, use CommonJS module, and allow importing of JSON files. The outDir property was set to "./out". The strict option was enabled along with noUnusedLocals and noUnusedParameters. The skipLibCheck option was set to true.
2023-03-06 22:39:18 +08:00

2.5 KiB

OpenCommit logo

OpenCommit

Author @di-sukharev

AI generates conventional commits with mind-blowing accuracy

Current version

Examples

Look into the commits to see how OpenCommit works. Emoji and long commit description text is configurable.

Setup

The minimum supported version of Node.js is the latest v14. Check your Node.js version with node --version.

  1. Install opencommit globally to use in any repository:

    npm install -g opencommit
    
  2. Get your API key from OpenAI

  3. Set the key to opencommit config:

    opencommit config set OPENAI_API_KEY=<your token>
    

    Your token isn't sent to anyone, it's saved in ~/.opencommit config file.

Usage

You can call opencommit directly to generate a commit message for your staged changes:

git add <files...>
opencommit

You can also use the oc shortcut:

git add <files...>
oc

Features

Preface commits with emoji 🤠

GitMoji convention is used.

To add emoji:

opencommit config set emoji=true

To remove emoji:

opencommit config set emoji=false

Postface commits with descriptions of changes 🤠

To add descriptions:

opencommit config set description=true

To remove description:

opencommit config set description=false

Git hook

You can set opencommit as Git prepare-commit-msg hook. Hook integrates with you IDE Source Control and allows you edit the message before commit.

To set the hook:

  opencommit hook set

To unset the hook:

  opencommit hook unset

To use the hook:

   git add <files...>
   git commit

Or follow the process of your IDE Source Control feature, when it calls git commit command — OpenCommit will integrate into the flow.

Payments

You pay for your own requests to OpenAI API. OpenCommit uses ChatGPT official model, that is ~10x times cheaper than GPT-3.