Skip to content

Commit bb658d2

Browse files
committed
feat(analyzer): implement enhanced pattern recognition for v1.1.0
- Add advanced vocabulary analysis with 4 categories (formal, casual, technical, business) - Implement deep commit history analysis with quality metrics - Add style profiling with personalized recommendations - Enhance confidence scoring with multi-factor calculation - Add type frequency and scope preference analysis - Introduce new CLI options: --enhanced, --analyze, --profile - Upgrade HistoryAnalyzer with comprehensive pattern libraries - Maintain backwards compatibility with existing functionality
1 parent 5d273d9 commit bb658d2

File tree

6 files changed

+413
-6
lines changed

6 files changed

+413
-6
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,30 @@ All notable changes to Git-Smart will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.0] - 2025-07-12
9+
10+
### Added
11+
- **Enhanced Pattern Recognition**: Advanced vocabulary and scope analysis with 4 distinct vocabulary categories (formal, casual, technical, business)
12+
- **Deep Commit Analysis**: New `--analyze` option provides detailed breakdown of commit history patterns and quality metrics
13+
- **Style Profiling**: New `--profile` option displays personalized commit style analysis with recommendations
14+
- **Advanced Confidence Scoring**: Multi-factor confidence calculation including consistency, conventional adherence, scope usage, and message quality
15+
- **Type Frequency Analysis**: Tracks and analyzes most commonly used commit types with usage statistics
16+
- **Scope Preference Detection**: Identifies preferred scopes and categorizes them by domain (frontend, backend, devops, testing)
17+
- **Team Recommendations**: Intelligent suggestions for improving commit message consistency and quality
18+
- **Enhanced CLI Options**: New flags `-e/--enhanced`, `-a/--analyze`, `-p/--profile` for advanced features
19+
20+
### Enhanced
21+
- **HistoryAnalyzer**: Completely upgraded with new methods for vocabulary analysis, scope preferences, and confidence calculation
22+
- **Style Guide Generation**: Enhanced with vocabulary style detection and team preference analysis
23+
- **CLI Interface**: Updated help system showcasing v1.1.0 features with comprehensive examples
24+
- **Analysis Depth**: Now analyzes up to 100 commits for better pattern recognition (increased from 50)
25+
26+
### Technical Improvements
27+
- **New Analysis Methods**: `analyzeVocabulary()`, `analyzeScopePreferences()`, `analyzeTypeFrequency()`, `calculateConfidenceFactors()`
28+
- **Enhanced Style Guides**: `generateEnhancedStyleGuide()` with vocabulary style and confidence scoring
29+
- **Backwards Compatibility**: All existing functionality preserved, new features opt-in
30+
- **Pattern Libraries**: Comprehensive vocabulary and scope pattern libraries for intelligent categorization
31+
832
## [1.0.1] - 2025-07-12
933

1034
### Fixed

bin/git-smart.js

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
const { GitSmart } = require('../src/GitSmart')
44
const { parseArgs, showHelp } = require('../src/utils/args')
5+
const { GitUtils } = require('../src/utils/git')
6+
const { HistoryAnalyzer } = require('../src/analyzers/HistoryAnalyzer')
57

