how2useliteflow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLiteFlow 助手
LiteFlow Assistant
本 skill 帮助用户用 AI 使用 LiteFlow(v2.16.X)。它内置了从官方文档与源码蒸馏出的绝大部分用法细节与代码细节,并规定了"答不到时怎么办"的严格流程。
版本对齐:本 skill 内容对齐 LiteFlow v2.16.X(约 v2.16.0)。不同小版本细节可能差异;作答时如涉及具体版本会标注。
This skill helps users use LiteFlow (v2.16.X) with AI. It builds in most usage details and code details distilled from official documentation and source code, and defines strict procedures for "what to do when unable to answer".
Version Alignment: The content of this skill aligns with LiteFlow v2.16.X (approximately v2.16.0). Details may vary across minor versions; the specific version will be noted when answering if involved.
一、何时使用
1. When to Use
用户提到以下任一场景时启用本 skill:
- 写组件(普通/选择/布尔/次数循环/迭代循环组件,或声明式组件)。
- 写 EL 规则(THEN/WHEN/IF/SWITCH/FOR/WHILE/ITERATOR/CATCH/RETRY/TIMEOUT/PRE/FINALLY/AND/OR/NOT、tag/data/bind 等)。
- 上下文(数据上下文、别名、参数注入、表达式取参)。
- 脚本组件(Groovy/JS/Python/QLExpress/Lua/Aviator/Kotlin/Java 等)。
- 规则配置源(本地文件/SQL/ZK/Nacos/Etcd/Apollo/Redis/自定义)。
- 配置项(SpringBoot/Spring/Solon/纯代码)。
- 执行器(FlowExecutor 的执行方法、LiteflowResponse)。
- 编写 / 调试测试用例(JUnit5 + SpringBoot 测试范式、全局状态清理、各功能的官方测试模块)。
BaseTest - AI Agent 编排(:把 ReAct Agent 当组件编排进 EL、模型/凭据配置、自定义工具、流式输出、会话/记忆)。
liteflow-react-agent - 调试/报错/链路排查、热刷新、线程池、动态构造、决策路由、生命周期、降级/回滚/切面等高级特性。
- 询问 LiteFlow 源码实现/代码细节(FlowExecutor、FlowBus、DataBus、Condition 树、两阶段解析等)。
Activate this skill when the user mentions any of the following scenarios:
- Writing components (normal/selection/boolean/loop-count/iterator-loop components, or declarative components).
- Writing EL rules (THEN/WHEN/IF/SWITCH/FOR/WHILE/ITERATOR/CATCH/RETRY/TIMEOUT/PRE/FINALLY/AND/OR/NOT, tag/data/bind, etc.).
- Context (data context, aliases, parameter injection, expression parameter retrieval).
- Script components (Groovy/JS/Python/QLExpress/Lua/Aviator/Kotlin/Java, etc.).
- Rule configuration sources (local files/SQL/ZK/Nacos/Etcd/Apollo/Redis/custom).
- Configuration items (SpringBoot/Spring/Solon/pure code).
- Executors (execution methods of FlowExecutor, LiteflowResponse).
- Writing/debugging test cases (JUnit5 + SpringBoot testing paradigm, global state cleanup, official test modules for each feature).
BaseTest - AI Agent orchestration (: orchestrating ReAct Agent as a component into EL, model/credential configuration, custom tools, streaming output, session/memory).
liteflow-react-agent - Advanced features such as debugging/error reporting/link troubleshooting, hot refresh, thread pools, dynamic construction, decision routing, lifecycle, downgrade/rollback/aspect, etc.
- Asking about LiteFlow source code implementation/code details (FlowExecutor, FlowBus, DataBus, Condition tree, two-stage parsing, etc.).
二、回答 LiteFlow 问题时的决策流程(必须严格遵守)
2. Decision Process for Answering LiteFlow Questions (Must Be Strictly Followed)
这是最重要的章节。绝不杜撰、绝不用网络内容充当 LiteFlow 行为依据。
第 0 步 — 先查本文件速查表(下方第三节):约 80% 的常见问题(EL 算子、组件类型、执行 API、核心配置)可直接作答,无需加载任何文件。
第 1 步 — 加载对应 reference:速查表不够时,按"知识地图"(第四节)用 打开 。绝大多数用法与代码细节问题在此解决。作答时标注来源 reference 文件名。
Readreferences/<文件>.md第 2 步 — 本地源码:若 reference 也未覆盖(通常是更冷门或更深层的源码细节),先探测本地 LiteFlow 仓库,按优先级:环境变量 → → 。
LITEFLOW_REPO~/openSource/liteFlow./liteFlow- 用 探测(找到则打印绝对路径;找不到退出码 2)。
scripts/source-lookup.sh path - 找到后用 (搜
scripts/source-lookup.sh grep <关键词>)/*.java/grepall/find <名字>定位,引用show <相对路径> [a-b]作答。path:line
第 3 步 — 请求克隆(必须先征得用户同意):本地也没有、或问题明确需要线上/最新源码时,停下来告知用户并请求确认,例如:
"这部分内容不在我的内置知识里。我可以 git clone LiteFlow 官方仓库(gitee.com/dromara/liteFlow,默认tag,与内置内容对齐)到临时目录,从源码里确认后再回答。是否允许?"v2.16.0
- 用户同意 → 运行 (克隆到缓存
scripts/source-lookup.sh clone),再用~/.cache/liteflow-skill定位,引用grep/find/show作答。path:line - 用户拒绝 / 未明确同意 → 如实说明"暂时无法确认,不建议臆测",不要自行克隆、不要杜撰、不要用网络搜索结果充当 LiteFlow 的行为依据。
This is the most important section. Never fabricate, never use online content as the basis for LiteFlow's behavior.
Step 0 — Check the quick reference in this document first (Section 3 below): About 80% of common questions (EL operators, component types, execution APIs, core configurations) can be answered directly without loading any files.
Step 1 — Load the corresponding reference: When the quick reference is insufficient, use to open according to the "Knowledge Map" (Section 4). Most usage and code detail issues are resolved here. Mark the source reference file name when answering.
Readreferences/<file>.mdStep 2 — Local source code: If the reference does not cover the issue (usually more obscure or deeper source code details), first detect the local LiteFlow repository, in the priority order: environment variable → → .
LITEFLOW_REPO~/openSource/liteFlow./liteFlow- Use to detect (prints the absolute path if found; exit code 2 if not found).
scripts/source-lookup.sh path - After finding it, use (search
scripts/source-lookup.sh grep <keyword>) /*.java/grepall/find <name>to locate, answer with reference toshow <relative path> [a-b].path:line
Step 3 — Request cloning (must obtain user consent first): If the local repository is not available, or the issue clearly requires online/latest source code, stop and inform the user to request confirmation, for example:
"This content is not in my built-in knowledge. I can git clone the official LiteFlow repository (gitee.com/dromara/liteFlow, defaulttag, aligned with built-in content) to a temporary directory, confirm from the source code and then answer. Is this allowed?"v2.16.0
- User agrees → Run (clone to cache
scripts/source-lookup.sh clone), then use~/.cache/liteflow-skillto locate, answer with reference togrep/find/show.path:line - User refuses / does not explicitly agree → Truthfully state "Cannot confirm temporarily, it is not recommended to speculate", do not clone on your own, do not fabricate, do not use web search results as the basis for LiteFlow's behavior.
绝对禁止
Absolute Prohibitions
- 在未读到对应 reference 或源码前,凭记忆编造 API、方法名、参数、配置项、默认值或行为。
- 把网络搜索(WebSearch/网页)结果当作 LiteFlow 真实行为的依据(除非用户明确要求联网查证)。
- 在用户未明确同意前执行 或
git clone。source-lookup.sh clone
- Fabricate APIs, method names, parameters, configuration items, default values or behaviors based on memory before reading the corresponding reference or source code.
- Treat web search (WebSearch/webpage) results as the basis for LiteFlow's actual behavior (unless the user explicitly requests online verification).
- Execute or
git clonewithout the user's explicit consent.source-lookup.sh clone
三、高频速查(直接作答,无需加载 reference)
3. High-Frequency Quick Reference (Answer Directly, No Need to Load Reference)
以下均经官方文档 + 源码核对。下方若仍不够,去对应 reference 查细节。
All the following content has been verified against official documentation + source code. If the following is still insufficient, check the corresponding reference for details.
3.1 EL 算子速查(详见 references/el-rules.md
)
references/el-rules.md3.1 EL Operator Quick Reference (See references/el-rules.md
for details)
references/el-rules.md| 算子 | 语义 | 最小示例 |
|---|---|---|
| 串行 | |
| 并行(异步) | |
| 条件(x 为布尔组件/表达式;可 | |
| 选择(x 返回目标 nodeId) | |
| 次数循环(x 返回次数) | |
| 条件循环 | |
| 迭代循环(x 返回 Iterator) | |
| 循环中断(配合循环) | |
| 捕获 a 的异常交 b 处理 | |
| 重试 | |
| 超时控制 | |
| 前置 / 后置(始终执行) | |
| 布尔与/或/非(用于 IF 条件) | |
| 子变量(复用片段) | 见 el-rules.md |
| 节点修饰 | | |
| 链路继承 | | 见 el-rules.md |
WHEN 并行修饰:(忽略错误继续)、(任一完成即结束)、(必须完成的节点)、(按比例)、是否独立线程池等——细节见 el-rules.md。
ignoreErroranymust(a,b)percentage(n)规则写在哪: / / 等规则文件中 ,结尾分号可省略;支持注释。
flow.xmlflow.jsonflow.el<chain name="..."> ... </chain>| Operator | Semantics | Minimal Example |
|---|---|---|
| Serial | |
| Parallel (asynchronous) | |
| Condition (x is a boolean component/expression; supports | |
| Selection (x returns target nodeId) | |
| Count loop (x returns the number of times) | |
| Condition loop | |
| Iterator loop (x returns Iterator) | |
| Loop interruption (used with loops) | |
| Catch exceptions of a and pass to b for processing | |
| Retry | |
| Timeout control | |
| Pre / Post (always executed) | |
| Boolean AND/OR/NOT (used for IF conditions) | |
| Sub-variable (reuse fragments) | See el-rules.md |
| Node modifiers | | |
| Link inheritance | | See el-rules.md |
WHEN Parallel Modifiers: (ignore errors and continue), (end when any completes), (nodes that must complete), (by proportion), whether to use an independent thread pool, etc. — details see el-rules.md.
ignoreErroranymust(a,b)percentage(n)Where to write rules: In rule files such as / / within , the trailing semicolon can be omitted; comments are supported.
flow.xmlflow.jsonflow.el<chain name="..."> ... </chain>3.2 组件类型速查(详见 references/components.md
)
references/components.md3.2 Component Type Quick Reference (See references/components.md
for details)
references/components.md| 想要的行为 | 用哪种组件 | 关键方法/注解 |
|---|---|---|
| 普通处理 | | |
| 多路选择(返回 nodeId) | | |
| 布尔判断(IF/WHILE 条件) | | |
| 次数循环 | | |
| 迭代循环 | | |
| 声明式(不继承基类) | | 方法加 |
- 注册:继承式/声明式组件都用 (也可用
@LiteflowComponent("nodeId")设别名)。name - 组件生命周期钩子(继承式可覆写,声明式用 ):
@LiteflowMethod(准入,false 则跳过)、isAccess()/beforeProcess()、afterProcess()/onSuccess()、onError()、isContinueOnError()、isEnd()。rollback() - 组件内取上下文:/
this.getContextBean(XxxContext.class);取流程入参:this.getFirstContextBean()。this.getRequestData()
| Desired Behavior | Component Type | Key Method/Annotation |
|---|---|---|
| Normal processing | | |
| Multi-way selection (returns nodeId) | | |
| Boolean judgment (IF/WHILE condition) | | |
| Count loop | | |
| Iterator loop | | |
| Declarative (no base class inheritance) | Register Bean with | Add |
- Registration: Both inherited/declarative components use (can also use
@LiteflowComponent("nodeId")to set alias).name - Component lifecycle hooks (overridable for inherited components, use for declarative components):
@LiteflowMethod(admission, skip if false),isAccess()/beforeProcess(),afterProcess()/onSuccess(),onError(),isContinueOnError(),isEnd().rollback() - Retrieve context within component: /
this.getContextBean(XxxContext.class); Retrieve process input parameters:this.getFirstContextBean().this.getRequestData()
3.3 执行 API 速查(详见 references/executor.md
)
references/executor.md3.3 Execution API Quick Reference (See references/executor.md
for details)
references/executor.mdjava
@Resource private FlowExecutor flowExecutor;
// 同步执行:chainId + 入参 + 多个上下文 Class(框架实例化)
LiteflowResponse resp = flowExecutor.execute2Resp("chain1", param, OrderContext.class, UserContext.class);
// 直接执行一段 EL(v2.15.0+,无需规则文件)
LiteflowResponse resp2 = flowExecutor.execute2RespWithEL("THEN(a, b, c)", param, OrderContext.class);
// 异步 / 路由
Future<LiteflowResponse> f = flowExecutor.execute2Future("chain1", param, OrderContext.class);
List<LiteflowResponse> rs = flowExecutor.executeRouteChain(param, OrderContext.class);LiteflowResponse| 需求 | 方法 |
|---|---|
| 是否成功 | |
| 失败异常 | |
| 异常 code/message | |
| 上下文 | |
| 步骤字符串(带耗时) | |
| 结构化步骤 | |
| 请求/会话/链路 ID | |
| 超时节点(v2.12.3+) | |
| 回滚步骤 | |
java
@Resource private FlowExecutor flowExecutor;
// Synchronous execution: chainId + input parameter + multiple context Classes (instantiated by framework)
LiteflowResponse resp = flowExecutor.execute2Resp("chain1", param, OrderContext.class, UserContext.class);
// Directly execute a segment of EL (v2.15.0+, no rule file required)
LiteflowResponse resp2 = flowExecutor.execute2RespWithEL("THEN(a, b, c)", param, OrderContext.class);
// Asynchronous / Routing
Future<LiteflowResponse> f = flowExecutor.execute2Future("chain1", param, OrderContext.class);
List<LiteflowResponse> rs = flowExecutor.executeRouteChain(param, OrderContext.class);Common values for (method names are based on source code):
LiteflowResponse| Requirement | Method |
|---|---|
| Whether successful | |
| Failure exception | |
| Exception code/message | |
| Context | |
| Step string (with time consumption) | |
| Structured steps | |
| Request/session/link ID | |
| Timeout nodes (v2.12.3+) | |
| Rollback steps | |
3.4 核心配置速查(详见 references/config.md
,SpringBoot liteflow.*
)
references/config.mdliteflow.*3.4 Core Configuration Quick Reference (See references/config.md
for details, SpringBoot liteflow.*
)
references/config.mdliteflow.*| key | 默认 | 说明 |
|---|---|---|
| — | 规则文件路径,用规则文件时必填;改为代码动态构造时自动失效 |
| | 另有 |
| | 上下文槽位数,自动扩容 |
| | WHEN 并行整体超时 |
| | 全局异步节点并发上限 |
| | 多种规则来源混装时设 true |
| | 本地规则文件变更自动重载 |
| | 快速解析模式 |
| | 仅 JDK21+ 生效 |
| | 执行过程日志 |
| | 简易监控统计 |
⚠️ v2.16.X 不存在这些配置名,勿臆造:(并发由whenMaxWorkers控制)、global-thread-pool-size(应为printExecutionResult)、print-execution-log。chainCache*
| key | Default | Description |
|---|---|---|
| — | Rule file path, required when using rule files; automatically invalid when changed to code dynamic construction |
| | Also available |
| | Context slot count, automatically expands |
| | Overall timeout for WHEN parallel execution |
| | Global asynchronous node concurrency limit |
| | Set to true when mixing multiple rule sources |
| | Auto-reload when local rule files change |
| | Fast parsing mode |
| | Only takes effect for JDK21+ |
| | Execution process log |
| | Simple monitoring statistics |
⚠️ These configuration names do not exist in v2.16.X, do not fabricate:(concurrency is controlled bywhenMaxWorkers),global-thread-pool-size(should beprintExecutionResult),print-execution-log.chainCache*
四、知识地图(问题类型 → reference 文件)
4. Knowledge Map (Question Type → Reference File)
用 打开 下对应文件获取细节:
Readreferences/| 问题类型 / 关键词 | 加载文件 |
|---|---|
| 框架定位、执行模型、模块地图、版本/JDK 支持、性能 | |
| 安装运行、Hello World(SpringBoot/Spring/Solon/其他) | |
| 全部配置项、各场景差异、LiteflowConfig | |
| 组件(继承式 5 种 / 声明式 / 生命周期钩子) | |
| EL 全语法、组件参数语法、重试/超时/继承/验证 | |
| 数据上下文、别名、参数注入、表达式取参 | |
| FlowExecutor 方法、入参、LiteflowResponse | |
| 测试用例与示例(测试范式、BaseTest 清理、功能→测试模块速查、DEMO) | |
| 脚本组件、各语言坐标、绑定变量、动态刷新/验证/卸载 | |
| 规则配置源(本地/SQL/ZK/Nacos/Etcd/Apollo/Redis/自定义) | |
| 元数据操作器、平滑热刷新、启动不检查 | |
| 异步线程池(FlowExecutor 层/组件异步层/虚拟线程) | |
| 动态构造 Node/EL/Chain | |
| 决策路由(概念/用法/executeRouteChain) | |
| 框架级生命周期(启动时/执行时钩子接口) | |
| 高级特性(降级/回滚/切面/隐式子流程/步骤/监控…18 项) | |
AI Agent 编排(ReAct Agent 组件、模型/凭据、自定义工具、流式输出、会话记忆、 | |
| 源码细节(FlowExecutor/FlowBus/DataBus/Condition 树/算子→类映射) | |
| 常见坑与 FAQ | |
Use to open the corresponding file under for details:
Readreferences/| Question Type / Keywords | Load File |
|---|---|
| Framework positioning, execution model, module map, version/JDK support, performance | |
| Installation and operation, Hello World (SpringBoot/Spring/Solon/others) | |
| All configuration items, scenario differences, LiteflowConfig | |
| Components (5 inherited types / declarative / lifecycle hooks) | |
| Full EL syntax, component parameter syntax, retry/timeout/inheritance/validation | |
| Data context, aliases, parameter injection, expression parameter retrieval | |
| FlowExecutor methods, input parameters, LiteflowResponse | |
| Test cases and examples (testing paradigm, BaseTest cleanup, feature→test module quick reference, DEMO) | |
| Script components, coordinates for various languages, bound variables, dynamic refresh/validation/uninstallation | |
| Rule configuration sources (local/SQL/ZK/Nacos/Etcd/Apollo/Redis/custom) | |
| Metadata operator, smooth hot refresh, no startup check | |
| Asynchronous thread pools (FlowExecutor layer/component asynchronous layer/virtual threads) | |
| Dynamic construction of Node/EL/Chain | |
| Decision routing (concept/usage/executeRouteChain) | |
| Framework-level lifecycle (startup/execution hook interfaces) | |
| Advanced features (downgrade/rollback/aspect/implicit sub-process/steps/monitoring...18 items) | |
AI Agent orchestration (ReAct Agent components, model/credentials, custom tools, streaming output, session memory, | |
| Source code details (FlowExecutor/FlowBus/DataBus/Condition tree/operator→class mapping) | |
| Common pitfalls and FAQ | |
五、引用规范
5. Citation Specifications
- 用法类问题:作答末尾标注来源 reference 文件名,例如"详见 "。
references/el-rules.md - 代码/源码类问题:引用源码 (来自
path:line或第 2/3 步实地查到的源码)。references/code-internals.md - 涉及版本依赖的 API/配置,标注所对齐版本(默认 v2.16.X)。
- Usage-related questions: Mark the source reference file name at the end of the answer, e.g., "See for details".
references/el-rules.md - Code/source code-related questions: Cite source code (from
path:lineor source code found in Step 2/3).references/code-internals.md - For APIs/configurations involving version dependencies, mark the aligned version (default v2.16.X).
六、关于 scripts/source-lookup.sh
scripts/source-lookup.sh6. About scripts/source-lookup.sh
scripts/source-lookup.sh本地优先 / 受控克隆 + 检索的命令行助手(POSIX sh,macOS 可直接运行):
| 子命令 | 作用 |
|---|---|
| 打印解析到的本地仓库路径(找不到退出码 2,不克隆) |
| 显式克隆 gitee 仓库到缓存(默认 |
| 在仓库 |
| 在仓库所有文件中检索 |
| 按文件名查找 |
| 显示某文件(带行号,可选区间) |
环境变量:(指定本地仓库覆盖探测)、(可选,指定 tag/分支;不设则克隆 ,显式留空 才回落 master)、(默认 )。
LITEFLOW_REPOLITEFLOW_TAGv2.16.0LITEFLOW_TAG=LITEFLOW_CACHE~/.cache/liteflow-skill职责边界:脚本不做用户交互,是否克隆由本 skill 的决策流程(第 3 步)征得用户同意后决定。
A command-line assistant that prioritizes local usage / controlled cloning + retrieval (POSIX sh, can be run directly on macOS):
| Subcommand | Function |
|---|---|
| Print the path of the detected local repository (exit code 2 if not found, no cloning) |
| Explicitly clone the gitee repository to cache (default |
| Search in |
| Search in all files of the repository |
| Search by file name |
| Display a file (with line numbers, optional range) |
Environment variables: (specify local repository to override detection), (optional, specify tag/branch; if not set, clone , only fallback to master if explicitly set to empty ), (default ).
LITEFLOW_REPOLITEFLOW_TAGv2.16.0LITEFLOW_TAG=LITEFLOW_CACHE~/.cache/liteflow-skillResponsibility Boundary: The script does not handle user interaction; whether to clone is determined by the decision process of this skill (Step 3) after obtaining user consent.