testzeus-cli 0.0.17__tar.gz → 0.0.19__tar.gz

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.
Files changed (35) hide show
  1. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/PKG-INFO +30 -4
  2. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/README.md +24 -0
  3. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/pyproject.toml +14 -6
  4. testzeus_cli-0.0.19/testzeus_cli/auth.py +452 -0
  5. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/cli.py +29 -1
  6. testzeus_cli-0.0.19/testzeus_cli/commands/daemon.py +270 -0
  7. testzeus_cli-0.0.19/testzeus_cli/commands/knowledge_bases.py +87 -0
  8. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/test_data.py +1 -1
  9. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/test_run_groups.py +1 -1
  10. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/test_runs.py +22 -4
  11. testzeus_cli-0.0.19/testzeus_cli/commands/tests_authoring.py +801 -0
  12. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/config.py +21 -12
  13. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/utils/auth.py +27 -1
  14. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/utils/client.py +17 -2
  15. testzeus_cli-0.0.19/testzeus_cli/utils/profile.py +151 -0
  16. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/utils/validators.py +2 -2
  17. testzeus_cli-0.0.17/testzeus_cli/auth.py +0 -134
  18. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/LICENSE +0 -0
  19. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/__init__.py +0 -0
  20. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/__init__.py +0 -0
  21. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/environments.py +0 -0
  22. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/extensions.py +0 -0
  23. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/hypermind_code_blocks.py +0 -0
  24. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/notification_channels.py +0 -0
  25. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/tags.py +0 -0
  26. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/test_report_schedules.py +0 -0
  27. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/test_suite_node_runs.py +0 -0
  28. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/test_suite_runs.py +0 -0
  29. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/test_suite_schedules.py +0 -0
  30. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/test_suites.py +0 -0
  31. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/tests.py +0 -0
  32. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/tests_ai_generator.py +0 -0
  33. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/commands/user_integrations.py +0 -0
  34. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/utils/__init__.py +0 -0
  35. {testzeus_cli-0.0.17 → testzeus_cli-0.0.19}/testzeus_cli/utils/formatters.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testzeus-cli
3
- Version: 0.0.17
3
+ Version: 0.0.19
4
4
  Summary: Command-line interface for TestZeus testing platform
5
5
  License-File: LICENSE
6
6
  Author: Shriyansh Agnihotri
@@ -11,16 +11,18 @@ Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
13
  Classifier: Programming Language :: Python :: 3.13
14
- Requires-Dist: aiohttp (>=3.13.3,<4.0.0)
14
+ Provides-Extra: daemon
15
+ Requires-Dist: Pygments (==2.20.0)
16
+ Requires-Dist: aiohttp (==3.13.4)
15
17
  Requires-Dist: click (>=8.1.3,<9.0.0)
16
- Requires-Dist: cryptography (>=46.0.5,<47.0.0)
18
+ Requires-Dist: cryptography (==46.0.7)
17
19
  Requires-Dist: ipdb (>=0.13.13,<0.14.0)
18
20
  Requires-Dist: keyring (>=24.0.0,<25.0.0)
19
21
  Requires-Dist: pocketbase (>=0.15.0,<0.16.0)
20
22
  Requires-Dist: pydantic (>=2.0.0,<3.0.0)
21
23
  Requires-Dist: pyyaml (>=6.0,<7.0)
22
24
  Requires-Dist: rich (>=13.3.1,<14.0.0)
23
- Requires-Dist: testzeus-sdk (>=0.0.15,<0.0.16)
25
+ Requires-Dist: testzeus-sdk (>=0.0.17,<0.0.18)
24
26
  Requires-Dist: toml (>=0.10.2,<0.11.0)
25
27
  Project-URL: Repository, https://github.com/test-zeus-ai/testzeus-cli
26
28
  Description-Content-Type: text/markdown
@@ -940,6 +942,30 @@ downloads/
940
942
  **Options:**
941
943
  - `--output-dir`: Base directory to save attachments (default: downloads)
942
944
 
