@sugarmo/aicommits 1.12.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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +387 -0
  3. package/dist/cli-2IldWz4f.mjs +217 -0
  4. package/dist/cli-B4CzHGlw.mjs +217 -0
  5. package/dist/cli-BLeSI0RG.mjs +217 -0
  6. package/dist/cli-BxYoCO_t.mjs +217 -0
  7. package/dist/cli-BxoTG54R.mjs +217 -0
  8. package/dist/cli-D5LKS_gV.mjs +214 -0
  9. package/dist/cli-DOlOxITZ.mjs +217 -0
  10. package/dist/cli-Dghc1HXo.mjs +217 -0
  11. package/dist/cli-DhEhfPVj.mjs +217 -0
  12. package/dist/cli-DoRxvV2c.mjs +214 -0
  13. package/dist/cli-VKXKWT-J.mjs +217 -0
  14. package/dist/cli-ZGc9mt4a.mjs +217 -0
  15. package/dist/cli.mjs +126 -0
  16. package/dist/token-BGl6xBJo.mjs +1 -0
  17. package/dist/token-BHAr8BGF.mjs +1 -0
  18. package/dist/token-BNKPepq2.mjs +1 -0
  19. package/dist/token-BU4WbpuT.mjs +1 -0
  20. package/dist/token-BgWUvNvl.mjs +1 -0
  21. package/dist/token-Bitulk9b.mjs +1 -0
  22. package/dist/token-C-_ybS1T.mjs +1 -0
  23. package/dist/token-D9tzl7Yz.mjs +1 -0
  24. package/dist/token-DSxWyl39.mjs +1 -0
  25. package/dist/token-Dqj85-rE.mjs +1 -0
  26. package/dist/token-pFVbzMqR.mjs +1 -0
  27. package/dist/token-util-12Sgwcw5.mjs +1 -0
  28. package/dist/token-util-BK5iblfw.mjs +1 -0
  29. package/dist/token-util-BNtjmkiu.mjs +1 -0
  30. package/dist/token-util-Bezp8Ra7.mjs +1 -0
  31. package/dist/token-util-BthbkaNP.mjs +1 -0
  32. package/dist/token-util-C-S1NtRU.mjs +1 -0
  33. package/dist/token-util-C08UmjgT.mjs +1 -0
  34. package/dist/token-util-C9k-Ose8.mjs +1 -0
  35. package/dist/token-util-CIaGUPau.mjs +1 -0
  36. package/dist/token-util-CghlsVgF.mjs +1 -0
  37. package/dist/token-util-Cm6RjjS1.mjs +1 -0
  38. package/dist/token-util-CnZZ1AJv.mjs +1 -0
  39. package/dist/token-util-CtBubgF8.mjs +1 -0
  40. package/dist/token-util-CzaKG7us.mjs +1 -0
  41. package/dist/token-util-D4W-wT_B.mjs +1 -0
  42. package/dist/token-util-DYebtoan.mjs +1 -0
  43. package/dist/token-util-Db6xqzh1.mjs +1 -0
  44. package/dist/token-util-Dg8-JbHb.mjs +1 -0
  45. package/dist/token-util-DtOpdBbh.mjs +1 -0
  46. package/dist/token-util-Hi0Y_OJ1.mjs +1 -0
  47. package/dist/token-util-Z9AnE2k6.mjs +1 -0
  48. package/dist/token-util-daVwaNP6.mjs +1 -0
  49. package/dist/token-util-r02UdbTi.mjs +1 -0
  50. package/dist/token-util-yhghfNwd.mjs +1 -0
  51. package/dist/token-xhtueDQA.mjs +1 -0
  52. package/package.json +87 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Hassan El Mghari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,387 @@
