
___x_cmd_groovy_co(){
    [ "$#" -gt 0 ] || set -- "$(___x_cmd_cmds_cat)"
    local IFS=" "
    local user_message="$___X_CMD_CHAT_PROMPT_CODE
        IMPORTANT: ONLY COMMAND LINE using groovy command as output, return only plaintext.
        You MUST always follow them. No exceptions.

        Example: running the file hi.groovy
        groovy hi.groovy

        Example: compile the groovy code to class code
        groovyc hi.groovy

        prompt: $*
    "
    local msg; msg='{
        role: user,
        content: '$(x chat --jqu "$user_message")'
    }'

    x chat -n 0 --request co,groovy "" "$msg"
}

# using the groovy facility to test the code

___x_cmd_groovy_coco(){
    [ "$#" -gt 0 ] || set -- "$(___x_cmd_cmds_cat)"
    local IFS=" "
    local user_message="$___X_CMD_CHAT_PROMPT_CODE""
        IMPORTANT: ONLY groovy CODE as output, return only plaintext.
        You MUST always follow them. No exceptions.

        Example: create a file named test.txt with the content 'hello world'
        def file = new File('test.txt')
        file.write('hello world')

        Example: get the content from x-cmd.com
        def url = new URL(\"https://x-cmd.com\")
        println(url.openConnection().getInputStream().text)

        prompt: '$*'
    "
    local msg; msg='{
        role: user,
        content: '$(x chat --jqu "$user_message")'
    }'

    # Consider refine the code ...
    ___x_cmd chat -n 0 --request coco,groovy "" "$msg"
}

