aicommit2 2.2.5 → 2.2.7

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 (3) hide show
  1. package/README.md +116 -72
  2. package/dist/cli.mjs +100 -69
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -19,11 +19,23 @@
19
19
 
20
20
  ---
21
21
 
22
- ## Introduction
22
+ ## 🚀 Quick Start
23
+
24
+ ```bash
25
+ # Install globally
26
+ npm install -g aicommit2
27
+ # Set up at least one AI provider
28
+ aicommit2 config set OPENAI.key=<your-key>
29
+ # Use in your git repository
30
+ git add .
31
+ aicommit2
32
+ ```
33
+
34
+ ## 📖 Introduction
23
35
 
24
36
  _aicommit2_ is a reactive CLI tool that automatically generates Git commit messages using various AI models. It supports simultaneous requests to multiple AI providers, allowing users to select the most suitable commit message. The core functionalities and architecture of this project are inspired by [AICommits](https://github.com/Nutlope/aicommits).
25
37
 
26
- ## Key Features
38
+ ## Key Features
27
39
 
28
40
  - **Multi-AI Support**: Integrates with OpenAI, Anthropic Claude, Google Gemini, Mistral AI, Cohere, Groq, Ollama and more.
29
41
  - **OpenAI API Compatibility**: Support for any service that implements the OpenAI API specification.
@@ -31,7 +43,7 @@ _aicommit2_ is a reactive CLI tool that automatically generates Git commit messa
31
43
  - **Git Hook Integration**: Can be used as a prepare-commit-msg hook.
32
44
  - **Custom Prompt**: Supports user-defined system prompt templates.
33
45
 
34
- ## Supported Providers
46
+ ## 🤖 Supported Providers
35
47
 
36
48
  - [OpenAI](https://openai.com/)
37
49
  - [Anthropic Claude](https://console.anthropic.com/)
@@ -41,20 +53,28 @@ _aicommit2_ is a reactive CLI tool that automatically generates Git commit messa
41
53
  - [Groq](https://groq.com/)
42
54
  - [Perplexity](https://docs.perplexity.ai/)
43
55
  - [DeepSeek](https://www.deepseek.com/)
44
- - [Huggingface **(Unofficial)**](https://huggingface.co/chat/)
45
56
  - [Ollama](https://ollama.com/)
46
57
  - [OpenAI API Compatibility](#openai-api-compatible-services)
47
58
 
48
59
  ## Setup
49
60
 
50
- > The minimum supported version of Node.js is the v18. Check your Node.js version with `node --version`.
61
+ > ⚠️ The minimum supported version of Node.js is the v18. Check your Node.js version with `node --version`.
51
62
 
52
63
  1. Install _aicommit2_:
53
64
 
65
+ **Directly from npm**:
54
66
  ```sh
55
67
  npm install -g aicommit2
56
68
  ```
57
69
 
70
+ **Alternatively, from source**:
71
+ ```sh
72
+ git clone https://github.com/tak-bro/aicommit2.git
73
+ cd aicommit2
74
+ npm run build
75
+ npm install -g .
76
+ ```
77
+
58
78
  2. Set up API keys (**at least ONE key must be set**):
59
79
 
60
80
  ```sh
@@ -135,7 +155,13 @@ aicommit2 --all # or -a
135
155
  - `--generate` or `-g`: Number of messages to generate (default: **1**)
136
156
  - **Warning**: This uses more tokens, meaning it costs more.
137
157
  - `--exclude` or `-x`: Files to exclude from AI analysis
138
-
158
+ - `--hook-mode`: Run as a Git hook, typically used with prepare-commit-msg hook (default: **false**)
159
+ - This mode is automatically enabled when running through the Git hook system
160
+ - See [Git hook](#git-hook) section for more details
161
+ - `--pre-commit`: Run in [pre-commit](https://pre-commit.com/) framework mode (default: **false**)
162
+ - This option is specifically for use with the pre-commit framework
163
+ - See [Integration with pre-commit framework](#integration-with-pre-commit-framework) section for setup instructions
164
+
139
165
  Example:
140
166
  ```sh
141
167
  aicommit2 --locale "jp" --all --type "conventional" --generate 3 --clipboard --exclude "*.json" --exclude "*.ts"
@@ -145,7 +171,7 @@ aicommit2 --locale "jp" --all --type "conventional" --generate 3 --clipboard --e
145
171
 
146
172
  You can also integrate _aicommit2_ 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.
147
173
 
148
- #### Install
174
+ #### Automatic Installation
149
175
 
150
176
  In the Git repository you want to install the hook in:
151
177
 
@@ -153,6 +179,22 @@ In the Git repository you want to install the hook in:
153
179
  aicommit2 hook install
154
180
  ```
155
181
 
182
+ #### Manual Installation
183
+
184
+ if you prefer to set up the hook manually, create or edit the `.git/hooks/prepare-commit-msg` file:
185
+
186
+ ```sh
187
+ #!/bin/sh
188
+ # your-other-hook "$@"
189
+ aicommit2 --hook-mode "$@"
190
+ ```
191
+
192
+ Make the hook executable:
193
+
194
+ ```sh
195
+ chmod +x .git/hooks/prepare-commit-msg
196
+ ```
197
+
156
198
  #### Uninstall
157
199
 
158
200
  In the Git repository you want to uninstall the hook from:
@@ -161,6 +203,8 @@ In the Git repository you want to uninstall the hook from:
161
203
  aicommit2 hook uninstall
162
204
  ```
163
205
 
206
+ Or manually delete the `.git/hooks/prepare-commit-msg` file.
207
+
164
208
  ### Configuration
165
209
 
166
210
  #### Reading and Setting Configuration
@@ -175,6 +219,35 @@ aicommit2 config get GEMINI.key
175
219
  aicommit2 config set OPENAI.generate=3 GEMINI.temperature=0.5
176
220
  ```
177
221
 
222
+ #### Environment Variables
223
+
224
+ You can configure API keys using environment variables. This is particularly useful for CI/CD environments or when you don't want to store keys in the configuration file.
225
+
226
+ ```bash
227
+ # OpenAI
228
+ OPENAI_API_KEY="your-openai-key"
229
+ # Anthropic
230
+ ANTHROPIC_API_KEY="your-anthropic-key"
231
+ # Google
232
+ GEMINI_API_KEY="your-gemini-key"
233
+ # Mistral AI
234
+ MISTRAL_API_KEY="your-mistral-key"
235
+ CODESTRAL_API_KEY="your-codestral-key"
236
+ # Other Providers
237
+ COHERE_API_KEY="your-cohere-key"
238
+ GROQ_API_KEY="your-groq-key"
239
+ PERPLEXITY_API_KEY="your-perplexity-key"
240
+ DEEPSEEK_API_KEY="your-deepseek-key"
241
+ ```
242
+
243
+ Usage Example:
244
+
245
+ ```sh
246
+ OPENAI_API_KEY="your-openai-key" ANTHROPIC_API_KEY="your-anthropic-key" aicommit2
247
+ ```
248
+
249
+ > **Note**: Environment variables take precedence over configuration file settings.
250
+
178
251
  #### How to Configure in detail
179
252
 
180
253
  1. Command-line arguments: **use the format** `--[Model].[Key]=value`
@@ -208,7 +281,7 @@ model[]=llama3.2
208
281
  model[]=codestral
209
282
  ```
210
283
 
211
- > The priority of settings is: **Command-line Arguments > Model-Specific Settings > General Settings > Default Values**.
284
+ > The priority of settings is: **Command-line Arguments > Environment Variables > Model-Specific Settings > General Settings > Default Values**.
212
285
 
213
286
  ## General Settings
214
287
 
@@ -442,7 +515,6 @@ aicommit2 config set codeReviewPromptPath="/path/to/user/prompt.txt"
442
515
  | **Groq** | ✓ | ✓ | ✓ | ✓ |
443
516
  | **Perplexity** | ✓ | ✓ | ✓ | ✓ |
444
517
  | **DeepSeek** | ✓ | ✓ | ✓ | ✓ |
445
- | **Huggingface** | | | | |
446
518
  | **Ollama** | ✓ | ✓ | | ✓ |
447
519
  | **OpenAI API-Compatible** | ✓ | ✓ | ✓ | ✓ |
448
520
 
@@ -547,7 +619,7 @@ Anthropic does not support the following options in General Settings.
547
619
  | Setting | Description | Default |
548
620
  |--------------------|------------------------|------------------------|
549
621
  | `key` | API key | - |
550
- | `model` | Model to use | `gemini-2.0-flash-exp` |
622
+ | `model` | Model to use | `gemini-2.0-flash` |
551
623
 
552
624
  ##### GEMINI.key
553
625
 
@@ -670,10 +742,10 @@ Cohere does not support the following options in General Settings.
670
742
 
671
743
  ### Groq
672
744
 
673
- | Setting | Description | Default |
674
- |--------------------|------------------------|----------------|
675
- | `key` | API key | - |
676
- | `model` | Model to use | `gemma2-9b-it` |
745
+ | Setting | Description | Default |
746
+ |--------------------|------------------------|---------------------------------|
747
+ | `key` | API key | - |
748
+ | `model` | Model to use | `deepseek-r1-distill-llama-70b` |
677
749
 
678
750
  ##### GROQ.key
679
751
 
@@ -681,9 +753,13 @@ The Groq API key. If you don't have one, please sign up and get the API key in [
681
753
 
682
754
  ##### GROQ.model
683
755
 
684
- Default: `gemma2-9b-it`
756
+ Default: `deepseek-r1-distill-llama-70b`
685
757
 
686
758
  Supported:
759
+ - `qwen-2.5-32b`
760
+ - `qwen-2.5-coder-32b`
761
+ - `deepseek-r1-distill-qwen-32b`
762
+ - `deepseek-r1-distill-llama-70b`
687
763
  - `distil-whisper-large-v3-en`
688
764
  - `gemma2-9b-it`
689
765
  - `llama-3.3-70b-versatile`
@@ -702,7 +778,7 @@ Supported:
702
778
 
703
779
 
704
780
  ```sh
705
- aicommit2 config set GROQ.model="llama-3.3-70b-versatile"
781
+ aicommit2 config set GROQ.model="deepseek-r1-distill-llama-70b"
706
782
  ```
707
783
 
708
784
  ### Perplexity
@@ -756,49 +832,6 @@ Supported:
756
832
  aicommit2 config set DEEPSEEK.model="deepseek-reasoner"
757
833
  ```
758
834
 
759
- ### HuggingFace
760
-
761
- | Setting | Description | Default |
762
- |--------------------|----------------------------|----------------------------------------|
763
- | `cookie` | Authentication cookie | - |
764
- | `model` | Model to use | `CohereForAI/c4ai-command-r-plus` |
765
-
766
- ##### HUGGINGFACE.cookie
767
-
768
- The [Huggingface Chat](https://huggingface.co/chat/) Cookie. Please check [how to get cookie](https://github.com/tak-bro/aicommit2?tab=readme-ov-file#how-to-get-cookieunofficial-api)
769
-
770
- ```sh
771
- # Please be cautious of Escape characters(\", \') in browser cookie string
772
- aicommit2 config set HUGGINGFACE.cookie="your-cooke"
773
- ```
774
-
775
- ##### HUGGINGFACE.model
776
-
777
- Default: `CohereForAI/c4ai-command-r-plus`
778
-
779
- Supported:
780
- - `CohereForAI/c4ai-command-r-plus`
781
- - `meta-llama/Meta-Llama-3-70B-Instruct`
782
- - `HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1`
783
- - `mistralai/Mixtral-8x7B-Instruct-v0.1`
784
- - `NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO`
785
- - `01-ai/Yi-1.5-34B-Chat`
786
- - `mistralai/Mistral-7B-Instruct-v0.2`
787
- - `microsoft/Phi-3-mini-4k-instruct`
788
-
789
- ```sh
790
- aicommit2 config set HUGGINGFACE.model="mistralai/Mistral-7B-Instruct-v0.2"
791
- ```
792
-
793
- ##### Unsupported Options
794
-
795
- Huggingface does not support the following options in General Settings.
796
-
797
- - maxTokens
798
- - timeout
799
- - temperature
800
- - topP
801
-
802
835
  ### Ollama
803
836
 
804
837
  | Setting | Description | Default |
@@ -1033,6 +1066,30 @@ The response should be valid JSON that can be parsed without errors.
1033
1066
 
1034
1067
  This ensures that the output is consistently formatted as a JSON array, regardless of the custom template used.
1035
1068
 
1069
+ ## Integration with pre-commit framework
1070
+
1071
+ If you're using the [pre-commit](https://pre-commit.com/) framework, you can add _aicommit2_ to your `.pre-commit-config.yaml`:
1072
+
1073
+ ```yaml
1074
+ repos:
1075
+ - repo: local
1076
+ hooks:
1077
+ - id: aicommit2
1078
+ name: AI Commit Message Generator
1079
+ entry: aicommit2 --pre-commit
1080
+ language: node
1081
+ stages: [prepare-commit-msg]
1082
+ always_run: true
1083
+ ```
1084
+
1085
+ Make sure you have:
1086
+
1087
+ 1. Installed pre-commit: `brew install pre-commit`
1088
+ 2. Installed aicommit2 globally: `npm install -g aicommit2`
1089
+ 3. Run `pre-commit install --hook-type prepare-commit-msg` to set up the hook
1090
+
1091
+ > **Note** : The `--pre-commit` flag is specifically designed for use with the pre-commit framework and ensures proper integration with other pre-commit hooks.
1092
+
1036
1093
  ## Loading Multiple Ollama Models
1037
1094
 
1038
1095
  <img src="https://github.com/tak-bro/aicommit2/blob/main/img/ollama_parallel.gif?raw=true" alt="OLLAMA_PARALLEL" />
@@ -1072,19 +1129,6 @@ aicommit2
1072
1129
 
1073
1130
  > Note that this feature is available starting from Ollama version [**0.1.33**](https://github.com/ollama/ollama/releases/tag/v0.1.33) and _aicommit2_ version [**1.9.5**](https://www.npmjs.com/package/aicommit2/v/1.9.5).
1074
1131
 
1075
- ## How to get Cookie(**Unofficial API**)
1076
-
1077
- * Login to the site you want
1078
- * You can get cookie from the browser's developer tools network tab
1079
- * See for any requests check out the Cookie, **Copy whole value**
1080
- * Check below image for the format of cookie
1081
-
1082
- > When setting cookies with long string values, ensure to **escape characters** like ", ', and others properly.
1083
- > - For double quotes ("), use \\"
1084
- > - For single quotes ('), use \\'
1085
-
1086
- ![how-to-get-cookie](https://github.com/tak-bro/aicommit2/assets/7614353/66f2994d-23d9-4c88-a113-f2d3dc5c0669)
1087
-
1088
1132
  ## Disclaimer and Risks
1089
1133
 
1090
1134
  This project uses functionalities from external APIs but is not officially affiliated with or endorsed by their providers. Users are responsible for complying with API terms, rate limits, and policies.