@m3hti/commit-genie 1.2.0 → 1.2.2
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/README.md +41 -3
- package/dist/services/analyzerService.d.ts +59 -0
- package/dist/services/analyzerService.d.ts.map +1 -1
- package/dist/services/analyzerService.js +723 -37
- package/dist/services/analyzerService.js.map +1 -1
- package/dist/services/analyzerService.test.js +130 -0
- package/dist/services/analyzerService.test.js.map +1 -1
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ A CLI tool that generates intelligent Git commit messages by analyzing your stag
|
|
|
30
30
|
- **Custom templates** - Define your own commit message format via config
|
|
31
31
|
- **Commit statistics** - Analyze your repository's commit patterns with `commit-genie stats`
|
|
32
32
|
- **AI-powered descriptions** - Optional LLM integration for smarter commit messages with `--ai`
|
|
33
|
+
- **Semantic role analysis** - Understands code changes by role (UI, logic, data, API, style) for intent-driven messages
|
|
33
34
|
- Shows detailed file change statistics
|
|
34
35
|
- Error handling for edge cases
|
|
35
36
|
|
|
@@ -453,9 +454,10 @@ CommitGenie/
|
|
|
453
454
|
1. **Git Integration**: Executes git commands to retrieve staged changes and diff information
|
|
454
455
|
2. **File Analysis**: Categorizes files by type (test, docs, config, source)
|
|
455
456
|
3. **Pattern Detection**: Analyzes file paths and diff content for keywords
|
|
456
|
-
4. **
|
|
457
|
-
5. **
|
|
458
|
-
6. **
|
|
457
|
+
4. **Semantic Role Analysis**: Identifies what kind of code changed (UI, logic, data, API, etc.) and the intent (add, fix, refactor)
|
|
458
|
+
5. **History Learning**: Analyzes past commits to learn your project's style (emoji usage, common scopes)
|
|
459
|
+
6. **Ticket Detection**: Extracts ticket references from branch names (e.g., `feature/ABC-123-add-login`)
|
|
460
|
+
7. **Message Generation**: Creates intent-driven commit messages based on semantic understanding
|
|
459
461
|
|
|
460
462
|
### Ticket Linking
|
|
461
463
|
|
|
@@ -480,6 +482,42 @@ CommitGenie learns from your project's commit history to match its style:
|
|
|
480
482
|
- **Scope suggestions**: Learns common scopes from history to suggest for your files
|
|
481
483
|
- **Style matching**: Adapts to your team's conventions automatically
|
|
482
484
|
|
|
485
|
+
### Semantic Role Analysis
|
|
486
|
+
|
|
487
|
+
CommitGenie analyzes your code changes at a semantic level to understand **what** changed and **why**, generating intent-driven commit messages:
|
|
488
|
+
|
|
489
|
+
**Detected Roles:**
|
|
490
|
+
| Role | Description | Patterns Detected |
|
|
491
|
+
|------|-------------|-------------------|
|
|
492
|
+
| `ui` | UI/rendering | JSX components, className, onClick, aria-* |
|
|
493
|
+
| `logic` | Business logic | conditionals, loops, try/catch, array methods |
|
|
494
|
+
| `data` | State/data management | useState, useReducer, interfaces, types |
|
|
495
|
+
| `style` | Styling | CSS, styled-components, theme, sx props |
|
|
496
|
+
| `api` | API integration | fetch, axios, useQuery, GraphQL |
|
|
497
|
+
| `config` | Configuration | process.env, settings, constants |
|
|
498
|
+
| `test` | Tests | describe, it, expect, mock |
|
|
499
|
+
|
|
500
|
+
**Detected Intents:**
|
|
501
|
+
- `add` - Adding new functionality
|
|
502
|
+
- `modify` - Updating existing code
|
|
503
|
+
- `fix` - Adding validation, guards, error handling
|
|
504
|
+
- `remove` - Removing code
|
|
505
|
+
- `refactor` - Code restructuring
|
|
506
|
+
- `enhance` - Performance optimizations (memo, useCallback)
|
|
507
|
+
|
|
508
|
+
**Example Output:**
|
|
509
|
+
```
|
|
510
|
+
# Instead of generic messages like:
|
|
511
|
+
✨ feat: update userService.ts
|
|
512
|
+
|
|
513
|
+
# You get intent-driven messages like:
|
|
514
|
+
✨ feat: add UserProfile validation logic
|
|
515
|
+
♻️ refactor: improve API error handling
|
|
516
|
+
🐛 fix: add null check to data processing
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
The semantic analysis considers pattern significance rather than line counts, so a single important change (like adding a new React component) is weighted more heavily than multiple minor changes.
|
|
520
|
+
|
|
483
521
|
### Breaking Change Detection
|
|
484
522
|
|
|
485
523
|
CommitGenie automatically detects breaking changes and formats commit messages according to Conventional Commits specification:
|
|
@@ -16,15 +16,73 @@ export declare class AnalyzerService {
|
|
|
16
16
|
* Check if diff contains actual logic changes (not just formatting)
|
|
17
17
|
*/
|
|
18
18
|
private static hasLogicChanges;
|
|
19
|
+
/**
|
|
20
|
+
* Check if the changes are ONLY non-style JavaScript changes
|
|
21
|
+
* (console.log, debug statements, test prints, comments, etc.)
|
|
22
|
+
* Returns true if JS files have changes but NO actual styling changes
|
|
23
|
+
*/
|
|
24
|
+
private static hasOnlyNonStyleJsChanges;
|
|
19
25
|
/**
|
|
20
26
|
* Check if the diff contains only comment changes (documentation)
|
|
21
27
|
* Returns true if ALL changes are comments (no code changes)
|
|
22
28
|
*/
|
|
23
29
|
private static isCommentOnlyChange;
|
|
30
|
+
/**
|
|
31
|
+
* Perform semantic analysis on the diff to understand the nature of changes
|
|
32
|
+
* This provides intent-based understanding rather than line-count metrics
|
|
33
|
+
*/
|
|
34
|
+
private static analyzeSemanticChanges;
|
|
35
|
+
/**
|
|
36
|
+
* Detect which roles are affected by the changes and calculate semantic significance
|
|
37
|
+
* Significance is NOT based on line count - it's based on the semantic weight of patterns
|
|
38
|
+
*/
|
|
39
|
+
private static detectRoleChanges;
|
|
40
|
+
/**
|
|
41
|
+
* Determine if a pattern represents a high-value semantic change
|
|
42
|
+
*/
|
|
43
|
+
private static isHighValuePattern;
|
|
44
|
+
/**
|
|
45
|
+
* Detect the intent for changes in a specific role
|
|
46
|
+
*/
|
|
47
|
+
private static detectRoleIntent;
|
|
48
|
+
/**
|
|
49
|
+
* Determine the primary role from all detected role changes
|
|
50
|
+
*/
|
|
51
|
+
private static determinePrimaryRole;
|
|
52
|
+
/**
|
|
53
|
+
* Determine the overall intent of the changes
|
|
54
|
+
*/
|
|
55
|
+
private static determineIntent;
|
|
56
|
+
/**
|
|
57
|
+
* Extract affected element names (components, functions, etc.) from the diff
|
|
58
|
+
*/
|
|
59
|
+
private static extractAffectedElements;
|
|
60
|
+
/**
|
|
61
|
+
* Extract affected elements for a specific role
|
|
62
|
+
*/
|
|
63
|
+
private static extractElementsForRole;
|
|
64
|
+
/**
|
|
65
|
+
* Generate a human-readable summary for a role change
|
|
66
|
+
*/
|
|
67
|
+
private static generateRoleSummary;
|
|
68
|
+
/**
|
|
69
|
+
* Generate the WHY description for the commit
|
|
70
|
+
*/
|
|
71
|
+
private static generateIntentDescription;
|
|
72
|
+
/**
|
|
73
|
+
* Generate the WHAT changed description
|
|
74
|
+
*/
|
|
75
|
+
private static generateWhatChanged;
|
|
24
76
|
/**
|
|
25
77
|
* Generate a descriptive commit message
|
|
78
|
+
* Uses semantic analysis when available for intent-based descriptions
|
|
26
79
|
*/
|
|
27
80
|
private static generateDescription;
|
|
81
|
+
/**
|
|
82
|
+
* Generate description based on semantic analysis
|
|
83
|
+
* Creates intent-based messages like "update UserProfile validation logic"
|
|
84
|
+
*/
|
|
85
|
+
private static generateSemanticDescription;
|
|
28
86
|
/**
|
|
29
87
|
* Determine scope from file paths
|
|
30
88
|
*/
|
|
@@ -35,6 +93,7 @@ export declare class AnalyzerService {
|
|
|
35
93
|
private static getFileName;
|
|
36
94
|
/**
|
|
37
95
|
* Generate commit body for larger changes
|
|
96
|
+
* Includes semantic role context when available
|
|
38
97
|
*/
|
|
39
98
|
private static generateBody;
|
|
40
99
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzerService.d.ts","sourceRoot":"","sources":["../../src/services/analyzerService.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"analyzerService.d.ts","sourceRoot":"","sources":["../../src/services/analyzerService.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,cAAc,EAEd,aAAa,EAGb,iBAAiB,EAKlB,MAAM,UAAU,CAAC;AA0NlB,qBAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,cAAc;IA0GvC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