glaip-sdk 0.0.3__py3-none-any.whl → 0.0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
glaip_sdk/branding.py ADDED
@@ -0,0 +1,145 @@
1
+ """AIP SDK Branding and Visual Identity.
2
+
3
+ Simple, friendly CLI branding for the AI Agent Platform (AIP) SDK.
4
+
5
+ - Platform name: AIP (AI Agent Platform)
6
+ - Version: auto-detected (AIP_VERSION env or importlib.metadata), or passed in
7
+ - Colors: blue / bright_blue, with NO_COLOR/AIP_NO_COLOR fallbacks
8
+
9
+ Author:
10
+ Raymond Christopher (raymond.christopher@gdplabs.id)
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import os
16
+ import platform
17
+ import sys
18
+
19
+ from rich.console import Console
20
+ from rich.panel import Panel
21
+
22
+ try:
23
+ # Python 3.8+ standard way to read installed package version
24
+ from importlib.metadata import PackageNotFoundError
25
+ from importlib.metadata import version as pkg_version
26
+ except Exception: # pragma: no cover
27
+ pkg_version = None
28
+ PackageNotFoundError = Exception
29
+
30
+
31
+ # ---- minimal, readable styles (blue-forward) ---------------------------------
32
+ PRIMARY = "bright_blue"
33
+ BORDER = PRIMARY
34
+ TITLE_STYLE = f"bold {PRIMARY}"
35
+ LABEL = "bold"
36
+
37
+
38
+ class AIPBranding:
39
+ """AIP SDK branding utilities with ASCII banner and version display."""
40
+
41
+ # AIP ASCII art - pixelated style
42
+ AIP_LOGO = r"""
43
+ █████╗ ██╗██████╗
44
+ ██╔══██╗██║██╔══██╗
45
+ ███████║██║██████╔╝
46
+ ██╔══██║██║██╔═══╝
47
+ ██║ ██║██║██║
48
+ ╚═╝ ╚═╝╚═╝╚═╝
49
+ AI Agent Platform
50
+ """.strip("\n")
51
+
52
+ def __init__(
53
+ self,
54
+ version: str | None = None,
55
+ package_name: str | None = None,
56
+ ):
57
+ """
58
+ Args:
59
+ version: Explicit SDK version (overrides auto-detection).
60
+ package_name: If set, attempt to read version from installed package.
61
+ """
62
+ self.version = version or self._auto_version(package_name)
63
+ self.console = self._make_console()
64
+
65
+ # ---- small helpers --------------------------------------------------------
66
+ @staticmethod
67
+ def _auto_version(package_name: str | None) -> str:
68
+ # Priority: env → package metadata → fallback
69
+ env_version = os.getenv("AIP_VERSION")
70
+ if env_version:
71
+ return env_version
72
+ if package_name and pkg_version:
73
+ try:
74
+ return pkg_version(package_name)
75
+ except PackageNotFoundError:
76
+ pass
77
+ return "0.0.0"
78
+
79
+ @staticmethod
80
+ def _make_console() -> Console:
81
+ # Respect NO_COLOR/AIP_NO_COLOR environment variables
82
+ no_color_env = (
83
+ os.getenv("NO_COLOR") is not None or os.getenv("AIP_NO_COLOR") is not None
84
+ )
85
+ if no_color_env:
86
+ color_system = None
87
+ no_color = True
88
+ else:
89
+ color_system = "auto"
90
+ no_color = False
91
+ return Console(color_system=color_system, no_color=no_color, soft_wrap=True)
92
+
93
+ # ---- public API -----------------------------------------------------------
94
+ def get_welcome_banner(self) -> str:
95
+ """Get AIP banner with version info."""
96
+ banner = self.AIP_LOGO
97
+ line = f"Version: {self.version}"
98
+ banner = f"{banner}\n{line}"
99
+ return banner
100
+
101
+ def get_version_info(self) -> dict:
102
+ return {
103
+ "version": self.version,
104
+ "python_version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
105
+ "platform": platform.platform(),
106
+ "architecture": platform.architecture()[0],
107
+ }
108
+
109
+ def display_welcome_panel(self, title: str = "Welcome to AIP") -> None:
110
+ banner = self.get_welcome_banner()
111
+ panel = Panel(
112
+ banner,
113
+ title=f"[{TITLE_STYLE}]{title}[/{TITLE_STYLE}]",
114
+ border_style=BORDER,
115
+ padding=(1, 2),
116
+ )
117
+ self.console.print(panel)
118
+
119
+ def display_version_panel(self) -> None:
120
+ v = self.get_version_info()
121
+ version_text = (
122
+ f"[{TITLE_STYLE}]AIP SDK Version Information[/{TITLE_STYLE}]\n\n"
123
+ f"[{LABEL}]Version:[/] {v['version']}\n"
124
+ f"[{LABEL}]Python:[/] {v['python_version']}\n"
125
+ f"[{LABEL}]Platform:[/] {v['platform']}\n"
126
+ f"[{LABEL}]Architecture:[/] {v['architecture']}"
127
+ )
128
+ panel = Panel(
129
+ version_text,
130
+ title=f"[{TITLE_STYLE}]Version Details[/{TITLE_STYLE}]",
131
+ border_style=BORDER,
132
+ padding=(1, 2),
133
+ )
134
+ self.console.print(panel)
135
+
136
+ def display_status_banner(self, status: str = "ready") -> None:
137
+ # Keep it simple (no emoji); easy to parse in logs/CI
138
+ banner = f"[{LABEL}]AIP[/{LABEL}] - {status.title()}"
139
+ self.console.print(banner)
140
+
141
+ @classmethod
142
+ def create_from_sdk(
143
+ cls, sdk_version: str | None = None, package_name: str | None = None
144
+ ) -> AIPBranding:
145
+ return cls(version=sdk_version, package_name=package_name)