@m3hti/commit-genie 1.1.4 → 1.2.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/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. **History Learning**: Analyzes past commits to learn your project's style (emoji usage, common scopes)
457
- 5. **Ticket Detection**: Extracts ticket references from branch names (e.g., `feature/ABC-123-add-login`)
458
- 6. **Message Generation**: Creates conventional commit messages based on detected patterns
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:
@@ -21,10 +21,62 @@ export declare class AnalyzerService {
21
21
  * Returns true if ALL changes are comments (no code changes)
22
22
  */
23
23
  private static isCommentOnlyChange;
24
+ /**
25
+ * Perform semantic analysis on the diff to understand the nature of changes
26
+ * This provides intent-based understanding rather than line-count metrics
27
+ */
28
+ private static analyzeSemanticChanges;
29
+ /**
30
+ * Detect which roles are affected by the changes and calculate semantic significance
31
+ * Significance is NOT based on line count - it's based on the semantic weight of patterns
32
+ */
33
+ private static detectRoleChanges;
34
+ /**
35
+ * Determine if a pattern represents a high-value semantic change
36
+ */
37
+ private static isHighValuePattern;
38
+ /**
39
+ * Detect the intent for changes in a specific role
40
+ */
41
+ private static detectRoleIntent;
42
+ /**
43
+ * Determine the primary role from all detected role changes
44
+ */
45
+ private static determinePrimaryRole;
46
+ /**
47
+ * Determine the overall intent of the changes
48
+ */
49
+ private static determineIntent;
50
+ /**
51
+ * Extract affected element names (components, functions, etc.) from the diff
52
+ */
53
+ private static extractAffectedElements;
54
+ /**
55
+ * Extract affected elements for a specific role
56
+ */
57
+ private static extractElementsForRole;
58
+ /**
59
+ * Generate a human-readable summary for a role change
60
+ */
61
+ private static generateRoleSummary;
62
+ /**
63
+ * Generate the WHY description for the commit
64
+ */
65
+ private static generateIntentDescription;
66
+ /**
67
+ * Generate the WHAT changed description
68
+ */
69
+ private static generateWhatChanged;
24
70
  /**
25
71
  * Generate a descriptive commit message
72
+ * Uses semantic analysis when available for intent-based descriptions
26
73
  */
27
74
  private static generateDescription;
75
+ /**
76
+ * Generate description based on semantic analysis
77
+ * Creates intent-based messages like "update UserProfile validation logic"
78
+ */
79
+ private static generateSemanticDescription;
28
80
  /**
29
81
  * Determine scope from file paths
30
82
  */
@@ -35,6 +87,7 @@ export declare class AnalyzerService {
35
87
  private static getFileName;
36
88
  /**
37
89
  * Generate commit body for larger changes
90
+ * Includes semantic role context when available
38
91
  */
39
92
  private static generateBody;
40
93
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"analyzerService.d.ts","sourceRoot":"","sources":["../../src/services/analyzerService.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,aAAa,EAA0B,iBAAiB,EAAc,MAAM,UAAU,CAAC;AAuChH,qBAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,cAAc;IAmFvC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAuEpC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAoQlC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IA4B9B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IA+ClC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IA6ElC;;OAE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