# ===================AIPASS==================== # META DATA HEADER # Name: explore_module.py - Exploration Module # Date: 2026-03-07 # Version: 1.0.0 # Category: commons/apps/modules # # CHANGELOG (Max 5 entries): # - v1.0.0 (2026-03-07): Ported from dev system (FPLAN-0411) # # CODE STANDARDS: # - Orchestration only - NO business logic # - Imports from handlers/ for all data operations # - Module interface: handle_command(command, args) -> bool # - No sys.path manipulation # ============================================= """ Exploration Module Router + display layer for secret room exploration commands. Delegates all logic to handlers/rooms/explore_ops.py and renders results with Rich. Handles: explore, secrets commands. """ import logging from typing import List try: from aipass.prax.apps.modules.logger import system_logger as logger except ImportError: logger = logging.getLogger("commons.explore_module") try: from aipass.cli.apps.modules import console except ImportError: from rich.console import Console console = Console() from rich.panel import Panel from rich.table import Table from commons.apps.handlers.rooms.explore_ops import explore_rooms, list_secrets # ============================================================================= # COMMAND ROUTING # ============================================================================= def handle_command(command: str, args: List[str]) -> bool: """Handle exploration commands.""" if command not in ["explore", "secrets"]: return False if command == "explore": return _handle_explore(args) elif command == "secrets": return _handle_secrets(args) return False # ============================================================================= # DISPLAY HANDLERS # ============================================================================= def _handle_explore(args: List[str]) -> bool: result = explore_rooms(args) if not result["success"]: console.print(f"[red]{result['error']}[/red]") return True hidden_rooms = result["hidden_rooms"] rooms_visited = result["rooms_visited"] if not hidden_rooms: console.print("\n[dim]No hidden rooms exist... yet.[/dim]\n") return True console.print() console.print(Panel( "[italic]You sense something beyond the ordinary rooms...[/italic]\n\n" "[dim]Hidden places exist in The Commons. " "Those who explore widely may discover their names.[/dim]", title="[bold]Exploration[/bold]", border_style="magenta", )) console.print() console.print("[bold]Whispered Hints:[/bold]") console.print() for room in hidden_rooms: hint = room.get("discovery_hint") or "..." console.print(f" [magenta]?[/magenta] [italic]{hint}[/italic]") console.print() revealed = result.get("revealed") if revealed: console.print(f"[green]Your exploration has paid off! You've visited {rooms_visited} rooms.[/green]") console.print(f"[green]A secret room reveals itself:[/green] [bold magenta]r/{revealed['name']}[/bold magenta]") console.print(f" [dim]{revealed['description']}[/dim]") console.print() console.print(f"[dim]Try: commons enter {revealed['name']}[/dim]") else: remaining = 3 - rooms_visited console.print(f"[dim]You've visited {rooms_visited} room(s). Visit {remaining} more to unlock a discovery...[/dim]") console.print() return True def _handle_secrets(args: List[str]) -> bool: result = list_secrets(args) if not result["success"]: console.print(f"[red]{result['error']}[/red]") return True discovered = result["discovered"] total_hidden = result["total_hidden"] console.print() if not discovered: console.print("[dim]You haven't discovered any secret rooms yet.[/dim]") console.print(f"[dim]There are {total_hidden} secret room(s) waiting to be found.[/dim]") console.print("[dim]Try: commons explore[/dim]") else: table = Table(title="Your Discovered Secrets", border_style="magenta") table.add_column("Room", style="bold magenta") table.add_column("Name", style="bold") table.add_column("Description", style="dim") for room in discovered: table.add_row(f"r/{room['name']}", room["display_name"], room["description"]) console.print(table) console.print(f"\n[dim]Discovered {len(discovered)} of {total_hidden} secret room(s)[/dim]") console.print() return True