Skip to main content

CLI Overview

@workflow-code/cli Only one workflow-code command is exposed, and it is divided into two command groups based on their respective purposes:

Command GroupPurpose
workflow-codeRun in a local workflow directory, print JSON reports, inspect structure, or start a stdio MCP Server.
workflow-code workspace / pnpm exec workflow-code workspaceConnect Workflow Server to log in, package, upload, publish, remotely run, debug, download, and version query.

Command Index

CLICommand
workflow-coderun, json, structure, resolve-params, mcp, help
workspacelogin, logout, status, health, pack, upload, publish, versions, run, debug-node, download, help

Typical Workflow

For local development, use workflow-code to verify the running results and structure in the workflow directory, and then use the workspace CLI to upload to the server.

workflow-code run workspace/workflow/hello -- --message "hello"
workflow-code json workspace/workflow/hello -- --message "hello"
workflow-code structure workspace/workflow/hello
workflow-code mcp workspace/workflow/hello
workflow-code json workspace/workflow/runtime-timer -- --title "Fixture Timer" --milliseconds 2000

When deploying to the server, first check the service status, then log in, upload the files, deploy, and run the application remotely.

pnpm exec workflow-code workspace health --server http://localhost:7125
pnpm exec workflow-code workspace login --server http://localhost:7125
pnpm exec workflow-code workspace upload hello
pnpm exec workflow-code workspace publish hello --release-log "Initial release"
pnpm exec workflow-code workspace run hello --target latest --message "hello"

In the development environment, you can use the local server address; in the production environment, it is recommended to explicitly use the official domain name or your production port.

Configuration Source

ConfigurationDescription
WORKFLOW_SERVER_URLDefault server address for workspace CLI.
WORKFLOW_SERVER_ADMIN_KEYExplicit administrator override credentials workspace CLI; automation or recovery scenarios can be used directly as a Bearer.
WORKFLOW_REPO_ROOTThe project root directory of workspace CLI. When not set, it is derived by traversing upward from the current directory.
WORKFLOW_CLI_AUTH_DIRThe workspace CLI is the directory that stores the independent login state workflow-auth.json.
WORKFLOW_DESKTOP_CONFIG_DIRDirectory for the Desktop connection configuration file workflow-desktop.json.
WORKFLOW_KV_STORE_DIRworkflow-code Local runtime KV store directory.
WORKFLOW_PERSISTENT_VALUE_STORE_DIRThe workflow-code local runtime PersistentValue store directory, which is also the local repository directory.
WORKFLOW_FILE_STORE_DIRworkflow-code The store directory for local runtime files.

workflow-code run/json requires an explicit workflowCode.projectInfo.dataStorage.mode. WORKFLOW_KV_STORE_DIR controls only context.storage.local.kv, while WORKFLOW_PERSISTENT_VALUE_STORE_DIR controls only context.storage.local.persistentValue and local Knowledge. They are isolated by project UUID and never fall back to each other. context.storage.server uses the top-level project UUID and an authenticated connection from WORKFLOW_SERVER_URL / WORKFLOW_SERVER_ADMIN_KEY or workspace CLI workflow-auth.json. local runs offline, server requires login and same-UUID binding, and both lets source code select explicitly. The two locations never synchronize automatically. Pass each related-project directory explicitly with repeatable --related-project alias=/absolute/project/path; CLI never scans parent or sibling directories. context.files.createFile(...) still uses the server connection; input attachment resolution remains controlled by WORKFLOW_FILE_STORE_DIR.

Workspace CLI reads .env from the current working directory. When WORKFLOW_REPO_ROOT is set explicitly, it also reads .env from that project root. The .env.example file at the CLI repository root provides a minimal configuration template.

Output Convention

Command familyOutput
workflow-code runOn success, output the contents of the output node; on failure, output JSON is reported to stderr.
workflow-code jsonAlways generate a complete JSON execution report.
workflow-code structureOutput workflow structure JSON.
workflow-code mcpReserves stdout for stdio JSON-RPC and writes project logs and diagnostics to stderr.
workspace CLIOutput server API response JSON, like { errCode, errMessage, data }.

Follow-up Reading