name: get_system_info
id: org.themobileprof.get_system_info
version: 1.0.0
description: Display system information (OS, kernel, architecture, hostname)
tags: [system-ops, atomic, info, diagnostics]
provides:
  - system_info_shown
requires: []
size_kb: 3

flows:
  main:
    start: gather_info
    steps:
      gather_info:
        type: action
        message: "Gathering system information..."
        command: |
          echo "💻 System Information"
          echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
          echo ""
          
          # Hostname
          echo "Hostname:      $(hostname 2>/dev/null || echo 'unknown')"
          
          # Operating System
          if [ -f /etc/os-release ]; then
            . /etc/os-release
            echo "OS:            $PRETTY_NAME"
          elif [ "$(uname)" = "Darwin" ]; then
            echo "OS:            macOS $(sw_vers -productVersion 2>/dev/null)"
          else
            echo "OS:            $(uname -s)"
          fi
          
          # Kernel
          echo "Kernel:        $(uname -r)"
          
          # Architecture
          echo "Architecture:  $(uname -m)"
          
          # Number of CPUs
          if [ -f /proc/cpuinfo ]; then
            CPUS=$(grep -c processor /proc/cpuinfo)
            echo "CPU Cores:     $CPUS"
          fi
          
          # Memory (Linux)
          if [ -f /proc/meminfo ]; then
            MEM_TOTAL=$(grep MemTotal /proc/meminfo | awk '{print $2}')
            MEM_TOTAL_GB=$((MEM_TOTAL / 1024 / 1024))
            echo "Memory:        ${MEM_TOTAL_GB} GB"
          # Memory (macOS)
          elif command -v sysctl >/dev/null 2>&1; then
            MEM_BYTES=$(sysctl -n hw.memsize 2>/dev/null)
            if [ -n "$MEM_BYTES" ]; then
              MEM_GB=$((MEM_BYTES / 1024 / 1024 / 1024))
              echo "Memory:        ${MEM_GB} GB"
            fi
          fi
          
          # Uptime
          if command -v uptime >/dev/null 2>&1; then
            echo "Uptime:        $(uptime -p 2>/dev/null || uptime | awk '{print $3, $4}')"
          fi
          
          # Shell
          echo "Shell:         $SHELL"
          
          # User
          echo "User:          $(whoami)"
          
          # Home Directory
          echo "Home:          $HOME"
          
          echo ""
          echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
          
          # Platform detection
          if [ -f /etc/os-release ]; then
            . /etc/os-release
            if [ "$ID" = "debian" ] || [ "$ID" = "ubuntu" ]; then
              echo "Platform:      Debian/Ubuntu-based"
              echo "Package Mgr:   apt"
            elif [ "$ID" = "fedora" ] || [ "$ID" = "rhel" ] || [ "$ID" = "centos" ]; then
              echo "Platform:      RedHat-based"
              echo "Package Mgr:   dnf/yum"
            elif [ "$ID" = "arch" ]; then
              echo "Platform:      Arch Linux"
              echo "Package Mgr:   pacman"
            fi
          elif [ "$(uname)" = "Darwin" ]; then
            echo "Platform:      macOS"
            echo "Package Mgr:   brew (if installed)"
          fi
          
          # Check if Termux
          if [ -n "$TERMUX_VERSION" ] || [ -d "$PREFIX" ]; then
            echo "Environment:   Termux (Android)"
            echo "Package Mgr:   pkg"
          fi
        next: end
      
      end:
        type: terminal
        message: "System information displayed"
