Files
dify/cli
GareArc d5dee5326e feat(cli): align HITL pause envelope, split resume into top-level command, JSON purity
- Match server SSE envelope: HitlPausePayload now mirrors {event, task_id,
  workflow_run_id, data:{...}}; renamed user_actions → actions.
- New shared hitl-render.ts: text-mode block, JSON-mode pretty pure JSON
  (no ANSI), colored stderr hint. Exit 0 on pause (no longer a process error).
- Move RunAppResume → top-level ResumeApp at commands/resume/app/; rewire
  imports + regen tree.generated.ts. User-facing strings updated to
  `difyctl resume app`.
- Spinner gated on text mode: structured strategy passes
  enabled = isText && !livePrint so -o json/yaml never spin.
- Hint emits external-channel note when form_token is null (email-only
  delivery to OPENAPI/SERVICE_API surface returns no resume token).
- ColorScheme extended with dim/cyan/green/yellow/magenta methods.
- dify-mock fixture + tests updated to envelope shape; HITL pause test
  split into text + json variants.
2026-05-18 19:25:13 -07:00
..
2026-05-18 19:07:23 +08:00
2026-05-18 19:07:23 +08:00

difyctl

CLI client for Dify platform. Browser device-flow signin, list/inspect apps, run with structured input, parse output as JSON, YAML, or human text.

Install

npm

npm install -g @langgenius/difyctl

Tarball

# macOS arm64
curl -fsSL https://github.com/langgenius/dify/releases/latest/download/difyctl-darwin-arm64.tar.xz | tar xJ -C /usr/local
ln -sf /usr/local/difyctl/bin/difyctl /usr/local/bin/difyctl

# Linux x64
curl -fsSL https://github.com/langgenius/dify/releases/latest/download/difyctl-linux-x64.tar.xz | tar xJ -C /opt
ln -sf /opt/difyctl/bin/difyctl /usr/local/bin/difyctl

Other targets: darwin-x64, linux-arm64, win32-x64.

Container

docker run --rm -it -v "$HOME/.config/difyctl:/root/.config/difyctl" \
  ghcr.io/langgenius/difyctl:latest version

Quickstart

difyctl auth login                                       # opens browser; paste the device code shown
difyctl get app                                          # list apps in default workspace
difyctl describe app <app-id>                            # inspect parameters
difyctl run app <app-id> "hello"                         # run, blocking
difyctl run app <app-id> "hello" -o json | jq .answer    # JSON output
difyctl run app <app-id> --input name=world --input topic=cats   # workflow inputs

Background docs: difyctl help account, difyctl help external, difyctl help environment.

Commands

Group Commands
auth login, logout, status, whoami, use <workspace>, devices list/revoke
get get app [<id>] [-A] [--mode] [--name] [--tag] [-o json|yaml|name|wide], get workspace
describe describe app <id> [--refresh] [-o json|yaml]
run run app <id> [<message>] [--input k=v]... [--conversation <id>] [--stream] [-o json|yaml|text]
config view, get <key>, set <key> <value>, unset <key>, path
env list
help account, external, environment
version version [--json]

Run difyctl <cmd> --help for per-command reference.

Output formats

Flag Behavior
(none) Human table, columns auto-sized to terminal.
-o wide Same as table, no column truncation.
-o json Pretty-printed JSON, machine-parseable, stable shape.
-o yaml YAML mirror of -o json.
-o name IDs only, newline-separated — pipes into xargs.
-o text kubectl-describe style human text (describe, run).

Errors emit JSON envelope to stderr in -o json mode; else human message. Exit codes deterministic.

Configuration

OS Config path
Linux ${XDG_CONFIG_HOME:-$HOME/.config}/difyctl/
macOS $HOME/.config/difyctl/
Windows %APPDATA%\difyctl\

Override with DIFY_CONFIG_DIR=/some/path. Files written 0600, directory 0700. Tokens use OS keychain by default, fall back to sealed file on hosts without one.

For every env var difyctl reads, run difyctl env list (machine-readable) or difyctl help environment (narrative).

Streaming

run app uses blocking transport by default. For long-running apps (likely exceed ~30s) pass --stream:

difyctl run app app-1 "tell me about cats" --stream

Agent apps (mode === 'agent-chat' or is_agent flag set) stream regardless — Dify backend rejects blocking requests for agent mode. Combining --stream with -o json or -o yaml aggregates SSE events into same envelope shape as blocking response, so structured output identical regardless of transport.

HTTP retry

Idempotent requests (GET, PUT, DELETE) retry on transient network/DNS failures with exponential backoff. Default count: 3. POST and PATCH never retry — side effects possible.

Knob Effect
--http-retry <n> Per-invocation override. 0 disables retries.
DIFYCTL_HTTP_RETRY=<n> Process-level default.

Resolution: flag → env → 3.

Contributing

See ARD.md for architecture patterns, scaffolding recipe, dev workflow.

License

Apache-2.0.