_athena_completion() {
  local current previous commands
  current="${COMP_WORDS[COMP_CWORD]}"
  previous="${COMP_WORDS[COMP_CWORD-1]}"
  commands="agent ai audit autopilot backup banner brain brief changelog check compare context control cve dashboard db decision demo deploy distro dns docs docs-site doctor dotfiles e2e examples expert factory fail2ban firewall fix handoff harden hardware iac idea index integrations launch learn local-cloud logs memory new observe openapi policy ports projects prompt prompts ps qa release-check release-notes release-room report restart roadmap rollout run sbom scaffold sdk secret security-checklist self-test shell sign-image snapshot status stop sync tasks template terraform test update upgrade vault version workspace"

  if [[ "${COMP_CWORD}" -eq 1 ]]; then
    COMPREPLY=($(compgen -W "${commands}" -- "${current}"))
    return 0
  fi

  case "${previous}" in
    new)        COMPREPLY=($(compgen -W "agent django express fastapi fullstack landing laravel nestjs nextjs saas vite" -- "${current}")) ;;
    projects)   COMPREPLY=($(compgen -W "archive clean list open search status tag untag" -- "${current}")) ;;
    template)   COMPREPLY=($(compgen -W "create list remove" -- "${current}")) ;;
    factory)    COMPREPLY=($(compgen -W "monorepo new" -- "${current}")) ;;
    db)         COMPREPLY=($(compgen -W "backup migrate reset restore seed shell start" -- "${current}")) ;;
    memory)     COMPREPLY=($(compgen -W "add build search" -- "${current}")) ;;
    workspace)  COMPREPLY=($(compgen -W "create list status use" -- "${current}")) ;;
    sync)       COMPREPLY=($(compgen -W "export import plan" -- "${current}")) ;;
    dotfiles)   COMPREPLY=($(compgen -W "apply init list" -- "${current}")) ;;
    vault)      COMPREPLY=($(compgen -W "backup get list rotate set" -- "${current}")) ;;
    harden)     COMPREPLY=($(compgen -W "docker ssh sysctl" -- "${current}")) ;;
    qa)         COMPREPLY=($(compgen -W "a11y api db gate mutation perf visual" -- "${current}")) ;;
    observe)    COMPREPLY=($(compgen -W "alerts bundle docker health profile stack timeline" -- "${current}")) ;;
    deploy)     COMPREPLY=($(compgen -W "coolify docker fly kubernetes local nomad railway vercel vps" -- "${current}")) ;;
    scaffold)   COMPREPLY=($(compgen -W "admin crud" -- "${current}")) ;;
    terraform)  COMPREPLY=($(compgen -W "apply init plan scaffold validate" -- "${current}")) ;;
    control)    COMPREPLY=($(compgen -W "html serve status" -- "${current}")) ;;
    brain)      COMPREPLY=($(compgen -W "ask build export" -- "${current}")) ;;
    autopilot)  COMPREPLY=($(compgen -W "plan run status" -- "${current}")) ;;
    local-cloud) COMPREPLY=($(compgen -W "down env init up" -- "${current}")) ;;
    release-room) COMPREPLY=($(compgen -W "build gate html" -- "${current}")) ;;
    sign-image) COMPREPLY=($(compgen -W "--execute --image --key --sign-action" -- "${current}")) ;;
    upgrade)    COMPREPLY=($(compgen -W "--check --dry-run --yes --desktop --testing" -- "${current}")) ;;
  esac
}
complete -F _athena_completion athena ath
