aicommit2 0.0.0-semantic-release → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +182 -47
  3. package/dist/cli.mjs +65 -90
  4. package/package.json +22 -5
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) Hassan El Mghari
3
+ Copyright (c) Hyungtak Jin
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,52 +1,75 @@
1
1
  <div align="center">
2
2
  <div>
3
- <img src=".github/screenshot.png" alt="AI Commits"/>
4
- <h1 align="center">AI Commit2</h1>
3
+ <img src="https://github.com/tak-bro/aicommit2/assets/7614353/fae40f3e-329d-4acf-bd91-f7297cb88209" alt="AICommit2"/>
4
+ <h1 align="center">AICommit2</h1>
5
5
  </div>
6
- <p>The project was inspired by the <a href="https://https://github.com/Nutlope/aicommit2">AI Commits</a></p>
7
- <a href="https://www.npmjs.com/package/aicommit2"><img src="https://img.shields.io/npm/v/aicommit2" alt="Current version"></a>
6
+ <p>A Reactive CLI that generates git commit messages with diverse AI</p>
7
+ <a aria-label="npm" href="https://www.npmjs.com/package/aicommit2">
8
+ <img src="https://img.shields.io/npm/v/aicommit2" alt="Current version">
9
+ </a>
10
+ <a aria-label="license" href="https://github.com/tak-bro/aicommit2/blob/main/LICENSE">
11
+ <img src="https://img.shields.io/github/license/tak-bro/aicommit2.svg" alt="license">
12
+ </a>
8
13
  </div>
9
14
 
10
15
  ---
11
16
 
