# shellcheck    shell=dash
___x_cmd_raku_co(){
    [ "$#" -gt 0 ] || set -- "$(___x_cmd_cmds_cat)"
    x chat --request --type co,raku --minion "$___X_CMD_ROOT_MOD/raku/lib/minion/co.yml" "$@"
}
# using the raku facility to test the code

___x_cmd_raku_coco(){
    [ "$#" -gt 0 ] || set -- "$(___x_cmd_cmds_cat)"
    # Consider refine the code ...
    code=$(x chat --request --type coco,raku --minion "$___X_CMD_ROOT_MOD/raku/lib/minion/coco.yml" "$@")

    local feedback
    feedback=$(printf "%s\n" "$code" | x raku -c) || {
        {
            printf "Linting fail. Here is the feedback:"
            printf "%s\n" "$feedback"
        } >/dev/tty

        while true; do
            x ui select "" "what's next" "Send feedback to ai for better answer" "view the feed back and code" "Exit" || {
                co:error "Recv interrupts. Exit"
                return 130
            }
            case "$___X_CMD_UI_SELECT_RET" in
                1)
                    # x chat -n 0 --request coco,raku "$feedback" "$msg"
                    #
                    x:error "Unsuported"
                    return 1
                    ;;
                2)  printf "%s\n" "$code" | x bat -l raku ;;
                3)  return 1 ;;
            esac
        done
    }

    printf "%s\n" "$code" | x bat -l raku
    x ui yesno "Do you want to run the code" || return 0        # default is no.

    printf "%s\n" "$code" | x raku
}
