aicommits 1.11.0 → 1.12.0-develop.2
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.
- package/README.md +150 -48
- package/dist/cli.mjs +116 -83
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -3,41 +3,62 @@
|
|
|
3
3
|
<img src=".github/screenshot.png" alt="AI Commits"/>
|
|
4
4
|
<h1 align="center">AI Commits</h1>
|
|
5
5
|
</div>
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
<p>A CLI that writes your git commit messages for you with AI. Never write a commit message again.</p>
|
|
7
|
+
<a href="https://www.npmjs.com/package/aicommits"><img src="https://img.shields.io/npm/v/aicommits" alt="Current version"></a>
|
|
8
|
+
<a href="https://www.npmjs.com/package/aicommits"><img src="https://img.shields.io/npm/dt/aicommits" alt="Downloads"></a>
|
|
8
9
|
</div>
|
|
9
10
|
|
|
10
11
|
---
|
|
11
12
|
|
|
12
13
|
## Setup
|
|
13
14
|
|
|
14
|
-
> The minimum supported version of Node.js is
|
|
15
|
-
|
|
15
|
+
> The minimum supported version of Node.js is v22. Check your Node.js version with `node --version`.
|
|
16
16
|
|
|
17
17
|
1. Install _aicommits_:
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
```sh
|
|
20
|
+
npm install -g aicommits
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
2. Run the setup command to choose your AI provider:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
aicommits setup
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This will guide you through:
|
|
30
|
+
|
|
31
|
+
- Selecting your AI provider (sets the `provider` config)
|
|
32
|
+
- Configuring your API key
|
|
33
|
+
- **Automatically fetching and selecting from available models** (when supported)
|
|
22
34
|
|
|
23
|
-
|
|
35
|
+
Supported providers include:
|
|
24
36
|
|
|
25
|
-
|
|
37
|
+
- **TogetherAI** (recommended) - Get your API key from [TogetherAI](https://api.together.ai/)
|
|
38
|
+
- **OpenAI** - Get your API key from [OpenAI API Keys page](https://platform.openai.com/account/api-keys)
|
|
39
|
+
- **Ollama** (local) - Run AI models locally with [Ollama](https://ollama.ai)
|
|
40
|
+
- **Custom OpenAI-compatible endpoint** - Use any service that implements the OpenAI API
|
|
26
41
|
|
|
27
|
-
|
|
42
|
+
Alternatively, you can use environment variables (recommended for CI/CD):
|
|
28
43
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
44
|
+
```bash
|
|
45
|
+
export OPENAI_API_KEY="your_api_key_here"
|
|
46
|
+
export OPENAI_BASE_URL="your_api_endpoint" # Optional, for custom endpoints
|
|
47
|
+
export OPENAI_MODEL="your_model_choice" # Optional, defaults to provider default
|
|
48
|
+
```
|
|
32
49
|
|
|
33
|
-
|
|
50
|
+
> **Note:** When using environment variables, ensure all related variables (e.g., `OPENAI_API_KEY` and `OPENAI_BASE_URL`) are set consistently to avoid configuration mismatches with the config file.
|
|
34
51
|
|
|
52
|
+
This will create a `.aicommits` file in your home directory.
|
|
35
53
|
|
|
36
54
|
### Upgrading
|
|
37
55
|
|
|
38
56
|
Check the installed version with:
|
|
57
|
+
|
|
39
58
|
```
|
|
59
|
+
|
|
40
60
|
aicommits --version
|
|
61
|
+
|
|
41
62
|
```
|
|
42
63
|
|
|
43
64
|
If it's not the [latest version](https://github.com/Nutlope/aicommits/releases/latest), run:
|
|
@@ -47,6 +68,7 @@ npm update -g aicommits
|
|
|
47
68
|
```
|
|
48
69
|
|
|
49
70
|
## Usage
|
|
71
|
+
|
|
50
72
|
### CLI mode
|
|
51
73
|
|
|
52
74
|
You can call `aicommits` directly to generate a commit message for your staged changes:
|
|
@@ -59,21 +81,42 @@ aicommits
|
|
|
59
81
|
`aicommits` passes down unknown flags to `git commit`, so you can pass in [`commit` flags](https://git-scm.com/docs/git-commit).
|
|
60
82
|
|
|
61
83
|
For example, you can stage all changes in tracked files with as you commit:
|
|
84
|
+
|
|
62
85
|
```sh
|
|
63
86
|
aicommits --all # or -a
|
|
64
87
|
```
|
|
65
88
|
|
|
66
89
|
> 👉 **Tip:** Use the `aic` alias if `aicommits` is too long for you.
|
|
67
90
|
|
|
91
|
+
#### CLI Options
|
|
92
|
+
|
|
93
|
+
- `--generate` or `-g`: Number of messages to generate (default: **1**)
|
|
94
|
+
- `--exclude` or `-x`: Files to exclude from AI analysis
|
|
95
|
+
- `--all` or `-a`: Automatically stage changes in tracked files for the commit (default: **false**)
|
|
96
|
+
- `--type` or `-t`: Git commit message format (default: **conventional**). Supports `conventional` and `gitmoji`
|
|
97
|
+
- `--confirm` or `-y`: Skip confirmation when committing after message generation (default: **false**)
|
|
98
|
+
- `--clipboard` or `-c`: Copy the selected message to the clipboard instead of committing (default: **false**)
|
|
99
|
+
|
|
68
100
|
#### Generate multiple recommendations
|
|
69
101
|
|
|
70
102
|
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:
|
|
103
|
+
|
|
71
104
|
```sh
|
|
72
105
|
aicommits --generate <i> # or -g <i>
|
|
73
106
|
```
|
|
74
107
|
|
|
75
108
|
> Warning: this uses more tokens, meaning it costs more.
|
|
76
109
|
|
|
110
|
+
#### Generating Conventional Commits
|
|
111
|
+
|
|
112
|
+
If you'd like to generate [Conventional Commits](https://conventionalcommits.org/), you can use the `--type` flag followed by `conventional`. This will prompt `aicommits` to format the commit message according to the Conventional Commits specification:
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
aicommits --type conventional # or -t conventional
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
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.
|
|
119
|
+
|
|
77
120
|
### Git hook
|
|
78
121
|
|
|
79
122
|
You can also integrate _aicommits_ with Git via the [`prepare-commit-msg`](https://git-scm.com/docs/githooks#_prepare_commit_msg) hook. This lets you use Git like you normally would, and edit the commit message before committing.
|
|
@@ -81,11 +124,13 @@ You can also integrate _aicommits_ with Git via the [`prepare-commit-msg`](https
|
|
|
81
124
|
#### Install
|
|
82
125
|
|
|
83
126
|
In the Git repository you want to install the hook in:
|
|
127
|
+
|
|
84
128
|
```sh
|
|
85
129
|
aicommits hook install
|
|
86
130
|
```
|
|
87
131
|
|
|
88
132
|
#### Uninstall
|
|
133
|
+
|
|
89
134
|
In the Git repository you want to uninstall the hook from:
|
|
90
135
|
|
|
91
136
|
```sh
|
|
@@ -95,20 +140,67 @@ aicommits hook uninstall
|
|
|
95
140
|
#### Usage
|
|
96
141
|
|
|
97
142
|
1. Stage your files and commit:
|
|
98
|
-
```sh
|
|
99
|
-
git add <files...>
|
|
100
|
-
git commit # Only generates a message when it's not passed in
|
|
101
|
-
```
|
|
102
143
|
|
|
103
|
-
|
|
144
|
+
```sh
|
|
145
|
+
git add <files...>
|
|
146
|
+
git commit # Only generates a message when it's not passed in
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
> If you ever want to write your own message instead of generating one, you can simply pass one in: `git commit -m "My message"`
|
|
104
150
|
|
|
105
151
|
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.
|
|
106
152
|
|
|
107
153
|
3. Save and close the editor to commit!
|
|
108
154
|
|
|
155
|
+
### Environment Variables
|
|
156
|
+
|
|
157
|
+
You can also configure aicommits using environment variables instead of the config file.
|
|
158
|
+
|
|
159
|
+
**Example:**
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
export OPENAI_API_KEY="sk-..."
|
|
163
|
+
export OPENAI_BASE_URL="https://api.example.com"
|
|
164
|
+
export OPENAI_MODEL="gpt-4"
|
|
165
|
+
aicommits # Uses environment variables
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Configuration settings are resolved in the following order of precedence:
|
|
169
|
+
|
|
170
|
+
1. Command-line arguments
|
|
171
|
+
2. Environment variables
|
|
172
|
+
3. Configuration file
|
|
173
|
+
4. Default values
|
|
174
|
+
|
|
109
175
|
## Configuration
|
|
110
176
|
|
|
177
|
+
### Viewing current configuration
|
|
178
|
+
|
|
179
|
+
To view all current configuration options that differ from defaults, run:
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
aicommits config
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
This will display only non-default configuration values with API keys masked for security. If no custom configuration is set, it will show "(using all default values)".
|
|
186
|
+
|
|
187
|
+
### Changing your model
|
|
188
|
+
|
|
189
|
+
To interactively select or change your AI model, run:
|
|
190
|
+
|
|
191
|
+
```sh
|
|
192
|
+
aicommits model
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
This will:
|
|
196
|
+
|
|
197
|
+
- Show your current provider and model
|
|
198
|
+
- Fetch available models from your provider's API
|
|
199
|
+
- Let you select from available models or enter a custom model name
|
|
200
|
+
- Update your configuration automatically
|
|
201
|
+
|
|
111
202
|
### Reading a configuration value
|
|
203
|
+
|
|
112
204
|
To retrieve a configuration option, use the command:
|
|
113
205
|
|
|
114
206
|
```sh
|
|
@@ -116,14 +208,15 @@ aicommits config get <key>
|
|
|
116
208
|
```
|
|
117
209
|
|
|
118
210
|
For example, to retrieve the API key, you can use:
|
|
211
|
+
|
|
119
212
|
```sh
|
|
120
|
-
aicommits config get
|
|
213
|
+
aicommits config get OPENAI_API_KEY
|
|
121
214
|
```
|
|
122
215
|
|
|
123
216
|
You can also retrieve multiple configuration options at once by separating them with spaces:
|
|
124
217
|
|
|
125
218
|
```sh
|
|
126
|
-
aicommits config get
|
|
219
|
+
aicommits config get OPENAI_API_KEY generate
|
|
127
220
|
```
|
|
128
221
|
|
|
129
222
|
### Setting a configuration value
|
|
@@ -137,23 +230,35 @@ aicommits config set <key>=<value>
|
|
|
137
230
|
For example, to set the API key, you can use:
|
|
138
231
|
|
|
139
232
|
```sh
|
|
140
|
-
aicommits config set
|
|
233
|
+
aicommits config set OPENAI_API_KEY=<your-api-key>
|
|
141
234
|
```
|
|
142
235
|
|
|
143
236
|
You can also set multiple configuration options at once by separating them with spaces, like
|
|
144
237
|
|
|
145
238
|
```sh
|
|
146
|
-
aicommits config set
|
|
239
|
+
aicommits config set OPENAI_API_KEY=<your-api-key> generate=3 locale=en
|
|
147
240
|
```
|
|
148
241
|
|
|
149
|
-
### Options
|
|
150
|
-
#### OPENAI_KEY
|
|
242
|
+
### Config Options
|
|
151
243
|
|
|
152
|
-
|
|
244
|
+
#### OPENAI_API_KEY
|
|
153
245
|
|
|
154
|
-
|
|
246
|
+
Your OpenAI API key or custom provider API Key
|
|
247
|
+
|
|
248
|
+
#### OPENAI_BASE_URL
|
|
249
|
+
|
|
250
|
+
Custom OpenAI-compatible API endpoint URL.
|
|
251
|
+
|
|
252
|
+
#### OPENAI_MODEL
|
|
253
|
+
|
|
254
|
+
Model to use for OpenAI-compatible providers.
|
|
255
|
+
|
|
256
|
+
#### provider
|
|
257
|
+
|
|
258
|
+
The selected AI provider. Set automatically during `aicommits setup`. Valid values: `openai`, `togetherai`, `ollama`, `custom`.
|
|
155
259
|
|
|
156
260
|
#### locale
|
|
261
|
+
|
|
157
262
|
Default: `en`
|
|
158
263
|
|
|
159
264
|
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.
|
|
@@ -166,46 +271,45 @@ The number of commit messages to generate to pick from.
|
|
|
166
271
|
|
|
167
272
|
Note, this will use more tokens as it generates more results.
|
|
168
273
|
|
|
169
|
-
####
|
|
274
|
+
#### timeout
|
|
170
275
|
|
|
171
|
-
|
|
276
|
+
The timeout for network requests to the OpenAI API in milliseconds.
|
|
172
277
|
|
|
173
|
-
|
|
278
|
+
Default: `10000` (10 seconds)
|
|
174
279
|
|
|
175
280
|
```sh
|
|
176
|
-
aicommits config set
|
|
281
|
+
aicommits config set timeout=20000 # 20s
|
|
177
282
|
```
|
|
178
283
|
|
|
179
|
-
####
|
|
284
|
+
#### max-length
|
|
180
285
|
|
|
181
|
-
|
|
286
|
+
The maximum character length of the generated commit message.
|
|
182
287
|
|
|
183
|
-
|
|
288
|
+
Default: `72`
|
|
184
289
|
|
|
185
|
-
|
|
290
|
+
```sh
|
|
291
|
+
aicommits config set max-length=100
|
|
292
|
+
```
|
|
186
293
|
|
|
294
|
+
#### type
|
|
187
295
|
|
|
188
|
-
|
|
189
|
-
The timeout for network requests to the OpenAI API in milliseconds.
|
|
296
|
+
Default: `""` (Empty string)
|
|
190
297
|
|
|
191
|
-
|
|
298
|
+
The type of commit message to generate. Set this to "conventional" to generate commit messages that follow the Conventional Commits specification:
|
|
192
299
|
|
|
193
300
|
```sh
|
|
194
|
-
aicommits config set
|
|
301
|
+
aicommits config set type=conventional
|
|
195
302
|
```
|
|
196
303
|
|
|
197
|
-
|
|
198
|
-
The maximum character length of the generated commit message.
|
|
199
|
-
|
|
200
|
-
Default: `50`
|
|
304
|
+
You can clear this option by setting it to an empty string:
|
|
201
305
|
|
|
202
306
|
```sh
|
|
203
|
-
aicommits config set
|
|
307
|
+
aicommits config set type=
|
|
204
308
|
```
|
|
205
309
|
|
|
206
310
|
## How it works
|
|
207
311
|
|
|
208
|
-
This CLI tool runs `git diff` to grab all your latest code changes, sends them to
|
|
312
|
+
This CLI tool runs `git diff` to grab all your latest code changes, sends them to the configured AI provider (TogetherAI by default), then returns the AI generated commit message.
|
|
209
313
|
|
|
210
314
|
Video coming soon where I rebuild it from scratch to show you how to easily build your own CLI tools powered by AI.
|
|
211
315
|
|
|
@@ -213,10 +317,8 @@ Video coming soon where I rebuild it from scratch to show you how to easily buil
|
|
|
213
317
|
|
|
214
318
|
- **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)
|
|
215
319
|
|
|
216
|
-
|
|
217
320
|
- **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)
|
|
218
321
|
|
|
219
|
-
|
|
220
322
|
## Contributing
|
|
221
323
|
|
|
222
|
-
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
|
|
324
|
+
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
|