68
async function main() {
79
try {
@@ -12,10 +14,17 @@ async function main() {
1214
process.exit(0)
1315
}
1416

17+
// v1.1.0: Handle new analysis options
18+
if (args.analyze || args.profile) {
19+
await handleAnalysisMode(args)
20+
process.exit(0)
21+
}
22+
1523
const gitSmart = new GitSmart({
1624
interactive: args.interactive,
1725
verbose: args.verbose,
18-
dryRun: args.dryRun
26+
dryRun: args.dryRun,
27+
enhanced: args.enhanced // v1.1.0: Pass enhanced option
1928
})
2029

2130
await gitSmart.run()
@@ -28,4 +37,94 @@ async function main() {
2837
}
2938
}
3039

40+
// v1.1.0: New analysis mode for --analyze and --profile options
41+
async function handleAnalysisMode(args) {
42+
try {
43+
// Validate git repository
44+
if (!GitUtils.isGitRepository()) {
45+
throw new Error('Not a git repository')
46+
}
47+
48+
const historyAnalyzer = new HistoryAnalyzer()
49+
const commits = GitUtils.getRecentCommits(100) // More commits for better analysis
50+
const analysis = historyAnalyzer.analyzeCommitHistory(commits)
51+
52+
if (args.analyze) {
53+
displayDetailedAnalysis(analysis)
54+
}
55+
56+
if (args.profile) {
57+
displayStyleProfile(analysis, historyAnalyzer)
58+
}
59+
60+
} catch (error) {
61+
console.error('❌ Analysis Error:', error.message)
62+
throw error
63+
}
64+
}
65+
66+
function displayDetailedAnalysis(analysis) {
67+
console.log('\n📊 Detailed Commit History Analysis')
68+
console.log('=====================================')
69+
70+
console.log(`\n📈 Commit Style: ${analysis.style}`)
71+
console.log(`📏 Average Length: ${analysis.averageLength} characters`)
72+
console.log(`🎯 Tone: ${analysis.tone}`)
73+
74+
if (analysis.vocabularyProfile) {
75+
console.log('\n📝 Vocabulary Analysis:')
76+
console.log(` Formal: ${(analysis.vocabularyProfile.formal * 100).toFixed(1)}%`)
77+
console.log(` Casual: ${(analysis.vocabularyProfile.casual * 100).toFixed(1)}%`)
78+
console.log(` Technical: ${(analysis.vocabularyProfile.technical * 100).toFixed(1)}%`)
79+
console.log(` Business: ${(analysis.vocabularyProfile.business * 100).toFixed(1)}%`)
80+
}
81+
82+
if (analysis.typeFrequency && analysis.typeFrequency.length > 0) {
83+
console.log('\n🏷️ Most Used Commit Types:')
84+
analysis.typeFrequency.slice(0, 5).forEach((type, index) => {
85+
console.log(` ${index + 1}. ${type.type}: ${type.count} times (${(type.frequency * 100).toFixed(1)}%)`)
86+
})
87+
}
88+
89+
if (analysis.confidenceFactors) {
90+
console.log('\n🎯 Quality Metrics:')
91+
console.log(` Consistency: ${(analysis.confidenceFactors.consistency * 100).toFixed(1)}%`)
92+
console.log(` Conventional Adherence: ${(analysis.confidenceFactors.conventionalAdherence * 100).toFixed(1)}%`)
93+
console.log(` Scope Usage: ${(analysis.confidenceFactors.scopeUsage * 100).toFixed(1)}%`)
94+
console.log(` Message Quality: ${(analysis.confidenceFactors.messageQuality * 100).toFixed(1)}%`)
95+
}
96+
}
97+
98+
function displayStyleProfile(analysis, historyAnalyzer) {
99+
console.log('\n👤 Your Commit Style Profile')
100+
console.log('=============================')
101+
102+
const enhancedGuide = historyAnalyzer.generateEnhancedStyleGuide(analysis)
103+
104+
console.log(`\n🎨 Style: ${enhancedGuide.vocabularyStyle || 'balanced'}`)
105+
console.log(`📝 Format: ${enhancedGuide.useConventional ? 'Conventional Commits' : 'Free form'}`)
106+
console.log(`🎯 Confidence Score: ${(enhancedGuide.confidenceScore * 100).toFixed(1)}%`)
107+
108+
if (enhancedGuide.preferredScopes && enhancedGuide.preferredScopes.length > 0) {
109+
console.log('\n🏷️ Your Preferred Scopes:')
110+
enhancedGuide.preferredScopes.forEach((scope, index) => {
111+
console.log(` ${index + 1}. ${scope.scope} (${(scope.frequency * 100).toFixed(1)}%)`)
112+
})
113+
}
114+
115+
if (enhancedGuide.mostUsedTypes && enhancedGuide.mostUsedTypes.length > 0) {
116+
console.log('\n📊 Your Most Used Types:')
117+
enhancedGuide.mostUsedTypes.forEach((type, index) => {
118+
console.log(` ${index + 1}. ${type.type} (${(type.frequency * 100).toFixed(1)}%)`)
119+
})
120+
}
121+
122+
if (enhancedGuide.recommendations && enhancedGuide.recommendations.length > 0) {
123+
console.log('\n💡 Recommendations:')
124+
enhancedGuide.recommendations.forEach((rec, index) => {
125+
console.log(` ${index + 1}. ${rec}`)
126+
})
127+
}
128+
}
129+
31130
main()

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@neabyte/git-smart",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"description": "Intelligent git commit message generator with 18 commit types and 70+ actions. Analyzes code changes, learns from project history, and generates conventional commits offline. Zero dependencies, zero configuration.",
55
"main": "src/GitSmart.js",
66
"bin": {

src/GitSmart.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,23 @@ class GitSmart {
7272
// Verbose logging removed for linting compliance
7373
const commits = GitUtils.getRecentCommits(50)
7474
const historyAnalysis = this.historyAnalyzer.analyzeCommitHistory(commits)
75-
const styleGuide = this.historyAnalyzer.generateStyleGuide(historyAnalysis)
75+
76+
// v1.1.0: Use enhanced style guide generation
77+
const styleGuide = this.options.enhanced
78+
? this.historyAnalyzer.generateEnhancedStyleGuide(historyAnalysis)
79+
: this.historyAnalyzer.generateStyleGuide(historyAnalysis)
80+
7681
// Verbose logging removed for linting compliance
7782
// Add the adaptation method
7883
styleGuide.adaptMessageToStyle = (message, guide) => {
7984
return this.historyAnalyzer.adaptMessageToStyle(message, guide)
8085
}
86+
87+
// v1.1.0: Store enhanced analysis for potential CLI options
88+
if (this.options.enhanced) {
89+
styleGuide.enhancedAnalysis = historyAnalysis
90+
}
91+
8192
return styleGuide
8293
}
8394

0 commit comments

Comments
 (0)