commit 853d04c3571786869f4f204707158e3744606370 Author: junjie.miao Date: Mon Mar 17 13:51:53 2025 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c9372ab --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +.idea +.vscode +*.iml \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..090cd6b --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +## Dify 1.0 Plugin Downloading and Repackaging + + +### Description + +#### From the Dify Marketplace downloading and repackaging + +![market](images/market.png) + +```shell +sh plugin_repackaging.sh market junjiem mcp_sse 0.0.1 +``` + + +#### From the Github downloading and repackaging + +![github](images/github.png) + +```shell +sh plugin_repackaging.sh github https://github.com/junjiem/dify-plugin-agent-mcp_sse 0.0.1 agent-mcp_see.difypkg +``` + diff --git a/dify-plugin-linux-amd64-5g b/dify-plugin-linux-amd64-5g new file mode 100644 index 0000000..6015d40 Binary files /dev/null and b/dify-plugin-linux-amd64-5g differ diff --git a/images/github.png b/images/github.png new file mode 100644 index 0000000..9ce2b35 Binary files /dev/null and b/images/github.png differ diff --git a/images/market.png b/images/market.png new file mode 100644 index 0000000..e846cc1 Binary files /dev/null and b/images/market.png differ diff --git a/plugin_repackaging.sh b/plugin_repackaging.sh new file mode 100644 index 0000000..4bc9502 --- /dev/null +++ b/plugin_repackaging.sh @@ -0,0 +1,95 @@ +#!/bin/bash +# author: Junjie.M + +MARKETPLACE_API_URL=https://marketplace.dify.ai +PIP_MIRROR_URL=https://mirrors.aliyun.com/pypi/simple + +market(){ + if [[ -z "$2" || -z "$3" || -z "$4" ]]; then + echo "" + echo "Usage: "$0" market [plugin author] [plugin name] [plugin version]" + echo "Example:" + echo " "$0" market junjiem mcp_sse 0.0.1" + echo " "$0" market langgenius agent 0.0.9" + echo "" + exit 2 + fi + echo "From the Dify Marketplace downloading ..." + PLUGIN_AUTHOR=$2 + PLUGIN_NAME=$3 + PLUGIN_VERSION=$4 + PLUGIN_ALL_NAME=${PLUGIN_AUTHOR}-${PLUGIN_NAME}_${PLUGIN_VERSION} + PLUGIN_PACKAGE_NAME=${PLUGIN_ALL_NAME}.difypkg + PLUGIN_DOWNLOAD_URL=${MARKETPLACE_API_URL}/api/v1/plugins/${PLUGIN_AUTHOR}/${PLUGIN_NAME}/${PLUGIN_VERSION}/download + repackage ${PLUGIN_ALL_NAME} ${PLUGIN_PACKAGE_NAME} ${PLUGIN_DOWNLOAD_URL} +} + +github(){ + if [[ -z "$2" || -z "$3" || -z "$4" ]]; then + echo "" + echo "Usage: "$0" github [Github repo] [Release title] [Assets name (include .difypkg suffix)]" + echo "Example:" + echo " "$0" github https://github.com/junjiem/dify-plugin-tools-dbquery v0.0.2 db_query.difypkg" + echo " "$0" github https://github.com/junjiem/dify-plugin-agent-mcp_sse 0.0.1 agent-mcp_see.difypkg" + echo "" + exit 3 + fi + echo "From the Github downloading ..." + GITHUB_REPO=$2 + RELEASE_TITLE=$3 + ASSETS_NAME=$4 + PLUGIN_NAME="${ASSETS_NAME%.difypkg}" + PLUGIN_ALL_NAME=${PLUGIN_NAME}-${RELEASE_TITLE} + PLUGIN_PACKAGE_NAME=${PLUGIN_ALL_NAME}.difypkg + PLUGIN_DOWNLOAD_URL=${GITHUB_REPO}/releases/download/${RELEASE_TITLE}/${ASSETS_NAME} + repackage ${PLUGIN_ALL_NAME} ${PLUGIN_PACKAGE_NAME} ${PLUGIN_DOWNLOAD_URL} +} + +repackage(){ + local PLUGIN_ALL_NAME=$1 + local PLUGIN_PACKAGE_NAME=$2 + local PLUGIN_DOWNLOAD_URL=$3 + echo "Download ${PLUGIN_PACKAGE_NAME} ..." + curl -L -o ./${PLUGIN_PACKAGE_NAME} ${PLUGIN_DOWNLOAD_URL} + if [[ $? -ne 0 ]]; then + echo "Download failed, please check the plugin author, name and version." + exit 1 + fi + echo "Download success, unziping ..." + install_unzip + unzip -o ./${PLUGIN_PACKAGE_NAME} -d ./${PLUGIN_ALL_NAME} + echo "Unzip success, repackaging ..." + cd ./${PLUGIN_ALL_NAME} + pip download -r requirements.txt -d ./wheels --index-url ${PIP_MIRROR_URL} + sed -i '1i\--no-index --find-links=./wheels/' requirements.txt + sed -i '/^wheels\/$/d' .difyignore + cd .. + chmod 755 ./dify-plugin-linux-amd64-5g + ./dify-plugin-linux-amd64-5g plugin package ./${PLUGIN_ALL_NAME} -o ${PLUGIN_ALL_NAME}-offline.difypkg +} + +install_unzip(){ + rpms=(`rpm -q unzip`) + if [ ${#rpms[@]} -ne 1 ]; then + echo "Installing unzip ..." + yum -y install unzip + if [ $? -ne 0 ]; then + echo "Install unzip failed." + exit 11 + fi + fi +} + +case "$1" in + 'market') + market $@ + ;; + 'github') + github $@ + ;; + *) + +echo "usage: $0 {market|github}" +exit 1 +esac +exit 0