CLI tool to manage Dify workflows via DSL files
npm install dify-cli


CLI tool to manage Dify workflows via DSL files.
- Update existing workflows with local DSL files
- Publish workflows to make them available via API
- Create new workflows from DSL templates
- List available workflow files
Add to your project:
``bash`
pnpm add dify-cli dotenv-cli
Create package.json scripts:
`json`
{
"scripts": {
"dify": "dotenv -e .env -- dify-cli",
"list": "dotenv -e .env -- dify-cli list",
"update": "dotenv -e .env -- dify-cli update",
"publish": "dotenv -e .env -- dify-cli publish",
"new": "dotenv -e .env -- dify-cli new"
}
}
Configure .env:
`bash`
DIFY_URL="https://dify.example.com"
DIFY_USER_EMAIL="your-email@example.com"
DIFY_USER_PASSWORD="your-password"
WORKFLOWS_DIR="./workflows"
Run commands:
`bash`
pnpm run list
pnpm run update
pnpm run publish
pnpm run new
`bash`
npm install -g dify-cli
`bashClone the repository
git clone https://github.com/jimx7/dify-cli.git
cd dify-cli
Configuration
Create
.env file with your Dify credentials:`bash
DIFY_URL="https://dify.example.com"
DIFY_USER_EMAIL="your-email@example.com"
DIFY_USER_PASSWORD="your-password"
WORKFLOWS_DIR="./workflows"
`Usage
$3
| Command | Description |
|---------|-------------|
|
list | List available workflow files |
| update | Update existing workflow with DSL file |
| publish | Publish workflow (make available via API) |
| new | Create new workflow, rename file with returned ID |$3
DSL files are stored in
workflows/ directory:- Deployed workflows:
(with ID in filename)
- New workflows: (without ID, will be renamed after creation)Example:
`
workflows/
├── document-assistant_00f0761f-43fc-4532-b160-407401f4e5f7.yml # deployed
└── new-workflow.yml # ready to create
`$3
`bash
List all workflows
pnpm run listUpdate an existing workflow
pnpm run update 00f0761f-43fc-4532-b160-407401f4e5f7Publish a workflow
pnpm run publish 00f0761f-43fc-4532-b160-407401f4e5f7Create a new workflow from template
(First create workflows/my-chatbot.yml)
pnpm run new my-chatbot
`Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
|
DIFY_URL | Dify instance URL | - |
| DIFY_USER_EMAIL | Login email | - |
| DIFY_USER_PASSWORD | Login password | - |
| WORKFLOWS_DIR | Workflows directory path | ./workflows |
| NODE_TLS_REJECT_UNAUTHORIZED | SSL verification | 0 |DSL File Format
Dify DSL files are YAML files that define workflow structure. Example:
`yaml
app:
description: My Chatbot
icon: "\U0001F916"
icon_background: '#2563EB'
mode: advanced-chat
name: My Chatbot
kind: app
version: 0.5.0
workflow:
graph:
nodes:
- data:
type: start
title: User Input
id: start_node
- data:
type: llm
title: LLM
model:
name: gpt-4
provider: openai
prompt_template:
- role: system
text: You are a helpful assistant.
id: llm_node
- data:
type: answer
answer: '{{#llm_node.text#}}'
id: answer_node
edges:
- source: start_node
target: llm_node
- source: llm_node
target: answer_node
``MIT