@@ -45,7 +45,7 @@ def __init__(self, test_mode: bool = False, api_key: str | None = None):
4545 self .repo_path = os .path .basename (os .getcwd ())
4646 except Exception :
4747 self .repo_path = "unknown_repo"
48-
48+
4949 self .git = GitOperations ()
5050 self .analyzer = CommitAnalyzer ()
5151 self .ai_service = AIService (api_key = api_key , test_mode = test_mode )
@@ -58,7 +58,7 @@ def _process_single_commit(self, files: list[GitFile]) -> None:
5858 try :
5959 # Start tracking metrics
6060 metrics_manager .start_commit_tracking (repository = self .repo_path )
61-
61+
6262 # Stage files
6363 file_paths = [f .path for f in files ]
6464 self .git .stage_files (file_paths )
@@ -92,36 +92,36 @@ def _process_single_commit(self, files: list[GitFile]) -> None:
9292 prompt_tokens = usage .prompt_tokens ,
9393 completion_tokens = usage .completion_tokens ,
9494 cost_in_eur = usage .total_cost ,
95- model_used = self .ai_service .model
95+ model_used = self .ai_service .model ,
9696 )
9797 sys .exit (0 )
9898
9999 # Create commit
100100 commit_success = self .git .create_commit (suggestion .title , suggestion .format_body ())
101101 if commit_success :
102102 console .print_success ("Changes committed successfully!" )
103-
103+
104104 # Record metrics
105105 metrics_manager .finish_commit_tracking (
106106 files_changed = len (files ),
107107 tokens_used = usage .total_tokens ,
108108 prompt_tokens = usage .prompt_tokens ,
109109 completion_tokens = usage .completion_tokens ,
110110 cost_in_eur = usage .total_cost ,
111- model_used = self .ai_service .model
111+ model_used = self .ai_service .model ,
112112 )
113113 else :
114114 console .print_warning ("No changes were committed. Files may already be committed." )
115115 self .git .reset_staged_changes ()
116-
116+
117117 # Record metrics with 0 files
118118 metrics_manager .finish_commit_tracking (
119119 files_changed = 0 ,
120120 tokens_used = usage .total_tokens ,
121121 prompt_tokens = usage .prompt_tokens ,
122122 completion_tokens = usage .completion_tokens ,
123123 cost_in_eur = usage .total_cost ,
124- model_used = self .ai_service .model
124+ model_used = self .ai_service .model ,
125125 )
126126 sys .exit (0 )
127127
@@ -144,7 +144,7 @@ def _handle_batch(
144144 try :
145145 # Start tracking metrics
146146 metrics_manager .start_commit_tracking (repository = self .repo_path )
147-
147+
148148 # Stage files
149149 file_paths = [f .path for f in batch ]
150150 self .git .stage_files (file_paths )
@@ -173,7 +173,7 @@ def _handle_batch(
173173 if not commit_success :
174174 console .print_warning ("No changes were committed. Files may already be committed." )
175175 self .git .reset_staged_changes ()
176-
176+
177177 # Record metrics with 0 files
178178 metrics_manager .finish_commit_tracking (
179179 files_changed = 0 ,
@@ -184,7 +184,7 @@ def _handle_batch(
184184 model_used = self .ai_service .model ,
185185 batch_processing = True ,
186186 batch_number = batch_num ,
187- batch_total = total_batches
187+ batch_total = total_batches ,
188188 )
189189 return None
190190
@@ -198,7 +198,7 @@ def _handle_batch(
198198 model_used = self .ai_service .model ,
199199 batch_processing = True ,
200200 batch_number = batch_num ,
201- batch_total = total_batches
201+ batch_total = total_batches ,
202202 )
203203
204204 console .print_batch_complete (batch_num , total_batches )
@@ -344,62 +344,69 @@ def stats_command(self) -> None:
344344 """Display usage statistics."""
345345 # Get usage statistics
346346 stats = metrics_manager .get_statistics ()
347-
347+
348348 console .console .print ("\n [bold blue]📊 CommitLoom Usage Statistics[/bold blue]" )
349-
349+
350350 # Display basic stats
351351 console .console .print ("\n [bold cyan]Basic Statistics:[/bold cyan]" )
352352 console .console .print (f" • Total commits generated: { stats .get ('total_commits' , 0 ):,} " )
353353 console .console .print (f" • Total tokens used: { stats .get ('total_tokens' , 0 ):,} " )
354- console .console .print (f" • Total cost: €{ stats .get ('total_cost_in_eur' , 0.0 ):.4f} " )
355- console .console .print (f" • Total files processed: { stats .get ('total_files_processed' , 0 ):,} " )
356-
354+ cost = stats .get ("total_cost_in_eur" , 0.0 )
355+ console .console .print (f" • Total cost: €{ cost :.4f} " )
356+ files = stats .get ("total_files_processed" , 0 )
357+ console .console .print (f" • Total files processed: { files :,} " )
358+
357359 # Display time saved if available
358- if ' time_saved_formatted' in stats :
360+ if " time_saved_formatted" in stats :
359361 console .console .print (f" • Total time saved: { stats ['time_saved_formatted' ]} " )
360-
362+
361363 # Display activity period if available
362- if 'first_used_at' in stats and stats ['first_used_at' ] and 'days_active' in stats :
363- first_used = stats ['first_used_at' ]
364- date_part = first_used .split ('T' )[0 ] if isinstance (first_used , str ) and 'T' in first_used else first_used
364+ if "first_used_at" in stats and stats ["first_used_at" ] and "days_active" in stats :
365+ first_used = stats ["first_used_at" ]
366+ has_t = isinstance (first_used , str ) and "T" in first_used
367+ date_part = first_used .split ("T" )[0 ] if has_t else first_used
365368 console .console .print (f" • Active since: { date_part } " )
366369 console .console .print (f" • Days active: { stats ['days_active' ]} " )
367-
368- if 'avg_commits_per_day' in stats :
369- console .console .print (f" • Average commits per day: { stats ['avg_commits_per_day' ]:.2f} " )
370- console .console .print (f" • Average cost per day: €{ stats ['avg_cost_per_day' ]:.4f} " )
371-
370+
371+ if "avg_commits_per_day" in stats :
372+ avg_commits = stats ["avg_commits_per_day" ]
373+ console .console .print (f" • Average commits per day: { avg_commits :.2f} " )
374+ avg_cost = stats ["avg_cost_per_day" ]
375+ console .console .print (f" • Average cost per day: €{ avg_cost :.4f} " )
376+
372377 # Display repository stats if available
373- repositories = stats .get (' repositories' , {})
378+ repositories = stats .get (" repositories" , {})
374379 if repositories and isinstance (repositories , dict ):
375380 console .console .print ("\n [bold cyan]Repository Activity:[/bold cyan]" )
376- if 'most_active_repository' in stats and stats ['most_active_repository' ]:
377- console .console .print (f" • Most active repository: { stats ['most_active_repository' ]} " )
381+ if "most_active_repository" in stats and stats ["most_active_repository" ]:
382+ most_active = stats ["most_active_repository" ]
383+ console .console .print (f" • Most active repository: { most_active } " )
378384 console .console .print (f" • Repositories used: { len (repositories )} " )
379-
385+
380386 # Display model usage if available
381- model_usage = stats .get (' model_usage' , {})
387+ model_usage = stats .get (" model_usage" , {})
382388 if model_usage and isinstance (model_usage , dict ):
383389 console .console .print ("\n [bold cyan]Model Usage:[/bold cyan]" )
384390 for model , count in model_usage .items ():
385391 console .console .print (f" • { model } : { count } commits" )
386-
392+
387393 # Display batch vs single commits
388394 console .console .print ("\n [bold cyan]Processing Methods:[/bold cyan]" )
389395 console .console .print (f" • Batch commits: { stats .get ('batch_commits' , 0 )} " )
390396 console .console .print (f" • Single commits: { stats .get ('single_commits' , 0 )} " )
391-
397+
392398 # Get more detailed stats if commits exist
393- if stats .get (' total_commits' , 0 ) > 0 :
399+ if stats .get (" total_commits" , 0 ) > 0 :
394400 model_stats = metrics_manager .get_model_usage_stats ()
395401 if model_stats :
396402 console .console .print ("\n [bold cyan]Detailed Model Stats:[/bold cyan]" )
397403 for model , model_data in model_stats .items ():
398404 console .console .print (f" • { model } :" )
399405 console .console .print (f" - Total tokens: { model_data .get ('tokens' , 0 ):,} " )
400406 console .console .print (f" - Total cost: €{ model_data .get ('cost' , 0.0 ):.4f} " )
401- console .console .print (f" - Avg tokens per commit: { model_data .get ('avg_tokens_per_commit' , 0.0 ):.1f} " )
402-
407+ avg_tokens = model_data .get ("avg_tokens_per_commit" , 0.0 )
408+ console .console .print (f" - Avg tokens per commit: { avg_tokens :.1f} " )
409+
403410 def run (
404411 self , auto_commit : bool = False , combine_commits : bool = False , debug : bool = False
405412 ) -> None :
0 commit comments