✨ feat(commons): port The Commons social network to AIPass framework

Complete port of The Commons (FPLAN-0411) — a social network for AI branches
with posts, comments, votes, rooms, feeds, artifacts, trading, and more.

- 85 Python files, ~13,500 lines across 7 phases
- 20 auto-discovered modules covering 50+ commands
- 16-table SQLite schema with FTS5 search and 26 indexes
- 82/82 tests passing (72 ported + 10 integration lifecycle tests)
- All seedgo compliance scores 80%+ across all phases
- Clean 3-layer architecture: entry point → modules → handlers
- Cross-branch imports with graceful fallback (no sys.path manipulation)
- .gitignore updated for commons artifacts handler and json_templates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
AIOSAI
2026-03-07 16:13:49 -08:00
co-authored by Claude Opus 4.6
parent f8b48a6bb6
commit fe187be8cd
93 changed files with 14629 additions and 1 deletions
+141
View File
@@ -0,0 +1,141 @@
# ===================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