@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 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
export function adaptServiceTreeManifestForLegacyFramework(input){const manifest=cloneJsonValue(input);const errors=[];if(!isObjectRecord(manifest)){return{manifest:manifest,errors:errors}}if(Array.isArray(manifest.commands)){manifest.commands.forEach((command,index)=>{if(!isObjectRecord(command))return;adaptBffTarget(command.target,`$.commands[${index}].target`,errors)})}adaptResources(manifest.resources,"$.resources",errors);return{manifest:manifest,errors:errors}}export function toPublicServiceTreeTarget(target){const{scriptName:scriptName,...publicTarget}=target;if(typeof scriptName==="string"&&scriptName.trim()){publicTarget.functionName=scriptName}return publicTarget}export function toPublicNormalizedServiceTree(tree){return{...tree,commands:tree.commands.map(command=>({...command,target:toPublicServiceTreeTarget(command.target)}))}}function adaptResources(value,path,errors){if(!isObjectRecord(value))return;for(const[resourceName,resource]of Object.entries(value)){
|
|
2
|
+
if(!isObjectRecord(resource))continue;const resourcePath=`${path}.${resourceName}`;if(isObjectRecord(resource.actions)){for(const[actionName,action]of Object.entries(resource.actions)){if(!isObjectRecord(action))continue;const actionPath=`${resourcePath}.actions.${actionName}`;const hasBffTarget=isObjectRecord(action.target)&&action.target.kind==="bff";adaptBffTarget(action.target,`${actionPath}.target`,errors);if(hasBffTarget||isBffAction(action)){adaptFunctionNameField(action,actionPath,errors)}}}adaptResources(resource.resources,`${resourcePath}.resources`,errors)}}function adaptBffTarget(value,path,errors){if(!isObjectRecord(value)||value.kind!=="bff")return;adaptFunctionNameField(value,path,errors)}function adaptFunctionNameField(value,path,errors){if(Object.prototype.hasOwnProperty.call(value,"scriptName")){errors.push({level:"error",path:`${path}.scriptName`,message:"Use functionName; scriptName is not part of the runtime Service Tree contract."})}
|
|
3
|
+
if(Object.prototype.hasOwnProperty.call(value,"functionName")){if(typeof value.functionName!=="string"||!value.functionName.trim()){errors.push({level:"error",path:`${path}.functionName`,message:"functionName must be a non-empty string."});delete value.functionName;return}value.scriptName=value.functionName;delete value.functionName}}function isBffAction(action){return action.kind==="bff"||action.action==="bff.exec"||action.target==="bff.exec"}function cloneJsonValue(value){if(Array.isArray(value)){return value.map(item=>cloneJsonValue(item))}if(isObjectRecord(value)){return Object.fromEntries(Object.entries(value).map(([key,item])=>[key,cloneJsonValue(item)]))}return value}function isObjectRecord(value){return Boolean(value)&&typeof value==="object"&&!Array.isArray(value)}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
function a67_0x3ee4(_0x68005c,_0x306f7a){_0x68005c=_0x68005c-0x1be;const _0x113a4f=a67_0x113a();let _0x3ee485=_0x113a4f[_0x68005c];return _0x3ee485;}const a67_0x27ca20=a67_0x3ee4;function a67_0x113a(){const _0x411f64=['serviceCode','length','1197ztiLqK','target','type','\x20service(s).','126IqXoMs','Show\x20a\x20locally\x20imported\x20Service\x20Tree\x20manifest','list','imported','name','file','1192261ohsbtS','validate','report','manifests','normalizedManifest','6041420mWBexZ','risk','Removes\x20the\x20given\x20service\x20manifest\x20from\x20the\x20local\x20Service\x20Tree\x20registry.\x20Dynamic\x20commands\x20from\x20that\x20manifest\x20will\x20no\x20longer\x20be\x20available.','errors','importedAt','Writes\x20the\x20local\x20Service\x20Tree\x20manifest\x20for\x20the\x20given\x20service\x20to\x20a\x20JSON\x20file.\x20An\x20existing\x20file\x20at\x20the\x20target\x20may\x20be\x20overwritten.\x20The\x20confirmation\x20UI\x20does\x20not\x20show\x20local\x20file\x20paths.','Remove\x20a\x20Service\x20Tree\x20manifest\x20from\x20the\x20local\x20runtime\x20registry','cliPath','version','List\x20locally\x20imported\x20Service\x20Tree\x20manifests','5gPbDDy','registryPath','flags','Service\x20manifest\x20validation\x20passed.','Preview\x20Service\x20Tree\x20import\x20into\x20~/.lovrabet/service.json','Updated','Local\x20service\x20code,\x20for\x20example\x20crm','Removed\x20service\x20','hash','service','filePath','str','read','Reads\x20the\x20given\x20manifest\x20into\x20the\x20local\x20Service\x20Tree\x20registry.\x20An\x20existing\x20manifest\x20with\x20the\x20same\x20service\x20code\x20is\x20updated.\x20The\x20confirmation\x20UI\x20does\x20not\x20show\x20local\x20file\x20paths.','write','entries','1015068HsCsBt','import','warnings','source','replaced','186EyUVSz','registry','Validate\x20a\x20Service\x20Tree\x20JSON\x20manifest','entry','string','kind','141064wCymiI','WRITE','updated','\x20service(s),\x20updated\x20','commands','registryIndex','description','Export\x20the\x20local\x20Service\x20Tree\x20manifest\x20to\x20a\x20JSON\x20file','manifest','778212EUPATP','map','411396pvrSjO','Service\x20Tree\x20manifest\x20file\x20path','serviceCount'];a67_0x113a=function(){return _0x411f64;};return a67_0x113a();}(function(_0x25e251,_0x18873c){const _0x46ba0e=a67_0x3ee4,_0x1a056f=_0x25e251();while(!![]){try{const _0x117ef4=parseInt(_0x46ba0e(0x1ea))/0x1*(-parseInt(_0x46ba0e(0x1d4))/0x2)+-parseInt(_0x46ba0e(0x1e3))/0x3+-parseInt(_0x46ba0e(0x1cf))/0x4*(-parseInt(_0x46ba0e(0x1bf))/0x5)+parseInt(_0x46ba0e(0x1e5))/0x6+-parseInt(_0x46ba0e(0x1f4))/0x7+-parseInt(_0x46ba0e(0x1da))/0x8*(parseInt(_0x46ba0e(0x1ee))/0x9)+parseInt(_0x46ba0e(0x1f9))/0xa;if(_0x117ef4===_0x18873c)break;else _0x1a056f['push'](_0x1a056f['shift']());}catch(_0x339471){_0x1a056f['push'](_0x1a056f['shift']());}}}(a67_0x113a,0x21d45));import{exportServiceManifest,formatValidationFailure,getLocalServiceEntry,getServiceRegistryPath,importServiceManifest,listLocalServices,loadServiceManifestFromFile,removeServiceManifest}from'../../commands/service/registry.js';import{toPublicNormalizedServiceTree,toPublicServiceTreeTarget}from'../../commands/service/function-name-adapter.js';const FILE_FLAG={'name':a67_0x27ca20(0x1f3),'type':a67_0x27ca20(0x1d8),'required':!![],'description':a67_0x27ca20(0x1e6)},SERVICE_FLAG={'name':a67_0x27ca20(0x1c8),'type':a67_0x27ca20(0x1d8),'required':!![],'description':a67_0x27ca20(0x1c5),'pattern':{'regex':/^[a-z][a-z0-9-]*$/,'description':'lower\x20kebab-case\x20service\x20code'}};function summarizeService(_0x1ac6a4){const _0xe9f57e=a67_0x27ca20;return{'serviceCode':_0x1ac6a4[_0xe9f57e(0x1e8)],'name':_0x1ac6a4[_0xe9f57e(0x1f8)][_0xe9f57e(0x1c8)][_0xe9f57e(0x1f2)],'version':_0x1ac6a4[_0xe9f57e(0x201)],'importedAt':_0x1ac6a4[_0xe9f57e(0x1fd)],'source':_0x1ac6a4[_0xe9f57e(0x1d2)],'commandCount':_0x1ac6a4[_0xe9f57e(0x1f8)]['commands'][_0xe9f57e(0x1e9)],'commands':_0x1ac6a4[_0xe9f57e(0x1f8)]['commands'][_0xe9f57e(0x1e4)](_0x5e8cdb=>({'path':_0x5e8cdb[_0xe9f57e(0x200)],'description':_0x5e8cdb[_0xe9f57e(0x1e0)],'risk':_0x5e8cdb[_0xe9f57e(0x1fa)],'target':toPublicServiceTreeTarget(_0x5e8cdb['target']),'flags':_0x5e8cdb[_0xe9f57e(0x1c1)][_0xe9f57e(0x1e4)](_0x42d913=>({'name':_0x42d913[_0xe9f57e(0x1f2)],'cliName':_0x42d913['cliName'],'type':_0x42d913[_0xe9f57e(0x1ec)],'required':_0x42d913['required']===!![]}))}))};}function summarizeLoadedManifest(_0x5855b5){const _0x34e138=a67_0x27ca20;return{'service':_0x5855b5['normalizedManifest']?.[_0x34e138(0x1c8)],'version':_0x5855b5['normalizedManifest']?.[_0x34e138(0x201)],'commandCount':_0x5855b5[_0x34e138(0x1f8)]?.[_0x34e138(0x1de)][_0x34e138(0x1e9)]??0x0,'commands':_0x5855b5[_0x34e138(0x1f8)]?.[_0x34e138(0x1de)][_0x34e138(0x1e4)](_0x5630cb=>({'path':_0x5630cb[_0x34e138(0x200)],'risk':_0x5630cb[_0x34e138(0x1fa)],'target':toPublicServiceTreeTarget(_0x5630cb[_0x34e138(0x1eb)])}))??[],'registryIndex':_0x5855b5[_0x34e138(0x1df)],'registryServiceCode':_0x5855b5['registryServiceCode'],'errors':_0x5855b5[_0x34e138(0x1f6)][_0x34e138(0x1fc)],'warnings':_0x5855b5[_0x34e138(0x1f6)][_0x34e138(0x1d1)]};}export const serviceDefinitions=[{'service':a67_0x27ca20(0x1c8),'command':a67_0x27ca20(0x1f5),'description':a67_0x27ca20(0x1d6),'risk':a67_0x27ca20(0x1cb),'requiresAuth':![],'requiresAppCode':![],'flags':[FILE_FLAG],async 'execute'(_0x10a307){const _0x205e49=a67_0x27ca20,_0x74716c=loadServiceManifestFromFile(_0x10a307[_0x205e49(0x1ca)]('file'));if(!_0x74716c['report']['ok'])return{'ok':![],'data':{'file':_0x74716c[_0x205e49(0x1c9)],'hash':_0x74716c['hash'],'kind':_0x74716c[_0x205e49(0x1d9)],'serviceCount':_0x74716c[_0x205e49(0x1f7)][_0x205e49(0x1e9)],'services':_0x74716c[_0x205e49(0x1f7)][_0x205e49(0x1e4)](summarizeLoadedManifest),'errors':_0x74716c[_0x205e49(0x1f6)]['errors'],'warnings':_0x74716c['report'][_0x205e49(0x1d1)]},'message':formatValidationFailure(_0x74716c['report'])};if(_0x74716c['kind']===_0x205e49(0x1d5)||_0x74716c['manifests'][_0x205e49(0x1e9)]!==0x1)return{'ok':!![],'data':{'file':_0x74716c[_0x205e49(0x1c9)],'hash':_0x74716c[_0x205e49(0x1c7)],'kind':_0x74716c[_0x205e49(0x1d9)],'serviceCount':_0x74716c[_0x205e49(0x1f7)]['length'],'commandCount':_0x74716c[_0x205e49(0x1f7)]['reduce']((_0x2cb4cd,_0x1101cd)=>_0x2cb4cd+(_0x1101cd[_0x205e49(0x1f8)]?.[_0x205e49(0x1de)]['length']??0x0),0x0),'services':_0x74716c[_0x205e49(0x1f7)][_0x205e49(0x1e4)](summarizeLoadedManifest),'warnings':_0x74716c['report'][_0x205e49(0x1d1)]},'message':'Service\x20registry\x20validation\x20passed.'};return{'ok':!![],'data':{'file':_0x74716c[_0x205e49(0x1c9)],'hash':_0x74716c['hash'],'kind':_0x74716c[_0x205e49(0x1d9)],'service':_0x74716c[_0x205e49(0x1f8)]?.['service'],'version':_0x74716c[_0x205e49(0x1f8)]?.['version'],'commandCount':_0x74716c['normalizedManifest']?.[_0x205e49(0x1de)][_0x205e49(0x1e9)]??0x0,'commands':_0x74716c['normalizedManifest']?.[_0x205e49(0x1de)][_0x205e49(0x1e4)](_0x1fe4ef=>({'path':_0x1fe4ef[_0x205e49(0x200)],'risk':_0x1fe4ef['risk'],'target':toPublicServiceTreeTarget(_0x1fe4ef[_0x205e49(0x1eb)])})),'warnings':_0x74716c[_0x205e49(0x1f6)][_0x205e49(0x1d1)]},'message':_0x205e49(0x1c2)};}},{'service':a67_0x27ca20(0x1c8),'command':a67_0x27ca20(0x1d0),'description':'Import\x20a\x20Service\x20Tree\x20manifest\x20into\x20the\x20local\x20runtime\x20registry','risk':a67_0x27ca20(0x1cd),'confirmationDescription':a67_0x27ca20(0x1cc),'requiresAuth':![],'requiresAppCode':![],'flags':[FILE_FLAG],async 'dryRun'(_0x31f1fd){const _0x17689e=a67_0x27ca20,_0x88308f=loadServiceManifestFromFile(_0x31f1fd['str'](_0x17689e(0x1f3)));return{'method':_0x17689e(0x1db),'url':getServiceRegistryPath(),'body':{'file':_0x88308f[_0x17689e(0x1c9)],'hash':_0x88308f[_0x17689e(0x1c7)],'kind':_0x88308f['kind'],'ok':_0x88308f['report']['ok'],'service':_0x88308f[_0x17689e(0x1f8)]?.[_0x17689e(0x1c8)],'version':_0x88308f[_0x17689e(0x1f8)]?.[_0x17689e(0x201)],'serviceCount':_0x88308f['manifests'][_0x17689e(0x1e9)],'services':_0x88308f[_0x17689e(0x1f7)][_0x17689e(0x1e4)](_0x3678b1=>({'service':_0x3678b1[_0x17689e(0x1f8)]?.[_0x17689e(0x1c8)],'version':_0x3678b1[_0x17689e(0x1f8)]?.[_0x17689e(0x201)],'commandCount':_0x3678b1[_0x17689e(0x1f8)]?.['commands'][_0x17689e(0x1e9)]??0x0,'errors':_0x3678b1['report'][_0x17689e(0x1fc)]})),'errors':_0x88308f[_0x17689e(0x1f6)][_0x17689e(0x1fc)],'commandCount':_0x88308f[_0x17689e(0x1f8)]?.[_0x17689e(0x1de)][_0x17689e(0x1e9)]??0x0},'description':_0x17689e(0x1c3)};},async 'execute'(_0x5b9ef8){const _0x5f1126=a67_0x27ca20,_0x3481ea=importServiceManifest(_0x5b9ef8[_0x5f1126(0x1ca)]('file'));if(_0x3481ea[_0x5f1126(0x1ce)][_0x5f1126(0x1e9)]!==0x1)return{'ok':!![],'data':{'registryPath':_0x3481ea[_0x5f1126(0x1c0)],'imported':_0x3481ea['imported'],'updated':_0x3481ea['updated'],'serviceCount':_0x3481ea[_0x5f1126(0x1e7)],'services':_0x3481ea[_0x5f1126(0x1ce)][_0x5f1126(0x1e4)](summarizeService)},'message':'Imported\x20'+_0x3481ea['imported']+_0x5f1126(0x1dd)+_0x3481ea[_0x5f1126(0x1dc)]+_0x5f1126(0x1ed)};return{'ok':!![],'data':{'registryPath':_0x3481ea[_0x5f1126(0x1c0)],'replaced':_0x3481ea[_0x5f1126(0x1d3)],'imported':_0x3481ea[_0x5f1126(0x1f1)],'updated':_0x3481ea['updated'],'serviceCount':_0x3481ea[_0x5f1126(0x1e7)],'service':summarizeService(_0x3481ea[_0x5f1126(0x1d7)])},'message':(_0x3481ea[_0x5f1126(0x1d3)]?_0x5f1126(0x1c4):'Imported')+'\x20service\x20'+_0x3481ea[_0x5f1126(0x1d7)]['serviceCode']+'.'};}},{'service':a67_0x27ca20(0x1c8),'command':'export','description':a67_0x27ca20(0x1e1),'risk':a67_0x27ca20(0x1cd),'confirmationDescription':a67_0x27ca20(0x1fe),'requiresAuth':![],'requiresAppCode':![],'flags':[SERVICE_FLAG,FILE_FLAG],async 'dryRun'(_0x1e2ca6){const _0x4fbb44=a67_0x27ca20,_0xa41986=getLocalServiceEntry(_0x1e2ca6[_0x4fbb44(0x1ca)](_0x4fbb44(0x1c8)));return{'method':'WRITE','url':_0x1e2ca6[_0x4fbb44(0x1ca)](_0x4fbb44(0x1f3)),'body':{'service':_0x1e2ca6[_0x4fbb44(0x1ca)]('service'),'found':Boolean(_0xa41986),'version':_0xa41986?.[_0x4fbb44(0x201)],'source':_0xa41986?.[_0x4fbb44(0x1d2)]},'description':'Preview\x20Service\x20Tree\x20export\x20from\x20~/.lovrabet/service.json'};},async 'execute'(_0x1bc4d5){const _0x4200e3=a67_0x27ca20,_0x4f7e5a=exportServiceManifest(_0x1bc4d5[_0x4200e3(0x1ca)](_0x4200e3(0x1c8)),_0x1bc4d5[_0x4200e3(0x1ca)](_0x4200e3(0x1f3)));return{'ok':!![],'data':{'registryPath':_0x4f7e5a[_0x4200e3(0x1c0)],'file':_0x4f7e5a[_0x4200e3(0x1c9)],'service':summarizeService(_0x4f7e5a[_0x4200e3(0x1d7)])},'message':'Exported\x20service\x20'+_0x4f7e5a[_0x4200e3(0x1d7)]['serviceCode']+'.'};}},{'service':a67_0x27ca20(0x1c8),'command':a67_0x27ca20(0x1f0),'description':a67_0x27ca20(0x1be),'risk':a67_0x27ca20(0x1cb),'requiresAuth':![],'requiresAppCode':![],'flags':[],async 'execute'(){const _0x5f480c=a67_0x27ca20,_0x6bc78a=listLocalServices();return{'ok':!![],'data':{'registryPath':getServiceRegistryPath(),'total':_0x6bc78a[_0x5f480c(0x1e9)],'services':_0x6bc78a[_0x5f480c(0x1e4)](summarizeService)}};}},{'service':a67_0x27ca20(0x1c8),'command':'remove','description':a67_0x27ca20(0x1ff),'risk':a67_0x27ca20(0x1cd),'confirmationDescription':a67_0x27ca20(0x1fb),'requiresAuth':![],'requiresAppCode':![],'flags':[SERVICE_FLAG],async 'dryRun'(_0xf4a796){const _0x573f9a=a67_0x27ca20,_0x4e0cb1=getLocalServiceEntry(_0xf4a796[_0x573f9a(0x1ca)](_0x573f9a(0x1c8)));return{'method':_0x573f9a(0x1db),'url':getServiceRegistryPath(),'body':{'service':_0xf4a796['str'](_0x573f9a(0x1c8)),'found':Boolean(_0x4e0cb1),'version':_0x4e0cb1?.[_0x573f9a(0x201)],'source':_0x4e0cb1?.[_0x573f9a(0x1d2)]},'description':'Preview\x20Service\x20Tree\x20removal\x20from\x20~/.lovrabet/service.json'};},async 'execute'(_0x28a892){const _0x55d274=a67_0x27ca20,_0x282733=removeServiceManifest(_0x28a892[_0x55d274(0x1ca)]('service'));return{'ok':!![],'data':{'registryPath':_0x282733['registryPath'],'serviceCount':_0x282733[_0x55d274(0x1e7)],'service':summarizeService(_0x282733[_0x55d274(0x1d7)])},'message':_0x55d274(0x1c6)+_0x282733[_0x55d274(0x1d7)]['serviceCode']+'.'};}},{'service':a67_0x27ca20(0x1c8),'command':'detail','description':a67_0x27ca20(0x1ef),'risk':a67_0x27ca20(0x1cb),'requiresAuth':![],'requiresAppCode':![],'flags':[SERVICE_FLAG],async 'execute'(_0x1c242e){const _0x5108a4=a67_0x27ca20,_0x30056e=getLocalServiceEntry(_0x1c242e[_0x5108a4(0x1ca)](_0x5108a4(0x1c8)));if(!_0x30056e)return{'ok':![],'data':{'registryPath':getServiceRegistryPath(),'service':_0x1c242e[_0x5108a4(0x1ca)]('service')},'message':'Local\x20service\x20not\x20found:\x20'+_0x1c242e[_0x5108a4(0x1ca)](_0x5108a4(0x1c8))};return{'ok':!![],'data':{'registryPath':getServiceRegistryPath(),'service':summarizeService(_0x30056e),'manifest':_0x30056e[_0x5108a4(0x1e2)],'normalizedManifest':toPublicNormalizedServiceTree(_0x30056e[_0x5108a4(0x1f8)])}};}}];
|
|
1
|
+
import{exportServiceManifest,formatValidationFailure,getLocalServiceEntry,getServiceRegistryPath,importServiceManifest,listLocalServices,loadServiceManifestFromFile,removeServiceManifest}from"../../commands/service/registry.js";import{toPublicNormalizedServiceTree,toPublicServiceTreeTarget}from"../../commands/service/function-name-adapter.js";const FILE_FLAG={name:"file",type:"string",required:true,description:"Service Tree manifest file path"};const SERVICE_FLAG={name:"service",type:"string",required:true,description:"Local service code, for example crm",pattern:{regex:/^[a-z][a-z0-9-]*$/,description:"lower kebab-case service code"}};function summarizeService(entry){return{serviceCode:entry.serviceCode,name:entry.normalizedManifest.service.name,version:entry.version,importedAt:entry.importedAt,source:entry.source,commandCount:entry.normalizedManifest.commands.length,commands:entry.normalizedManifest.commands.map(command=>({path:command.cliPath,description:command.description,
|
|
2
|
+
risk:command.risk,target:toPublicServiceTreeTarget(command.target),flags:command.flags.map(flag=>({name:flag.name,cliName:flag.cliName,type:flag.type,required:flag.required===true}))}))}}function summarizeLoadedManifest(loaded){return{service:loaded.normalizedManifest?.service,version:loaded.normalizedManifest?.version,commandCount:loaded.normalizedManifest?.commands.length??0,commands:loaded.normalizedManifest?.commands.map(command=>({path:command.cliPath,risk:command.risk,target:toPublicServiceTreeTarget(command.target)}))??[],registryIndex:loaded.registryIndex,registryServiceCode:loaded.registryServiceCode,errors:loaded.report.errors,warnings:loaded.report.warnings}}export const serviceDefinitions=[{service:"service",command:"validate",description:"Validate a Service Tree JSON manifest",risk:"read",requiresAuth:false,requiresAppCode:false,flags:[FILE_FLAG],async execute(ctx){const loaded=loadServiceManifestFromFile(ctx.str("file"));if(!loaded.report.ok){return{ok:false,data:{
|
|
3
|
+
file:loaded.filePath,hash:loaded.hash,kind:loaded.kind,serviceCount:loaded.manifests.length,services:loaded.manifests.map(summarizeLoadedManifest),errors:loaded.report.errors,warnings:loaded.report.warnings},message:formatValidationFailure(loaded.report)}}if(loaded.kind==="registry"||loaded.manifests.length!==1){return{ok:true,data:{file:loaded.filePath,hash:loaded.hash,kind:loaded.kind,serviceCount:loaded.manifests.length,commandCount:loaded.manifests.reduce((total,manifest)=>total+(manifest.normalizedManifest?.commands.length??0),0),services:loaded.manifests.map(summarizeLoadedManifest),warnings:loaded.report.warnings},message:"Service registry validation passed."}}return{ok:true,data:{file:loaded.filePath,hash:loaded.hash,kind:loaded.kind,service:loaded.normalizedManifest?.service,version:loaded.normalizedManifest?.version,commandCount:loaded.normalizedManifest?.commands.length??0,commands:loaded.normalizedManifest?.commands.map(command=>({path:command.cliPath,risk:command.risk,
|
|
4
|
+
target:toPublicServiceTreeTarget(command.target)})),warnings:loaded.report.warnings},message:"Service manifest validation passed."}}},{service:"service",command:"import",description:"Import a Service Tree manifest into the local runtime registry",risk:"write",confirmationDescription:"Reads the given manifest into the local Service Tree registry. An existing manifest with the same service code is updated. The confirmation UI does not show local file paths.",requiresAuth:false,requiresAppCode:false,flags:[FILE_FLAG],async dryRun(ctx){const loaded=loadServiceManifestFromFile(ctx.str("file"));return{method:"WRITE",url:getServiceRegistryPath(),body:{file:loaded.filePath,hash:loaded.hash,kind:loaded.kind,ok:loaded.report.ok,service:loaded.normalizedManifest?.service,version:loaded.normalizedManifest?.version,serviceCount:loaded.manifests.length,services:loaded.manifests.map(manifest=>({service:manifest.normalizedManifest?.service,version:manifest.normalizedManifest?.version,
|
|
5
|
+
commandCount:manifest.normalizedManifest?.commands.length??0,errors:manifest.report.errors})),errors:loaded.report.errors,commandCount:loaded.normalizedManifest?.commands.length??0},description:"Preview Service Tree import into ~/.lovrabet/service.json"}},async execute(ctx){const result=importServiceManifest(ctx.str("file"));if(result.entries.length!==1){return{ok:true,data:{registryPath:result.registryPath,imported:result.imported,updated:result.updated,serviceCount:result.serviceCount,services:result.entries.map(summarizeService)},message:`Imported ${result.imported} service(s), updated ${result.updated} service(s).`}}return{ok:true,data:{registryPath:result.registryPath,replaced:result.replaced,imported:result.imported,updated:result.updated,serviceCount:result.serviceCount,service:summarizeService(result.entry)},message:`${result.replaced?"Updated":"Imported"} service ${result.entry.serviceCode}.`}}},{service:"service",command:"export",
|
|
6
|
+
description:"Export the local Service Tree manifest to a JSON file",risk:"write",confirmationDescription:"Writes the local Service Tree manifest for the given service to a JSON file. An existing file at the target may be overwritten. The confirmation UI does not show local file paths.",requiresAuth:false,requiresAppCode:false,flags:[SERVICE_FLAG,FILE_FLAG],async dryRun(ctx){const entry=getLocalServiceEntry(ctx.str("service"));return{method:"WRITE",url:ctx.str("file"),body:{service:ctx.str("service"),found:Boolean(entry),version:entry?.version,source:entry?.source},description:"Preview Service Tree export from ~/.lovrabet/service.json"}},async execute(ctx){const result=exportServiceManifest(ctx.str("service"),ctx.str("file"));return{ok:true,data:{registryPath:result.registryPath,file:result.filePath,service:summarizeService(result.entry)},message:`Exported service ${result.entry.serviceCode}.`}}},{service:"service",command:"list",
|
|
7
|
+
description:"List locally imported Service Tree manifests",risk:"read",requiresAuth:false,requiresAppCode:false,flags:[],async execute(){const services=listLocalServices();return{ok:true,data:{registryPath:getServiceRegistryPath(),total:services.length,services:services.map(summarizeService)}}}},{service:"service",command:"remove",description:"Remove a Service Tree manifest from the local runtime registry",risk:"write",confirmationDescription:"Removes the given service manifest from the local Service Tree registry. Dynamic commands from that manifest will no longer be available.",requiresAuth:false,requiresAppCode:false,flags:[SERVICE_FLAG],async dryRun(ctx){const entry=getLocalServiceEntry(ctx.str("service"));return{method:"WRITE",url:getServiceRegistryPath(),body:{service:ctx.str("service"),found:Boolean(entry),version:entry?.version,source:entry?.source},description:"Preview Service Tree removal from ~/.lovrabet/service.json"}},async execute(ctx){
|
|
8
|
+
const result=removeServiceManifest(ctx.str("service"));return{ok:true,data:{registryPath:result.registryPath,serviceCount:result.serviceCount,service:summarizeService(result.entry)},message:`Removed service ${result.entry.serviceCode}.`}}},{service:"service",command:"detail",description:"Show a locally imported Service Tree manifest",risk:"read",requiresAuth:false,requiresAppCode:false,flags:[SERVICE_FLAG],async execute(ctx){const entry=getLocalServiceEntry(ctx.str("service"));if(!entry){return{ok:false,data:{registryPath:getServiceRegistryPath(),service:ctx.str("service")},message:`Local service not found: ${ctx.str("service")}`}}return{ok:true,data:{registryPath:getServiceRegistryPath(),service:summarizeService(entry),manifest:entry.manifest,normalizedManifest:toPublicNormalizedServiceTree(entry.normalizedManifest)}}}}];
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
(function(_0x3ee12e,_0x4bfc50){const _0x14a5c0=a68_0x59eb,_0xc476b8=_0x3ee12e();while(!![]){try{const _0x1b33f3=-parseInt(_0x14a5c0(0x1cd))/0x1+-parseInt(_0x14a5c0(0x1ee))/0x2*(-parseInt(_0x14a5c0(0x1ab))/0x3)+parseInt(_0x14a5c0(0x1bd))/0x4*(-parseInt(_0x14a5c0(0x1b7))/0x5)+parseInt(_0x14a5c0(0x1b9))/0x6+parseInt(_0x14a5c0(0x1e5))/0x7+-parseInt(_0x14a5c0(0x1c0))/0x8*(-parseInt(_0x14a5c0(0x1c3))/0x9)+parseInt(_0x14a5c0(0x1c9))/0xa*(-parseInt(_0x14a5c0(0x1d6))/0xb);if(_0x1b33f3===_0x4bfc50)break;else _0xc476b8['push'](_0xc476b8['shift']());}catch(_0x3982d5){_0xc476b8['push'](_0xc476b8['shift']());}}}(a68_0x3aae,0xd44eb));import{createHash}from'node:crypto';import{existsSync,mkdirSync,readFileSync,renameSync,unlinkSync,writeFileSync}from'node:fs';import{homedir}from'node:os';import{dirname,resolve}from'node:path';import{normalizeServiceTreeManifest,validateServiceTreeManifest}from'@lovrabet/cli-framework';function a68_0x59eb(_0x376465,_0x2a37cb){_0x376465=_0x376465-0x1a6;const _0x3aaef5=a68_0x3aae();let _0x59eb45=_0x3aaef5[_0x376465];return _0x59eb45;}import{PRODUCT_CONFIG}from'../../constant/product.js';import{CliErrors}from'../../errors.js';import{adaptServiceTreeManifestForLegacyFramework}from'../../commands/service/function-name-adapter.js';export const SERVICE_REGISTRY_SCHEMA_VERSION=0x1;export const SERVICE_REGISTRY_FILE_NAME='service.json';function a68_0x3aae(){const _0x5899da=['utf8','normalizedManifest','hex','isArray','Run\x20lovrabet\x20service\x20list\x20to\x20see\x20imported\x20services.','Local\x20service\x20not\x20found:\x20','sort','manifests','service','empty','services\x20must\x20be\x20an\x20array','reduce','updatedAt','sha256','.tmp','6xNDVAP','trim','Add\x20at\x20least\x20one\x20service\x20manifest,\x20then\x20run\x20service\x20import\x20again.','ENOENT','push','version','risk','importedAt','serviceCode','command','invalid','homeDirName','6498770eLkigh','slice','3196158HQjsCw','Service\x20registry\x20has\x20no\x20services\x20to\x20import.','Unsupported\x20schemaVersion:\x20','Unsupported\x20service\x20registry\x20schemaVersion:\x20','4JGMyLT','update','find','1264HPMTQl','map','join','35991Trivmr','length','description','].manifest','validation','source','19070DVFeGq','Fix\x20the\x20service\x20manifest\x20and\x20run\x20service\x20validate\x20again.','name','$.services[','1202388oiTmJK','Cannot\x20write\x20service\x20registry:\x20','homeDir','registryIndex','target','registry','schemaVersion','parse','path','6413vQeQkg','Remove\x20or\x20migrate\x20','services','message','report','stringify','Service\x20manifest\x20file\x20not\x20found:\x20','errors','manifest','digest','startsWith','flatMap','code','findIndex','commandCount','11379571ACOWgP','Service\x20manifest\x20validation\x20failed:\x0a','object','sourceHash','bff\x20target\x20requires\x20functionName.','commands','warnings','].manifest.','now','1693346kTMrDx','filePath','Fix\x20the\x20JSON\x20syntax\x20and\x20run\x20service\x20validate\x20again.','Invalid\x20service\x20registry\x20JSON:\x20','Fix\x20the\x20JSON\x20file\x20or\x20move\x20it\x20aside\x20and\x20import\x20services\x20again.','toISOString'];a68_0x3aae=function(){return _0x5899da;};return a68_0x3aae();}export function getServiceRegistryPath(_0x4a3fab={}){const _0x55cde9=a68_0x59eb;return resolve(_0x4a3fab[_0x55cde9(0x1cf)]??homedir(),PRODUCT_CONFIG[_0x55cde9(0x1b6)],SERVICE_REGISTRY_FILE_NAME);}export function emptyServiceRegistry(){return{'schemaVersion':SERVICE_REGISTRY_SCHEMA_VERSION,'services':[]};}export function readServiceRegistry(_0x20b5be={}){const _0x376b33=a68_0x59eb,_0x32bbf3=getServiceRegistryPath(_0x20b5be);if(!existsSync(_0x32bbf3))return emptyServiceRegistry();try{const _0x13e763=readFileSync(_0x32bbf3,'utf8');if(!_0x13e763[_0x376b33(0x1ac)]())return emptyServiceRegistry();const _0x2ed3e2=JSON[_0x376b33(0x1d4)](_0x13e763);if(_0x2ed3e2['schemaVersion']!==SERVICE_REGISTRY_SCHEMA_VERSION)throw CliErrors['validation'](_0x376b33(0x1bc)+String(_0x2ed3e2[_0x376b33(0x1d3)]),_0x376b33(0x1d7)+_0x32bbf3+'.');if(!Array[_0x376b33(0x1f7)](_0x2ed3e2[_0x376b33(0x1d8)]))return emptyServiceRegistry();return{'schemaVersion':SERVICE_REGISTRY_SCHEMA_VERSION,'updatedAt':_0x2ed3e2['updatedAt'],'services':_0x2ed3e2[_0x376b33(0x1d8)]};}catch(_0x3437e6){if(_0x3437e6 instanceof Error&&_0x3437e6[_0x376b33(0x1cb)]==='CliError')throw _0x3437e6;throw CliErrors['validation'](_0x376b33(0x1f1)+_0x32bbf3,_0x376b33(0x1f2));}}export function writeServiceRegistry(_0x18d2b2,_0x2f5d21={}){const _0x3099b3=a68_0x59eb,_0xa097b0=getServiceRegistryPath(_0x2f5d21),_0x3cd618=dirname(_0xa097b0);!existsSync(_0x3cd618)&&mkdirSync(_0x3cd618,{'recursive':!![]});const _0x38b2e7=_0xa097b0+_0x3099b3(0x1aa);try{writeFileSync(_0x38b2e7,JSON[_0x3099b3(0x1db)](_0x18d2b2,null,0x2)+'\x0a',{'encoding':_0x3099b3(0x1f4),'mode':0x180}),renameSync(_0x38b2e7,_0xa097b0);}catch(_0xd99e7b){try{unlinkSync(_0x38b2e7);}catch{}if(_0xd99e7b?.[_0x3099b3(0x1e2)]===_0x3099b3(0x1ae))throw CliErrors[_0x3099b3(0x1c7)](_0x3099b3(0x1ce)+_0xa097b0);throw _0xd99e7b;}return _0xa097b0;}export function loadServiceManifestFromFile(_0x4fefa7){const _0x26c1d0=a68_0x59eb,_0x2bac27=resolve(_0x4fefa7);if(!existsSync(_0x2bac27))throw CliErrors[_0x26c1d0(0x1c7)](_0x26c1d0(0x1dc)+_0x4fefa7);let _0x579549;const _0x47bf7d=readFileSync(_0x2bac27,_0x26c1d0(0x1f4));try{_0x579549=JSON[_0x26c1d0(0x1d4)](_0x47bf7d);}catch{throw CliErrors[_0x26c1d0(0x1c7)]('Invalid\x20service\x20manifest\x20JSON:\x20'+_0x4fefa7,_0x26c1d0(0x1f0));}const _0x119454=sha256(_0x47bf7d),_0x221ca0=extractLoadedServiceManifests(_0x579549,_0x119454),_0x57bdba=aggregateValidationReports(_0x221ca0),_0x5361b5=_0x221ca0[0x0];return{'filePath':_0x2bac27,'hash':_0x119454,'kind':isServiceRegistryLike(_0x579549)?_0x26c1d0(0x1d2):_0x26c1d0(0x1de),'manifest':_0x5361b5?.[_0x26c1d0(0x1de)]??_0x579549,'report':_0x57bdba,'normalizedManifest':_0x221ca0[_0x26c1d0(0x1c4)]===0x1?_0x5361b5?.[_0x26c1d0(0x1f5)]:undefined,'manifests':_0x221ca0};}export function importServiceManifest(_0xb9707d,_0x4ba73b={}){const _0x19525a=a68_0x59eb,_0x5ba5b5=loadServiceManifestFromFile(_0xb9707d);if(!_0x5ba5b5[_0x19525a(0x1da)]['ok'])throw CliErrors['validation'](formatValidationFailure(_0x5ba5b5[_0x19525a(0x1da)]),_0x19525a(0x1ca));if(_0x5ba5b5[_0x19525a(0x1fb)]['length']===0x0)throw CliErrors[_0x19525a(0x1c7)](_0x19525a(0x1ba),_0x19525a(0x1ad));const _0xe0b660=readServiceRegistry(_0x4ba73b),_0x88cbe=(_0x4ba73b[_0x19525a(0x1ed)]??(()=>new Date()))()[_0x19525a(0x1f3)](),_0x434afa=[];let _0xf2acd8=0x0,_0x2d7bfd=0x0;for(const _0xa3c924 of _0x5ba5b5['manifests']){if(!_0xa3c924[_0x19525a(0x1f5)])continue;const _0x13040b=_0xa3c924[_0x19525a(0x1f5)][_0x19525a(0x1fc)]['code'],_0x4369c3={'serviceCode':_0x13040b,'version':_0xa3c924['normalizedManifest'][_0x19525a(0x1b0)],'importedAt':_0x88cbe,'source':{'type':'file','path':_0x5ba5b5[_0x19525a(0x1ef)],'hash':_0xa3c924[_0x19525a(0x1e8)]},'manifest':_0xa3c924[_0x19525a(0x1de)],'normalizedManifest':_0xa3c924[_0x19525a(0x1f5)]},_0x1e9135=_0xe0b660[_0x19525a(0x1d8)][_0x19525a(0x1e3)](_0x31f3a7=>_0x31f3a7[_0x19525a(0x1b3)]===_0x13040b);_0x1e9135>=0x0?(_0xe0b660[_0x19525a(0x1d8)][_0x1e9135]=_0x4369c3,_0x2d7bfd++):(_0xe0b660['services']['push'](_0x4369c3),_0xf2acd8++),_0x434afa[_0x19525a(0x1af)](_0x4369c3);}_0xe0b660['services'][_0x19525a(0x1fa)]((_0xcd2f63,_0x24bb5e)=>_0xcd2f63[_0x19525a(0x1b3)]['localeCompare'](_0x24bb5e['serviceCode'])),_0xe0b660[_0x19525a(0x1a8)]=_0x88cbe;const _0xb15aec=writeServiceRegistry(_0xe0b660,_0x4ba73b);return{'registryPath':_0xb15aec,'entry':_0x434afa[0x0],'replaced':_0x434afa['length']===0x1?_0x2d7bfd===0x1:_0x2d7bfd>0x0,'entries':_0x434afa,'imported':_0xf2acd8,'updated':_0x2d7bfd,'serviceCount':_0xe0b660[_0x19525a(0x1d8)][_0x19525a(0x1c4)]};}export function exportServiceManifest(_0x26ffa2,_0x5ddc4d,_0x80de34={}){const _0x5a411c=a68_0x59eb,_0x23e697=getServiceRegistryPath(_0x80de34),_0x589aba=getLocalServiceEntry(_0x26ffa2,_0x80de34);if(!_0x589aba)throw CliErrors[_0x5a411c(0x1c7)](_0x5a411c(0x1f9)+_0x26ffa2,_0x5a411c(0x1f8));const _0x17eae3=resolve(_0x5ddc4d),_0x12673b=dirname(_0x17eae3);return!existsSync(_0x12673b)&&mkdirSync(_0x12673b,{'recursive':!![]}),writeFileSync(_0x17eae3,JSON[_0x5a411c(0x1db)](_0x589aba[_0x5a411c(0x1de)],null,0x2)+'\x0a',{'encoding':_0x5a411c(0x1f4),'mode':0x180}),{'registryPath':_0x23e697,'filePath':_0x17eae3,'entry':_0x589aba};}export function removeServiceManifest(_0x26cb8d,_0x4dbc6b={}){const _0x5b7ebd=a68_0x59eb,_0x481a27=readServiceRegistry(_0x4dbc6b),_0x8e7275=_0x26cb8d[_0x5b7ebd(0x1ac)](),_0x9188ef=_0x481a27[_0x5b7ebd(0x1d8)][_0x5b7ebd(0x1e3)](_0xf96d8c=>_0xf96d8c[_0x5b7ebd(0x1b3)]===_0x8e7275);if(_0x9188ef<0x0)throw CliErrors['validation']('Local\x20service\x20not\x20found:\x20'+_0x8e7275,'Run\x20lovrabet\x20service\x20list\x20to\x20see\x20imported\x20services.');const [_0x26c215]=_0x481a27[_0x5b7ebd(0x1d8)]['splice'](_0x9188ef,0x1),_0x25d7f6=(_0x4dbc6b[_0x5b7ebd(0x1ed)]??(()=>new Date()))()[_0x5b7ebd(0x1f3)]();_0x481a27[_0x5b7ebd(0x1a8)]=_0x25d7f6;const _0x2222c7=writeServiceRegistry(_0x481a27,_0x4dbc6b);return{'registryPath':_0x2222c7,'entry':_0x26c215,'serviceCount':_0x481a27['services'][_0x5b7ebd(0x1c4)]};}export function listLocalServices(_0x1e9b97={}){const _0x28b59e=a68_0x59eb;return readServiceRegistry(_0x1e9b97)[_0x28b59e(0x1d8)];}export function getLocalServiceEntry(_0x582b5c,_0x24a101={}){const _0x16bd30=a68_0x59eb;return readServiceRegistry(_0x24a101)[_0x16bd30(0x1d8)][_0x16bd30(0x1bf)](_0x35a925=>_0x35a925[_0x16bd30(0x1b3)]===_0x582b5c[_0x16bd30(0x1ac)]());}export function listLocalServiceTrees(_0x443be9={}){const _0x1d7aca=a68_0x59eb;return readServiceRegistry(_0x443be9)['services'][_0x1d7aca(0x1c1)](_0x33625d=>_0x33625d[_0x1d7aca(0x1f5)]);}export function inspectServiceRegistry(_0x5c8fd3={}){const _0x34d3f6=a68_0x59eb,_0x1b8b07=getServiceRegistryPath(_0x5c8fd3);if(!existsSync(_0x1b8b07))return emptyServiceRegistryInspection(_0x1b8b07,'missing',![]);try{const _0x120d91=readFileSync(_0x1b8b07,_0x34d3f6(0x1f4));if(!_0x120d91['trim']())return emptyServiceRegistryInspection(_0x1b8b07,_0x34d3f6(0x1fd),!![]);const _0x391f5d=JSON['parse'](_0x120d91);if(_0x391f5d[_0x34d3f6(0x1d3)]!==SERVICE_REGISTRY_SCHEMA_VERSION)return{...emptyServiceRegistryInspection(_0x1b8b07,'invalid',!![]),'schemaVersion':_0x391f5d['schemaVersion'],'message':_0x34d3f6(0x1bb)+String(_0x391f5d['schemaVersion'])};if(!Array[_0x34d3f6(0x1f7)](_0x391f5d['services']))return{...emptyServiceRegistryInspection(_0x1b8b07,_0x34d3f6(0x1b5),!![]),'schemaVersion':SERVICE_REGISTRY_SCHEMA_VERSION,'updatedAt':_0x391f5d[_0x34d3f6(0x1a8)],'message':_0x34d3f6(0x1a6)};const _0x486ec8=_0x391f5d[_0x34d3f6(0x1d8)][_0x34d3f6(0x1c1)](summarizeLocalServiceEntry);return{'registryPath':_0x1b8b07,'exists':!![],'status':'ok','schemaVersion':SERVICE_REGISTRY_SCHEMA_VERSION,'updatedAt':_0x391f5d[_0x34d3f6(0x1a8)],'serviceCount':_0x486ec8[_0x34d3f6(0x1c4)],'commandCount':_0x486ec8[_0x34d3f6(0x1a7)]((_0xb6c55c,_0x23163a)=>_0xb6c55c+_0x23163a[_0x34d3f6(0x1e4)],0x0),'services':_0x486ec8};}catch(_0x2d2a75){return{...emptyServiceRegistryInspection(_0x1b8b07,_0x34d3f6(0x1b5),!![]),'message':_0x2d2a75 instanceof Error?_0x2d2a75[_0x34d3f6(0x1d9)]:String(_0x2d2a75)};}}export function formatValidationFailure(_0x1e7b0b){const _0x4b8d8e=a68_0x59eb,_0x491a18=_0x1e7b0b[_0x4b8d8e(0x1dd)][_0x4b8d8e(0x1c1)](_0xf87f90=>_0xf87f90[_0x4b8d8e(0x1d5)]+':\x20'+_0xf87f90['message']);return _0x4b8d8e(0x1e6)+_0x491a18[_0x4b8d8e(0x1c2)]('\x0a');}function extractLoadedServiceManifests(_0x5df5e7,_0x29839b){const _0x184503=a68_0x59eb;if(!isServiceRegistryLike(_0x5df5e7)){const _0x1641ca=_0x5df5e7,{manifest:_0x191142,errors:_0x296a53}=adaptServiceTreeManifestForLegacyFramework(_0x1641ca),_0x3b5ff0=validateServiceTreeManifest(_0x191142),_0x5374a9=mergeValidationErrors(_0x3b5ff0,_0x296a53);return[{'manifest':_0x1641ca,'report':_0x5374a9,'normalizedManifest':_0x5374a9['ok']?normalizeServiceTreeManifest(_0x191142):undefined,'sourceHash':_0x29839b}];}return _0x5df5e7[_0x184503(0x1d8)][_0x184503(0x1c1)]((_0x31e7ef,_0x48f500)=>{const _0x17f059=_0x184503,_0x4268bd=isObjectRecord(_0x31e7ef)?_0x31e7ef[_0x17f059(0x1de)]:undefined,{manifest:_0x24ccad,errors:_0x55441c}=adaptServiceTreeManifestForLegacyFramework(_0x4268bd),_0x441c0d=validateServiceTreeManifest(_0x24ccad),_0x2bc884=mergeValidationErrors(_0x441c0d,_0x55441c),_0x184d32=isObjectRecord(_0x31e7ef)&&typeof _0x31e7ef[_0x17f059(0x1b3)]==='string'?_0x31e7ef['serviceCode']:undefined;return{'manifest':_0x4268bd,'report':_0x2bc884,'normalizedManifest':_0x2bc884['ok']?normalizeServiceTreeManifest(_0x24ccad):undefined,'sourceHash':sha256(JSON[_0x17f059(0x1db)](_0x4268bd,null,0x2)+'\x0a'),'registryIndex':_0x48f500,'registryServiceCode':_0x184d32};});}function mergeValidationErrors(_0x3d311a,_0x1cfc96){const _0x3f4932=a68_0x59eb,_0x5580f0=_0x3d311a[_0x3f4932(0x1dd)][_0x3f4932(0x1c1)](_0x47c153=>_0x47c153[_0x3f4932(0x1d9)]==='bff\x20target\x20requires\x20bffCode,\x20bffId,\x20or\x20scriptName.'?{..._0x47c153,'message':_0x3f4932(0x1e9)}:_0x47c153),_0x1b792b=[..._0x1cfc96,..._0x5580f0];return{'ok':_0x1b792b[_0x3f4932(0x1c4)]===0x0,'errors':_0x1b792b,'warnings':_0x3d311a[_0x3f4932(0x1eb)]};}function aggregateValidationReports(_0x492419){const _0x38f7a0=a68_0x59eb,_0x72fb61=_0x492419[_0x38f7a0(0x1e1)](_0x4a6fb5=>_0x4a6fb5['registryIndex']===undefined?_0x4a6fb5[_0x38f7a0(0x1da)][_0x38f7a0(0x1dd)]:_0x4a6fb5[_0x38f7a0(0x1da)][_0x38f7a0(0x1dd)][_0x38f7a0(0x1c1)](_0x3346c7=>({..._0x3346c7,'path':prefixRegistryIssuePath(_0x4a6fb5[_0x38f7a0(0x1d0)],_0x3346c7[_0x38f7a0(0x1d5)])}))),_0x44d0f3=_0x492419[_0x38f7a0(0x1e1)](_0x3db86a=>_0x3db86a['registryIndex']===undefined?_0x3db86a['report'][_0x38f7a0(0x1eb)]:_0x3db86a['report'][_0x38f7a0(0x1eb)][_0x38f7a0(0x1c1)](_0x1b7fa3=>({..._0x1b7fa3,'path':prefixRegistryIssuePath(_0x3db86a[_0x38f7a0(0x1d0)],_0x1b7fa3[_0x38f7a0(0x1d5)])})));return{'ok':_0x72fb61['length']===0x0,'errors':_0x72fb61,'warnings':_0x44d0f3};}function prefixRegistryIssuePath(_0x101455,_0x3b42a4){const _0x3a99d4=a68_0x59eb;if(_0x3b42a4==='$')return _0x3a99d4(0x1cc)+_0x101455+_0x3a99d4(0x1c6);if(_0x3b42a4[_0x3a99d4(0x1e0)]('$.'))return _0x3a99d4(0x1cc)+_0x101455+_0x3a99d4(0x1c6)+_0x3b42a4[_0x3a99d4(0x1b8)](0x1);if(_0x3b42a4[_0x3a99d4(0x1e0)]('$['))return _0x3a99d4(0x1cc)+_0x101455+_0x3a99d4(0x1c6)+_0x3b42a4[_0x3a99d4(0x1b8)](0x1);return'$.services['+_0x101455+_0x3a99d4(0x1ec)+_0x3b42a4;}function isServiceRegistryLike(_0x424399){const _0x20c291=a68_0x59eb;return isObjectRecord(_0x424399)&&_0x424399[_0x20c291(0x1d3)]===SERVICE_REGISTRY_SCHEMA_VERSION&&Array[_0x20c291(0x1f7)](_0x424399[_0x20c291(0x1d8)]);}function isObjectRecord(_0x3dd638){const _0x8e4f4e=a68_0x59eb;return Boolean(_0x3dd638)&&typeof _0x3dd638===_0x8e4f4e(0x1e7)&&!Array[_0x8e4f4e(0x1f7)](_0x3dd638);}function emptyServiceRegistryInspection(_0x44bdf1,_0x19d941,_0x3fb21b){return{'registryPath':_0x44bdf1,'exists':_0x3fb21b,'status':_0x19d941,'serviceCount':0x0,'commandCount':0x0,'services':[]};}function summarizeLocalServiceEntry(_0x383efe){const _0x403820=a68_0x59eb,_0x50be00=_0x383efe['normalizedManifest'],_0x5930a6=_0x50be00[_0x403820(0x1ea)][_0x403820(0x1c1)](_0x35cf9a=>({'path':_0x35cf9a['cliPath'],'description':_0x35cf9a[_0x403820(0x1c5)],'risk':_0x35cf9a[_0x403820(0x1b1)],'targetKind':_0x35cf9a['target']['kind'],'targetCommand':_0x35cf9a[_0x403820(0x1d1)][_0x403820(0x1b4)]}));return{'serviceCode':_0x383efe['serviceCode'],'name':_0x50be00[_0x403820(0x1fc)][_0x403820(0x1cb)],'description':_0x50be00[_0x403820(0x1fc)]['description'],'version':_0x383efe['version'],'importedAt':_0x383efe[_0x403820(0x1b2)],'source':_0x383efe[_0x403820(0x1c8)],'commandCount':_0x5930a6[_0x403820(0x1c4)],'commands':_0x5930a6};}function sha256(_0x4ca9c5){const _0x253a4e=a68_0x59eb;return createHash(_0x253a4e(0x1a9))[_0x253a4e(0x1be)](_0x4ca9c5)[_0x253a4e(0x1df)](_0x253a4e(0x1f6));}
|
|
1
|
+
import{createHash}from"node:crypto";import{existsSync,mkdirSync,readFileSync,renameSync,unlinkSync,writeFileSync}from"node:fs";import{homedir}from"node:os";import{dirname,resolve}from"node:path";import{normalizeServiceTreeManifest,validateServiceTreeManifest}from"@lovrabet/cli-framework";import{PRODUCT_CONFIG}from"../../constant/product.js";import{CliErrors}from"../../errors.js";import{adaptServiceTreeManifestForLegacyFramework}from"../../commands/service/function-name-adapter.js";export const SERVICE_REGISTRY_SCHEMA_VERSION=1;export const SERVICE_REGISTRY_FILE_NAME="service.json";export function getServiceRegistryPath(options={}){return resolve(options.homeDir??homedir(),PRODUCT_CONFIG.homeDirName,SERVICE_REGISTRY_FILE_NAME)}export function emptyServiceRegistry(){return{schemaVersion:SERVICE_REGISTRY_SCHEMA_VERSION,services:[]}}export function readServiceRegistry(options={}){const registryPath=getServiceRegistryPath(options);if(!existsSync(registryPath))return emptyServiceRegistry()
|
|
2
|
+
;try{const raw=readFileSync(registryPath,"utf8");if(!raw.trim())return emptyServiceRegistry();const parsed=JSON.parse(raw);if(parsed.schemaVersion!==SERVICE_REGISTRY_SCHEMA_VERSION){throw CliErrors.validation(`Unsupported service registry schemaVersion: ${String(parsed.schemaVersion)}`,`Remove or migrate ${registryPath}.`)}if(!Array.isArray(parsed.services))return emptyServiceRegistry();return{schemaVersion:SERVICE_REGISTRY_SCHEMA_VERSION,updatedAt:parsed.updatedAt,services:parsed.services}}catch(err){if(err instanceof Error&&err.name==="CliError")throw err;throw CliErrors.validation(`Invalid service registry JSON: ${registryPath}`,"Fix the JSON file or move it aside and import services again.")}}export function writeServiceRegistry(registry,options={}){const registryPath=getServiceRegistryPath(options);const parent=dirname(registryPath);if(!existsSync(parent)){mkdirSync(parent,{recursive:true})}const tempPath=`${registryPath}.tmp`;try{
|
|
3
|
+
writeFileSync(tempPath,`${JSON.stringify(registry,null,2)}\n`,{encoding:"utf8",mode:384});renameSync(tempPath,registryPath)}catch(err){try{unlinkSync(tempPath)}catch{}if(err?.code==="ENOENT"){throw CliErrors.validation(`Cannot write service registry: ${registryPath}`)}throw err}return registryPath}export function loadServiceManifestFromFile(filePath){const absolutePath=resolve(filePath);if(!existsSync(absolutePath)){throw CliErrors.validation(`Service manifest file not found: ${filePath}`)}let parsed;const raw=readFileSync(absolutePath,"utf8");try{parsed=JSON.parse(raw)}catch{throw CliErrors.validation(`Invalid service manifest JSON: ${filePath}`,"Fix the JSON syntax and run service validate again.")}const fileHash=sha256(raw);const manifests=extractLoadedServiceManifests(parsed,fileHash);const report=aggregateValidationReports(manifests);const first=manifests[0];return{filePath:absolutePath,hash:fileHash,kind:isServiceRegistryLike(parsed)?"registry":"manifest",
|
|
4
|
+
manifest:first?.manifest??parsed,report:report,normalizedManifest:manifests.length===1?first?.normalizedManifest:undefined,manifests:manifests}}export function importServiceManifest(filePath,options={}){const loaded=loadServiceManifestFromFile(filePath);if(!loaded.report.ok){throw CliErrors.validation(formatValidationFailure(loaded.report),"Fix the service manifest and run service validate again.")}if(loaded.manifests.length===0){throw CliErrors.validation("Service registry has no services to import.","Add at least one service manifest, then run service import again.")}const registry=readServiceRegistry(options);const now=(options.now??(()=>new Date))().toISOString();const entries=[];let imported=0;let updated=0;for(const manifest of loaded.manifests){if(!manifest.normalizedManifest)continue;const serviceCode=manifest.normalizedManifest.service.code;const entry={serviceCode:serviceCode,version:manifest.normalizedManifest.version,importedAt:now,source:{type:"file",path:loaded.filePath,
|
|
5
|
+
hash:manifest.sourceHash},manifest:manifest.manifest,normalizedManifest:manifest.normalizedManifest};const index=registry.services.findIndex(item=>item.serviceCode===serviceCode);if(index>=0){registry.services[index]=entry;updated++}else{registry.services.push(entry);imported++}entries.push(entry)}registry.services.sort((a,b)=>a.serviceCode.localeCompare(b.serviceCode));registry.updatedAt=now;const registryPath=writeServiceRegistry(registry,options);return{registryPath:registryPath,entry:entries[0],replaced:entries.length===1?updated===1:updated>0,entries:entries,imported:imported,updated:updated,serviceCount:registry.services.length}}export function exportServiceManifest(serviceCode,filePath,options={}){const registryPath=getServiceRegistryPath(options);const entry=getLocalServiceEntry(serviceCode,options);if(!entry){throw CliErrors.validation(`Local service not found: ${serviceCode}`,"Run lovrabet service list to see imported services.")}const absolutePath=resolve(filePath)
|
|
6
|
+
;const parent=dirname(absolutePath);if(!existsSync(parent)){mkdirSync(parent,{recursive:true})}writeFileSync(absolutePath,`${JSON.stringify(entry.manifest,null,2)}\n`,{encoding:"utf8",mode:384});return{registryPath:registryPath,filePath:absolutePath,entry:entry}}export function removeServiceManifest(serviceCode,options={}){const registry=readServiceRegistry(options);const normalizedCode=serviceCode.trim();const index=registry.services.findIndex(entry=>entry.serviceCode===normalizedCode);if(index<0){throw CliErrors.validation(`Local service not found: ${normalizedCode}`,"Run lovrabet service list to see imported services.")}const[entry]=registry.services.splice(index,1);const now=(options.now??(()=>new Date))().toISOString();registry.updatedAt=now;const registryPath=writeServiceRegistry(registry,options);return{registryPath:registryPath,entry:entry,serviceCount:registry.services.length}}export function listLocalServices(options={}){return readServiceRegistry(options).services}
|
|
7
|
+
export function getLocalServiceEntry(serviceCode,options={}){return readServiceRegistry(options).services.find(entry=>entry.serviceCode===serviceCode.trim())}export function listLocalServiceTrees(options={}){return readServiceRegistry(options).services.map(entry=>entry.normalizedManifest)}export function inspectServiceRegistry(options={}){const registryPath=getServiceRegistryPath(options);if(!existsSync(registryPath)){return emptyServiceRegistryInspection(registryPath,"missing",false)}try{const raw=readFileSync(registryPath,"utf8");if(!raw.trim()){return emptyServiceRegistryInspection(registryPath,"empty",true)}const parsed=JSON.parse(raw);if(parsed.schemaVersion!==SERVICE_REGISTRY_SCHEMA_VERSION){return{...emptyServiceRegistryInspection(registryPath,"invalid",true),schemaVersion:parsed.schemaVersion,message:`Unsupported schemaVersion: ${String(parsed.schemaVersion)}`}}if(!Array.isArray(parsed.services)){return{...emptyServiceRegistryInspection(registryPath,"invalid",true),
|
|
8
|
+
schemaVersion:SERVICE_REGISTRY_SCHEMA_VERSION,updatedAt:parsed.updatedAt,message:"services must be an array"}}const services=parsed.services.map(summarizeLocalServiceEntry);return{registryPath:registryPath,exists:true,status:"ok",schemaVersion:SERVICE_REGISTRY_SCHEMA_VERSION,updatedAt:parsed.updatedAt,serviceCount:services.length,commandCount:services.reduce((total,service)=>total+service.commandCount,0),services:services}}catch(err){return{...emptyServiceRegistryInspection(registryPath,"invalid",true),message:err instanceof Error?err.message:String(err)}}}export function formatValidationFailure(report){const lines=report.errors.map(issue=>`${issue.path}: ${issue.message}`);return`Service manifest validation failed:\n${lines.join("\n")}`}function extractLoadedServiceManifests(parsed,fileHash){if(!isServiceRegistryLike(parsed)){const manifest=parsed;const{manifest:frameworkManifest,errors:errors}=adaptServiceTreeManifestForLegacyFramework(manifest)
|
|
9
|
+
;const frameworkReport=validateServiceTreeManifest(frameworkManifest);const report=mergeValidationErrors(frameworkReport,errors);return[{manifest:manifest,report:report,normalizedManifest:report.ok?normalizeServiceTreeManifest(frameworkManifest):undefined,sourceHash:fileHash}]}return parsed.services.map((entry,index)=>{const manifest=isObjectRecord(entry)?entry.manifest:undefined;const{manifest:frameworkManifest,errors:errors}=adaptServiceTreeManifestForLegacyFramework(manifest);const frameworkReport=validateServiceTreeManifest(frameworkManifest);const report=mergeValidationErrors(frameworkReport,errors);const registryServiceCode=isObjectRecord(entry)&&typeof entry.serviceCode==="string"?entry.serviceCode:undefined;return{manifest:manifest,report:report,normalizedManifest:report.ok?normalizeServiceTreeManifest(frameworkManifest):undefined,sourceHash:sha256(`${JSON.stringify(manifest,null,2)}\n`),registryIndex:index,registryServiceCode:registryServiceCode}})}
|
|
10
|
+
function mergeValidationErrors(report,errors){const publicFrameworkErrors=report.errors.map(issue=>issue.message==="bff target requires bffCode, bffId, or scriptName."?{...issue,message:"bff target requires functionName."}:issue);const mergedErrors=[...errors,...publicFrameworkErrors];return{ok:mergedErrors.length===0,errors:mergedErrors,warnings:report.warnings}}function aggregateValidationReports(manifests){const errors=manifests.flatMap(manifest=>manifest.registryIndex===undefined?manifest.report.errors:manifest.report.errors.map(issue=>({...issue,path:prefixRegistryIssuePath(manifest.registryIndex,issue.path)})));const warnings=manifests.flatMap(manifest=>manifest.registryIndex===undefined?manifest.report.warnings:manifest.report.warnings.map(issue=>({...issue,path:prefixRegistryIssuePath(manifest.registryIndex,issue.path)})));return{ok:errors.length===0,errors:errors,warnings:warnings}}function prefixRegistryIssuePath(index,path){if(path==="$")return`$.services[${index}].manifest`
|
|
11
|
+
;if(path.startsWith("$."))return`$.services[${index}].manifest${path.slice(1)}`;if(path.startsWith("$["))return`$.services[${index}].manifest${path.slice(1)}`;return`$.services[${index}].manifest.${path}`}function isServiceRegistryLike(value){return isObjectRecord(value)&&value.schemaVersion===SERVICE_REGISTRY_SCHEMA_VERSION&&Array.isArray(value.services)}function isObjectRecord(value){return Boolean(value)&&typeof value==="object"&&!Array.isArray(value)}function emptyServiceRegistryInspection(registryPath,status,exists){return{registryPath:registryPath,exists:exists,status:status,serviceCount:0,commandCount:0,services:[]}}function summarizeLocalServiceEntry(entry){const tree=entry.normalizedManifest;const commands=tree.commands.map(command=>({path:command.cliPath,description:command.description,risk:command.risk,targetKind:command.target.kind,targetCommand:command.target.command}));return{serviceCode:entry.serviceCode,name:tree.service.name,description:tree.service.description,
|
|
12
|
+
version:entry.version,importedAt:entry.importedAt,source:entry.source,commandCount:commands.length,commands:commands}}function sha256(value){return createHash("sha256").update(value).digest("hex")}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{existsSync,lstatSync,mkdirSync,writeFileSync}from"node:fs";import{dirname,resolve}from"node:path";import{CliErrors}from"../../../errors.js";import{writeCliSideChannelLine}from"../../../utils/write-cli-side-channel.js";import{CREATE_NAME_FLAG,FORCE_FLAG,TARGET_FLAG,TYPE_FLAG}from"../flags.js";import{DEFAULT_SKILL_TARGET,renderSkillTemplate}from"../templates.js";export const createCommand={service:"skill",command:"create",description:"Create a local self-contained runtime Skill draft",risk:"read",requiresAuth:false,requiresAppCode:false,flags:[CREATE_NAME_FLAG,TYPE_FLAG,TARGET_FLAG,FORCE_FLAG],async dryRun(ctx){const plan=buildSkillCreatePlan(ctx.str("name"),ctx.str("type"),ctx.str("target"));return{method:"WRITE",url:plan.skillDir,body:{skillName:plan.rendered.skillName,type:plan.rendered.type,selfContained:true,files:plan.rendered.files.map(file=>file.path)},description:"Create a local runtime Skill draft without uploading or publishing it."}},async execute(ctx){
|
|
2
|
+
const plan=buildSkillCreatePlan(ctx.str("name"),ctx.str("type"),ctx.str("target"));writeSkillDraft(plan,ctx.bool("force"));return{ok:true,data:{skillName:plan.rendered.skillName,type:plan.rendered.type,dir:plan.skillDir,files:plan.rendered.files.map(file=>file.path)},message:`Created local Skill draft ${plan.rendered.skillName}`}}};function buildSkillCreatePlan(name,type,target){const explicitType=type.trim();const rendered=renderSkillTemplate({skillName:name,type:explicitType});if(!explicitType){writeCliSideChannelLine("Omitting --type is deprecated; defaulting to write for compatibility. Pass --type read or --type write explicitly.")}const targetRoot=resolve(normalizeSkillTarget(target));return{rendered:rendered,targetRoot:targetRoot,skillDir:resolve(targetRoot,rendered.skillName)}}function normalizeSkillTarget(target){return(target||DEFAULT_SKILL_TARGET).trim()||DEFAULT_SKILL_TARGET}function writeSkillDraft(plan,force){if(existsSync(plan.skillDir)){
|
|
3
|
+
const stat=lstatSync(plan.skillDir);if(!stat.isDirectory()||stat.isSymbolicLink()){throw CliErrors.validation(`Skill path already exists and is not a writable directory: ${plan.skillDir}`)}if(!force){throw CliErrors.validation(`Skill directory already exists: ${plan.skillDir}`,"Pass --force to overwrite generated template files.")}}for(const file of plan.rendered.files){const filePath=resolve(plan.skillDir,file.path);const parent=dirname(filePath);mkdirSync(parent,{recursive:true});if(existsSync(filePath)&&lstatSync(filePath).isSymbolicLink()){throw CliErrors.validation(`Refusing to overwrite symlink: ${filePath}`)}writeFileSync(filePath,file.content,"utf8")}}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{getRuntimeSkillVersionDiagram,putRuntimeSkillVersionDiagram,validateRuntimeSkillVersionDiagram}from"../../../core/api-client.js";import{CliErrors}from"../../../errors.js";import{readRequiredSkillDiagram}from"../diagram.js";import{DIAGRAM_FILE_FLAG,DIAGRAM_SCOPE_FLAG,DIAGRAM_SKILL_CODE_FLAG,DIAGRAM_VERSION_FLAG,EXPECTED_DIAGRAM_REVISION_FLAG,SOURCE_FINGERPRINT_FLAG}from"../flags.js";const TARGET_FLAGS=[DIAGRAM_SKILL_CODE_FLAG,DIAGRAM_VERSION_FLAG,DIAGRAM_SCOPE_FLAG];const WRITE_FLAGS=[...TARGET_FLAGS,SOURCE_FINGERPRINT_FLAG,EXPECTED_DIAGRAM_REVISION_FLAG,DIAGRAM_FILE_FLAG];function readDiagramTarget(ctx){const skillCode=ctx.str("skill-code").trim();const version=ctx.str("version").trim();const scope=ctx.str("scope");if(!skillCode||!version||scope!=="personal"&&scope!=="company"){throw CliErrors.validation("--skill-code, --version, and --scope personal|company are required.")}return{skillCode:skillCode,version:version,scope:scope}}async function readDiagramWriteInput(ctx){
|
|
2
|
+
const expectedDiagramRevision=ctx.num("expected-diagram-revision");const sourceFingerprint=ctx.str("source-fingerprint").trim();if(!Number.isInteger(expectedDiagramRevision)||expectedDiagramRevision<0){throw CliErrors.validation("--expected-diagram-revision must be a non-negative integer.")}if(!/^sha256:[0-9a-f]{64}$/.test(sourceFingerprint)){throw CliErrors.validation("--source-fingerprint must be lowercase sha256:<64 hex characters>.")}return{expectedDiagramRevision:expectedDiagramRevision,sourceFingerprint:sourceFingerprint,diagram:await readRequiredSkillDiagram(ctx.str("diagram-file"))}}export const diagramValidateCommand={service:"skill",command:"diagram-validate",description:"Validate a Mermaid diagram replacement for one exact Skill version",risk:"read",flags:WRITE_FLAGS,async execute(ctx){const target=readDiagramTarget(ctx);const result=await validateRuntimeSkillVersionDiagram(ctx.appCode,target.skillCode,target.version,target.scope,await readDiagramWriteInput(ctx));return{
|
|
3
|
+
ok:true,data:result,message:`Skill diagram validation passed for ${target.skillCode}@${target.version}.`}}};export const diagramPushCommand={service:"skill",command:"diagram-push",description:"Create or replace a Mermaid diagram for a specific Skill version",risk:"write",confirmationDescription:"Creates or replaces a Mermaid diagram for an exact Skill version. The write is rejected if the server version has changed. The confirmation UI does not show the diagram body.",flags:WRITE_FLAGS,async execute(ctx){const target=readDiagramTarget(ctx);const result=await putRuntimeSkillVersionDiagram(ctx.appCode,target.skillCode,target.version,target.scope,await readDiagramWriteInput(ctx));return{ok:true,data:result,message:result.action==="unchanged"?`Skill diagram for ${target.skillCode}@${target.version} is unchanged.`:`${result.action==="created"?"Created":"Updated"} Skill diagram for ${target.skillCode}@${target.version}.`}}};export const diagramShowCommand={service:"skill",
|
|
4
|
+
command:"diagram-show",description:"Show the current Mermaid diagram for one exact Skill version",risk:"read",flags:TARGET_FLAGS,async execute(ctx){const target=readDiagramTarget(ctx);const result=await getRuntimeSkillVersionDiagram(ctx.appCode,target.skillCode,target.version,target.scope);return{ok:true,data:result,message:result.found?`Found Skill diagram for ${target.skillCode}@${target.version}; next write expects revision ${result.expectedDiagramRevision}.`:`No Skill diagram is stored for ${target.skillCode}@${target.version}; first write expects revision ${result.expectedDiagramRevision}.`}}};
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../../errors.js";import{CODE_FLAG,FORCE_FLAG,PROJECT_TARGET_FLAG,SCOPE_FLAG}from"../flags.js";import{normalizeSyncScopes}from"../scopes.js";import{summarizeRuntimeSkill}from"../summary.js";const PACKAGE_DOWNLOAD_CONCURRENCY=4;export const installCommand={service:"skill",command:"install",description:"Install current-app business Skills into user-level Agent skill directories",risk:"read",requiresAuth:true,requiresAppCode:true,hasFormat:false,flags:[CODE_FLAG,SCOPE_FLAG,FORCE_FLAG,PROJECT_TARGET_FLAG],async execute(ctx){return syncRuntimeSkills(ctx)}};async function syncRuntimeSkills(ctx){const{downloadRuntimeSkillPackage:downloadRuntimeSkillPackage,listRuntimeSkills:listRuntimeSkills}=await(import("../../../core/api-client.js"))
|
|
2
|
+
;const{linkEffectiveRuntimeSkills:linkEffectiveRuntimeSkills,materializeRuntimeSkill:materializeRuntimeSkill,pruneStaleRuntimeSkillCache:pruneStaleRuntimeSkillCache,pruneStaleRuntimeSkillLinks:pruneStaleRuntimeSkillLinks,resolveRuntimeSkillInstallTarget:resolveRuntimeSkillInstallTarget,reuseMaterializedRuntimeSkill:reuseMaterializedRuntimeSkill}=await(import("../../../skills/runtime-skill-sync.js"));const code=ctx.str("code");const scopes=normalizeSyncScopes(ctx.str("scope"));const env=ctx.envName??"production";const accessKey=ctx.accessKey;const force=ctx.bool("force");if(!accessKey){throw CliErrors.authRequired("Business Skill installation requires authentication. Run `lovrabet auth login`, or use `lovrabet cli-skill install` for CLI Built-in Skill setup.")}const installTarget=resolveRuntimeSkillInstallTarget(ctx.appCode,ctx.bool("project")?"project":"global");const counterpartTarget=resolveRuntimeSkillInstallTarget(ctx.appCode,installTarget.scope==="project"?"global":"project")
|
|
3
|
+
;const remote=await listRuntimeSkills({appCode:ctx.appCode,scope:scopes.length===1?scopes[0]:"all",code:code.trim()||undefined,installableOnly:true});const personal=scopes.includes("personal")?remote.personal:[];const company=scopes.includes("company")?remote.company:[];const activeSkillCodes=new Set([...personal.map(skill=>skill.skillCode?.trim()).filter(item=>Boolean(item)),...company.map(skill=>skill.skillCode?.trim()).filter(item=>Boolean(item))]);const pruneSkillCodes=code.trim()?[code.trim()]:undefined;const shouldPruneLinks=scopes.length===2&&scopes.includes("personal")&&scopes.includes("company");const prunedLinks=shouldPruneLinks?pruneStaleRuntimeSkillLinks(installTarget,activeSkillCodes,pruneSkillCodes):[];const prunedCache=pruneStaleRuntimeSkillCache({env:env,accessKey:accessKey,appCode:ctx.appCode,activeSkillCodes:activeSkillCodes,pruneSkillCodes:pruneSkillCodes,scopes:scopes,protectedLinkRoots:counterpartTarget.skillRoots});const installItems=[...personal.map(skill=>({
|
|
4
|
+
skill:skill,scope:"personal"})),...company.map(skill=>({skill:skill,scope:"company"}))];const materialized=await mapConcurrent(installItems,PACKAGE_DOWNLOAD_CONCURRENCY,async({skill:skill,scope:scope})=>{const reused=reuseMaterializedRuntimeSkill(skill,scope,{env:env,accessKey:accessKey,appCode:ctx.appCode});if(reused)return reused;return materializeRuntimeSkill(skill,scope,{env:env,accessKey:accessKey,appCode:ctx.appCode,force:force,packageBytes:await downloadSkillPackage(skill,scope,ctx.appCode,downloadRuntimeSkillPackage)})});const links=linkEffectiveRuntimeSkills(materialized,installTarget);const linkCounts=countLinkActions(links);return{ok:true,data:{appCode:ctx.appCode,...installTarget.scope==="project"?{installTarget:{scope:installTarget.scope,skillRoots:[...installTarget.skillRoots]}}:{},personal:personal.length,company:company.length,materialized:materialized.length,links:{total:links.length,created:linkCounts.created??0,updated:linkCounts.updated??0,
|
|
5
|
+
unchanged:linkCounts.unchanged??0,skipped:0,conflicted:0},pruned:{links:prunedLinks.filter(item=>item.action==="removed").length,cacheDirs:prunedCache.filter(item=>item.action==="removed").length,skipped:[...prunedLinks,...prunedCache].filter(item=>item.action==="skipped").length},skills:{personal:personal.map(summarizeRuntimeSkill),company:company.map(summarizeRuntimeSkill)}},message:`Installed ${personal.length} personal and ${company.length} company Skill(s).`}}async function mapConcurrent(items,concurrency,operation){const results=new Array(items.length);let nextIndex=0;const workers=Array.from({length:Math.min(concurrency,items.length)},async()=>{while(nextIndex<items.length){const index=nextIndex;nextIndex+=1;results[index]=await operation(items[index])}});await Promise.all(workers);return results}async function downloadSkillPackage(skill,scope,appCode,downloadPackage){const version=skill.version?.trim()
|
|
6
|
+
;return version?downloadPackage(scope,skill.skillCode,appCode,version):downloadPackage(scope,skill.skillCode,appCode)}function countLinkActions(links){return links.reduce((acc,link)=>{acc[link.action]=(acc[link.action]??0)+1;return acc},{})}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../../errors.js";import{CODE_FLAG,LIST_SCOPE_FLAG,LOCAL_FLAG,PROJECT_TARGET_FLAG}from"../flags.js";import{listScopeToRemoteScope,listScopeToRuntimeScopes,normalizeListScope,shouldListScope}from"../scopes.js";import{summarizeLocalRuntimeSkill,summarizeRuntimeSkill}from"../summary.js";export const listCommand={service:"skill",command:"list",description:"List runtime Skills from remote or CLI-managed local cache",risk:"read",flags:[CODE_FLAG,LIST_SCOPE_FLAG,LOCAL_FLAG,PROJECT_TARGET_FLAG],async execute(ctx){const code=ctx.str("code");const scope=normalizeListScope(ctx.str("scope"));if(ctx.bool("local")){const accessKey=ctx.accessKey;if(!accessKey){throw CliErrors.authRequired()}const{listLocalRuntimeSkills:listLocalRuntimeSkills,resolveRuntimeSkillInstallTarget:resolveRuntimeSkillInstallTarget}=await(import("../../../skills/runtime-skill-sync.js"));const installTarget=resolveRuntimeSkillInstallTarget(ctx.appCode,ctx.bool("project")?"project":"global")
|
|
2
|
+
;const localItems=listLocalRuntimeSkills({env:ctx.envName??"production",accessKey:accessKey,appCode:ctx.appCode,scopes:listScopeToRuntimeScopes(scope),code:code.trim()||undefined},installTarget);const grouped=groupLocalRuntimeSkills(localItems);return{ok:true,data:{appCode:ctx.appCode,source:"local",...installTarget.scope==="project"?{installScope:installTarget.scope}:{},scope:scope,total:localItems.length,personal:grouped.personal.length,company:grouped.company.length,items:localItems.map(summarizeLocalRuntimeSkill),skills:{personal:grouped.personal.map(summarizeLocalRuntimeSkill),company:grouped.company.map(summarizeLocalRuntimeSkill)}},message:`Listed ${localItems.length} local Skill(s).`}}const{listRuntimeSkills:listRuntimeSkills}=await(import("../../../core/api-client.js"));const response=await listRuntimeSkills({appCode:ctx.appCode,scope:listScopeToRemoteScope(scope),code:code.trim()||undefined});const personal=shouldListScope(scope,"personal")?response.personal??[]:[]
|
|
3
|
+
;const company=shouldListScope(scope,"company")?response.company??[]:[];const items=[...personal,...company];return{ok:true,data:{appCode:ctx.appCode,source:"remote",scope:scope,total:items.length,personal:personal.length,company:company.length,items:items.map(summarizeRuntimeSkill),skills:{personal:personal.map(summarizeRuntimeSkill),company:company.map(summarizeRuntimeSkill)}},message:`Listed ${items.length} remote Skill(s).`}}};function groupLocalRuntimeSkills(items){return{personal:items.filter(item=>item.scope==="personal"),company:items.filter(item=>item.scope==="company"),builtin:items.filter(item=>item.scope==="builtin")}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{CONFIRM_WARNINGS_FLAG,DIAGRAM_FILE_FLAG,DIR_FLAG,PUSH_SCOPE_FLAG}from"../flags.js";import{skillPushDryRun,skillPushExecute}from"../push-execute.js";export const pushCommand={service:"skill",command:"push",description:"Push a local Skill directory to personal scope, or submit a company-scope version for review",risk:"write",confirmationDescription:"Reads local Skill content: personal scope is saved immediately; company scope submits a new version for review. The confirmation UI does not show the directory path or Skill body.",flags:[DIR_FLAG,DIAGRAM_FILE_FLAG,PUSH_SCOPE_FLAG,CONFIRM_WARNINGS_FLAG],dryRun:skillPushDryRun,execute:skillPushExecute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{DIR_FLAG,STRICT_FLAG}from"../flags.js";import{throwIfSkillValidationFailed,validateSkillDirectory}from"../validate.js";export const validateCommand={service:"skill",command:"validate",description:"Validate a local Skill directory as a self-contained delivery package",risk:"read",requiresAuth:false,requiresAppCode:false,flags:[DIR_FLAG,STRICT_FLAG],async execute(ctx){const strict=ctx.bool("strict");const report=validateSkillDirectory(ctx.str("dir"),{strict:strict});throwIfSkillValidationFailed(report,strict);return{ok:true,data:{dir:report.dir,type:report.type,errors:report.errors,warnings:report.warnings},message:"Skill validation passed."}}};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{existsSync,readFileSync,realpathSync,statSync}from"node:fs";import{resolve}from"node:path";import{JSDOM}from"jsdom";import{CliErrors}from"../../errors.js";let mermaidApiPromise;export async function readRequiredSkillDiagram(path){return(await readRequiredSkillDiagramInput(path)).diagram}export async function readRequiredSkillDiagramInput(path){const normalizedPath=path.trim();if(!normalizedPath){throw CliErrors.validation("--diagram-file is required when publishing a Skill version.","Generate a Mermaid flowchart and pass --diagram-file <path>, or use --diagram-file - for standard input.")}let source;let sourceFilePath;if(normalizedPath==="-"){try{source=readFileSync(0,"utf8")}catch{throw CliErrors.validation("Unable to read Mermaid flowchart from standard input.")}}else{const absolutePath=resolve(normalizedPath);if(!existsSync(absolutePath)){throw CliErrors.validation(`Mermaid flowchart file not found: ${absolutePath}`)}if(!statSync(absolutePath).isFile()){
|
|
2
|
+
throw CliErrors.validation(`Mermaid flowchart path is not a regular file: ${absolutePath}`)}sourceFilePath=realpathSync(absolutePath);source=readFileSync(sourceFilePath,"utf8")}return{diagram:{schemaVersion:1,mermaid:await validateAndCanonicalizeMermaid(source)},sourceFilePath:sourceFilePath}}export async function validateAndCanonicalizeMermaid(source){const mermaid=`${source.replace(/\r\n/g,"\n").replace(/\r/g,"\n").replace(/\n+$/,"")}\n`;try{const parser=await loadMermaidApi();await parser.parse(mermaid)}catch{throw diagramValidationError()}return mermaid}function loadMermaidApi(){mermaidApiPromise??=(async()=>{if(!("window"in globalThis)||!("document"in globalThis)){const dom=new JSDOM("");Object.defineProperties(globalThis,{window:{configurable:true,value:dom.window},document:{configurable:true,value:dom.window.document}})}return(await(import("mermaid"))).default})();return mermaidApiPromise}function diagramValidationError(){
|
|
3
|
+
return CliErrors.validation("Mermaid syntax validation failed.","Fix the Mermaid syntax reported by your editor or preview tool, then retry with the same file.")}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{DEFAULT_SKILL_TARGET,SKILL_NAME_PATTERN,SKILL_TYPES}from"./templates.js";export const CODE_FLAG={name:"code",type:"string",description:"Only target a specific runtime Skill code"};export const SCOPE_FLAG={name:"scope",type:"string",description:"Skill sync scope: all (personal/company), personal, or company",enum:["all","personal","company"]};export const PUSH_SCOPE_FLAG={name:"scope",type:"string",description:"Skill push target scope: personal saves immediately, company submits a new version for review",default:"personal",enum:["personal","company"]};export const LIST_SCOPE_FLAG={name:"scope",type:"string",description:"Skill list scope: all, personal, or company",enum:["all","personal","company"]};export const LOCAL_FLAG={name:"local",type:"boolean",description:"Read CLI-managed local Skill cache and links instead of remote lists"};export const DIR_FLAG={name:"dir",type:"string",required:true,description:"Local Skill directory containing SKILL.md"}
|
|
2
|
+
;export const DIAGRAM_FILE_FLAG={name:"diagram-file",type:"string",required:true,description:"UTF-8 Mermaid flowchart file; the selected file is excluded from the Skill package; use - for stdin"};export const DIAGRAM_SKILL_CODE_FLAG={name:"skill-code",type:"string",required:true,description:"Exact Skill code whose version diagram is being managed"};export const DIAGRAM_VERSION_FLAG={name:"version",type:"string",required:true,description:"Exact Skill version whose diagram is being managed"};export const DIAGRAM_SCOPE_FLAG={name:"scope",type:"string",required:true,enum:["personal","company"],description:"Exact Skill scope: personal or company"};export const SOURCE_FINGERPRINT_FLAG={name:"source-fingerprint",type:"string",required:true,description:"Server-reported SkillVersion source fingerprint",pattern:{regex:/^sha256:[0-9a-f]{64}$/,description:"a lowercase sha256:<64 hex characters> fingerprint"}};export const EXPECTED_DIAGRAM_REVISION_FLAG={name:"expected-diagram-revision",
|
|
3
|
+
type:"number",required:true,description:"Expected current diagram revision; use 0 for the first diagram"};export const CREATE_NAME_FLAG={name:"name",type:"string",required:true,description:"Skill name using lowercase letters, numbers, and hyphens",pattern:{regex:SKILL_NAME_PATTERN,description:"lowercase letters, numbers, and single hyphens"}};export const TYPE_FLAG={name:"type",type:"string",description:"Skill template type: pass read or write explicitly (omission is deprecated)",enum:[...SKILL_TYPES]};export const TARGET_FLAG={name:"target",type:"string",description:"Directory that will contain the generated Skill directory",default:DEFAULT_SKILL_TARGET};export const FORCE_FLAG={name:"force",type:"boolean",description:"Overwrite generated or CLI-managed Skill files when the target already exists"};export const PROJECT_TARGET_FLAG={name:"project",type:"boolean",description:"Use the current project's .agents/skills instead of user-level Agent Skill directories"}
|
|
4
|
+
;export const CONFIRM_WARNINGS_FLAG={name:"confirm-warnings",type:"boolean",description:"Confirm reviewed personal or company Skill publish warnings"};export const STRICT_FLAG={name:"strict",type:"boolean",description:"Compatibility flag; no extra checks are enabled"};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{createCommand}from"./commands/create.js";import{diagramPushCommand,diagramShowCommand,diagramValidateCommand}from"./commands/diagram.js";import{installCommand}from"./commands/install.js";import{listCommand}from"./commands/list.js";import{pushCommand}from"./commands/push.js";import{validateCommand}from"./commands/validate.js";export const skillDefinitions=[installCommand,createCommand,validateCommand,listCommand,pushCommand,diagramValidateCommand,diagramPushCommand,diagramShowCommand];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export function isPackageBackedManifest(files){return!!files&&typeof files==="object"&&!Array.isArray(files)&&typeof files.ossPath==="string"&&files.ossPath.length>0&&Array.isArray(files.files)}export function isMultiFileManifest(files){return!!files&&typeof files==="object"&&!Array.isArray(files)&&Array.isArray(files.files)&&files.files.some(file=>file.path!=="SKILL.md")}
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
(function(_0x201346,_0x2ce91a){const _0x391340=a79_0x3009,_0x40e39d=_0x201346();while(!![]){try{const _0x1b948f=parseInt(_0x391340(0xde))/0x1+-parseInt(_0x391340(0xe9))/0x2+parseInt(_0x391340(0xc8))/0x3*(-parseInt(_0x391340(0xc7))/0x4)+parseInt(_0x391340(0xb5))/0x5*(-parseInt(_0x391340(0xe0))/0x6)+-parseInt(_0x391340(0xf1))/0x7*(-parseInt(_0x391340(0xdc))/0x8)+parseInt(_0x391340(0xd3))/0x9*(parseInt(_0x391340(0xdb))/0xa)+-parseInt(_0x391340(0xb8))/0xb*(-parseInt(_0x391340(0xcf))/0xc);if(_0x1b948f===_0x2ce91a)break;else _0x40e39d['push'](_0x40e39d['shift']());}catch(_0x5e95c2){_0x40e39d['push'](_0x40e39d['shift']());}}}(a79_0x295f,0xcd293));import{CliErrors}from'../../errors.js';import{isMultiFileManifest,isPackageBackedManifest}from'./manifest-helpers.js';function a79_0x3009(_0x45657d,_0x332c51){_0x45657d=_0x45657d-0xb5;const _0x295f24=a79_0x295f();let _0x3009ee=_0x295f24[_0x45657d];return _0x3009ee;}import{remotePersonalReadOptions,remoteMissingCompanyReadOptions,remoteMissingPersonalReadOptions}from'./push-flow-helpers.js';import{allowRetargetArgs,buildRetargetWarning,remoteFirstMetadataOptions,resolvePushScope,runRemoteContentPreflight,throwIfBuiltinPushTarget,throwIfUnconfirmedPublishWarnings,throwIfPublishValidationFailed}from'./push-flow-helpers.js';function a79_0x295f(){const _0x5e9906=['str','company','Submitted\x20company\x20Skill\x20','payload','submitted','3425848IKcKMM','3WHQaPl','diagramValidated','../../skills/runtime-skill-sync.js','trim','../../core/api-client.js','unknown','/publish/validate','49836NpBQLX','/api/cli/v1/skills/','Validate\x20a\x20personal\x20Skill\x20push\x20package\x20without\x20creating\x20or\x20updating\x20a\x20remote\x20Skill.','valid','14220NgRkdZ','appCode','diagram-file','Validate\x20a\x20company\x20Skill\x20push\x20package\x20without\x20creating\x20a\x20version\x20or\x20review\x20task.','PRIVATE','scope','savedSkill','authRequired','7210QBOCpx','904lRbnNr','\x20has\x20scope=\x22','1126413ZvCdvI','files','49974bopjkN','\x20version\x20','(unknown)','validation','skillCode','NAMESPACE_ONLY','resolvedVersion','metadata','\x20is\x20already\x20published\x20and\x20content\x20is\x20identical','833998HRMeAN','existing','personal','bool','accessKey','input','appcode','version','22001GYIFAm','965tYMhmH','errors','frontmatterDisplayName','2915OnjkTq','Created\x20personal\x20Skill\x20','Personal','confirmWarnings','publishInput','dir','\x20Skill\x20','resolvedSlug','warnings','remoteForPreflight'];a79_0x295f=function(){return _0x5e9906;};return a79_0x295f();}import{withRetargetExistingMetadata}from'./push-retarget.js';import{summarizeRuntimeSkill}from'./summary.js';import{readRequiredSkillDiagramInput}from'./diagram.js';import{throwIfSkillValidationFailed,validateSkillDirectory}from'./validate.js';export async function skillPushDryRun(_0x58099e){const _0x47654a=a79_0x3009,{getRuntimeSkillByCode:_0x48589b,validateRuntimeSkillPublish:_0x500d7d}=await import(_0x47654a(0xcc)),{readPushDirectory:_0x526ead,resolvePushDirectoryIdentity:_0xbd5e8e}=await import(_0x47654a(0xca));if(!_0x58099e[_0x47654a(0xed)])throw CliErrors[_0x47654a(0xda)]();const _0x4c76ce=resolvePushScope(_0x58099e),_0x3a736d=validateSkillDirectory(_0x58099e[_0x47654a(0xc2)](_0x47654a(0xbd)));throwIfSkillValidationFailed(_0x3a736d);const {diagram:_0xb0db28,sourceFilePath:_0x2a5f2f}=await readRequiredSkillDiagramInput(_0x58099e[_0x47654a(0xc2)]('diagram-file')),_0x1e612b=diagramPackageExclusion(_0x2a5f2f),_0x5f005b=_0xbd5e8e(_0x3a736d[_0x47654a(0xbd)],_0x58099e[_0x47654a(0xd4)],remoteFirstMetadataOptions()),_0x5aee80=await _0x48589b(_0x58099e[_0x47654a(0xd4)],_0x5f005b[_0x47654a(0xe4)]);throwIfBuiltinPushTarget(_0x5aee80);if(_0x4c76ce===_0x47654a(0xc3)){const _0x3bad12=_0x526ead(_0x3a736d[_0x47654a(0xbd)],_0x58099e['appCode'],{...remoteMissingCompanyReadOptions(),..._0x1e612b}),_0x100d0a=await _0x500d7d(_0x58099e[_0x47654a(0xd4)],withDiagram(_0x3bad12[_0x47654a(0xee)],_0xb0db28),{'visibility':'NAMESPACE_ONLY'});return{'method':'POST','url':'/api/cli/v1/skills/'+_0x58099e['appCode']+_0x47654a(0xce),'body':{'skillCode':_0x3bad12['skillCode'],'visibility':_0x47654a(0xe5),'valid':_0x100d0a[_0x47654a(0xd2)],'errors':_0x100d0a[_0x47654a(0xb6)],'warnings':_0x100d0a[_0x47654a(0xc0)],'resolvedSlug':_0x100d0a[_0x47654a(0xbf)],'resolvedVersion':_0x100d0a['resolvedVersion'],'diagramValidated':_0x100d0a['diagramValidated']},'description':_0x47654a(0xd6)};}if(_0x5aee80&&_0x5aee80[_0x47654a(0xd8)]!==_0x47654a(0xeb))throw CliErrors[_0x47654a(0xe3)]('Only\x20personal\x20Skills\x20can\x20be\x20pushed;\x20remote\x20Skill\x20'+_0x5f005b[_0x47654a(0xe4)]+_0x47654a(0xdd)+(_0x5aee80[_0x47654a(0xd8)]??_0x47654a(0xcd))+'\x22.');const _0x4056ac=_0x526ead(_0x3a736d[_0x47654a(0xbd)],_0x58099e[_0x47654a(0xd4)],{..._0x5aee80?remotePersonalReadOptions(!![]):remoteMissingPersonalReadOptions(),..._0x1e612b}),_0x477c92=await _0x500d7d(_0x58099e[_0x47654a(0xd4)],withDiagram(_0x4056ac[_0x47654a(0xee)],_0xb0db28),{'visibility':_0x47654a(0xd7)});return{'method':'POST','url':_0x47654a(0xd0)+_0x58099e[_0x47654a(0xd4)]+_0x47654a(0xce),'body':{'skillCode':_0x4056ac[_0x47654a(0xe4)],'visibility':_0x47654a(0xd7),'valid':_0x477c92[_0x47654a(0xd2)],'errors':_0x477c92[_0x47654a(0xb6)],'warnings':_0x477c92[_0x47654a(0xc0)],'resolvedSlug':_0x477c92['resolvedSlug'],'resolvedVersion':_0x477c92[_0x47654a(0xe6)],'diagramValidated':_0x477c92[_0x47654a(0xc9)]},'description':_0x47654a(0xd1)};}export async function skillPushExecute(_0x1bdd8d){const _0x2a8449=a79_0x3009,{createPersonalRuntimeSkill:_0xbc08fc,downloadRuntimeSkillPackage:_0x5bf479,getRuntimeSkillByCode:_0x2ebdd3,publishCompanyRuntimeSkill:_0x1c9196,updatePersonalRuntimeSkill:_0x27c29a,validateRuntimeSkillPublish:_0x440c9b}=await import(_0x2a8449(0xcc)),{verifyRuntimeSkillPackage:_0x300380,verifyRuntimeSkillBundle:_0x26e71c,readPushDirectory:_0x452a20,refreshPushDirectoryMetadataFromRemote:_0x4f4106,recordPushedRuntimeSkill:_0x3986b4,resolvePushDirectoryIdentity:_0x38584d}=await import('../../skills/runtime-skill-sync.js');if(!_0x1bdd8d[_0x2a8449(0xed)])throw CliErrors['authRequired']();const _0x6fc7b4=resolvePushScope(_0x1bdd8d),_0x1faaa6=_0x1bdd8d['bool']('confirm-warnings')||_0x1bdd8d[_0x2a8449(0xec)](_0x2a8449(0xbb)),_0x262a3d=validateSkillDirectory(_0x1bdd8d[_0x2a8449(0xc2)](_0x2a8449(0xbd)));throwIfSkillValidationFailed(_0x262a3d);const {diagram:_0x5f58aa,sourceFilePath:_0x9dcc42}=await readRequiredSkillDiagramInput(_0x1bdd8d[_0x2a8449(0xc2)](_0x2a8449(0xd5))),_0x2891e9=diagramPackageExclusion(_0x9dcc42),_0x3b7ba9=_0x262a3d[_0x2a8449(0xbd)];let _0x42ee7a;if(_0x6fc7b4===_0x2a8449(0xc3)){const _0x1bdd56=_0x38584d(_0x3b7ba9,_0x1bdd8d[_0x2a8449(0xd4)],remoteFirstMetadataOptions()),_0x20fcf8=await _0x2ebdd3(_0x1bdd8d[_0x2a8449(0xd4)],_0x1bdd56[_0x2a8449(0xe4)]);throwIfBuiltinPushTarget(_0x20fcf8);if(_0x20fcf8)_0x4f4106(_0x3b7ba9,_0x20fcf8,_0x1bdd8d[_0x2a8449(0xd4)]);const _0x261c86=_0x452a20(_0x3b7ba9,_0x1bdd8d[_0x2a8449(0xd4)],{..._0x20fcf8?{'targetScope':_0x2a8449(0xc3),'ignoreInvalidMetadata':!![]}:remoteMissingCompanyReadOptions(),..._0x2891e9});_0x42ee7a={'scope':_0x2a8449(0xc3),'payload':_0x261c86,'publishInput':withDiagram(_0x261c86[_0x2a8449(0xee)],_0x5f58aa),'remoteForPreflight':_0x20fcf8,'warnings':[]};}else{const _0x274e16=_0x1bdd8d[_0x2a8449(0xc2)](_0x2a8449(0xef))[_0x2a8449(0xcb)](),_0x431236=Boolean(_0x274e16),_0x137e62=allowRetargetArgs(_0x431236),_0x158b73=_0x38584d(_0x3b7ba9,_0x1bdd8d['appCode'],{...remoteFirstMetadataOptions(),..._0x137e62[0x0]}),_0x32efd7=await _0x2ebdd3(_0x1bdd8d[_0x2a8449(0xd4)],_0x158b73[_0x2a8449(0xe4)]);throwIfBuiltinPushTarget(_0x32efd7);if(_0x32efd7){if(_0x32efd7[_0x2a8449(0xd8)]!=='personal'){if(_0x431236)throw CliErrors['validation']('Only\x20personal\x20Skills\x20can\x20be\x20pushed;\x20remote\x20Skill\x20'+_0x158b73[_0x2a8449(0xe4)]+'\x20has\x20scope=\x22'+(_0x32efd7['scope']??'unknown')+'\x22.');_0x4f4106(_0x3b7ba9,_0x32efd7,_0x1bdd8d['appCode']);}else!_0x431236&&_0x4f4106(_0x3b7ba9,_0x32efd7,_0x1bdd8d[_0x2a8449(0xd4)]);}const _0x2dfa7c=_0x452a20(_0x3b7ba9,_0x1bdd8d['appCode'],{..._0x32efd7?remotePersonalReadOptions(_0x431236,_0x137e62[0x0]):remoteMissingPersonalReadOptions(_0x137e62[0x0]),..._0x2891e9}),_0x55eac5=_0x32efd7?.['scope']===_0x2a8449(0xeb)&&_0x32efd7[_0x2a8449(0xe4)]===_0x2dfa7c[_0x2a8449(0xe4)]?_0x32efd7:undefined,_0x73a318=_0x431236&&_0x55eac5?withRetargetExistingMetadata(_0x2dfa7c[_0x2a8449(0xee)],_0x55eac5,{'preferInputSkillName':Boolean(_0x2dfa7c[_0x2a8449(0xb7)])}):_0x2dfa7c[_0x2a8449(0xee)],_0x57e5d3=_0x431236?buildRetargetWarning(_0x158b73[_0x2a8449(0xe7)],_0x1bdd8d[_0x2a8449(0xd4)]):[];_0x42ee7a={'scope':_0x2a8449(0xeb),'payload':_0x2dfa7c,'publishInput':withDiagram(_0x73a318,_0x5f58aa),'remoteForPreflight':_0x55eac5,'existing':_0x55eac5,'warnings':[..._0x262a3d[_0x2a8449(0xc0)],..._0x57e5d3]};}const _0x4c1870=await runRemoteContentPreflight({'scope':_0x42ee7a[_0x2a8449(0xd8)],'remote':_0x42ee7a[_0x2a8449(0xc1)],'publishInput':_0x42ee7a[_0x2a8449(0xbc)],'skillCode':_0x42ee7a[_0x2a8449(0xc5)][_0x2a8449(0xe4)],'appCode':_0x1bdd8d['appCode'],'downloadRuntimeSkillPackage':_0x5bf479,'verifyRuntimeSkillBundle':_0x26e71c});if(_0x4c1870['status']==='identical')return _0x42ee7a[_0x2a8449(0xd8)]===_0x2a8449(0xc3)?_0x3986b4(_0x3b7ba9,_0x4c1870[_0x2a8449(0xd9)],_0x1bdd8d['appCode'],{'scope':'company'}):_0x3986b4(_0x3b7ba9,_0x4c1870[_0x2a8449(0xd9)],_0x1bdd8d[_0x2a8449(0xd4)]),{'ok':!![],'data':{...summarizeRuntimeSkill(_0x4c1870[_0x2a8449(0xd9)]),'scope':_0x42ee7a[_0x2a8449(0xd8)],..._0x42ee7a[_0x2a8449(0xd8)]===_0x2a8449(0xeb)?{'warnings':_0x42ee7a[_0x2a8449(0xc0)]}:{},'alreadyPublished':!![],'contentIdentical':!![],'diagramSubmitted':![]},'message':scopeLabel(_0x42ee7a[_0x2a8449(0xd8)])+_0x2a8449(0xbe)+_0x42ee7a[_0x2a8449(0xc5)]['skillCode']+_0x2a8449(0xe8)};if(_0x42ee7a[_0x2a8449(0xd8)]===_0x2a8449(0xc3)){const _0x5d4c1a=await _0x440c9b(_0x1bdd8d[_0x2a8449(0xd4)],_0x42ee7a[_0x2a8449(0xbc)],{'visibility':'NAMESPACE_ONLY'});throwIfPublishValidationFailed(_0x2a8449(0xc3),_0x42ee7a[_0x2a8449(0xc5)][_0x2a8449(0xe4)],_0x5d4c1a),throwIfUnconfirmedPublishWarnings(_0x2a8449(0xc3),_0x42ee7a['payload'][_0x2a8449(0xe4)],_0x5d4c1a[_0x2a8449(0xc0)],_0x1faaa6);const _0x6eb832=await _0x1c9196(_0x1bdd8d[_0x2a8449(0xd4)],_0x42ee7a[_0x2a8449(0xbc)],{'confirmWarnings':_0x1faaa6});return _0x3986b4(_0x3b7ba9,{..._0x6eb832,'files':_0x42ee7a[_0x2a8449(0xbc)][_0x2a8449(0xdf)]},_0x1bdd8d[_0x2a8449(0xd4)],{'scope':_0x2a8449(0xc3)}),{'ok':!![],'data':{...summarizeRuntimeSkill(_0x6eb832),'scope':_0x2a8449(0xc3),'reviewState':_0x2a8449(0xc6),'submittedForReview':!![],'diagramBound':!![],'validation':{'warnings':_0x5d4c1a['warnings']}},'message':_0x2a8449(0xc4)+_0x42ee7a[_0x2a8449(0xc5)][_0x2a8449(0xe4)]+_0x2a8449(0xe1)+(_0x6eb832[_0x2a8449(0xf0)]??_0x2a8449(0xe2))+'\x20for\x20review'};}const _0x2e6669=await _0x440c9b(_0x1bdd8d[_0x2a8449(0xd4)],_0x42ee7a['publishInput'],{'visibility':_0x2a8449(0xd7)});throwIfPublishValidationFailed(_0x2a8449(0xeb),_0x42ee7a['payload']['skillCode'],_0x2e6669),throwIfUnconfirmedPublishWarnings('personal',_0x42ee7a[_0x2a8449(0xc5)][_0x2a8449(0xe4)],_0x2e6669['warnings'],_0x1faaa6);const _0x39b1ae={'confirmWarnings':_0x1faaa6},_0x19a320=_0x42ee7a[_0x2a8449(0xea)]?await _0x27c29a(_0x42ee7a[_0x2a8449(0xc5)]['skillCode'],_0x1bdd8d[_0x2a8449(0xd4)],_0x42ee7a[_0x2a8449(0xbc)],_0x39b1ae):await _0xbc08fc(_0x1bdd8d[_0x2a8449(0xd4)],_0x42ee7a[_0x2a8449(0xbc)],_0x39b1ae);let _0x1e7dbb=_0x19a320;if(isMultiFileManifest(_0x42ee7a[_0x2a8449(0xbc)]['files'])){const _0x2da424=await _0x5bf479('personal',_0x19a320['skillCode']||_0x42ee7a[_0x2a8449(0xc5)][_0x2a8449(0xe4)],_0x1bdd8d['appCode']);_0x26e71c(_0x42ee7a[_0x2a8449(0xbc)][_0x2a8449(0xdf)],_0x2da424),_0x1e7dbb={..._0x19a320,'files':_0x42ee7a[_0x2a8449(0xbc)][_0x2a8449(0xdf)]};}else{if(isPackageBackedManifest(_0x19a320[_0x2a8449(0xdf)])){const _0x10da40=await _0x5bf479(_0x2a8449(0xeb),_0x19a320[_0x2a8449(0xe4)]||_0x42ee7a[_0x2a8449(0xc5)][_0x2a8449(0xe4)],_0x1bdd8d[_0x2a8449(0xd4)]);_0x300380(_0x19a320[_0x2a8449(0xdf)],_0x10da40);}}return _0x3986b4(_0x3b7ba9,_0x1e7dbb,_0x1bdd8d[_0x2a8449(0xd4)]),{'ok':!![],'data':{...summarizeRuntimeSkill(_0x19a320),'warnings':_0x42ee7a[_0x2a8449(0xc0)],'validation':{'warnings':_0x2e6669[_0x2a8449(0xc0)]},'diagramBound':!![]},'message':_0x42ee7a[_0x2a8449(0xea)]?'Updated\x20personal\x20Skill\x20'+_0x42ee7a[_0x2a8449(0xc5)][_0x2a8449(0xe4)]:_0x2a8449(0xb9)+_0x42ee7a[_0x2a8449(0xc5)][_0x2a8449(0xe4)]};}function scopeLabel(_0x79e74c){const _0x36b35c=a79_0x3009;return _0x79e74c===_0x36b35c(0xc3)?'Company':_0x36b35c(0xba);}function withDiagram(_0x5610a5,_0x2256b1){return{..._0x5610a5,'diagram':_0x2256b1};}function diagramPackageExclusion(_0x35da74){return _0x35da74?{'excludedFilePaths':[_0x35da74]}:{};}
|
|
1
|
+
import{CliErrors}from"../../errors.js";import{isMultiFileManifest,isPackageBackedManifest}from"./manifest-helpers.js";import{remotePersonalReadOptions,remoteMissingCompanyReadOptions,remoteMissingPersonalReadOptions}from"./push-flow-helpers.js";import{allowRetargetArgs,buildRetargetWarning,remoteFirstMetadataOptions,resolvePushScope,runRemoteContentPreflight,throwIfBuiltinPushTarget,throwIfUnconfirmedPublishWarnings,throwIfPublishValidationFailed}from"./push-flow-helpers.js";import{withRetargetExistingMetadata}from"./push-retarget.js";import{summarizeRuntimeSkill}from"./summary.js";import{readRequiredSkillDiagramInput}from"./diagram.js";import{throwIfSkillValidationFailed,validateSkillDirectory}from"./validate.js";export async function skillPushDryRun(ctx){const{getRuntimeSkillByCode:getRuntimeSkillByCode,validateRuntimeSkillPublish:validateRuntimeSkillPublish}=await(import("../../core/api-client.js"))
|
|
2
|
+
;const{readPushDirectory:readPushDirectory,resolvePushDirectoryIdentity:resolvePushDirectoryIdentity}=await(import("../../skills/runtime-skill-sync.js"));if(!ctx.accessKey)throw CliErrors.authRequired();const scope=resolvePushScope(ctx);const validationReport=validateSkillDirectory(ctx.str("dir"));throwIfSkillValidationFailed(validationReport);const{diagram:diagram,sourceFilePath:diagramFilePath}=await readRequiredSkillDiagramInput(ctx.str("diagram-file"));const packageExclusion=diagramPackageExclusion(diagramFilePath);const identity=resolvePushDirectoryIdentity(validationReport.dir,ctx.appCode,remoteFirstMetadataOptions());const remote=await getRuntimeSkillByCode(ctx.appCode,identity.skillCode);throwIfBuiltinPushTarget(remote);if(scope==="company"){const payload=readPushDirectory(validationReport.dir,ctx.appCode,{...remoteMissingCompanyReadOptions(),...packageExclusion});const validation=await validateRuntimeSkillPublish(ctx.appCode,withDiagram(payload.input,diagram),{
|
|
3
|
+
visibility:"NAMESPACE_ONLY"});return{method:"POST",url:`/api/cli/v1/skills/${ctx.appCode}/publish/validate`,body:{skillCode:payload.skillCode,visibility:"NAMESPACE_ONLY",valid:validation.valid,errors:validation.errors,warnings:validation.warnings,resolvedSlug:validation.resolvedSlug,resolvedVersion:validation.resolvedVersion,diagramValidated:validation.diagramValidated},description:"Validate a company Skill push package without creating a version or review task."}}if(remote&&remote.scope!=="personal"){throw CliErrors.validation(`Only personal Skills can be pushed; remote Skill ${identity.skillCode} has scope="${remote.scope??"unknown"}".`)}const payload=readPushDirectory(validationReport.dir,ctx.appCode,{...remote?remotePersonalReadOptions(true):remoteMissingPersonalReadOptions(),...packageExclusion});const validation=await validateRuntimeSkillPublish(ctx.appCode,withDiagram(payload.input,diagram),{visibility:"PRIVATE"});return{method:"POST",
|
|
4
|
+
url:`/api/cli/v1/skills/${ctx.appCode}/publish/validate`,body:{skillCode:payload.skillCode,visibility:"PRIVATE",valid:validation.valid,errors:validation.errors,warnings:validation.warnings,resolvedSlug:validation.resolvedSlug,resolvedVersion:validation.resolvedVersion,diagramValidated:validation.diagramValidated},description:"Validate a personal Skill push package without creating or updating a remote Skill."}}export async function skillPushExecute(ctx){const{createPersonalRuntimeSkill:createPersonalRuntimeSkill,downloadRuntimeSkillPackage:downloadRuntimeSkillPackage,getRuntimeSkillByCode:getRuntimeSkillByCode,publishCompanyRuntimeSkill:publishCompanyRuntimeSkill,updatePersonalRuntimeSkill:updatePersonalRuntimeSkill,validateRuntimeSkillPublish:validateRuntimeSkillPublish}=await(import("../../core/api-client.js"))
|
|
5
|
+
;const{verifyRuntimeSkillPackage:verifyRuntimeSkillPackage,verifyRuntimeSkillBundle:verifyRuntimeSkillBundle,readPushDirectory:readPushDirectory,refreshPushDirectoryMetadataFromRemote:refreshPushDirectoryMetadataFromRemote,recordPushedRuntimeSkill:recordPushedRuntimeSkill,resolvePushDirectoryIdentity:resolvePushDirectoryIdentity}=await(import("../../skills/runtime-skill-sync.js"));if(!ctx.accessKey)throw CliErrors.authRequired();const scope=resolvePushScope(ctx);const confirmWarnings=ctx.bool("confirm-warnings")||ctx.bool("confirmWarnings");const validationReport=validateSkillDirectory(ctx.str("dir"));throwIfSkillValidationFailed(validationReport);const{diagram:diagram,sourceFilePath:diagramFilePath}=await readRequiredSkillDiagramInput(ctx.str("diagram-file"));const packageExclusion=diagramPackageExclusion(diagramFilePath);const pushDir=validationReport.dir;let plan;if(scope==="company"){const identity=resolvePushDirectoryIdentity(pushDir,ctx.appCode,remoteFirstMetadataOptions())
|
|
6
|
+
;const remote=await getRuntimeSkillByCode(ctx.appCode,identity.skillCode);throwIfBuiltinPushTarget(remote);if(remote)refreshPushDirectoryMetadataFromRemote(pushDir,remote,ctx.appCode);const payload=readPushDirectory(pushDir,ctx.appCode,{...remote?{targetScope:"company",ignoreInvalidMetadata:true}:remoteMissingCompanyReadOptions(),...packageExclusion});plan={scope:"company",payload:payload,publishInput:withDiagram(payload.input,diagram),remoteForPreflight:remote,warnings:[]}}else{const explicitAppCode=ctx.str("appcode").trim();const allowRetarget=Boolean(explicitAppCode);const retargetArgs=allowRetargetArgs(allowRetarget);const identity=resolvePushDirectoryIdentity(pushDir,ctx.appCode,{...remoteFirstMetadataOptions(),...retargetArgs[0]});const remote=await getRuntimeSkillByCode(ctx.appCode,identity.skillCode);throwIfBuiltinPushTarget(remote);if(remote){if(remote.scope!=="personal"){if(allowRetarget){
|
|
7
|
+
throw CliErrors.validation(`Only personal Skills can be pushed; remote Skill ${identity.skillCode} has scope="${remote.scope??"unknown"}".`)}refreshPushDirectoryMetadataFromRemote(pushDir,remote,ctx.appCode)}else if(!allowRetarget){refreshPushDirectoryMetadataFromRemote(pushDir,remote,ctx.appCode)}}const payload=readPushDirectory(pushDir,ctx.appCode,{...remote?remotePersonalReadOptions(allowRetarget,retargetArgs[0]):remoteMissingPersonalReadOptions(retargetArgs[0]),...packageExclusion});const existing=remote?.scope==="personal"&&remote.skillCode===payload.skillCode?remote:undefined;const packagePublishInput=allowRetarget&&existing?withRetargetExistingMetadata(payload.input,existing,{preferInputSkillName:Boolean(payload.frontmatterDisplayName)}):payload.input;const retargetWarning=allowRetarget?buildRetargetWarning(identity.metadata,ctx.appCode):[];plan={scope:"personal",payload:payload,publishInput:withDiagram(packagePublishInput,diagram),remoteForPreflight:existing,existing:existing,
|
|
8
|
+
warnings:[...validationReport.warnings,...retargetWarning]}}const contentPreflight=await runRemoteContentPreflight({scope:plan.scope,remote:plan.remoteForPreflight,publishInput:plan.publishInput,skillCode:plan.payload.skillCode,appCode:ctx.appCode,downloadRuntimeSkillPackage:downloadRuntimeSkillPackage,verifyRuntimeSkillBundle:verifyRuntimeSkillBundle});if(contentPreflight.status==="identical"){if(plan.scope==="company"){recordPushedRuntimeSkill(pushDir,contentPreflight.savedSkill,ctx.appCode,{scope:"company"})}else{recordPushedRuntimeSkill(pushDir,contentPreflight.savedSkill,ctx.appCode)}return{ok:true,data:{...summarizeRuntimeSkill(contentPreflight.savedSkill),scope:plan.scope,...plan.scope==="personal"?{warnings:plan.warnings}:{},alreadyPublished:true,contentIdentical:true,diagramSubmitted:false},message:`${scopeLabel(plan.scope)} Skill ${plan.payload.skillCode} is already published and content is identical`}}if(plan.scope==="company"){
|
|
9
|
+
const validation=await validateRuntimeSkillPublish(ctx.appCode,plan.publishInput,{visibility:"NAMESPACE_ONLY"});throwIfPublishValidationFailed("company",plan.payload.skillCode,validation);throwIfUnconfirmedPublishWarnings("company",plan.payload.skillCode,validation.warnings,confirmWarnings);const saved=await publishCompanyRuntimeSkill(ctx.appCode,plan.publishInput,{confirmWarnings:confirmWarnings});recordPushedRuntimeSkill(pushDir,{...saved,files:plan.publishInput.files},ctx.appCode,{scope:"company"});return{ok:true,data:{...summarizeRuntimeSkill(saved),scope:"company",reviewState:"submitted",submittedForReview:true,diagramBound:true,validation:{warnings:validation.warnings}},message:`Submitted company Skill ${plan.payload.skillCode} version ${saved.version??"(unknown)"} for review`}}const validation=await validateRuntimeSkillPublish(ctx.appCode,plan.publishInput,{visibility:"PRIVATE"});throwIfPublishValidationFailed("personal",plan.payload.skillCode,validation)
|
|
10
|
+
;throwIfUnconfirmedPublishWarnings("personal",plan.payload.skillCode,validation.warnings,confirmWarnings);const personalPublishOptions={confirmWarnings:confirmWarnings};const saved=plan.existing?await updatePersonalRuntimeSkill(plan.payload.skillCode,ctx.appCode,plan.publishInput,personalPublishOptions):await createPersonalRuntimeSkill(ctx.appCode,plan.publishInput,personalPublishOptions);let savedForLocalRecord=saved;if(isMultiFileManifest(plan.publishInput.files)){const packageBytes=await downloadRuntimeSkillPackage("personal",saved.skillCode||plan.payload.skillCode,ctx.appCode);verifyRuntimeSkillBundle(plan.publishInput.files,packageBytes);savedForLocalRecord={...saved,files:plan.publishInput.files}}else if(isPackageBackedManifest(saved.files)){const packageBytes=await downloadRuntimeSkillPackage("personal",saved.skillCode||plan.payload.skillCode,ctx.appCode);verifyRuntimeSkillPackage(saved.files,packageBytes)}recordPushedRuntimeSkill(pushDir,savedForLocalRecord,ctx.appCode);return{
|
|
11
|
+
ok:true,data:{...summarizeRuntimeSkill(saved),warnings:plan.warnings,validation:{warnings:validation.warnings},diagramBound:true},message:plan.existing?`Updated personal Skill ${plan.payload.skillCode}`:`Created personal Skill ${plan.payload.skillCode}`}}function scopeLabel(scope){return scope==="company"?"Company":"Personal"}function withDiagram(input,diagram){return{...input,diagram:diagram}}function diagramPackageExclusion(sourceFilePath){return sourceFilePath?{excludedFilePaths:[sourceFilePath]}:{}}
|
|
@@ -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}}
|