#686/#661 night shift wave 2: daemon + prax + ai_mail -> 100% seedgo. daemon.py + ai_mail.py main() intercept <cmd> --help before dispatch (Subcommand_Help 0->100). Output_Routing ->100: daemon timer_install/update, prax dashboard/log_audit, ai_mail central_writer route status via cli warning()/error(); ai_mail introspection doc-glyphs -> markup. Tests green: daemon 300, prax 978, ai_mail 765.
This commit is contained in:
@@ -243,6 +243,13 @@ def main():
|
||||
error("No modules found")
|
||||
return 1
|
||||
|
||||
if remaining_args and remaining_args[0] in ["--help", "-h"]:
|
||||
for module in modules:
|
||||
if module.handle_command(command, ["--help"]):
|
||||
return 0
|
||||
print_help()
|
||||
return 0
|
||||
|
||||
# Route command
|
||||
if route_command(command, remaining_args, modules):
|
||||
return 0
|
||||
|
||||
@@ -349,5 +349,7 @@ if __name__ == "__main__":
|
||||
console.print()
|
||||
|
||||
except Exception as e:
|
||||
console.print(f"[red]Error:[/red] {e}")
|
||||
from aipass.cli.apps.modules import error as cli_error
|
||||
|
||||
cli_error(f"Error: {e}")
|
||||
raise
|
||||
|
||||
@@ -173,10 +173,10 @@ if __name__ == "__main__":
|
||||
console.print(" - format_email_list_item(index, email_data, show_unread) -> str")
|
||||
console.print()
|
||||
console.print("HANDLER CHARACTERISTICS:")
|
||||
console.print(" ✓ Independent - no module dependencies")
|
||||
console.print(" ✓ Can import Prax (service provider)")
|
||||
console.print(" ✓ Pure business logic")
|
||||
console.print(" ✗ CANNOT import parent modules")
|
||||
console.print(" [green]+[/green] Independent - no module dependencies")
|
||||
console.print(" [green]+[/green] Can import Prax (service provider)")
|
||||
console.print(" [green]+[/green] Pure business logic")
|
||||
console.print(" [dim]-[/dim] CANNOT import parent modules")
|
||||
console.print()
|
||||
console.print("USAGE FROM MODULES:")
|
||||
console.print(" from ai_mail.apps.handlers.email.format import format_email_preview")
|
||||
|
||||
@@ -134,10 +134,10 @@ if __name__ == "__main__":
|
||||
console.print(" - load_inbox(inbox_file) -> Dict")
|
||||
console.print()
|
||||
console.print("HANDLER CHARACTERISTICS:")
|
||||
console.print(" ✓ Independent - no module dependencies")
|
||||
console.print(" ✓ Can import Prax (service provider)")
|
||||
console.print(" ✓ Pure business logic")
|
||||
console.print(" ✗ CANNOT import parent modules")
|
||||
console.print(" [green]+[/green] Independent - no module dependencies")
|
||||
console.print(" [green]+[/green] Can import Prax (service provider)")
|
||||
console.print(" [green]+[/green] Pure business logic")
|
||||
console.print(" [dim]-[/dim] CANNOT import parent modules")
|
||||
console.print()
|
||||
console.print("USAGE FROM MODULES:")
|
||||
console.print(" from aipass.ai_mail.apps.handlers.email.inbox_ops import load_inbox")
|
||||
|
||||
@@ -305,10 +305,10 @@ if __name__ == "__main__":
|
||||
console.print(" - get_branch_info_from_registry(branch_path) -> Optional[Dict]")
|
||||
console.print()
|
||||
console.print("HANDLER CHARACTERISTICS:")
|
||||
console.print(" ✓ Independent - no module dependencies")
|
||||
console.print(" ✓ Can import Prax (service provider)")
|
||||
console.print(" ✓ Pure business logic")
|
||||
console.print(" ✗ CANNOT import parent modules")
|
||||
console.print(" [green]+[/green] Independent - no module dependencies")
|
||||
console.print(" [green]+[/green] Can import Prax (service provider)")
|
||||
console.print(" [green]+[/green] Pure business logic")
|
||||
console.print(" [dim]-[/dim] CANNOT import parent modules")
|
||||
console.print()
|
||||
console.print("DETECTION FLOW:")
|
||||
console.print(" 1. Get current working directory (PWD)")
|
||||
|
||||
@@ -200,6 +200,14 @@ def main():
|
||||
command = args[0]
|
||||
remaining_args = args[1:] if len(args) > 1 else []
|
||||
|
||||
# Subcommand --help guard — intercept before dispatch
|
||||
if remaining_args and remaining_args[0] in ["--help", "-h"]:
|
||||
for module in modules:
|
||||
if module.handle_command(command, ["--help"]):
|
||||
return 0
|
||||
print_help(modules)
|
||||
return 0
|
||||
|
||||
json_handler.log_operation("daemon_command", {"command": command})
|
||||
|
||||
# Route to modules
|
||||
|
||||
@@ -68,7 +68,7 @@ def _run_systemctl(*args: str) -> bool:
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=15)
|
||||
if result.returncode != 0:
|
||||
logger.warning("[timer_install] systemctl --user %s failed: %s", " ".join(args), result.stderr.strip())
|
||||
console.print(f" [red]FAIL:[/red] systemctl --user {' '.join(args)}")
|
||||
error(f"FAIL: systemctl --user {' '.join(args)}")
|
||||
if result.stderr.strip():
|
||||
console.print(f" [dim]{result.stderr.strip()}[/dim]")
|
||||
return False
|
||||
@@ -79,7 +79,7 @@ def _run_systemctl(*args: str) -> bool:
|
||||
return False
|
||||
except subprocess.TimeoutExpired:
|
||||
logger.error("[timer_install] systemctl --user %s timed out", " ".join(args))
|
||||
console.print(" [red]systemctl timed out[/red]")
|
||||
error("systemctl timed out")
|
||||
return False
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ if sys.platform == "win32":
|
||||
|
||||
from aipass.prax import logger
|
||||
|
||||
from aipass.cli.apps.modules import console, error
|
||||
from aipass.cli.apps.modules import console, error, warning
|
||||
from aipass.daemon.apps.handlers.json import json_handler
|
||||
from aipass.daemon.apps.handlers.update.data_loader import (
|
||||
load_inbox,
|
||||
@@ -117,7 +117,7 @@ def _print_digest(inbox_data: Dict[str, Any], local_data: Dict[str, Any]) -> Non
|
||||
console.print(" Recently completed: [dim]None[/dim]")
|
||||
console.print()
|
||||
|
||||
console.print("[bold red]ESCALATIONS NEEDED[/bold red]")
|
||||
warning("ESCALATIONS NEEDED")
|
||||
escalations = get_escalations(messages)
|
||||
if escalations:
|
||||
for msg in escalations:
|
||||
|
||||
@@ -373,7 +373,7 @@ def _handle_diff_template(args: List[str]) -> None:
|
||||
for a in branch_diff.get("additions", []):
|
||||
console.print(f" [green]+ {a}[/green]")
|
||||
for r in branch_diff.get("removals", []):
|
||||
console.print(f" [red]- {r}[/red]")
|
||||
warning(f" - {r}")
|
||||
for m in branch_diff.get("modifications", []):
|
||||
console.print(f" [yellow]~ {m}[/yellow]")
|
||||
|
||||
@@ -388,7 +388,10 @@ def _handle_template_status() -> None:
|
||||
console.print("[bold]Dashboard Template Status[/bold]")
|
||||
console.print("=" * 50)
|
||||
console.print(f" Templates dir: {status['templates_dir']}")
|
||||
console.print(f" Template file: {'[green]found[/green]' if status['template_exists'] else '[red]MISSING[/red]'}")
|
||||
if status["template_exists"]:
|
||||
console.print(" Template file: found")
|
||||
else:
|
||||
warning("Template file: MISSING")
|
||||
console.print(f" Schema version: {status.get('version', 'unknown')}")
|
||||
console.print(f" Last updated: {status.get('last_updated', 'unknown')}")
|
||||
console.print(f" Updated by: {status.get('updated_by', 'unknown')}")
|
||||
|
||||
@@ -26,7 +26,7 @@ if sys.platform == "win32":
|
||||
_reconfigure(encoding="utf-8", errors="replace")
|
||||
|
||||
from aipass.prax.apps.modules.logger import system_logger as logger
|
||||
from aipass.cli.apps.modules import console, error
|
||||
from aipass.cli.apps.modules import console, error, warning
|
||||
from aipass.prax.apps.handlers.json import json_handler
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ def _run_sweep():
|
||||
return
|
||||
|
||||
for entry in result["removed"]:
|
||||
console.print(f" [red]DELETED[/red] {entry['name']}: {entry['age_days']} days old, {entry['size_kb']} KB")
|
||||
warning(f"DELETED {entry['name']}: {entry['age_days']} days old, {entry['size_kb']} KB")
|
||||
console.print(f"\n Removed {result['files_removed']} file(s), reclaimed {result['total_reclaimed_kb']} KB\n")
|
||||
logger.info("[log-audit] Sweep removed %d stale files", result["files_removed"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user