Coverage for src / osiris_cli / main_v5.py: 0%

52 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-27 17:41 +0200

1#!/usr/bin/env python3 

2""" 

3Osiris CLI v5.0 - Main Entry Point 

4Complete rewrite based on Gemini CLI and Letta Code architectures. 

5""" 

6 

7import typer 

8import asyncio 

9from typing import Optional 

10from pathlib import Path 

11 

12from rich.console import Console 

13from rich.panel import Panel 

14 

15from .config import settings, CONFIG_FILE 

16from .cli_v5 import main as cli_v5_main 

17 

18console = Console() 

19app = typer.Typer( 

20 name="osiris", 

21 help="Osiris CLI v5.0 - Autonomous AGI Terminal", 

22 add_completion=False 

23) 

24 

25 

26def ensure_config() -> bool: 

27 """Ensure configuration exists""" 

28 if not CONFIG_FILE.exists(): 

29 console.print(Panel( 

30 "[bold yellow]⚠️ First Time Setup Required[/bold yellow]\n\n" 

31 "Run: [cyan]osiris setup[/cyan]", 

32 title="Welcome to Osiris v5.0", 

33 border_style="yellow" 

34 )) 

35 return False 

36 return True 

37 

38 

39@app.command() 

40def setup(): 

41 """Interactive setup wizard""" 

42 console.print(Panel( 

43 "[bold cyan]🚀 Osiris v5.0 Setup[/bold cyan]\n\n" 

44 "Let's configure your AI provider...", 

45 title="Setup Wizard", 

46 border_style="cyan" 

47 )) 

48 

49 # Provider selection 

50 providers = { 

51 "1": ("openai", "OpenAI (GPT-4)"), 

52 "2": ("anthropic", "Anthropic (Claude)"), 

53 "3": ("google", "Google (Gemini)"), 

54 "4": ("groq", "Groq (Fast & Free)"), 

55 "5": ("openrouter", "OpenRouter (Many models)"), 

56 } 

57 

58 console.print("\n[bold]Available Providers:[/bold]\n") 

59 for key, (_, name) in providers.items(): 

60 console.print(f" {key}. {name}") 

61 

62 choice = input("\nChoose provider (1-5): ").strip() 

63 

64 if choice in providers: 

65 provider_id, provider_name = providers[choice] 

66 settings.provider = provider_id 

67 

68 # API key 

69 if provider_id != "ollama": 

70 api_key = input(f"\nEnter {provider_name} API key: ").strip() 

71 if api_key: 

72 import os 

73 os.environ[f"{provider_id.upper()}_API_KEY"] = api_key 

74 

75 # Model selection 

76 console.print(f"\n[green]✓[/green] Provider set to: {provider_name}") 

77 

78 # Enable YOLO mode by default 

79 settings.yolo_mode = True 

80 settings.save() 

81 

82 console.print(Panel( 

83 "[bold green]✓ Setup Complete![/bold green]\n\n" 

84 f"Provider: {provider_name}\n" 

85 "Mode: YOLO (autonomous)\n\n" 

86 "Run [cyan]osiris[/cyan] to start!", 

87 title="Success", 

88 border_style="green" 

89 )) 

90 else: 

91 console.print("[red]Invalid choice[/red]") 

92 

93 

94@app.callback(invoke_without_command=True) 

95def main( 

96 ctx: typer.Context, 

97 prompt: Optional[str] = typer.Option(None, "--prompt", "-p", help="One-shot prompt"), 

98 agent: Optional[str] = typer.Option("main", "--agent", "-a", help="Agent name"), 

99 yolo: bool = typer.Option(None, "--yolo", help="Enable/disable YOLO mode"), 

100 model: Optional[str] = typer.Option(None, "--model", "-m", help="Override model"), 

101): 

102 """ 

103 Osiris CLI v5.0 - Autonomous AGI Terminal 

104  

105 Features: 

106 - Autonomous tool execution (no round limits) 

107 - Smart context loading (OSIRIS.md + agent memory) 

108 - Safety limits (max 50 tool calls per turn) 

109 """ 

110 

111 # Apply overrides 

112 if yolo is not None: 

113 settings.yolo_mode = yolo 

114 if model: 

115 settings.default_model = model 

116 

117 # If no subcommand, launch CLI 

118 if ctx.invoked_subcommand is None: 

119 if not ensure_config(): 

120 return 

121 

122 # Migrate tools on first run 

123 try: 

124 from .tool_migration import migrate_tools 

125 except: 

126 pass # Already migrated 

127 

128 # Launch v5 CLI 

129 asyncio.run(cli_v5_main(agent_name=agent, prompt=prompt)) 

130 

131 

132if __name__ == "__main__": 

133 app()