|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
| 15 | +import importlib.metadata |
| 16 | +import random |
15 | 17 | import sys |
16 | 18 | from collections.abc import Callable |
17 | 19 | from functools import wraps |
18 | 20 | from typing import Any, TypeVar, cast |
19 | 21 |
|
20 | 22 | from rich.console import Console |
| 23 | +from rich.panel import Panel |
| 24 | +from rich.table import Table |
21 | 25 |
|
22 | 26 | console = Console() |
23 | 27 |
|
| 28 | +MOTTOS = [ |
| 29 | + "Your agents are cleared for takeoff.", |
| 30 | + "Launching agents into production, one deploy at a time.", |
| 31 | + "Houston, we have an agent.", |
| 32 | + "To production... and beyond!", |
| 33 | + "One small step for code, one giant leap for agents.", |
| 34 | + "Fueling your AI agents with Google Cloud.", |
| 35 | + "3... 2... 1... Agent deployed!", |
| 36 | + "The sky is not the limit when you have agents.", |
| 37 | +] |
| 38 | + |
24 | 39 | F = TypeVar("F", bound=Callable[..., Any]) |
25 | 40 |
|
26 | 41 |
|
| 42 | +def _get_version() -> str: |
| 43 | + """Get the package version, with fallback to 'dev'.""" |
| 44 | + try: |
| 45 | + return importlib.metadata.version("agent-starter-pack") |
| 46 | + except Exception: |
| 47 | + return "dev" |
| 48 | + |
| 49 | + |
| 50 | +def _build_banner(line1: str, version: str, motto: str) -> Panel: |
| 51 | + """Build a compact banner panel with ASP ASCII art logo.""" |
| 52 | + a = "bold blue" |
| 53 | + s = "bold cyan" |
| 54 | + p = "bold magenta" |
| 55 | + logo = ( |
| 56 | + f"[{a}]▄▀▄[/] [{s}]█▀▀[/] [{p}]█▀▄[/]\n" |
| 57 | + f"[{a}]█▀█[/] [{s}]▀▀█[/] [{p}]█▀▀[/]\n" |
| 58 | + f"[{a}]▀ ▀[/] [{s}]▀▀▀[/] [{p}]▀[/] " |
| 59 | + ) |
| 60 | + right_text = f' [italic dim]"{motto}"[/]\n\n {line1}' |
| 61 | + table = Table( |
| 62 | + show_header=False, |
| 63 | + show_edge=False, |
| 64 | + show_lines=False, |
| 65 | + padding=0, |
| 66 | + pad_edge=False, |
| 67 | + ) |
| 68 | + table.add_column(width=12) |
| 69 | + table.add_column() |
| 70 | + table.add_row(logo, right_text) |
| 71 | + return Panel( |
| 72 | + table, |
| 73 | + title=f"Agent Starter Pack v{version}", |
| 74 | + border_style="blue", |
| 75 | + padding=(1, 2), |
| 76 | + ) |
| 77 | + |
| 78 | + |
27 | 79 | def display_welcome_banner( |
28 | | - agent: str | None = None, enhance_mode: bool = False, agent_garden: bool = False |
| 80 | + agent: str | None = None, |
| 81 | + enhance_mode: bool = False, |
| 82 | + agent_garden: bool = False, |
| 83 | + setup_cicd_mode: bool = False, |
| 84 | + register_mode: bool = False, |
| 85 | + quiet: bool = False, |
29 | 86 | ) -> None: |
30 | 87 | """Display the Agent Starter Pack welcome banner. |
31 | 88 |
|
32 | 89 | Args: |
33 | 90 | agent: Optional agent specification to customize the welcome message |
34 | 91 | enhance_mode: Whether this is for enhancement mode |
35 | 92 | agent_garden: Whether this deployment is from Agent Garden |
| 93 | + setup_cicd_mode: Whether this is for CI/CD setup |
| 94 | + register_mode: Whether this is for Gemini Enterprise registration |
| 95 | + quiet: If True, skip the banner (e.g. in auto-approve/programmatic mode) |
36 | 96 | """ |
| 97 | + version = _get_version() |
| 98 | + if quiet: |
| 99 | + console.print(f"[bold blue]Agent Starter Pack[/] [dim]v{version}[/]") |
| 100 | + return |
| 101 | + |
| 102 | + motto = random.choice(MOTTOS) |
| 103 | + |
37 | 104 | if enhance_mode: |
38 | | - console.print( |
39 | | - "\n=== Google Cloud Agent Starter Pack 🚀===", |
40 | | - style="bold blue", |
| 105 | + panel = _build_banner( |
| 106 | + line1="Enhancing your project with production-ready capabilities!", |
| 107 | + version=version, |
| 108 | + motto=motto, |
41 | 109 | ) |
42 | | - console.print( |
43 | | - "Enhancing your existing project with production-ready agent capabilities!\n", |
44 | | - style="green", |
| 110 | + elif setup_cicd_mode: |
| 111 | + panel = _build_banner( |
| 112 | + line1="Setting up CI/CD infrastructure for your agent!", |
| 113 | + version=version, |
| 114 | + motto=motto, |
45 | 115 | ) |
46 | | - elif agent_garden: |
47 | | - console.print( |
48 | | - "\n=== Welcome to Agent Garden! 🌱 ===", |
49 | | - style="bold blue", |
50 | | - ) |
51 | | - console.print( |
52 | | - "Powered by [link=https://goo.gle/agent-starter-pack]Google Cloud - Agent Starter Pack [/link]\n", |
| 116 | + elif register_mode: |
| 117 | + panel = _build_banner( |
| 118 | + line1="Registering your agent to Gemini Enterprise!", |
| 119 | + version=version, |
| 120 | + motto=motto, |
53 | 121 | ) |
54 | | - console.print( |
55 | | - "This tool will help you deploy production-ready AI agents from Agent Garden to Google Cloud!\n" |
| 122 | + elif agent_garden: |
| 123 | + panel = _build_banner( |
| 124 | + line1=( |
| 125 | + "Powered by [link=https://goo.gle/agent-starter-pack]" |
| 126 | + "Google Cloud - Agent Starter Pack[/link]" |
| 127 | + ), |
| 128 | + version=version, |
| 129 | + motto=motto, |
56 | 130 | ) |
57 | 131 | elif agent and agent.startswith("adk@"): |
58 | | - console.print( |
59 | | - "\n=== Welcome to [link=https://github.com/google/adk-samples]google/adk-samples[/link]! ✨ ===", |
60 | | - style="bold blue", |
61 | | - ) |
62 | | - console.print( |
63 | | - "Powered by [link=https://goo.gle/agent-starter-pack]Google Cloud - Agent Starter Pack [/link]\n", |
64 | | - ) |
65 | | - console.print( |
66 | | - "This tool will help you create an end-to-end production-ready AI agent in Google Cloud!\n" |
| 132 | + panel = _build_banner( |
| 133 | + line1=( |
| 134 | + "Powered by [link=https://goo.gle/agent-starter-pack]" |
| 135 | + "Google Cloud - Agent Starter Pack[/link]" |
| 136 | + ), |
| 137 | + version=version, |
| 138 | + motto=motto, |
67 | 139 | ) |
68 | 140 | else: |
69 | | - console.print( |
70 | | - "\n=== Google Cloud Agent Starter Pack 🚀===", |
71 | | - style="bold blue", |
72 | | - ) |
73 | | - console.print("Welcome to the Agent Starter Pack!") |
74 | | - console.print( |
75 | | - "This tool will help you create an end-to-end production-ready AI agent in Google Cloud!\n" |
| 141 | + panel = _build_banner( |
| 142 | + line1="Create production-ready AI agents on Google Cloud!", |
| 143 | + version=version, |
| 144 | + motto=motto, |
76 | 145 | ) |
77 | 146 |
|
| 147 | + console.print() |
| 148 | + console.print(panel) |
| 149 | + |
78 | 150 |
|
79 | 151 | def handle_cli_error(f: F) -> F: |
80 | 152 | """Decorator to handle CLI errors gracefully. |
|
0 commit comments