#!/usr/bin/env bash
# Step 00: Verify fresh VM has no prerequisites installed.
# Copies check-prerequisites.sh into the VM and runs it.
# Expected: everything MISSING, exit code > 0.

step_name="Fresh VM baseline check"

run() {
  # Create temp dir in guest
  vm_exec cmd "mkdir C:\\bigstack-test 2>NUL"

  # Copy check-prerequisites.sh into the VM
  vm_exec copy-to "$SKILL_DIR/bin/check-prerequisites.sh" "$GUEST_TEMP\\check-prerequisites.sh"

  # Run via Git Bash if available, otherwise PowerShell+bash
  # On a fresh Windows install, there's no bash — run via PowerShell parsing the output
  log_info "Running prerequisite check in VM (expecting all MISSING)..."
  local output
  output=$(vm_exec cmd "C:\\bigstack-test\\check-prerequisites.sh" 2>&1) || true
  echo "$output"

  # Store output for verify()
  BASELINE_OUTPUT="$output"
}

verify() {
  # On a truly fresh Windows install, there's no bash to run the script.
  # The check script itself requires bash, so we first need to verify
  # whether the script can even run. If cmd.exe can't run .sh files,
  # that's actually a valid "nothing installed" baseline.
  #
  # For now, we verify the VM is responsive and report the baseline state.
  local hostname
  hostname=$(vm_exec cmd "hostname" 2>/dev/null)
  [[ -n "$hostname" ]]
}
