@lovrabet/lovrabet-cli 2.3.13-beta.1 → 2.4.0-beta.2
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.
- package/README.md +22 -14
- package/lib/cli.js +4 -1
- package/lib/commands/api-doc/index.js +11 -1
- package/lib/commands/app/cache.js +2 -1
- package/lib/commands/app/definitions.js +7 -1
- package/lib/commands/app/eligibility.js +2 -1
- package/lib/commands/app/mock-loader.js +1 -1
- package/lib/commands/app/remote-source.js +2 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/approval/index.js +7 -1
- package/lib/commands/artifact/index.js +11 -1
- package/lib/commands/auth/device.js +8 -1
- package/lib/commands/auth/index.js +9 -1
- package/lib/commands/auth/prompt.js +2 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/exec.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/cli-skill/index.js +2 -1
- package/lib/commands/common/config-policy.js +2 -1
- package/lib/commands/common/constraints.js +2 -1
- package/lib/commands/common/flags.js +2 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/config/definitions.js +8 -1
- package/lib/commands/config/init.js +4 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/import-excel.js +10 -1
- package/lib/commands/data/index.js +10 -1
- package/lib/commands/dataset/detail.js +6 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +2 -1
- package/lib/commands/dataset/sdk-doc.js +1 -1
- package/lib/commands/doctor.js +9 -1
- package/lib/commands/file/index.js +3 -1
- package/lib/commands/init.js +4 -1
- package/lib/commands/issue/context.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/report.js +5 -1
- package/lib/commands/kb/index.js +7 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/metric/contract.js +5 -1
- package/lib/commands/metric/definition.js +4 -1
- package/lib/commands/metric/detail.js +1 -1
- package/lib/commands/metric/exec.js +3 -1
- package/lib/commands/metric/index.js +1 -1
- package/lib/commands/metric/list.js +2 -1
- package/lib/commands/metric/shared.js +2 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +2 -1
- package/lib/commands/ocr/index.js +4 -1
- package/lib/commands/permit/dataset-get.js +1 -1
- package/lib/commands/permit/dataset-set.js +5 -1
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.js +3 -1
- package/lib/commands/permit/role-menus-set.js +4 -1
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.js +7 -1
- package/lib/commands/personal-bff/index.js +7 -1
- package/lib/commands/registry.js +6 -1
- package/lib/commands/role/create.js +2 -1
- package/lib/commands/role/delete.js +2 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +2 -1
- package/lib/commands/role/shared.js +8 -1
- package/lib/commands/role/update.js +3 -1
- package/lib/commands/role/user-add.js +2 -1
- package/lib/commands/role/user-remove.js +2 -1
- package/lib/commands/schedule/index.js +7 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/service/dynamic.js +10 -1
- package/lib/commands/service/function-name-adapter.js +3 -1
- package/lib/commands/service/index.js +8 -1
- package/lib/commands/service/registry.js +12 -1
- package/lib/commands/skill/commands/create.js +3 -1
- package/lib/commands/skill/commands/diagram.js +4 -1
- package/lib/commands/skill/commands/install.js +6 -1
- package/lib/commands/skill/commands/list.js +3 -1
- package/lib/commands/skill/commands/push.js +1 -1
- package/lib/commands/skill/commands/validate.js +1 -1
- package/lib/commands/skill/diagram.js +3 -1
- package/lib/commands/skill/flags.js +4 -1
- package/lib/commands/skill/index.js +1 -1
- package/lib/commands/skill/manifest-helpers.js +1 -1
- package/lib/commands/skill/push-execute.js +11 -1
- package/lib/commands/skill/push-flow-helpers.js +4 -1
- package/lib/commands/skill/push-retarget.js +1 -1
- package/lib/commands/skill/scopes.js +1 -1
- package/lib/commands/skill/summary.js +1 -1
- package/lib/commands/skill/templates.js +8 -1
- package/lib/commands/skill/validate.js +8 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +2 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/update.d.ts +2 -1
- package/lib/commands/update.js +8 -1
- package/lib/commands/user-account/bind.js +3 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/index.js +7 -1
- package/lib/config/domain-config.js +6 -1
- package/lib/config/schema.js +5 -1
- package/lib/constant/app.js +1 -1
- package/lib/constant/auth-mode.js +1 -1
- package/lib/constant/cli.js +3 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/distribution.js +1 -1
- package/lib/constant/domain.js +2 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/product.js +2 -1
- package/lib/constant/region.js +2 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/url.js +1 -1
- package/lib/context.js +11 -1
- package/lib/core/api-client.js +38 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/kb-management-client.js +6 -1
- package/lib/core/kb-sdk-errors.js +2 -1
- package/lib/core/kb-search-client.js +2 -1
- package/lib/core/sdk-client.js +5 -1
- package/lib/errors.js +2 -1
- package/lib/framework/access-error.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/dryrun.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +2 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/preparse.js +3 -1
- package/lib/framework/rate-limit.js +2 -1
- package/lib/framework/raw-flags.js +2 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-confirmation.js +2 -1
- package/lib/framework/runner-error.js +2 -1
- package/lib/framework/runner.js +9 -1
- package/lib/framework/schema-export.js +2 -1
- package/lib/framework/service-order.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +2 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +4 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +2 -1
- package/lib/runtime/types.js +1 -1
- package/lib/services/dataset-import/auto-id-runner.js +9 -1
- package/lib/services/dataset-import/excel-reader.js +25 -1
- package/lib/services/dataset-import/image-bytes.js +6 -1
- package/lib/services/dataset-import/image-ooxml.js +15 -1
- package/lib/services/dataset-import/image-runner.js +9 -1
- package/lib/services/dataset-import/metadata.js +1 -1
- package/lib/services/dataset-import/preview.js +1 -1
- package/lib/services/dataset-import/runner.js +13 -1
- package/lib/services/dataset-import/types.js +1 -1
- package/lib/skills/builtin-skill.js +8 -1
- package/lib/skills/install-updated-skill.d.ts +8 -0
- package/lib/skills/install-updated-skill.js +3 -0
- package/lib/skills/local-skills-installer.d.ts +2 -0
- package/lib/skills/local-skills-installer.js +1 -0
- package/lib/skills/npx-skills-add.d.ts +2 -2
- package/lib/skills/npx-skills-add.js +4 -1
- package/lib/skills/runtime-skill-sync/constants.js +1 -1
- package/lib/skills/runtime-skill-sync/fs-utils.js +3 -1
- package/lib/skills/runtime-skill-sync/hashing.js +1 -1
- package/lib/skills/runtime-skill-sync/install-target.js +1 -1
- package/lib/skills/runtime-skill-sync/links.js +9 -1
- package/lib/skills/runtime-skill-sync/list-local.js +4 -1
- package/lib/skills/runtime-skill-sync/local-files.js +5 -1
- package/lib/skills/runtime-skill-sync/materialize.js +9 -1
- package/lib/skills/runtime-skill-sync/metadata.js +3 -1
- package/lib/skills/runtime-skill-sync/paths.js +2 -1
- package/lib/skills/runtime-skill-sync/push.js +8 -1
- package/lib/skills/runtime-skill-sync/scopes.js +1 -1
- package/lib/skills/runtime-skill-sync/types.js +1 -1
- package/lib/skills/runtime-skill-sync/zip-codec.js +2 -1
- package/lib/skills/runtime-skill-sync/zip-package.js +6 -1
- package/lib/skills/runtime-skill-sync.js +1 -1
- package/lib/skills/skill-presence.d.ts +1 -34
- package/lib/skills/skill-presence.js +2 -1
- package/lib/utils/access-key-redaction.js +2 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cli-version-check.js +2 -1
- package/lib/utils/cli-version-policy.js +3 -1
- package/lib/utils/logger.js +3 -1
- package/lib/utils/lossless-json.js +3 -1
- package/lib/utils/params.js +3 -1
- package/lib/utils/positive-safe-integer.js +1 -1
- package/lib/utils/redaction.js +2 -1
- package/lib/utils/runtime-user-id.js +1 -1
- package/lib/utils/update-notice.js +3 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +5 -7
- package/skills/lovrabet/SKILL.md +3 -3
- package/skills/lovrabet/references/lovrabet-skill-install.md +1 -1
- package/skills/lovrabet/references/lovrabet-update.md +6 -4
- package/skills/lovrabet-report-generation/SKILL.md +1 -1
- package/skills/lovrabet.manifest.json +3 -3
- package/lib/postinstall.d.ts +0 -2
- package/lib/postinstall.js +0 -1
- package/scripts/postinstall.mjs +0 -24
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";export function resolvePushScope(ctx){const scope=ctx.str("scope")||"personal";if(scope==="personal"||scope==="company"){return scope}throw CliErrors.validation(`skill push supports --scope personal or --scope company; received "${scope}".`)}export function allowRetargetArgs(allowRetarget){return allowRetarget?[{allowAppCodeRetarget:true}]:[]}export function remoteFirstMetadataOptions(){return{ignoreInvalidMetadata:true,ignoreMetadataAppCodeMismatch:true,ignoreMetadataSkillCode:true}}export function remoteMissingPayloadOptions(){return{ignoreMetadataForPayload:true,ignoreMetadataScope:true,ignoreMetadataSkillCode:true}}export function remoteMissingCompanyReadOptions(){return{targetScope:"company",...remoteFirstMetadataOptions(),...remoteMissingPayloadOptions()}}export function remoteMissingPersonalReadOptions(extra={}){return{...remoteFirstMetadataOptions(),...remoteMissingPayloadOptions(),...extra}}
|
|
2
|
+
export function remotePersonalReadOptions(allowLocalScopeRecovery,extra={}){return{ignoreInvalidMetadata:true,...allowLocalScopeRecovery?{ignoreMetadataAppCodeMismatch:true,ignoreMetadataScope:true}:{},...extra}}export function throwIfBuiltinPushTarget(remote){if(remote?.scope!=="builtin"){return}throw CliErrors.validation(`Builtin Skill ${remote.skillCode??"(unknown)"} cannot be pushed.`,"Use a different skillCode when submitting a personal or company Skill.")}export function throwIfPublishValidationFailed(scope,skillCode,validation){if(validation.errors.length===0&&(validation.valid||validation.warnings.length>0)){return}const detail=validation.errors.length>0?validation.errors.join("; "):"SkillHub validation returned invalid.";const scopeLabel=scope==="company"?"Company":"Personal";throw CliErrors.validation(`${scopeLabel} Skill push validation failed for ${skillCode}.`,detail)}export function throwIfUnconfirmedPublishWarnings(scope,skillCode,warnings,confirmWarnings){
|
|
3
|
+
if(warnings.length===0||confirmWarnings){return}const scopeLabel=scope==="company"?"Company":"Personal";throw CliErrors.validation(`${scopeLabel} Skill push validation reported warning(s) for ${skillCode}.`,["Review each warning before continuing.","Do not modify the source Skill merely to satisfy publishing.","Fix real issues. If the remaining warnings are reviewed false positives, rerun with --confirm-warnings to submit the unchanged package.",`Warnings: ${warnings.join("; ")}`].join(" "))}export function buildRetargetWarning(metadata,targetAppCode){if(!metadata?.appCode||metadata.appCode===targetAppCode){return[]}return[{level:"warning",ruleId:"skill-metadata-appcode-retargeted",file:"lovrabet.skill.json",message:`Local Skill metadata appCode ${metadata.appCode} was retargeted to explicit appCode ${targetAppCode} after successful push.`,suggestion:"Review the updated local Skill metadata before the next push."}]}export async function runRemoteContentPreflight(input){
|
|
4
|
+
if(!input.remote||input.remote.scope!==input.scope||!input.publishInput.files){return{status:"not-applicable"}}const remoteSkillCode=input.remote.skillCode||input.skillCode;if(!remoteSkillCode){return{status:"not-applicable"}}const remotePackage=await input.downloadRuntimeSkillPackage(input.scope,remoteSkillCode,input.appCode,input.remote.version);try{input.verifyRuntimeSkillBundle(input.publishInput.files,remotePackage)}catch{return{status:"different"}}return{status:"identical",savedSkill:{...input.remote,content:input.publishInput.content,files:input.publishInput.files}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export function withRetargetExistingMetadata(input,existing,options={}){const skillName=options.preferInputSkillName?input.skillName??existing.skillName:existing.skillName??input.skillName;return{...input,skillName:skillName,description:existing.description??input.description,tags:Array.isArray(existing.tags)?existing.tags:input.tags,version:existing.version??input.version,sourceSessionId:existing.sourceSessionId??input.sourceSessionId}}export function buildRetargetWarning(metadata,targetAppCode){if(!metadata?.appCode||metadata.appCode===targetAppCode){return[]}return[{level:"warning",ruleId:"skill-metadata-appcode-retargeted",file:"lovrabet.skill.json",message:`Local Skill metadata appCode ${metadata.appCode} was retargeted to explicit appCode ${targetAppCode} after successful push.`,suggestion:"Review the updated local Skill metadata before the next push."}]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";export function normalizeSyncScopes(value){const normalized=value.trim();if(!normalized||normalized==="all")return["personal","company"];if(normalized==="personal"||normalized==="company")return[normalized];throw CliErrors.validation(`Unsupported Skill sync scope: ${value}`)}export function normalizeListScope(value){const normalized=value.trim();if(!normalized)return"all";if(normalized==="personal"||normalized==="company"||normalized==="all"){return normalized}throw CliErrors.validation(`Unsupported Skill list scope: ${value}`)}export function shouldListScope(scope,target){if(scope==="all")return true;return scope===target}export function listScopeToRuntimeScopes(scope){if(scope==="all")return["personal","company"];return[scope==="company"?"company":scope]}export function listScopeToRemoteScope(scope){return scope}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export function summarizeRuntimeSkill(item){return{id:item.id,skillCode:item.skillCode,skillName:item.skillName,scope:item.scope,version:item.version,readonly:item.readonly}}export function summarizeLocalRuntimeSkill(item){return{id:item.id,skillCode:item.skillCode,skillName:item.skillName,scope:item.scope,appCode:item.appCode,version:item.version,status:item.status,readonly:item.readonly,tags:item.tags,dir:item.dir,cacheDir:item.cacheDir,skillMdPath:item.skillMdPath,metadataPath:item.metadataPath,linkedPaths:item.linkedPaths,contentHash:item.contentHash,treeHash:item.treeHash,pulledAt:item.pulledAt}}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";export const SKILL_TYPES=["write","read"];export const DEFAULT_SKILL_TARGET=".agents/skills";export const SKILL_NAME_PATTERN=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;export const RUNTIME_CONTRACT_FILE="references/runtime-contract.md";export const OUTPUT_CONTRACT_FILE="references/output-contract.md";export function validateSkillName(name){const normalized=name.trim();if(!SKILL_NAME_PATTERN.test(normalized)){throw CliErrors.validation(`Invalid Skill name: ${name}. Use lowercase letters, numbers, and single hyphens.`,"Use lowercase letters, numbers, and single hyphens, for example invoice-export.")}return normalized}export function normalizeSkillTemplateType(type){const normalized=(type||"write").trim()||"write";if(SKILL_TYPES.includes(normalized)){return normalized}throw CliErrors.validation(`Unsupported Skill type: ${type}`,`Use one of: ${SKILL_TYPES.join(", ")}.`)}export function renderSkillTemplate(options){
|
|
2
|
+
const skillName=validateSkillName(options.skillName);const type=normalizeSkillTemplateType(options.type);const timestamp=options.timestamp??(new Date).toISOString();return{skillName:skillName,type:type,files:[{path:"SKILL.md",content:renderSkillMd(skillName,type,timestamp)},{path:RUNTIME_CONTRACT_FILE,content:renderRuntimeContract(skillName,type)},{path:OUTPUT_CONTRACT_FILE,content:renderOutputContract(skillName,type)}]}}function renderSkillMd(skillName,type,timestamp){const workflow=typeWorkflow(type)
|
|
3
|
+
;return`---\nname: ${skillName}\n# displayName: "<填写符合用户实际诉求的人类可读展示名>"\ndescription: "【填写模型触发语义:用户在什么场景应使用本 Skill、不要使用的边界和关键词】"\n# example: "<填写一句用户可以直接说出的最简触发话术>"\nmetadata:\n type: ${type}\n created: "${timestamp}"\n generator: "lovrabet skill create"\n---\n\n# ${skillName}\n\n## 内部要求\n\n执行前必须读取并遵守 [runtime-contract.md](references/runtime-contract.md) 和 [output-contract.md](references/output-contract.md)。\n\n## 使用边界\n\n【填写该 Skill 能做什么、不能做什么、适用业务范围和禁止扩大执行范围】\n\n## 输入门禁\n\n【填写必须具备的输入;缺失业务对象、执行范围、确认信息或权限上下文时必须停止】\n\n## 与现有能力集成\n\n【填写本 Skill 使用的 lovrabet data、lovrabet sql、lovrabet bff 或 lovrabet personal-bff 命令,以及包内 references/ 中沉淀的运行态入口、脚本对接方式或人工操作边界。不得依赖 Skill 目录外文件、绝对路径或本机专属配置。】\n\n## 平台能力优先\n\n【填写本 Skill 优先使用的 Lovrabet 平台命令:lovrabet data / lovrabet sql / lovrabet bff / lovrabet personal-bff。本地脚本仅用于平台明确不覆盖的文件格式转换、静态校验、展示整理或第三方薄适配;不得用本地脚本替代平台命令承载业务写入、权限判断、状态机、审批提交或回滚。】\n\n## 第三方服务边界\n\n【填写是否调用第三方识别、生成、上传或行业服务;如涉及 API Key、OAuth、Cookie、登录态或业务数据上传,必须说明由 Lovrabet 应用后台、Backend Function 或平台适配器统一配置。目标治理口径是 Skill 不读取、不分发、不保存明文凭证。详细凭证、额度、审计和审核发布规则写入 references/runtime-contract.md。】\n\n## SOP 工作流\n\n${workflow}\n\n${businessStateSection(type)}\n\n## 展示规范\n\n【填写面向运营人员的展示字段、差异摘要、成功/失败状态和人工处理项;最终输出必须按 references/output-contract.md 的 status / mode / summary / errors / nextActions 返回,不能把 unknown、partial_success、failed 或 needs_manual_check 包装为 success。】\n\n## 失败恢复\n\n【填写失败后的 checkpoint、重试条件、人工接管方式和避免重复写入的核对步骤】\n`
|
|
4
|
+
}function renderRuntimeContract(skillName,type){const stateReadback=type==="write"?`## 状态读回与未知状态处理\n\n【填写业务状态事实源、fromStatus -> toStatus 预览、写入后读回核对方式,以及 unknown / needs_manual_check 的处理边界】\n\n`:""
|
|
5
|
+
;return`# Runtime Contract\n\nSkill push 后的 zip 包就是完整交付产物。${skillName} 的所有必读规则必须位于 SKILL.md 或 references/ 内。\n\n## 必读文档\n\n- [SKILL.md](../SKILL.md)\n- [runtime-contract.md](runtime-contract.md)\n- [output-contract.md](output-contract.md)\n\n## 主边界\n\n- 不得依赖 Skill 目录外的仓库文件、绝对路径、file URL 或本机专属配置。\n- 文档中的缓存路径、安装路径、示例路径或排障路径不等于运行时包外依赖;只有明确要求读取、链接或执行包外内容时才属于自包含风险。\n- 如需承接仓库规范,必须把必要规则内化到本 Skill 包内的 references/ 文件中。\n- type=${type} 只作为模板选择器,不替代业务权限、风险等级和用户确认。\n\n## 运行态入口\n\n【填写包内说明的运行态入口、可调用脚本或人工执行边界】\n\n## 凭证与登录态\n\n【填写本 Skill 依赖的第三方服务凭证和登录态治理方式。强烈建议通过 Lovrabet 应用后台或平台服务端适配器做平台托管配置;开发先行阶段如存在临时明文凭证,应标注后续治理计划、适用环境和额度边界,并避免进入长期交付内容。】\n\n## 第三方候选资产\n\n【填写第三方生成类结果的消费边界。生成类结果仅作为候选素材;涉及商品图、客户资料、Excel 或业务文件上传时,必须声明授权、额度、审计、失败降级和人工审核/业务 Backend Function 校验后的发布边界。】\n\n## 预览 / 写入 / 核对差异\n\n【填写预览、确认、正式执行和只读核对的顺序】\n\n${stateReadback}\n## 返回契约\n\n最终输出必须遵守 [output-contract.md](output-contract.md)。本文件只补充运行态安全约束;展示字段、状态枚举、失败暴露和人工处理项以 output-contract.md 为准。\n\n## 失败恢复\n\n【填写失败状态识别、checkpoint、重试和人工接管方式】\n\n## 禁止事项\n\n- 禁止链接或读取 Skill 目录外的 AGENTS.md、wiki、docs、脚本或个人路径作为运行时必读依赖。\n- 禁止把说明性的缓存路径、安装路径、示例路径或排障路径包装成运行时必读依赖。\n- 禁止在未确认影响范围时执行写入。\n- 禁止隐藏失败或把未知状态描述为成功。\n`
|
|
6
|
+
}function renderOutputContract(skillName,type){const writeSpecific=type==="write"?`write 类型在 dry_run 下只展示预览、影响范围和差异,不写入业务数据。\nconfirmed 写入后必须执行读回核对,并把核对结果写入 verification。\n读回异常、业务状态未知或结果不一致时,status 必须为 partial_success、failed 或 needs_manual_check。`:`${type} 类型默认不执行业务写入;如流程包含受控维护或人工确认,也必须用 mode 标明执行阶段并暴露核对结果。`
|
|
7
|
+
;return`# Output Contract\n\n${skillName} 的最终回复必须让运营人员能判断:是否执行、影响了什么、如何复核、失败后下一步做什么。\n\n## 状态枚举\n\nstatus: success | no_op | partial_success | blocked | failed | needs_manual_check\n\n- success:动作已完成,且关键结果已核对。\n- no_op:没有符合条件的对象或无需变更。\n- partial_success:部分对象完成,未完成对象必须进入 errors 和 nextActions。\n- blocked:缺少输入、权限、确认或平台能力,无法继续。\n- failed:执行失败,必须说明失败阶段、错误和恢复方式。\n- needs_manual_check:读回异常、状态未知或人工判断缺失。\n\nunknown、partial_success、failed、needs_manual_check 不能包装为 success。\n\n## 输出模式\n\nmode: dry_run | confirmed | read_only\n\n- dry_run:只展示预览、影响范围和差异,不写入业务数据。\n- confirmed:用户明确确认后的执行模式;写入后必须读回核对。\n- read_only:只查询、汇总或核对,不触发写入。\n\n## 必填字段\n\n- status\n- mode\n- summary\n- scope\n- changes\n- verification\n- warnings\n- errors\n- nextActions\n\n## 写入结果\n\n${writeSpecific}\n\n## 错误与人工接管\n\nerrors 必须包含失败阶段、错误原因和可复核对象。\nnextActions 必须给出重试、补充输入、人工接管或停止处理的动作。\n`}function typeWorkflow(type){if(type==="read"){
|
|
8
|
+
return`1. 只读查询:【填写查询入口、过滤条件和权限边界】\n2. 业务汇总:【填写统计口径、字段解释和异常提示】\n3. 查看链接:【填写可供运营人员复核的记录、页面或报告链接】\n4. 禁止写入:不得创建、更新、删除或触发会改变业务状态的动作。`}return`1. dry-run:【填写预览入口、影响范围和差异摘要;不得写入业务数据】\n2. 用户确认:【填写确认语义、目标对象、数量、风险和操作者责任】\n3. confirmed 写入:【填写确认后的写入入口和幂等/防重复要求】\n4. 只读核对:【填写写入后的查询核对、差异展示和结果链接】\n5. checkpoint:【填写失败恢复、重试条件和人工接管方式】`}function businessStateSection(type){if(type!=="write")return"";return`## 业务状态流转\n\n【填写本 Skill 的前置业务状态、允许动作、目标业务状态、fromStatus -> toStatus 预览、写入后读回核对,以及 unknown / needs_manual_check 处理。状态迁移合法性必须由业务 Backend Function、Lovrabet 平台命令或服务端接口判断,Skill 不作为状态事实源。】`}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
const a92_0x28873f=a92_0x4049;(function(_0x3b65ac,_0x3f2485){const _0x3a6065=a92_0x4049,_0xdc097b=_0x3b65ac();while(!![]){try{const _0x50035b=-parseInt(_0x3a6065(0xb2))/0x1*(parseInt(_0x3a6065(0xbc))/0x2)+parseInt(_0x3a6065(0xa9))/0x3*(-parseInt(_0x3a6065(0xd4))/0x4)+-parseInt(_0x3a6065(0xd7))/0x5+-parseInt(_0x3a6065(0x89))/0x6*(-parseInt(_0x3a6065(0xa3))/0x7)+-parseInt(_0x3a6065(0xcf))/0x8*(-parseInt(_0x3a6065(0xbd))/0x9)+-parseInt(_0x3a6065(0xb5))/0xa+-parseInt(_0x3a6065(0x88))/0xb*(-parseInt(_0x3a6065(0xe5))/0xc);if(_0x50035b===_0x3f2485)break;else _0xdc097b['push'](_0xdc097b['shift']());}catch(_0x3d6f9a){_0xdc097b['push'](_0xdc097b['shift']());}}}(a92_0x5830,0x6da94));import{existsSync,lstatSync,readFileSync,realpathSync}from'node:fs';import{resolve}from'node:path';import{parse as a92_0xf745e1}from'yaml';function a92_0x4049(_0x1b0273,_0x15f906){_0x1b0273=_0x1b0273-0x86;const _0x583070=a92_0x5830();let _0x404973=_0x583070[_0x1b0273];return _0x404973;}import{CliErrors}from'../../errors.js';import{fileText,scanSkillDirectory}from'../../skills/runtime-skill-sync/local-files.js';const SKILL_FILE=a92_0x28873f(0xd9),SUPPORTED_SKILL_TYPES=new Set([a92_0x28873f(0xc2),a92_0x28873f(0xac)]),TEXT_SKILL_FILE_PATTERN=/(?:^SKILL\.md$|\.(?:md|mdx|txt|json|ya?ml|js|mjs|cjs|ts|tsx|sh|sql))$/i;export function validateSkillDirectory(_0x5681bf,_0x2aa046={}){const _0x35d97e=a92_0x28873f,_0x56e6bf=resolveSkillDirectoryRoot(_0x5681bf),_0xc78fde=[],_0x4fbd6b=loadRequiredSkillFile(_0x56e6bf,_0xc78fde),_0x883980=_0x4fbd6b?parseFrontmatter(_0x4fbd6b[_0x35d97e(0x91)]):{'hasFrontmatter':![]};_0x4fbd6b&&validateFrontmatter(_0x4fbd6b[_0x35d97e(0xd6)],_0x883980,_0xc78fde);validateRuntimeCliReferences(_0x56e6bf,_0xc78fde);const _0x41e32a=_0xc78fde['filter'](_0x29c3df=>_0x29c3df[_0x35d97e(0xc0)]==='error'),_0x39e26e=_0xc78fde[_0x35d97e(0xe1)](_0x9c7651=>_0x9c7651[_0x35d97e(0xc0)]==='warning');return{'ok':_0x41e32a['length']===0x0,'dir':_0x56e6bf,'type':_0x883980[_0x35d97e(0x8a)],'errors':_0x41e32a,'warnings':_0x39e26e};}function resolveSkillDirectoryRoot(_0x157cdb){const _0x4c6f22=a92_0x28873f,_0x36a170=resolve(_0x157cdb);if(!existsSync(_0x36a170))throw CliErrors[_0x4c6f22(0xe6)]('Skill\x20directory\x20not\x20found:\x20'+_0x157cdb);const _0x37c1f1=lstatSync(_0x36a170);if(_0x37c1f1[_0x4c6f22(0xa0)]())return _0x36a170;if(_0x37c1f1['isSymbolicLink']()){const _0x2778c5=realpathSync(_0x36a170);if(lstatSync(_0x2778c5)[_0x4c6f22(0xa0)]())return _0x2778c5;}throw CliErrors[_0x4c6f22(0xe6)](_0x4c6f22(0xad)+_0x157cdb);}export function throwIfSkillValidationFailed(_0x250f75,_0x712ee1=![]){const _0x3c074d=a92_0x28873f;if(_0x250f75['ok'])return;const _0x3c44df=_0x250f75[_0x3c074d(0xe8)][_0x3c074d(0xb7)](_0x155b2e=>{const _0x380b9d=_0x3c074d,_0x4fa2ac=_0x155b2e[_0x380b9d(0xbb)]?'#'+_0x155b2e['section']:'';return _0x155b2e[_0x380b9d(0xc0)]['toUpperCase']()+'\x20'+_0x155b2e[_0x380b9d(0xa7)]+'\x20'+_0x155b2e[_0x380b9d(0xa8)]+_0x4fa2ac+':\x20'+_0x155b2e['message']+_0x380b9d(0xd1)+_0x155b2e[_0x380b9d(0x93)];});throw CliErrors[_0x3c074d(0xe6)](_0x3c074d(0xab)+_0x3c44df[_0x3c074d(0x87)]('\x0a'),_0x3c074d(0x8c));}function loadRequiredSkillFile(_0x1747a1,_0x10e605){const _0x3b77ad=a92_0x28873f,_0x20e0df=resolve(_0x1747a1,SKILL_FILE);if(!existsSync(_0x20e0df))return _0x10e605[_0x3b77ad(0x86)](issue('error',_0x3b77ad(0xbf),SKILL_FILE,_0x3b77ad(0xbe),'Add\x20SKILL.md\x20at\x20the\x20Skill\x20directory\x20root.')),undefined;const _0x4fd6a4=lstatSync(_0x20e0df);if(_0x4fd6a4[_0x3b77ad(0x92)]())return _0x10e605['push'](issue(_0x3b77ad(0xa2),'structure-complete',SKILL_FILE,_0x3b77ad(0x94),_0x3b77ad(0xa6))),undefined;if(!_0x4fd6a4['isFile']())return _0x10e605[_0x3b77ad(0x86)](issue(_0x3b77ad(0xa2),_0x3b77ad(0xbf),SKILL_FILE,'SKILL.md\x20is\x20not\x20a\x20file.',_0x3b77ad(0xb6))),undefined;return{'path':SKILL_FILE,'content':readFileSync(_0x20e0df,'utf8')};}function validateFrontmatter(_0x2ed2e0,_0x82488c,_0x724bf6){const _0x10877e=a92_0x28873f;if(!_0x82488c[_0x10877e(0xe7)]){_0x724bf6[_0x10877e(0x86)](issue(_0x10877e(0xa2),_0x10877e(0xa5),_0x2ed2e0,_0x10877e(0x9f),_0x10877e(0xc1)));return;}!_0x82488c[_0x10877e(0xce)]?.[_0x10877e(0xde)]()&&_0x724bf6[_0x10877e(0x86)](issue(_0x10877e(0xa2),'frontmatter-required',_0x2ed2e0,_0x10877e(0xc3),_0x10877e(0xc5))),!_0x82488c[_0x10877e(0xb9)]?.[_0x10877e(0xde)]()&&_0x724bf6[_0x10877e(0x86)](issue(_0x10877e(0x8d),_0x10877e(0xcb),_0x2ed2e0,_0x10877e(0xcd),_0x10877e(0xb0))),!_0x82488c[_0x10877e(0x9a)]?.[_0x10877e(0xde)]()&&_0x724bf6[_0x10877e(0x86)](issue(_0x10877e(0x8d),_0x10877e(0x9b),_0x2ed2e0,_0x10877e(0x8f),_0x10877e(0xd5))),!_0x82488c['description']?.[_0x10877e(0xde)]()&&_0x724bf6[_0x10877e(0x86)](issue(_0x10877e(0xa2),_0x10877e(0x98),_0x2ed2e0,_0x10877e(0x8e),_0x10877e(0xa4))),_0x82488c[_0x10877e(0x97)]===!![]&&_0x724bf6[_0x10877e(0x86)](issue('error','internal-skill',_0x2ed2e0,_0x10877e(0xb8),_0x10877e(0xd3))),_0x82488c[_0x10877e(0x8a)]?.[_0x10877e(0xde)]()&&!SUPPORTED_SKILL_TYPES[_0x10877e(0x95)](_0x82488c[_0x10877e(0x8a)])&&_0x724bf6[_0x10877e(0x86)](issue(_0x10877e(0xa2),_0x10877e(0xa5),_0x2ed2e0,_0x10877e(0xe2),_0x10877e(0xaa)));}function validateRuntimeCliReferences(_0x37c17a,_0x53b722){const _0x4bcc0f=a92_0x28873f;for(const _0x269c9d of findRabetbaseCliInvocations(_0x37c17a)){_0x53b722[_0x4bcc0f(0x86)](issue('warning',_0x4bcc0f(0xdb),_0x269c9d[_0x4bcc0f(0xa8)],_0x4bcc0f(0xca),_0x4bcc0f(0x9e),'L'+_0x269c9d[_0x4bcc0f(0xe3)]));}}function findRabetbaseCliInvocations(_0x1cd550){const _0x80f8ff=a92_0x28873f;return scanSkillDirectory(_0x1cd550)['filter'](_0x4d74ef=>TEXT_SKILL_FILE_PATTERN[_0x80f8ff(0xb1)](_0x4d74ef[_0x80f8ff(0xd6)]))[_0x80f8ff(0xd0)](_0x16ef08=>{const _0x548681=_0x80f8ff,_0x416a5c=fileText(_0x16ef08);return _0x416a5c[_0x548681(0xe0)](/\r?\n/)[_0x548681(0xb7)]((_0x2d9076,_0x1aa71b)=>({'file':_0x16ef08[_0x548681(0xd6)],'line':_0x1aa71b+0x1,'text':_0x2d9076}))['filter'](({text:_0x8a95b7})=>isRabetbaseCliInvocation(_0x8a95b7))[_0x548681(0xb7)](({file:_0x5199aa,line:_0x392c38})=>({'file':_0x5199aa,'line':_0x392c38}));});}const RABETBASE_SUBCOMMANDS=[a92_0x28873f(0xc7),a92_0x28873f(0xd8),a92_0x28873f(0x9d),a92_0x28873f(0xdd),a92_0x28873f(0xc9),a92_0x28873f(0xaf),a92_0x28873f(0x99),a92_0x28873f(0xb3),a92_0x28873f(0xae),'kb',a92_0x28873f(0xcc),a92_0x28873f(0xd2),a92_0x28873f(0xda),a92_0x28873f(0xba),a92_0x28873f(0xa1),a92_0x28873f(0x9c)],RABETBASE_INVOCATION=new RegExp(String[a92_0x28873f(0x8b)]`\brabetbase\s+(?:${RABETBASE_SUBCOMMANDS[a92_0x28873f(0x87)]('|')})\b`+String[a92_0x28873f(0x8b)]`(?:\s+[a-z][\w-]*){0,2}\s+(?:--?[a-z]|[\w.-]+=)`,'i');function isRabetbaseCliInvocation(_0x4de787){const _0x560189=a92_0x28873f,_0x3c9588=_0x4de787['search'](/\brabetbase\b/i);if(_0x3c9588<0x0)return![];const _0x155e97=_0x4de787[_0x560189(0xc4)](_0x3c9588)[_0x560189(0xe0)](/\blovrabet\b/i)[0x0]??'';return RABETBASE_INVOCATION['test'](_0x155e97);}function parseFrontmatter(_0x262542){const _0x550e91=a92_0x28873f,_0x250453=_0x262542[_0x550e91(0xe4)](/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);if(!_0x250453)return{'hasFrontmatter':![]};const _0x34add3=_0x250453[0x1]??'',_0x307de3={'hasFrontmatter':!![]};let _0x4700c6;try{_0x4700c6=a92_0xf745e1(_0x34add3);}catch{return _0x307de3;}const _0x2f5238=asRecord(_0x4700c6);if(!_0x2f5238)return _0x307de3;_0x307de3[_0x550e91(0xce)]=scalarToString(_0x2f5238[_0x550e91(0xce)]),_0x307de3['displayName']=scalarToString(_0x2f5238[_0x550e91(0xb9)]),_0x307de3[_0x550e91(0xb4)]=scalarToString(_0x2f5238[_0x550e91(0xb4)]),_0x307de3['example']=scalarToString(_0x2f5238[_0x550e91(0x9a)]);const _0x5e966e=asRecord(_0x2f5238['metadata']);return _0x5e966e&&(_0x307de3[_0x550e91(0x8a)]=scalarToString(_0x5e966e[_0x550e91(0x8a)]),_0x307de3[_0x550e91(0x97)]=scalarToBoolean(_0x5e966e['internal'])),_0x307de3;}function asRecord(_0x2a3dcb){const _0x6d0e82=a92_0x28873f;if(_0x2a3dcb&&typeof _0x2a3dcb===_0x6d0e82(0x90)&&!Array[_0x6d0e82(0x96)](_0x2a3dcb))return _0x2a3dcb;return undefined;}function scalarToString(_0x3c866a){const _0x791acf=a92_0x28873f;if(typeof _0x3c866a===_0x791acf(0xdc))return _0x3c866a[_0x791acf(0xde)]();if(typeof _0x3c866a==='number'||typeof _0x3c866a==='boolean')return String(_0x3c866a);return undefined;}function scalarToBoolean(_0x35e507){const _0x26471f=a92_0x28873f;if(typeof _0x35e507==='boolean')return _0x35e507;if(typeof _0x35e507===_0x26471f(0xdc))return cleanBoolean(_0x35e507);return undefined;}function cleanBoolean(_0x2f0278){const _0x3a6eb6=a92_0x28873f,_0x355931=_0x2f0278[_0x3a6eb6(0xde)]()[_0x3a6eb6(0xdf)]();if(_0x355931===_0x3a6eb6(0xc8))return!![];if(_0x355931===_0x3a6eb6(0xc6))return![];return undefined;}function issue(_0x5d7817,_0x1a2306,_0x1b9c9c,_0xa43889,_0x3f734b,_0x412ccc){return{'level':_0x5d7817,'ruleId':_0x1a2306,'file':_0x1b9c9c,'section':_0x412ccc,'message':_0xa43889,'suggestion':_0x3f734b};}function a92_0x5830(){const _0x16f2c2=['11642cMFZpr','service','description','3458860EQxcif','Add\x20SKILL.md\x20as\x20a\x20regular\x20file\x20at\x20the\x20Skill\x20directory\x20root.','map','metadata.internal=true\x20Skills\x20cannot\x20be\x20uploaded.','displayName','auth','section','54AwEPPL','9gwdXIZ','Missing\x20SKILL.md.','structure-complete','level','Add\x20frontmatter\x20with\x20name\x20and\x20description.','write','Frontmatter\x20name\x20is\x20missing.','slice','Set\x20name\x20to\x20the\x20Skill\x20directory\x20code.','false','dataset','true','project','This\x20line\x20invokes\x20the\x20rabetbase\x20CLI.\x20rabetbase\x20is\x20a\x20dev-time\x20tool;\x20runtime\x20Skills\x20should\x20drive\x20runtime\x20work\x20through\x20lovrabet\x20commands.','display-name-recommended','config','Frontmatter\x20displayName\x20is\x20missing.','name','920488GBtyfq','flatMap','\x20Fix:\x20','workspace','Remove\x20metadata.internal\x20or\x20set\x20it\x20to\x20false\x20before\x20running\x20skill\x20push.','1132988sBwlYo','Set\x20example\x20to\x20one\x20short\x20user\x20message\x20that\x20can\x20directly\x20trigger\x20this\x20Skill.','path','1377505jNZJmy','sql','SKILL.md','data','rabetbase-cli-reference','string','page','trim','toLowerCase','split','filter','metadata.type\x20must\x20be\x20one\x20of\x20write\x20or\x20read.','line','match','15466524liVFjm','validation','hasFrontmatter','errors','push','join','11ojIWdn','3284694zDYTuf','type','raw','Fix\x20the\x20Skill\x20metadata\x20before\x20running\x20skill\x20push.','warning','Frontmatter\x20description\x20is\x20empty.','Frontmatter\x20example\x20is\x20missing.','object','content','isSymbolicLink','suggestion','SKILL.md\x20must\x20be\x20a\x20regular\x20file.','has','isArray','internal','description-required','schema','example','example-recommended','registry','bff','If\x20this\x20is\x20a\x20runtime\x20step,\x20replace\x20it\x20with\x20the\x20equivalent\x20lovrabet\x20command.\x20Dev-time\x20discovery\x20or\x20handoff\x20notes\x20can\x20stay.','SKILL.md\x20must\x20start\x20with\x20frontmatter.','isDirectory','logs','error','7Ckbtja','Describe\x20when\x20the\x20model\x20should\x20trigger\x20this\x20Skill,\x20plus\x20out-of-scope\x20boundaries\x20and\x20keywords.','frontmatter-required','Replace\x20the\x20symlink\x20with\x20a\x20regular\x20SKILL.md\x20file\x20inside\x20the\x20Skill\x20directory.','ruleId','file','6ZaGDZr','Set\x20metadata.type\x20to\x20write\x20or\x20read.','Skill\x20validation\x20failed:\x0a','read','Skill\x20directory\x20not\x20found:\x20','artifact','app','Set\x20displayName\x20to\x20the\x20human-readable\x20Skill\x20name\x20shown\x20in\x20SkillHub.','test'];a92_0x5830=function(){return _0x16f2c2;};return a92_0x5830();}
|
|
1
|
+
import{existsSync,lstatSync,readFileSync,realpathSync}from"node:fs";import{resolve}from"node:path";import{parse as parseYaml}from"yaml";import{CliErrors}from"../../errors.js";import{fileText,scanSkillDirectory}from"../../skills/runtime-skill-sync/local-files.js";const SKILL_FILE="SKILL.md";const SUPPORTED_SKILL_TYPES=new Set(["write","read"]);const TEXT_SKILL_FILE_PATTERN=/(?:^SKILL\.md$|\.(?:md|mdx|txt|json|ya?ml|js|mjs|cjs|ts|tsx|sh|sql))$/i;export function validateSkillDirectory(dir,_options={}){const root=resolveSkillDirectoryRoot(dir);const issues=[];const skillFile=loadRequiredSkillFile(root,issues);const parsed=skillFile?parseFrontmatter(skillFile.content):{hasFrontmatter:false};if(skillFile){validateFrontmatter(skillFile.path,parsed,issues)}validateRuntimeCliReferences(root,issues);const errors=issues.filter(item=>item.level==="error");const warnings=issues.filter(item=>item.level==="warning");return{ok:errors.length===0,dir:root,type:parsed.type,errors:errors,warnings:warnings
|
|
2
|
+
}}function resolveSkillDirectoryRoot(dir){const root=resolve(dir);if(!existsSync(root)){throw CliErrors.validation(`Skill directory not found: ${dir}`)}const stat=lstatSync(root);if(stat.isDirectory()){return root}if(stat.isSymbolicLink()){const realRoot=realpathSync(root);if(lstatSync(realRoot).isDirectory()){return realRoot}}throw CliErrors.validation(`Skill directory not found: ${dir}`)}export function throwIfSkillValidationFailed(report,_strict=false){if(report.ok)return;const lines=report.errors.map(item=>{const section=item.section?`#${item.section}`:"";return`${item.level.toUpperCase()} ${item.ruleId} ${item.file}${section}: ${item.message} Fix: ${item.suggestion}`});throw CliErrors.validation(`Skill validation failed:\n${lines.join("\n")}`,"Fix the Skill metadata before running skill push.")}function loadRequiredSkillFile(root,issues){const absolutePath=resolve(root,SKILL_FILE);if(!existsSync(absolutePath)){
|
|
3
|
+
issues.push(issue("error","structure-complete",SKILL_FILE,"Missing SKILL.md.","Add SKILL.md at the Skill directory root."));return undefined}const stat=lstatSync(absolutePath);if(stat.isSymbolicLink()){issues.push(issue("error","structure-complete",SKILL_FILE,"SKILL.md must be a regular file.","Replace the symlink with a regular SKILL.md file inside the Skill directory."));return undefined}if(!stat.isFile()){issues.push(issue("error","structure-complete",SKILL_FILE,"SKILL.md is not a file.","Add SKILL.md as a regular file at the Skill directory root."));return undefined}return{path:SKILL_FILE,content:readFileSync(absolutePath,"utf8")}}function validateFrontmatter(file,parsed,issues){if(!parsed.hasFrontmatter){issues.push(issue("error","frontmatter-required",file,"SKILL.md must start with frontmatter.","Add frontmatter with name and description."));return}if(!parsed.name?.trim()){
|
|
4
|
+
issues.push(issue("error","frontmatter-required",file,"Frontmatter name is missing.","Set name to the Skill directory code."))}if(!parsed.displayName?.trim()){issues.push(issue("warning","display-name-recommended",file,"Frontmatter displayName is missing.","Set displayName to the human-readable Skill name shown in SkillHub."))}if(!parsed.example?.trim()){issues.push(issue("warning","example-recommended",file,"Frontmatter example is missing.","Set example to one short user message that can directly trigger this Skill."))}if(!parsed.description?.trim()){issues.push(issue("error","description-required",file,"Frontmatter description is empty.","Describe when the model should trigger this Skill, plus out-of-scope boundaries and keywords."))}if(parsed.internal===true){issues.push(issue("error","internal-skill",file,"metadata.internal=true Skills cannot be uploaded.","Remove metadata.internal or set it to false before running skill push."))}
|
|
5
|
+
if(parsed.type?.trim()&&!SUPPORTED_SKILL_TYPES.has(parsed.type)){issues.push(issue("error","frontmatter-required",file,"metadata.type must be one of write or read.","Set metadata.type to write or read."))}}function validateRuntimeCliReferences(root,issues){for(const finding of findRabetbaseCliInvocations(root)){issues.push(issue("warning","rabetbase-cli-reference",finding.file,"This line invokes the rabetbase CLI. rabetbase is a dev-time tool; runtime Skills should drive runtime work through lovrabet commands.","If this is a runtime step, replace it with the equivalent lovrabet command. Dev-time discovery or handoff notes can stay.",`L${finding.line}`))}}function findRabetbaseCliInvocations(dir){return scanSkillDirectory(dir).filter(file=>TEXT_SKILL_FILE_PATTERN.test(file.path)).flatMap(file=>{const text=fileText(file);return text.split(/\r?\n/).map((line,index)=>({file:file.path,line:index+1,text:line
|
|
6
|
+
})).filter(({text:text})=>isRabetbaseCliInvocation(text)).map(({file:file,line:line})=>({file:file,line:line}))})}const RABETBASE_SUBCOMMANDS=["dataset","sql","bff","page","project","app","schema","service","artifact","kb","config","workspace","data","auth","logs","registry"];const RABETBASE_INVOCATION=new RegExp(String.raw`\brabetbase\s+(?:${RABETBASE_SUBCOMMANDS.join("|")})\b`+String.raw`(?:\s+[a-z][\w-]*){0,2}\s+(?:--?[a-z]|[\w.-]+=)`,"i");function isRabetbaseCliInvocation(line){const start=line.search(/\brabetbase\b/i);if(start<0)return false;const scoped=line.slice(start).split(/\blovrabet\b/i)[0]??"";return RABETBASE_INVOCATION.test(scoped)}function parseFrontmatter(content){const match=content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);if(!match)return{hasFrontmatter:false};const yaml=match[1]??"";const parsed={hasFrontmatter:true};let value;try{value=parseYaml(yaml)}catch{return parsed}const frontmatter=asRecord(value);if(!frontmatter)return parsed
|
|
7
|
+
;parsed.name=scalarToString(frontmatter.name);parsed.displayName=scalarToString(frontmatter.displayName);parsed.description=scalarToString(frontmatter.description);parsed.example=scalarToString(frontmatter.example);const metadata=asRecord(frontmatter.metadata);if(metadata){parsed.type=scalarToString(metadata.type);parsed.internal=scalarToBoolean(metadata.internal)}return parsed}function asRecord(value){if(value&&typeof value==="object"&&!Array.isArray(value)){return value}return undefined}function scalarToString(value){if(typeof value==="string")return value.trim();if(typeof value==="number"||typeof value==="boolean")return String(value);return undefined}function scalarToBoolean(value){if(typeof value==="boolean")return value;if(typeof value==="string")return cleanBoolean(value);return undefined}function cleanBoolean(value){const cleaned=value.trim().toLowerCase();if(cleaned==="true")return true;if(cleaned==="false")return false;return undefined}
|
|
8
|
+
function issue(level,ruleId,file,message,suggestion,section){return{level:level,ruleId:ruleId,file:file,section:section,message:message,suggestion:suggestion}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{getSqlQueryInfo}from"../../core/api-client.js";import{getDbName}from"../../core/db-resolver.js";import{SQLCODE_FLAG,VERBOSE_FLAG}from"../../commands/common/flags.js";export const sqlDetail={service:"sql",command:"detail",description:"Get custom SQL query details by sqlCode",risk:"read",flags:[SQLCODE_FLAG,VERBOSE_FLAG],async execute(ctx){const sql=await getSqlQueryInfo(ctx.appCode,ctx.str("sqlcode"));const verbose=ctx.bool("verbose");if(verbose){return{ok:true,data:sql}}const dbName=sql.dbId?await getDbName(ctx.appCode,sql.dbId):undefined;return{ok:true,data:{sqlCode:sql.sqlCode,sqlName:sql.sqlName,db:dbName?`${dbName} (${sql.dbId})`:sql.dbId??"",sqlContent:sql.sqlContent??""}}}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{executeSdkSql}from"../../core/sdk-client.js";import{SQLCODE_FLAG,PARAMS_FLAG}from"../../commands/common/flags.js";import{parseJsonParams}from"../../utils/params.js";import{CliErrors}from"../../errors.js";export const sqlExec={service:"sql",command:"exec",description:"Execute a custom SQL query by sqlCode",risk:"read",flags:[SQLCODE_FLAG,PARAMS_FLAG],async execute(ctx){const params=parseJsonParams(ctx.str("params"));const startTime=Date.now();const result=await executeSdkSql(ctx.str("sqlcode"),params);const elapsed=Date.now()-startTime;if(!result||typeof result!=="object"||Array.isArray(result)||typeof result.execSuccess!=="boolean"){throw CliErrors.apiError("Invalid SQL execution response: execSuccess must be a boolean.")}if(!result.execSuccess){return{ok:false,data:{error:"SQL execution failed",elapsed:elapsed},message:"SQL execution failed"}}const rows=Array.isArray(result.execResult)?result.execResult:[];return{ok:true,data:{rows:rows,rowCount:rows.length,elapsed:elapsed},
|
|
2
|
+
message:`Returned ${rows.length} row(s) in ${elapsed}ms`}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{sqlDetail}from"../../commands/sql/detail.js";import{sqlExec}from"../../commands/sql/exec.js";export const sqlDefinitions=[sqlDetail,sqlExec];
|
package/lib/commands/update.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The runtime CLI intentionally checks npm dist-tags directly and does not use
|
|
5
5
|
* a CDN policy file. The npm package owns its Built-in Skill installation;
|
|
6
|
-
* this command repairs the current package or
|
|
6
|
+
* this command repairs the current package or explicitly installs from the new one.
|
|
7
7
|
*/
|
|
8
8
|
import type { CommandDefinition } from "../framework/types.js";
|
|
9
9
|
/**
|
|
@@ -16,6 +16,7 @@ import type { CommandDefinition } from "../framework/types.js";
|
|
|
16
16
|
export declare function installCliPackage(version: string, nonInteractive: boolean, currentCliPrefix?: string | null): {
|
|
17
17
|
ok: boolean;
|
|
18
18
|
error?: string;
|
|
19
|
+
prefix?: string;
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
22
|
* Resolves the npm prefix that owns the running CLI package.
|
package/lib/commands/update.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
const a96_0x1b8d00=a96_0xe3ab;(function(_0x4d7291,_0x51bda4){const _0x1ee625=a96_0xe3ab,_0xde5927=_0x4d7291();while(!![]){try{const _0x581d8d=parseInt(_0x1ee625(0x16e))/0x1+-parseInt(_0x1ee625(0x169))/0x2+-parseInt(_0x1ee625(0x15c))/0x3*(-parseInt(_0x1ee625(0x17a))/0x4)+-parseInt(_0x1ee625(0x19c))/0x5*(-parseInt(_0x1ee625(0x157))/0x6)+-parseInt(_0x1ee625(0x195))/0x7*(-parseInt(_0x1ee625(0x1ab))/0x8)+-parseInt(_0x1ee625(0x197))/0x9*(parseInt(_0x1ee625(0x1a3))/0xa)+-parseInt(_0x1ee625(0x167))/0xb*(-parseInt(_0x1ee625(0x164))/0xc);if(_0x581d8d===_0x51bda4)break;else _0xde5927['push'](_0xde5927['shift']());}catch(_0xf07263){_0xde5927['push'](_0xde5927['shift']());}}}(a96_0x5396,0x2b36e));import{fileURLToPath}from'node:url';import{basename,dirname,relative,win32}from'node:path';import{execaSync}from'execa';import a96_0x488200 from'semver';import{CliErrors}from'../errors.js';import{CLI_BIN_NAME}from'../constant/cli.js';import{LOVRABET_NPM_PACKAGE_NAME,NPM_REGISTRY_BASE_URL}from'../constant/distribution.js';import{getCliVersion}from'../utils/version.js';import{inspectInstalledBuiltinSkillVersion,installBuiltinSkill}from'../skills/builtin-skill.js';const updateFlags=[{'name':'latest','type':a96_0x1b8d00(0x199),'description':a96_0x1b8d00(0x18e),'default':![]},{'name':a96_0x1b8d00(0x196),'type':'boolean','description':a96_0x1b8d00(0x1a9),'default':![]},{'name':'version','type':a96_0x1b8d00(0x19a),'description':a96_0x1b8d00(0x18b)}];function getRequestedVersion(_0x442d4c){const _0x458491=a96_0x1b8d00,_0x54fdc5=_0x442d4c['str'](_0x458491(0x180))['trim']();if(_0x54fdc5)return _0x54fdc5;return String(_0x442d4c[_0x458491(0x1a1)]?.[0x0]??'')['trim']();}function a96_0xe3ab(_0x4ea82e,_0x13c2fb){_0x4ea82e=_0x4ea82e-0x148;const _0x5396eb=a96_0x5396();let _0xe3abdb=_0x5396eb[_0x4ea82e];return _0xe3abdb;}async function validateUpdateFlags(_0x4551ca){const _0x57c8b0=a96_0x1b8d00,_0x3e7c11=getRequestedVersion(_0x4551ca),_0x475811=[_0x4551ca[_0x57c8b0(0x177)](_0x57c8b0(0x179))?_0x57c8b0(0x179):'',_0x4551ca[_0x57c8b0(0x177)](_0x57c8b0(0x196))?_0x57c8b0(0x196):'',_0x3e7c11?'version':''][_0x57c8b0(0x18d)](Boolean);if(_0x475811[_0x57c8b0(0x160)]>0x1)throw CliErrors[_0x57c8b0(0x189)]('--latest,\x20--beta,\x20and\x20version\x20cannot\x20be\x20used\x20together.','Choose\x20exactly\x20one\x20target:\x20--latest,\x20--beta,\x20or\x20--version\x20<version>.');if(_0x3e7c11&&!a96_0x488200[_0x57c8b0(0x163)](_0x3e7c11))throw CliErrors[_0x57c8b0(0x189)]('Invalid\x20version:\x20'+_0x3e7c11,'Use\x20a\x20full\x20semver\x20such\x20as\x202.0.6\x20or\x202.0.7-beta.1.');}async function fetchNpmDistTags(){const _0x1d9faa=a96_0x1b8d00;try{const _0x3426aa=NPM_REGISTRY_BASE_URL+_0x1d9faa(0x16c)+encodeURIComponent(LOVRABET_NPM_PACKAGE_NAME)+_0x1d9faa(0x1a0),_0xa0e082=await fetch(_0x3426aa,{'signal':AbortSignal[_0x1d9faa(0x18c)](0x2710)});if(!_0xa0e082['ok'])return null;const _0x13e781=await _0xa0e082[_0x1d9faa(0x190)]();if(!_0x13e781||typeof _0x13e781!==_0x1d9faa(0x19d))return null;return Object['fromEntries'](Object[_0x1d9faa(0x1aa)](_0x13e781)[_0x1d9faa(0x18d)](([,_0x65bbee])=>typeof _0x65bbee==='string'&&_0x65bbee[_0x1d9faa(0x166)]())[_0x1d9faa(0x16b)](([_0x170e67,_0x231919])=>[_0x170e67,String(_0x231919)[_0x1d9faa(0x166)]()]));}catch{return null;}}async function resolveTargetVersion(_0x3bba37){const _0x45a5e2=a96_0x1b8d00,_0x2984a3=getRequestedVersion(_0x3bba37);if(_0x2984a3)return{'version':_0x2984a3,'source':_0x45a5e2(0x180)};const _0xb489f5=_0x3bba37['bool'](_0x45a5e2(0x196))?_0x45a5e2(0x196):'latest',_0x43aea2=await fetchNpmDistTags(),_0x53bf50=_0x43aea2?.[_0xb489f5];if(!_0x53bf50)return null;return{'version':_0x53bf50,'source':_0xb489f5};}function shouldInstallTarget(_0x3882ab,_0x2855f5){const _0x14488c=a96_0x1b8d00;if(_0x2855f5[_0x14488c(0x176)]===_0x14488c(0x180)||_0x2855f5['source']===_0x14488c(0x196))return!a96_0x488200['eq'](_0x3882ab,_0x2855f5[_0x14488c(0x180)]);return a96_0x488200['lt'](_0x3882ab,_0x2855f5['version']);}export function installCliPackage(_0x3764e4,_0x3e5dcb,_0x202e18=resolveCurrentCliNpmPrefix()){const _0x428de9=a96_0x1b8d00,_0x1181ee=LOVRABET_NPM_PACKAGE_NAME+'@'+_0x3764e4,_0x3e81e5=['install','-g',_0x1181ee],_0x507c68=runNpmInstall(_0x3e81e5,_0x3e5dcb);if(_0x507c68['ok']||!isNpmPrefixPermissionError(_0x507c68[_0x428de9(0x15a)]))return _0x507c68;if(!_0x202e18||_0x507c68[_0x428de9(0x15a)]?.['toLowerCase']()[_0x428de9(0x15d)](_0x202e18[_0x428de9(0x16f)]()))return _0x507c68;return console[_0x428de9(0x171)](_0x428de9(0x178)+_0x202e18),runNpmInstall([..._0x3e81e5,_0x428de9(0x161),_0x202e18],_0x3e5dcb);}export function resolveCurrentCliNpmPrefix(_0x13f067=fileURLToPath(import.meta.url),_0x509852=process[a96_0x1b8d00(0x16a)]){const _0x5a2f78=a96_0x1b8d00,_0x3ce4f7=_0x509852===_0x5a2f78(0x1a2)?win32:{'basename':basename,'dirname':dirname,'relative':relative},_0x336b40=_0x3ce4f7[_0x5a2f78(0x18f)](_0x3ce4f7[_0x5a2f78(0x18f)](_0x3ce4f7[_0x5a2f78(0x18f)](_0x13f067))),_0x2f9178=_0x509852==='win32'?_0x5a2f78(0x154):_0x5a2f78(0x15b);let _0x30eaac=_0x3ce4f7[_0x5a2f78(0x18f)](_0x336b40);while(!![]){if(_0x3ce4f7[_0x5a2f78(0x15e)](_0x30eaac)===_0x5a2f78(0x1a6)&&_0x3ce4f7[_0x5a2f78(0x14c)](_0x30eaac,_0x336b40)===_0x2f9178){const _0x541697=_0x3ce4f7[_0x5a2f78(0x18f)](_0x30eaac);return _0x3ce4f7[_0x5a2f78(0x15e)](_0x541697)===_0x5a2f78(0x173)?_0x3ce4f7['dirname'](_0x541697):_0x541697;}const _0x5c7a0d=_0x3ce4f7[_0x5a2f78(0x18f)](_0x30eaac);if(_0x5c7a0d===_0x30eaac)return null;_0x30eaac=_0x5c7a0d;}}function runNpmInstall(_0x5593c2,_0x130978){const _0x126583=a96_0x1b8d00;console[_0x126583(0x151)]('*\x20'+[_0x126583(0x17d),..._0x5593c2][_0x126583(0x14e)]('\x20'));const _0xeb5928=execaSync(_0x126583(0x17d),_0x5593c2,{'cwd':process[_0x126583(0x15f)](),'stdio':_0x126583(0x1a5),'env':process.env,'extendEnv':![],'shell':![],'reject':![]}),_0x40fa09=_0xeb5928[_0x126583(0x187)]?String(_0xeb5928['stderr'])[_0x126583(0x166)]():'',_0x54ebbf=_0xeb5928[_0x126583(0x191)]?String(_0xeb5928[_0x126583(0x191)])[_0x126583(0x166)]():'';if(!_0x130978){if(_0x54ebbf)process[_0x126583(0x191)]['write'](_0x54ebbf+'\x0a');if(_0x40fa09)process[_0x126583(0x187)]['write'](_0x40fa09+'\x0a');}if(_0xeb5928[_0x126583(0x150)]===0x0)return{'ok':!![]};const _0x21664e=_0x40fa09||_0x54ebbf||_0xeb5928['shortMessage']||'exit\x20'+(_0xeb5928['exitCode']??_0x126583(0x19f));return{'ok':![],'error':_0x21664e};}function isNpmPrefixPermissionError(_0x209396){return Boolean(_0x209396&&/\b(?:EACCES|EPERM)\b/['test'](_0x209396));}function a96_0x5396(){const _0xf242ac=['INSTALL_FAILED','\x20\x20Restart\x20your\x20terminal\x20to\x20use\x20the\x20new\x20version.','Run:\x20npm\x20view\x20',',\x20state\x20','find','stderr','apiError','validation','update','Install\x20a\x20specific\x20CLI\x20version','timeout','filter','Install\x20the\x20version\x20from\x20npm\x20latest\x20dist-tag','dirname','json','stdout','reason','\x20CLI\x20from\x20npm','Checking\x20CLI\x20Built-in\x20Skill...','65219TibowH','beta','2042559MDufTu','\x20dist-tags,\x20then\x20retry.','boolean','string','\x20is\x20current.','885815JVvYMA','object','Update\x20the\x20','unknown','/dist-tags','args','win32','10fEKaXT','Checking\x20npm\x20dist-tags...','pipe','node_modules','current','code','Install\x20the\x20version\x20from\x20npm\x20beta\x20dist-tag','entries','120VGvAYA','skillVersion','Updating\x20','\x20version\x20from\x20npm.','Already\x20on\x20requested\x20version\x20(v','relative','Updated\x20to\x20v','join','Version\x20comparison\x20failed:\x20','exitCode','log','expected\x20','run','@lovrabet\x5clovrabet-cli','repairCommand','state','6LQPWHl','inherit','read','error','@lovrabet/lovrabet-cli','32673OeJoDm','includes','basename','cwd','length','--prefix','nonInteractive','valid','60qPRlyC',',\x20but\x20Built-in\x20Skill\x20verification\x20failed:\x20','trim','33066feHvgO','\x20doctor','565430AEwdjF','platform','map','/-/package/','Unable\x20to\x20resolve\x20','93340fJkOMu','toLowerCase','CLI\x20Built-in\x20Skill\x20repair\x20failed\x20[','warn',']:\x20','lib','\x20\x20CLI\x20Built-in\x20Skill\x20',',\x20found\x20','source','bool','Global\x20npm\x20prefix\x20is\x20not\x20writable;\x20retrying\x20in\x20the\x20current\x20CLI\x20Node\x20environment:\x20','latest','96YQycDF','Already\x20up\x20to\x20date\x20(v','Update\x20failed:\x20','npm','Run:\x20',',\x20then\x20verify\x20with:\x20','version','Run:\x20npm\x20install\x20-g\x20'];a96_0x5396=function(){return _0xf242ac;};return a96_0x5396();}function repairCurrentBuiltinSkill(_0x3564c9){const _0x4b5215=a96_0x1b8d00;console['log'](_0x4b5215(0x194));const _0x236ca7=installBuiltinSkill({'stdio':_0x3564c9?_0x4b5215(0x1a5):_0x4b5215(0x158)});if(_0x236ca7['ok']){console[_0x4b5215(0x151)](_0x4b5215(0x174)+_0x236ca7[_0x4b5215(0x148)]+_0x4b5215(0x19b));return;}throw CliErrors[_0x4b5215(0x188)](_0x4b5215(0x170)+(_0x236ca7[_0x4b5215(0x1a8)]||_0x4b5215(0x182))+_0x4b5215(0x172)+(_0x236ca7[_0x4b5215(0x15a)]||_0x4b5215(0x19f)),_0x4b5215(0x17e)+_0x236ca7[_0x4b5215(0x155)]+',\x20then\x20verify\x20with:\x20'+CLI_BIN_NAME+_0x4b5215(0x168));}function verifyUpdatedBuiltinSkill(_0x2e29e1){const _0x6e0d22=a96_0x1b8d00;console['log'](_0x6e0d22(0x194));const _0x3fb8c6=inspectInstalledBuiltinSkillVersion(_0x2e29e1);if(_0x3fb8c6['state']===_0x6e0d22(0x1a7)){console['log'](_0x6e0d22(0x174)+_0x2e29e1+_0x6e0d22(0x19b));return;}const _0x1938a7=_0x3fb8c6[_0x6e0d22(0x148)]?_0x6e0d22(0x152)+_0x2e29e1+_0x6e0d22(0x175)+_0x3fb8c6[_0x6e0d22(0x148)]:_0x6e0d22(0x152)+_0x2e29e1+_0x6e0d22(0x185)+_0x3fb8c6[_0x6e0d22(0x156)],_0x196735=_0x3fb8c6[_0x6e0d22(0x192)]?_0x1938a7+':\x20'+_0x3fb8c6['reason']:_0x1938a7;throw CliErrors[_0x6e0d22(0x188)]('CLI\x20updated\x20to\x20v'+_0x2e29e1+_0x6e0d22(0x165)+_0x196735,_0x6e0d22(0x17e)+_0x3fb8c6[_0x6e0d22(0x155)]+_0x6e0d22(0x17f)+CLI_BIN_NAME+_0x6e0d22(0x168));}async function execute(_0x21c4b3){const _0x206e22=a96_0x1b8d00;await validateUpdateFlags(_0x21c4b3);const _0x515b54=getCliVersion();console[_0x206e22(0x151)]('Current\x20version:\x20'+_0x515b54),console['log'](_0x206e22(0x1a4));const _0x1ca0bb=await resolveTargetVersion(_0x21c4b3);if(!_0x1ca0bb){const _0x4260cd=_0x21c4b3['bool'](_0x206e22(0x196))?_0x206e22(0x196):_0x206e22(0x179),_0x2c785c=_0x206e22(0x16d)+_0x4260cd+_0x206e22(0x14a);throw CliErrors[_0x206e22(0x188)](_0x2c785c,_0x206e22(0x181)+LOVRABET_NPM_PACKAGE_NAME+'@'+_0x4260cd);}const _0x284cb0=[_0x515b54,_0x1ca0bb[_0x206e22(0x180)]][_0x206e22(0x186)](_0x3cecd2=>!a96_0x488200[_0x206e22(0x163)](_0x3cecd2));if(_0x284cb0){const _0xbf6a23=_0x206e22(0x14f)+_0x284cb0+'.';throw CliErrors['apiError'](_0xbf6a23,_0x206e22(0x184)+LOVRABET_NPM_PACKAGE_NAME+_0x206e22(0x198));}if(!shouldInstallTarget(_0x515b54,_0x1ca0bb)){const _0x174b17=_0x1ca0bb['source']===_0x206e22(0x180)?_0x206e22(0x14b)+_0x1ca0bb[_0x206e22(0x180)]+').':_0x206e22(0x17b)+_0x1ca0bb[_0x206e22(0x180)]+').';return console['log'](_0x174b17),repairCurrentBuiltinSkill(_0x21c4b3[_0x206e22(0x162)]),{'ok':!![]};}console[_0x206e22(0x151)](_0x206e22(0x149)+LOVRABET_NPM_PACKAGE_NAME+':\x20'+_0x515b54+'\x20->\x20'+_0x1ca0bb['version']);const _0x2b0872=installCliPackage(_0x1ca0bb[_0x206e22(0x180)],_0x21c4b3[_0x206e22(0x162)]);if(!_0x2b0872['ok']){const _0x3e5a63=_0x206e22(0x17c)+(_0x2b0872[_0x206e22(0x15a)]||_0x206e22(0x19f));throw CliErrors['apiError'](_0x3e5a63,'Run:\x20npm\x20install\x20-g\x20'+LOVRABET_NPM_PACKAGE_NAME+'@'+_0x1ca0bb['version']);}return console[_0x206e22(0x151)](_0x206e22(0x14d)+_0x1ca0bb[_0x206e22(0x180)]+'.'),console['log'](_0x206e22(0x183)),verifyUpdatedBuiltinSkill(_0x1ca0bb['version']),{'ok':!![]};}export const updateDefinition={'service':a96_0x1b8d00(0x18a),'command':a96_0x1b8d00(0x153),'description':a96_0x1b8d00(0x19e)+CLI_BIN_NAME+a96_0x1b8d00(0x193),'risk':a96_0x1b8d00(0x159),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'flags':updateFlags,'validate':validateUpdateFlags,'execute':execute};
|
|
1
|
+
import{fileURLToPath}from"node:url";import{basename,dirname,relative,win32}from"node:path";import{execa,execaSync}from"execa";import semver from"semver";import{CliErrors}from"../errors.js";import{CLI_BIN_NAME}from"../constant/cli.js";import{LOVRABET_NPM_PACKAGE_NAME}from"../constant/distribution.js";import{getCliVersion}from"../utils/version.js";import{installBuiltinSkill}from"../skills/builtin-skill.js";import{installUpdatedBuiltinSkill}from"../skills/install-updated-skill.js";const updateFlags=[{name:"latest",type:"boolean",description:"Install the version from npm latest dist-tag",default:false},{name:"beta",type:"boolean",description:"Install the version from npm beta dist-tag",default:false},{name:"version",type:"string",description:"Install a specific CLI version"}];function getRequestedVersion(ctx){const flagVersion=ctx.str("version").trim();if(flagVersion)return flagVersion;return String(ctx.args?.[0]??"").trim()}async function validateUpdateFlags(ctx){
|
|
2
|
+
const requestedVersion=getRequestedVersion(ctx);const enabledTargets=[ctx.bool("latest")?"latest":"",ctx.bool("beta")?"beta":"",requestedVersion?"version":""].filter(Boolean);if(enabledTargets.length>1){throw CliErrors.validation("--latest, --beta, and version cannot be used together.","Choose exactly one target: --latest, --beta, or --version <version>.")}if(requestedVersion&&!semver.valid(requestedVersion)){throw CliErrors.validation(`Invalid version: ${requestedVersion}`,"Use a full semver such as 2.0.6 or 2.0.7-beta.1.")}}async function fetchNpmDistTags(){try{const{stdout:stdout}=await execa("npm",["view",LOVRABET_NPM_PACKAGE_NAME,"dist-tags","--json","--global"],{timeout:1e4});const parsed=JSON.parse(stdout);const data=Array.isArray(parsed)&&parsed.length===1?parsed[0]:parsed;if(!data||typeof data!=="object"||Array.isArray(data))return null
|
|
3
|
+
;return Object.fromEntries(Object.entries(data).filter(([,value])=>typeof value==="string"&&value.trim()).map(([key,value])=>[key,String(value).trim()]))}catch{return null}}async function resolveTargetVersion(ctx){const requestedVersion=getRequestedVersion(ctx);if(requestedVersion){return{version:requestedVersion,source:"version"}}const tag=ctx.bool("beta")?"beta":"latest";const tags=await fetchNpmDistTags();const version=tags?.[tag];if(!version)return null;return{version:version,source:tag}}function shouldInstallTarget(currentVersion,target){if(target.source==="version"||target.source==="beta"){return!semver.eq(currentVersion,target.version)}return semver.lt(currentVersion,target.version)}export function installCliPackage(version,nonInteractive,currentCliPrefix=resolveCurrentCliNpmPrefix()){const packageSpec=`${LOVRABET_NPM_PACKAGE_NAME}@${version}`;const args=["install","-g",packageSpec];const install=runNpmInstall(args,nonInteractive)
|
|
4
|
+
;if(install.ok||!isNpmPrefixPermissionError(install.error))return install;if(!currentCliPrefix||install.error?.toLowerCase().includes(currentCliPrefix.toLowerCase())){return install}console.warn(`Global npm prefix is not writable; retrying in the current CLI Node environment: ${currentCliPrefix}`);return{...runNpmInstall([...args,"--prefix",currentCliPrefix],nonInteractive),prefix:currentCliPrefix}}export function resolveCurrentCliNpmPrefix(modulePath=fileURLToPath(import.meta.url),platform=process.platform){const path=platform==="win32"?win32:{basename:basename,dirname:dirname,relative:relative};const packageRoot=path.dirname(path.dirname(path.dirname(modulePath)));const packageRelativePath=platform==="win32"?"@lovrabet\\lovrabet-cli":"@lovrabet/lovrabet-cli";let directory=path.dirname(packageRoot);while(true){if(path.basename(directory)==="node_modules"&&path.relative(directory,packageRoot)===packageRelativePath){const modulesParent=path.dirname(directory)
|
|
5
|
+
;return path.basename(modulesParent)==="lib"?path.dirname(modulesParent):modulesParent}const parent=path.dirname(directory);if(parent===directory)return null;directory=parent}}function runNpmInstall(args,nonInteractive){console.log(`* ${["npm",...args].join(" ")}`);const result=execaSync("npm",args,{cwd:process.cwd(),stdio:"pipe",env:process.env,extendEnv:false,shell:false,reject:false});const stderr=result.stderr?String(result.stderr).trim():"";const stdout=result.stdout?String(result.stdout).trim():"";if(!nonInteractive){if(stdout)process.stdout.write(`${stdout}\n`);if(stderr)process.stderr.write(`${stderr}\n`)}if(result.exitCode===0)return{ok:true};const error=stderr||stdout||result.shortMessage||`exit ${result.exitCode??"unknown"}`;return{ok:false,error:error}}function isNpmPrefixPermissionError(error){return Boolean(error&&/\b(?:EACCES|EPERM)\b/.test(error))}function repairCurrentBuiltinSkill(nonInteractive){console.log("Checking CLI Built-in Skill...")
|
|
6
|
+
;const result=installBuiltinSkill({stdio:nonInteractive?"pipe":"inherit"});if(result.ok){console.log(` CLI Built-in Skill ${result.skillVersion} is current.`);return}throw CliErrors.apiError(`CLI Built-in Skill repair failed [${result.code||"INSTALL_FAILED"}]: ${result.error||"unknown"}`,`Run: ${result.repairCommand}, then verify with: ${CLI_BIN_NAME} doctor`)}async function execute(ctx){await validateUpdateFlags(ctx);const currentVersion=getCliVersion();console.log(`Current version: ${currentVersion}`);console.log("Checking npm dist-tags...");const target=await resolveTargetVersion(ctx);if(!target){const tag=ctx.bool("beta")?"beta":"latest";const message=`Unable to resolve ${tag} version from npm.`;throw CliErrors.apiError(message,`Run: npm install -g ${LOVRABET_NPM_PACKAGE_NAME}@${tag}`)}const invalidVersion=[currentVersion,target.version].find(version=>!semver.valid(version));if(invalidVersion){const message=`Version comparison failed: ${invalidVersion}.`
|
|
7
|
+
;throw CliErrors.apiError(message,`Run: npm view ${LOVRABET_NPM_PACKAGE_NAME} dist-tags, then retry.`)}if(!shouldInstallTarget(currentVersion,target)){const message=target.source==="version"?`Already on requested version (v${target.version}).`:`Already up to date (v${target.version}).`;repairCurrentBuiltinSkill(ctx.nonInteractive);console.log(message);return{ok:true}}console.log(`Updating ${LOVRABET_NPM_PACKAGE_NAME}: ${currentVersion} -> ${target.version}`);const install=installCliPackage(target.version,ctx.nonInteractive);if(!install.ok){const message=`Update failed: ${install.error||"unknown"}`;throw CliErrors.apiError(message,`Run: npm install -g ${LOVRABET_NPM_PACKAGE_NAME}@${target.version}`)}try{installUpdatedBuiltinSkill({version:target.version,packageManager:"npm",packageManagerCommand:"npm",...install.prefix?{prefix:install.prefix}:{}})}catch(error){
|
|
8
|
+
throw CliErrors.apiError(`CLI updated to v${target.version}, but Built-in Skill installation failed: ${error instanceof Error?error.message:String(error)}`,`Run: ${CLI_BIN_NAME} cli-skill install, then verify with: ${CLI_BIN_NAME} doctor`)}console.log(`Updated CLI and Built-in Skill to v${target.version}.`);console.log(" Restart your terminal to use the new version.");return{ok:true}}export const updateDefinition={service:"update",command:"run",description:`Update the ${CLI_BIN_NAME} CLI from npm`,risk:"read",requiresAuth:false,requiresAppCode:false,hasFormat:false,flags:updateFlags,validate:validateUpdateFlags,execute:execute};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{bindExternalUserAccount,USER_ACCOUNT_BIND_PATH}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";const CURRENT_BINDING_WARNING="The current binding is not exposed by the server; before is unavailable.";const SUPPORTED_PROVIDERS=["dingtalk"];function readBindingInput(ctx){const provider=ctx.str("provider").trim().toLowerCase();if(!SUPPORTED_PROVIDERS.includes(provider)){throw CliErrors.validation(`Unsupported provider: ${provider||"(empty)"}.`,`Pass one of: ${SUPPORTED_PROVIDERS.join(", ")}.`)}const accountId=ctx.str("account-id").trim();if(!accountId){throw CliErrors.validation("--account-id cannot be empty.","Pass the external account ID for the selected provider.")}return{provider:provider,accountId:accountId}}function buildBindingData(provider,accountId,dryRun){return{operation:"bind",selector:{provider:provider,accountId:accountId},before:null,after:{provider:provider,accountId:accountId,bound:true},dryRun:dryRun,warnings:[CURRENT_BINDING_WARNING]}}
|
|
2
|
+
export const bindUserAccount={service:"user-account",command:"bind",description:"Bind the current platform user to an external provider account",risk:"write",confirmationDescription:"Binds the platform user of the current AccessKey to the given collaboration-provider account. An existing bind for the same provider may be replaced.",requiresAuth:true,requiresAppCode:false,flags:[{name:"provider",type:"string",required:true,enum:[...SUPPORTED_PROVIDERS],description:"External account provider"},{name:"account-id",type:"string",required:true,description:"External account ID for the selected provider"}],async validate(ctx){readBindingInput(ctx)},async dryRun(ctx){const{provider:provider,accountId:accountId}=readBindingInput(ctx);return{...buildBindingData(provider,accountId,true),method:"POST",url:USER_ACCOUNT_BIND_PATH,body:{provider:provider,accountId:accountId}}},async execute(ctx){const{provider:provider,accountId:accountId}=readBindingInput(ctx)
|
|
3
|
+
;const confirmed=await bindExternalUserAccount(provider,accountId);if(confirmed!==true){throw CliErrors.apiError("External account binding was not confirmed.","Retry with the same --provider and --account-id only after checking the current AccessKey identity.")}return{ok:true,data:buildBindingData(provider,accountId,false),message:"Bound current user to external provider account."}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{bindUserAccount}from"../../commands/user-account/bind.js";export const userAccountDefinitions=[bindUserAccount];
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import{CLI_BIN_NAME}from"../../constant/cli.js";import{DEFAULT_CONFIG_VALUES}from"../../constant/defaults.js";import{RUNTIME_ENV_VALUES}from"../../constant/env.js";import{CliErrors}from"../../errors.js";import{readConfigFile,resolveWriteConfigPath,writeConfigFile}from"../../context.js";import{findAppByName,isRuntimeAccessibleApp,runtimeInaccessibleAppError}from"../../commands/app/eligibility.js";const WORKSPACE_USE_FLAGS=[{name:"app",type:"string",description:"App name to bind as the current workspace default"},{name:"appcode",type:"string",description:"App code to bind directly"},{name:"env",type:"string",description:"Internal development: set and save the workspace environment; normally omit",enum:[...RUNTIME_ENV_VALUES]}];async function executeWorkspaceUse(ctx,command){const appName=ctx.str("app").trim();const appcode=ctx.str("appcode").trim();const envInput=ctx.str("env").trim();const env=resolveWorkspaceEnv(envInput||ctx.envName||DEFAULT_CONFIG_VALUES.env);if(!appName&&!appcode){
|
|
2
|
+
throw CliErrors.validation("Missing workspace app selector.",`Usage: ${CLI_BIN_NAME} workspace ${command} --app <name> or ${CLI_BIN_NAME} workspace ${command} --appcode <code>`)}if(appName&&appcode){throw CliErrors.validation("Conflicting workspace app selectors.","Pass either --app <name> or --appcode <code>, not both.")}const configPath=resolveWriteConfigPath("project");const config=readConfigFile(configPath);assertWorkspaceCommandState(command,config);const resolvedAppcode=appcode||await resolveRemoteAppCode({command:command,appName:appName,env:env,accessKey:ctx.accessKey});writeWorkspaceConfig({command:command,appName:appName,appcode:resolvedAppcode,env:env,shouldWriteEnv:!!envInput,accessKey:ctx.accessKey},configPath,config);return{ok:true,data:{configPath:configPath,app:appName||null,appcode:resolvedAppcode,env:envInput?env:null,accessKeyWritten:false,command:`workspace ${command}`},message:buildWorkspaceMessage(configPath,appName,resolvedAppcode,envInput?env:undefined)}}
|
|
3
|
+
async function resolveRemoteAppCode(input){if(!input.accessKey){throw CliErrors.authRequired(`Resolving --app requires accessKey. Pass --appcode directly, or set accessKey before running ${CLI_BIN_NAME} workspace ${input.command}.`)}const{setActiveAK:setActiveAK}=await(import("../../core/api-client.js"));const{getRemoteAppList:getRemoteAppList}=await(import("../../commands/app/remote-source.js"));setActiveAK(input.accessKey);const remote=await getRemoteAppList({env:input.env,accessKey:input.accessKey,noCache:false});const match=findAppByName(remote.items,input.appName);if(match&&!isRuntimeAccessibleApp(match)){throw runtimeInaccessibleAppError(match,`"${input.appName}"`)}const resolved=match?.appCode?.trim();if(resolved)return resolved;const available=remote.items.map(item=>item.appName).filter(Boolean)
|
|
4
|
+
;const hint=available.length?`Available apps: ${Array.from(new Set(available)).join(", ")}.`:`Run \`${CLI_BIN_NAME} app list --no-cache\` to refresh available apps, or pass --appcode directly.`;throw CliErrors.validation(`App "${input.appName}" not found.`,hint)}function writeWorkspaceConfig(input,configPath,config){if(input.shouldWriteEnv){config.env=input.env}if(input.appName){const apps=isRecord(config.apps)?{...config.apps}:{};const existing=isRecord(apps[input.appName])?apps[input.appName]:{};apps[input.appName]={...existing,appcode:input.appcode};config.apps=apps;config.defaultApp=input.appName;delete config.appcode;delete config.app;return writeAndReturn(configPath,config)}config.appcode=input.appcode;delete config.defaultApp;delete config.app;return writeAndReturn(configPath,config)}function writeAndReturn(configPath,config){writeConfigFile(configPath,config);return configPath}function resolveWorkspaceEnv(value){if(RUNTIME_ENV_VALUES.includes(value)){return value}
|
|
5
|
+
throw CliErrors.validation(`Invalid env "${value}". Allowed: ${RUNTIME_ENV_VALUES.join(", ")}`)}function buildWorkspaceMessage(configPath,appName,appcode,env){const target=appName?`${appName} (${appcode})`:appcode;const envLine=env?`\nEnv: ${env}`:"";return`Workspace configured.\nConfig file: ${configPath}\nDefault app: ${target}${envLine}\nAccessKey: not written`}function isRecord(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)}function hasWorkspaceAppBinding(config){if(typeof config.appcode==="string"&&config.appcode.trim().length>0){return true}if(typeof config.defaultApp!=="string"||!config.defaultApp.trim())return false;if(!isRecord(config.apps))return false;const activeProfile=config.apps[config.defaultApp.trim()];return isRecord(activeProfile)&&typeof activeProfile.appcode==="string"&&activeProfile.appcode.trim().length>0}function assertWorkspaceCommandState(command,config){const initialized=hasWorkspaceAppBinding(config)
|
|
6
|
+
;if(command==="init"&&initialized){throw CliErrors.validation("Workspace app context is already initialized.",`Use \`${CLI_BIN_NAME} workspace use --app <name>\` or \`${CLI_BIN_NAME} workspace use --appcode <code>\` to change it.`)}if(command==="use"&&!initialized){throw CliErrors.validation("Workspace app context is not initialized.",`Run \`${CLI_BIN_NAME} workspace init --app <name>\` or \`${CLI_BIN_NAME} workspace init --appcode <code>\` first.`)}}function makeWorkspaceCommand(command){return{service:"workspace",command:command,description:command==="init"?"Initialize app context for the current working directory when no app is bound yet":"Change the app context already bound to the current working directory",risk:"write",
|
|
7
|
+
confirmationDescription:command==="init"?"Writes Lovrabet project config in the current working directory when no app is bound yet, and sets the selected app as the directory default. AccessKey is not written.":"Updates the app binding already present in the current working directory and sets the selected app as the directory default. AccessKey is not written.",requiresAuth:false,requiresAppCode:false,hasFormat:true,flags:WORKSPACE_USE_FLAGS,async execute(ctx){return executeWorkspaceUse(ctx,command)}}}export const workspaceDefinitions=[makeWorkspaceCommand("init"),makeWorkspaceCommand("use")];
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import{existsSync,readFileSync}from"node:fs";import{isAbsolute,resolve}from"node:path";import{CliErrors}from"../errors.js";import{ENTERPRISE_ROUTING_DOMAIN_FIELDS,ENTERPRISE_ROUTING_KIND,ENTERPRISE_ROUTING_PROTOCOL,REQUIRED_ENTERPRISE_ROUTING_DOMAIN_FIELDS}from"../generated/routing-contract.js";export const DOMAIN_CONFIG_FIELDS=["userDomain","apiDomain","runtimeDomain","skillDomain","kbServiceDomain","harnessDomain"];const DOMAIN_FLAGS={userDomain:"user-domain",apiDomain:"api-domain",runtimeDomain:"runtime-domain",skillDomain:"skill-domain",kbServiceDomain:"kb-service-domain",harnessDomain:"harness-domain"};export const LEGACY_DOMAIN_CONFIG_FIELDS=["host","agentDomain","platformDomain","skillHubDomain","kbDomain"];const ENTERPRISE_TO_LOCAL_FIELD={userDomain:"userDomain",apiDomain:"apiDomain",runtimeDomain:"runtimeDomain",skillDomain:"skillDomain",kbServiceDomain:"kbServiceDomain",harnessDomain:"harnessDomain"};const ROUTING_CONSUMER="lovrabet-cli"
|
|
2
|
+
;export function normalizeDomainOrigin(field,input){if(typeof input!=="string"||!input.trim()){throw CliErrors.validation(`Invalid ${field}: expected a non-empty HTTPS origin.`)}let url;try{url=new URL(input.trim())}catch{throw CliErrors.validation(`Invalid ${field}: "${input}" is not a valid URL.`)}if(url.protocol!=="https:"||url.username||url.password||url.pathname!=="/"&&url.pathname!==""||url.search||url.hash){throw CliErrors.validation(`Invalid ${field}: expected an HTTPS origin without credentials, path, query, or fragment.`,"For internal deployments, terminate TLS at the ingress, reverse proxy, or load balancer; an internal CA is supported.")}return url.origin}export function normalizeRoutingDomainValue(field,input){if(typeof input==="string")return normalizeDomainOrigin(field,input);if(!input||typeof input!=="object"||Array.isArray(input)){throw CliErrors.validation(`Invalid ${field}: expected an HTTPS origin or consumer Domain object.`)}const source=input
|
|
3
|
+
;const resolved=source[ROUTING_CONSUMER]??source.default;if(resolved===undefined){throw CliErrors.validation(`Enterprise ${field} does not provide a Domain for ${ROUTING_CONSUMER} and has no default.`)}return normalizeDomainOrigin(field,resolved)}export function resolveEnterpriseRoutingConfig(input){if(input===undefined)return undefined;if(!input||typeof input!=="object"||Array.isArray(input)){throw CliErrors.validation("Invalid enterprise routing config: expected an object.")}return parseEnterpriseRoutingManifest(input).domains}export function readDomainConfigInput(filePath){const absolutePath=isAbsolute(filePath)?filePath:resolve(process.cwd(),filePath);if(!existsSync(absolutePath)){throw CliErrors.validation(`Domain config file not found: ${absolutePath}`)}let parsed;try{parsed=JSON.parse(readFileSync(absolutePath,"utf8"))}catch{throw CliErrors.validation(`Invalid domain config JSON: ${absolutePath}`)}if(!parsed||typeof parsed!=="object"||Array.isArray(parsed)){
|
|
4
|
+
throw CliErrors.validation("Invalid domain config: expected a JSON object.")}const source=parsed;if("protocol"in source)return parseEnterpriseRoutingManifest(source);const unknown=Object.keys(source).filter(key=>!DOMAIN_CONFIG_FIELDS.includes(key));if(unknown.length>0){throw CliErrors.validation(`Unsupported domain config field(s): ${unknown.join(", ")}`,`Allowed fields: ${DOMAIN_CONFIG_FIELDS.join(", ")}`)}const result={};for(const field of DOMAIN_CONFIG_FIELDS){if(source[field]!==undefined){result[field]=normalizeDomainOrigin(field,source[field])}}if(Object.keys(result).length===0){throw CliErrors.validation("Invalid domain config: provide at least one supported Domain.")}return{mode:"legacy",domains:result}}export function readDomainConfig(filePath){return readDomainConfigInput(filePath).domains}export function resolveDomainConfigInput(ctx){const filePath=(ctx.str("domain-config")||"").trim();const input=filePath?readDomainConfigInput(filePath):{mode:"legacy",domains:{}}
|
|
5
|
+
;const explicitFields=DOMAIN_CONFIG_FIELDS.filter(field=>Boolean((ctx.str(DOMAIN_FLAGS[field])||"").trim()));if(input.mode==="enterprise-v1"&&explicitFields.length>0){throw CliErrors.validation("Enterprise routing manifests cannot be combined with individual Domain flags.","Update the manifest so both CLIs consume the same routing data.")}for(const field of DOMAIN_CONFIG_FIELDS){const value=(ctx.str(DOMAIN_FLAGS[field])||"").trim();if(value)input.domains[field]=normalizeDomainOrigin(field,value)}return input}export function resolveDomainFlags(ctx){return resolveDomainConfigInput(ctx).domains}export function parseEnterpriseRoutingManifest(source){if(source.protocol!==ENTERPRISE_ROUTING_PROTOCOL||source.kind!==ENTERPRISE_ROUTING_KIND){throw CliErrors.validation(`Unsupported routing manifest: expected protocol "${ENTERPRISE_ROUTING_PROTOCOL}" and kind "${ENTERPRISE_ROUTING_KIND}".`)}if(!source.domains||typeof source.domains!=="object"||Array.isArray(source.domains)){
|
|
6
|
+
throw CliErrors.validation("Invalid enterprise routing manifest: domains must be an object.")}const rawDomains=source.domains;const missing=REQUIRED_ENTERPRISE_ROUTING_DOMAIN_FIELDS.filter(field=>rawDomains[field]===undefined);if(missing.length>0){throw CliErrors.validation(`Enterprise routing manifest is missing required Domain(s): ${missing.join(", ")}`)}const manifestDomains={};const domains={};for(const field of ENTERPRISE_ROUTING_DOMAIN_FIELDS){const value=rawDomains[field];if(value===undefined)continue;const normalized=normalizeRoutingDomainValue(field,value);manifestDomains[field]=normalized;const localField=ENTERPRISE_TO_LOCAL_FIELD[field];if(localField){domains[localField]=normalized}}return{mode:"enterprise-v1",domains:domains,manifestDomains:manifestDomains}}
|
package/lib/config/schema.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import{DEFAULT_CONFIG_VALUES}from"../constant/defaults.js";import{RUNTIME_ENV_VALUES}from"../constant/env.js";import{OUTPUT_FORMAT_VALUES}from"../constant/output.js";import{DEFAULT_LOVRABET_REGION,ENABLED_LOVRABET_REGION_VALUES}from"../constant/region.js";export const CONFIG_FIELD_SCHEMAS={routing:{description:"Versioned enterprise routing manifest",topLevel:true},region:{description:"Lovrabet region",topLevel:true,cliSettableTopLevel:true,enumValues:ENABLED_LOVRABET_REGION_VALUES,defaultValue:DEFAULT_LOVRABET_REGION,importable:true},env:{description:"Target environment",topLevel:true,cliSettableTopLevel:true,enumValues:RUNTIME_ENV_VALUES,defaultValue:DEFAULT_CONFIG_VALUES.env,importable:true},format:{description:"Default output format",topLevel:true,cliSettableTopLevel:true,enumValues:OUTPUT_FORMAT_VALUES,defaultValue:DEFAULT_CONFIG_VALUES.format,importable:true},pageSize:{description:"Default page size",topLevel:true,cliSettableTopLevel:true,importable:true},apiDomain:{
|
|
2
|
+
description:"Override API domain",topLevel:true,cliSettableTopLevel:true,importable:true},userDomain:{description:"Override user domain",topLevel:true,cliSettableTopLevel:true,importable:true},runtimeDomain:{description:"Override runtime domain",topLevel:true,cliSettableTopLevel:true,importable:true},skillDomain:{description:"Override SkillHub domain",topLevel:true,cliSettableTopLevel:true,importable:true},kbServiceDomain:{description:"Override KB Service domain",topLevel:true,cliSettableTopLevel:true,importable:true},harnessDomain:{description:"Override Harness domain",topLevel:true,cliSettableTopLevel:true,importable:true},accessKey:{description:"Access key (client-ak auth)",topLevel:true,cliSettableTopLevel:true,importable:true},riskLevel:{description:"Risk level",topLevel:true,defaultValue:DEFAULT_CONFIG_VALUES.riskLevel,importable:true},nativeToolAvailable:{description:"Native Lovrabet tool availability in the current execution host",topLevel:true,defaultValue:false},locale:{
|
|
3
|
+
description:"App locale (not CLI language; reserved for later app use)",topLevel:true,cliSettableTopLevel:true,defaultValue:DEFAULT_CONFIG_VALUES.locale,importable:true}};export const TOP_LEVEL_CONFIG_KEYS=new Set(Object.entries(CONFIG_FIELD_SCHEMAS).filter(([,schema])=>schema.cliSettableTopLevel).map(([key])=>key));export const CLI_PROTECTED_CONFIG_KEYS=new Set(["riskLevel","nativeToolAvailable"]);export const CONFIG_ENUM_VALUES=Object.fromEntries(Object.entries(CONFIG_FIELD_SCHEMAS).filter(([,schema])=>schema.enumValues).map(([key,schema])=>[key,[...schema.enumValues||[]]]));export const IMPORTABLE_RUNTIME_CONFIG_KEYS=Object.entries(CONFIG_FIELD_SCHEMAS).filter(([,schema])=>schema.importable).map(([key])=>key);export function getConfigFieldSchema(key){return CONFIG_FIELD_SCHEMAS[key]}export function getConfigEnumValues(key){return getConfigFieldSchema(key)?.enumValues}export function getConfigDefaultValue(key){return getConfigFieldSchema(key)?.defaultValue}
|
|
4
|
+
export function isTopLevelConfigKey(key){return TOP_LEVEL_CONFIG_KEYS.has(key)}export function isCliProtectedConfigKey(key){return CLI_PROTECTED_CONFIG_KEYS.has(key)}const LOCALE_MAP={zh:"zh-CN","zh-cn":"zh-CN",zh_cn:"zh-CN",en:"en-US","en-us":"en-US",en_us:"en-US"};export function normalizeLocale(value){if(!value)return null;return LOCALE_MAP[value.toLowerCase()]??null}export function isLegacyCompatConfigKey(key){return getConfigFieldSchema(key)?.legacyCompatOnly===true}export function getTopLevelConfigKeyList(){return[...TOP_LEVEL_CONFIG_KEYS]}export function formatConfigKeyList(keys){return[...keys].join(", ")}export function getTopLevelConfigKeySummary(){return formatConfigKeyList(getTopLevelConfigKeyList())}export function getConfigCommandKeyDescription(){return`Config key. Top-level: ${getTopLevelConfigKeySummary()}; local alias: apps.<alias>.appcode`}export function buildAppProfileListFields(fallbackEnv){return{env:fallbackEnv,hasAccessKey:false,format:null,pageSize:null,
|
|
5
|
+
riskLevel:null,locale:null}}
|
package/lib/constant/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export const APP_PUBLISH_STATUS={Published:"PUBLISHED",Unpublished:"UNPUBLISH"};export const RUNTIME_ACCESSIBLE_APP_STATUS=APP_PUBLISH_STATUS.Published;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export const AUTH_MODE={ClientAk:"client-ak"};export function isAuthMode(v){return v===AUTH_MODE.ClientAk}
|
package/lib/constant/cli.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{PRODUCT_CONFIG}from"../constant/product.js";import{LOVRABET_NPM_PACKAGE_NAME}from"../constant/distribution.js";export const CLI_BIN_NAME=PRODUCT_CONFIG.cliBinName;export const CLI_DISPLAY_NAME=PRODUCT_CONFIG.cliDisplayName;export const NPM_PACKAGE_NAME=LOVRABET_NPM_PACKAGE_NAME;export const GLOBAL_FLAGS=[{name:"appcode",meowKey:"appcode",type:"string",description:"Override appcode",hint:"<code>"},{name:"app",meowKey:"app",type:"string",description:"Select app profile by name",hint:"<name>"},{name:"env",meowKey:"env",type:"string",description:"Environment",hint:"production | development | daily"},{name:"format",meowKey:"format",type:"string",description:"Output format",hint:"json | pretty | compress"},{name:"jq",meowKey:"jq",type:"string",description:"Filter JSON output (JQ_PATH > bundled jq > PATH; implies --format json when current format is pretty)",hint:"<expr>"},{name:"dry-run",meowKey:"dryRun",type:"boolean",description:"Preview operation without executing"},{name:"yes",
|
|
2
|
+
meowKey:"yes",type:"boolean",description:"Skip confirmation for high-risk writes"},{name:"non-interactive",meowKey:"nonInteractive",type:"boolean",description:"Force non-interactive mode (CI)"},{name:"global",meowKey:"global",type:"boolean",description:"Use global config scope"},{name:"ci",meowKey:"ci",type:"boolean",description:"Alias for --non-interactive",hidden:true},{name:"help",meowKey:"help",type:"boolean",description:"Show help"},{name:"id",meowKey:"id",type:"string",description:"Record ID",hidden:true},{name:"name",meowKey:"name",type:"string",description:"Name filter",hidden:true},{name:"sqlcode",meowKey:"sqlcode",type:"string",description:"SQL query code",hidden:true},{name:"params",meowKey:"params",type:"string",description:"JSON params for execute commands",hidden:true},{name:"verbose",meowKey:"verbose",type:"boolean",description:"Verbose output",hidden:true},{name:"clear",meowKey:"clear",type:"boolean",description:"Clear output",hidden:true}]
|
|
3
|
+
;export const PIPELINE_FLAG_NAMES=new Set(["appcode","app","env","format","jq","dry-run","yes","non-interactive","ci"]);export function buildMeowFlags(){return Object.fromEntries(GLOBAL_FLAGS.map(f=>[f.meowKey,{type:f.type}]))}
|
package/lib/constant/defaults.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export const DEFAULT_APP_PROFILE_NAME="main";export const DEFAULT_CONFIG_VALUES={env:"production",format:"compress",locale:"en-US",riskLevel:"write"};export const DEFAULT_COMMAND_OUTPUT_FORMAT="compress";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{PRODUCT_CONFIG}from"../constant/product.js";export const LOVRABET_NPM_PACKAGE_NAME=PRODUCT_CONFIG.npmPackageName;export const LOVRABET_SKILL_SOURCE=PRODUCT_CONFIG.skillSource;export const NPM_REGISTRY_BASE_URL=PRODUCT_CONFIG.npmRegistryBaseUrl;export const LOVRABET_CLI_CDN_BASE_URL=PRODUCT_CONFIG.cliCdnBaseUrl;export const LOVRABET_CLI_VERSION_POLICY_URL=`${LOVRABET_CLI_CDN_BASE_URL}/dist/lovrabet-cli/config/index.json`;
|
package/lib/constant/domain.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../errors.js";import{getEnv,isProduction}from"../constant/env.js";import{OFFICIAL_ROUTING_PROFILES}from"../generated/official-routing.js";import{DEFAULT_LOVRABET_REGION}from"../constant/region.js";let customApiDomain;let customUserDomain;let customRuntimeDomain;let customSkillDomain;let customKbServiceDomain;let customHarnessDomain;let activeRegion=DEFAULT_LOVRABET_REGION;export function initDomains(domains){customApiDomain=domains?.apiDomain;customUserDomain=domains?.userDomain;customRuntimeDomain=domains?.runtimeDomain;customSkillDomain=domains?.skillDomain;customKbServiceDomain=domains?.kbServiceDomain;customHarnessDomain=domains?.harnessDomain;activeRegion=domains?.region??DEFAULT_LOVRABET_REGION}const getActiveRegionDomains=()=>{const domains=OFFICIAL_ROUTING_PROFILES[activeRegion].serviceDomains;return isProduction(getEnv())?domains.production:"daily"in domains?domains.daily:domains.production}
|
|
2
|
+
;export const getUserDomain=()=>customUserDomain||getActiveRegionDomains().user;export const getApiDomain=()=>customApiDomain||getActiveRegionDomains().api;export const getRuntimeDomain=()=>customRuntimeDomain||getActiveRegionDomains().runtime;export const getSkillDomain=()=>customSkillDomain||getActiveRegionDomains().skill;export const getKbServiceDomain=()=>{if(customKbServiceDomain)return customKbServiceDomain;const domains=getActiveRegionDomains();return"kbService"in domains?domains.kbService:undefined};export const getHarnessDomain=()=>{if(customHarnessDomain)return customHarnessDomain;const domains=getActiveRegionDomains();return"harness"in domains?domains.harness:undefined};export function requireHarnessDomain(){const domain=getHarnessDomain();if(!domain){throw CliErrors.validation("Harness is not configured.","Configure a trusted harnessDomain HTTPS origin in the connection settings.")}return domain}
|