aicommit2 2.2.6 → 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 +97 -65
  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,13 +53,12 @@ _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
 
@@ -55,6 +66,7 @@ _aicommit2_ is a reactive CLI tool that automatically generates Git commit messa
55
66
  ```sh
56
67
  npm install -g aicommit2
57
68
  ```
69
+
58
70
  **Alternatively, from source**:
59
71
  ```sh
60
72
  git clone https://github.com/tak-bro/aicommit2.git
@@ -143,7 +155,13 @@ aicommit2 --all # or -a
143
155
  - `--generate` or `-g`: Number of messages to generate (default: **1**)
144
156
  - **Warning**: This uses more tokens, meaning it costs more.
145
157
  - `--exclude` or `-x`: Files to exclude from AI analysis
146
-
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
+
147
165
  Example:
148
166
  ```sh
149
167
  aicommit2 --locale "jp" --all --type "conventional" --generate 3 --clipboard --exclude "*.json" --exclude "*.ts"
@@ -153,7 +171,7 @@ aicommit2 --locale "jp" --all --type "conventional" --generate 3 --clipboard --e
153
171
 
154
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.
155
173
 
156
- #### Install
174
+ #### Automatic Installation
157
175
 
158
176
  In the Git repository you want to install the hook in:
159
177
 
@@ -161,6 +179,22 @@ In the Git repository you want to install the hook in:
161
179
  aicommit2 hook install
162
180
  ```
163
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
+
164
198
  #### Uninstall
165
199
 
166
200
  In the Git repository you want to uninstall the hook from:
@@ -169,6 +203,8 @@ In the Git repository you want to uninstall the hook from:
169
203
  aicommit2 hook uninstall
170
204
  ```
171
205
 
206
+ Or manually delete the `.git/hooks/prepare-commit-msg` file.
207
+
172
208
  ### Configuration
173
209
 
174
210
  #### Reading and Setting Configuration
@@ -183,6 +219,35 @@ aicommit2 config get GEMINI.key
183
219
  aicommit2 config set OPENAI.generate=3 GEMINI.temperature=0.5
184
220
  ```
185
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
+
186
251
  #### How to Configure in detail
187
252
 
188
253
  1. Command-line arguments: **use the format** `--[Model].[Key]=value`
@@ -216,7 +281,7 @@ model[]=llama3.2
216
281
  model[]=codestral
217
282
  ```
218
283
 
219
- > 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**.
220
285
 
221
286
  ## General Settings
222
287
 
@@ -450,7 +515,6 @@ aicommit2 config set codeReviewPromptPath="/path/to/user/prompt.txt"
450
515
  | **Groq** | ✓ | ✓ | ✓ | ✓ |
451
516
  | **Perplexity** | ✓ | ✓ | ✓ | ✓ |
452
517
  | **DeepSeek** | ✓ | ✓ | ✓ | ✓ |
453
- | **Huggingface** | | | | |
454
518
  | **Ollama** | ✓ | ✓ | | ✓ |
455
519
  | **OpenAI API-Compatible** | ✓ | ✓ | ✓ | ✓ |
456
520
 
@@ -768,49 +832,6 @@ Supported:
768
832
  aicommit2 config set DEEPSEEK.model="deepseek-reasoner"
769
833
  ```
770
834
 
771
- ### HuggingFace
772
-
773
- | Setting | Description | Default |
774
- |--------------------|----------------------------|----------------------------------------|
775
- | `cookie` | Authentication cookie | - |
776
- | `model` | Model to use | `CohereForAI/c4ai-command-r-plus` |
777
-
778
- ##### HUGGINGFACE.cookie
779
-
780
- 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)
781
-
782
- ```sh
783
- # Please be cautious of Escape characters(\", \') in browser cookie string
784
- aicommit2 config set HUGGINGFACE.cookie="your-cooke"
785
- ```
786
-
787
- ##### HUGGINGFACE.model
788
-
789
- Default: `CohereForAI/c4ai-command-r-plus`
790
-
791
- Supported:
792
- - `CohereForAI/c4ai-command-r-plus`
793
- - `meta-llama/Meta-Llama-3-70B-Instruct`
794
- - `HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1`
795
- - `mistralai/Mixtral-8x7B-Instruct-v0.1`
796
- - `NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO`
797
- - `01-ai/Yi-1.5-34B-Chat`
798
- - `mistralai/Mistral-7B-Instruct-v0.2`
799
- - `microsoft/Phi-3-mini-4k-instruct`
800
-
801
- ```sh
802
- aicommit2 config set HUGGINGFACE.model="mistralai/Mistral-7B-Instruct-v0.2"
803
- ```
804
-
805
- ##### Unsupported Options
806
-
807
- Huggingface does not support the following options in General Settings.
808
-
809
- - maxTokens
810
- - timeout
811
- - temperature
812
- - topP
813
-
814
835
  ### Ollama
815
836
 
816
837
  | Setting | Description | Default |
@@ -1045,6 +1066,30 @@ The response should be valid JSON that can be parsed without errors.
1045
1066
 
1046
1067
  This ensures that the output is consistently formatted as a JSON array, regardless of the custom template used.
1047
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
+
1048
1093
  ## Loading Multiple Ollama Models
1049
1094
 
1050
1095
  <img src="https://github.com/tak-bro/aicommit2/blob/main/img/ollama_parallel.gif?raw=true" alt="OLLAMA_PARALLEL" />
@@ -1084,19 +1129,6 @@ aicommit2
1084
1129
 
1085
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).
1086
1131
 
1087
- ## How to get Cookie(**Unofficial API**)
1088
-
1089
- * Login to the site you want
1090
- * You can get cookie from the browser's developer tools network tab
1091
- * See for any requests check out the Cookie, **Copy whole value**
1092
- * Check below image for the format of cookie
1093
-
1094
- > When setting cookies with long string values, ensure to **escape characters** like ", ', and others properly.
1095
- > - For double quotes ("), use \\"
1096
- > - For single quotes ('), use \\'
1097
-
1098
- ![how-to-get-cookie](https://github.com/tak-bro/aicommit2/assets/7614353/66f2994d-23d9-4c88-a113-f2d3dc5c0669)
1099
-
1100
1132
  ## Disclaimer and Risks
1101
1133
 
1102
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.