
# run with multiple skill.

# x skill run --yolo <folder>/SKILL.md
# x skill run --yolo <folder>
# Basic permission

# allow read, webfetch, websearch = 1

___x_cmd_skill_run(){

    local yolo=""
    local skill_list=""
    while [ $# -gt 0 ]; do
        case "$1" in
            --yolo)     yolo=1 ;    shift ;;
            --skill)    skill_list="${skill_list} $2" ; arg:2:shift ;;
                        # Search the home folder, or search the x-cmd registry, or just

            *)          break ;;
        esac
    done

    [ $# -gt 0 ]    ||  N=skill M="Please provide skill folder to exec." log:ret:64

    local targetfp="$1" ; shift

    local entrancefp=""

    if [ -d "$targetfp" ]; then
        ___x_cmd_skill_run___locate_ "$targetfp"    ||  N=skill M="Cannot locate SKILL.md in the folder." log:ret:64
        entrancefp="$x_"
    elif [ -f "$targetfp" ]; then
        entrancefp="$targetfp"
    fi


}

___x_cmd_skill_run___locate_(){
    local targetfp="$1"

    x_="$targetfp/SKILL.md"
    [ ! -f "$x_" ]    ||    return 0
    x_="$targetfp/skill.md"
    [ ! -f "$x_" ]    ||    return 0
    x_="$targetfp/agent.md"
    [ ! -f "$x_" ]    ||    return 0
    x_="$targetfp/AGENT.md"
    [ ! -f "$x_" ]    ||    return 0
    x_="$targetfp/CLAUDE.md"
    [ ! -f "$x_" ]    ||    return 0
    x_="$targetfp/CODEX.md"
    [ ! -f "$x_" ]    ||    return 0
    x_="$targetfp/GEMINI.md"
    [ ! -f "$x_" ]    ||    return 0

    return 1
}
