> ## 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.

# Dify 插件开发速查表

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

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

### 环境要求

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

> 了解更多：[初始化开发工具](/zh/develop-plugin/getting-started/cli)

### 获取 Dify 插件开发包

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

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

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

```bash theme={null}
brew tap langgenius/dify
brew install dify
```

安装完成后，打开一个新的终端窗口并输入 `dify version` 命令。如果输出版本信息，则表示安装成功。

**macOS ARM（M 系列芯片）：**

```bash theme={null}
# Download dify-plugin-darwin-arm64
chmod +x dify-plugin-darwin-arm64
./dify-plugin-darwin-arm64 version
```

**macOS Intel：**

```bash theme={null}
# Download dify-plugin-darwin-amd64
chmod +x dify-plugin-darwin-amd64
./dify-plugin-darwin-amd64 version
```

**Linux：**

```bash theme={null}
# Download dify-plugin-linux-amd64
chmod +x dify-plugin-linux-amd64
./dify-plugin-linux-amd64 version
```

**全局安装（推荐）：**

```bash theme={null}
# Rename and move to system path
# Example (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 theme={null}
./dify plugin init
```

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

> 了解更多：[Dify 插件开发：Hello World 指南](/zh/develop-plugin/dev-guides-and-walkthroughs/tool-plugin)

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

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

```bash theme={null}
python -m main
```

> 了解更多：[远程调试插件](/zh/develop-plugin/features-and-specs/plugin-types/remote-debug-a-plugin)

#### 3. 打包和部署

打包插件：

```bash theme={null}
cd ..
dify plugin package ./yourapp
```

> 了解更多：[发布概览](/zh/develop-plugin/publishing/marketplace-listing/release-overview)

### 插件类别

#### 工具标签

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

```python theme={null}
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 和服务
  > 了解更多：[Dify 插件开发：Hello World 指南](/zh/develop-plugin/dev-guides-and-walkthroughs/tool-plugin)

* **模型插件**：集成 AI 模型
  > 了解更多：[模型插件](/zh/develop-plugin/features-and-specs/plugin-types/model-designing-rules)，[快速集成新模型](/zh/develop-plugin/dev-guides-and-walkthroughs/creating-new-model-provider)

* **智能体策略插件**：自定义智能体思考和决策策略
  > 了解更多：[智能体策略插件](/zh/develop-plugin/features-and-specs/advanced-development/reverse-invocation)

* **扩展插件**：扩展 Dify 平台功能，如 Endpoints 和 WebAPP
  > 了解更多：[扩展插件](/zh/develop-plugin/dev-guides-and-walkthroughs/endpoint)

* **数据源插件**：作为知识库管道的文档数据源和起点
  > 了解更多：[数据源插件](/zh/develop-plugin/dev-guides-and-walkthroughs/datasource-plugin)

* **触发器插件**：在第三方事件发生时自动触发工作流执行
  > 了解更多：[触发器插件](/zh/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin)

***

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