@@ -77,7 +77,7 @@ def filter_test_files(
7777
7878 return files_for_review_map
7979
80- app = typer .Typer (add_completion = False )
80+ app = typer .Typer (add_completion = False , invoke_without_command = True )
8181
8282
8383def setup_logging (trace_mode : bool ):
@@ -119,19 +119,9 @@ def load_config(repo_path: str) -> dict:
119119POSSIBLE_FOCUS_AREAS = list (IssueType .__args__ )
120120
121121
122- @app .command ()
123- def review (
124- repo_path : Annotated [str , typer .Option ("--repo-path" , help = "Path to the local Git repository." )] = "." ,
125- base_ref : Annotated [str , typer .Option (help = "The base commit/ref to compare against." )] = "HEAD~1" ,
126- head_ref : Annotated [str , typer .Option (help = "The commit hash or ref to review." )] = "HEAD" ,
127- staged : Annotated [bool , typer .Option (help = "Review only staged files instead of a commit range." )] = False ,
128- focus_from_cli : Annotated [Optional [List [str ]], typer .Option (
129- "-f" , "--focus" ,
130- help = f"Areas of focus. Can be used multiple times. Possible values: { ', ' .join (POSSIBLE_FOCUS_AREAS )} "
131- )] = None ,
132- trace : Annotated [bool , typer .Option (
133- "--trace" , help = "Enable detailed debug logging to the console."
134- )] = False ,
122+ def run_review_logic (
123+ repo_path : str , base_ref : str , head_ref : str , staged : bool ,
124+ focus_from_cli : Optional [List [str ]], trace : bool
135125):
136126 """
137127 Performs an AI-powered, context-aware code review using an iterative context-building approach.
@@ -344,11 +334,29 @@ def review(
344334 else :
345335 logging .info (f"\n Found a total of { len (all_issues )} issue(s)." )
346336
347- def main ():
348- app ()
349337
350- if __name__ == "__main__" :
351- main ()
338+ @app .callback ()
339+ def main_callback (
340+ ctx : typer .Context ,
341+ repo_path : Annotated [str , typer .Option ("--repo-path" )] = "." ,
342+ base_ref : Annotated [str , typer .Option ()] = "HEAD~1" ,
343+ head_ref : Annotated [str , typer .Option ()] = "HEAD" ,
344+ staged : Annotated [bool , typer .Option ()] = False ,
345+ focus_from_cli : Annotated [Optional [List [str ]], typer .Option ("-f" , "--focus" )] = None ,
346+ trace : Annotated [bool , typer .Option ("--trace" )] = False ,
347+ ):
348+ """
349+ AI Code Review Agent.
350+ If no subcommand (like 'assess') is given, this will run the code review by default.
351+ """
352+ if ctx .invoked_subcommand is not None :
353+ return
354+
355+ typer .echo ("Running default command: review" )
356+ run_review_logic (
357+ repo_path = repo_path , base_ref = base_ref , head_ref = head_ref , staged = staged ,
358+ focus_from_cli = focus_from_cli , trace = trace
359+ )
352360
353361@app .command ()
354362def assess (
@@ -399,4 +407,11 @@ def assess(
399407 f"/!\\ The code changes have a **{ relevance .score } %** relevance score to this task.\n \n "
400408 f"**Justification:** { relevance .justification } "
401409 )
402- jira_client .add_comment (task_id , comment_body )
410+ jira_client .add_comment (task_id , comment_body )
411+
412+
413+ def main ():
414+ app ()
415+
416+ if __name__ == "__main__" :
417+ main ()
0 commit comments