lovrabet
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineselovrabet-runtime-cli — Lovrabet 运行态 CLI
lovrabet-runtime-cli — Lovrabet Runtime CLI
面向业务人员和集成开发者的运行态 CLI,提供数据集查询、数据 CRUD、SQL 执行、BFF 调用能力。
结构化输出与 jq:需要机器可读 JSON 时优先(单行信封);需缩进时用--format compress。二者均可叠加全局--format json缩小输出;语义与--jq '<expr>'一致,详见 输出格式与 --jq。rabetbase
A runtime CLI for business personnel and integration developers, providing capabilities for dataset queries, data CRUD, SQL execution, and BFF invocations.
Structured Output & jq: Use(single-line envelope) first when machine-readable JSON is needed; use--format compressfor indentation. Both can be combined with the global--format jsonto narrow down output; the semantics are consistent with--jq '<expr>', see Output Format & --jq for details.rabetbase
使用顺序
Usage Sequence
先看 guides,再查 references。
- 流程 / 决策:
- 应用决议
- 数据集与数据流程
- SQL 与 BFF 流程
- 排障
- 命令细节 / 参数参考:
references/*.md
Check guides first, then references.
- Flow / Decision:
- App Resolution
- Dataset & Data Workflow
- SQL & BFF Workflow
- Troubleshooting
- Command Details / Parameter References:
references/*.md
安装
Installation
bash
npm install -g @lovrabet/lovrabet-clibash
npm install -g @lovrabet/lovrabet-cli认证
Authentication
当前主路径是 User Access Key(client-ak)。优先级:CLI flags > 环境变量 > 配置文件。
- User AK:或
.lovrabet.json配LOVRABET_ACCESS_KEY(适合 CI);有accessKey时走 client-akaccessKey - Cookie:历史兼容读取,已不是推荐主路径;新文档与 Agent 指导默认按 AK 流程处理
详见 认证参考。
The current primary method is User Access Key (client-ak). Priority: CLI flags > Environment Variables > Configuration File.
- User AK: Configure in
accessKeyor.lovrabet.json(suitable for CI); whenLOVRABET_ACCESS_KEYexists, use client-akaccessKey - Cookie: Read for historical compatibility, no longer the recommended primary method; new documents and Agent guidance default to the AK process
See Authentication Reference for details.
认证命令选择
Authentication Command Selection
- 只想更新 AK,尽量保留现有配置:使用
lovrabet auth login - 要从头重建当前作用域认证配置:使用
lovrabet auth init - 不要把 当作普通登录命令;它会清空当前作用域下已有配置,再只写回新的认证结果
auth init - 仅作为实现层兼容能力存在,默认不要在指导中主推;需要“清空后重建 + 写 env”时优先用
auth login --envauth init --env ...
- Only want to update AK while retaining existing configuration: Use
lovrabet auth login - Want to rebuild the authentication configuration for the current scope from scratch: Use
lovrabet auth init - Do NOT treat as a regular login command; it will clear existing configurations under the current scope and then only write back the new authentication result
auth init - exists only as a compatibility layer for implementation; do not promote it by default in guidance; prefer
auth login --envwhen you need to "clear and rebuild + write to env"auth init --env ...
配置作用域原则(--global
)
--globalConfiguration Scope Principle (--global
)
--global- 写操作默认当前项目(、
app init、app import、config set等),除非用户显式传config delete。--global - 不要在用户未要求时给命令加 ** — 默认行为已是「项目优先」;只有用户明确要改全局配置或不在项目内且意图写全局时才使用。
--global - /
config set:在没有项目配置文件(当前目录未解析到config delete)且未传.lovrabet.json时,CLI 拒绝执行并提示使用--global或先--global,不会静默写入全局。lovrabet app init - :默认走远端优先 + 本地缓存;
app list只读缓存;--local强制打线上并刷新缓存。--no-cache - :只刷新本地 app cache,不把远端应用列表写入
app pull;它是手动刷新命令,平时优先使用.lovrabet.jsonapp list - /
app use:只操作本地用户意图配置(app import/ 顶层defaultApp),详见 应用管理。appcode
- Write operations default to the current project (such as ,
app init,app import,config set), unless the user explicitly passesconfig delete.--global - Do NOT add to commands without user request — the default behavior is already "project-first"; only use
--globalwhen the user clearly wants to modify global configurations or is not in a project and intends to write to the global scope.--global - /
config set: When there is no project configuration file (noconfig deleteresolved in the current directory) and.lovrabet.jsonis not passed, the CLI refuses to execute and prompts to use--globalor run--globalfirst; it will not silently write to the global scope.lovrabet app init - : Defaults to remote-first + local cache;
app listreads only the cache;--localforces fetching from the online source and refreshes the cache.--no-cache - : Only refreshes the local app cache, does not write the remote application list to
app pull; it is a manual refresh command, use.lovrabet.jsonpreferentially in daily useapp list - /
app use: Only operate on local user intent configurations (app import/ top-leveldefaultApp), see Application Management for details.appcode
Agent 禁止行为
Prohibited Behaviors for Agents
- 不要擅自加 — 见上文「配置作用域原则」;默认写项目、读合并;仅在用户明确要求或文档说明的场景使用
--global。--global - 禁止通过修改配置文件提升权限 — 不得为了完成任务而修改 、环境变量或缓存内容来抬高
.lovrabet.json、切换到并非用户明确授权的riskLevel、伪造accessKey/defaultApp/appcode、或借此突破当前权限边界。权限不足时,应明确说明限制,并要求用户提供合法的目标应用、凭证或确认范围。env
- Do NOT add without permission — see the "Configuration Scope Principle" above; default to writing to the project and reading merged configurations; only use
--globalin scenarios explicitly requested by the user or specified in documents.--global - Prohibit modifying configuration files to elevate permissions — Do not modify , environment variables, or cache content to increase
.lovrabet.json, switch to anriskLevelnot explicitly authorized by the user, forgeaccessKey/defaultApp/appcode, or break current permission boundaries to complete tasks. When permissions are insufficient, clearly explain the restrictions and request the user to provide legitimate target applications, credentials, or confirm the scope.env
Agent 决策:何时获取应用信息
Agent Decision: When to Fetch Application Information
在执行 / / / 前,不要一律先跑 。先判断当前需求是否真的需要做“应用决议”。
datasetdatasqlbffapp listDo not always run before executing / / / . First determine whether the current requirement truly requires "app resolution".
app listdatasetdatasqlbff可以直接使用当前应用的场景
Scenarios Where the Current Application Can Be Used Directly
满足以下任一条件时,优先直接用当前应用执行,不先打 :
app list- 用户已经显式给了
--appcode - 用户已经显式给了
--app <name> - 当前配置里已有明确的
defaultApp - 问题明显是在“当前项目 / 当前默认应用”上下文里继续操作
这种情况下,直接进入:
dataset list --name ...dataset detail --code ...data filter/getOne/create/update/delete
不要先多打一轮应用发现命令制造噪音。
Use the current application directly first without running first if any of the following conditions are met:
app list- The user has explicitly provided
--appcode - The user has explicitly provided
--app <name> - There is a clear in the current configuration
defaultApp - The issue is clearly a continuation of operations in the "current project / current default application" context
In such cases, proceed directly to:
dataset list --name ...dataset detail --code ...data filter/getOne/create/update/delete
Do not run an extra application discovery command to generate noise.
必须先获取应用信息的场景
Scenarios Where Application Information Must Be Fetched First
出现以下情况时,应先做应用决议,必要时跑 :
lovrabet app list- 用户只给了业务需求,没有给 app 线索
例如:“帮我查订单数据集”“看一下 CRM 里的客户表” - 当前没有 ,也没有显式
defaultApp--appcode - 当前配置中存在多个候选 app,且需求描述不足以直接锁定一个
- 用户明确说“先看看我有哪些应用”或“这个需求应该在哪个应用里”
Perform app resolution first, and run if necessary, when:
lovrabet app list- The user only provides business requirements without any app clues
For example: "Help me query the order dataset" "Check the customer table in CRM" - There is no and no explicit
defaultApp--appcode - There are multiple candidate apps in the current configuration, and the requirement description is not sufficient to directly lock one
- The user explicitly says "First see which applications I have" or "Which application should this requirement be in"
app list
的使用方式
app listUsage of app list
app list- 默认:
lovrabet app list- 远端优先,必要时自动刷新 cache
- 只想复用本地目录时:
lovrabet app list --local - 明确要强制刷新时:
lovrabet app list --no-cache
- Default:
lovrabet app list- Remote-first, automatically refreshes cache when necessary
- Only want to reuse local cache:
lovrabet app list --local - Clearly need to force a refresh:
lovrabet app list --no-cache
如何根据需求判断使用哪个应用
How to Determine Which Application to Use Based on Requirements
优先级按下面做,不要随意跳步:
- 显式指定优先
- 用户给了 app 名、appcode、当前项目语境,直接采用
- 本地默认优先
- 有 且需求没有显示冲突,先用默认应用
defaultApp
- 有
- 需求关键词映射
- 需求里出现业务域关键词时,用 输出的
app list先做语义匹配name - 例如:、
CRM、订单、电商、证照需求管理
- 需求里出现业务域关键词时,用
- 验证式收敛
- 对候选应用执行
dataset list --app <name> --name <关键词> - 哪个返回的数据集更匹配,就收敛到哪个 app
- 对候选应用执行
Follow the priority below, do not skip steps arbitrarily:
- Explicit specification first
- Directly use the app name, appcode, or current project context provided by the user
- Local default first
- Use the default application first if there is a and the requirement does not show conflicts
defaultApp
- Use the default application first if there is a
- Requirement keyword mapping
- When business domain keywords appear in the requirement, perform semantic matching first using the from the
nameoutputapp list - Examples: ,
CRM,Order,E-commerce,LicenseRequirements Management
- When business domain keywords appear in the requirement, perform semantic matching first using the
- Verification-based convergence
- Execute for candidate applications
dataset list --app <name> --name <keyword> - Converge to the app whose returned datasets match better
- Execute
推荐决策流程
Recommended Decision Flow
当用户说“帮我查某个业务数据”时,推荐流程是:
- 先判断当前是否已有明确 app 上下文
- 没有则
lovrabet app list - 按业务关键词挑 1-2 个候选 app
- 对候选 app 执行
dataset list --app <name> --name <关键词> - 命中后再继续 或
dataset detaildata filter
When the user says "Help me query some business data", the recommended flow is:
- First determine whether there is a clear app context currently
- If not, run
lovrabet app list - Select 1-2 candidate apps based on business keywords
- Execute for candidate apps
dataset list --app <name> --name <keyword> - Proceed with or
dataset detailafter hitting a matchdata filter
不要这样做
Do NOT Do the Following
- 不要每次都先
app list - 不要只看 app 名就武断决定,不做 验证
dataset list - 不要把平台应用目录再写回
.lovrabet.json - 不要因为本地配置里没有某个 app 就判定它不存在,先看 cache/remote 目录
| 服务 | 命令 | 说明 | 风险等级 | 需 Cookie |
|---|---|---|---|---|
| auth | | 保存 accessKey | — | — |
| auth | | 清空当前作用域配置并重建认证 | write | — |
| auth | | 清除本地 accessKey | — | — |
| app | | 创建 | write | — |
| app | | 列出当前 AK 可见应用(远端优先,带缓存) | read | — |
| app | | 刷新本地 app cache | write | — |
| app | | 切换默认应用 | write | — |
| app | | 从升级后的 .rabetbase.json 导入顶层配置 | write | — |
| config | | 查看完整配置 | read | — |
| config | | 读取配置项 | read | — |
| config | | 写入配置项 | write | — |
| config | | 删除配置项 | write | — |
| skill | | 全局安装官方运行态 Skill | write | — |
| dataset | | 列出数据集(含字段列表) | read | 是 |
| dataset | | 查看数据集结构 | read | 是 |
| data | | 按条件查询数据记录 | read | — |
| data | | 按 ID 获取单条记录 | read | — |
| data | | 聚合统计 | read | — |
| data | | 新建记录 | write | — |
| data | | 更新记录 | write | — |
| data | | 删除记录(需 | high-risk-write | — |
| sql | | 查看 SQL 查询详情 | read | 是 |
| sql | | 执行 SQL 查询 | read | — |
| bff | | 查看 BFF 脚本详情 | read | 是 |
| bff | | 执行 BFF 函数 | read | — |
| logs | | 查看命令执行历史 | read | — |
| logs | | 清除命令历史 | read | — |
- Do not run every time
app list - Do not make arbitrary decisions based only on app names without verifying via
dataset list - Do not write the platform application directory back to
.lovrabet.json - Do not judge that an app does not exist just because it is not in the local configuration; check the cache/remote directory first
| Service | Command | Description | Risk Level | Requires Cookie |
|---|---|---|---|---|
| auth | | Save accessKey | — | — |
| auth | | Clear current scope configuration and rebuild authentication | write | — |
| auth | | Clear local accessKey | — | — |
| app | | Create | write | — |
| app | | List applications visible to the current AK (remote-first, with cache) | read | — |
| app | | Refresh local app cache | write | — |
| app | | Switch default application | write | — |
| app | | Import top-level configuration from upgraded .rabetbase.json | write | — |
| config | | View complete configuration | read | — |
| config | | Read configuration item | read | — |
| config | | Write configuration item | write | — |
| config | | Delete configuration item | write | — |
| skill | | Globally install official runtime Skill | write | — |
| dataset | | List datasets (including field lists) | read | Yes |
| dataset | | View dataset structure | read | Yes |
| data | | Query data records by condition | read | — |
| data | | Get a single record by ID | read | — |
| data | | Aggregation statistics | read | — |
| data | | Create new record | write | — |
| data | | Update record | write | — |
| data | | Delete record (requires | high-risk-write | — |
| sql | | View SQL query details | read | Yes |
| sql | | Execute SQL query | read | — |
| bff | | View BFF script details | read | Yes |
| bff | | Execute BFF function | read | — |
| logs | | View command execution history | read | — |
| logs | | Clear command history | read | — |
意图 → 命令索引
Intent → Command Index
初始化与配置
Initialization & Configuration
| 意图 | 命令 |
|---|---|
| 安装 / 刷新 Skill | |
| 初始化配置 | |
| 从升级后的 rb 配置导入 | |
| 登录 | |
| 重置并重建认证配置 | |
| 登出 | |
| 查看配置 | |
| 读取配置项 | |
| 设置配置项 | |
| 删除配置项 | |
| 查看应用列表 | |
| 只看本地缓存的应用列表 | |
| 强制刷新线上应用列表 | |
| 手动刷新应用缓存 | |
| 切换默认应用 | |
| Intent | Command |
|---|---|
| Install / Refresh Skill | |
| Initialize configuration | |
| Import from upgraded rb configuration | |
| Login | |
| Reset and rebuild authentication configuration | |
| Logout | |
| View configuration | |
| Read configuration item | |
| Set configuration item | |
| Delete configuration item | |
| View application list | |
| View only locally cached application list | |
| Force refresh online application list | |
| Manually refresh app cache | |
| Switch default application | |
数据集与数据操作
Dataset & Data Operations
| 意图 | 命令 |
|---|---|
| 找数据集 | |
| 看数据集字段 | |
| 查询数据 | |
| 获取单条 | |
| 新建记录 | |
| 更新记录 | |
| 删除记录 | |
| 聚合统计 | |
| Intent | Command |
|---|---|
| Find dataset | |
| View dataset fields | |
| Query data | |
| Get single record | |
| Create new record | |
| Update record | |
| Delete record | |
| Aggregation statistics | |
SQL 与 BFF
SQL & BFF
| 意图 | 命令 |
|---|---|
| 查看 SQL | |
| 执行 SQL | |
| 查看 BFF | |
| 执行 BFF | |
| Intent | Command |
|---|---|
| View SQL | |
| Execute SQL | |
| View BFF | |
| Execute BFF | |
日志
Logs
| 意图 | 命令 |
|---|---|
| 查看日志 | |
| 清除日志 | |
| Intent | Command |
|---|---|
| View logs | |
| Clear logs | |
统一的 --params 设计
Unified --params Design
datasql execbff exec--paramsbash
lovrabet <service> <command> --code <code> --params '<json>'datasql execbff exec--paramsbash
lovrabet <service> <command> --code <code> --params '<json>'数据 CRUD 工作流
Data CRUD Workflow
bash
undefinedbash
undefined1. 找到目标数据集
1. Locate the target dataset
lovrabet dataset list --name "订单"
lovrabet dataset list --name "Order"
2. 查看字段结构(确认数据集 code + 字段名)
2. View field structure (confirm dataset code + field names)
lovrabet dataset detail --code <datasetCode>
lovrabet dataset detail --code <datasetCode>
3. 查询数据
3. Query data
lovrabet data filter --code <datasetCode> --params '{"where":{"status":{"$eq":"active"}},"currentPage":1,"pageSize":20}'
lovrabet data filter --code <datasetCode> --params '{"where":{"status":{"$eq":"active"}},"currentPage":1,"pageSize":20}'
翻到第 2 页
Go to page 2
lovrabet data filter --code <datasetCode> --params '{"where":{"status":{"$eq":"active"}},"currentPage":2,"pageSize":20}'
lovrabet data filter --code <datasetCode> --params '{"where":{"status":{"$eq":"active"}},"currentPage":2,"pageSize":20}'
4. 获取单条
4. Get single record
lovrabet data getOne --code <datasetDataset> --params '{"id":123}'
lovrabet data getOne --code <datasetDataset> --params '{"id":123}'
5. 创建记录(先 dry-run 预览)
5. Create record (preview with dry-run first)
lovrabet data create --code <datasetCode> --params '{"name":"test","amount":100}' --dry-run
lovrabet data create --code <datasetCode> --params '{"name":"test","amount":100}'
lovrabet data create --code <datasetCode> --params '{"name":"test","amount":100}' --dry-run
lovrabet data create --code <datasetCode> --params '{"name":"test","amount":100}'
6. 更新记录
6. Update record
lovrabet data update --code <datasetCode> --params '{"id":123,"status":"completed"}'
lovrabet data update --code <datasetCode> --params '{"id":123,"status":"completed"}'
7. 删除记录(高风险,需确认)
7. Delete record (high risk, requires confirmation)
lovrabet data delete --code <datasetCode> --params '{"id":123}' --dry-run
lovrabet data delete --code <datasetCode> --params '{"id":123}' --yes
undefinedlovrabet data delete --code <datasetCode> --params '{"id":123}' --dry-run
lovrabet data delete --code <datasetCode> --params '{"id":123}' --yes
undefinedfilter 的 --params 结构
--params Structure for filter
--paramsfilterjson
{
"where": { "status": { "$eq": "active" } },
"select": ["id", "name", "status"],
"orderBy": [{ "id": "desc" }],
"currentPage": 1,
"pageSize": 20
}The JSON is directly forwarded as the request body:
--paramsfilterjson
{
"where": { "status": { "$eq": "active" } },
"select": ["id", "name", "status"],
"orderBy": [{ "id": "desc" }],
"currentPage": 1,
"pageSize": 20
}where 查询语法
where Query Syntax
| 操作符 | 含义 | 示例 |
|---|---|---|
| 等于 | |
| 不等于 | |
| 比较 | |
| 包含匹配 | |
| 前缀匹配 | |
| 后缀匹配 | |
| 非空判断 | |
| 包含 | |
| 组合条件 | |
| Operator | Meaning | Example |
|---|---|---|
| Equal to | |
| Not equal to | |
| Comparison | |
| Contains match | |
| Prefix match | |
| Suffix match | |
| Non-null check | |
| In | |
| Combined conditions | |
aggregate 的 --params 结构
--params Structure for aggregate
--paramsaggregateAggregateParamsjson
{
"select": ["category_id"],
"aggregate": [
{ "type": "SUM", "field": "amount", "alias": "total_amount", "round": true, "precision": 2 }
],
"where": { "status": { "$eq": "active" } },
"groupBy": ["category_id"],
"having": [
{ "columnName": "total_amount", "condition": { "$gte": 1000 } }
],
"join": [
{ "type": "LEFT", "table": "users", "condition": { "user_id": "id" } }
],
"orderBy": [{ "total_amount": "desc" }],
"currentPage": 1,
"pageSize": 20
}The JSON is directly forwarded as the request body, with fields aligned with the SDK :
--paramsaggregateAggregateParamsjson
{
"select": ["category_id"],
"aggregate": [
{ "type": "SUM", "field": "amount", "alias": "total_amount", "round": true, "precision": 2 }
],
"where": { "status": { "$eq": "active" } },
"groupBy": ["category_id"],
"having": [
{ "columnName": "total_amount", "condition": { "$gte": 1000 } }
],
"join": [
{ "type": "LEFT", "table": "users", "condition": { "user_id": "id" } }
],
"orderBy": [{ "total_amount": "desc" }],
"currentPage": 1,
"pageSize": 20
}全局选项
Global Options
| 选项 | 说明 |
|---|---|
| 覆盖 appcode |
| 环境: production / development / daily |
| 输出: json / pretty / compress(默认偏好见配置与 |
| 对 json / compress 最终打印的 JSON 做 jq 过滤;与 |
| 多应用模式下指定应用 |
| 预览不执行(write 命令) |
| 跳过确认(high-risk-write) |
| 非交互模式(CI) |
| Option | Description |
|---|---|
| Override appcode |
| Environment: production / development / daily |
| Output: json / pretty / compress (default preference see configuration & |
| Perform jq filtering on the final printed JSON for json / compress; behavior is consistent with |
| Specify application in multi-app mode |
| Preview without execution (write commands) |
| Skip confirmation (high-risk-write) |
| Non-interactive mode (CI) |
配置文件
Configuration File
项目根目录 (完整字段、优先级、环境变量见 配置参考):
.lovrabet.jsonjson
{
"appcode": "app-xxxxxxxx",
"env": "daily",
"accessKey": "ak_xxx"
}配置文件只保存用户意图配置,不保存平台应用目录。远端应用列表缓存位于:
text
~/.lovrabet/cache/<env>/<ak-fingerprint>/my-apps.json多应用意图配置示例:
json
{
"accessKey": "ak_xxx",
"env": "daily",
"defaultApp": "crm"
}.lovrabet.jsonjson
{
"appcode": "app-xxxxxxxx",
"env": "daily",
"accessKey": "ak_xxx"
}The configuration file only saves user intent configurations, not the platform application directory. The remote application list cache is located at:
text
~/.lovrabet/cache/<env>/<ak-fingerprint>/my-apps.jsonExample of multi-app intent configuration:
json
{
"accessKey": "ak_xxx",
"env": "daily",
"defaultApp": "crm"
}风险控制
Risk Control
| 等级 | 命令 | 保护 |
|---|---|---|
| read | dataset list/detail, data filter/getOne/aggregate, sql detail/exec, bff detail/exec, app list, config list/get, logs | 无 |
| write | data create, data update, app use, config set/delete, app import | dry-run 预览 |
| high-risk-write | data delete | 需 |
| Level | Command | Protection |
|---|---|---|
| read | dataset list/detail, data filter/getOne/aggregate, sql detail/exec, bff detail/exec, app list, config list/get, logs | None |
| write | data create, data update, app use, config set/delete, app import | dry-run preview |
| high-risk-write | data delete | Requires |
详细参考
Detailed References
| 主题 | 文件 |
|---|---|
输出格式与 | lovrabet-output-format-jq.md |
| 认证 | lovrabet-auth.md |
| 初始化 | lovrabet-init.md |
| 应用管理 | lovrabet-app.md |
| 配置管理 | lovrabet-config-commands.md |
| 配置文件参考 | lovrabet-config.md |
| 数据集发现 | dataset-discovery-workflow.md |
| 数据 CRUD | data-crud-workflow.md |
| SQL 工作流 | lovrabet-sql-workflow.md |
| BFF 工作流 | lovrabet-bff-workflow.md |
| 日志 | lovrabet-logs.md |
| Topic | File |
|---|---|
Output Format & | lovrabet-output-format-jq.md |
| Authentication | lovrabet-auth.md |
| Initialization | lovrabet-init.md |
| Application Management | lovrabet-app.md |
| Configuration Management | lovrabet-config-commands.md |
| Configuration File Reference | lovrabet-config.md |
| Dataset Discovery | dataset-discovery-workflow.md |
| Data CRUD | data-crud-workflow.md |
| SQL Workflow | lovrabet-sql-workflow.md |
| BFF Workflow | lovrabet-bff-workflow.md |
| Logs | lovrabet-logs.md |