17
+ ## Project Base & Inspiration
18
+
19
+ The core functionalities and architecture of this project are inspired by [AI Commits](https://github.com/Nutlope/aicommits).
20
+
21
+ ## Supported AI
22
+
23
+ - [OpenAI](https://openai.com/)
24
+ - [Huggingface **(Unofficial)**](https://huggingface.co/chat/)
25
+ - [Clova X **(Unofficial)**](https://clova-x.naver.com/)
26
+
12
27
  ## Setup
13
28
 
14
29
  > The minimum supported version of Node.js is the latest v14. Check your Node.js version with `node --version`.
15
30
 
16
-
17
31
  1. Install _aicommit2_:
18
32
 
19
- ```sh
20
- npm install -g aicommit2
21
- ```
33
+ ```sh
34
+ npm install -g aicommit2
35
+ ```
22
36
 
23
- 2. Retrieve your API key from [OpenAI](https://platform.openai.com/account/api-keys)
37
+ 2. Retrieve your API key or Cookie
24
38
 
25
- > Note: If you haven't already, you'll have to create an account and set up billing.
39
+ - [OpenAI](https://platform.openai.com/account/api-keys)
40
+ - [Huggingface **(Unofficial)**](https://github.com/tak-bro/aicommit2/blob/main/README.md#how-to-get-cookie)
41
+ - [Clova X **(Unofficial)**](https://github.com/tak-bro/aicommit2/blob/main/README.md#how-to-get-cookie)
42
+
43
+ > If you haven't already, you'll have to create an account and set up billing.
26
44
 
27
45
  3. Set the key so aicommit2 can use it:
28
46
 
29
- ```sh
30
- aicommit2 config set OPENAI_KEY=<your token>
31
- ```
47
+ ```sh
48
+ aicommit2 config set OPENAI_KEY=<your token> # openai
49
+ aicommit2 config set HUGGING_COOKIE="<your browser cookie>" # huggingface
50
+ aicommit2 config set CLOVAX_COOKIE="<your browser cookie>" # clova x
51
+ ```
32
52
 
33
- This will create a `.aicommit2` file in your home directory.
53
+ This will create a `.aicommit2` file in your home directory.
34
54
 
55
+ > It is not necessary to set all keys. **But at least one key must be set up.**
35
56
 
36
57
  ### Upgrading
37
58
 
38
59
  Check the installed version with:
60
+
39
61
  ```
40
62
  aicommit2 --version
41
63
  ```
42
64
 
43
- If it's not the [latest version](https://github.com/Nutlope/aicommit2/releases/latest), run:
65
+ If it's not the [latest version](https://github.com/tak-bro/aicommit2/releases/latest), run:
44
66
 
45
67
  ```sh
46
68
  npm update -g aicommit2
47
69
  ```
48
70
 
49
71
  ## Usage
72
+
50
73
  ### CLI mode
51
74
 
52
75
  You can call `aicommit2` directly to generate a commit message for your staged changes:
@@ -59,30 +82,63 @@ aicommit2
59
82
  `aicommit2` passes down unknown flags to `git commit`, so you can pass in [`commit` flags](https://git-scm.com/docs/git-commit).
60
83
 
61
84
  For example, you can stage all changes in tracked files with as you commit:
85
+
62
86
  ```sh
63
87
  aicommit2 --all # or -a
64
88
  ```
65
89
 
66
- > 👉 **Tip:** Use the `aic` alias if `aicommit2` is too long for you.
90
+ > 👉 **Tip:** Use the `aic2` alias if `aicommit2` is too long for you.
91
+
92
+ #### CLI Options
93
+
94
+ ##### `--locale` or `-l`
95
+ - Locale to use for the generated commit messages (default: **en**)
96
+
97
+ ```sh
98
+ aicommit2 --locale <s> # or -l <s>
99
+ ```
67
100
 
68
- #### Generate multiple recommendations
101
+ ##### `--generate` or `-g`
102
+ - Number of messages to generate (Warning: generating multiple costs more) (default: **1**)
103
+ - 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 <i>` flag, where 'i' is the number of generated messages:
69
104
 
70
- 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 <i>` flag, where 'i' is the number of generated messages:
71
105
  ```sh
72
106
  aicommit2 --generate <i> # or -g <i>
73
107
  ```
74
108
 
75
109
  > Warning: this uses more tokens, meaning it costs more.
76
110
 
77
- #### Generating Conventional Commits
111
+ ##### `--all` or `-a`
112
+ - Automatically stage changes in tracked files for the commit (default: **false**)
113
+
114
+ ```sh
115
+ aicommit2 --all # or -a
116
+ ```
78
117
 
79
- If you'd like to generate [Conventional Commits](https://conventionalcommits.org/), you can use the `--type` flag followed by `conventional`. This will prompt `aicommit2` to format the commit message according to the Conventional Commits specification:
118
+ ##### `--type` or `-t`
119
+ - Automatically stage changes in tracked files for the commit (default: **conventional**)
120
+ - it supports [`conventional`](https://conventionalcommits.org/) and [`gitmoji`](https://gitmoji.dev/)
80
121
 
81
122
  ```sh
82
123
  aicommit2 --type conventional # or -t conventional
124
+ aicommit2 --type gitmoji # or -t gitmoji
83
125
  ```
84
126
 
85
- This feature can be useful if your project follows the Conventional Commits standard or if you're using tools that rely on this commit format.
127
+ ##### `--confirm` or `-y`
128
+ - Skip confirmation when committing after message generation (default: **false**)
129
+
130
+ ```sh
131
+ aicommit2 --confirm # or -y
132
+ ```
133
+
134
+ ##### `--clipboard` or `-c`
135
+ - Copy the selected message to the clipboard (default: **false**)
136
+ - This is a useful option when you don't want to commit through aicommit2.
137
+ - If you give this option, aicommit2 will not commit.
138
+
139
+ ```sh
140
+ aicommit2 --clipboard # or -c
141
+ ```
86
142
 
87
143
  ### Git hook
88
144
 
@@ -91,11 +147,13 @@ You can also integrate _aicommit2_ with Git via the [`prepare-commit-msg`](https
91
147
  #### Install
92
148
 
93
149
  In the Git repository you want to install the hook in:
150
+
94
151
  ```sh
95
152
  aicommit2 hook install
96
153
  ```
97
154
 
98
155
  #### Uninstall
156
+
99
157
  In the Git repository you want to uninstall the hook from:
100
158
 
101
159
  ```sh
@@ -105,20 +163,22 @@ aicommit2 hook uninstall
105
163
  #### Usage
106
164
 
107
165
  1. Stage your files and commit:
108
- ```sh
109
- git add <files...>
110
- git commit # Only generates a message when it's not passed in
111
- ```
112
166
 
113
- > If you ever want to write your own message instead of generating one, you can simply pass one in: `git commit -m "My message"`
167
+ ```sh
168
+ git add <files...>
169
+ git commit # Only generates a message when it's not passed in
170
+ ```
171
+
172
+ > If you ever want to write your own message instead of generating one, you can simply pass one in: `git commit -m "My message"`
114
173
 
115
- 2. aicommit2 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.
174
+ 2. AICommit2 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.
116
175
 
117
176
  3. Save and close the editor to commit!
118
177
 
119
178
  ## Configuration
120
179
 
121
180
  ### Reading a configuration value
181
+
122
182
  To retrieve a configuration option, use the command:
123
183
 
124
184
  ```sh
@@ -126,6 +186,7 @@ aicommit2 config get <key>
126
186
  ```
127
187
 
128
188
  For example, to retrieve the API key, you can use:
189
+
129
190
  ```sh
130
191
  aicommit2 config get OPENAI_KEY
131
192
  ```
@@ -133,7 +194,7 @@ aicommit2 config get OPENAI_KEY
133
194
  You can also retrieve multiple configuration options at once by separating them with spaces:
134
195
 
135
196
  ```sh
136
- aicommit2 config get OPENAI_KEY generate
197
+ aicommit2 config get OPENAI_KEY OPENAI_MODEL CLOVAX_COOKIE
137
198
  ```
138
199
 
139
200
  ### Setting a configuration value
@@ -157,16 +218,65 @@ aicommit2 config set OPENAI_KEY=<your-api-key> generate=3 locale=en
157
218
  ```
158
219
 
159
220
  ### Options
160
- #### OPENAI_KEY
161
221
 
162
- Required
222
+ | Option | Default | Description |
223
+ |------------------|----------------------------------------|-----------------------------------------------------------------------------|
224
+ | `OPENAI_KEY` | N/A | The OpenAI API key. |
225
+ | `OPENAI_MODEL` | `gpt-3.5-turbo` | The OpenAI Model to use. |
226
+ | `HUGGING_COOKIE` | N/A | The HuggingFace Cookie string |
227
+ | `HUGGING_MODEL` | `mistralai/Mixtral-8x7B-Instruct-v0.1` | The HuggingFace Model to use. |
228
+ | `CLOVAX_COOKIE` | N/A | The Clova X Cookie string |
229
+ | `locale` | `en` | Locale for the generated commit messages. |
230
+ | `generate` | `1` | Number of commit messages to generate. |
231
+ | `type` | `conventional` | Type of commit message to generate. |
232
+ | `proxy` | N/A | Set a HTTP/HTTPS proxy to use for requests(only **OpenAI**). |
233
+ | `timeout` | `10000` ms | Network request timeout |
234
+ | `max-length` | `50` | Maximum character length of the generated commit message. |
235
+ | `max-tokens` | `200` | The maximum number of tokens that the AI models can generate. |
236
+ | `temperature` | `0.7` | The temperature (0.0-2.0) is used to control the randomness of the output |
237
+
238
+
239
+ #### OPENAI_KEY
163
240
 
164
241
  The OpenAI API key. You can retrieve it from [OpenAI API Keys page](https://platform.openai.com/account/api-keys).
165
242
 
243
+ #### OPENAI_MODEL
244
+
245
+ Default: `gpt-3.5-turbo`
246
+
247
+ The Chat Completions (`/v1/chat/completions`) model to use. Consult the list of models available in the [OpenAI Documentation](https://platform.openai.com/docs/models/model-endpoint-compatibility).
248
+
249
+ > 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.
250
+
251
+ ```sh
252
+ aicommit2 config set OPENAI_MODEL=gpt-4
253
+ ```
254
+
255
+ #### HUGGING_COOKIE
256
+
257
+ The [Huggingface Chat](https://huggingface.co/chat/) Cookie. Please check [how to get cookie](https://github.com/tak-bro/aicommit2/blob/main/README.md#how-to-get-cookie)
258
+
259
+ #### HUGGING_MODEL
260
+
261
+ Default: `mistralai/Mixtral-8x7B-Instruct-v0.1`
262
+
263
+ Supported:
264
+ - `mistralai/Mixtral-8x7B-Instruct-v0.1`
265
+ - `meta-llama/Llama-2-70b-chat-hf`
266
+ - `NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO`
267
+ - `codellama/CodeLlama-70b-Instruct-hf`
268
+ - `mistralai/Mistral-7B-Instruct-v0.2`
269
+ - `openchat/openchat-3.5-0106`
270
+
271
+ #### CLOVAX_COOKIE
272
+
273
+ The [Clova X](https://clova-x.naver.com/) Cookie. Please check [how to get cookie](https://github.com/tak-bro/aicommit2/blob/main/README.md#how-to-get-cookie)
274
+
166
275
  #### locale
276
+
167
277
  Default: `en`
168
278
 
169
- 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.
279
+ The locale to use for the generated commit messages. Consult the list of codes in: https://wikipedia.org/wiki/List_of_ISO_639_language_codes.
170
280
 
171
281
  #### generate
172
282
 
@@ -182,20 +292,14 @@ Set a HTTP/HTTPS proxy to use for requests.
182
292
 
183
293
  To clear the proxy option, you can use the command (note the empty value after the equals sign):
184
294
 
295
+ > **Only supported within the OpenAI**
296
+
185
297
  ```sh
186
298
  aicommit2 config set proxy=
187
299
  ```
188
300
 
189
- #### model
190
-
191
- Default: `gpt-3.5-turbo`
192
-
193
- The Chat Completions (`/v1/chat/completions`) model to use. Consult the list of models available in the [OpenAI Documentation](https://platform.openai.com/docs/models/model-endpoint-compatibility).
194
-
195
- > 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.
196
-
197
-
198
301
  #### timeout
302
+
199
303
  The timeout for network requests to the OpenAI API in milliseconds.
200
304
 
201
305
  Default: `10000` (10 seconds)
@@ -205,6 +309,7 @@ aicommit2 config set timeout=20000 # 20s
205
309
  ```
206
310
 
207
311
  #### max-length
312
+
208
313
  The maximum character length of the generated commit message.
209
314
 
210
315
  Default: `50`
@@ -215,7 +320,9 @@ aicommit2 config set max-length=100
215
320
 
216
321
  #### type
217
322
 
218
- Default: `""` (Empty string)
323
+ Default: `conventional`
324
+
325
+ Supported: `conventional`, `gitmoji`
219
326
 
220
327
  The type of commit message to generate. Set this to "conventional" to generate commit messages that follow the Conventional Commits specification:
221
328
 
@@ -229,20 +336,48 @@ You can clear this option by setting it to an empty string:
229
336
  aicommit2 config set type=
230
337
  ```
231
338
 
339
+ #### max-tokens
340
+ The maximum number of tokens that the AI models can generate.
341
+
342
+ Default: `200`
343
+
344
+ ```sh
345
+ aicommit2 config set max-tokens=1000
346
+ ```
347
+
232
348
  ## How it works
233
349
 
234
- This CLI tool runs `git diff` to grab all your latest code changes, sends them to OpenAI's GPT-3, then returns the AI generated commit message.
350
+ This CLI tool runs `git diff` to grab all your latest code changes, sends them to configured AI, then returns the AI generated commit message.
235
351
 
236
- Video coming soon where I rebuild it from scratch to show you how to easily build your own CLI tools powered by AI.
352
+ ## How to get Cookie(**Unofficial API**)
237
353
 
238
- ## Maintainers
354
+ * Login to the site you want
355
+ * You can get cookie from the browser's developer tools network tab
356
+ * See for any requests check out the Cookie, **Copy whole value**
357
+ * Check below image for the format of cookie
358
+
359
+ ![how-to-get-cookie](https://github.com/tak-bro/aicommit2/assets/7614353/66f2994d-23d9-4c88-a113-f2d3dc5c0669)
360
+
361
+ > This picture is an example of the Huggingface Chat.
362
+
363
+ ## Disclaimer
239
364
 
240
- - **Hassan El Mghari**: [@Nutlope](https://github.com/Nutlope) [<img src="https://img.shields.io/twitter/follow/nutlope?style=flat&label=nutlope&logo=twitter&color=0bf&logoColor=fff" align="center">](https://twitter.com/nutlope)
365
+ This project utilizes certain functionalities or data from external APIs, but it is important to note that it is not officially affiliated with or endorsed by the providers of those APIs. The use of external APIs is at the sole discretion and risk of the user.
241
366
 
367
+ ## Risk Acknowledgment
242
368
 
243
- - **Hiroki Osame**: [@privatenumber](https://github.com/privatenumber) [<img src="https://img.shields.io/twitter/follow/privatenumbr?style=flat&label=privatenumbr&logo=twitter&color=0bf&logoColor=fff" align="center">](https://twitter.com/privatenumbr)
369
+ Users are responsible for understanding and abiding by the terms of use, rate limits, and policies set forth by the respective API providers. The project maintainers cannot be held responsible for any misuse, downtime, or issues arising from the use of the external APIs.
370
+
371
+ It is recommended that users thoroughly review the API documentation and adhere to best practices to ensure a positive and compliant experience.
372
+
373
+ ## Project Base and Inspiration
374
+
375
+ The core functionalities and architecture of this project are inspired by [AI Commits](https://https://github.com/Nutlope/aicommit). In addition to AI Commits, inspiration has been drawn from various open-source communities, expanding upon existing ideas and introducing new features.
376
+
377
+ ## Maintainers
244
378
 
379
+ - [@tak-bro](https://env-tak.github.io/)
245
380
 
246
381
  ## Contributing
247
382
 
248
- If you want to help fix a bug or implement a feature in [Issues](https://github.com/Nutlope/aicommit2/issues), checkout the [Contribution Guide](CONTRIBUTING.md) to learn how to setup and test the project.
383
+ If you want to help fix a bug or implement a feature in [Issues](https://github.com/tak-bro/aicommit2/issues), checkout the [Contribution Guide](CONTRIBUTING.md) to learn how to setup and test the project.