22
33const { GitSmart } = require ( '../src/GitSmart' )
44const { parseArgs, showHelp } = require ( '../src/utils/args' )
5+ const { GitUtils } = require ( '../src/utils/git' )
6+ const { HistoryAnalyzer } = require ( '../src/analyzers/HistoryAnalyzer' )
57
68async 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+
31130main ( )
0 commit comments