#compdef workforest wf
# zsh completion for workforest / wf — installed to zsh site-functions.
# Dynamic candidates are delegated to `workforest --complete TOPIC`.

local topic cmd
local -a items
cmd="${words[2]:-}"
if (( CURRENT == 2 )); then
    topic=commands
else
    case "$cmd" in
        create) topic=branches ;;
        open|delete|checkout) topic=worktrees ;;
        run) topic=scripts ;;
        claude) topic=claude-sessions ;;
        tui|list|init|config|shell-init) topic=none ;;
        *) topic=worktrees ;;
    esac
fi
if [[ "$topic" != none ]]; then
    items=(${(f)"$(workforest --complete "$topic" 2>/dev/null)"})
    (( ${#items} )) && compadd -a items
fi
