feat(prax): monitor restoration phases 1-3, dead module cleanup, help cleanup

Co-Authored-By: @prax <prax@aipass>
This commit is contained in:
AIOSAI
2026-03-18 19:41:07 -07:00
co-authored by @prax
parent 8162f43099
commit fe5f1d2cdc
6 changed files with 10 additions and 584 deletions
-106
View File
@@ -1,106 +0,0 @@
# =================== AIPass ====================
# Name: discover.py
# Description: PRAX Discover Command
# Version: 1.0.0
# Created: 2025-11-15
# Modified: 2026-03-09
# =============================================
"""
PRAX Discover Module
Implements the 'discover' command using handle_command interface.
"""
import sys
from typing import List
from aipass.cli.apps.modules import console, error
from aipass.prax.apps.handlers.discovery.scanner import discover_python_modules
from aipass.prax.apps.handlers.json import json_handler
def print_help():
"""Drone-compliant help output - command syntax and examples"""
console.print()
console.print("[bold cyan]PRAX Discover - Scan Python Modules[/bold cyan]")
console.print()
console.print("[yellow]Purpose:[/yellow]")
console.print(" Scan and register Python modules in the AIPass ecosystem")
console.print()
console.print("[yellow]Usage:[/yellow]")
console.print(" drone @prax discover scan")
console.print()
console.print("[yellow]Subcommands:[/yellow]")
console.print(" scan Discover and register Python modules")
console.print()
console.print("[yellow]Examples:[/yellow]")
console.print()
console.print(" [dim]# Discover Python modules[/dim]")
console.print(" $ drone @prax discover scan")
console.print()
def handle_command(command: str, args: List[str]) -> bool:
"""
Handle discover command
Args:
command: Command name
args: Command arguments
Returns:
True if command was handled
"""
if command != 'discover':
return False
if not args:
print_introspection()
return True
if args[0] in ('--help', '-h', 'help'):
print_help()
return True
if args[0] == 'scan':
json_handler.log_operation("discover_command_executed", {"command": command})
console.print("🔍 Discovering Python modules...")
modules = discover_python_modules()
console.print(f"✅ Discovered {len(modules)} modules")
return True
error(f"Unknown discover subcommand: {args[0]}")
print_help()
return True
def print_introspection():
"""Display module introspection - shows connected handlers"""
console.print()
console.print("[bold cyan]PRAX Discover Module[/bold cyan]")
console.print()
console.print("[yellow]Connected Handlers:[/yellow]")
console.print()
console.print(" [cyan]prax/modules/[/cyan]")
console.print(" [dim]- logger.py[/dim] (system_logger)")
console.print()
console.print(" [cyan]prax/handlers/discovery/[/cyan]")
console.print(" [dim]- scanner.py[/dim] (discover_python_modules)")
console.print()
console.print("[dim]Run 'drone @prax discover --help' for usage[/dim]")
console.print()
if __name__ == "__main__":
# Show introspection when run without arguments
if len(sys.argv) == 1:
print_help()
sys.exit(0)
-122
View File
@@ -1,122 +0,0 @@
# =================== AIPass ====================
# Name: init_prax.py
# Description: PRAX Init Command
# Version: 1.0.0
# Created: 2025-11-15
# Modified: 2026-03-09
# =============================================
"""
PRAX Init Module
Implements the 'init' command using handle_command interface.
"""
import sys
from typing import List
from aipass.prax.apps.modules.logger import initialize_logging_system, system_logger as logger
from aipass.cli.apps.modules import console, error
from aipass.prax.apps.handlers.json import json_handler
def print_introspection():
"""Display module introspection - shows connected handlers"""
console.print()
console.print("[bold cyan]PRAX Init Module[/bold cyan]")
console.print()
console.print("[yellow]Connected Handlers:[/yellow]")
console.print()
console.print(" [cyan]prax/modules/[/cyan]")
console.print(" [dim]- logger.py[/dim] (initialize_logging_system, system_logger)")
console.print()
console.print("[dim]Run 'drone @prax init --help' for usage[/dim]")
console.print()
def print_help():
"""Drone-compliant help output - command syntax and examples"""
console.print()
console.print("[bold cyan]PRAX Init - Initialize Logging System[/bold cyan]")
console.print()
console.print("[yellow]Purpose:[/yellow]")
console.print(" Initialize the PRAX logging system for monitoring AIPass operations")
console.print()
console.print("[yellow]Usage:[/yellow]")
console.print(" drone @prax init start")
console.print()
console.print("[yellow]Subcommands:[/yellow]")
console.print(" start Initialize the PRAX logging system")
console.print()
console.print("[yellow]Examples:[/yellow]")
console.print()
console.print(" [dim]# Initialize logging system[/dim]")
console.print(" $ drone @prax init start")
console.print()
def handle_command(command: str, args: List[str]) -> bool:
"""
Handle init command
Args:
command: Command name
args: Command arguments
Returns:
True if command was handled
"""
if command != 'init':
return False
if not args:
print_introspection()
return True
if args[0] in ('--help', '-h', 'help'):
print_help()
return True
if args[0] == 'start':
try:
json_handler.log_operation("init_command_executed", {"command": command})
console.print("🚀 Initializing PRAX logging system...")
initialize_logging_system()
console.print("✅ PRAX logging system initialized")
return True
except Exception as e:
logger.error(f"Error in init command: {e}")
error(str(e))
return True
error(f"Unknown init subcommand: {args[0]}")
print_help()
return True
if __name__ == "__main__":
# Show introspection when run without arguments
if len(sys.argv) == 1:
print_introspection()
sys.exit(0)
# Handle --help flag
if '--help' in sys.argv:
print_help()
sys.exit(0)
# Handle --introspect flag
if '--introspect' in sys.argv:
print_introspection()
sys.exit(0)
# Execute init command
handled = handle_command('init', [])
sys.exit(0 if handled else 1)
-101
View File
@@ -1,101 +0,0 @@
# =================== AIPass ====================
# Name: run.py
# Description: PRAX Run Command
# Version: 1.0.0
# Created: 2025-11-15
# Modified: 2026-03-09
# =============================================
"""
PRAX Run Module
Implements the 'run' command using handle_command interface.
"""
import sys
from typing import List
from aipass.prax.apps.modules.logger import start_continuous_logging
from aipass.cli.apps.modules import console, error
from aipass.prax.apps.handlers.json import json_handler
def print_help():
"""Drone-compliant help output - command syntax and examples"""
console.print()
console.print("[bold cyan]PRAX Run - Continuous Logging Mode[/bold cyan]")
console.print()
console.print("[yellow]Purpose:[/yellow]")
console.print(" Start PRAX continuous logging mode for monitoring AIPass operations")
console.print()
console.print("[yellow]Usage:[/yellow]")
console.print(" drone @prax run start")
console.print()
console.print("[yellow]Subcommands:[/yellow]")
console.print(" start Start continuous logging mode")
console.print()
console.print("[yellow]Examples:[/yellow]")
console.print()
console.print(" [dim]# Start continuous logging[/dim]")
console.print(" $ drone @prax run start")
console.print()
def handle_command(command: str, args: List[str]) -> bool:
"""
Handle run command
Args:
command: Command name
args: Command arguments
Returns:
True if command was handled
"""
if command != 'run':
return False
if not args:
print_introspection()
return True
if args[0] in ('--help', '-h', 'help'):
print_help()
return True
if args[0] == 'start':
json_handler.log_operation("run_command_executed", {"command": command})
console.print("🚀 Starting PRAX continuous logging mode...")
start_continuous_logging()
return True
error(f"Unknown run subcommand: {args[0]}")
print_help()
return True
def print_introspection():
"""Display module introspection - shows connected handlers"""
console.print()
console.print("[bold cyan]PRAX Run Module[/bold cyan]")
console.print()
console.print("[yellow]Connected Handlers:[/yellow]")
console.print()
console.print(" [cyan]prax/modules/[/cyan]")
console.print(" [dim]- logger.py[/dim] (start_continuous_logging, system_logger)")
console.print()
console.print("[dim]Run 'drone @prax run --help' for usage[/dim]")
console.print()
if __name__ == "__main__":
# Show introspection when run without arguments
if len(sys.argv) == 1:
print_help()
sys.exit(0)
-102
View File
@@ -1,102 +0,0 @@
# =================== AIPass ====================
# Name: shutdown.py
# Description: PRAX Shutdown Command
# Version: 1.0.0
# Created: 2025-11-15
# Modified: 2026-03-09
# =============================================
"""
PRAX Shutdown Module
Implements the 'shutdown' command using handle_command interface.
"""
import sys
from typing import List
from aipass.prax.apps.modules.logger import shutdown_logging_system
from aipass.cli.apps.modules import console, error
from aipass.prax.apps.handlers.json import json_handler
def print_help():
"""Drone-compliant help output - command syntax and examples"""
console.print()
console.print("[bold cyan]PRAX Shutdown - Stop Logging System[/bold cyan]")
console.print()
console.print("[yellow]Purpose:[/yellow]")
console.print(" Cleanly stop the PRAX logging system")
console.print()
console.print("[yellow]Usage:[/yellow]")
console.print(" drone @prax shutdown now")
console.print()
console.print("[yellow]Subcommands:[/yellow]")
console.print(" now Shut down the PRAX logging system")
console.print()
console.print("[yellow]Examples:[/yellow]")
console.print()
console.print(" [dim]# Shut down logging system[/dim]")
console.print(" $ drone @prax shutdown now")
console.print()
def handle_command(command: str, args: List[str]) -> bool:
"""
Handle shutdown command
Args:
command: Command name
args: Command arguments
Returns:
True if command was handled
"""
if command != 'shutdown':
return False
if not args:
print_introspection()
return True
if args[0] in ('--help', '-h', 'help'):
print_help()
return True
if args[0] == 'now':
json_handler.log_operation("shutdown_command_executed", {"command": command})
console.print("🛑 Shutting down PRAX logging system...")
shutdown_logging_system()
console.print("✅ PRAX logging system shutdown complete")
return True
error(f"Unknown shutdown subcommand: {args[0]}")
print_help()
return True
def print_introspection():
"""Display module introspection - shows connected handlers"""
console.print()
console.print("[bold cyan]PRAX Shutdown Module[/bold cyan]")
console.print()
console.print("[yellow]Connected Handlers:[/yellow]")
console.print()
console.print(" [cyan]prax/modules/[/cyan]")
console.print(" [dim]- logger.py[/dim] (shutdown_logging_system, system_logger)")
console.print()
console.print("[dim]Run 'drone @prax shutdown --help' for usage[/dim]")
console.print()
if __name__ == "__main__":
# Show introspection when run without arguments
if len(sys.argv) == 1:
print_help()
sys.exit(0)
-134
View File
@@ -1,134 +0,0 @@
# =================== AIPass ====================
# Name: terminal.py
# Description: PRAX Terminal Command
# Version: 1.1.0
# Created: 2025-11-15
# Modified: 2026-03-09
# =============================================
"""
PRAX Terminal Module
Implements the 'terminal' command using handle_command interface.
"""
import sys
from typing import List
from aipass.prax.apps.modules.logger import enable_terminal_output, disable_terminal_output, system_logger as logger
from aipass.cli.apps.modules import console, error
from aipass.prax.apps.handlers.json import json_handler
def print_introspection():
"""Display module introspection - shows connected handlers"""
console.print()
console.print("[bold cyan]PRAX Terminal Module[/bold cyan]")
console.print()
console.print("[yellow]Purpose:[/yellow]")
console.print(" Enable or disable terminal output for PRAX logging system")
console.print()
console.print("[yellow]Connected Handlers:[/yellow]")
console.print()
console.print(" [cyan]prax/modules/[/cyan]")
console.print(" [dim]- logger.py[/dim] (enable_terminal_output, disable_terminal_output, system_logger)")
console.print()
console.print("[dim]Run 'drone @prax terminal --help' for usage[/dim]")
console.print()
def print_help():
"""Drone-compliant help output - command syntax and examples"""
console.print()
console.print("[bold cyan]PRAX Terminal - Logger Output Control[/bold cyan]")
console.print()
console.print("[yellow]Available Subcommands:[/yellow]")
console.print()
console.print(" [cyan]enable[/cyan]")
console.print(" Enable terminal output for PRAX logging")
console.print()
console.print(" [cyan]disable[/cyan]")
console.print(" Disable terminal output for PRAX logging")
console.print()
console.print("[yellow]Usage Examples:[/yellow]")
console.print()
console.print(" [dim]# Enable terminal output[/dim]")
console.print(" $ drone @prax terminal enable")
console.print()
console.print(" [dim]# Disable terminal output[/dim]")
console.print(" $ drone @prax terminal disable")
console.print()
console.print("[dim]Commands: enable, disable[/dim]")
console.print()
def handle_command(command: str, args: List[str]) -> bool:
"""
Handle terminal command
Args:
command: Command name
args: Command arguments (expects 'enable' or 'disable')
Returns:
True if command was handled
"""
if command != 'terminal':
return False
if not args:
print_introspection()
return True
if args[0] in ('--help', '-h', 'help'):
print_help()
return True
try:
if args[0] not in ['enable', 'disable']:
print_help()
return True # Command was handled, even if validation failed
json_handler.log_operation("terminal_command", {"action": args[0]})
if args[0] == 'enable':
enable_terminal_output()
console.print("✅ Terminal output enabled")
else:
disable_terminal_output()
console.print("✅ Terminal output disabled")
return True
except Exception as e:
logger.error(f"Error in terminal command: {e}")
error(str(e))
return True
if __name__ == "__main__":
# Show introspection when run without arguments
if len(sys.argv) == 1:
print_introspection()
sys.exit(0)
# Handle --help flag
if '--help' in sys.argv:
print_help()
sys.exit(0)
# Handle --introspect flag
if '--introspect' in sys.argv:
print_introspection()
sys.exit(0)
# Execute terminal command with remaining args
args = [arg for arg in sys.argv[1:] if not arg.startswith('--')]
handled = handle_command('terminal', args)
sys.exit(0 if handled else 1)
+10 -19
View File
@@ -108,25 +108,21 @@ def print_help():
console.print("[yellow]Commands:[/yellow]")
console.print(" [cyan]monitor[/cyan] Mission Control - unified real-time monitoring")
console.print(" [cyan]init[/cyan] Initialize PRAX logging system")
console.print(" [cyan]status[/cyan] Show PRAX system status")
console.print(" [cyan]run[/cyan] Start continuous logging mode")
console.print(" [cyan]shutdown[/cyan] Shutdown PRAX logging system")
console.print(" [cyan]discover[/cyan] Discover Python modules in ecosystem")
console.print(" [cyan]terminal[/cyan] Enable/disable terminal output")
console.print(" [cyan]log-audit[/cyan] Audit log file sizes and health")
console.print(" [cyan]dashboard[/cyan] System dashboard")
console.print()
console.print("[yellow]Flags:[/yellow]")
console.print(" [cyan]--help, -h[/cyan] Show help information")
console.print(" [cyan]--version, -V[/cyan] Show version")
console.print(" [cyan]--verbose, -v[/cyan] Verbose output")
console.print(" [cyan]--help[/cyan] Show help information")
console.print(" [cyan]--version[/cyan] Show version")
console.print()
console.print("[yellow]Examples:[/yellow]")
console.print(" $ drone @prax monitor")
console.print(" $ drone @prax monitor run")
console.print(" $ drone @prax status")
console.print(" $ drone @prax terminal enable")
console.print(" $ drone @prax log-audit audit")
console.print(" $ drone @prax dashboard")
console.print()
@@ -169,18 +165,14 @@ def main():
epilog="""
Available Commands:
monitor Mission Control - unified real-time monitoring
init Initialize PRAX logging system
status Show PRAX system status
run Start continuous logging mode
shutdown Shutdown PRAX logging system
discover Discover Python modules in ecosystem
terminal Enable/disable terminal output (requires: enable|disable)
log-audit Audit log file sizes and health
dashboard System dashboard
Examples:
drone @prax monitor
drone @prax init
drone @prax monitor run
drone @prax status
drone @prax terminal enable
drone @prax dashboard
"""
)
@@ -197,7 +189,6 @@ Examples:
parser.add_argument('--help', '-h', action='store_true', dest='show_help',
help='Show help information')
parser.add_argument('--version', '-V', action='version', version='PRAX v2.0.0')
parser.add_argument('--verbose', '-v', action='store_true', help='Verbose output')
parsed_args, remaining = parser.parse_known_args()