945
+ ## Test Authoring
946
+
947
+ Create tests via interactive wizard or quick mode.
948
+
949
+ ### Wizard Mode
950
+ Interactive multi-step wizard for guided test creation:
951
+ ```bash
952
+ testzeus tests-authoring wizard
953
+ ```
954
+
955
+ ### Quick Mode
956
+ Rapid test creation with minimal prompts:
957
+ ```bash
958
+ testzeus tests-authoring quick --name my_test --description "Test checkout"
959
+ ```
960
+
961
+ ### Manual Mode
962
+ Create test directly with Gherkin feature:
963
+ ```bash
964
+ testzeus tests-authoring manual --name my_test --feature "Feature: Login..."
965
+ ```
966
+
967
+ See `testzeus_cli/commands/tests_authoring.py` for implementation.
968
+
943
969
  ## Configuration
944
970
 
945
971
  The CLI stores configuration and credentials in your user's config directory. Different profiles can be used to manage multiple TestZeus environments.
@@ -913,6 +913,30 @@ downloads/
913
913
  **Options:**
914
914
  - `--output-dir`: Base directory to save attachments (default: downloads)
915
915
 
916
+ ## Test Authoring
917
+
918
+ Create tests via interactive wizard or quick mode.
919
+
920
+ ### Wizard Mode
921
+ Interactive multi-step wizard for guided test creation:
922
+ ```bash
923
+ testzeus tests-authoring wizard
924
+ ```
925
+
926
+ ### Quick Mode
927
+ Rapid test creation with minimal prompts:
928
+ ```bash
929
+ testzeus tests-authoring quick --name my_test --description "Test checkout"
930
+ ```
931
+
932
+ ### Manual Mode
933
+ Create test directly with Gherkin feature:
934
+ ```bash
935
+ testzeus tests-authoring manual --name my_test --feature "Feature: Login..."
936
+ ```
937
+
938
+ See `testzeus_cli/commands/tests_authoring.py` for implementation.
939
+
916
940
  ## Configuration
917
941
 
918
942
  The CLI stores configuration and credentials in your user's config directory. Different profiles can be used to manage multiple TestZeus environments.
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "testzeus-cli"
7
- version = "0.0.17"
7
+ version = "0.0.19"
8
8
  description = "Command-line interface for TestZeus testing platform"
9
9
  authors = ["Shriyansh Agnihotri <shriyansh@testzeus.com>"]
10
10
  readme = "README.md"
@@ -22,17 +22,25 @@ pydantic = "^2.0.0"
22
22
  pyyaml = "^6.0"
23
23
  keyring = "^24.0.0"
24
24
  ipdb = "^0.13.13"
25
- testzeus-sdk = "^0.0.15"
25
+ testzeus-sdk = "^0.0.17"
26
26
  pocketbase = "^0.15.0"
27
27
  toml = "^0.10.2"
28
- aiohttp = "^3.13.3"
29
- cryptography = "^46.0.5"
28
+ aiohttp = "3.13.4"
29
+ Pygments = "2.20.0"
30
+ cryptography = "46.0.7"
31
+
32
+ [tool.poetry.extras]
33
+ daemon = [
34
+ "fastapi",
35
+ "uvicorn",
36
+ "sse-starlette",
37
+ ]
30
38
 
31
39
  [tool.poetry.group.dev.dependencies]
32
- pytest = "^7.3.1"
40
+ pytest = "^9.0.3"
33
41
  black = ">=26.3.1,<27.0"
34
42
  isort = "^5.12.0"
35
- python-dotenv = "^1.0.0"
43
+ python-dotenv = "^1.2.2"
36
44
  ipykernel = "^6.29.5"
37
45
 
38
46
  [tool.poetry.scripts]
