> ## Documentation Index
> Fetch the complete documentation index at: https://dify-6c0370d8-add-new-agent.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Bundle 插件包

> 本文档介绍 Bundle 插件包的概念和开发方法。Bundle 插件包可以将多个插件聚合在一起，支持三种类型（Marketplace、GitHub 和 Package）。文档详细介绍了创建 Bundle 项目、添加不同类型依赖以及打包 Bundle 项目的整个流程。

<Note> ⚠️ 本文档由 AI 自动翻译。如有任何不准确之处，请参考[英文原版](/en/develop-plugin/features-and-specs/advanced-development/bundle)。</Note>

Bundle 插件包是多个插件的集合。它允许在单个插件中打包多个插件，实现批量安装并提供更强大的服务。

你可以使用 Dify CLI 工具将多个插件打包成一个 Bundle。Bundle 插件包分为三种类型：

* `Marketplace` 类型。存储插件的 ID 和版本信息。导入时，将从 Dify Marketplace 下载特定的插件包。
* `GitHub` 类型。存储 GitHub 仓库地址、发布版本号和资源文件名。导入时，Dify 将访问对应的 GitHub 仓库下载插件包。
* `Package` 类型。插件包直接存储在 Bundle 内部。它不存储引用来源，但这可能导致 Bundle 包体积较大。

### 前置条件

* Dify 插件脚手架工具
* Python 环境，版本 ≥ 3.10

有关如何准备插件开发脚手架工具的详细说明，请参阅[初始化开发工具](/zh/develop-plugin/getting-started/cli)。

### 创建 Bundle 项目

在当前目录下，运行脚手架命令行工具创建新的插件包项目。

```bash theme={null}
./dify-plugin-darwin-arm64 bundle init
```

如果你已将二进制文件重命名为 `dify` 并复制到 `/usr/local/bin` 路径，可以运行以下命令创建新的插件项目：

```bash theme={null}
dify bundle init
```

#### 1. 填写插件信息

按照提示配置插件名称、作者信息和插件描述。如果你是团队协作，也可以输入组织名称作为作者。

> 名称长度必须为 1-128 个字符，只能包含字母、数字、连字符和下划线。

![Bundle 基本信息](https://assets-docs.dify.ai/2024/12/03a1c4cdc72213f09523eb1b40832279.png)

填写信息并按 Enter 后，将自动创建 Bundle 插件项目目录。

![](https://assets-docs.dify.ai/2024/12/356d1a8201fac3759bf01ee64e79a52b.png)

#### 2. 添加依赖

* **Marketplace**

执行以下命令：

```bash theme={null}
dify-plugin bundle append marketplace . --marketplace_pattern=langgenius/openai:0.0.1
```

其中 `marketplace_pattern` 是插件在 marketplace 中的引用，格式为 `organization_name/plugin_name:version_number`。

* **GitHub**

执行以下命令：

```bash theme={null}
dify-plugin bundle append github . --repo_pattern=langgenius/openai:0.0.1/openai.difypkg
```

其中 `repo_pattern` 是插件在 GitHub 上的引用，格式为 `organization_name/repository_name:release/asset_name`。

* **Package**

执行以下命令：

```bash theme={null}
dify-plugin bundle append package . --package_path=./openai.difypkg
```

其中 `package_path` 是插件包的目录。

### 打包 Bundle 项目

运行以下命令打包 Bundle 插件：

```bash theme={null}
dify-plugin bundle package ./bundle
```

执行命令后，将在当前目录自动创建 `bundle.difybndl` 文件。该文件即为最终的打包结果。

***

[编辑此页面](https://github.com/langgenius/dify-docs/edit/main/en/develop-plugin/features-and-specs/advanced-development/bundle.mdx) | [报告问题](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml)