1
+ <div align="center">
2
+ <div>
3
+ <img src=".github/screenshot.png" alt="AI Commits"/>
4
+ <h1 align="center">AI Commits</h1>
5
+ </div>
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/@sugarmo/aicommits"><img src="https://img.shields.io/npm/v/%40sugarmo%2Faicommits" alt="Current version"></a>
8
+ </div>
9
+
10
+ ---
11
+
12
+ ## Setup
13
+
14
+ > The minimum supported version of Node.js is the latest v14. Check your Node.js version with `node --version`.
15
+
16
+
17
+ 1. Install _aicommits_:
18
+
19
+ ```sh
20
+ npm install -g @sugarmo/aicommits
21
+ ```
22
+
23
+ 2. Retrieve your API key from your API provider
24
+
25
+ > Note: If you haven't already, you'll have to create an account and set up billing.
26
+
27
+ 3. Set the key so aicommits can use it:
28
+
29
+ ```sh
30
+ aicommits config set api-key=<your token>
31
+ ```
32
+
33
+ This will create `~/.aicommits/config.toml`.
34
+
35
+
36
+ ### Upgrading
37
+
38
+ Check the installed version with:
39
+ ```
40
+ aicommits --version
41
+ ```
42
+
43
+ If it's not the [latest version](https://github.com/sugarmo/aicommits/releases/latest), run:
44
+
45
+ ```sh
46
+ npm update -g @sugarmo/aicommits
47
+ ```
48
+
49
+ ## Usage
50
+ ### CLI mode
51
+
52
+ You can call `aicommits` directly to generate a commit message for your staged changes:
53
+
54
+ ```sh
55
+ git add <files...>
56
+ aicommits
57
+ ```
58
+
59
+ `aicommits` passes down unknown flags to `git commit`, so you can pass in [`commit` flags](https://git-scm.com/docs/git-commit).
60
+
61
+ For example, you can stage all changes in tracked files with as you commit:
62
+ ```sh
63
+ aicommits --all # or -a
64
+ ```
65
+
66
+ > 👉 **Tip:** Use the `aic` alias if `aicommits` is too long for you.
67
+
68
+ #### Generate multiple recommendations
69
+
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
+ ```sh
72
+ aicommits --generate <i> # or -g <i>
73
+ ```
74
+
75
+ > Warning: this uses more tokens, meaning it costs more.
76
+
77
+ #### Generate title + details
78
+
79
+ If you want both a commit title and body:
80
+
81
+ ```sh
82
+ aicommits --details
83
+ ```
84
+
85
+ If you prefer a bullet-list body style:
86
+
87
+ ```sh
88
+ aicommits --details --details-style list
89
+ ```
90
+
91
+ #### Default style
92
+
93
+ The generator uses a GitHub Copilot-like style by default and prefers commit titles with a concrete file/class/module anchor so commit lists are easier to scan.
94
+
95
+ You can still fine-tune output using custom instructions:
96
+
97
+ ```sh
98
+ aicommits --details --instructions "Use shorter body sentences and prioritize class names in the title"
99
+ ```
100
+
101
+ #### Customize conventional format
102
+
103
+ You can combine conventional commits with custom output format and type mapping:
104
+
105
+ ```sh
106
+ aicommits --type conventional --conventional-format "<type>(<scope>): <subject>" --conventional-types '{"feature":"Introduce a feature","bugfix":"Fix defects"}'
107
+ ```
108
+
109
+ By default, conventional mode also prefers including scope (for example `refactor(RecentScrollshotController): ...`) when there is a clear dominant file/class/module. You can disable this behavior with:
110
+
111
+ ```sh
112
+ aicommits --conventional-scope false
113
+ ```
114
+
115
+ ### Git hook
116
+
117
+ 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.
118
+
119
+ #### Install
120
+
121
+ In the Git repository you want to install the hook in:
122
+ ```sh
123
+ aicommits hook install
124
+ ```
125
+
126
+ #### Uninstall
127
+ In the Git repository you want to uninstall the hook from:
128
+
129
+ ```sh
130
+ aicommits hook uninstall
131
+ ```
132
+
133
+ #### Usage
134
+
135
+ 1. Stage your files and commit:
136
+ ```sh
137
+ git add <files...>
138
+ git commit # Only generates a message when it's not passed in
139
+ ```
140
+
141
+ > If you ever want to write your own message instead of generating one, you can simply pass one in: `git commit -m "My message"`
142
+
143
+ 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.
144
+
145
+ 3. Save and close the editor to commit!
146
+
147
+ ## Configuration
148
+
149
+ Runtime configuration is read from `~/.aicommits/config.toml` (and CLI flags). Environment variables are not used as config inputs.
150
+
151
+ The file format is TOML.
152
+
153
+ ### Reading a configuration value
154
+ To retrieve a configuration option, use the command:
155
+
156
+ ```sh
157
+ aicommits config get <key>
158
+ ```
159
+
160
+ For example, to retrieve the API key, you can use:
161
+ ```sh
162
+ aicommits config get api-key
163
+ ```
164
+
165
+ You can also retrieve multiple configuration options at once by separating them with spaces:
166
+
167
+ ```sh
168
+ aicommits config get api-key generate
169
+ ```
170
+
171
+ ### Setting a configuration value
172
+
173
+ To set a configuration option, use the command:
174
+
175
+ ```sh
176
+ aicommits config set <key>=<value>
177
+ ```
178
+
179
+ For example, to set the API key, you can use:
180
+
181
+ ```sh
182
+ aicommits config set api-key=<your-api-key>
183
+ ```
184
+
185
+ You can also set multiple configuration options at once by separating them with spaces, like
186
+
187
+ ```sh
188
+ aicommits config set api-key=<your-api-key> generate=3 locale=en
189
+ ```
190
+
191
+ ### Options
192
+ #### api-key
193
+
194
+ Required
195
+
196
+ API key for your chat completions provider.
197
+
198
+ #### base-url
199
+
200
+ Required
201
+
202
+ Base URL used for chat completions requests.
203
+
204
+ ```sh
205
+ aicommits config set base-url=https://api.openai.com/v1
206
+ ```
207
+
208
+ #### profile
209
+
210
+ Default: empty
211
+
212
+ Selects a named profile from the `profiles` table in `config.toml`.
213
+ When a profile is selected, profile values override top-level values.
214
+
215
+ ```sh
216
+ aicommits config set profile=openai
217
+ ```
218
+
219
+ Example:
220
+
221
+ ```toml
222
+ api-key = "top-level-key"
223
+ model = "gpt-4o-mini"
224
+ profile = "openai"
225
+
226
+ [profiles.openai]
227
+ model = "gpt-5.2-codex"
228
+ base-url = "https://api.example.com/v1"
229
+ ```
230
+
231
+ #### locale
232
+ Default: `en`
233
+
234
+ 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.
235
+
236
+ Common aliases are normalized automatically (for example `cn` -> `zh-CN`).
237
+
238
+ #### generate
239
+
240
+ Default: `1`
241
+
242
+ The number of commit messages to generate to pick from.
243
+
244
+ Note, this will use more tokens as it generates more results.
245
+
246
+ #### proxy
247
+
248
+ Set a HTTP/HTTPS proxy to use for requests.
249
+
250
+ To clear the proxy option, you can use the command (note the empty value after the equals sign):
251
+
252
+ ```sh
253
+ aicommits config set proxy=
254
+ ```
255
+
256
+ #### model
257
+
258
+ Default: `gpt-3.5-turbo`
259
+
260
+ The Chat Completions (`/v1/chat/completions`) model to use.
261
+
262
+
263
+ #### timeout
264
+ The timeout for network requests to the API in milliseconds.
265
+
266
+ Default: `10000` (10 seconds)
267
+
268
+ ```sh
269
+ aicommits config set timeout=20000 # 20s
270
+ ```
271
+
272
+ #### max-length
273
+ The maximum character length of the generated commit message.
274
+
275
+ Default: `50`
276
+
277
+ ```sh
278
+ aicommits config set max-length=100
279
+ ```
280
+
281
+ #### type
282
+
283
+ Default: plain format
284
+
285
+ Set commit type formatting:
286
+
287
+ ```sh
288
+ aicommits config set type=conventional
289
+ ```
290
+
291
+ #### details
292
+
293
+ Default: `false`
294
+
295
+ Set this to `true` to generate title and body:
296
+
297
+ ```sh
298
+ aicommits config set details=true
299
+ ```
300
+
301
+ #### details-style
302
+
303
+ Default: `paragraph`
304
+
305
+ Controls body formatting when `details=true`.
306
+
307
+ Allowed values: `paragraph`, `list`
308
+
309
+ ```sh
310
+ aicommits config set details-style=list
311
+ ```
312
+
313
+ #### show-reasoning
314
+
315
+ Default: `false`
316
+
317
+ By default, aicommits shows normal analyzing progress.
318
+ If the model emits reasoning tokens, it switches to elapsed thinking time (for example `Thinking for 1m 12s`).
319
+ Enable this option to print full streamed model reasoning (debug mode):
320
+
321
+ ```sh
322
+ aicommits config set show-reasoning=true
323
+ ```
324
+
325
+ Or enable for a single run:
326
+
327
+ ```sh
328
+ aicommits --show-reasoning
329
+ ```
330
+
331
+ #### instructions
332
+
333
+ Default: empty
334
+
335
+ Additional custom prompt instructions:
336
+
337
+ ```sh
338
+ aicommits config set instructions="Use short and direct wording"
339
+ ```
340
+
341
+ #### conventional-format
342
+
343
+ Default: `<type>[optional (<scope>)]: <commit message>`
344
+
345
+ Customize the conventional output template:
346
+
347
+ ```sh
348
+ aicommits config set conventional-format="<type>(<scope>): <subject>"
349
+ ```
350
+
351
+ #### conventional-types
352
+
353
+ Default: built-in conventional type map
354
+
355
+ Customize type descriptions with JSON:
356
+
357
+ ```sh
358
+ aicommits config set conventional-types='{"feature":"Introduce a feature","bugfix":"Fix defects"}'
359
+ ```
360
+
361
+ #### conventional-scope
362
+
363
+ Default: `true`
364
+
365
+ When enabled, conventional commits strongly prefer `type(scope): subject` using the primary file/class/module as scope.
366
+
367
+ ```sh
368
+ aicommits config set conventional-scope=true
369
+ ```
370
+
371
+ ## How it works
372
+
373
+ This CLI tool runs `git diff` to grab your latest code changes, sends them to your configured chat completions API, then returns the generated commit message.
374
+
375
+ Video coming soon where I rebuild it from scratch to show you how to easily build your own CLI tools powered by AI.
376
+
377
+ ## Maintainers
378
+
379
+ - **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)
380
+
381
+
382
+ - **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)
383
+
384
+
385
+ ## Contributing
386
+
387
+ 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.