diff --git a/README.md b/README.md index 106eceed..c07a9f2e 100644 --- a/README.md +++ b/README.md @@ -13,29 +13,28 @@ > The minimum supported version of Node.js is the latest v14. Check your Node.js version with `node --version`. - 1. Install _aicommits_: - ```sh - npm install -g aicommits - ``` + ```sh + npm install -g aicommits + ``` 2. Retrieve your API key from [OpenAI](https://platform.openai.com/account/api-keys) - > Note: If you haven't already, you'll have to create an account and set up billing. + > Note: If you haven't already, you'll have to create an account and set up billing. 3. Set the key so aicommits can use it: - ```sh - aicommits config set OPENAI_KEY= - ``` - - This will create a `.aicommits` file in your home directory. + ```sh + aicommits config set OPENAI_KEY= + ``` + This will create a `.aicommits` file in your home directory. ### Upgrading Check the installed version with: + ``` aicommits --version ``` @@ -47,6 +46,7 @@ npm update -g aicommits ``` ## Usage + ### CLI mode You can call `aicommits` directly to generate a commit message for your staged changes: @@ -59,6 +59,7 @@ aicommits `aicommits` passes down unknown flags to `git commit`, so you can pass in [`commit` flags](https://git-scm.com/docs/git-commit). For example, you can stage all changes in tracked files with as you commit: + ```sh aicommits --all # or -a ``` @@ -68,6 +69,7 @@ aicommits --all # or -a #### Generate multiple recommendations Sometimes the recommended commit message isn't the best so you want it to generate a few to pick from. You can generate multiple commit messages at once by passing in the `--generate ` flag, where 'i' is the number of generated messages: + ```sh aicommits --generate # or -g ``` @@ -91,11 +93,13 @@ You can also integrate _aicommits_ with Git via the [`prepare-commit-msg`](https #### Install In the Git repository you want to install the hook in: + ```sh aicommits hook install ``` #### Uninstall + In the Git repository you want to uninstall the hook from: ```sh @@ -105,12 +109,13 @@ aicommits hook uninstall #### Usage 1. Stage your files and commit: - ```sh - git add - git commit # Only generates a message when it's not passed in - ``` - > If you ever want to write your own message instead of generating one, you can simply pass one in: `git commit -m "My message"` + ```sh + git add + git commit # Only generates a message when it's not passed in + ``` + + > If you ever want to write your own message instead of generating one, you can simply pass one in: `git commit -m "My message"` 2. Aicommits will generate the commit message for you and pass it back to Git. Git will open it with the [configured editor](https://docs.github.com/en/get-started/getting-started-with-git/associating-text-editors-with-git) for you to review/edit it. @@ -119,6 +124,7 @@ aicommits hook uninstall ## Configuration ### Reading a configuration value + To retrieve a configuration option, use the command: ```sh @@ -126,6 +132,7 @@ aicommits config get ``` For example, to retrieve the API key, you can use: + ```sh aicommits config get OPENAI_KEY ``` @@ -157,6 +164,7 @@ aicommits config set OPENAI_KEY= generate=3 locale=en ``` ### Options + #### OPENAI_KEY Required @@ -164,6 +172,7 @@ Required The OpenAI API key. You can retrieve it from [OpenAI API Keys page](https://platform.openai.com/account/api-keys). #### locale + Default: `en` The locale to use for the generated commit messages. Consult the list of codes in: https://wikipedia.org/wiki/List_of_ISO_639-1_codes. @@ -194,8 +203,8 @@ The Chat Completions (`/v1/chat/completions`) model to use. Consult the list of > Tip: If you have access, try upgrading to [`gpt-4`](https://platform.openai.com/docs/models/gpt-4) for next-level code analysis. It can handle double the input size, but comes at a higher cost. Check out OpenAI's website to learn more. - #### timeout + The timeout for network requests to the OpenAI API in milliseconds. Default: `10000` (10 seconds) @@ -205,6 +214,7 @@ aicommits config set timeout=20000 # 20s ``` #### max-length + The maximum character length of the generated commit message. Default: `50` @@ -239,10 +249,8 @@ Video coming soon where I rebuild it from scratch to show you how to easily buil - **Hassan El Mghari**: [@Nutlope](https://github.com/Nutlope) [](https://twitter.com/nutlope) - - **Hiroki Osame**: [@privatenumber](https://github.com/privatenumber) [](https://twitter.com/privatenumbr) - ## Contributing -If you want to help fix a bug or implement a feature in [Issues](https://github.com/Nutlope/aicommits/issues), checkout the [Contribution Guide](CONTRIBUTING.md) to learn how to setup and test the project. +If you want to help fix a bug or implement a feature in [Issues](https://github.com/Nutlope/aicommits/issues), checkout the [Contribution Guide](CONTRIBUTING.md) to learn how to setup and test the project