prvng_core/nulib/main_provisioning/commands/diagnostics.nu
Jesús Pérez 894046ef5a
feat(core): three-layer DAG, unified component arch, commands-registry cache, Nushell 0.112.2 migration
- DAG architecture: `dag show/validate/export` (nulib/main_provisioning/dag.nu),
    config loader (lib_provisioning/config/loader/dag.nu), taskserv dag-executor.
    Backed by schemas/lib/dag/*.ncl; orchestrator emits NATS events via
    WorkspaceComposition::into_workflow. See ADR-020, ADR-021.
  - Unified Component Architecture: components/mod.nu, main_provisioning/
    {components,workflow,extensions,ontoref-queries}.nu. Full workflow engine with
    topological sort and NATS subject emission. Blocks A-H complete (libre-daoshi).
  - Commands-registry: nulib/commands-registry.ncl (Nickel source, 314 lines) +
    JSON cache at ~/.cache/provisioning/commands-registry.json rebuilt on source
    change. cli/provisioning fast-path alias expansion avoids cold Nu startup.
    ADDING_COMMANDS.md documents new-command workflow.
  - Platform service manager: service-manager.nu (+573), startup.nu (+611),
    service-check.nu (+255); autostart/bootstrap/health/target refactored.
  - Nushell 0.112.2 migration: removed all try/catch and bash redirections;
    external commands prefixed with ^; type signatures enforced. Driven by
    scripts/refactor-try-catch{,-simplified}.nu.
  - TTY stack: removed shlib/*-tty.sh; replaced by cli/tty-dispatch.sh,
    tty-filter.sh, tty-commands.conf.
  - New domain modules: images/ (golden image lifecycle), workspace/{state,sync}.nu,
    main_provisioning/{bootstrap,cluster-deploy,fip,state}.nu, commands/{state,
    build,integrations/auth,utilities/alias}.nu, platform.nu expanded (+874).
  - Config loader overhaul: loader/core.nu slimmed (-759), cache/core.nu
    refactored (-454), removed legacy loaders/file_loader.nu (-330).
  - Thirteen new provisioning-<domain>.nu top-level modules for bash dispatcher.
  - Tests: test_workspace_state.nu (+351); updates to test_oci_registry,
    test_services.
  - README + CHANGELOG updated.
2026-04-17 04:27:33 +01:00

79 lines
2.4 KiB
Text

# Diagnostics Command Handlers
# Handles: status, health, next
use ../flags.nu *
# Import all from diagnostics modules
use ../../lib_provisioning/diagnostics/system_status.nu *
use ../../lib_provisioning/diagnostics/health_check.nu *
use ../../lib_provisioning/diagnostics/next_steps.nu *
# Main diagnostics command dispatcher
export def handle_diagnostics_command [
command: string
ops: string
flags: record
] {
match $command {
"status" => { handle_status $ops $flags }
"health" => { handle_health $ops $flags }
"next" => { handle_next $flags }
"phase" => { handle_phase $flags }
"" | "diagnostics" => { handle_status $ops $flags } # Default to status when no subcommand
_ => {
print $"❌ Unknown diagnostics command: ($command)"
print ""
print "Available diagnostics commands:"
print " status - Show comprehensive system status"
print " health - Run deep health validation"
print " next - Get next steps recommendations"
print " phase - Show current deployment phase"
exit 1
}
}
}
# Status command handler
def handle_status [ops: string, flags: record] {
let subcommand = ($ops | str trim)
if $subcommand == "json" or ($flags.out? | default "" | str trim) == "json" {
provisioning status-json | to json
} else {
provisioning status
}
}
# Health command handler
def handle_health [ops: string, flags: record] {
let subcommand = ($ops | str trim)
if $subcommand == "json" or ($flags.out? | default "" | str trim) == "json" {
provisioning health-json | to json
} else {
provisioning health
}
}
# Next steps command handler
def handle_next [flags: record] {
if ($flags.out? | default "" | str trim) == "json" {
provisioning phase | to json
} else {
provisioning next
}
}
# Phase command handler
def handle_phase [flags: record] {
let phase_info = (provisioning phase)
if ($flags.out? | default "" | str trim) == "json" {
$phase_info | to json
} else {
print $"(ansi cyan_bold)Current Deployment Phase(ansi reset)\n"
print $"Phase: (ansi yellow)($phase_info.info.phase)(ansi reset)"
print $"Description: ($phase_info.info.description)"
print $"Progress: ($phase_info.info.step)/($phase_info.info.total_steps) steps \(($phase_info.progress_percentage)%\)"
print $"Ready for deployment: (if $phase_info.info.ready_for_deployment { '✅ Yes' } else { '❌ No' })"
}
}