@@ -0,0 +1,452 @@
1
+ """
2
+ Authentication utilities for TestZeus CLI.
3
+ """
4
+
5
+ import asyncio
6
+ import json
7
+ import uuid
8
+ import os
9
+ import logging
10
+ import click
11
+ from getpass import getpass
12
+ from rich.console import Console
13
+ from typing import Dict, Any, Optional
14
+
15
+ from testzeus_sdk import TestZeusClient
16
+ from testzeus_cli.config import (
17
+ update_config,
18
+ get_client_config,
19
+ clear_auth_data,
20
+ load_config,
21
+ save_config,
22
+ )
23
+ from testzeus_cli.utils.auth import (
24
+ initialize_client_with_token,
25
+ decode_jwt_payload,
26
+ )
27
+
28
+ console = Console()
29
+ logger = logging.getLogger("testzeus_cli.auth")
30
+
31
+
32
+ def _auth_debug_enabled() -> bool:
33
+ return str(os.environ.get("TESTZEUS_AUTH_DEBUG", "")).lower() in {"1", "true", "yes", "on"}
34
+
35
+
36
+ def _debug(msg: str) -> None:
37
+ if _auth_debug_enabled():
38
+ logger.warning("[AUTH_DEBUG] %s", msg)
39
+
40
+
41
+ @click.command(name="login")
42
+ @click.option("--email", help="Your TestZeus email")
43
+ @click.option("--password", help="Your TestZeus password", hide_input=True)
44
+ @click.option("--save", is_flag=True, default=True, help="Save credentials to config")
45
+ @click.pass_context
46
+ def login_command(
47
+ ctx: click.Context, email: Optional[str], password: Optional[str], save: bool
48
+ ) -> None:
49
+ """Log in to TestZeus"""
50
+ if not email:
51
+ email = click.prompt("Email")
52
+
53
+ if not password:
54
+ password = getpass("Password: ")
55
+
56
+ async def _login() -> Dict[str, Any]:
57
+ config, _, _, _ = get_client_config(
58
+ ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL")
59
+ )
60
+
61
+ # Create a clean config without email/password to avoid duplicates
62
+ base_config = {"base_url": config.get("base_url")}
63
+
64
+ # Create client with explicit email/password
65
+ client = TestZeusClient(email=email, password=password, **base_config)
66
+
67
+ async with client:
68
+ # Authenticate and get token
69
+ await client.ensure_authenticated()
70
+ token = client.token
71
+
72
+ # Get tenant ID from the authenticated client
73
+ tenant_id = client.get_tenant_id()
74
+ user_id = client.get_user_id()
75
+
76
+ if save:
77
+ update_config(
78
+ ctx.obj["PROFILE"],
79
+ {
80
+ "api_url": client.base_url,
81
+ "email": email,
82
+ "token": token,
83
+ "tenant_id": tenant_id,
84
+ "user_id": user_id,
85
+ },
86
+ )
87
+
88
+ return {
89
+ "email": email,
90
+ "api_url": client.base_url,
91
+ "authenticated": client.is_authenticated(),
92
+ "tenant_id": tenant_id,
93
+ "user_id": user_id,
94
+ }
95
+
96
+ try:
97
+ result = asyncio.run(_login())
98
+ console.print("[green]Successfully logged in![/green]")
99
+ console.print(f"Email: {result['email']}")
100
+ console.print(f"API URL: {result['api_url']}")
101
+ console.print(f"Tenant ID: {result['tenant_id']}")
102
+ except Exception as e:
103
+ console.print(f"[red]Login failed:[/red] {str(e)}")
104
+ exit(1)
105
+
106
+
107
+ @click.command(name="logout")
108
+ @click.pass_context
109
+ def logout_command(ctx: click.Context) -> None:
110
+ """Log out from TestZeus"""
111
+ profile = ctx.obj["PROFILE"]
112
+ clear_auth_data(profile)
113
+ console.print(f"[green]Successfully logged out from profile '{profile}'[/green]")
114
+
115
+
116
+ @click.command(name="whoami")
117
+ @click.pass_context
118
+ def whoami_command(ctx: click.Context) -> None:
119
+ """Show current user information"""
120
+
121
+ async def _whoami() -> Dict[str, Any]:
122
+ config, token, stored_tenant_id, stored_user_id = get_client_config(
123
+ ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL")
124
+ )
125
+
126
+ client = TestZeusClient(**config)
127
+
128
+ try:
129
+ async with client:
130
+ # Apply token from config if available
131
+ if token:
132
+ initialize_client_with_token(client, token)
133
+ else:
134
+ await client.ensure_authenticated()
135
+ return {
136
+ "email": client.email,
137
+ "api_url": client.base_url,
138
+ "tenant_id": stored_tenant_id,
139
+ "user_id": stored_user_id,
140
+ }
141
+ except Exception as e:
142
+ console.print(f"[red]Not authenticated:[/red] {str(e)}")
143
+ console.print("[yellow]Run 'testzeus login' to authenticate[/yellow]")
144
+ exit(1)
145
+
146
+ try:
147
+ user_info = asyncio.run(_whoami())
148
+ console.print("[green]Current User Information:[/green]")
149
+ console.print(f"Email: {user_info['email']}")
150
+ console.print(f"API URL: {user_info['api_url']}")
151
+ console.print(f"Tenant ID: {user_info['tenant_id']}")
152
+ console.print(f"User ID: {user_info['user_id']}")
153
+ except Exception as e:
154
+ console.print(f"[red]Failed to get user information:[/red] {str(e)}")
155
+ exit(1)
156
+
157
+
158
+ # =============================================================================
159
+ # Session Management Commands (for Hermes Integration)
160
+ # =============================================================================
161
+
162
+ @click.command(name="session-exchange")
163
+ @click.option("--token", required=True, help="PocketBase JWT token from UI")
164
+ @click.option("--profile", default=None, help="Session profile name (auto-generated if not provided)")
165
+ @click.option("--tenant-id", default=None, help="Tenant ID hint from UI/Hermes")
166
+ @click.option("--user-id", default=None, help="User ID hint from UI/Hermes")
167
+ @click.option("--email", "email_hint", default=None, help="Email hint from UI/Hermes")
168
+ @click.pass_context
169
+ def session_exchange_command(
170
+ ctx: click.Context,
171
+ token: str,
172
+ profile: Optional[str],
173
+ tenant_id: Optional[str],
174
+ user_id: Optional[str],
175
+ email_hint: Optional[str],
176
+ ) -> None:
177
+ """
178
+ Exchange a PocketBase JWT for a session-scoped CLI authentication.
179
+
180
+ This command is used by Hermes to establish a CLI session from a UI-provided
181
+ PocketBase JWT. The session is stored in a separate profile and can be used
182
+ for subsequent CLI operations.
183
+
184
+ Example:
185
+ testzeus auth session-exchange --token <pocketbase_jwt>
186
+ """
187
+ async def _exchange() -> Dict[str, Any]:
188
+ tenant_hint = tenant_id
189
+ user_hint = user_id
190
+ # Get base config for API URL
191
+ config, _, _, _ = get_client_config(
192
+ ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL")
193
+ )
194
+ base_url = config.get("base_url", "https://pb.prod.testzeus.app")
195
+
196
+ # Generate session ID if not provided
197
+ profile_name = profile or f"hermes-{uuid.uuid4().hex[:16]}"
198
+ _debug(f"session-exchange start profile={profile_name} base_url={base_url}")
199
+
200
+ # Create SDK client
201
+ client = TestZeusClient(base_url=base_url)
202
+
203
+ async def enrich_from_user_record(
204
+ session_token: str,
205
+ current_user_id: str,
206
+ current_tenant_id: str,
207
+ current_email: str,
208
+ ) -> tuple[str, str, str]:
209
+ """
210
+ Best-effort enrichment from the authenticated user record.
211
+
212
+ This keeps session profiles self-contained even when auth-refresh
213
+ does not include a tenant in its response.
214
+ """
215
+ if not current_user_id:
216
+ return current_user_id, current_tenant_id, current_email
217
+
218
+ try:
219
+ initialize_client_with_token(client, session_token, tenant_hint)
220
+ user = await client.users.get_one(current_user_id)
221
+ if not current_tenant_id:
222
+ current_tenant_id = str(getattr(user, "tenant", "") or "")
223
+ if not current_email:
224
+ current_email = str(getattr(user, "email", "") or "")
225
+ _debug(
226
+ f"session-exchange user enrichment success profile={profile_name} user_id={current_user_id} tenant_id={current_tenant_id}"
227
+ )
228
+ except Exception:
229
+ _debug(
230
+ f"session-exchange user enrichment failed profile={profile_name} user_id={current_user_id}"
231
+ )
232
+ return current_user_id, current_tenant_id, current_email
233
+
234
+ try:
235
+ async with client:
236
+ exchanged_user_id = ""
237
+ exchanged_tenant_id = ""
238
+ exchanged_email = ""
239
+ # Exchange the token
240
+ try:
241
+ result = await client.auth.exchange_session(token)
242
+ session_token = result.session_token
243
+ exchanged_user_id = result.user_id
244
+ exchanged_tenant_id = result.tenant_id
245
+ exchanged_email = result.email
246
+ fallback_mode = False
247
+ _debug(
248
+ f"session-exchange upstream success profile={profile_name} user_id={exchanged_user_id} tenant_id={exchanged_tenant_id}"
249
+ )
250
+ except ValueError:
251
+ # UI-compatible fallback: persist the raw incoming token.
252
+ # This mirrors the frontend behavior where the token is forwarded directly.
253
+ claims = decode_jwt_payload(token) or {}
254
+ session_token = token
255
+ exchanged_user_id = str(user_hint or claims.get("id") or claims.get("sub") or "")
256
+ exchanged_tenant_id = str(tenant_hint or claims.get("tenant") or "")
257
+ exchanged_email = str(email_hint or claims.get("email") or "")
258
+ fallback_mode = True
259
+ _debug(
260
+ f"session-exchange upstream failed; using fallback profile={profile_name} user_id={exchanged_user_id}"
261
+ )
262
+
263
+ exchanged_user_id, exchanged_tenant_id, exchanged_email = await enrich_from_user_record(
264
+ session_token,
265
+ exchanged_user_id,
266
+ exchanged_tenant_id,
267
+ exchanged_email,
268
+ )
269
+
270
+ # Apply hints as a final fallback even when upstream exchange succeeds
271
+ if not exchanged_user_id and user_hint:
272
+ exchanged_user_id = str(user_hint)
273
+ if not exchanged_tenant_id and tenant_hint:
274
+ exchanged_tenant_id = str(tenant_hint)
275
+ if not exchanged_email and email_hint:
276
+ exchanged_email = str(email_hint)
277
+
278
+ update_config(
279
+ profile_name,
280
+ {
281
+ "api_url": base_url,
282
+ "token": session_token,
283
+ "user_id": exchanged_user_id,
284
+ "tenant_id": exchanged_tenant_id,
285
+ "email": exchanged_email,
286
+ "session_id": profile_name,
287
+ "source": "raw_ui_token" if fallback_mode else "exchanged_token",
288
+ "auth_mode": "token",
289
+ },
290
+ )
291
+ _debug(
292
+ f"session-exchange saved profile={profile_name} source={'raw_ui_token' if fallback_mode else 'exchanged_token'} user_id={exchanged_user_id} tenant_id={exchanged_tenant_id} email={'set' if exchanged_email else 'empty'}"
293
+ )
294
+
295
+ return {
296
+ "success": True,
297
+ "session_id": profile_name,
298
+ "profile": profile_name,
299
+ "user_id": exchanged_user_id,
300
+ "tenant_id": exchanged_tenant_id,
301
+ "email": exchanged_email,
302
+ "fallback_mode": fallback_mode,
303
+ }
304
+
305
+ except ValueError as e:
306
+ return {
307
+ "success": False,
308
+ "error": str(e),
309
+ }
310
+
311
+ output_format = (ctx.obj or {}).get("FORMAT", "table")
312
+ as_json = output_format == "json"
313
+
314
+ try:
315
+ result = asyncio.run(_exchange())
316
+
317
+ if result.get("success"):
318
+ if as_json:
319
+ click.echo(json.dumps(result))
320
+ else:
321
+ console.print("[green]Session exchange successful![/green]")
322
+ console.print(f"Session ID: {result['session_id']}")
323
+ console.print(f"Profile: {result['profile']}")
324
+ console.print(f"User ID: {result['user_id']}")
325
+ console.print(f"Tenant ID: {result['tenant_id']}")
326
+ console.print(f"Email: {result['email']}")
327
+ if result.get("fallback_mode"):
328
+ console.print("[yellow]Using raw UI token fallback mode (auth-refresh exchange unavailable).[/yellow]")
329
+ else:
330
+ if as_json:
331
+ click.echo(json.dumps(result))
332
+ else:
333
+ console.print(f"[red]Session exchange failed:[/red] {result.get('error')}")
334
+ exit(1)
335
+
336
+ except Exception as e:
337
+ if as_json:
338
+ click.echo(json.dumps({"success": False, "error": str(e)}))
339
+ else:
340
+ console.print(f"[red]Session exchange failed:[/red] {str(e)}")
341
+ exit(1)
342
+
343
+
344
+ @click.command(name="session-clear")
345
+ @click.option("--profile", "profile_name", required=False, help="Session profile to clear")
346
+ @click.pass_context
347
+ def session_clear_command(ctx: click.Context, profile_name: Optional[str]) -> None:
348
+ """
349
+ Clear a session profile and remove stored credentials.
350
+
351
+ This command removes the session profile created by session-exchange,
352
+ effectively logging out from that session.
353
+
354
+ Example:
355
+ testzeus auth session-clear --profile hermes-sess_abc123
356
+ """
357
+ if not profile_name:
358
+ console.print("[yellow]No profile specified. Use --profile to specify a session profile.[/yellow]")
359
+ exit(1)
360
+
361
+ try:
362
+ config = load_config()
363
+ if profile_name in config:
364
+ clear_auth_data(profile_name)
365
+ # Remove empty profile after clearing auth fields
366
+ config = load_config()
367
+ if profile_name in config:
368
+ del config[profile_name]
369
+ save_config(config)
370
+ console.print(f"[green]Session profile '{profile_name}' cleared successfully.[/green]")
371
+ else:
372
+ console.print(f"[yellow]Session profile '{profile_name}' not found.[/yellow]")
373
+ except Exception as e:
374
+ console.print(f"[red]Failed to clear session:[/red] {str(e)}")
375
+ exit(1)
376
+
377
+
378
+ @click.command(name="session-status")
379
+ @click.option("--profile", "profile_name", required=False, help="Session profile to check")
380
+ @click.pass_context
381
+ def session_status_command(ctx: click.Context, profile_name: Optional[str]) -> None:
382
+ """
383
+ Check the status of a session profile.
384
+
385
+ This command shows the current authentication status of a session profile,
386
+ including user info and whether the token is valid.
387
+
388
+ Example:
389
+ testzeus auth session-status --profile hermes-sess_abc123
390
+ """
391
+ if not profile_name:
392
+ console.print("[yellow]No profile specified. Use --profile to specify a session profile.[/yellow]")
393
+ exit(1)
394
+
395
+ try:
396
+ session_data = load_config().get(profile_name, {})
397
+
398
+ if not session_data.get("token"):
399
+ console.print(f"[red]Session profile '{profile_name}' not found or not authenticated.[/red]")
400
+ exit(1)
401
+
402
+ # Check if token appears valid (basic check)
403
+ token = session_data.get("token", "")
404
+ valid = len(token) > 0
405
+
406
+ console.print("[green]Session Status:[/green]")
407
+ console.print(f"Profile: {profile_name}")
408
+ console.print(f"Authenticated: {valid}")
409
+ console.print(f"User ID: {session_data.get('user_id', 'N/A')}")
410
+ console.print(f"Tenant ID: {session_data.get('tenant_id', 'N/A')}")
411
+ console.print(f"Email: {session_data.get('email', 'N/A')}")
412
+ console.print(f"Session ID: {session_data.get('session_id', 'N/A')}")
413
+ console.print(f"API URL: {session_data.get('api_url', 'N/A')}")
414
+
415
+ if ctx.obj.get("FORMAT") == "json":
416
+ click.echo(json.dumps({"authenticated": valid, **session_data}))
417
+
418
+ except Exception as e:
419
+ console.print(f"[red]Failed to get session status:[/red] {str(e)}")
420
+ exit(1)
421
+
422
+
423
+ @click.command(name="session-list")
424
+ @click.pass_context
425
+ def session_list_command(ctx: click.Context) -> None:
426
+ """
427
+ List all session profiles.
428
+
429
+ This command shows all Hermes session profiles currently stored.
430
+
431
+ Example:
432
+ testzeus auth session-list
433
+ """
434
+ try:
435
+ profiles = [key for key in load_config().keys() if key.startswith("hermes-")]
436
+
437
+ if not profiles:
438
+ console.print("[yellow]No session profiles found.[/yellow]")
439
+ return
440
+
441
+ console.print(f"[green]Found {len(profiles)} session profile(s):[/green]")
442
+ for profile in profiles:
443
+ session_data = load_config().get(profile, {})
444
+ email = session_data.get("email", "N/A")
445
+ console.print(f" - {profile} ({email})")
446
+
447
+ if ctx.obj.get("FORMAT") == "json":
448
+ click.echo(json.dumps({"profiles": profiles}))
449
+
450
+ except Exception as e:
451
+ console.print(f"[red]Failed to list sessions:[/red] {str(e)}")
452
+ exit(1)
@@ -7,7 +7,15 @@ import click
7
7
  from rich.console import Console
