Skip to content

API 参考

返回总览

这一页不重复讲教程,只收口最常查的导出、配置和结果结构

根入口导出了什么

根入口围绕四组能力展开

workflow 定义与执行

  • createWorkflowKit
  • runWorkflow
  • runWorkflowSafely
  • defineWorkflow
  • defineSteps
  • defineStep

CLI、模板与扩展

  • createWorkflowCliBridge
  • defineWorkflowTemplate
  • createWorkflowTemplateCatalog

renderer、executor 与存储

  • createClackRenderer
  • createCommandExecutor
  • createNodeCommandExecutor
  • createTinyexecCommandExecutor
  • createFileCheckpointStore
  • createMemoryCheckpointStore
  • createFileHistoryStore
  • createMemoryHistoryStore
  • createFileLogStore
  • createMemoryLogStore

工具与辅助类型

  • createWorkflowI18n
  • createI18nLocales
  • commandExists
  • runCommand
  • readTextFile、writeTextFile
  • readJson、writeJson、patchJson
  • globFiles、sleep
  • isPromptCancelledError
  • isWorkflowExecutionError

createWorkflowKit 常用选项

字段默认值说明
idkit 唯一 ID,也是 asciiArt 的最后回退来源
asciiArttrueASCII banner 开关或配置,优先尝试 title,再尝试 artTitle,最后回退 id
checkpointsfalsecheckpoint 配置或开关
executor自定义命令执行器实例
historyfalsehistory 配置或开关
logsfalselog store 配置或开关
taskLogcommand 步骤的全局 task-log 默认配置
executorTypenode内置命令执行器类型
cwdprocess.cwd()相对路径解析根目录,会映射到运行时的 projectRoot
locale自动推断默认语言
locales自定义 locale 资源目录
resolveLocale动态解析语言
resolveTimeZone动态解析时区
timeZone自动推断默认时区
renderer默认 Clack renderer自定义渲染器
rendererOptions默认 renderer 的选项
plugins[]运行时插件
showCancelMessagetrue取消时是否显示提示

createWorkflowKit({ asciiArt }) 里支持这几个字段

  • asciiArt.title 会把原始标题交给 figlet 生成 banner
  • asciiArt.artTitle 会原样输出 ASCII banner
  • asciiArt.font 控制自动生成 banner 时使用的字体

当前内置字体限定为 StandardSlantSmallBigBlockDoomLarry 3DBannerColossalBubbleDigitalShadowScript

运行时也接受对应的小写别名,例如 slantsmalldoomlarry3d

WorkflowRunOptions 常用字段

字段说明
initialValues预填值,常用于跳过交互
history本次运行的快照复用和保存行为
checkpoint本次运行的恢复和保存行为
logs本次运行是否启用日志能力
locale覆盖本次运行语言
timeZone覆盖本次运行时区
meta进入日志快照的元数据

WorkflowRunResult 常用字段

字段说明
status当前实现里完成态为 completed
values最终输入和值快照
results步骤返回结果
events结构化事件流
savedLogPath最近一次保存日志的路径,未保存时为 null
saveLog直接保存日志
confirmSaveLog交互确认后保存日志
confirmSaveLogSafely安全确认保存日志
snapshot读取完整运行快照
workflowIdworkflow 唯一标识
runId当前运行唯一标识

Step helper 一览

输入类

  • defineStep.text
  • defineStep.password
  • defineStep.path
  • defineStep.date
  • defineStep.select
  • defineStep.selectKey
  • defineStep.autocomplete
  • defineStep.multiselect
  • defineStep.autocompleteMultiselect
  • defineStep.groupMultiselect
  • defineStep.confirm

展示类

  • defineStep.note
  • defineStep.box
  • defineStep.log

执行类

  • defineStep.command

常用类型名

类型说明
WorkflowRuntimeContext回调与 resolver 的上下文
WorkflowRunOptions单次运行配置
WorkflowRunResult单次运行结果
WorkflowPlugin插件定义
WorkflowStepDefinition标准化后的步骤定义
WorkflowCommandExecutionResult命令执行结果
WorkflowCommandResult命令步骤结果类型别名

该页之外再查什么