@untools/commitgen 0.2.6 → 0.3.1
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/dist/commands/login.d.ts +1 -0
- package/dist/commands/login.js +91 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/commitgen.d.ts +9 -0
- package/dist/providers/commitgen.js +77 -0
- package/dist/providers/commitgen.js.map +1 -0
- package/dist/providers/index.js +3 -11
- package/dist/providers/index.js.map +1 -1
- package/dist/types.d.ts +8 -1
- package/package.json +4 -4
- package/README.md +0 -734
- package/dist/package.json +0 -70
- package/dist/src/commands/configure.d.ts +0 -1
- package/dist/src/commands/configure.js +0 -96
- package/dist/src/commands/configure.js.map +0 -1
- package/dist/src/config.d.ts +0 -15
- package/dist/src/config.js +0 -56
- package/dist/src/config.js.map +0 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.js +0 -649
- package/dist/src/index.js.map +0 -1
- package/dist/src/providers/base.d.ts +0 -9
- package/dist/src/providers/base.js +0 -107
- package/dist/src/providers/base.js.map +0 -1
- package/dist/src/providers/index.d.ts +0 -4
- package/dist/src/providers/index.js +0 -41
- package/dist/src/providers/index.js.map +0 -1
- package/dist/src/providers/vercel-google.d.ts +0 -10
- package/dist/src/providers/vercel-google.js +0 -113
- package/dist/src/providers/vercel-google.js.map +0 -1
- package/dist/src/types.d.ts +0 -46
- package/dist/src/types.js +0 -4
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils/commit-history.d.ts +0 -35
- package/dist/src/utils/commit-history.js +0 -165
- package/dist/src/utils/commit-history.js.map +0 -1
- package/dist/src/utils/issue-tracker.d.ts +0 -43
- package/dist/src/utils/issue-tracker.js +0 -207
- package/dist/src/utils/issue-tracker.js.map +0 -1
- package/dist/src/utils/loading.d.ts +0 -14
- package/dist/src/utils/loading.js +0 -72
- package/dist/src/utils/loading.js.map +0 -1
- package/dist/src/utils/multi-commit.d.ts +0 -40
- package/dist/src/utils/multi-commit.js +0 -274
- package/dist/src/utils/multi-commit.js.map +0 -1
package/README.md
DELETED
|
@@ -1,734 +0,0 @@
|
|
|
1
|
-
<!-- ./README.md -->
|
|
2
|
-
|
|
3
|
-
# @untools/commitgen
|
|
4
|
-
|
|
5
|
-
🚀 AI-powered commit message generator for Git with modular AI provider support.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
✨ **AI-Powered Generation**: Leverages advanced AI models to analyze your git changes and generate meaningful commit messages
|
|
10
|
-
|
|
11
|
-
🎯 **Conventional Commits**: Follows the [Conventional Commits](https://www.conventionalcommits.org/) specification
|
|
12
|
-
|
|
13
|
-
🔌 **Modular Providers**: Support for multiple AI providers:
|
|
14
|
-
|
|
15
|
-
- ✅ Vercel AI SDK (Google Gemini)
|
|
16
|
-
- 🔜 Vercel AI SDK (OpenAI)
|
|
17
|
-
- 🔜 Groq
|
|
18
|
-
- 🔜 OpenAI Direct
|
|
19
|
-
- 🔜 Google Direct
|
|
20
|
-
- 🔜 Local LLMs (Ollama, LM Studio, etc.)
|
|
21
|
-
|
|
22
|
-
📜 **Commit History Learning**: Analyzes your past commits to personalize suggestions in your style.
|
|
23
|
-
|
|
24
|
-
🔄 **Multi-Commit Mode**: Intelligently splits staged changes into multiple atomic commits.
|
|
25
|
-
|
|
26
|
-
🎫 **Issue Tracker Integration**: Auto-links commits to Jira, GitHub, Linear, and GitLab issues from your branch name.
|
|
27
|
-
|
|
28
|
-
🎨 **Beautiful CLI**: Colorized output with interactive prompts using Inquirer
|
|
29
|
-
|
|
30
|
-
📊 **Smart Analysis**: Analyzes file patterns, additions/deletions, and git diffs
|
|
31
|
-
|
|
32
|
-
⚡ **Fast**: Efficient processing with fallback to rule-based suggestions
|
|
33
|
-
|
|
34
|
-
## Installation
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# Global installation (recommended)
|
|
38
|
-
npm install -g @untools/commitgen
|
|
39
|
-
|
|
40
|
-
# Or use with npx
|
|
41
|
-
npx @untools/commitgen
|
|
42
|
-
````
|
|
43
|
-
|
|
44
|
-
## Quick Start
|
|
45
|
-
|
|
46
|
-
1. **Stage your changes**:
|
|
47
|
-
|
|
48
|
-
<!-- end list -->
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
git add .
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
2. **Generate commit message**:
|
|
55
|
-
|
|
56
|
-
<!-- end list -->
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
commitgen
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
That's it\! If it's your first time, CommitGen will automatically prompt you to configure your API key. The tool will then analyze your changes and suggest commit messages.
|
|
63
|
-
|
|
64
|
-
### First-Time Setup
|
|
65
|
-
|
|
66
|
-
When you run `commitgen` for the first time without an API key, you'll see:
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
⚠️ API key not found for the selected provider.
|
|
70
|
-
? Would you like to configure your API key now? (Y/n)
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Choose "Yes" to set up your configuration, or run `commitgen config` manually anytime.
|
|
74
|
-
|
|
75
|
-
## Usage
|
|
76
|
-
|
|
77
|
-
### Basic Commands
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
# Generate commit message (interactive, all features enabled)
|
|
81
|
-
commitgen
|
|
82
|
-
|
|
83
|
-
# Commit and push in one command
|
|
84
|
-
commitgen --push
|
|
85
|
-
|
|
86
|
-
# Skip git hooks
|
|
87
|
-
commitgen --noverify
|
|
88
|
-
|
|
89
|
-
# Use rule-based suggestions (no AI)
|
|
90
|
-
commitgen --no-ai
|
|
91
|
-
|
|
92
|
-
# Configure AI provider
|
|
93
|
-
commitgen config
|
|
94
|
-
|
|
95
|
-
# Show help
|
|
96
|
-
commitgen --help
|
|
97
|
-
|
|
98
|
-
# Show version
|
|
99
|
-
commitgen --version
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Command-Line Overrides
|
|
103
|
-
|
|
104
|
-
You can temporarily disable new features using flags:
|
|
105
|
-
|
|
106
|
-
```bash
|
|
107
|
-
# Disable history learning for a single commit
|
|
108
|
-
commitgen --no-history
|
|
109
|
-
|
|
110
|
-
# Force or disable multi-commit mode
|
|
111
|
-
commitgen --multi-commit
|
|
112
|
-
commitgen --no-multi-commit
|
|
113
|
-
|
|
114
|
-
# Disable issue linking for a single commit
|
|
115
|
-
commitgen --no-issues
|
|
116
|
-
|
|
117
|
-
# Quick commit without any enhancements
|
|
118
|
-
commitgen --no-history --no-multi-commit --no-issues
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### Configuration
|
|
122
|
-
|
|
123
|
-
The configuration file is stored at `~/.commitgenrc.json`. It stores both your provider settings and your preferences for new features.
|
|
124
|
-
|
|
125
|
-
```json
|
|
126
|
-
{
|
|
127
|
-
"provider": {
|
|
128
|
-
"provider": "vercel-google",
|
|
129
|
-
"model": "gemini-2.5-flash",
|
|
130
|
-
"apiKey": "optional-if-using-env-var"
|
|
131
|
-
},
|
|
132
|
-
"features": {
|
|
133
|
-
"historyLearning": true,
|
|
134
|
-
"multiCommit": true,
|
|
135
|
-
"issueTracking": true
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
You can disable features globally by setting them to `false` in this file.
|
|
141
|
-
|
|
142
|
-
### Environment Variables
|
|
143
|
-
|
|
144
|
-
You can use environment variables instead of storing API keys in the config:
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
# For Google Gemini (via Vercel AI SDK)
|
|
148
|
-
export GOOGLE_GENERATIVE_AI_API_KEY="your-api-key"
|
|
149
|
-
|
|
150
|
-
# Then run without configuring
|
|
151
|
-
commitgen
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## AI Providers
|
|
155
|
-
|
|
156
|
-
### Vercel AI SDK - Google Gemini (Available Now)
|
|
157
|
-
|
|
158
|
-
Uses the [Vercel AI SDK](https://sdk.vercel.ai/) with Google's Gemini models.
|
|
159
|
-
|
|
160
|
-
**Setup:**
|
|
161
|
-
|
|
162
|
-
1. Get a free API key from [Google AI Studio](https://aistudio.google.com/app/apikey)
|
|
163
|
-
2. Run `commitgen config` and select "Vercel AI SDK - Google Gemini"
|
|
164
|
-
3. Enter your API key or set `GOOGLE_GENERATIVE_AI_API_KEY` environment variable
|
|
165
|
-
|
|
166
|
-
**Available Models:**
|
|
167
|
-
|
|
168
|
-
- `gemini-2.5-flash` (Recommended - Fast and efficient)
|
|
169
|
-
- `gemini-2.5-pro` (More capable, higher quality)
|
|
170
|
-
- `gemini-1.5-flash`
|
|
171
|
-
- `gemini-1.5-pro`
|
|
172
|
-
|
|
173
|
-
### Model Selection
|
|
174
|
-
|
|
175
|
-
You can override the default model for a single commit using the `--model` flag:
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
# Use a specific Gemini model
|
|
179
|
-
commitgen --model gemini-1.5-flash
|
|
180
|
-
commitgen --model gemini-2.5-pro
|
|
181
|
-
commitgen --model gemini-1.5-pro
|
|
182
|
-
|
|
183
|
-
# This overrides your configured model temporarily
|
|
184
|
-
# Your config file remains unchanged
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
**Available Models (Google Gemini):**
|
|
188
|
-
|
|
189
|
-
- `gemini-2.5-flash` - Fast and efficient (default)
|
|
190
|
-
- `gemini-2.5-pro` - More capable, higher quality
|
|
191
|
-
- `gemini-1.5-flash` - Previous generation, fast
|
|
192
|
-
- `gemini-1.5-pro` - Previous generation, high quality
|
|
193
|
-
|
|
194
|
-
**When to Use Different Models:**
|
|
195
|
-
|
|
196
|
-
- **Large changesets (100+ files)**: Use `gemini-2.5-pro` for better context understanding
|
|
197
|
-
- **Quick commits**: Use `gemini-2.5-flash` for speed
|
|
198
|
-
- **API rate limiting**: Switch to `gemini-1.5-flash` as a fallback
|
|
199
|
-
- **API overload**: Try different model when one is overloaded
|
|
200
|
-
|
|
201
|
-
**Examples:**
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
# Override model for a complex refactoring
|
|
205
|
-
commitgen --model gemini-2.5-pro
|
|
206
|
-
|
|
207
|
-
# Quick commit with faster model
|
|
208
|
-
commitgen --model gemini-1.5-flash
|
|
209
|
-
|
|
210
|
-
# Combine with other flags
|
|
211
|
-
commitgen --model gemini-2.5-pro --push
|
|
212
|
-
commitgen --model gemini-1.5-flash --no-history
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
**Note:** The model override only applies to the current command. To permanently change your model, use `commitgen config`.
|
|
216
|
-
|
|
217
|
-
### Coming Soon
|
|
218
|
-
|
|
219
|
-
- **Vercel AI SDK - OpenAI**: GPT-4o, GPT-4o-mini
|
|
220
|
-
- **Groq**: Ultra-fast inference with Llama models
|
|
221
|
-
- **OpenAI Direct**: Direct OpenAI API integration
|
|
222
|
-
- **Google Direct**: Direct Google Generative AI integration
|
|
223
|
-
- **Local LLMs**: Ollama, LM Studio, LocalAI support
|
|
224
|
-
|
|
225
|
-
## How It Works
|
|
226
|
-
|
|
227
|
-
1. **Analysis**: Scans your staged git changes
|
|
228
|
-
- File patterns (tests, docs, configs, components)
|
|
229
|
-
- Addition/deletion statistics
|
|
230
|
-
- Git diff content
|
|
231
|
-
2. **AI Generation**: Sends analysis to your configured AI provider
|
|
232
|
-
- Uses a specialized prompt for commit message generation
|
|
233
|
-
- Follows Conventional Commits specification
|
|
234
|
-
- Returns 3-5 contextual suggestions
|
|
235
|
-
3. **Selection**: Interactive prompt to choose or customize
|
|
236
|
-
- Select from AI-generated suggestions
|
|
237
|
-
- Write a custom message
|
|
238
|
-
- Confirm before committing
|
|
239
|
-
4. **Commit**: Executes git commit with your chosen message
|
|
240
|
-
- Optional: Push to remote with `--push` flag
|
|
241
|
-
- Optional: Skip hooks with `--noverify` flag
|
|
242
|
-
|
|
243
|
-
## Core Features in Detail
|
|
244
|
-
|
|
245
|
-
### 📜 Commit History Learning
|
|
246
|
-
|
|
247
|
-
CommitGen now analyzes your past commits to personalize suggestions in your style.
|
|
248
|
-
|
|
249
|
-
**How It Works**
|
|
250
|
-
|
|
251
|
-
- **Automatic Analysis**: Analyzes your last 50 commits to understand your patterns
|
|
252
|
-
- **Smart Caching**: Results cached for 5 minutes to maintain performance
|
|
253
|
-
- **Pattern Recognition**: Identifies your preferred:
|
|
254
|
-
- Commit types (feat, fix, chore, etc.)
|
|
255
|
-
- Scopes and naming conventions
|
|
256
|
-
- Subject length preferences
|
|
257
|
-
- Style preferences (capitalization, emojis, periods)
|
|
258
|
-
|
|
259
|
-
**Usage**
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
# Enabled by default
|
|
263
|
-
commitgen
|
|
264
|
-
|
|
265
|
-
# Disable for a single commit
|
|
266
|
-
commitgen --no-history
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
**What Gets Personalized**
|
|
270
|
-
|
|
271
|
-
- **Type Selection**: Favors your most-used commit types
|
|
272
|
-
- **Subject Length**: Matches your typical message length
|
|
273
|
-
- **Capitalization**: Follows your capitalization style
|
|
274
|
-
- **Punctuation**: Respects your period usage preferences
|
|
275
|
-
|
|
276
|
-
**Example**
|
|
277
|
-
|
|
278
|
-
If your history shows:
|
|
279
|
-
|
|
280
|
-
- 60% of commits are `feat` type
|
|
281
|
-
- Average subject length: 45 characters
|
|
282
|
-
- 90% capitalize first letter
|
|
283
|
-
- 10% use periods
|
|
284
|
-
|
|
285
|
-
Then suggestions will be adjusted to match this style.
|
|
286
|
-
|
|
287
|
-
### 🔄 Multi-Commit Mode
|
|
288
|
-
|
|
289
|
-
Intelligently splits staged changes into multiple atomic commits for better git history.
|
|
290
|
-
|
|
291
|
-
**How It Works**
|
|
292
|
-
|
|
293
|
-
- **Automatic Detection**: Analyzes staged files for distinct concerns
|
|
294
|
-
- **Smart Grouping**: Groups files by:
|
|
295
|
-
- File type (tests, docs, configs, types)
|
|
296
|
-
- Directory structure
|
|
297
|
-
- Functional concerns (API, components, utils)
|
|
298
|
-
- **Logical Ordering**: Commits in the right order (types → config → features → tests → docs)
|
|
299
|
-
|
|
300
|
-
**Usage**
|
|
301
|
-
|
|
302
|
-
```bash
|
|
303
|
-
# Let CommitGen suggest splitting
|
|
304
|
-
commitgen
|
|
305
|
-
|
|
306
|
-
# Force multi-commit mode
|
|
307
|
-
commitgen --multi-commit
|
|
308
|
-
|
|
309
|
-
# Disable multi-commit mode
|
|
310
|
-
commitgen --no-multi-commit
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
**When It Triggers**
|
|
314
|
-
|
|
315
|
-
Multi-commit mode is suggested when:
|
|
316
|
-
|
|
317
|
-
- You have 4+ files changed
|
|
318
|
-
- Files belong to 2+ distinct concerns
|
|
319
|
-
|
|
320
|
-
**Example**
|
|
321
|
-
|
|
322
|
-
Staged Changes:
|
|
323
|
-
|
|
324
|
-
- `src/types.ts`
|
|
325
|
-
- `src/config.ts`
|
|
326
|
-
- `src/components/Button.tsx`
|
|
327
|
-
- `src/components/Button.test.tsx`
|
|
328
|
-
- `README.md`
|
|
329
|
-
|
|
330
|
-
Suggested Commits:
|
|
331
|
-
|
|
332
|
-
1. Type definition updates (1 file)
|
|
333
|
-
- `src/types.ts`
|
|
334
|
-
2. Configuration changes (1 file)
|
|
335
|
-
- `src/config.ts`
|
|
336
|
-
3. Component updates (1 file)
|
|
337
|
-
- `src/components/Button.tsx`
|
|
338
|
-
4. Test additions/updates (1 file)
|
|
339
|
-
- `src/components/Button.test.tsx`
|
|
340
|
-
5. Documentation updates (1 file)
|
|
341
|
-
- `README.md`
|
|
342
|
-
|
|
343
|
-
**Benefits**
|
|
344
|
-
|
|
345
|
-
- **Cleaner History**: Each commit has a single responsibility
|
|
346
|
-
- **Better Rollbacks**: Can revert specific changes without affecting others
|
|
347
|
-
- **Easier Reviews**: Smaller, focused commits are easier to review
|
|
348
|
-
- **Semantic Versioning**: Clear separation of features, fixes, and chores
|
|
349
|
-
|
|
350
|
-
### 🎫 Issue Tracker Integration
|
|
351
|
-
|
|
352
|
-
Auto-links commits to Jira/GitHub/Linear/GitLab issues from branch names.
|
|
353
|
-
|
|
354
|
-
**Supported Platforms**
|
|
355
|
-
|
|
356
|
-
- **Jira**
|
|
357
|
-
- Pattern: `PROJ-123` or `feature/PROJ-123-description`
|
|
358
|
-
- Format: `[PROJ-123]` in subject + footer
|
|
359
|
-
- **GitHub**
|
|
360
|
-
- Pattern: `#123`, `issue-123`, or `123-description`
|
|
361
|
-
- Format: `Closes #123` in footer (auto-closes issues)
|
|
362
|
-
- **Linear**
|
|
363
|
-
- Pattern: `TEAM-123` or `team/TEAM-123-description`
|
|
364
|
-
- Format: `[TEAM-123]` in subject
|
|
365
|
-
- **GitLab**
|
|
366
|
-
- Pattern: Same as GitHub
|
|
367
|
-
- Format: `Closes #123` in footer (auto-closes issues)
|
|
368
|
-
|
|
369
|
-
**How It Works**
|
|
370
|
-
|
|
371
|
-
- **Branch Detection**: Extracts issue ID from current branch name
|
|
372
|
-
- **Type Inference**: Suggests commit type based on branch prefix
|
|
373
|
-
- `feature/` → `feat`
|
|
374
|
-
- `fix/` or `bugfix/` → `fix`
|
|
375
|
-
- `hotfix/` → `fix`
|
|
376
|
-
- `docs/` → `docs`
|
|
377
|
-
- **Auto-Linking**: Adds proper references to commit message
|
|
378
|
-
|
|
379
|
-
**Usage**
|
|
380
|
-
|
|
381
|
-
```bash
|
|
382
|
-
# Enabled by default
|
|
383
|
-
commitgen
|
|
384
|
-
|
|
385
|
-
# Disable for a single commit
|
|
386
|
-
commitgen --no-issues
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
**Examples**
|
|
390
|
-
|
|
391
|
-
- **Jira Integration**
|
|
392
|
-
- Branch: `feature/AUTH-456-oauth-login`
|
|
393
|
-
- Result:
|
|
394
|
-
|
|
395
|
-
```
|
|
396
|
-
feat(auth): add OAuth2 authentication [AUTH-456]
|
|
397
|
-
|
|
398
|
-
Implemented OAuth2 flow with Google provider
|
|
399
|
-
|
|
400
|
-
Jira: AUTH-456
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
- **GitHub Integration**
|
|
404
|
-
- Branch: `fix/123-navigation-bug`
|
|
405
|
-
- Result:
|
|
406
|
-
|
|
407
|
-
```
|
|
408
|
-
fix(navigation): resolve routing issue
|
|
409
|
-
|
|
410
|
-
Fixed navigation bug causing incorrect redirects
|
|
411
|
-
|
|
412
|
-
Closes #123
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
- **Linear Integration**
|
|
416
|
-
- Branch: `ENG-789-refactor-api`
|
|
417
|
-
- Result:
|
|
418
|
-
|
|
419
|
-
```
|
|
420
|
-
refactor(api): simplify endpoint structure [ENG-789]
|
|
421
|
-
|
|
422
|
-
Restructured API endpoints for better organization
|
|
423
|
-
```
|
|
424
|
-
|
|
425
|
-
**Branch Naming Best Practices**
|
|
426
|
-
|
|
427
|
-
For best results, use conventional branch names:
|
|
428
|
-
|
|
429
|
-
```
|
|
430
|
-
# Jira
|
|
431
|
-
feature/PROJ-123-short-description
|
|
432
|
-
fix/PROJ-456-bug-description
|
|
433
|
-
hotfix/PROJ-789-critical-fix
|
|
434
|
-
|
|
435
|
-
# GitHub/GitLab
|
|
436
|
-
feature/123-new-feature
|
|
437
|
-
fix/456-bug-fix
|
|
438
|
-
docs/789-update-readme
|
|
439
|
-
|
|
440
|
-
# Linear
|
|
441
|
-
feature/TEAM-123-description
|
|
442
|
-
refactor/TEAM-456-cleanup
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
### Performance Optimizations
|
|
446
|
-
|
|
447
|
-
All new features are designed with performance in mind:
|
|
448
|
-
|
|
449
|
-
- **Commit History Learning**
|
|
450
|
-
- ✅ Cached Results: 5-minute TTL cache
|
|
451
|
-
- ✅ Limited Analysis: Only last 50 commits
|
|
452
|
-
- ✅ Async Processing: Non-blocking analysis
|
|
453
|
-
- ⚡ Impact: \<50ms overhead
|
|
454
|
-
- **Multi-Commit Mode**
|
|
455
|
-
- ✅ Lazy Evaluation: Only triggers when needed
|
|
456
|
-
- ✅ Pattern Matching: Fast regex-based detection
|
|
457
|
-
- ✅ Incremental Git Ops: Efficient file-specific diffs
|
|
458
|
-
- ⚡ Impact: \~100ms for large changesets
|
|
459
|
-
- **Issue Tracker Integration**
|
|
460
|
-
- ✅ Single Git Call: One branch name fetch
|
|
461
|
-
- ✅ Regex Parsing: No external API calls
|
|
462
|
-
- ✅ Result Caching: Cached per session
|
|
463
|
-
- ⚡ Impact: \<10ms overhead
|
|
464
|
-
|
|
465
|
-
**Combined Overhead**
|
|
466
|
-
|
|
467
|
-
- Typical usage: **+150ms total**
|
|
468
|
-
- Large projects: **+250ms total**
|
|
469
|
-
- All features disabled: **0ms overhead**
|
|
470
|
-
|
|
471
|
-
## Examples
|
|
472
|
-
|
|
473
|
-
### Typical Workflow
|
|
474
|
-
|
|
475
|
-
```bash
|
|
476
|
-
# Make some changes
|
|
477
|
-
vim src/components/Button.tsx
|
|
478
|
-
|
|
479
|
-
# Stage changes
|
|
480
|
-
git add src/components/Button.tsx
|
|
481
|
-
|
|
482
|
-
# Generate and commit
|
|
483
|
-
commitgen
|
|
484
|
-
```
|
|
485
|
-
|
|
486
|
-
Output:
|
|
487
|
-
|
|
488
|
-
```
|
|
489
|
-
🚀 CommitGen - AI-Powered Commit Message Generator
|
|
490
|
-
|
|
491
|
-
📊 Analysis:
|
|
492
|
-
Files changed: 1
|
|
493
|
-
Additions: +45
|
|
494
|
-
Deletions: -12
|
|
495
|
-
|
|
496
|
-
📝 Changed files:
|
|
497
|
-
⚛️ src/components/Button.tsx
|
|
498
|
-
|
|
499
|
-
🤖 Generating commit messages using vercel-google...
|
|
500
|
-
|
|
501
|
-
💡 Suggested commit messages:
|
|
502
|
-
|
|
503
|
-
1. feat(components): add variant prop to Button component
|
|
504
|
-
2. feat(Button): implement new button styles and variants
|
|
505
|
-
3. refactor(components): restructure Button component props
|
|
506
|
-
4. style(Button): update button styling system
|
|
507
|
-
✏️ Write custom message
|
|
508
|
-
|
|
509
|
-
? Choose a commit message: (Use arrow keys)
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
### Configuration Example
|
|
513
|
-
|
|
514
|
-
```bash
|
|
515
|
-
$ commitgen config
|
|
516
|
-
|
|
517
|
-
⚙️ Configure CommitGen
|
|
518
|
-
|
|
519
|
-
? Select AI provider: Vercel AI SDK - Google Gemini
|
|
520
|
-
? Enter your Google AI API key: **********************
|
|
521
|
-
? Select model: Gemini 2.5 Flash (Fast, Recommended)
|
|
522
|
-
|
|
523
|
-
✅ Configuration saved successfully!
|
|
524
|
-
Config file: /Users/you/.commitgenrc.json
|
|
525
|
-
```
|
|
526
|
-
|
|
527
|
-
## Commit Message Format
|
|
528
|
-
|
|
529
|
-
Generated messages follow the Conventional Commits specification:
|
|
530
|
-
|
|
531
|
-
```
|
|
532
|
-
<type>(<scope>): <subject>
|
|
533
|
-
|
|
534
|
-
<body>
|
|
535
|
-
|
|
536
|
-
<footer>
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
**Types:**
|
|
540
|
-
|
|
541
|
-
- `feat`: New feature
|
|
542
|
-
- `fix`: Bug fix
|
|
543
|
-
- `docs`: Documentation changes
|
|
544
|
-
- `style`: Code style changes
|
|
545
|
-
- `refactor`: Code refactoring
|
|
546
|
-
- `perf`: Performance improvements
|
|
547
|
-
- `test`: Test updates
|
|
548
|
-
- `build`: Build system changes
|
|
549
|
-
- `ci`: CI/CD changes
|
|
550
|
-
- `chore`: Maintenance tasks
|
|
551
|
-
- `revert`: Revert previous commit
|
|
552
|
-
|
|
553
|
-
**Example:**
|
|
554
|
-
|
|
555
|
-
```
|
|
556
|
-
feat(auth): add OAuth2 authentication
|
|
557
|
-
|
|
558
|
-
Implemented OAuth2 flow with Google and GitHub providers.
|
|
559
|
-
Added JWT token management and refresh logic.
|
|
560
|
-
|
|
561
|
-
BREAKING CHANGE: Authentication API has changed
|
|
562
|
-
```
|
|
563
|
-
|
|
564
|
-
## Migration Guide
|
|
565
|
-
|
|
566
|
-
### From v0.0.x to v0.1.x
|
|
567
|
-
|
|
568
|
-
- **Breaking Changes**: None
|
|
569
|
-
- **New Features**: All new features (History Learning, Multi-Commit, Issue Tracking) are **enabled by default**.
|
|
570
|
-
- **Recommended Steps**:
|
|
571
|
-
1. Update package: `npm install -g @untools/commitgen@latest`
|
|
572
|
-
2. Test new features: `commitgen` (uses all features)
|
|
573
|
-
3. Configure preferences in `~/.commitgenrc.json` if you wish to disable any features globally.
|
|
574
|
-
4. Update CI/CD workflows to use new flags (e.g., `--no-history`) if desired.
|
|
575
|
-
|
|
576
|
-
### Backward Compatibility
|
|
577
|
-
|
|
578
|
-
All existing commands work exactly as before:
|
|
579
|
-
|
|
580
|
-
```bash
|
|
581
|
-
# These still work identically
|
|
582
|
-
commitgen
|
|
583
|
-
commitgen --push
|
|
584
|
-
commitgen --noverify
|
|
585
|
-
commitgen --no-ai
|
|
586
|
-
```
|
|
587
|
-
|
|
588
|
-
## API for Advanced Users
|
|
589
|
-
|
|
590
|
-
### Programmatic Usage
|
|
591
|
-
|
|
592
|
-
```javascript
|
|
593
|
-
import { CommitGen } from '@untools/commitgen';
|
|
594
|
-
|
|
595
|
-
const commitGen = new CommitGen();
|
|
596
|
-
|
|
597
|
-
await commitGen.run({
|
|
598
|
-
push: false,
|
|
599
|
-
noverify: false,
|
|
600
|
-
useAi: true,
|
|
601
|
-
multiCommit: true,
|
|
602
|
-
learnFromHistory: true,
|
|
603
|
-
linkIssues: true
|
|
604
|
-
});
|
|
605
|
-
```
|
|
606
|
-
|
|
607
|
-
### Custom History Analyzer
|
|
608
|
-
|
|
609
|
-
```javascript
|
|
610
|
-
import { CommitHistoryAnalyzer } from '@untools/commitgen/utils/commit-history';
|
|
611
|
-
|
|
612
|
-
const analyzer = new CommitHistoryAnalyzer();
|
|
613
|
-
const pattern = await analyzer.getCommitPattern();
|
|
614
|
-
|
|
615
|
-
console.log(pattern.commonTypes); // { feat: 30, fix: 15, ... }
|
|
616
|
-
console.log(pattern.avgSubjectLength); // 45
|
|
617
|
-
```
|
|
618
|
-
|
|
619
|
-
### Custom Multi-Commit Logic
|
|
620
|
-
|
|
621
|
-
```javascript
|
|
622
|
-
import { MultiCommitAnalyzer } from '@untools/commitgen/utils/multi-commit';
|
|
623
|
-
|
|
624
|
-
const analyzer = new MultiCommitAnalyzer();
|
|
625
|
-
const shouldSplit = analyzer.shouldSplit(analysis);
|
|
626
|
-
const groups = analyzer.groupFiles(analysis);
|
|
627
|
-
```
|
|
628
|
-
|
|
629
|
-
## Troubleshooting
|
|
630
|
-
|
|
631
|
-
### "No staged changes found"
|
|
632
|
-
|
|
633
|
-
Make sure you've staged your changes:
|
|
634
|
-
|
|
635
|
-
```bash
|
|
636
|
-
git add <files>
|
|
637
|
-
# or
|
|
638
|
-
git add .
|
|
639
|
-
```
|
|
640
|
-
|
|
641
|
-
### "API key is required"
|
|
642
|
-
|
|
643
|
-
Set your API key either:
|
|
644
|
-
|
|
645
|
-
1. Run `commitgen config` to save it in config file
|
|
646
|
-
2. Set environment variable: `export GOOGLE_GENERATIVE_AI_API_KEY="your-key"`
|
|
647
|
-
|
|
648
|
-
### AI generation fails
|
|
649
|
-
|
|
650
|
-
The tool will automatically fall back to rule-based suggestions if AI generation fails. You can also force rule-based mode with `--no-ai`.
|
|
651
|
-
|
|
652
|
-
### History Learning Not Working
|
|
653
|
-
|
|
654
|
-
- **Issue**: "No personalization detected"
|
|
655
|
-
- **Solutions**:
|
|
656
|
-
- Ensure you have at least 5 commits in your repository
|
|
657
|
-
- Check that commits follow conventional commit format
|
|
658
|
-
- Wait 5 minutes for cache to refresh
|
|
659
|
-
|
|
660
|
-
### Multi-Commit Mode Not Triggering
|
|
661
|
-
|
|
662
|
-
- **Issue**: Single commit despite multiple concerns
|
|
663
|
-
- **Solutions**:
|
|
664
|
-
- Ensure you have 4+ files staged
|
|
665
|
-
- Use `--multi-commit` flag to force
|
|
666
|
-
- Check that files have distinct purposes
|
|
667
|
-
|
|
668
|
-
### Issue Reference Not Detected
|
|
669
|
-
|
|
670
|
-
- **Issue**: Branch issue not linked
|
|
671
|
-
- **Solutions**:
|
|
672
|
-
- Check branch naming follows conventions
|
|
673
|
-
- Verify issue ID format matches platform
|
|
674
|
-
- Use `git branch --show-current` to check branch name
|
|
675
|
-
|
|
676
|
-
### Performance Issues
|
|
677
|
-
|
|
678
|
-
- **Issue**: CommitGen feels slow
|
|
679
|
-
- **Solutions**:
|
|
680
|
-
- Disable features individually to identify bottleneck (`--no-history`, etc.)
|
|
681
|
-
- Check git repository size (very large repos may be slower)
|
|
682
|
-
- Clear cache with `rm -rf ~/.commitgen-cache` (if implemented)
|
|
683
|
-
|
|
684
|
-
## Development
|
|
685
|
-
|
|
686
|
-
```bash
|
|
687
|
-
# Clone the repository
|
|
688
|
-
git clone [https://github.com/aevrHQ/untools-commitgen.git](https://github.com/aevrHQ/untools-commitgen.git)
|
|
689
|
-
cd untools-commitgen
|
|
690
|
-
|
|
691
|
-
# Install dependencies
|
|
692
|
-
npm install
|
|
693
|
-
|
|
694
|
-
# Build
|
|
695
|
-
npm run build
|
|
696
|
-
|
|
697
|
-
# Link for local testing
|
|
698
|
-
npm link
|
|
699
|
-
|
|
700
|
-
# Run
|
|
701
|
-
commitgen
|
|
702
|
-
```
|
|
703
|
-
|
|
704
|
-
## Dependencies
|
|
705
|
-
|
|
706
|
-
```json
|
|
707
|
-
{
|
|
708
|
-
"@ai-sdk/google": "^1.x.x",
|
|
709
|
-
"ai": "^4.x.x",
|
|
710
|
-
"chalk": "^4.1.2",
|
|
711
|
-
"commander": "^13.1.0",
|
|
712
|
-
"inquirer": "^12.5.2"
|
|
713
|
-
}
|
|
714
|
-
```
|
|
715
|
-
|
|
716
|
-
## Contributing
|
|
717
|
-
|
|
718
|
-
Contributions are welcome\! Please feel free to submit a Pull Request.
|
|
719
|
-
|
|
720
|
-
## License
|
|
721
|
-
|
|
722
|
-
MIT © Miracle Onyenma
|
|
723
|
-
|
|
724
|
-
## Links
|
|
725
|
-
|
|
726
|
-
- [GitHub Repository](https://github.com/aevrHQ/untools-commitgen)
|
|
727
|
-
- [npm Package](https://www.npmjs.com/package/@untools/commitgen)
|
|
728
|
-
- [Issue Tracker](https://github.com/aevrHQ/untools-commitgen/issues)
|
|
729
|
-
|
|
730
|
-
-----
|
|
731
|
-
|
|
732
|
-
Made with ❤️ by [Miracle Onyenma](https://github.com/miracleonyenma)
|
|
733
|
-
|
|
734
|
-
```
|