> ## Documentation Index
> Fetch the complete documentation index at: https://alterxyz-a56768d7.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Dify Plugin 开发速查表

> 全面的Dify插件开发参考指南，包括环境要求、安装方法、开发流程、插件分类及类型、常用代码片段和常见问题解决方案。适合开发者快速查阅和参考。

### 环境要求

* Python 版本 ≥ 3.12
* Dify 插件脚手架工具 (dify-plugin-daemon)

> 了解更多：[初始化开发工具](https://alterxyz-a56768d7.mintlify.site/plugin_dev_zh/0221-initialize-development-tools.zh.md)

### 获取 Dify Plugin 开发包

[Dify Plugin CLI](https://github.com/langgenius/dify-plugin-daemon/releases)

#### 不同平台安装方法

**macOS [Brew](https://github.com/langgenius/homebrew-dify)（全局安装）：**

```bash
brew tap langgenius/dify
brew install dify
```

安装完成后，新建任意终端窗口，输出 `dify version` 命令，若输出版本号信息，则说明安装成功。

**macOS ARM (M 系列芯片):**

```bash
# 下载 dify-plugin-darwin-arm64
chmod +x dify-plugin-darwin-arm64
./dify-plugin-darwin-arm64 version
```

**macOS Intel:**

```bash
# 下载 dify-plugin-darwin-amd64
chmod +x dify-plugin-darwin-amd64
./dify-plugin-darwin-amd64 version
```

**Linux:**

```bash
# 下载 dify-plugin-linux-amd64
chmod +x dify-plugin-linux-amd64
./dify-plugin-linux-amd64 version
```

**全局安装 (推荐):**

```bash
# 重命名并移动到系统路径
# 示例 (macOS ARM)
mv dify-plugin-darwin-arm64 dify
sudo mv dify /usr/local/bin/
dify version
```

### 运行开发包

这里以 `dify` 为例。如果你使用的是局部的安装方式，请根据情况替换指令例如 `./dify-plugin-darwin-arm64 plugin init`。

### 插件开发流程

#### 1. 新建插件

```bash
./dify plugin init
```

按提示完成插件基本信息配置

> 了解更多：[Dify 插件开发：Hello World 指南](https://alterxyz-a56768d7.mintlify.site/plugin_dev_zh/0211-getting-started-dify-tool.zh.md)

#### 2. 开发模式运行

配置 `.env` 文件，然后在插件目录下运行以下命令：

```bash
python -m main
```

> 了解更多：[远程调试插件](https://alterxyz-a56768d7.mintlify.site/plugin_dev_zh/0411-remote-debug-a-plugin.zh.md)

#### 4. 打包与部署

打包插件:

```bash
cd ..
dify plugin package ./yourapp
```

> 了解更多：[发布概览](https://alterxyz-a56768d7.mintlify.site/plugin_dev_zh/0321-release-overview.zh.md)

### 插件分类

#### 工具标签

分类 `tag` [class ToolLabelEnum(Enum)](https://github.com/langgenius/dify-plugin-sdks/blob/main/python/dify_plugin/entities/tool.py)

```python
class ToolLabelEnum(Enum):
    SEARCH = "search"
    IMAGE = "image"
    VIDEOS = "videos"
    WEATHER = "weather"
    FINANCE = "finance"
    DESIGN = "design"
    TRAVEL = "travel"
    SOCIAL = "social"
    NEWS = "news"
    MEDICAL = "medical"
    PRODUCTIVITY = "productivity"
    EDUCATION = "education"
    BUSINESS = "business"
    ENTERTAINMENT = "entertainment"
    UTILITIES = "utilities"
    OTHER = "other"
```

### 插件类型参考

Dify 支持多种类型的插件开发：

* **工具插件**: 集成第三方 API 和服务
  > 了解更多：[工具插件开发](https://alterxyz-a56768d7.mintlify.site/plugin_dev_zh/0211-getting-started-dify-tool.zh.md)
* **模型插件**: 集成 AI 模型
  > 了解更多：[模型插件介绍](https://alterxyz-a56768d7.mintlify.site/plugin_dev_zh/0131-model-plugin-introduction.zh.md)、[快速接入一个新模型](https://alterxyz-a56768d7.mintlify.site/plugin_dev_zh/0211-getting-started-new-model.zh.md)
* **Agent 策略插件**: 自定义 Agent 思考和决策策略
  > 了解更多：[Agent 策略插件](https://alterxyz-a56768d7.mintlify.site/plugin_dev_zh/9433-agent-strategy-plugin.zh.md)
* **扩展插件**: 扩展 Dify 平台功能，例如 Endpoint 和 WebAPP
  > 了解更多：[扩展插件](https://alterxyz-a56768d7.mintlify.site/plugin_dev_zh/9231-extension-plugin.zh.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.