feat(system): stderr routing migration Phase 3 — 10 branches migrated (FPLAN-0033)

Migrated error()/warning() calls across 10 branches to use CLI display API
which routes to stderr. 48 files modified across ai_mail, api, backup, daemon,
flow, memory, prax, seedgo, spawn, trigger. Seedgo stderr_routing standard
created (24th standard) with full-file scanning. System average 49% → 69%.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AIOSAI
2026-03-14 00:41:38 -07:00
co-authored by Claude Opus 4.6
parent 154e92d13e
commit 97952124b5
48 changed files with 666 additions and 226 deletions
+8 -8
View File
@@ -14,7 +14,7 @@ All implementation logic lives in apps/handlers/delete_ops.py.
from aipass.prax import logger
# CLI service: from cli.apps.modules import console (via aipass namespace)
from aipass.cli.apps.modules import console
from aipass.cli.apps.modules import console, error, warning
from aipass.spawn.apps.handlers.delete_ops import delete_branch
@@ -65,7 +65,7 @@ def handle_delete(args: list[str]) -> int:
Returns exit code (0=success, 1=failure).
"""
if not args:
console.print("[yellow]Usage: drone @spawn delete <@branch> [--yes] [--dry-run][/yellow]")
warning("Usage: drone @spawn delete <@branch> [--yes] [--dry-run]")
console.print()
console.print(" [green]@branch[/green] Branch to archive and deregister")
console.print(" [green]--yes[/green] Skip confirmation prompt")
@@ -79,7 +79,7 @@ def handle_delete(args: list[str]) -> int:
targets = [a for a in args if not a.startswith("--")]
if not targets:
console.print("[red]Error: specify a branch name (e.g. @api)[/red]")
error("specify a branch name (e.g. @api)")
return 1
branch_name = targets[0].lstrip("@").lower()
@@ -92,7 +92,7 @@ def handle_delete(args: list[str]) -> int:
)
except Exception as exc:
logger.error(f"[delete] Unexpected error deleting {branch_name}: {exc}")
console.print(f"[red]Error deleting {branch_name}: {exc}[/red]")
error(f"Error deleting {branch_name}: {exc}")
return 1
_print_summary(result, dry_run)
@@ -113,7 +113,7 @@ def _print_summary(result: dict, dry_run: bool) -> None:
if success:
console.print(f"[green]Delete {mode}{branch}[/green]")
else:
console.print(f"[red]Delete FAILED {mode}{branch}[/red]")
error(f"Delete FAILED {mode}{branch}")
archive_path = result.get("archive_path", "")
if archive_path:
@@ -121,8 +121,8 @@ def _print_summary(result: dict, dry_run: bool) -> None:
console.print(f" Registry updated: {result.get('registry_updated', False)}")
error = result.get("error", "")
if error:
console.print(f" [red]Error: {error}[/red]")
err_msg = result.get("error", "")
if err_msg:
error(err_msg)
console.print()
+6 -6
View File
@@ -15,7 +15,7 @@ All implementation logic lives in apps/handlers/passport_ops.py.
import argparse
from aipass.prax import logger
from aipass.cli.apps.modules import console
from aipass.cli.apps.modules import console, error, warning
from aipass.spawn.apps.handlers.passport_ops import grant_passport
@@ -58,13 +58,13 @@ def handle_passport(args: list[str]) -> int:
Returns exit code (0=success, 1=failure).
"""
if not args:
console.print("[yellow]Usage: drone @spawn passport <@dirname> [--role ...] [--purpose ...][/yellow]")
warning("Usage: drone @spawn passport <@dirname> [--role ...] [--purpose ...]")
console.print()
console.print(" [dim]Grant birthright citizenship to a directory[/dim]")
console.print()
console.print(" [green]@dirname[/green] Directory to grant citizenship (created if needed)")
console.print(" [yellow]--role[/yellow] Role description for the passport")
console.print(" [yellow]--purpose[/yellow] Purpose description")
warning("--role", details="Role description for the passport")
warning("--purpose", details="Purpose description")
return 1
parser = argparse.ArgumentParser(prog="spawn passport", add_help=False)
@@ -96,9 +96,9 @@ def handle_passport(args: list[str]) -> int:
console.print(f" Files: {result['files_copied']}")
console.print(f" Registry: {'updated' if result['registry_updated'] else 'not updated'}")
if result["validation_issues"]:
console.print(f" [yellow]Warnings: {len(result['validation_issues'])} unreplaced placeholders[/yellow]")
warning(f"{len(result['validation_issues'])} unreplaced placeholders")
console.print()
return 0
else:
console.print(f"[red]Error: {result['error']}[/red]")
error(result['error'])
return 1
@@ -14,7 +14,7 @@ All implementation logic lives in apps/handlers/sync_registry_ops.py.
from aipass.prax import logger
# CLI service: from cli.apps.modules import console (via aipass namespace)
from aipass.cli.apps.modules import console
from aipass.cli.apps.modules import console, error, warning
from aipass.spawn.apps.handlers.sync_registry_ops import sync_registry
@@ -64,7 +64,7 @@ def handle_sync_registry(args: list[str]) -> int:
Returns exit code (0=success, 1=failure).
"""
if args and args[0] in ["--help", "-h"]:
console.print("[yellow]Usage: drone @spawn sync-registry [--fix][/yellow]")
warning("Usage: drone @spawn sync-registry [--fix]")
console.print()
console.print(" [green](no args)[/green] Report mismatches between registry and filesystem")
console.print(" [green]--fix[/green] Auto-repair: remove stale, add unregistered")
@@ -76,7 +76,7 @@ def handle_sync_registry(args: list[str]) -> int:
result = sync_registry(fix=fix)
except Exception as exc:
logger.error(f"[sync-registry] Unexpected error: {exc}")
console.print(f"[red]Error: {exc}[/red]")
error(str(exc))
return 1
_print_summary(result)
@@ -106,7 +106,7 @@ def _print_summary(result: dict) -> None:
# Stale
if stale:
console.print(f" [red]Stale ({len(stale)}):[/red] [dim]registered but missing/invalid[/dim]")
error(f"Stale ({len(stale)}): registered but missing/invalid")
for name in sorted(stale):
console.print(f" {name}")
else:
@@ -114,7 +114,7 @@ def _print_summary(result: dict) -> None:
# Unregistered
if unregistered:
console.print(f" [yellow]Unregistered ({len(unregistered)}):[/yellow] [dim]on disk but not in registry[/dim]")
warning(f"Unregistered ({len(unregistered)}): on disk but not in registry")
for name in sorted(unregistered):
console.print(f" {name}")
else:
@@ -14,7 +14,7 @@ All implementation logic lives in apps/handlers/sync_templates_ops.py.
from aipass.prax import logger
# CLI service: from cli.apps.modules import console (via aipass namespace)
from aipass.cli.apps.modules import console
from aipass.cli.apps.modules import console, error, warning
from aipass.spawn.apps.handlers.sync_templates_ops import sync_templates
@@ -66,7 +66,7 @@ def handle_sync_templates(args: list[str]) -> int:
Returns exit code (0=success, 1=failure).
"""
if args and args[0] in ["--help", "-h"]:
console.print("[yellow]Usage: drone @spawn sync-templates [--status|--sync|--dry-run][/yellow]")
warning("Usage: drone @spawn sync-templates [--status|--sync|--dry-run]")
console.print()
console.print(" [green](no args)[/green] Report which managed template files are stale")
console.print(" [green]--status[/green] Same as no args")
@@ -81,7 +81,7 @@ def handle_sync_templates(args: list[str]) -> int:
result = sync_templates(sync=sync, dry_run=dry_run)
except Exception as exc:
logger.error(f"[sync-templates] Unexpected error: {exc}")
console.print(f"[red]Error: {exc}[/red]")
error(str(exc))
return 1
_print_summary(result, dry_run)
@@ -119,7 +119,7 @@ def _print_summary(result: dict, dry_run: bool) -> None:
console.print(f" {name}")
if stale:
console.print(f" [yellow]Stale ({len(stale)}):[/yellow]")
warning(f"Stale ({len(stale)}):")
for name in stale:
console.print(f" {name}")
@@ -129,7 +129,7 @@ def _print_summary(result: dict, dry_run: bool) -> None:
console.print(f" {name}")
if errors:
console.print(f" [red]Errors ({len(errors)}):[/red]")
error(f"Errors ({len(errors)}):")
for err in errors:
console.print(f" {err}")
+8 -10
View File
@@ -14,7 +14,7 @@ All implementation logic lives in apps/handlers/update_ops.py.
from aipass.prax import logger
# CLI service: from cli.apps.modules import console (via aipass namespace)
from aipass.cli.apps.modules import console
from aipass.cli.apps.modules import console, error, warning
from aipass.spawn.apps.handlers.update_ops import (
update_branch,
@@ -72,7 +72,7 @@ def handle_update(args: list[str]) -> int:
Returns exit code (0=success, 1=failure).
"""
if not args:
console.print("[yellow]Usage: drone @spawn update <@branch|class --all> [--dry-run] [--trace][/yellow]")
warning("Usage: drone @spawn update <@branch|class --all> [--dry-run] [--trace]")
console.print()
console.print(" [green]@branch[/green] Update a single branch (uses its own class)")
console.print(" [green]builder --all[/green] Update all builder-class branches")
@@ -100,9 +100,7 @@ def handle_update(args: list[str]) -> int:
if "--all" in args:
if citizen_class is None:
classes = ", ".join(get_available_classes())
console.print(f"[red]Error: --all requires a citizen class[/red]")
console.print(f"[dim]Specify a class: drone @spawn update <class> --all[/dim]")
console.print(f"[dim]Available classes: {classes}[/dim]")
error("--all requires a citizen class", suggestion=f"drone @spawn update <class> --all (available: {classes})")
return 1
results = update_all(dry_run=dry_run, trace=trace, citizen_class=citizen_class)
@@ -110,7 +108,7 @@ def handle_update(args: list[str]) -> int:
return 0 if all(r.get("success") for r in results) else 1
if not targets:
console.print("[red]Error: specify a branch name (e.g. @prax) or use <class> --all[/red]")
error("specify a branch name (e.g. @prax) or use <class> --all")
return 1
# Take the first target, strip leading @
@@ -120,7 +118,7 @@ def handle_update(args: list[str]) -> int:
result = update_branch(branch_name, dry_run=dry_run, trace=trace)
except Exception as exc:
logger.error(f"[update] Unexpected error updating {branch_name}: {exc}")
console.print(f"[red]Error updating {branch_name}: {exc}[/red]")
error(f"Error updating {branch_name}: {exc}")
return 1
_print_branch_summary(result, dry_run)
@@ -141,7 +139,7 @@ def _print_branch_summary(result: dict, dry_run: bool) -> None:
if success:
console.print(f"[green]Update {mode}{branch}[/green]")
else:
console.print(f"[red]Update FAILED {mode}{branch}[/red]")
error(f"Update FAILED {mode}{branch}")
console.print(f" Additions: {result.get('additions', 0)}")
console.print(f" Renames: {result.get('renames', 0)}")
@@ -151,7 +149,7 @@ def _print_branch_summary(result: dict, dry_run: bool) -> None:
errs = result.get("errors", [])
if errs:
console.print(f" [red]Errors: {len(errs)}[/red]")
error(f"Errors: {len(errs)}")
for e in errs:
console.print(f" - {e}")
@@ -223,5 +221,5 @@ def _print_all_summary(results: list[dict], dry_run: bool) -> None:
f"!{total_skip} py-skipped")
if total_err:
console.print(f" [red]{total_err} errors across all branches[/red]")
error(f"{total_err} errors across all branches")
console.print()