8
8
 
9
9
  from testzeus_cli import __version__
10
- from testzeus_cli.auth import login_command, logout_command, whoami_command
10
+ from testzeus_cli.auth import (
11
+ login_command,
12
+ logout_command,
13
+ whoami_command,
14
+ session_exchange_command,
15
+ session_clear_command,
16
+ session_status_command,
17
+ session_list_command,
18
+ )
11
19
  from testzeus_cli.commands.tests import tests_group
12
20
  from testzeus_cli.commands.test_runs import test_runs_group
13
21
  from testzeus_cli.commands.test_suite_node_runs import test_suite_node_runs_group
@@ -24,6 +32,17 @@ from testzeus_cli.commands.extensions import extensions_group
24
32
  from testzeus_cli.commands.tests_ai_generator import tests_ai_generator_group
25
33
  from testzeus_cli.commands.hypermind_code_blocks import hypermind_code_blocks_group
26
34
  from testzeus_cli.commands.user_integrations import user_integrations_group
35
+ from testzeus_cli.commands.tests_authoring import tests_authoring_group
36
+ from testzeus_cli.commands.knowledge_bases import knowledge_bases_group
37
+
38
+ # Daemon dependencies (fastapi/uvicorn/sse-starlette) are optional extras.
39
+ # Keep CLI core commands (e.g. session-exchange) functional when extras are absent.
40
+ daemon_import_error = None
41
+ try:
42
+ from testzeus_cli.commands.daemon import daemon as daemon_command
43
+ except ModuleNotFoundError as exc:
44
+ daemon_command = None
45
+ daemon_import_error = exc
27
46
 
28
47
  # New command groups can be imported here when implemented
29
48
 
@@ -56,6 +75,11 @@ def cli(ctx, profile, api_url, verbose, output_format):
56
75
  cli.add_command(login_command)
57
76
  cli.add_command(logout_command)
58
77
  cli.add_command(whoami_command)
78
+ # Session management commands (Hermes integration)
79
+ cli.add_command(session_exchange_command, name="session-exchange")
80
+ cli.add_command(session_clear_command, name="session-clear")
81
+ cli.add_command(session_status_command, name="session-status")
82
+ cli.add_command(session_list_command, name="session-list")
59
83
  cli.add_command(tests_group)
60
84
  cli.add_command(test_runs_group)
61
85
  cli.add_command(test_suites_group)
@@ -72,6 +96,10 @@ cli.add_command(extensions_group)
72
96
  cli.add_command(tests_ai_generator_group)
73
97
  cli.add_command(hypermind_code_blocks_group)
74
98
  cli.add_command(user_integrations_group)
99
+ cli.add_command(tests_authoring_group)
100
+ cli.add_command(knowledge_bases_group)
101
+ if daemon_command is not None:
102
+ cli.add_command(daemon_command)
75
103
  # New command groups can be added here when implemented
76
104
 
77
105