@m3hti/commit-genie 1.0.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.
- package/LICENSE +21 -0
- package/README.md +430 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +31 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/generate.d.ts +10 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +313 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/generate.test.d.ts +2 -0
- package/dist/commands/generate.test.d.ts.map +1 -0
- package/dist/commands/generate.test.js +168 -0
- package/dist/commands/generate.test.js.map +1 -0
- package/dist/commands/hook.d.ts +4 -0
- package/dist/commands/hook.d.ts.map +1 -0
- package/dist/commands/hook.js +62 -0
- package/dist/commands/hook.js.map +1 -0
- package/dist/commands/stats.d.ts +6 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +39 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/services/aiService.d.ts +38 -0
- package/dist/services/aiService.d.ts.map +1 -0
- package/dist/services/aiService.js +187 -0
- package/dist/services/aiService.js.map +1 -0
- package/dist/services/analyzerService.d.ts +60 -0
- package/dist/services/analyzerService.d.ts.map +1 -0
- package/dist/services/analyzerService.js +832 -0
- package/dist/services/analyzerService.js.map +1 -0
- package/dist/services/analyzerService.test.d.ts +2 -0
- package/dist/services/analyzerService.test.d.ts.map +1 -0
- package/dist/services/analyzerService.test.js +323 -0
- package/dist/services/analyzerService.test.js.map +1 -0
- package/dist/services/configService.d.ts +25 -0
- package/dist/services/configService.d.ts.map +1 -0
- package/dist/services/configService.js +207 -0
- package/dist/services/configService.js.map +1 -0
- package/dist/services/configService.test.d.ts +2 -0
- package/dist/services/configService.test.d.ts.map +1 -0
- package/dist/services/configService.test.js +165 -0
- package/dist/services/configService.test.js.map +1 -0
- package/dist/services/gitService.d.ts +44 -0
- package/dist/services/gitService.d.ts.map +1 -0
- package/dist/services/gitService.js +217 -0
- package/dist/services/gitService.js.map +1 -0
- package/dist/services/gitService.test.d.ts +2 -0
- package/dist/services/gitService.test.d.ts.map +1 -0
- package/dist/services/gitService.test.js +140 -0
- package/dist/services/gitService.test.js.map +1 -0
- package/dist/services/historyService.d.ts +39 -0
- package/dist/services/historyService.d.ts.map +1 -0
- package/dist/services/historyService.js +195 -0
- package/dist/services/historyService.js.map +1 -0
- package/dist/services/historyService.test.d.ts +2 -0
- package/dist/services/historyService.test.d.ts.map +1 -0
- package/dist/services/historyService.test.js +157 -0
- package/dist/services/historyService.test.js.map +1 -0
- package/dist/services/hookService.d.ts +29 -0
- package/dist/services/hookService.d.ts.map +1 -0
- package/dist/services/hookService.js +164 -0
- package/dist/services/hookService.js.map +1 -0
- package/dist/services/statsService.d.ts +28 -0
- package/dist/services/statsService.d.ts.map +1 -0
- package/dist/services/statsService.js +204 -0
- package/dist/services/statsService.js.map +1 -0
- package/dist/types/index.d.ts +134 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/filePatterns.d.ts +5 -0
- package/dist/utils/filePatterns.d.ts.map +1 -0
- package/dist/utils/filePatterns.js +77 -0
- package/dist/utils/filePatterns.js.map +1 -0
- package/dist/utils/filePatterns.test.d.ts +2 -0
- package/dist/utils/filePatterns.test.d.ts.map +1 -0
- package/dist/utils/filePatterns.test.js +51 -0
- package/dist/utils/filePatterns.test.js.map +1 -0
- package/dist/utils/prompt.d.ts +4 -0
- package/dist/utils/prompt.d.ts.map +1 -0
- package/dist/utils/prompt.js +60 -0
- package/dist/utils/prompt.js.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 M3hTi
|
|
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,430 @@
|
|
|
1
|
+
# CommitGenie
|
|
2
|
+
|
|
3
|
+
A CLI tool that generates intelligent Git commit messages by analyzing your staged code changes using rule-based analysis.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Analyzes staged Git changes automatically
|
|
8
|
+
- Follows [Conventional Commits](https://www.conventionalcommits.org/) format
|
|
9
|
+
- Adds relevant emojis to commit messages based on type
|
|
10
|
+
- Detects commit types based on file patterns and diff content:
|
|
11
|
+
- `✨ feat:` for new features
|
|
12
|
+
- `🐛 fix:` for bug fixes
|
|
13
|
+
- `📚 docs:` for documentation changes
|
|
14
|
+
- `🧪 test:` for test files
|
|
15
|
+
- `🔧 chore:` for configuration changes
|
|
16
|
+
- `♻️ refactor:` for code refactoring
|
|
17
|
+
- `⚡ perf:` for performance improvements
|
|
18
|
+
- `💄 style:` for style changes
|
|
19
|
+
- Automatically determines scope when applicable
|
|
20
|
+
- **Multiple message suggestions** - Choose from different commit message styles
|
|
21
|
+
- **Commit body support** - Automatically generates detailed body for large changes
|
|
22
|
+
- **Ticket/Issue linking** - Auto-detects ticket references from branch names (JIRA, GitHub issues)
|
|
23
|
+
- **Commit history learning** - Learns your project's commit style from past commits
|
|
24
|
+
- **Breaking change detection** - Automatically detects and flags breaking changes with `!` and footer
|
|
25
|
+
- **Dry run mode** - Preview commits without executing with `-d` or `--dry-run`
|
|
26
|
+
- **Custom templates** - Define your own commit message format via config
|
|
27
|
+
- **Commit statistics** - Analyze your repository's commit patterns with `commit-genie stats`
|
|
28
|
+
- **AI-powered descriptions** - Optional LLM integration for smarter commit messages with `--ai`
|
|
29
|
+
- Shows detailed file change statistics
|
|
30
|
+
- Error handling for edge cases
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
### Using npx (Recommended)
|
|
35
|
+
Run directly without installation:
|
|
36
|
+
```bash
|
|
37
|
+
npx @m3hti/commit-genie
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Global Installation
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g @m3hti/commit-genie
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Local Development
|
|
46
|
+
1. Clone the repository:
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/M3hTi/CommitGenie.git
|
|
49
|
+
cd CommitGenie
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
2. Install dependencies:
|
|
53
|
+
```bash
|
|
54
|
+
npm install
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
3. Build the project:
|
|
58
|
+
```bash
|
|
59
|
+
npm run build
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
4. Link the CLI globally (optional):
|
|
63
|
+
```bash
|
|
64
|
+
npm link
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
### Basic Usage
|
|
70
|
+
|
|
71
|
+
1. Stage your changes:
|
|
72
|
+
```bash
|
|
73
|
+
git add <files>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
2. Run CommitGenie:
|
|
77
|
+
```bash
|
|
78
|
+
# Using npx:
|
|
79
|
+
npx @m3hti/commit-genie
|
|
80
|
+
|
|
81
|
+
# Or if installed globally:
|
|
82
|
+
commit-genie
|
|
83
|
+
|
|
84
|
+
# Or for local development:
|
|
85
|
+
npm run dev
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
3. The tool will analyze your changes and suggest a commit message:
|
|
89
|
+
```
|
|
90
|
+
Analyzing staged changes...
|
|
91
|
+
|
|
92
|
+
Staged files:
|
|
93
|
+
+ src/services/userService.ts
|
|
94
|
+
~ src/types/index.ts
|
|
95
|
+
|
|
96
|
+
2 file(s) changed, 45 insertion(s)(+), 3 deletion(s)(-)
|
|
97
|
+
|
|
98
|
+
Suggested commit message:
|
|
99
|
+
──────────────────────────────────────────────────
|
|
100
|
+
|
|
101
|
+
✨ feat: add userService.ts and update 1 file
|
|
102
|
+
|
|
103
|
+
──────────────────────────────────────────────────
|
|
104
|
+
|
|
105
|
+
Breakdown:
|
|
106
|
+
Type: feat
|
|
107
|
+
Description: add userService.ts and update 1 file
|
|
108
|
+
|
|
109
|
+
To commit with this message, run:
|
|
110
|
+
git commit -m "✨ feat: add userService.ts and update 1 file"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Commands
|
|
114
|
+
|
|
115
|
+
- `commit-genie` or `commit-genie generate` - Analyze changes and suggest commit message
|
|
116
|
+
- `commit-genie gen` - Shorthand for generate
|
|
117
|
+
- `commit-genie -c` or `--commit` - Auto-commit with the generated message
|
|
118
|
+
- `commit-genie -d` or `--dry-run` - Preview commit without executing (dry run mode)
|
|
119
|
+
- `commit-genie --ai` - Use AI to generate enhanced commit descriptions
|
|
120
|
+
- `commit-genie -s` or `--single` - Show only one suggestion (skip multiple options)
|
|
121
|
+
- `commit-genie -m` or `--message-only` - Output only the commit message (for scripts/hooks)
|
|
122
|
+
- `commit-genie --no-interactive` - Disable interactive prompts
|
|
123
|
+
- `commit-genie stats` - Show commit statistics for the repository
|
|
124
|
+
- `commit-genie stats -n 200` - Analyze last 200 commits
|
|
125
|
+
- `commit-genie stats --json` - Output statistics as JSON
|
|
126
|
+
- `commit-genie hook install` - Install git prepare-commit-msg hook
|
|
127
|
+
- `commit-genie hook uninstall` - Remove the git hook
|
|
128
|
+
- `commit-genie hook status` - Check if hook is installed
|
|
129
|
+
- `commit-genie config init` - Create a default config file
|
|
130
|
+
- `commit-genie config show` - Show current configuration
|
|
131
|
+
- `commit-genie --help` - Show help
|
|
132
|
+
- `commit-genie --version` - Show version
|
|
133
|
+
|
|
134
|
+
### Dry Run Mode
|
|
135
|
+
|
|
136
|
+
Preview exactly what would be committed without making any changes:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
commit-genie -d
|
|
140
|
+
# or
|
|
141
|
+
commit-genie --dry-run
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
This displays:
|
|
145
|
+
- All files that would be committed (with status)
|
|
146
|
+
- The generated commit message
|
|
147
|
+
- Message breakdown (type, scope, description)
|
|
148
|
+
- Alternative suggestions available
|
|
149
|
+
- The exact git command that would be executed
|
|
150
|
+
|
|
151
|
+
Example output:
|
|
152
|
+
```
|
|
153
|
+
════════════════════════════════════════════════════════════
|
|
154
|
+
DRY RUN - No changes will be made
|
|
155
|
+
════════════════════════════════════════════════════════════
|
|
156
|
+
|
|
157
|
+
📁 Files to be committed:
|
|
158
|
+
────────────────────────────────────
|
|
159
|
+
+ src/newFeature.ts (added)
|
|
160
|
+
~ src/utils/helper.ts (modified)
|
|
161
|
+
|
|
162
|
+
Total: 2 file(s), +45/-3 lines
|
|
163
|
+
|
|
164
|
+
📝 Commit message:
|
|
165
|
+
────────────────────────────────────
|
|
166
|
+
✨ feat: add newFeature.ts and update helper
|
|
167
|
+
|
|
168
|
+
🔍 Breakdown:
|
|
169
|
+
────────────────────────────────────
|
|
170
|
+
Type: feat
|
|
171
|
+
Description: add newFeature.ts and update helper
|
|
172
|
+
|
|
173
|
+
⚡ Command that would be executed:
|
|
174
|
+
────────────────────────────────────
|
|
175
|
+
git commit -m "✨ feat: add newFeature.ts and update helper"
|
|
176
|
+
|
|
177
|
+
════════════════════════════════════════════════════════════
|
|
178
|
+
To commit, run: commit-genie -c
|
|
179
|
+
Or interactively: commit-genie
|
|
180
|
+
════════════════════════════════════════════════════════════
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Interactive Mode
|
|
184
|
+
|
|
185
|
+
By default, CommitGenie runs in interactive mode. After analyzing your changes, you'll be prompted to:
|
|
186
|
+
- **[c]** Commit with the suggested message
|
|
187
|
+
- **[e]** Edit the message before committing
|
|
188
|
+
- **[n]** Cancel and do nothing
|
|
189
|
+
|
|
190
|
+
### Git Hook Integration
|
|
191
|
+
|
|
192
|
+
Install a git hook to automatically generate commit messages:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
commit-genie hook install
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
This installs a `prepare-commit-msg` hook that suggests messages when you run `git commit`.
|
|
199
|
+
|
|
200
|
+
### Configuration
|
|
201
|
+
|
|
202
|
+
Create a `.commitgenierc.json` file to customize behavior:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
commit-genie config init
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Example configuration:
|
|
209
|
+
|
|
210
|
+
```json
|
|
211
|
+
{
|
|
212
|
+
"scopes": [
|
|
213
|
+
{ "pattern": "src/api", "scope": "api" },
|
|
214
|
+
{ "pattern": "src/components", "scope": "ui" }
|
|
215
|
+
],
|
|
216
|
+
"defaultType": "feat",
|
|
217
|
+
"includeEmoji": true,
|
|
218
|
+
"maxMessageLength": 72,
|
|
219
|
+
"ticketLinking": {
|
|
220
|
+
"enabled": true,
|
|
221
|
+
"patterns": ["[A-Z]{2,10}-\\d+", "#\\d+"],
|
|
222
|
+
"prefix": "Refs:"
|
|
223
|
+
},
|
|
224
|
+
"learnFromHistory": {
|
|
225
|
+
"enabled": true,
|
|
226
|
+
"commitCount": 50
|
|
227
|
+
},
|
|
228
|
+
"breakingChangeDetection": {
|
|
229
|
+
"enabled": true,
|
|
230
|
+
"keywords": ["breaking", "removed", "deleted", "deprecated"],
|
|
231
|
+
"includeFooter": true
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Configuration options:
|
|
237
|
+
- `scopes` - Map file path patterns to commit scopes
|
|
238
|
+
- `defaultType` - Default commit type when none is detected
|
|
239
|
+
- `includeEmoji` - Include emoji prefix in commit messages (default: learned from history)
|
|
240
|
+
- `maxMessageLength` - Maximum length for commit messages
|
|
241
|
+
- `ticketLinking` - Auto-detect ticket references from branch names
|
|
242
|
+
- `enabled` - Enable/disable ticket linking (default: `true`)
|
|
243
|
+
- `patterns` - Custom regex patterns for ticket detection
|
|
244
|
+
- `prefix` - Footer prefix like "Refs:", "Closes:", "Fixes:" (default: `"Refs:"`)
|
|
245
|
+
- `learnFromHistory` - Learn commit style from past commits
|
|
246
|
+
- `enabled` - Enable/disable history learning (default: `true`)
|
|
247
|
+
- `commitCount` - Number of commits to analyze (default: `50`)
|
|
248
|
+
- `breakingChangeDetection` - Detect and flag breaking changes
|
|
249
|
+
- `enabled` - Enable/disable breaking change detection (default: `true`)
|
|
250
|
+
- `keywords` - Custom keywords to detect breaking changes
|
|
251
|
+
- `includeFooter` - Include `BREAKING CHANGE:` footer (default: `true`)
|
|
252
|
+
|
|
253
|
+
## Development
|
|
254
|
+
|
|
255
|
+
### Scripts
|
|
256
|
+
|
|
257
|
+
- `npm run build` - Compile TypeScript to JavaScript
|
|
258
|
+
- `npm run dev` - Run in development mode with ts-node
|
|
259
|
+
- `npm run watch` - Watch mode for development
|
|
260
|
+
- `npm start` - Run the compiled version
|
|
261
|
+
|
|
262
|
+
### Project Structure
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
CommitGenie/
|
|
266
|
+
├── src/
|
|
267
|
+
│ ├── index.ts # CLI entry point
|
|
268
|
+
│ ├── commands/
|
|
269
|
+
│ │ ├── generate.ts # Generate command implementation
|
|
270
|
+
│ │ ├── hook.ts # Git hook management commands
|
|
271
|
+
│ │ └── config.ts # Configuration commands
|
|
272
|
+
│ ├── services/
|
|
273
|
+
│ │ ├── gitService.ts # Git operations
|
|
274
|
+
│ │ ├── analyzerService.ts # Change analysis logic
|
|
275
|
+
│ │ ├── historyService.ts # Ticket detection & history learning
|
|
276
|
+
│ │ ├── hookService.ts # Git hook installation
|
|
277
|
+
│ │ └── configService.ts # Configuration loading
|
|
278
|
+
│ ├── utils/
|
|
279
|
+
│ │ ├── filePatterns.ts # File type detection
|
|
280
|
+
│ │ └── prompt.ts # Interactive prompts
|
|
281
|
+
│ └── types/
|
|
282
|
+
│ └── index.ts # TypeScript type definitions
|
|
283
|
+
├── dist/ # Compiled output
|
|
284
|
+
├── package.json
|
|
285
|
+
├── tsconfig.json
|
|
286
|
+
└── README.md
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## How It Works
|
|
290
|
+
|
|
291
|
+
1. **Git Integration**: Executes git commands to retrieve staged changes and diff information
|
|
292
|
+
2. **File Analysis**: Categorizes files by type (test, docs, config, source)
|
|
293
|
+
3. **Pattern Detection**: Analyzes file paths and diff content for keywords
|
|
294
|
+
4. **History Learning**: Analyzes past commits to learn your project's style (emoji usage, common scopes)
|
|
295
|
+
5. **Ticket Detection**: Extracts ticket references from branch names (e.g., `feature/ABC-123-add-login`)
|
|
296
|
+
6. **Message Generation**: Creates conventional commit messages based on detected patterns
|
|
297
|
+
|
|
298
|
+
### Ticket Linking
|
|
299
|
+
|
|
300
|
+
CommitGenie automatically detects ticket references from your branch name and appends them to commit messages:
|
|
301
|
+
|
|
302
|
+
- **JIRA-style**: `ABC-123`, `PROJ-1234`
|
|
303
|
+
- **GitHub/GitLab issues**: `#123`, `#456`
|
|
304
|
+
- **Underscore style**: `ABC_123`
|
|
305
|
+
|
|
306
|
+
Example: If you're on branch `feature/ABC-123-add-login`, the commit message will include:
|
|
307
|
+
```
|
|
308
|
+
✨ feat: add login functionality
|
|
309
|
+
|
|
310
|
+
Refs: ABC-123
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### History Learning
|
|
314
|
+
|
|
315
|
+
CommitGenie learns from your project's commit history to match its style:
|
|
316
|
+
|
|
317
|
+
- **Emoji detection**: If 30%+ of past commits use emojis, new commits will include them
|
|
318
|
+
- **Scope suggestions**: Learns common scopes from history to suggest for your files
|
|
319
|
+
- **Style matching**: Adapts to your team's conventions automatically
|
|
320
|
+
|
|
321
|
+
### Breaking Change Detection
|
|
322
|
+
|
|
323
|
+
CommitGenie automatically detects breaking changes and formats commit messages according to Conventional Commits specification:
|
|
324
|
+
|
|
325
|
+
**Detection methods:**
|
|
326
|
+
- **Keywords in diff**: Detects words like `breaking`, `removed`, `deleted`, `deprecated`
|
|
327
|
+
- **Deleted source files**: Flags removal of `.ts`, `.js`, `.py`, etc. as potentially breaking
|
|
328
|
+
- **Code patterns**: Identifies removed exports, deleted functions, and changed interfaces
|
|
329
|
+
|
|
330
|
+
**Output format:**
|
|
331
|
+
When a breaking change is detected, the commit message includes:
|
|
332
|
+
1. A `!` suffix on the commit type (e.g., `feat!:` instead of `feat:`)
|
|
333
|
+
2. A `BREAKING CHANGE:` footer explaining the change
|
|
334
|
+
|
|
335
|
+
Example output:
|
|
336
|
+
```
|
|
337
|
+
✨ feat!: remove legacy authentication endpoint
|
|
338
|
+
|
|
339
|
+
BREAKING CHANGE: Removed deprecated /auth/v1 endpoint
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Customization:**
|
|
343
|
+
- Disable detection entirely with `breakingChangeDetection.enabled: false`
|
|
344
|
+
- Add custom keywords with `breakingChangeDetection.keywords`
|
|
345
|
+
- Toggle the footer with `breakingChangeDetection.includeFooter`
|
|
346
|
+
|
|
347
|
+
### Custom Templates
|
|
348
|
+
|
|
349
|
+
Define your own commit message format using placeholders:
|
|
350
|
+
|
|
351
|
+
```json
|
|
352
|
+
{
|
|
353
|
+
"templates": {
|
|
354
|
+
"default": "{emoji} {type}({scope}): {description}",
|
|
355
|
+
"noScope": "{emoji} {type}: {description}",
|
|
356
|
+
"withBody": "{emoji} {type}({scope}): {description}\n\n{body}"
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**Available placeholders:**
|
|
362
|
+
- `{emoji}` - The commit type emoji (e.g., ✨, 🐛)
|
|
363
|
+
- `{type}` - The commit type with breaking indicator (e.g., `feat`, `feat!`)
|
|
364
|
+
- `{scope}` - The scope if detected
|
|
365
|
+
- `{description}` - The commit description
|
|
366
|
+
|
|
367
|
+
### Commit Statistics
|
|
368
|
+
|
|
369
|
+
Analyze your repository's commit patterns:
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
commit-genie stats
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
This shows:
|
|
376
|
+
- Total commits and average message length
|
|
377
|
+
- Conventional commits and emoji usage percentages
|
|
378
|
+
- Commits breakdown by type, scope, and author
|
|
379
|
+
- Top contributors with medals
|
|
380
|
+
- Recent 7-day activity chart
|
|
381
|
+
- Monthly commit trends
|
|
382
|
+
|
|
383
|
+
Options:
|
|
384
|
+
- `-n, --count <number>` - Number of commits to analyze (default: 100)
|
|
385
|
+
- `--json` - Output as JSON for programmatic use
|
|
386
|
+
|
|
387
|
+
### AI-Powered Descriptions
|
|
388
|
+
|
|
389
|
+
Get smarter commit messages using AI (optional):
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
commit-genie --ai
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**Setup:**
|
|
396
|
+
1. Add your API key to config:
|
|
397
|
+
```json
|
|
398
|
+
{
|
|
399
|
+
"ai": {
|
|
400
|
+
"enabled": true,
|
|
401
|
+
"provider": "openai",
|
|
402
|
+
"apiKey": "sk-...",
|
|
403
|
+
"model": "gpt-4o-mini"
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
2. Supported providers:
|
|
409
|
+
- **OpenAI**: `gpt-4o-mini`, `gpt-4o`, `gpt-4-turbo`
|
|
410
|
+
- **Anthropic**: `claude-3-haiku-20240307`, `claude-3-sonnet-20240229`
|
|
411
|
+
|
|
412
|
+
The AI analyzes your diff and generates contextually aware descriptions while following Conventional Commits format.
|
|
413
|
+
|
|
414
|
+
## Error Handling
|
|
415
|
+
|
|
416
|
+
The tool handles common error cases:
|
|
417
|
+
|
|
418
|
+
- Not in a git repository - Shows error and exits
|
|
419
|
+
- No staged changes - Prompts user to stage files first
|
|
420
|
+
- Git command failures - Shows descriptive error messages
|
|
421
|
+
|
|
422
|
+
## Requirements
|
|
423
|
+
|
|
424
|
+
- Node.js >= 16.0.0
|
|
425
|
+
- Git installed and accessible from command line
|
|
426
|
+
- Must be run inside a git repository
|
|
427
|
+
|
|
428
|
+
## License
|
|
429
|
+
|
|
430
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,SAoBhC;AAED,wBAAgB,iBAAiB,SAIhC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configInitCommand = configInitCommand;
|
|
4
|
+
exports.configShowCommand = configShowCommand;
|
|
5
|
+
const configService_1 = require("../services/configService");
|
|
6
|
+
function configInitCommand() {
|
|
7
|
+
console.log('Creating CommitGenie config file...\n');
|
|
8
|
+
const result = configService_1.ConfigService.initConfig();
|
|
9
|
+
if (result.success) {
|
|
10
|
+
console.log(`✓ ${result.message}`);
|
|
11
|
+
if (result.path) {
|
|
12
|
+
console.log(` Location: ${result.path}`);
|
|
13
|
+
}
|
|
14
|
+
console.log('\nYou can customize:');
|
|
15
|
+
console.log(' - scopes: Map file patterns to scope names');
|
|
16
|
+
console.log(' - defaultType: Default commit type (feat, fix, etc.)');
|
|
17
|
+
console.log(' - maxMessageLength: Maximum commit message length');
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
console.log(`✗ ${result.message}`);
|
|
21
|
+
if (result.path) {
|
|
22
|
+
console.log(` Existing file: ${result.path}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function configShowCommand() {
|
|
27
|
+
const config = configService_1.ConfigService.getConfig();
|
|
28
|
+
console.log('Current CommitGenie configuration:\n');
|
|
29
|
+
console.log(JSON.stringify(config, null, 2));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":";;AAEA,8CAoBC;AAED,8CAIC;AA5BD,6DAA0D;AAE1D,SAAgB,iBAAiB;IAC/B,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;IAErD,MAAM,MAAM,GAAG,6BAAa,CAAC,UAAU,EAAE,CAAC;IAE1C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACnC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,eAAe,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,wDAAwD,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IACrE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACnC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,oBAAoB,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAgB,iBAAiB;IAC/B,MAAM,MAAM,GAAG,6BAAa,CAAC,SAAS,EAAE,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface GenerateOptions {
|
|
2
|
+
commit?: boolean;
|
|
3
|
+
dryRun?: boolean;
|
|
4
|
+
ai?: boolean;
|
|
5
|
+
interactive?: boolean;
|
|
6
|
+
messageOnly?: boolean;
|
|
7
|
+
single?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function generateCommand(options?: GenerateOptions): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,eAAe,CAAC,OAAO,GAAE,eAAoB,iBAoIlE"}
|