@lovrabet/lovrabet-cli 2.4.0-beta.4 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import{readScopedConfig,writeScopedConfig}from"../../context.js";import{CLI_BIN_NAME}from"../../constant/cli.js";import{PRODUCT_CONFIG,productEnvName}from"../../constant/product.js";import{AUTH_MODE}from"../../constant/auth-mode.js";import{normalizeEnv,isDaily,isDev,isProduction}from"../../constant/env.js";import{CliErrors}from"../../errors.js";import{promptAccessKey,isAbortPrompt}from"../../commands/auth/prompt.js";import{resolveConfigScope,toScopeFlags}from"../../commands/common/config-policy.js";import{writeCliSideChannelLine}from"../../utils/write-cli-side-channel.js";import{getLoginUserInfo}from"../../core/api-client.js";import{getUserDomain,getUserPageDomain}from"../../constant/domain.js";import{authDeviceDefinition,readStoredDeviceCode,deleteStoredDeviceCode,fetchDeviceToken,isStoredDeviceCodeExpired}from"../../commands/auth/device.js";import{maskCliAccessKey}from"../../utils/access-key-redaction.js";const ACCESS_KEY_PATTERN=/^ak_[A-Za-z0-9]{16,}$/
|
|
2
|
-
;function showAccessKeyCreateHint(createUrl){writeCliSideChannelLine(`AccessKey required for login. Create one in ${PRODUCT_CONFIG.userCenterDisplayName}:`);writeCliSideChannelLine(`\n${createUrl}\n`);writeCliSideChannelLine("Tip: you can also run:");writeCliSideChannelLine(` ${CLI_BIN_NAME} auth login --access-key <ak_xxx>`)}function buildAccessKeySetupGuide(createUrl){return[`AccessKey required for login. Create one in ${PRODUCT_CONFIG.userCenterDisplayName}:`,createUrl,`Give the AccessKey to your AI Agent, then run: ${CLI_BIN_NAME} auth login --access-key <ak_xxx> [--global]`].join("\n")}function canPromptForAccessKey(ctx){return!ctx.nonInteractive&&process.stdin.isTTY!==false&&process.stdout.isTTY!==false}function resolveAuthScopeFlags(ctx){return toScopeFlags(resolveConfigScope({explicitGlobal:ctx.bool("global"),explicitProject:ctx.bool("project"),policy:"global-default"}))}async function resolveAuthWriteInput(ctx){
|
|
3
|
-
;const envFlag=(ctx.str("env")||"").trim();const accessKeyCreateUrl=()=>`${getUserPageDomain()}${PRODUCT_CONFIG.accessKeyCreatePath}`;if(!ak&&canPromptForAccessKey(ctx)){try{showAccessKeyCreateHint(accessKeyCreateUrl());ak=await promptAccessKey("")}catch(err){if(isAbortPrompt(err)){throw CliErrors.cancelled()}throw err}}if(!ak){throw CliErrors.validation("Missing accessKey.",buildAccessKeySetupGuide(accessKeyCreateUrl()))}if(!ACCESS_KEY_PATTERN.test(ak)){throw CliErrors.validation("Invalid accessKey format. Expected: ak_ followed by 16+ alphanumeric chars")}if(!envFlag){return{accessKey:ak}}const normalizedEnv=normalizeEnv(envFlag);return{accessKey:ak,env:isDaily(normalizedEnv)?"daily":isDev(normalizedEnv)?"development":"production"}}export const authDefinitions=[{service:"auth",command:"login",description:"Save the user AccessKey (global by default; --project for project config)",risk:"write",
|
|
2
|
+
;const CONFIGURED_ACCESS_KEY_STATUS_LINE="Status: valid";function showAccessKeyCreateHint(createUrl){writeCliSideChannelLine(`AccessKey required for login. Create one in ${PRODUCT_CONFIG.userCenterDisplayName}:`);writeCliSideChannelLine(`\n${createUrl}\n`);writeCliSideChannelLine("Tip: you can also run:");writeCliSideChannelLine(` ${CLI_BIN_NAME} auth login --access-key <ak_xxx>`)}function buildAccessKeySetupGuide(createUrl){return[`AccessKey required for login. Create one in ${PRODUCT_CONFIG.userCenterDisplayName}:`,createUrl,`Give the AccessKey to your AI Agent, then run: ${CLI_BIN_NAME} auth login --access-key <ak_xxx> [--global]`].join("\n")}function canPromptForAccessKey(ctx){return!ctx.nonInteractive&&process.stdin.isTTY!==false&&process.stdout.isTTY!==false}function resolveAuthScopeFlags(ctx){return toScopeFlags(resolveConfigScope({explicitGlobal:ctx.bool("global"),explicitProject:ctx.bool("project"),policy:"global-default"}))}async function resolveAuthWriteInput(ctx){
|
|
3
|
+
let ak=(ctx.str("access-key")||ctx.str("ak")||"").trim();const envFlag=(ctx.str("env")||"").trim();const accessKeyCreateUrl=()=>`${getUserPageDomain()}${PRODUCT_CONFIG.accessKeyCreatePath}`;if(!ak&&canPromptForAccessKey(ctx)){try{showAccessKeyCreateHint(accessKeyCreateUrl());ak=await promptAccessKey("")}catch(err){if(isAbortPrompt(err)){throw CliErrors.cancelled()}throw err}}if(!ak){throw CliErrors.validation("Missing accessKey.",buildAccessKeySetupGuide(accessKeyCreateUrl()))}if(!ACCESS_KEY_PATTERN.test(ak)){throw CliErrors.validation("Invalid accessKey format. Expected: ak_ followed by 16+ alphanumeric chars")}if(!envFlag){return{accessKey:ak}}const normalizedEnv=normalizeEnv(envFlag);return{accessKey:ak,env:isDaily(normalizedEnv)?"daily":isDev(normalizedEnv)?"development":"production"}}export const authDefinitions=[{service:"auth",command:"login",description:"Save the user AccessKey (global by default; --project for project config)",risk:"write",
|
|
4
4
|
confirmationDescription:"Saves a user AccessKey to the selected Lovrabet config. An existing key in that scope is overwritten. The confirmation UI does not show the secret.",requiresAuth:false,requiresAppCode:false,hasFormat:false,flags:[{name:"access-key",type:"string",description:"AccessKey (ak_xxx...)"},{name:"ak",type:"string",description:"Shorthand for --access-key"},{name:"global",type:"boolean",description:"Write to global config (default)",default:true},{name:"project",type:"boolean",description:"Write to project config instead of global config",default:false}],async execute(ctx){if(ctx.bool("yes")){throw CliErrors.validation("`auth login` does not support --yes.",`Use \`${CLI_BIN_NAME} auth login --non-interactive\` to avoid prompts, or \`${CLI_BIN_NAME} auth login --access-key <ak_xxx>\` to save credentials.`)}const providedAccessKey=(ctx.str("access-key")||ctx.str("ak")||"").trim();if(!providedAccessKey&&ctx.nonInteractive){return{ok:true,
|
|
5
5
|
message:buildAccessKeySetupGuide(`${getUserPageDomain()}${PRODUCT_CONFIG.accessKeyCreatePath}`)}}const resolved=await resolveAuthWriteInput(ctx);const scopeFlags=resolveAuthScopeFlags(ctx);const config=readScopedConfig(scopeFlags);config.accessKey=resolved.accessKey;if(resolved.env){config.env=resolved.env}writeScopedConfig(config,scopeFlags);const scope=scopeFlags.global?"global":"project";const envMessage=config.env?` Current env: ${config.env}.`:"";return{ok:true,message:`AccessKey saved to ${scope} config.${envMessage} Verify: ${CLI_BIN_NAME} auth status`}}},{service:"auth",command:"logout",description:"Clear the user AccessKey from config",risk:"write",confirmationDescription:"Removes the user AccessKey from the selected Lovrabet config. Credentials in another scope or environment variables are unchanged.",requiresAuth:false,requiresAppCode:false,hasFormat:false,flags:[{name:"global",type:"boolean",description:"Clear from global config (default)",default:true},{name:"project",
|
|
6
6
|
type:"boolean",description:"Clear from project config instead of global config",default:false}],async execute(ctx){const scopeFlags=resolveAuthScopeFlags(ctx);const config=readScopedConfig(scopeFlags);const had=!!config.accessKey;delete config.accessKey;writeScopedConfig(config,scopeFlags);const scope=scopeFlags.global?"global":"project";if(had)return{ok:true,message:`AccessKey cleared from ${scope} config.`};return{ok:true,message:`No AccessKey found in ${scope} config. Nothing to clear.`}}},{service:"auth",command:"status",description:"Show current authentication status",risk:"read",requiresAuth:false,requiresAppCode:false,hasFormat:false,flags:[{name:"global",type:"boolean",description:"Read from global config (default)",default:true},{name:"project",type:"boolean",description:"Read from project config instead of global config",default:false},{name:"check",type:"boolean",description:"Exit non-zero when no AccessKey is configured",default:false}],async execute(ctx){
|
|
7
|
-
const scopeFlags=resolveAuthScopeFlags(ctx);const raw=readScopedConfig(scopeFlags);const accessKeyEnvName=productEnvName("ACCESS_KEY");const accessKey=ctx.accessKey;const source=ctx.accessKeySource;const lines=[`Auth mode: ${AUTH_MODE.ClientAk}`];if(ctx.envName&&!isProduction(ctx.envName))lines.push(`Environment: ${ctx.envName}`);lines.push(`Stored AccessKey (${scopeFlags.global?"global":"project"} config): ${raw.accessKey?maskCliAccessKey(raw.accessKey):"(not set)"}`);if(accessKey){const masked=maskCliAccessKey(accessKey);lines.push(`AccessKey: ${masked}${source?` (via ${source})`:""}`);lines.push(
|
|
7
|
+
const scopeFlags=resolveAuthScopeFlags(ctx);const raw=readScopedConfig(scopeFlags);const accessKeyEnvName=productEnvName("ACCESS_KEY");const accessKey=ctx.accessKey;const source=ctx.accessKeySource;const lines=[`Auth mode: ${AUTH_MODE.ClientAk}`];if(ctx.envName&&!isProduction(ctx.envName))lines.push(`Environment: ${ctx.envName}`);lines.push(`Stored AccessKey (${scopeFlags.global?"global":"project"} config): ${raw.accessKey?maskCliAccessKey(raw.accessKey):"(not set)"}`);if(accessKey){const masked=maskCliAccessKey(accessKey);lines.push(`AccessKey: ${masked}${source?` (via ${source})`:""}`);lines.push(CONFIGURED_ACCESS_KEY_STATUS_LINE)}if(!accessKey){lines.push("");lines.push("No credentials found. Configure one of the options below:");lines.push("");lines.push(`Option A: ${CLI_BIN_NAME} auth login [--global] [--access-key ak_xxx]`);lines.push("");lines.push(`Option B: apps config (${PRODUCT_CONFIG.newConfigFileName})`);lines.push('{ "accessKey": "ak_xxx" }');lines.push("")
|
|
8
8
|
;lines.push("Option C: environment variable");lines.push(` export ${accessKeyEnvName}=ak_xxx`);lines.push("");lines.push(`Then verify with: ${CLI_BIN_NAME} auth status`);lines.push(`If command execution still fails, run: ${CLI_BIN_NAME} doctor`);if(ctx.bool("check")){const deviceCode=readStoredDeviceCode();if(deviceCode&&!isStoredDeviceCodeExpired(deviceCode)){const tokenResp=await fetchDeviceToken(getUserDomain(),deviceCode.code);if(tokenResp.status==="success"&&tokenResp.access_key){const scopeFlags={global:deviceCode.scope==="global"};const config=readScopedConfig(scopeFlags);config.accessKey=tokenResp.access_key;writeScopedConfig(config,scopeFlags);deleteStoredDeviceCode();const ak=tokenResp.access_key;const masked=maskCliAccessKey(ak);const scopeLabel=deviceCode.scope==="global"?"global config":"project config";return{ok:true,
|
|
9
|
-
message:[`Auth mode: ${AUTH_MODE.ClientAk}`,...ctx.envName&&!isProduction(ctx.envName)?[`Environment: ${ctx.envName}`]:[],`AccessKey: ${masked} (via ${scopeLabel})
|
|
9
|
+
message:[`Auth mode: ${AUTH_MODE.ClientAk}`,...ctx.envName&&!isProduction(ctx.envName)?[`Environment: ${ctx.envName}`]:[],`AccessKey: ${masked} (via ${scopeLabel})`,CONFIGURED_ACCESS_KEY_STATUS_LINE,`Device authorization completed.`].join("\n")}}if(tokenResp.status==="expired"){deleteStoredDeviceCode()}throw CliErrors.authRequired("Device authorization pending. Complete authorization in browser, then try again.")}throw CliErrors.authRequired(lines.join("\n"))}}return{ok:true,message:lines.join("\n")}}},{service:"auth",command:"info",description:"Fetch current login user info for the active access key",risk:"read",requiresAuth:true,requiresAppCode:false,hasFormat:true,flags:[],async execute(ctx){const user=await getLoginUserInfo();return{ok:true,data:{user:user,meta:{env:ctx.envName??"production"}}}}},authDeviceDefinition];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const VERSION = "2.4.0
|
|
2
|
-
export declare const GIT_TAG = "v2.4.0
|
|
3
|
-
export declare const GIT_COMMIT = "
|
|
4
|
-
export declare const BUILD_TIME = "2026-11-
|
|
1
|
+
export declare const VERSION = "2.4.0";
|
|
2
|
+
export declare const GIT_TAG = "v2.4.0";
|
|
3
|
+
export declare const GIT_COMMIT = "40794e3";
|
|
4
|
+
export declare const BUILD_TIME = "2026-11-20T15:28:18.664Z";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION="2.4.0
|
|
1
|
+
export const VERSION="2.4.0";export const GIT_TAG="v2.4.0";export const GIT_COMMIT="40794e3";export const BUILD_TIME="2026-11-20T15:28:18.664Z";
|
package/package.json
CHANGED
package/skills/lovrabet/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: lovrabet
|
|
3
3
|
displayName: Lovrabet 运行态 CLI
|
|
4
|
-
version: 2.4.0
|
|
4
|
+
version: 2.4.0
|
|
5
5
|
description: "Lovrabet 运行态 CLI — 面向业务场景的 AI 操作套件,通过 lovrabet 命令管理应用目录、业务角色与权限、用户级外部账号、API 文档发现、数据集查询、Instant API 数据操作、可恢复 Excel 导入、Custom SQL/Backend Function、Personal Backend Function、文件上传、面向票证类业务材料文字与结构化字段提取的 OCR、审批待办与任务办理、定时任务、Skill、知识库与运行态 app-config key 状态检查。触发词:云图、lovrabet、lovrabet-cli、指标查询、统计口径、经营报告、业务角色、角色成员、页面权限、菜单权限、数据集权限、user-account bind、provider 外部账号绑定、钉钉 userId 绑定、api-doc、dataset、data filter、Excel 导入、data import-excel、file upload、file query-url、ocr recognize、OCR 识别、票证文字提取、票证字段提取、发票识别、票据识别、证照识别、附件上传、personal-bff、approval、审批、待办、approve、reject、transfer、schedule、定时任务、cron、kb、skill、sql exec、bff exec、app-config、accessKey、compress、jq。"
|
|
6
6
|
metadata:
|
|
7
7
|
requires:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: lovrabet-report-generation
|
|
3
3
|
displayName: 业务报告与分析
|
|
4
|
-
version: 2.4.0
|
|
4
|
+
version: 2.4.0
|
|
5
5
|
description: "Use when 用户需要日报、周报、经营汇总、指标比较、综合分析,修改已有报告,或根据已提供的上下文补齐报告。完整匹配的企业业务 Skill 可直接使用;单值或身份查询不强制生成报告。不用于开发发布指标或修改业务数据。"
|
|
6
6
|
example: "帮我整理昨天各门店的经营情况。"
|
|
7
7
|
metadata:
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "lovrabet",
|
|
4
4
|
"packageName": "@lovrabet/lovrabet-cli",
|
|
5
|
-
"packageVersion": "2.4.0
|
|
6
|
-
"skillVersion": "2.4.0
|
|
5
|
+
"packageVersion": "2.4.0",
|
|
6
|
+
"skillVersion": "2.4.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"SKILL.md",
|
|
9
9
|
"guides/app-resolution.md",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"references/lovrabet-user-account.md",
|
|
44
44
|
"references/lovrabet-workspace.md"
|
|
45
45
|
],
|
|
46
|
-
"digest": "
|
|
46
|
+
"digest": "0e14bd3bf23d5819992a24959a1ec580eea251db48e58d7b2121ae2aa7280e7a"
|
|
47
47
|
}
|