@lovrabet/lovrabet-cli 2.3.12 → 2.4.0-beta.1
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 +39 -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.d.ts +8 -0
- package/lib/commands/metric/contract.js +5 -0
- package/lib/commands/metric/definition.d.ts +35 -0
- package/lib/commands/metric/definition.js +4 -0
- package/lib/commands/metric/detail.d.ts +2 -0
- package/lib/commands/metric/detail.js +1 -0
- package/lib/commands/metric/exec.d.ts +2 -0
- package/lib/commands/metric/exec.js +3 -0
- package/lib/commands/metric/index.d.ts +1 -0
- package/lib/commands/metric/index.js +1 -0
- package/lib/commands/metric/list.d.ts +2 -0
- package/lib/commands/metric/list.js +2 -0
- package/lib/commands/metric/shared.d.ts +17 -0
- package/lib/commands/metric/shared.js +2 -0
- 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.d.ts +4 -0
- 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 +9 -8
- package/skills/lovrabet/SKILL.md +14 -6
- package/skills/lovrabet/guides/app-resolution.md +2 -0
- package/skills/lovrabet/guides/dataset-and-data-workflow.md +2 -0
- package/skills/lovrabet/guides/development-intent-handoff.md +19 -3
- package/skills/lovrabet/guides/metric-consumption.md +134 -0
- package/skills/lovrabet/guides/sql-and-bff-workflow.md +2 -0
- package/skills/lovrabet/references/lovrabet-auth.md +4 -0
- package/skills/lovrabet/references/lovrabet-schedule-workflow.md +16 -0
- package/skills/lovrabet/references/lovrabet-skill-authoring.md +27 -0
- 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 +28 -0
- package/skills/lovrabet-report-generation/references/business-skill-reuse.md +19 -0
- package/skills/lovrabet-report-generation/references/quality-checks.md +16 -0
- package/skills/lovrabet-report-generation/references/report-workflow.md +42 -0
- package/skills/lovrabet-report-generation/templates/report-outline.md +10 -0
- package/skills/lovrabet.manifest.json +4 -3
- package/lib/postinstall.d.ts +0 -2
- package/lib/postinstall.js +0 -1
- package/scripts/postinstall.mjs +0 -24
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Global Skill install-state resolution, decoupled from the external `skills` CLI.
|
|
3
|
-
*
|
|
4
|
-
* Only reasonably trustworthy signals are used, and "confirmed missing" is kept
|
|
5
|
-
* distinct from "cannot tell":
|
|
6
|
-
* - artifact probe: `<globalSkillsDir>/<name>/SKILL.md`, what consumers actually resolve
|
|
7
|
-
* - install bookkeeping: the `skills` CLI's own `~/.agents/.skill-lock.json`
|
|
8
|
-
*
|
|
9
|
-
* Directory layout is owned by the external tool, so a stale layout assumption must
|
|
10
|
-
* resolve to `unverifiable` (pass through with a reason) rather than `absent` (fail).
|
|
11
|
-
* Only when both the artifact probe and the bookkeeping agree is the skill `absent`.
|
|
12
|
-
*/
|
|
13
|
-
/** Install bookkeeping file written by the `skills` CLI, relative to HOME. */
|
|
14
|
-
export declare const SKILL_LOCK_RELATIVE_PATH: string;
|
|
15
|
-
/** Known global Skill directories, relative to HOME, in probe order. */
|
|
16
|
-
export declare const GLOBAL_SKILLS_DIR_RELATIVE_PATHS: string[];
|
|
17
|
-
/**
|
|
18
|
-
* Install state of a global Skill.
|
|
19
|
-
*
|
|
20
|
-
* `unverifiable` is deliberate: local assumptions were not sufficient to decide, so
|
|
21
|
-
* callers should pass through instead of failing.
|
|
22
|
-
*/
|
|
23
1
|
export type SkillPresence = {
|
|
24
2
|
state: "present";
|
|
25
3
|
path: string;
|
|
@@ -31,18 +9,7 @@ export type SkillPresence = {
|
|
|
31
9
|
reason: string;
|
|
32
10
|
};
|
|
33
11
|
export interface ResolveSkillPresenceOptions {
|
|
34
|
-
/** Override
|
|
35
|
-
globalSkillsDirs?: string[];
|
|
36
|
-
/** Override the `skills` CLI bookkeeping file path. */
|
|
37
|
-
lockFile?: string;
|
|
38
|
-
/** Override HOME. Tests only. */
|
|
12
|
+
/** Override the user home for isolated verification only. */
|
|
39
13
|
home?: string;
|
|
40
14
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Resolves whether a global Skill is currently discoverable by consumers.
|
|
43
|
-
*
|
|
44
|
-
* @param skillName - Global Skill name (its directory name), e.g. `lovrabet`.
|
|
45
|
-
* @param options - Probe overrides for isolated environments or tests.
|
|
46
|
-
* @returns `present`, `absent`, or `unverifiable`.
|
|
47
|
-
*/
|
|
48
15
|
export declare function resolveInstalledSkill(skillName: string, options?: ResolveSkillPresenceOptions): SkillPresence;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{spawnSync}from"node:child_process";import{isAbsolute,join}from"node:path";import{resolveLocalSkillsInstaller}from"../skills/local-skills-installer.js";export function resolveInstalledSkill(skillName,options){try{const env={...process.env,DISABLE_TELEMETRY:"1",DO_NOT_TRACK:"1",...options?.home?{HOME:options.home,USERPROFILE:options.home}:{}};const result=spawnSync(process.execPath,[resolveLocalSkillsInstaller(),"list","-g","--json"],{env:env,encoding:"utf8",shell:false,timeout:3e4,maxBuffer:16*1024*1024});if(result.error||result.status!==0){throw new Error(result.error?.message||result.stderr?.trim()||"Skills CLI listing failed")}const rows=JSON.parse(result.stdout);if(!Array.isArray(rows)||rows.some(row=>!row||typeof row.name!=="string"||row.scope!=="global")){throw new Error("Unsupported Skills CLI listing response")}const matches=rows.filter(row=>row.name===skillName);if(matches.length===0||matches.every(row=>row.status==="missing"&&row.path===null)){return{state:"absent",
|
|
2
|
+
checked:[]}}if(matches.some(row=>!["tracked","untracked","modified"].includes(row.status)||typeof row.path!=="string"||!isAbsolute(row.path))){throw new Error(`Skills CLI returned an invalid installation path or status for "${skillName}"`)}const paths=[...new Set(matches.map(row=>row.path))];if(paths.length!==1)throw new Error(`Skills CLI returned multiple installation paths for "${skillName}"`);return{state:"present",path:join(paths[0],"SKILL.md")}}catch(error){return{state:"unverifiable",reason:error instanceof Error?error.message:String(error)}}}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
const
|
|
1
|
+
const REDACTED_ACCESS_KEY="<redacted>";export function maskCliAccessKey(value){if(typeof value!=="string"||value.length<=8){return REDACTED_ACCESS_KEY}return`${value.slice(0,8)}${"*".repeat(value.length-8)}`}export function redactCliConfigCredentials(config){const displayed={...config};if(Object.prototype.hasOwnProperty.call(displayed,"accessKey")){displayed.accessKey=maskCliAccessKey(displayed.accessKey)}if(displayed.apps&&typeof displayed.apps==="object"&&!Array.isArray(displayed.apps)){displayed.apps=redactLegacyAppCredentials(displayed.apps)}return displayed}export function redactCliConfigValue(path,value){if(path==="accessKey"||/^apps\.[^.]+\.accessKey$/.test(path)){return maskCliAccessKey(value)}if(path==="apps"&&value&&typeof value==="object"&&!Array.isArray(value)){return redactLegacyAppCredentials(value)}if(/^apps\.[^.]+$/.test(path)&&value&&typeof value==="object"&&!Array.isArray(value)){const profile=value;return Object.prototype.hasOwnProperty.call(profile,"accessKey")?{
|
|
2
|
+
...profile,accessKey:maskCliAccessKey(profile.accessKey)}:value}return value}function redactLegacyAppCredentials(apps){return Object.fromEntries(Object.entries(apps).map(([alias,profile])=>{if(!profile||typeof profile!=="object"||Array.isArray(profile)){return[alias,profile]}const displayedProfile={...profile};if(Object.prototype.hasOwnProperty.call(displayedProfile,"accessKey")){displayedProfile.accessKey=maskCliAccessKey(displayedProfile.accessKey)}return[alias,displayedProfile]}))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{createJqFilter,resolveBundledJqPaths}from"@lovrabet/cli-framework";import{CliErrors}from"../errors.js";export const applyJqFilter=createJqFilter(CliErrors,{bundledJqPaths:resolveBundledJqPaths()});
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import semver from"semver";import{LOVRABET_NPM_PACKAGE_NAME}from"../constant/distribution.js";import{CliErrors}from"../errors.js";import{getCliVersionPolicy}from"../utils/cli-version-policy.js";import{getCliVersion}from"../utils/version.js";export function evaluateCliVersionPolicy(currentVersion,policy){const currentIsValid=semver.valid(currentVersion)===currentVersion;const stableVersion=policy?.stableVersion??null;const minimumVersion=policy?.minimumVersion??null;const needsUpgrade=Boolean(currentIsValid&&stableVersion&&semver.lt(currentVersion,stableVersion));const belowMinimum=Boolean(currentIsValid&&minimumVersion&&semver.lt(currentVersion,minimumVersion));return{currentVersion:currentVersion,stableVersion:stableVersion,minimumVersion:minimumVersion,needsUpgrade:needsUpgrade||belowMinimum,belowMinimum:belowMinimum,upgradeMessage:policy?.upgradeMessage,minimumVersionMessage:policy?.minimumVersionMessage}}export async function checkCliVersion(){
|
|
2
|
+
return evaluateCliVersionPolicy(getCliVersion(),await getCliVersionPolicy())}export function getCliUpgradeCommand(result){return`npm install -g ${LOVRABET_NPM_PACKAGE_NAME}@${result.stableVersion??"latest"}`}export function assertCliVersionSupported(result){if(!result.belowMinimum)return;const details=[result.minimumVersionMessage,`Current version: ${result.currentVersion}`,`Minimum supported: ${result.minimumVersion}`,`Recommended stable: ${result.stableVersion??"unavailable"}`,`Upgrade command: ${getCliUpgradeCommand(result)}`].filter(Boolean).join("\n");throw CliErrors.validation("Current CLI version is below the minimum supported version.",details)}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import semver from"semver";import{LOVRABET_CLI_VERSION_POLICY_URL}from"../constant/distribution.js";const SUCCESS_CACHE_TTL_MS=5*60*1e3;const FAILURE_CACHE_TTL_MS=60*1e3;const FETCH_TIMEOUT_MS=1500;function pickString(value){return typeof value==="string"&&value.trim()?value.trim():null}function pickStrictSemver(value){const text=pickString(value);return text&&semver.valid(text)===text?text:null}export function normalizeCliVersionPolicy(raw){if(!raw||typeof raw!=="object")return null;const root=raw;const source=root.cli&&typeof root.cli==="object"?root.cli:root;const stableVersion=pickStrictSemver(source.stableVersion??source.latestVersion??source.recommendedVersion);const minimumVersion=pickStrictSemver(source.minimumVersion??source.minVersion);if(!stableVersion&&!minimumVersion)return null;if(stableVersion&&minimumVersion&&semver.gt(minimumVersion,stableVersion)){return null}return{stableVersion:stableVersion,minimumVersion:minimumVersion,
|
|
2
|
+
upgradeMessage:pickString(source.upgradeMessage)??undefined,minimumVersionMessage:pickString(source.minimumVersionMessage)??undefined}}export async function fetchCliVersionPolicy(){try{const response=await fetch(LOVRABET_CLI_VERSION_POLICY_URL,{headers:{Accept:"application/json"},signal:AbortSignal.timeout(FETCH_TIMEOUT_MS)});if(!response.ok)return null;return normalizeCliVersionPolicy(await response.json())}catch{return null}}let cachedPolicy=null;let cachedAt=0;let hasCachedPolicy=false;let pendingPolicy=null;export async function getCliVersionPolicy(){const now=Date.now();if(hasCachedPolicy){const ttl=cachedPolicy?SUCCESS_CACHE_TTL_MS:FAILURE_CACHE_TTL_MS;if(now-cachedAt<ttl)return cachedPolicy}if(pendingPolicy)return pendingPolicy;pendingPolicy=fetchCliVersionPolicy().then(policy=>{cachedPolicy=policy;cachedAt=Date.now();hasCachedPolicy=true;return policy}).finally(()=>{pendingPolicy=null});return pendingPolicy}export function clearCliVersionPolicyCache(){cachedPolicy=null
|
|
3
|
+
;cachedAt=0;hasCachedPolicy=false;pendingPolicy=null}
|
package/lib/utils/logger.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import winston from"winston";import fs from"node:fs";import path from"node:path";import{PRODUCT_CONFIG}from"../constant/product.js";class Logger{winstonLogger;logFilePath="";currentRawCommand="";constructor(){}setRawCommand(rawCommand){this.currentRawCommand=rawCommand}setLogPath(projectPath){this.logFilePath=path.join(projectPath,PRODUCT_CONFIG.logFileName);if(this.winstonLogger){this.winstonLogger.clear()}this.initWinstonLogger()}initWinstonLogger(){const dir=path.dirname(this.logFilePath);if(!fs.existsSync(dir)){fs.mkdirSync(dir,{recursive:true})}const customFormat=winston.format.combine(winston.format.timestamp(),winston.format.errors({stack:true}),winston.format.printf(info=>{const logEntry={timestamp:info.timestamp||(new Date).toISOString(),level:info.level||"info",command:info.command||"unknown",rawCommand:info.rawCommand||this.currentRawCommand||undefined,message:info.message||"",duration:info.duration||undefined,details:info.details||undefined};return JSON.stringify(logEntry)
|
|
2
|
+
}));this.winstonLogger=winston.createLogger({level:"info",format:customFormat,transports:[new winston.transports.File({filename:this.logFilePath,level:"info"})],silent:false});winston.addColors({success:"green",error:"red",warn:"yellow",info:"blue"})}info(command,message,details){if(!this.logFilePath||!this.winstonLogger)return;this.winstonLogger.info(message,{command:command,details:details})}success(command,message,duration,details){if(!this.logFilePath||!this.winstonLogger)return;this.winstonLogger.log("info",message,{level:"success",command:command,duration:duration,details:details})}error(command,message,details){if(!this.logFilePath||!this.winstonLogger)return;this.winstonLogger.error(message,{command:command,details:details})}warn(command,message,details){if(!this.logFilePath||!this.winstonLogger)return;this.winstonLogger.warn(message,{command:command,details:details})}async logTask(command,taskName,task){const startTime=Date.now();this.info(command,`Starting: ${taskName}`);try{
|
|
3
|
+
const result=await task();const duration=Date.now()-startTime;this.success(command,`Completed: ${taskName}`,duration);return result}catch(error){const duration=Date.now()-startTime;this.error(command,`Failed: ${taskName}`,{error:error instanceof Error?error.message:String(error),duration:duration});throw error}}readLogs(){try{if(!fs.existsSync(this.logFilePath)){return[]}const content=fs.readFileSync(this.logFilePath,"utf8");return content.split(/\r?\n/).filter(line=>line.trim()).map(line=>JSON.parse(line))}catch(error){console.warn("Failed to read logs:",error);return[]}}clearLogs(){try{if(fs.existsSync(this.logFilePath)){fs.writeFileSync(this.logFilePath,"","utf8")}}catch(error){console.warn("Failed to clear logs:",error)}}getWinstonInstance(){return this.winstonLogger}}export const logger=new Logger;
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
const
|
|
1
|
+
const JSON_NUMBER_PATTERN=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/;const MAX_SAFE_INTEGER=BigInt(Number.MAX_SAFE_INTEGER);const MIN_SAFE_INTEGER=BigInt(Number.MIN_SAFE_INTEGER);let restoreResponseJsonParser;let responseJsonPrototype;let originalResponseJsonDescriptor;function isUnsafeIntegerLiteral(token){if(token.includes(".")||token.includes("e")||token.includes("E")){return false}const value=BigInt(token);return value>MAX_SAFE_INTEGER||value<MIN_SAFE_INTEGER}function quoteUnsafeIntegerLiterals(text){let output="";let inString=false;let escaped=false;for(let index=0;index<text.length;){const character=text[index];if(inString){output+=character;index+=1;if(escaped){escaped=false}else if(character==="\\"){escaped=true}else if(character==='"'){inString=false}continue}if(character==='"'){inString=true;output+=character;index+=1;continue}if(character==="-"||character>="0"&&character<="9"){const token=JSON_NUMBER_PATTERN.exec(text.slice(index))?.[0];if(token){
|
|
2
|
+
output+=isUnsafeIntegerLiteral(token)?`"${token}"`:token;index+=token.length;continue}}output+=character;index+=1}return output}export function parseLosslessJson(text){return JSON.parse(quoteUnsafeIntegerLiterals(text))}export function installLosslessJsonResponseParser(){if(typeof Response==="undefined")return()=>{};if(restoreResponseJsonParser)return restoreResponseJsonParser;responseJsonPrototype=Response.prototype;originalResponseJsonDescriptor=Object.getOwnPropertyDescriptor(responseJsonPrototype,"json");Object.defineProperty(responseJsonPrototype,"json",{...originalResponseJsonDescriptor??{configurable:true,enumerable:false,writable:true},value:async function losslessJson(){return parseLosslessJson(await this.text())}});restoreResponseJsonParser=()=>{if(!responseJsonPrototype)return;if(originalResponseJsonDescriptor){Object.defineProperty(responseJsonPrototype,"json",originalResponseJsonDescriptor)}else{delete responseJsonPrototype.json}responseJsonPrototype=undefined
|
|
3
|
+
;originalResponseJsonDescriptor=undefined;restoreResponseJsonParser=undefined};return restoreResponseJsonParser}export function restoreLosslessJsonResponseParser(){restoreResponseJsonParser?.()}
|
package/lib/utils/params.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../errors.js";import{parseLosslessJson}from"../utils/lossless-json.js";export const MAX_DATA_UPDATE_IDS=1e3;export function parseJsonParams(paramsStr){if(!paramsStr)return undefined;try{return parseLosslessJson(paramsStr)}catch{throw CliErrors.validation(`Invalid JSON for --params: ${paramsStr}`)}}export function parseJsonParamsValue(paramsStr){if(!paramsStr)return undefined;try{return parseLosslessJson(paramsStr)}catch{throw CliErrors.validation(`Invalid JSON for --params: ${paramsStr}`)}}export function parseBatchCreateItemsFromParams(params){if(Array.isArray(params)){return params}if(params!==null&¶ms!==undefined&&typeof params==="object"&&Array.isArray(params.items)){return params.items}throw CliErrors.validation('batchCreate --params must be a JSON array or {"items":[...]}','Example: --params \'[{"name":"a"},{"name":"b"}]\'')}function parseDataUpdateId(value,label){if(typeof value==="number"&&Number.isSafeInteger(value)&&value>0){return value}
|
|
2
|
+
if(typeof value==="string"){if(/^[1-9]\d*$/.test(value)){return value}}throw CliErrors.validation(`data update --params.${label} must be a positive integer or numeric string.`)}export function parseUpdateIdsFromParams(params){if(params===null||params===undefined||typeof params!=="object"||Array.isArray(params)){throw CliErrors.validation("data update --params must be a JSON object with id.",'Example: --params \'{"id":[1,2,3],"status":"done"}\'')}const id=params.id;if(id===undefined||id===null){throw CliErrors.validation('data update requires "id" in --params.','Example: --params \'{"id":[1,2,3],"status":"done"}\'')}const rawIds=Array.isArray(id)?id:[id];if(rawIds.length===0){throw CliErrors.validation("data update id array cannot be empty.")}if(rawIds.length>MAX_DATA_UPDATE_IDS){throw CliErrors.validation(`data update can update at most ${MAX_DATA_UPDATE_IDS} records per call; received ${rawIds.length}.`)}
|
|
3
|
+
return rawIds.map((value,index)=>parseDataUpdateId(value,Array.isArray(id)?`id[${index}]`:"id"))}export function normalizeUpdateParamsForRuntime(params,ids){if(Array.isArray(params.id)&&ids.length>1){return{...params,id:ids.join(",")}}return params}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export function normalizePositiveSafeInteger(value){if(typeof value==="number"){return Number.isSafeInteger(value)&&value>0?value:undefined}if(typeof value!=="string"||!/^\d+$/.test(value)){return undefined}const normalized=Number(value);return Number.isSafeInteger(normalized)&&normalized>0?normalized:undefined}
|
package/lib/utils/redaction.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
const
|
|
1
|
+
const REDACTED_VALUE="[REDACTED]";const SENSITIVE_KEY_PATTERN=/(?:access.?key|api.?key|authorization|cookie|credential|password|passwd|private.?key|secret|token|webhook)/i;const SENSITIVE_FLAG_NAMES=new Set(["comment","variables"]);const SENSITIVE_VALUE_KEYS=new Set(["comment"]);export function isSensitiveKey(key){const normalized=key.replace(/_/g,"-").toLowerCase();return SENSITIVE_KEY_PATTERN.test(normalized)}export function isSensitiveFlagName(key){const normalized=key.replace(/_/g,"-").toLowerCase();return isSensitiveKey(normalized)||SENSITIVE_FLAG_NAMES.has(normalized)}function redactVariableValues(value){if(Array.isArray(value)){return value.map(item=>redactVariableValues(item))}if(value&&typeof value==="object"){return Object.fromEntries(Object.entries(value).map(([key,item])=>[key,redactVariableValues(item)]))}return REDACTED_VALUE}export function redactSensitiveValue(value){if(Array.isArray(value)){return value.map(item=>redactSensitiveValue(item))}
|
|
2
|
+
if(!value||typeof value!=="object"){return value}const output={};for(const[key,item]of Object.entries(value)){const normalized=key.replace(/_/g,"-").toLowerCase();output[key]=normalized==="variables"?redactVariableValues(item):SENSITIVE_VALUE_KEYS.has(normalized)||isSensitiveKey(key)?REDACTED_VALUE:redactSensitiveValue(item)}return output}export function redactCommandArgv(argv){const output=[];let redactNext=false;for(const token of argv){if(redactNext){output.push(REDACTED_VALUE);redactNext=false;continue}const match=token.match(/^--([^=]+)(?:=(.*))?$/);if(!match||!isSensitiveFlagName(match[1]??"")){output.push(token);continue}output.push(`--${match[1]}${match[2]===undefined?"":`=${REDACTED_VALUE}`}`);if(match[2]===undefined){redactNext=true}}return output}export{REDACTED_VALUE};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export function normalizeRuntimeUserId(value){if(typeof value==="number"){return Number.isSafeInteger(value)&&value>0?String(value):undefined}if(typeof value!=="string"||!/^\d+$/.test(value))return undefined;const normalized=value.replace(/^0+/,"");return normalized||undefined}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{mkdir,readFile,writeFile}from"node:fs/promises";import{homedir}from"node:os";import{dirname,join}from"node:path";import{LOVRABET_NPM_PACKAGE_NAME}from"../constant/distribution.js";import{CLI_BIN_NAME}from"../constant/cli.js";import{checkCliVersion,getCliUpgradeCommand}from"../utils/cli-version-check.js";const UPDATE_NOTICE_TTL_MS=24*60*60*1e3;function isUpdateNoticeDisabled(){const raw=process.env.LOVRABET_NO_UPDATE_NOTICE?.trim().toLowerCase();return raw==="1"||raw==="true"||raw==="yes"}function cacheRoot(){return process.env.XDG_CACHE_HOME||process.env.LOCALAPPDATA||join(homedir(),".cache")}export function getUpdateNoticeCachePath(){return join(cacheRoot(),"lovrabet-cli","update-check.json")}async function readUpdateNoticeCache(){try{const content=await readFile(getUpdateNoticeCachePath(),"utf8");const parsed=JSON.parse(content);if(!parsed||typeof parsed!=="object")return{};return parsed}catch{return{}}}async function writeUpdateNoticeCache(cache){try{
|
|
2
|
+
const file=getUpdateNoticeCachePath();await mkdir(dirname(file),{recursive:true});await writeFile(file,`${JSON.stringify(cache,null,2)}\n`,"utf8")}catch{}}function isRecentlyNotified(cache,latest,now){return cache.lastNotifiedVersion===latest&&typeof cache.lastNotifiedAt==="number"&&now-cache.lastNotifiedAt<UPDATE_NOTICE_TTL_MS}export function buildNpmVersionUrl(version){return`https://www.npmjs.com/package/${LOVRABET_NPM_PACKAGE_NAME}/v/${version}`}export async function resolveLatestUpdateNotice(checked){if(isUpdateNoticeDisabled())return null;try{const now=Date.now();const result=checked??await checkCliVersion();const current=result.currentVersion;const latest=result.stableVersion;const cache=await readUpdateNoticeCache();if(!latest||!result.needsUpgrade||result.belowMinimum)return null;if(isRecentlyNotified(cache,latest,now))return null;const command=getCliUpgradeCommand(result);await writeUpdateNoticeCache({...cache,checkedAt:now,latest:latest,failed:false,
|
|
3
|
+
lastNotifiedVersion:latest,lastNotifiedAt:now});return{command:command,current:current,latest:latest,url:buildNpmVersionUrl(latest),message:[result.upgradeMessage,`${CLI_BIN_NAME} ${latest} is recommended, current ${current}, run: ${command}`].filter(Boolean).join(" ")}}catch{return null}}
|
package/lib/utils/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{BUILD_TIME,GIT_COMMIT,VERSION}from"../generated/build-info.js";export function getCliVersion(){return VERSION}export function getCliGitCommit(){const gitCommit=String(GIT_COMMIT);return gitCommit&&gitCommit!=="unknown"?gitCommit:""}export function getCliVersionDisplay(){const gitCommit=getCliGitCommit();const buildDate=BUILD_TIME.slice(0,10);if(!gitCommit||!buildDate)return VERSION;return`${VERSION} (${gitCommit}, ${buildDate})`}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export function writeCliSideChannelLine(line){process.stderr.write(`${line}\n`)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovrabet/lovrabet-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-beta.1",
|
|
4
4
|
"description": "Runtime CLI for Lovrabet apps, datasets, SQL, Backend Function, skills, and AI agent workflows.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"prebuild": "node scripts/generate-build-info.js && node scripts/generate-builtin-skill-manifest.mjs --check",
|
|
44
|
-
"build": "
|
|
44
|
+
"build": "node scripts/clean-build-output.mjs && tsc && tsc-alias && node scripts/minify-build-output.mjs && node scripts/ensure-bin-executable.mjs",
|
|
45
45
|
"prebuild:dev": "node scripts/generate-build-info.js",
|
|
46
|
-
"build:dev": "
|
|
46
|
+
"build:dev": "node scripts/clean-build-output.mjs && tsc && tsc-alias && node scripts/ensure-bin-executable.mjs",
|
|
47
47
|
"prestart": "node scripts/generate-build-info.js",
|
|
48
48
|
"start": "tsc --watch",
|
|
49
49
|
"pretypecheck": "node scripts/generate-build-info.js",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"check:skill-version": "node scripts/check-skill-version.mjs",
|
|
64
64
|
"generate:builtin-skill-manifest": "node scripts/generate-builtin-skill-manifest.mjs",
|
|
65
65
|
"check:builtin-skill-manifest": "node scripts/generate-builtin-skill-manifest.mjs --check",
|
|
66
|
-
"postinstall": "node scripts/postinstall.mjs",
|
|
67
66
|
"ci": "npm run typecheck && npm run check:skill-version && npm run check:lockfile && npm run build",
|
|
68
67
|
"pretest": "node scripts/generate-build-info.js",
|
|
69
68
|
"test": "vitest run",
|
|
@@ -77,8 +76,8 @@
|
|
|
77
76
|
"files": [
|
|
78
77
|
"lib",
|
|
79
78
|
"skills/lovrabet",
|
|
79
|
+
"skills/lovrabet-report-generation",
|
|
80
80
|
"skills/lovrabet.manifest.json",
|
|
81
|
-
"scripts/postinstall.mjs",
|
|
82
81
|
"README.md",
|
|
83
82
|
"LICENSE",
|
|
84
83
|
"NOTICE"
|
|
@@ -86,7 +85,9 @@
|
|
|
86
85
|
"dependencies": {
|
|
87
86
|
"@inquirer/prompts": "^8.6.0",
|
|
88
87
|
"@lovrabet/cli-framework": "1.0.10",
|
|
89
|
-
"@lovrabet/sdk": "1.6.
|
|
88
|
+
"@lovrabet/sdk": "1.6.4",
|
|
89
|
+
"ajv": "^8.20.0",
|
|
90
|
+
"ajv-formats": "^3.0.1",
|
|
90
91
|
"chalk": "^5.6.2",
|
|
91
92
|
"exceljs": "4.4.0",
|
|
92
93
|
"execa": "^9.6.0",
|
|
@@ -103,6 +104,7 @@
|
|
|
103
104
|
"react": "^19.2.0",
|
|
104
105
|
"saxes": "6.0.0",
|
|
105
106
|
"semver": "^7.7.3",
|
|
107
|
+
"skills": "1.8.1",
|
|
106
108
|
"winston": "^3.17.0",
|
|
107
109
|
"ws": "8.20.1",
|
|
108
110
|
"yaml": "^2.9.0",
|
|
@@ -115,8 +117,7 @@
|
|
|
115
117
|
"@types/semver": "^7.7.1",
|
|
116
118
|
"@types/yauzl": "2.10.3",
|
|
117
119
|
"@vitest/coverage-v8": "^4.1.2",
|
|
118
|
-
"
|
|
119
|
-
"rimraf": "^6.1.3",
|
|
120
|
+
"terser": "5.51.2",
|
|
120
121
|
"tsc-alias": "^1.8.10",
|
|
121
122
|
"typescript": "5.9.3",
|
|
122
123
|
"vitest": "^4.1.2",
|
package/skills/lovrabet/SKILL.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: lovrabet
|
|
3
3
|
displayName: Lovrabet 运行态 CLI
|
|
4
|
-
version: 2.
|
|
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
|
|
4
|
+
version: 2.4.0-beta.1
|
|
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:
|
|
8
8
|
bins: ["lovrabet"]
|
|
@@ -20,12 +20,18 @@ metadata:
|
|
|
20
20
|
|
|
21
21
|
## 开发能力交接
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
指标体系是应用级的:指标归属企业的具体应用,以 AppCode 和指标名定位,页面与业务 Skill 按权限复用;登记或发布不改变资产归属,也不授予跨应用或跨企业访问权限。
|
|
24
|
+
|
|
25
|
+
任务决定工具,当前账号在目标应用的实际操作权限决定能否执行;不识别或要求用户证明岗位。查询、分析和报告使用 lovrabet;创建或修改应用级指标及其 SQL/BFF 使用 rabetbase。指标体系可选;先澄清业务目标,Agent 根据已有能力自主判断是否需要开发并进入开发交接,不默认让用户选择建设路径。既有授权内连续推进,不因缺数自动扩大安装、写入或发布授权,也不切换身份绕过限制。
|
|
26
|
+
|
|
27
|
+
先按操作对象与目的区分应用开发和运行态操作,再选择下面的执行流程。用户要创建、修改或发布 Lovrabet 应用级开发资产时,先读 [开发能力交接](guides/development-intent-handoff.md),例如应用、页面、数据集结构、应用级指标口径及其 BFF/SQL、菜单结构或流程定义;按需引导安装 rabetbase CLI 并交给其 Skill,不先进入运行态能力发现流程。
|
|
24
28
|
|
|
25
29
|
业务数据操作、执行已绑定 BFF/SQL、Personal BFF、角色菜单权限和已有审批任务办理仍由本 Skill 处理;不能仅凭“创建”“修改”判定为应用开发。纯开发任务无需先完成 lovrabet 的 AK 认证;两个 CLI 分别认证,不复制凭证。
|
|
26
30
|
|
|
27
31
|
## 使用顺序
|
|
28
32
|
|
|
33
|
+
日报、周报、经营汇总、综合分析或继续未完成报告,使用已安装的 `lovrabet-report-generation` Skill;完整匹配的企业业务 Skill 可直接使用,单值/身份查询保持简短。按宿主发现能力加载稳定名称,不假设安装目录相邻;配套缺失时说明该流程尚不可加载并交管理员处理,已有可信查询能力仍可使用。一次任务只由一条流程组织,不重复取数、生成或投递。
|
|
34
|
+
|
|
29
35
|
先看 guides,再查 references。
|
|
30
36
|
|
|
31
37
|
- 流程 / 决策:
|
|
@@ -34,6 +40,7 @@ metadata:
|
|
|
34
40
|
- [数据集与数据流程](guides/dataset-and-data-workflow.md)
|
|
35
41
|
- [可恢复 Excel 导入](references/lovrabet-excel-import.md)
|
|
36
42
|
- [DB_TABLE 的 Excel 转换与分批新增](references/lovrabet-db-table-excel-import.md)
|
|
43
|
+
- [指标查询与分析](guides/metric-consumption.md):应用级指标、metric exec 参数预演与调用前后校验、统计口径、分母、覆盖与报告表达
|
|
37
44
|
- [Custom SQL 与 Backend Function 流程](guides/sql-and-bff-workflow.md)
|
|
38
45
|
- [排障](guides/troubleshooting.md)
|
|
39
46
|
- [审批流运行态办理](references/lovrabet-approval-workflow.md)
|
|
@@ -46,7 +53,7 @@ metadata:
|
|
|
46
53
|
npm install -g @lovrabet/lovrabet-cli
|
|
47
54
|
```
|
|
48
55
|
|
|
49
|
-
npm
|
|
56
|
+
npm 包携带同版本 Built-in Skill;首次 npm 安装后必须执行 `lovrabet cli-skill install` 显式安装。若 `lovrabet doctor` 报告缺失、版本不一致或内容不一致,先处理提示的网络/权限问题,再执行 `lovrabet cli-skill install` 从当前 npm 包内修复。详见 [CLI 更新](references/lovrabet-update.md) 与 [诊断](references/lovrabet-doctor.md)。
|
|
50
57
|
|
|
51
58
|
## 认证
|
|
52
59
|
|
|
@@ -81,7 +88,7 @@ npm 包会自动安装同版本 Built-in Skill。若 `lovrabet doctor` 报告缺
|
|
|
81
88
|
- **不要擅自加 `--global` 或修改本地配置** — 见上文「本地配置原则」;仅在用户明确要求或文档说明的场景使用配置写命令。
|
|
82
89
|
- **不要主动创建工作目录配置** — 即使连续多次在同一目录使用同一个 `--app` / `--appcode`,也只能提醒用户是否要写入当前目录 `.lovrabet.json`;必须得到用户明确同意后,才可执行 `workspace init/use`。
|
|
83
90
|
- **不要回显或记录真实凭证** — 如果用户提供 AccessKey,只用于本次认证命令;不要在最终答复、日志、文档片段或排障输出里展示真实值。
|
|
84
|
-
- **禁止通过修改配置文件提升权限** — 不得为了完成任务而修改 `.lovrabet.json`、环境变量或缓存内容来抬高 `riskLevel`、切换到并非用户明确授权的 `accessKey`、伪造 `defaultApp` / `appcode`
|
|
91
|
+
- **禁止通过修改配置文件提升权限** — 不得为了完成任务而修改 `.lovrabet.json`、环境变量或缓存内容来抬高 `riskLevel`、切换到并非用户明确授权的 `accessKey`、伪造 `defaultApp` / `appcode` 或连接路由,或借此突破当前权限边界。权限不足时,说明目标应用与受阻操作,引导向管理员申请相应权限;保留原任务,授权后用当前账号重新核验,不索要明文凭证或代为提权。
|
|
85
92
|
- **不要访问未发布应用的数据** — `app list` 默认只展示已发布应用;即使通过 `app list --include-unpublished` 或缓存看到未发布应用,也不要把它作为 `dataset` / `data` / `sql` / `bff` 的目标。
|
|
86
93
|
- **不要臆测当前登录用户** — 只要任务依赖“当前是谁在登录 / 当前 AK 属于谁”,先执行 `lovrabet auth info`,再继续判断应用、权限或数据可见性。
|
|
87
94
|
- **运行态业务发现与实现资产隔离** — 运行态发现业务能力,不枚举实现资产。简单基础事实查询优先通过已治理 Dataset 的字段、关联和只读操作回答;稳定规则由业务 Skill 或可信 Service Tree 绑定到已发布入口。未绑定的 Custom SQL/Backend Function 实现资产不进入运行态候选。
|
|
@@ -234,6 +241,7 @@ npm 包会自动安装同版本 Built-in Skill。若 `lovrabet doctor` 报告缺
|
|
|
234
241
|
| **bff** | `detail` | 查看 Backend Function 详情 | read | AK |
|
|
235
242
|
| **bff** | `exec` | 执行 Backend Function | read | AK |
|
|
236
243
|
| **notification** | `config-list` | 查询当前应用的应用级通知渠道配置和 configCode | read | AK |
|
|
244
|
+
| **metric** | `list` / `detail` / `exec` | 发现应用指标摘要、按名称读取所属应用的指标,预演参数、执行 SQL/BFF 并校验结果 | read | AK |
|
|
237
245
|
| **app-config** | `get` | 按 key 获取当前应用的运行态 app-config value | read | AK |
|
|
238
246
|
| **user-account** | `bind` | 按 provider 绑定当前 AccessKey 所属用户的外部账号 | write | AK |
|
|
239
247
|
| **personal-bff** | `list` | 查看当前用户 Personal Backend Function | read | AK |
|
|
@@ -303,7 +311,7 @@ npm 包会自动安装同版本 Built-in Skill。若 `lovrabet doctor` 报告缺
|
|
|
303
311
|
|
|
304
312
|
### CLI 更新
|
|
305
313
|
|
|
306
|
-
`lovrabet update` 只查询 npm package 的 dist-tags,不依赖 CDN 文件。默认等价于 `--latest`;`--beta` 使用 npm `beta` dist-tag;`--version <version>` 安装指定 semver。CLI 与 Built-in Skill
|
|
314
|
+
`lovrabet update` 只查询 npm package 的 dist-tags,不依赖 CDN 文件。默认等价于 `--latest`;`--beta` 使用 npm `beta` dist-tag;`--version <version>` 安装指定 semver。CLI 与 Built-in Skill 一体升级,不提供拆分升级选项;升级后启动新版 CLI 的显式安装命令并验证 Skill 版本及内容摘要,同版本检查则直接从当前包内修复。
|
|
307
315
|
|
|
308
316
|
开源二开配置集中在项目代码的 `src/constant/product.ts`,`src/constant/distribution.ts` 只做兼容导出:
|
|
309
317
|
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
Agent 优先查询默认应用,必要时再查询当前用户有权限的其他应用。
|
|
7
7
|
一个执行上下文只有一个连接环境和一份用户 AK;选择应用只改变目标,不改变身份或环境。
|
|
8
8
|
|
|
9
|
+
指标任务分开核对当前凭证身份、指标所属应用和业务查询对象。`--params` 中的 `tenantCode` 或 `appCode` 若被指标契约声明,只是业务筛选,不改变执行应用或权限。`auth status` 与 `doctor` 展示配置及来源,不能据此认定身份或应用操作权限已通过服务端验证。
|
|
10
|
+
|
|
9
11
|
## 默认目标
|
|
10
12
|
|
|
11
13
|
- 用户明确指定的应用或已确认的任务范围优先。
|
|
@@ -105,6 +105,8 @@ lovrabet data filter --code <datasetCode> --params '{"where":{"status":{"$eq":"a
|
|
|
105
105
|
- 需要确认 SDK 参数结构,而不只是字段名
|
|
106
106
|
- 要把数据访问方式写进可交付源码或文档
|
|
107
107
|
|
|
108
|
+
统计或报告涉及正式业务口径时,先读 [指标查询与分析](metric-consumption.md);不能用原始字段或当前页重算替代可信指标。
|
|
109
|
+
|
|
108
110
|
## Dataset 回退准入
|
|
109
111
|
|
|
110
112
|
Dataset Detail + Instant API 是简单低风险事实查询的直接路径,例如读取单条记录、列举明细或做不承载业务判定的基础统计;这类请求不强制查询 KB,也不需要包装成 Custom SQL 或 Backend Function。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 开发能力交接
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
按任务和具体操作选择 CLI,不按用户岗位选择;岗位未提供也无需追问。平台权限与用户本次授权分别判断,有权限仍须遵守“不发布”等任务边界。先判断用户是在咨询开发方式、讨论方案,还是请求执行。咨询或方案讨论时,直接回答所问,不因提及开发就启动安装或认证;仅询问影响回答的缺失信息。
|
|
4
4
|
|
|
5
5
|
用户请求执行 Lovrabet 开发任务时,保留已有需求和上下文,按下文流程交接 rabetbase CLI 内置 Skill(名称为 `rabetbase`,以下简称“rabetbase Skill”),并依据实际能力推进。尊重用户明确的操作方式;需要用户完成某一步时,说明该步骤及后续衔接。不要索要密码或含密码的连接串。
|
|
6
6
|
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
| 创建 Lovrabet 应用、创建或修改页面、发布应用或页面 | rabetbase CLI 内置 Skill |
|
|
12
12
|
| 新增数据集、修改字段与关联结构 | rabetbase CLI 内置 Skill |
|
|
13
13
|
| 创建或修改应用级 Backend Function、Custom SQL 定义、菜单结构 | rabetbase CLI 内置 Skill |
|
|
14
|
+
| 定义或修改应用级指标口径、应用内复用的统计接口 | rabetbase CLI 内置 Skill;按其实际 schema 与业务契约确定操作入口 |
|
|
15
|
+
| 查询已有指标、分析经营数据或生成报告 | lovrabet 的可信业务能力;先读 [指标查询与分析](metric-consumption.md) |
|
|
14
16
|
| 创建、修改或发布审批流、工作流的流程定义 | rabetbase CLI 内置 Skill |
|
|
15
17
|
| 查询、新增或修改业务记录,导入 Excel | lovrabet 的 dataset/data 能力 |
|
|
16
18
|
| 执行已有且可信契约绑定的 BFF/SQL | lovrabet 的 bff/sql 能力 |
|
|
@@ -21,10 +23,16 @@
|
|
|
21
23
|
|
|
22
24
|
- 不以“BFF”“SQL”“菜单”“数据集”单个关键词决定切换。“修改菜单”不明确时,先问是菜单结构还是角色可见权限;“修改数据集”不明确时,先问是字段结构还是业务记录。
|
|
23
25
|
- 普通网站或本地代码开发不自动视为 Lovrabet 应用开发;上下文不能确定平台或操作对象时,只询问缺失信息。
|
|
24
|
-
- 混合任务按实际依赖拆分:例如先执行已绑定 BFF
|
|
26
|
+
- 混合任务按实际依赖拆分:例如先执行已绑定 BFF 查询、再增加字段,可先在既有授权内完成查询,再交接结构变更。查询契约不足、认证失败或权限拒绝不构成更换账号或借用其他身份的理由;不能借交接扩大权限或枚举未绑定实现资产。
|
|
25
27
|
|
|
26
28
|
## 2. 检查 CLI,缺失时引导安装
|
|
27
29
|
|
|
30
|
+
本节用于明确的开发请求,或 Agent 为完成已明确的业务目标判断需要补齐统计能力的任务,不要求用户承担某种岗位。指标体系不是报告前置条件;已有可信且获授权的统计入口满足目标时直接复用。Agent 自主选择工具和实现路径;用户无需先选择是否“建设指标体系”。已有业务决定与授权直接沿用;判断需要开发不自动授权安装、远端写入或发布,不把协作渠道配置作为前置条件。
|
|
31
|
+
|
|
32
|
+
需要澄清想完成的业务任务时,优先使用宿主实际可用的结构化提问工具(如 question),无此能力时使用普通对话;不要求固定 `/question` 命令。一次只问影响下一步的业务目标、范围、完成标准或未知口径,不让用户选择 CLI、SQL/BFF、Schema 或重复已确认信息。进入开发任务后,按研发指引补齐无法自行核实的技术约束与验收要求;已有契约先自行查明。技术方案影响交付时间、成本、业务范围或完整性时才需用户决定相应业务取舍,用户明确请求技术比较时按需讨论;安装与发布的必要授权另行按下文处理,已有授权不重问。
|
|
33
|
+
|
|
34
|
+
安装、应用开发权限和发布授权分别判断。用户允许安装不代表取得开发权限或允许发布;明确“先不发布”时连同依赖 SQL/BFF 一并保持未发布,只做获授权的本地准备与验证,说明未进行真实执行的限制。
|
|
35
|
+
|
|
28
36
|
先只读探测命令是否存在,再读取 `rabetbase --version`。POSIX shell 可用 `command -v rabetbase`;PowerShell 可用 `Get-Command rabetbase -ErrorAction SilentlyContinue`。
|
|
29
37
|
|
|
30
38
|
- 命令不存在:说明本任务需要 rabetbase CLI。当前会话没有覆盖安装的明确授权时,询问是否安装;用户拒绝则停止需要该 CLI 的部分,保留原任务上下文。
|
|
@@ -51,10 +59,18 @@ lovrabet 使用 User Access Key;rabetbase 的开发能力通过浏览器 OAuth
|
|
|
51
59
|
- 已确认有效的 rabetbase 会话直接复用;未知或过期时,Agent 使用 `rabetbase auth login --yes`。该命令会先检查已有会话,有效时跳过登录。`--yes` 仅跳过 CLI 的本地询问,不代替用户的浏览器授权。
|
|
52
60
|
- 命令输出授权链接时,将链接交给用户在自己的浏览器完成授权;Agent 不自行访问,也不索要密码或 Cookie。保持登录命令运行并等待真实结果,不在授权过程中反复启动登录。
|
|
53
61
|
- 登录失败、取消或超时后停止依赖认证的操作,给出实际原因及重新登录步骤;不能仅凭退出码为 0 判定成功。只有有效会话或登录成功的明确结果才继续。
|
|
54
|
-
- 按目标 Skill
|
|
62
|
+
- 按目标 Skill 核对当前账号在目标应用执行所需操作的权限;已登录不等于有开发或发布权限。权限不足时说明实际拒绝的应用、资源与操作,帮助整理最小权限申请给管理员;权限名称不明确时保留错误事实,不猜测应授予的角色。不自行改权限或借用管理员账号。
|
|
63
|
+
|
|
64
|
+
权限申请等待期间保留原任务目标、应用、固定期间、口径、已完成结果、草稿及下一步;可独立完成部分继续。用户选择申请权限不等于授权发送申请,只有明确要求且渠道可用时才提交并回读,否则给可转交摘要。
|
|
65
|
+
|
|
66
|
+
收到“已授权,继续”后,先用当前账号重新核验该操作权限,并回读当前云端定义及相关事实;不以口头声明当作已获权证据。随后沿用原期间与口径,只继续未完成部分;权限仍拒绝则保留待授权状态。不要要求更换成所谓研发/运营账号、重复安装或重建原报告。两个 CLI 可由同一用户分别完成各自认证,不复制凭证。
|
|
55
67
|
|
|
56
68
|
## 4. 带着原任务继续
|
|
57
69
|
|
|
58
70
|
向 rabetbase Skill 传递:用户原始目标、已确认的应用标识、目标国家/地区或独立部署信息、已有工作目录、已完成的步骤、剩余操作与授权范围。只传必要信息,不传凭证、整份配置或无关业务数据。
|
|
59
71
|
|
|
60
72
|
随后按其 Skill 读取能力、执行并验证结果;安装成功或登录成功不等于原任务完成。若后续只需验证真实业务记录,回到 lovrabet 对应能力并单独核对运行态认证与授权,避免两个 CLI 之间反复交接同一步骤。
|
|
73
|
+
|
|
74
|
+
## 指标开发所需信息
|
|
75
|
+
|
|
76
|
+
指标开发使用已确认的业务目标、指标所属应用、业务查询对象、期间与时区、已发现的指标及不足、期望结果和当前授权边界。复用已确认的信息,只补充影响结果的缺项,不要求用户重填整份需求。权限拒绝先交企业管理员核对授权,不以开发交接切换管理员身份。交付云端应用与稳定指标名后,以当前账号重新读取当前定义并验证业务结果;不要求消费方持有定义文件,不复制认证配置。
|