-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add frictionless onboarding with praisonai setup wizard and post-install hooks #1453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
395f2b4
feat: implement frictionless onboarding with praisonai setup wizard
praisonai-triage-agent[bot] 5797e0e
fix: harden windows installer command execution and stabilize setup test
Copilot ebe08c8
fix: improve powershell python command parsing diagnostics
Copilot 00806cd
fix: comprehensive setup wizard security and robustness improvements
praisonai-triage-agent[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| """ | ||
| Setup command group for PraisonAI CLI. | ||
|
|
||
| Provides interactive onboarding and configuration wizard. | ||
| """ | ||
|
|
||
| import os | ||
| from pathlib import Path | ||
| from typing import Optional | ||
|
|
||
| import typer | ||
|
|
||
| from ..output.console import get_output_controller | ||
|
|
||
| app = typer.Typer(help="Interactive onboarding / configuration wizard") | ||
|
|
||
| # Default PRAISON_HOME directory | ||
| def get_praison_home() -> Path: | ||
| """Get the PraisonAI home directory.""" | ||
| home = os.getenv("PRAISONAI_HOME") | ||
| if home: | ||
| return Path(home) | ||
| return Path.home() / ".praisonai" | ||
|
|
||
| PRAISON_HOME = get_praison_home() | ||
| ENV_FILE = PRAISON_HOME / ".env" | ||
|
|
||
| # Provider configurations | ||
| PROVIDERS = { | ||
| "1": ("openai", "OPENAI_API_KEY", "gpt-4o-mini"), | ||
| "2": ("anthropic", "ANTHROPIC_API_KEY", "claude-3-5-sonnet-latest"), | ||
| "3": ("google", "GEMINI_API_KEY", "gemini-2.0-flash"), | ||
| "4": ("ollama", None, "llama3.2"), | ||
| "5": ("custom", None, None), | ||
| } | ||
|
|
||
| PROVIDER_NAMES = { | ||
| "openai": ("OpenAI", "OPENAI_API_KEY", "gpt-4o-mini"), | ||
| "anthropic": ("Anthropic", "ANTHROPIC_API_KEY", "claude-3-5-sonnet-latest"), | ||
| "google": ("Google", "GEMINI_API_KEY", "gemini-2.0-flash"), | ||
| "ollama": ("Ollama", None, "llama3.2"), | ||
| "custom": ("Custom", None, None), | ||
| } | ||
|
|
||
|
|
||
| def _run_setup( | ||
| non_interactive: bool = False, | ||
| provider: Optional[str] = None, | ||
| api_key: Optional[str] = None, | ||
| model: Optional[str] = None, | ||
| ) -> int: | ||
| """Run the setup wizard.""" | ||
| try: | ||
| from ..features.setup.handler import SetupHandler | ||
| handler = SetupHandler() | ||
| return handler.execute( | ||
| non_interactive=non_interactive, | ||
| provider=provider, | ||
| api_key=api_key, | ||
| model=model | ||
| ) | ||
| except ImportError as e: | ||
| output = get_output_controller() | ||
| output.print_error(f"Setup module not available: {e}") | ||
| return 4 | ||
| except Exception as e: | ||
| output = get_output_controller() | ||
| output.print_error(f"Setup error: {e}") | ||
| return 1 | ||
|
|
||
|
|
||
| @app.callback(invoke_without_command=True) | ||
| def setup_callback( | ||
| ctx: typer.Context, | ||
| non_interactive: bool = typer.Option(False, "--non-interactive", help="Run in non-interactive mode"), | ||
| provider: Optional[str] = typer.Option(None, "--provider", help="LLM provider (openai, anthropic, google, ollama, custom)"), | ||
| api_key: Optional[str] = typer.Option(None, "--api-key", help="API key for the provider"), | ||
| model: Optional[str] = typer.Option(None, "--model", help="Default model to use"), | ||
| ): | ||
| """Run the onboarding wizard (idempotent — safe to re-run).""" | ||
| if ctx.invoked_subcommand: | ||
| return | ||
|
|
||
| exit_code = _run_setup( | ||
| non_interactive=non_interactive, | ||
| provider=provider, | ||
| api_key=api_key, | ||
| model=model | ||
| ) | ||
| raise typer.Exit(exit_code) | ||
|
|
||
|
|
||
| @app.command("wizard") | ||
| def setup_wizard( | ||
| provider: Optional[str] = typer.Option(None, "--provider", help="LLM provider"), | ||
| api_key: Optional[str] = typer.Option(None, "--api-key", help="API key"), | ||
| model: Optional[str] = typer.Option(None, "--model", help="Default model"), | ||
| ): | ||
| """Run the interactive setup wizard.""" | ||
| exit_code = _run_setup( | ||
| non_interactive=False, | ||
| provider=provider, | ||
| api_key=api_key, | ||
| model=model | ||
| ) | ||
| raise typer.Exit(exit_code) | ||
|
|
||
|
|
||
| @app.command("config") | ||
| def setup_config( | ||
| show: bool = typer.Option(False, "--show", help="Show current configuration"), | ||
| edit: bool = typer.Option(False, "--edit", help="Edit configuration file"), | ||
| ): | ||
| """Manage setup configuration.""" | ||
| output = get_output_controller() | ||
|
|
||
| if show: | ||
| if ENV_FILE.exists(): | ||
| output.console.print(f"[bold]Configuration at {ENV_FILE}:[/bold]") | ||
| content = ENV_FILE.read_text() | ||
| # Don't show actual API keys for security | ||
| lines = [] | ||
| for line in content.split('\n'): | ||
| if '=' in line and any(key in line for key in ['API_KEY', 'TOKEN', 'SECRET']): | ||
| key, _ = line.split('=', 1) | ||
| lines.append(f"{key}=***") | ||
| else: | ||
| lines.append(line) | ||
| output.console.print('\n'.join(lines)) | ||
| else: | ||
| output.print_warning(f"No configuration found at {ENV_FILE}") | ||
| output.console.print("Run [cyan]praisonai setup[/cyan] to create one.") | ||
|
|
||
| if edit: | ||
| import subprocess | ||
| editor = os.getenv("EDITOR", "nano") | ||
| try: | ||
| subprocess.run([editor, str(ENV_FILE)], check=True) | ||
| except subprocess.CalledProcessError: | ||
| output.print_error(f"Failed to open editor: {editor}") | ||
| except FileNotFoundError: | ||
| output.print_error(f"Editor not found: {editor}") | ||
|
|
||
|
|
||
| @app.command("reset") | ||
| def setup_reset( | ||
| force: bool = typer.Option(False, "--force", help="Skip confirmation"), | ||
| ): | ||
| """Reset setup configuration.""" | ||
| output = get_output_controller() | ||
|
|
||
| praison_home = get_praison_home() | ||
| env_file = praison_home / ".env" | ||
| config_file = praison_home / "config.yaml" | ||
| files_to_remove = [path for path in (env_file, config_file) if path.exists()] | ||
|
|
||
| if not files_to_remove: | ||
| output.print_info("No setup configuration to reset.") | ||
| return | ||
|
|
||
| if not force: | ||
| confirm = typer.confirm(f"Reset configuration at {praison_home}?") | ||
| if not confirm: | ||
| output.print_info("Reset cancelled.") | ||
| return | ||
|
|
||
| try: | ||
| for path in files_to_remove: | ||
| path.unlink() | ||
| output.print_success("Configuration reset successfully.") | ||
| output.console.print("Run [cyan]praisonai setup[/cyan] to configure again.") | ||
| except Exception as e: | ||
| output.print_error(f"Failed to reset configuration: {e}") | ||
| raise typer.Exit(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| """ | ||
| Setup feature module for PraisonAI CLI. | ||
|
|
||
| Provides interactive onboarding and configuration management. | ||
| """ | ||
|
|
||
| from .handler import SetupHandler | ||
|
|
||
| __all__ = ["SetupHandler"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a structured remediation hint to config errors.
PraisonAIConfigErrorcapturesconfig_key, but the rendered exception still relies entirely on caller-supplied text for next steps. Add an optional/default remediation hint so setup failures consistently tell users how to recover. As per coding guidelines, "Error handling: Fail fast with clear error messages; include remediation hints in exceptions; propagate context (agent name, tool name, session ID); provide hook points for error interception (on_error events)".Proposed refinement
class PraisonAIConfigError(PraisonAIError): @@ def __init__( self, message: str, config_key: Optional[str] = None, agent_id: str = "unknown", run_id: Optional[str] = None, is_retryable: bool = False, # Config errors need user intervention + remediation_hint: Optional[str] = None, context: Optional[Dict[str, Any]] = None ): context = context or {} if config_key: context.update({"config_key": config_key}) + if remediation_hint is None: + remediation_hint = f"Set {config_key} or run the setup wizard before retrying." + if remediation_hint: + context["remediation_hint"] = remediation_hint + message = f"{message} Remediation: {remediation_hint}" super().__init__( message,🤖 Prompt for AI Agents