npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tplog/agent-dify

v0.3.2

Published

CLI tool for Dify - import/export app DSL, semantic diff, validation

Readme

agent-dify

一个通过浏览器会话对 Dify app DSL 进行导入、导出和轻量 app 管理的 CLI 工具。

安装

curl -fsSL https://raw.githubusercontent.com/tplog/agent-dify/main/install.sh | sh

或者从 GitHub Releases 下载二进制文件。

概览

agent-dify 并不是一个主要面向人类日常操作的 CLI。它的设计目标,是让 LLM / AI agent 通过命令行去操作 Dify 实例,重点覆盖 app DSL 的导入、导出和基础 app 管理。

而这份 README,是写给人看的:帮助你理解这个工具是做什么的、如何安装、如何完成一次性认证,以及如何决定让 agent 以什么方式来使用它。

支持的应用类型

agent-dify 目前聚焦于以下两种 Dify 应用类型:

| 应用类型 | Dify Mode | 支持级别 | 说明 | |----------|-----------|----------|------| | Workflow | workflow | 稳定 | 完全支持,推荐用于自动化任务 | | Chatflow | advanced-chat | 实验性 | 导入后 Graph 可能无法完全保留 |

  • Workflow: 一次性执行流程,有确定的输入/输出
  • Chatflow: 多轮对话流程,支持 conversation_variablessys.dialogue_count 等特性

导入时请通过 --app-type workflow--app-type chatflow 显式指定目标类型。

适用对象

  • 人类:完成初始化配置、认证,以及理解整体使用方式
  • LLM / AI agent:实际执行命令和日常调用

命令

认证

agent-dify auth import-browser           # 从浏览器导入当前 Dify 会话
agent-dify auth test                     # 验证当前会话是否有效
agent-dify auth whoami                   # 显示当前账号信息

App 管理

agent-dify app list                      # 列出所有 app
agent-dify app export <id> [-o a.yaml]   # 将 app DSL 导出到本地文件
agent-dify app export-all [-o ./refs/]   # 批量导出所有 app DSL
agent-dify app import <file.yaml>        # 导入 DSL 并创建 app
agent-dify app delete <id>               # 删除 app(需要 destructive mode)
agent-dify delete <id>                   # 同上

Import(validate + import)

# Workflow(稳定)
agent-dify import workflow.yaml --app-type workflow
agent-dify import workflow.yaml --app-type workflow --json
agent-dify import workflow.yaml --app-type workflow --app-id <id>

# Chatflow(实验性)
agent-dify import chatflow.yaml --app-type chatflow --allow-experimental
agent-dify import chatflow.yaml --app-type chatflow --allow-experimental --json

注意: Chatflow 导入需要 --allow-experimental 参数,并会输出关于 graph 保真度的警告。

DSL 生成与校验

agent-dify dsl scaffold llm                   # 生成 LLM 节点 scaffold
agent-dify dsl scaffold start --format json   # 以 JSON 格式输出 scaffold

# 带类型检测的校验
agent-dify dsl validate workflow.yaml                    # 自动检测 mode
agent-dify dsl validate workflow.yaml --app-type workflow # 强制要求 workflow mode
agent-dify dsl validate chatflow.yaml --app-type chatflow # 强制要求 chatflow mode

agent-dify dsl list                           # 列出可 scaffold 的节点类型
agent-dify dsl version                        # 显示 DSL 版本信息

校验输出包含:

  • mode_detected: DSL 中发现的 app.mode
  • mode_expected: 通过 --app-type 指定的 mode
  • support_level: stable(workflow)或 experimental(chatflow)
  • errorswarnings: 结构化的校验结果

Workflow 节点探索

agent-dify nodes list                         # 列出所有 workflow 节点类型
agent-dify nodes show <node-type>             # 显示某个节点类型的详细定义

Trash 管理

agent-dify app trash list                     # 列出已删除 app 的备份
agent-dify app trash restore <file>           # 从备份恢复 app

认证

  • 从浏览器导入当前 Dify 会话(目前主要面向 Dify + Chrome)
  • 凭证保存在 ~/.config/agent-dify/credentials.json
  • 支持通过 --profile 管理多个实例

快速开始

  1. 登录 Dify Cloud:https://cloud.dify.ai
  2. 导入当前浏览器会话:
    agent-dify auth import-browser
  3. 测试连接:
    agent-dify auth test
  4. 列出 app:
    agent-dify app list
  5. 探索 workflow 节点:
    agent-dify nodes list
    agent-dify nodes show llm

Agent 工作流示例

Workflow(稳定路径)

# 1. 查看可用节点
agent-dify nodes show llm

# 2. 生成节点 scaffold
agent-dify dsl scaffold llm > node.yaml

# 3. 组装 workflow 并做本地校验
agent-dify dsl validate workflow.yaml --app-type workflow

# 4. 导入到 Dify
agent-dify import workflow.yaml --app-type workflow --json

# 5. 在同一个 app 上持续迭代
agent-dify import workflow.yaml --app-type workflow --app-id <id> --json

Chatflow(实验性路径)

# 1. 显式指定类型进行校验
agent-dify dsl validate chatflow.yaml --app-type chatflow

# 2. 使用实验性标志导入
agent-dify import chatflow.yaml --app-type chatflow --allow-experimental --json

# 3. 检查结果 - 可能需要在 Dify UI 中手动验证

构建

cargo build --release

技术栈

  • Rust 2024 edition
  • reqwest 用于 HTTP
  • serde / serde_json / serde_yaml 用于序列化
  • clap 用于 CLI 参数解析
  • keyring 用于安全 token 存储
  • rusqlite 用于读取浏览器 cookie 数据库

安全性

Delete 操作有两层保护:

  1. 默认禁用 destructive operation

    AGENT_DIFY_ALLOW_DESTRUCTIVE=true agent-dify delete <id>
  2. 删除前自动备份

    agent-dify app trash list
    agent-dify app trash restore <filename>

不包含的内容

  • 在 CLI 中直接编辑 workflow
  • app 执行 / runtime trigger
  • 日志查看
  • Web UI

License

MIT