@@ -780,136 +780,136 @@ async def install_agent_async():
780780 )
781781 return 1
782782
783- # Pre-flight checks
784- _console .print (f"[bold cyan]🚀 Installing { agent ['name' ]} [/bold cyan]" )
785- _console .print (f"[dim]{ agent .get ('description' , '' )} [/dim]" )
786- _console .print ()
783+ # Pre-flight checks
784+ _console .print (f"[bold cyan]🚀 Installing { agent ['name' ]} [/bold cyan]" )
785+ _console .print (f"[dim]{ agent .get ('description' , '' )} [/dim]" )
786+ _console .print ()
787787
788- # Check system dependencies
789- deps = check_system_dependencies ()
790- missing_deps = [dep for dep , available in deps .items () if not available ]
788+ # Check system dependencies
789+ deps = check_system_dependencies ()
790+ missing_deps = [dep for dep , available in deps .items () if not available ]
791+
792+ if missing_deps :
793+ _console .print ("[yellow]⚠️ Missing system dependencies detected:[/yellow]" )
794+ for dep in missing_deps :
795+ _console .print (f" [red]• { dep } [/red]" )
796+
797+ # Try to auto-install critical dependencies
798+ critical_deps = ["uv" ] # Add more as needed
799+ for dep in critical_deps :
800+ if dep in missing_deps :
801+ if not install_system_dependency (dep ):
802+ _console .print (
803+ f"[red]Cannot proceed without { dep } . Please install it manually.[/red]"
804+ )
805+ return 1
806+
807+ _console .print ()
808+
809+ # Get the install command for current OS
810+ install_command = get_os_command (actions , "install" )
811+ if not install_command :
812+ _console .print ("[red]No installation command found for this agent on your OS.[/red]" )
813+ return 1
791814
792- if missing_deps :
793- _console .print ("[yellow]⚠️ Missing system dependencies detected:[/yellow]" )
794- for dep in missing_deps :
795- _console .print (f" [red]• { dep } [/red]" )
815+ # Check for bootstrap_uv flag
816+ needs_uv_bootstrap = False
817+ for os_actions in actions .values ():
818+ if isinstance (os_actions , dict ) and os_actions .get ("bootstrap_uv" , False ):
819+ needs_uv_bootstrap = True
820+ break
796821
797- # Try to auto-install critical dependencies
798- critical_deps = ["uv" ] # Add more as needed
799- for dep in critical_deps :
800- if dep in missing_deps :
801- if not install_system_dependency (dep ):
802- _console .print (
803- f"[red]Cannot proceed without { dep } . Please install it manually.[/red]"
804- )
805- return 1
822+ # Bootstrap UV if needed
823+ if needs_uv_bootstrap and not deps .get ("uv" , False ):
824+ _console .print ("[cyan]Bootstrapping UV package manager...[/cyan]" )
825+ if not install_system_dependency ("uv" ):
826+ _console .print ("[red]UV bootstrap failed. Cannot proceed.[/red]" )
827+ return 1
806828
829+ _console .print (f"[green]Installing { agent ['name' ]} ...[/green]" )
830+ _console .print (f"[dim]Command: { install_command } [/dim]" )
807831 _console .print ()
808832
809- # Get the install command for current OS
810- install_command = get_os_command (actions , "install" )
811- if not install_command :
812- _console .print ("[red]No installation command found for this agent on your OS.[/red]" )
813- return 1
814-
815- # Check for bootstrap_uv flag
816- needs_uv_bootstrap = False
817- for os_actions in actions .values ():
818- if isinstance (os_actions , dict ) and os_actions .get ("bootstrap_uv" , False ):
819- needs_uv_bootstrap = True
820- break
821-
822- # Bootstrap UV if needed
823- if needs_uv_bootstrap and not deps .get ("uv" , False ):
824- _console .print ("[cyan]Bootstrapping UV package manager...[/cyan]" )
825- if not install_system_dependency ("uv" ):
826- _console .print ("[red]UV bootstrap failed. Cannot proceed.[/red]" )
827- return 1
828-
829- _console .print (f"[green]Installing { agent ['name' ]} ...[/green]" )
830- _console .print (f"[dim]Command: { install_command } [/dim]" )
831- _console .print ()
833+ # Run the installation command with progress feedback
834+ try :
835+ # Use a more interactive approach for long-running installs
836+ process = subprocess .Popen (
837+ install_command ,
838+ shell = True ,
839+ stdout = subprocess .PIPE ,
840+ stderr = subprocess .PIPE ,
841+ text = True ,
842+ bufsize = 1 ,
843+ universal_newlines = True ,
844+ )
832845
833- # Run the installation command with progress feedback
834- try :
835- # Use a more interactive approach for long-running installs
836- process = subprocess .Popen (
837- install_command ,
838- shell = True ,
839- stdout = subprocess .PIPE ,
840- stderr = subprocess .PIPE ,
841- text = True ,
842- bufsize = 1 ,
843- universal_newlines = True ,
844- )
846+ # Show progress
847+ _console .print ("[cyan]Installation in progress...[/cyan]" )
845848
846- # Show progress
847- _console . print ( "[cyan]Installation in progress...[/cyan]" )
849+ # Wait for completion
850+ stdout , stderr = process . communicate ( )
848851
849- # Wait for completion
850- stdout , stderr = process . communicate ( )
852+ if process . returncode == 0 :
853+ _console . print ( "[green]✓ Installation completed successfully![/green]" )
851854
852- if process .returncode == 0 :
853- _console .print ("[green]✓ Installation completed successfully![/green]" )
855+ # Verify installation
856+ if check_agent_installed (agent ):
857+ _console .print (f"[green]✓ Agent '{ agent ['short_name' ]} ' is ready to use![/green]" )
858+ _console .print (f"[dim]Try: superqode agents connect { agent ['short_name' ]} [/dim]" )
859+ else :
860+ _console .print ("[yellow]⚠️ Agent installed but verification failed[/yellow]" )
861+ _console .print (
862+ "[dim]You may need to restart your shell or check the installation manually[/dim]"
863+ )
854864
855- # Verify installation
856- if check_agent_installed (agent ):
857- _console .print (f"[green]✓ Agent '{ agent ['short_name' ]} ' is ready to use![/green]" )
858- _console .print (f"[dim]Try: superqode agents connect { agent ['short_name' ]} [/dim]" )
865+ return 0
859866 else :
860- _console .print ("[yellow]⚠️ Agent installed but verification failed[/yellow]" )
861- _console .print (
862- f"[dim]You may need to restart your shell or check the installation manually[/dim]"
863- )
867+ _console .print (f"[red]✗ Installation failed (exit code { process .returncode } )[/red]" )
864868
865- return 0
866- else :
867- _console .print (f"[red]✗ Installation failed (exit code { process .returncode } )[/red]" )
869+ # Enhanced error analysis
870+ error_msg = stderr .lower () if stderr else ""
868871
869- # Enhanced error analysis
870- error_msg = stderr .lower () if stderr else ""
872+ if "eacces" in error_msg or "permission denied" in error_msg :
873+ _console .print ("[yellow]💡 Permission Error:[/yellow]" )
874+ _console .print (" This command requires administrator privileges." )
875+ _console .print (f" Try: [bold]sudo { install_command } [/bold]" )
876+ _console .print (
877+ " Or use a Node version manager like nvm/fnm for user-space installation"
878+ )
879+ elif "command not found" in error_msg or "npm: command not found" in error_msg :
880+ _console .print ("[yellow]💡 Missing npm:[/yellow]" )
881+ _console .print (" Node.js/npm is not installed. Install from:" )
882+ _console .print (" https://nodejs.org/ or use your system package manager" )
883+ elif "uv: command not found" in error_msg :
884+ _console .print ("[yellow]💡 Missing UV:[/yellow]" )
885+ _console .print (" UV package manager is not installed. Install with:" )
886+ _console .print (" curl -LsSf https://astral.sh/uv/install.sh | sh" )
887+ elif "certificate" in error_msg or "ssl" in error_msg :
888+ _console .print ("[yellow]💡 SSL/Certificate Error:[/yellow]" )
889+ _console .print (" There may be network or certificate issues." )
890+ _console .print (" Try updating your system's CA certificates." )
891+ else :
892+ # Show the actual error output
893+ if stdout .strip ():
894+ _console .print ("[dim]Output:[/dim]" )
895+ _console .print (stdout .strip ())
896+ if stderr .strip ():
897+ _console .print ("[dim]Error:[/dim]" )
898+ _console .print (stderr .strip ())
871899
872- if "eacces" in error_msg or "permission denied" in error_msg :
873- _console .print ("[yellow]💡 Permission Error:[/yellow]" )
874- _console .print (" This command requires administrator privileges." )
875- _console .print (f" Try: [bold]sudo { install_command } [/bold]" )
876900 _console .print (
877- " Or use a Node version manager like nvm/fnm for user-space installation "
901+ f" \n [dim]💡 Alternative: Try installing manually with: { install_command } [/dim] "
878902 )
879- elif "command not found" in error_msg or "npm: command not found" in error_msg :
880- _console .print ("[yellow]💡 Missing npm:[/yellow]" )
881- _console .print (" Node.js/npm is not installed. Install from:" )
882- _console .print (" https://nodejs.org/ or use your system package manager" )
883- elif "uv: command not found" in error_msg :
884- _console .print ("[yellow]💡 Missing UV:[/yellow]" )
885- _console .print (" UV package manager is not installed. Install with:" )
886- _console .print (" curl -LsSf https://astral.sh/uv/install.sh | sh" )
887- elif "certificate" in error_msg or "ssl" in error_msg :
888- _console .print ("[yellow]💡 SSL/Certificate Error:[/yellow]" )
889- _console .print (" There may be network or certificate issues." )
890- _console .print (" Try updating your system's CA certificates." )
891- else :
892- # Show the actual error output
893- if stdout .strip ():
894- _console .print ("[dim]Output:[/dim]" )
895- _console .print (stdout .strip ())
896- if stderr .strip ():
897- _console .print ("[dim]Error:[/dim]" )
898- _console .print (stderr .strip ())
903+ return 1
899904
905+ except FileNotFoundError :
900906 _console .print (
901- f" \n [dim]💡 Alternative: Try installing manually with: { install_command } [/dim ]"
907+ "[red]Command not found. Please ensure required dependencies are installed.[/red ]"
902908 )
903909 return 1
904-
905- except FileNotFoundError :
906- _console .print (
907- f"[red]Command not found. Please ensure required dependencies are installed.[/red]"
908- )
909- return 1
910- except Exception as e :
911- _console .print (f"[red]Installation error: { e } [/red]" )
912- return 1
910+ except Exception as e :
911+ _console .print (f"[red]Installation error: { e } [/red]" )
912+ return 1
913913
914914 try :
915915 return asyncio .run (install_agent_async ())
0 commit comments