@lovrabet/lovrabet-cli 2.3.13-beta.1 → 2.4.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -14
- package/lib/cli.js +4 -1
- package/lib/commands/api-doc/index.js +11 -1
- package/lib/commands/app/cache.js +2 -1
- package/lib/commands/app/definitions.js +7 -1
- package/lib/commands/app/eligibility.js +2 -1
- package/lib/commands/app/mock-loader.js +1 -1
- package/lib/commands/app/remote-source.js +2 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/approval/index.js +7 -1
- package/lib/commands/artifact/index.js +11 -1
- package/lib/commands/auth/device.js +8 -1
- package/lib/commands/auth/index.js +9 -1
- package/lib/commands/auth/prompt.js +2 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/exec.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/cli-skill/index.js +2 -1
- package/lib/commands/common/config-policy.js +2 -1
- package/lib/commands/common/constraints.js +2 -1
- package/lib/commands/common/flags.js +2 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/config/definitions.js +8 -1
- package/lib/commands/config/init.js +4 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/import-excel.js +10 -1
- package/lib/commands/data/index.js +10 -1
- package/lib/commands/dataset/detail.js +6 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +2 -1
- package/lib/commands/dataset/sdk-doc.js +1 -1
- package/lib/commands/doctor.js +9 -1
- package/lib/commands/file/index.js +3 -1
- package/lib/commands/init.js +4 -1
- package/lib/commands/issue/context.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/report.js +5 -1
- package/lib/commands/kb/index.js +7 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/metric/contract.js +5 -1
- package/lib/commands/metric/definition.js +4 -1
- package/lib/commands/metric/detail.js +1 -1
- package/lib/commands/metric/exec.js +3 -1
- package/lib/commands/metric/index.js +1 -1
- package/lib/commands/metric/list.js +2 -1
- package/lib/commands/metric/shared.js +2 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +2 -1
- package/lib/commands/ocr/index.js +4 -1
- package/lib/commands/permit/dataset-get.js +1 -1
- package/lib/commands/permit/dataset-set.js +5 -1
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.js +3 -1
- package/lib/commands/permit/role-menus-set.js +4 -1
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.js +7 -1
- package/lib/commands/personal-bff/index.js +7 -1
- package/lib/commands/registry.js +6 -1
- package/lib/commands/role/create.js +2 -1
- package/lib/commands/role/delete.js +2 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +2 -1
- package/lib/commands/role/shared.js +8 -1
- package/lib/commands/role/update.js +3 -1
- package/lib/commands/role/user-add.js +2 -1
- package/lib/commands/role/user-remove.js +2 -1
- package/lib/commands/schedule/index.js +7 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/service/dynamic.js +10 -1
- package/lib/commands/service/function-name-adapter.js +3 -1
- package/lib/commands/service/index.js +8 -1
- package/lib/commands/service/registry.js +12 -1
- package/lib/commands/skill/commands/create.js +3 -1
- package/lib/commands/skill/commands/diagram.js +4 -1
- package/lib/commands/skill/commands/install.js +6 -1
- package/lib/commands/skill/commands/list.js +3 -1
- package/lib/commands/skill/commands/push.js +1 -1
- package/lib/commands/skill/commands/validate.js +1 -1
- package/lib/commands/skill/diagram.js +3 -1
- package/lib/commands/skill/flags.js +4 -1
- package/lib/commands/skill/index.js +1 -1
- package/lib/commands/skill/manifest-helpers.js +1 -1
- package/lib/commands/skill/push-execute.js +11 -1
- package/lib/commands/skill/push-flow-helpers.js +4 -1
- package/lib/commands/skill/push-retarget.js +1 -1
- package/lib/commands/skill/scopes.js +1 -1
- package/lib/commands/skill/summary.js +1 -1
- package/lib/commands/skill/templates.js +8 -1
- package/lib/commands/skill/validate.js +8 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +2 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/update.d.ts +2 -1
- package/lib/commands/update.js +8 -1
- package/lib/commands/user-account/bind.js +3 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/index.js +7 -1
- package/lib/config/domain-config.js +6 -1
- package/lib/config/schema.js +5 -1
- package/lib/constant/app.js +1 -1
- package/lib/constant/auth-mode.js +1 -1
- package/lib/constant/cli.js +3 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/distribution.js +1 -1
- package/lib/constant/domain.js +2 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/product.js +2 -1
- package/lib/constant/region.js +2 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/url.js +1 -1
- package/lib/context.js +11 -1
- package/lib/core/api-client.js +38 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/kb-management-client.js +6 -1
- package/lib/core/kb-sdk-errors.js +2 -1
- package/lib/core/kb-search-client.js +2 -1
- package/lib/core/sdk-client.js +5 -1
- package/lib/errors.js +2 -1
- package/lib/framework/access-error.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/dryrun.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +2 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/preparse.js +3 -1
- package/lib/framework/rate-limit.js +2 -1
- package/lib/framework/raw-flags.js +2 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-confirmation.js +2 -1
- package/lib/framework/runner-error.js +2 -1
- package/lib/framework/runner.js +9 -1
- package/lib/framework/schema-export.js +2 -1
- package/lib/framework/service-order.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +2 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +4 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +2 -1
- package/lib/runtime/types.js +1 -1
- package/lib/services/dataset-import/auto-id-runner.js +9 -1
- package/lib/services/dataset-import/excel-reader.js +25 -1
- package/lib/services/dataset-import/image-bytes.js +6 -1
- package/lib/services/dataset-import/image-ooxml.js +15 -1
- package/lib/services/dataset-import/image-runner.js +9 -1
- package/lib/services/dataset-import/metadata.js +1 -1
- package/lib/services/dataset-import/preview.js +1 -1
- package/lib/services/dataset-import/runner.js +13 -1
- package/lib/services/dataset-import/types.js +1 -1
- package/lib/skills/builtin-skill.js +8 -1
- package/lib/skills/install-updated-skill.d.ts +8 -0
- package/lib/skills/install-updated-skill.js +3 -0
- package/lib/skills/local-skills-installer.d.ts +2 -0
- package/lib/skills/local-skills-installer.js +1 -0
- package/lib/skills/npx-skills-add.d.ts +2 -2
- package/lib/skills/npx-skills-add.js +4 -1
- package/lib/skills/runtime-skill-sync/constants.js +1 -1
- package/lib/skills/runtime-skill-sync/fs-utils.js +3 -1
- package/lib/skills/runtime-skill-sync/hashing.js +1 -1
- package/lib/skills/runtime-skill-sync/install-target.js +1 -1
- package/lib/skills/runtime-skill-sync/links.js +9 -1
- package/lib/skills/runtime-skill-sync/list-local.js +4 -1
- package/lib/skills/runtime-skill-sync/local-files.js +5 -1
- package/lib/skills/runtime-skill-sync/materialize.js +9 -1
- package/lib/skills/runtime-skill-sync/metadata.js +3 -1
- package/lib/skills/runtime-skill-sync/paths.js +2 -1
- package/lib/skills/runtime-skill-sync/push.js +8 -1
- package/lib/skills/runtime-skill-sync/scopes.js +1 -1
- package/lib/skills/runtime-skill-sync/types.js +1 -1
- package/lib/skills/runtime-skill-sync/zip-codec.js +2 -1
- package/lib/skills/runtime-skill-sync/zip-package.js +6 -1
- package/lib/skills/runtime-skill-sync.js +1 -1
- package/lib/skills/skill-presence.d.ts +1 -34
- package/lib/skills/skill-presence.js +2 -1
- package/lib/utils/access-key-redaction.js +2 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cli-version-check.js +2 -1
- package/lib/utils/cli-version-policy.js +3 -1
- package/lib/utils/logger.js +3 -1
- package/lib/utils/lossless-json.js +3 -1
- package/lib/utils/params.js +3 -1
- package/lib/utils/positive-safe-integer.js +1 -1
- package/lib/utils/redaction.js +2 -1
- package/lib/utils/runtime-user-id.js +1 -1
- package/lib/utils/update-notice.js +3 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +5 -7
- package/skills/lovrabet/SKILL.md +3 -3
- package/skills/lovrabet/references/lovrabet-skill-install.md +1 -1
- package/skills/lovrabet/references/lovrabet-update.md +6 -4
- package/skills/lovrabet-report-generation/SKILL.md +1 -1
- package/skills/lovrabet.manifest.json +3 -3
- package/lib/postinstall.d.ts +0 -2
- package/lib/postinstall.js +0 -1
- package/scripts/postinstall.mjs +0 -24
|
@@ -1 +1,10 @@
|
|
|
1
|
-
(function(_0x12fbcf,_0x39dc31){const _0x203214=a72_0x2099,_0x246fd7=_0x12fbcf();while(!![]){try{const _0x321931=parseInt(_0x203214(0xed))/0x1+-parseInt(_0x203214(0x117))/0x2+-parseInt(_0x203214(0xf5))/0x3+parseInt(_0x203214(0x108))/0x4*(-parseInt(_0x203214(0x125))/0x5)+-parseInt(_0x203214(0x11d))/0x6+parseInt(_0x203214(0xf9))/0x7*(parseInt(_0x203214(0x105))/0x8)+parseInt(_0x203214(0xd0))/0x9;if(_0x321931===_0x39dc31)break;else _0x246fd7['push'](_0x246fd7['shift']());}catch(_0x9c9907){_0x246fd7['push'](_0x246fd7['shift']());}}}(a72_0x4064,0x32336));import{compileServiceTreeCommand,matchServiceTreeCommand}from'@lovrabet/cli-framework';import{getLoginUserInfo,listDatasets}from'../../core/api-client.js';import{executeData,executeSdkBff,executeSdkSql}from'../../core/sdk-client.js';import{CliErrors}from'../../errors.js';function a72_0x4064(){const _0x272890=['cliName','\x20\x20MAP\x20TO','target','217KLonpW','datasetCode','\x20<command>\x20[flags]','\x22,\x20but\x20the\x20current\x20environment\x20is\x20\x22','const','description','nickname','commands','params','\x20\x20\x20\x20datatable:\x20','bff','This\x20will\x20run\x20Service\x20Tree\x20command\x20\x22','920irclCj','scriptName','\x20\x20\x20\x20datasetCode:\x20','12tnpwrX','username','\x20requires\x20target.functionName.','Use\x20lovrabet\x20dataset\x20list\x20to\x20confirm\x20the\x20physical\x20table\x20name\x20or\x20add\x20target.datasetCode\x20to\x20the\x20manifest.','remainingArgs','some','normalizedManifest','type','command','high-risk-write','fromEntries','required','sql','nickName','\x22\x20in\x20service\x20command\x20','38798HJkzaS','ctx.','appRef','`\x20to\x20inspect\x20the\x20manifest.','boolean','\x20requires\x20target.sqlCode.','600588SvbYSs','\x20requires\x20target.datasetCode\x20or\x20target.datatable.','mapTo','now','Use\x20`','tenantCode','Service\x20command\x20','risk','168395dNkwRZ','cliPath','envName','appBindings','dbtableConfig','find','read','Unsupported\x20service\x20target\x20kind:\x20','slice','padEnd','context.','userId','Commands:','\x20\x20\x20\x20','source','map','\x20\x20\x20\x20kind:\x20\x20\x20\x20','entries','bffId','Run\x20service\x20command\x20','app','push','bffCode','The\x20manifest\x20marks\x20this\x20command\x20as\x20a\x20high-risk\x20write.\x20It\x20may\x20make\x20business\x20changes\x20that\x20are\x20hard\x20to\x20reverse.','validation','env','Check\x20the\x20service\x20binding\x20and\x20current\x20connection.\x20Do\x20not\x20switch\x20environments\x20or\x20credentials\x20automatically.','\x20requires\x20environment\x20\x22','4767039EDzgFu','args','length','development','service','flags','default','employeeId','Cannot\x20resolve\x20datatable\x20\x22','kind','\x20\x20SERVICE\x20TREE\x20TARGET','\x20completed\x20in\x20','fullPath','appCode','tree','\x22\x20to\x20a\x20datasetCode\x20in\x20app\x20','string','code','\x20\x20\x20\x20sqlCode:\x20','filter','userName','name','number','\x20\x20\x20\x20command:\x20','appcode','\x20->\x20','sqlCode','rawFlags','Define\x20the\x20appRef\x20under\x20appBindings\x20or\x20remove\x20target.appRef.','177971AtFqke','tableName','startsWith','json','operator','join','SERVICE_TREE','datatable','855153yGzHLx'];a72_0x4064=function(){return _0x272890;};return a72_0x4064();}import{listLocalServices,listLocalServiceTrees}from'../../commands/service/registry.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{isDev,normalizeEnv}from'../../constant/env.js';export function resolveDynamicServiceCommand(_0x254079,_0x1d1c44){const _0x22a01c=a72_0x2099,_0x3c2e5d=listLocalServiceTrees();let _0x188306;for(const _0x1f3678 of _0x3c2e5d){const _0x4a0e3c=matchServiceTreeCommand(_0x1f3678,_0x254079);if(!_0x4a0e3c)continue;(!_0x188306||_0x4a0e3c[_0x22a01c(0x110)][_0x22a01c(0xdc)][_0x22a01c(0xd2)]>_0x188306['command'][_0x22a01c(0xdc)][_0x22a01c(0xd2)])&&(_0x188306={'tree':_0x1f3678,'command':_0x4a0e3c[_0x22a01c(0x110)],'remainingArgs':_0x4a0e3c[_0x22a01c(0x10c)]});}if(!_0x188306)return undefined;const _0x682727={..._0x1d1c44};return applyAppBinding(_0x188306[_0x22a01c(0xde)],_0x188306[_0x22a01c(0x110)],_0x682727),{'definition':buildDynamicCommandDefinition(_0x188306[_0x22a01c(0xde)],_0x188306[_0x22a01c(0x110)]),'args':_0x188306[_0x22a01c(0x10c)],'flags':_0x682727,'tree':_0x188306['tree'],'command':_0x188306[_0x22a01c(0x110)]};}export function generateDynamicServiceHelp(_0x2964f4){const _0x42d5df=a72_0x2099,_0x280f3f=listLocalServiceTrees()[_0x42d5df(0x12a)](_0x35a8c4=>_0x35a8c4[_0x42d5df(0xd4)]['code']===_0x2964f4);if(!_0x280f3f)return undefined;const _0x2e69ed=[CLI_BIN_NAME+'\x20'+_0x2964f4+_0x42d5df(0xfb),'',_0x280f3f[_0x42d5df(0xd4)][_0x42d5df(0xe5)]||_0x2964f4,_0x280f3f['service'][_0x42d5df(0xfe)]?'\x20\x20'+_0x280f3f[_0x42d5df(0xd4)][_0x42d5df(0xfe)]:'','',_0x42d5df(0x131),..._0x280f3f['commands'][_0x42d5df(0x134)](_0x3485e1=>{const _0x321f11=_0x42d5df,_0xe431e6=_0x3485e1[_0x321f11(0xdc)][_0x321f11(0x12d)](0x1)['join']('\x20'),_0x188ed6=_0x3485e1['risk']===_0x321f11(0x12b)?'':'\x20['+_0x3485e1['risk']+']';return'\x20\x20'+_0xe431e6[_0x321f11(0x12e)](0x18)+'\x20'+(_0x3485e1['description']||'')+_0x188ed6;}),'',_0x42d5df(0x121)+CLI_BIN_NAME+'\x20service\x20detail\x20--service\x20'+_0x2964f4+_0x42d5df(0x11a)][_0x42d5df(0xe3)](Boolean);return _0x2e69ed['join']('\x0a');}export function listDynamicServiceEntries(){const _0x2daf40=a72_0x2099;return listLocalServices()[_0x2daf40(0x134)](_0x2e4132=>{const _0xc4b5f9=_0x2daf40,_0x4dc12f=_0x2e4132[_0xc4b5f9(0x10e)];return{'service':_0x4dc12f[_0xc4b5f9(0xd4)][_0xc4b5f9(0xe1)],'label':_0x4dc12f[_0xc4b5f9(0xd4)][_0xc4b5f9(0xe5)]||_0x4dc12f[_0xc4b5f9(0xd4)][_0xc4b5f9(0xe1)],'commands':_0x4dc12f[_0xc4b5f9(0x100)][_0xc4b5f9(0x134)](_0x2f76a2=>({'command':dynamicCommandName(_0x2f76a2),'description':_0x2f76a2['description']||'Run\x20service\x20command\x20'+_0x2f76a2[_0xc4b5f9(0x126)],'tag':riskTag(_0x2f76a2[_0xc4b5f9(0x124)])}))};});}export function getDynamicServiceEntry(_0x16498f){const _0x5c6a85=a72_0x2099;return listDynamicServiceEntries()['find'](_0x25f6a5=>_0x25f6a5[_0x5c6a85(0xd4)]===_0x16498f);}export function listDynamicServiceDefinitions(_0x507015){const _0x312774=a72_0x2099;return listLocalServiceTrees()[_0x312774(0xe3)](_0x1bef3a=>!_0x507015||_0x1bef3a['service'][_0x312774(0xe1)]===_0x507015)['flatMap'](_0x5862c3=>_0x5862c3[_0x312774(0x100)][_0x312774(0x134)](_0x96d849=>buildDynamicCommandDefinition(_0x5862c3,_0x96d849)));}export function getDynamicServiceDefinitions(_0x4f19a4){const _0x4a2568=listDynamicServiceDefinitions(_0x4f19a4);return _0x4a2568['length']>0x0?_0x4a2568:undefined;}export function findDynamicServiceDefinition(_0x1634af,_0x31b7b3){const _0x4253e7=a72_0x2099;return listDynamicServiceDefinitions(_0x1634af)[_0x4253e7(0x12a)](_0x5e9176=>_0x5e9176[_0x4253e7(0x110)]===_0x31b7b3);}export function buildDynamicCommandDefinition(_0x44e9d2,_0x523b47){const _0x2c649d=a72_0x2099;return{'service':_0x44e9d2[_0x2c649d(0xd4)]['code'],'command':dynamicCommandName(_0x523b47),'description':_0x523b47[_0x2c649d(0xfe)]||_0x2c649d(0xc7)+_0x523b47['cliPath'],'risk':_0x523b47[_0x2c649d(0x124)],..._0x523b47[_0x2c649d(0x124)]===_0x2c649d(0x12b)?{}:{'confirmationDescription':buildDynamicConfirmationDescription(_0x523b47)},'requiresAuth':!![],'requiresAppCode':!![],'args':_0x523b47['args'][_0x2c649d(0x134)](_0x1d521c=>({'name':_0x1d521c[_0x2c649d(0xe5)],'description':_0x1d521c['description']||_0x1d521c[_0x2c649d(0xe5)],'required':_0x1d521c[_0x2c649d(0x113)]})),'flags':_0x523b47[_0x2c649d(0xd5)]['map'](flagToCommandFlag),'helpExtra':()=>renderDynamicCommandHelp(_0x523b47),async 'dryRun'(_0x292bde){const _0x409c64=_0x2c649d,_0xf9e35b=await compilePlan(_0x44e9d2,_0x523b47,_0x292bde);return{'method':_0x409c64(0xf3),'url':_0x523b47[_0x409c64(0x126)],'body':{'target':targetPreview(_0xf9e35b),'params':_0xf9e35b['params']},'description':'Preview\x20dynamic\x20service\x20command:\x20'+_0x523b47[_0x409c64(0x126)]};},async 'execute'(_0x1b1668){const _0x7ccc1=_0x2c649d,_0x25308b=await compilePlan(_0x44e9d2,_0x523b47,_0x1b1668),_0x29c031=Date[_0x7ccc1(0x120)](),_0xe155ea=await executePlan(_0x25308b,_0x523b47,_0x1b1668),_0x4e85fa=Date[_0x7ccc1(0x120)]()-_0x29c031;return{'ok':!![],'data':{'service':_0x44e9d2[_0x7ccc1(0xd4)],'command':_0x523b47[_0x7ccc1(0x126)],'target':targetPreview(_0x25308b),'result':_0xe155ea,'elapsed':_0x4e85fa},'message':'Service\x20command\x20'+_0x523b47['cliPath']+_0x7ccc1(0xdb)+_0x4e85fa+'ms'};}};}function buildDynamicConfirmationDescription(_0x2bc9dc){const _0x305c94=a72_0x2099,_0x2bad3d=_0x2bc9dc['description']||_0x2bc9dc['cliPath'],_0x5ad3c1=_0x2bc9dc['risk']===_0x305c94(0x111)?_0x305c94(0xcb):'The\x20manifest\x20marks\x20this\x20command\x20as\x20a\x20write.\x20It\x20may\x20change\x20business\x20data\x20or\x20service\x20state.';return _0x305c94(0x104)+_0x2bad3d+'\x22.\x20'+_0x5ad3c1;}function dynamicCommandName(_0x5b3397){const _0x283ba6=a72_0x2099;return _0x5b3397[_0x283ba6(0xdc)][_0x283ba6(0x12d)](0x1)[_0x283ba6(0xf2)]('\x20');}function riskTag(_0x5d43df){return _0x5d43df==='read'?'':'\x20\x20['+_0x5d43df+']';}function flagToCommandFlag(_0x37f89a){const _0xdf38c3=a72_0x2099;return{'name':_0x37f89a[_0xdf38c3(0xf6)],'type':_0x37f89a[_0xdf38c3(0x10f)]===_0xdf38c3(0xf0)?_0xdf38c3(0xe0):_0x37f89a[_0xdf38c3(0x10f)],'description':_0x37f89a[_0xdf38c3(0xfe)]||_0x37f89a[_0xdf38c3(0xe5)],'required':_0x37f89a[_0xdf38c3(0x113)],'default':isPrimitiveFlagDefault(_0x37f89a[_0xdf38c3(0xd6)])?_0x37f89a[_0xdf38c3(0xd6)]:undefined,'enum':_0x37f89a['enum']};}async function compilePlan(_0x5360bc,_0x19371a,_0x5a378a){const _0x2a9e3f=a72_0x2099,_0x2c7c2b=_0x19371a[_0x2a9e3f(0xf8)][_0x2a9e3f(0x119)]?_0x5360bc[_0x2a9e3f(0x128)][_0x19371a['target'][_0x2a9e3f(0x119)]]:undefined;if(_0x2c7c2b?.['env']){const _0x18201c=isDev(_0x2c7c2b[_0x2a9e3f(0xcd)])?_0x2a9e3f(0xd3):normalizeEnv(_0x2c7c2b[_0x2a9e3f(0xcd)]);if(_0x18201c!==_0x5a378a[_0x2a9e3f(0x127)])throw CliErrors[_0x2a9e3f(0xcc)]('Service\x20command\x20'+_0x19371a[_0x2a9e3f(0x126)]+_0x2a9e3f(0xcf)+_0x18201c+_0x2a9e3f(0xfc)+_0x5a378a[_0x2a9e3f(0x127)]+'\x22.',_0x2a9e3f(0xce));}return compileServiceTreeCommand(_0x19371a,{'flags':_0x5a378a[_0x2a9e3f(0xeb)],'args':_0x5a378a[_0x2a9e3f(0xd1)],'context':await buildServiceContext(_0x19371a,_0x5a378a)});}async function buildServiceContext(_0x1c3472,_0x3c90c6){const _0x1b1232=a72_0x2099,_0x43047d={'appCode':_0x3c90c6[_0x1b1232(0xdd)],'env':_0x3c90c6[_0x1b1232(0x127)],'envName':_0x3c90c6[_0x1b1232(0x127)]};if(!usesRuntimeContext(_0x1c3472))return _0x43047d;const _0x59b468=await getLoginUserInfo(),_0x2c072d=pickFirst(_0x59b468[_0x1b1232(0x130)],_0x59b468['id']);return{..._0x43047d,'user':_0x59b468,'userId':_0x2c072d,'id':_0x59b468['id'],'username':pickFirst(_0x59b468[_0x1b1232(0x109)],_0x59b468[_0x1b1232(0xe4)],_0x59b468['loginName']),'userName':_0x59b468[_0x1b1232(0xe4)],'nickname':pickFirst(_0x59b468[_0x1b1232(0xff)],_0x59b468[_0x1b1232(0x115)]),'nickName':_0x59b468[_0x1b1232(0x115)],'tenantCode':_0x59b468[_0x1b1232(0x122)],'employeeId':_0x59b468[_0x1b1232(0xd7)]};}function usesRuntimeContext(_0x55ffdf){const _0x408a6d=a72_0x2099;return _0x55ffdf[_0x408a6d(0x11f)][_0x408a6d(0x10d)](_0x33618a=>typeof _0x33618a[_0x408a6d(0x133)]===_0x408a6d(0xe0)&&(_0x33618a[_0x408a6d(0x133)][_0x408a6d(0xef)](_0x408a6d(0x12f))||_0x33618a[_0x408a6d(0x133)][_0x408a6d(0xef)](_0x408a6d(0x118))));}function a72_0x2099(_0x3e7127,_0x17c86c){_0x3e7127=_0x3e7127-0xc4;const _0x406488=a72_0x4064();let _0x209999=_0x406488[_0x3e7127];return _0x209999;}function pickFirst(..._0x4650f3){return _0x4650f3['find'](_0x295ad0=>_0x295ad0!==undefined&&_0x295ad0!==null);}async function executePlan(_0x5ee1ae,_0x1bf0c9,_0x4a8b24){const _0xefa36=a72_0x2099;if(_0x5ee1ae['kind']==='data'){const _0x50c554=await resolveDatasetCode(_0x5ee1ae,_0x1bf0c9,_0x4a8b24);return executeData(_0x50c554,_0x5ee1ae['command'],_0x5ee1ae[_0xefa36(0x101)]);}if(_0x5ee1ae[_0xefa36(0xd9)]===_0xefa36(0x114)){if(!_0x5ee1ae[_0xefa36(0xea)])throw CliErrors['validation']('Service\x20command\x20'+_0x1bf0c9['cliPath']+_0xefa36(0x11c));return executeSdkSql(_0x5ee1ae['sqlCode'],normalizeScalarParams(_0x5ee1ae[_0xefa36(0x101)]));}if(_0x5ee1ae[_0xefa36(0xd9)]===_0xefa36(0x103)){const _0x2895b9=_0x5ee1ae[_0xefa36(0x106)]||_0x5ee1ae[_0xefa36(0xca)]||(_0x5ee1ae['bffId']==null?'':String(_0x5ee1ae['bffId']));if(!_0x2895b9)throw CliErrors[_0xefa36(0xcc)]('Service\x20command\x20'+_0x1bf0c9['cliPath']+_0xefa36(0x10a));return executeSdkBff(_0x2895b9,_0x5ee1ae['params']);}throw CliErrors['validation'](_0xefa36(0x12c)+_0x5ee1ae['kind']);}async function resolveDatasetCode(_0x9dfb17,_0x10033b,_0x16ea4d){const _0x395368=a72_0x2099;if(_0x9dfb17[_0x395368(0xfa)])return _0x9dfb17['datasetCode'];if(!_0x9dfb17[_0x395368(0xf4)])throw CliErrors[_0x395368(0xcc)](_0x395368(0x123)+_0x10033b['cliPath']+_0x395368(0x11e));const _0x4e83bd=await listDatasets(_0x16ea4d['appCode']),_0x172d2c=_0x4e83bd[_0x395368(0x12a)](_0x1bb201=>_0x1bb201[_0x395368(0x129)]?.[_0x395368(0xee)]===_0x9dfb17['datatable']);if(!_0x172d2c?.[_0x395368(0xe1)])throw CliErrors[_0x395368(0xcc)](_0x395368(0xd8)+_0x9dfb17['datatable']+_0x395368(0xdf)+_0x16ea4d[_0x395368(0xdd)]+'.',_0x395368(0x10b));return _0x172d2c[_0x395368(0xe1)];}function applyAppBinding(_0x385e85,_0x1dad93,_0x5d13df){const _0x4df356=a72_0x2099,_0x4ee9b8=_0x1dad93[_0x4df356(0xf8)][_0x4df356(0x119)];if(!_0x4ee9b8)return;const _0x4bfef9=_0x385e85[_0x4df356(0x128)][_0x4ee9b8];if(!_0x4bfef9)throw CliErrors[_0x4df356(0xcc)]('Unknown\x20appRef\x20\x22'+_0x4ee9b8+_0x4df356(0x116)+_0x1dad93['cliPath']+'.',_0x4df356(0xec));const _0x3b733e=_0x4bfef9[_0x4df356(0xe8)]||_0x4bfef9[_0x4df356(0xdd)];_0x3b733e&&!hasText(_0x5d13df['appcode'])&&!hasText(_0x5d13df[_0x4df356(0xc8)])&&(_0x5d13df[_0x4df356(0xe8)]=_0x3b733e),_0x4bfef9[_0x4df356(0xc8)]&&!hasText(_0x5d13df['app'])&&!hasText(_0x5d13df[_0x4df356(0xe8)])&&(_0x5d13df['app']=_0x4bfef9[_0x4df356(0xc8)]);}function renderDynamicCommandHelp(_0x112437){const _0x3d1ca5=a72_0x2099,_0x563149=[_0x3d1ca5(0xda),_0x3d1ca5(0xc4)+_0x112437['target'][_0x3d1ca5(0xd9)],_0x3d1ca5(0xe7)+_0x112437[_0x3d1ca5(0xf8)]['command']];if(_0x112437[_0x3d1ca5(0xf8)]['datasetCode'])_0x563149[_0x3d1ca5(0xc9)](_0x3d1ca5(0x107)+_0x112437[_0x3d1ca5(0xf8)][_0x3d1ca5(0xfa)]);if(_0x112437[_0x3d1ca5(0xf8)][_0x3d1ca5(0xf4)])_0x563149[_0x3d1ca5(0xc9)](_0x3d1ca5(0x102)+_0x112437[_0x3d1ca5(0xf8)][_0x3d1ca5(0xf4)]);if(_0x112437[_0x3d1ca5(0xf8)][_0x3d1ca5(0xea)])_0x563149[_0x3d1ca5(0xc9)](_0x3d1ca5(0xe2)+_0x112437[_0x3d1ca5(0xf8)][_0x3d1ca5(0xea)]);if(_0x112437[_0x3d1ca5(0xf8)]['scriptName'])_0x563149['push']('\x20\x20\x20\x20functionName:\x20'+_0x112437[_0x3d1ca5(0xf8)][_0x3d1ca5(0x106)]);if(_0x112437[_0x3d1ca5(0x11f)][_0x3d1ca5(0xd2)]>0x0){_0x563149['push']('',_0x3d1ca5(0xf7));for(const _0x26108b of _0x112437[_0x3d1ca5(0x11f)]){_0x563149[_0x3d1ca5(0xc9)](_0x3d1ca5(0x132)+(_0x26108b[_0x3d1ca5(0x133)]||_0x3d1ca5(0xfd))+_0x3d1ca5(0xe9)+_0x26108b[_0x3d1ca5(0xf8)]+(_0x26108b[_0x3d1ca5(0xf1)]?'.'+_0x26108b[_0x3d1ca5(0xf1)]:''));}}return _0x563149[_0x3d1ca5(0xf2)]('\x0a');}function targetPreview(_0x1732db){const _0x4e3c27=a72_0x2099;return{'kind':_0x1732db[_0x4e3c27(0xd9)],'command':_0x1732db['command'],'appRef':_0x1732db[_0x4e3c27(0x119)],'datasetCode':_0x1732db[_0x4e3c27(0xfa)],'datatable':_0x1732db[_0x4e3c27(0xf4)],'sqlCode':_0x1732db[_0x4e3c27(0xea)],'bffCode':_0x1732db[_0x4e3c27(0xca)],'bffId':_0x1732db[_0x4e3c27(0xc6)],'functionName':_0x1732db['scriptName']};}function normalizeScalarParams(_0x7dba9d){const _0x45dc1a=a72_0x2099;return Object[_0x45dc1a(0x112)](Object[_0x45dc1a(0xc5)](_0x7dba9d)['filter'](([,_0x3347f6])=>typeof _0x3347f6===_0x45dc1a(0xe0)||typeof _0x3347f6===_0x45dc1a(0xe6)));}function hasText(_0x49a40a){const _0x294dde=a72_0x2099;return typeof _0x49a40a===_0x294dde(0xe0)&&_0x49a40a['trim']()[_0x294dde(0xd2)]>0x0;}function isPrimitiveFlagDefault(_0x3c9f87){const _0x470b9f=a72_0x2099;return _0x3c9f87===undefined||typeof _0x3c9f87===_0x470b9f(0xe0)||typeof _0x3c9f87==='number'||typeof _0x3c9f87===_0x470b9f(0x11b);}
|
|
1
|
+
import{compileServiceTreeCommand,matchServiceTreeCommand}from"@lovrabet/cli-framework";import{getLoginUserInfo,listDatasets}from"../../core/api-client.js";import{executeData,executeSdkBff,executeSdkSql}from"../../core/sdk-client.js";import{CliErrors}from"../../errors.js";import{listLocalServices,listLocalServiceTrees}from"../../commands/service/registry.js";import{CLI_BIN_NAME}from"../../constant/cli.js";import{isDev,normalizeEnv}from"../../constant/env.js";export function resolveDynamicServiceCommand(input,flags){const trees=listLocalServiceTrees();let best;for(const tree of trees){const match=matchServiceTreeCommand(tree,input);if(!match)continue;if(!best||match.command.fullPath.length>best.command.fullPath.length){best={tree:tree,command:match.command,remainingArgs:match.remainingArgs}}}if(!best)return undefined;const nextFlags={...flags};applyAppBinding(best.tree,best.command,nextFlags);return{definition:buildDynamicCommandDefinition(best.tree,best.command),args:best.remainingArgs,
|
|
2
|
+
flags:nextFlags,tree:best.tree,command:best.command}}export function generateDynamicServiceHelp(serviceCode){const tree=listLocalServiceTrees().find(item=>item.service.code===serviceCode);if(!tree)return undefined;const lines=[`${CLI_BIN_NAME} ${serviceCode} <command> [flags]`,"",tree.service.name||serviceCode,tree.service.description?` ${tree.service.description}`:"","","Commands:",...tree.commands.map(command=>{const tail=command.fullPath.slice(1).join(" ");const riskTag=command.risk==="read"?"":` [${command.risk}]`;return` ${tail.padEnd(24)} ${command.description||""}${riskTag}`}),"",`Use \`${CLI_BIN_NAME} service detail --service ${serviceCode}\` to inspect the manifest.`].filter(Boolean);return lines.join("\n")}export function listDynamicServiceEntries(){return listLocalServices().map(entry=>{const tree=entry.normalizedManifest;return{service:tree.service.code,label:tree.service.name||tree.service.code,commands:tree.commands.map(command=>({command:dynamicCommandName(command),
|
|
3
|
+
description:command.description||`Run service command ${command.cliPath}`,tag:riskTag(command.risk)}))}})}export function getDynamicServiceEntry(serviceCode){return listDynamicServiceEntries().find(entry=>entry.service===serviceCode)}export function listDynamicServiceDefinitions(serviceCode){return listLocalServiceTrees().filter(tree=>!serviceCode||tree.service.code===serviceCode).flatMap(tree=>tree.commands.map(command=>buildDynamicCommandDefinition(tree,command)))}export function getDynamicServiceDefinitions(serviceCode){const definitions=listDynamicServiceDefinitions(serviceCode);return definitions.length>0?definitions:undefined}export function findDynamicServiceDefinition(serviceCode,commandName){return listDynamicServiceDefinitions(serviceCode).find(definition=>definition.command===commandName)}export function buildDynamicCommandDefinition(tree,command){return{service:tree.service.code,command:dynamicCommandName(command),
|
|
4
|
+
description:command.description||`Run service command ${command.cliPath}`,risk:command.risk,...command.risk==="read"?{}:{confirmationDescription:buildDynamicConfirmationDescription(command)},requiresAuth:true,requiresAppCode:true,args:command.args.map(arg=>({name:arg.name,description:arg.description||arg.name,required:arg.required})),flags:command.flags.map(flagToCommandFlag),helpExtra:()=>renderDynamicCommandHelp(command),async dryRun(ctx){const plan=await compilePlan(tree,command,ctx);return{method:"SERVICE_TREE",url:command.cliPath,body:{target:targetPreview(plan),params:plan.params},description:`Preview dynamic service command: ${command.cliPath}`}},async execute(ctx){const plan=await compilePlan(tree,command,ctx);const startTime=Date.now();const result=await executePlan(plan,command,ctx);const elapsed=Date.now()-startTime;return{ok:true,data:{service:tree.service,command:command.cliPath,target:targetPreview(plan),result:result,elapsed:elapsed},
|
|
5
|
+
message:`Service command ${command.cliPath} completed in ${elapsed}ms`}}}}function buildDynamicConfirmationDescription(command){const businessDescription=command.description||command.cliPath;const riskDescription=command.risk==="high-risk-write"?"The manifest marks this command as a high-risk write. It may make business changes that are hard to reverse.":"The manifest marks this command as a write. It may change business data or service state.";return`This will run Service Tree command "${businessDescription}". ${riskDescription}`}function dynamicCommandName(command){return command.fullPath.slice(1).join(" ")}function riskTag(risk){return risk==="read"?"":` [${risk}]`}function flagToCommandFlag(flag){return{name:flag.cliName,type:flag.type==="json"?"string":flag.type,description:flag.description||flag.name,required:flag.required,default:isPrimitiveFlagDefault(flag.default)?flag.default:undefined,enum:flag.enum}}async function compilePlan(tree,command,ctx){
|
|
6
|
+
const binding=command.target.appRef?tree.appBindings[command.target.appRef]:undefined;if(binding?.env){const requiredEnv=isDev(binding.env)?"development":normalizeEnv(binding.env);if(requiredEnv!==ctx.envName){throw CliErrors.validation(`Service command ${command.cliPath} requires environment "${requiredEnv}", but the current environment is "${ctx.envName}".`,"Check the service binding and current connection. Do not switch environments or credentials automatically.")}}return compileServiceTreeCommand(command,{flags:ctx.rawFlags,args:ctx.args,context:await buildServiceContext(command,ctx)})}async function buildServiceContext(command,ctx){const base={appCode:ctx.appCode,env:ctx.envName,envName:ctx.envName};if(!usesRuntimeContext(command))return base;const user=await getLoginUserInfo();const userId=pickFirst(user.userId,user.id);return{...base,user:user,userId:userId,id:user.id,username:pickFirst(user.username,user.userName,user.loginName),userName:user.userName,
|
|
7
|
+
nickname:pickFirst(user.nickname,user.nickName),nickName:user.nickName,tenantCode:user.tenantCode,employeeId:user.employeeId}}function usesRuntimeContext(command){return command.mapTo.some(rule=>typeof rule.source==="string"&&(rule.source.startsWith("context.")||rule.source.startsWith("ctx.")))}function pickFirst(...values){return values.find(value=>value!==undefined&&value!==null)}async function executePlan(plan,command,ctx){if(plan.kind==="data"){const datasetCode=await resolveDatasetCode(plan,command,ctx);return executeData(datasetCode,plan.command,plan.params)}if(plan.kind==="sql"){if(!plan.sqlCode){throw CliErrors.validation(`Service command ${command.cliPath} requires target.sqlCode.`)}return executeSdkSql(plan.sqlCode,normalizeScalarParams(plan.params))}if(plan.kind==="bff"){const functionName=plan.scriptName||plan.bffCode||(plan.bffId==null?"":String(plan.bffId));if(!functionName){throw CliErrors.validation(`Service command ${command.cliPath} requires target.functionName.`)}
|
|
8
|
+
return executeSdkBff(functionName,plan.params)}throw CliErrors.validation(`Unsupported service target kind: ${plan.kind}`)}async function resolveDatasetCode(plan,command,ctx){if(plan.datasetCode)return plan.datasetCode;if(!plan.datatable){throw CliErrors.validation(`Service command ${command.cliPath} requires target.datasetCode or target.datatable.`)}const datasets=await listDatasets(ctx.appCode);const match=datasets.find(item=>item.dbtableConfig?.tableName===plan.datatable);if(!match?.code){throw CliErrors.validation(`Cannot resolve datatable "${plan.datatable}" to a datasetCode in app ${ctx.appCode}.`,"Use lovrabet dataset list to confirm the physical table name or add target.datasetCode to the manifest.")}return match.code}function applyAppBinding(tree,command,flags){const appRef=command.target.appRef;if(!appRef)return;const binding=tree.appBindings[appRef];if(!binding){
|
|
9
|
+
throw CliErrors.validation(`Unknown appRef "${appRef}" in service command ${command.cliPath}.`,"Define the appRef under appBindings or remove target.appRef.")}const appCode=binding.appcode||binding.appCode;if(appCode&&!hasText(flags.appcode)&&!hasText(flags.app)){flags.appcode=appCode}if(binding.app&&!hasText(flags.app)&&!hasText(flags.appcode)){flags.app=binding.app}}function renderDynamicCommandHelp(command){const lines=[" SERVICE TREE TARGET",` kind: ${command.target.kind}`,` command: ${command.target.command}`];if(command.target.datasetCode)lines.push(` datasetCode: ${command.target.datasetCode}`);if(command.target.datatable)lines.push(` datatable: ${command.target.datatable}`);if(command.target.sqlCode)lines.push(` sqlCode: ${command.target.sqlCode}`);if(command.target.scriptName)lines.push(` functionName: ${command.target.scriptName}`);if(command.mapTo.length>0){lines.push(""," MAP TO");for(const rule of command.mapTo){
|
|
10
|
+
lines.push(` ${rule.source||"const"} -> ${rule.target}${rule.operator?`.${rule.operator}`:""}`)}}return lines.join("\n")}function targetPreview(plan){return{kind:plan.kind,command:plan.command,appRef:plan.appRef,datasetCode:plan.datasetCode,datatable:plan.datatable,sqlCode:plan.sqlCode,bffCode:plan.bffCode,bffId:plan.bffId,functionName:plan.scriptName}}function normalizeScalarParams(params){return Object.fromEntries(Object.entries(params).filter(([,value])=>typeof value==="string"||typeof value==="number"))}function hasText(value){return typeof value==="string"&&value.trim().length>0}function isPrimitiveFlagDefault(value){return value===undefined||typeof value==="string"||typeof value==="number"||typeof value==="boolean"}
|
|
@@ -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
|
-
const a74_0x2eedcf=a74_0x53d9;(function(_0x31b95c,_0x107818){const _0x480ebe=a74_0x53d9,_0x40eda1=_0x31b95c();while(!![]){try{const _0x7d5a97=-parseInt(_0x480ebe(0x154))/0x1*(parseInt(_0x480ebe(0x127))/0x2)+parseInt(_0x480ebe(0x123))/0x3*(-parseInt(_0x480ebe(0x13d))/0x4)+parseInt(_0x480ebe(0x163))/0x5*(parseInt(_0x480ebe(0x12f))/0x6)+parseInt(_0x480ebe(0x14d))/0x7*(parseInt(_0x480ebe(0x155))/0x8)+parseInt(_0x480ebe(0x14b))/0x9+-parseInt(_0x480ebe(0x121))/0xa+parseInt(_0x480ebe(0x15c))/0xb*(parseInt(_0x480ebe(0x13e))/0xc);if(_0x7d5a97===_0x107818)break;else _0x40eda1['push'](_0x40eda1['shift']());}catch(_0xbe7e2e){_0x40eda1['push'](_0x40eda1['shift']());}}}(a74_0x90a7,0x3c536));function a74_0x53d9(_0x581ec2,_0x184dce){_0x581ec2=_0x581ec2-0x116;const _0x90a71d=a74_0x90a7();let _0x53d988=_0x90a71d[_0x581ec2];return _0x53d988;}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':a74_0x2eedcf(0x151),'type':a74_0x2eedcf(0x146),'required':!![],'description':a74_0x2eedcf(0x140)},SERVICE_FLAG={'name':a74_0x2eedcf(0x11e),'type':a74_0x2eedcf(0x146),'required':!![],'description':a74_0x2eedcf(0x15f),'pattern':{'regex':/^[a-z][a-z0-9-]*$/,'description':a74_0x2eedcf(0x152)}};function summarizeService(_0x5a0a56){const _0x17687f=a74_0x2eedcf;return{'serviceCode':_0x5a0a56[_0x17687f(0x13f)],'name':_0x5a0a56[_0x17687f(0x13b)][_0x17687f(0x11e)][_0x17687f(0x150)],'version':_0x5a0a56[_0x17687f(0x145)],'importedAt':_0x5a0a56[_0x17687f(0x14e)],'source':_0x5a0a56['source'],'commandCount':_0x5a0a56[_0x17687f(0x13b)][_0x17687f(0x14f)][_0x17687f(0x117)],'commands':_0x5a0a56[_0x17687f(0x13b)][_0x17687f(0x14f)][_0x17687f(0x11a)](_0x51379b=>({'path':_0x51379b[_0x17687f(0x12c)],'description':_0x51379b['description'],'risk':_0x51379b['risk'],'target':toPublicServiceTreeTarget(_0x51379b[_0x17687f(0x12a)]),'flags':_0x51379b[_0x17687f(0x133)][_0x17687f(0x11a)](_0x3dc8dd=>({'name':_0x3dc8dd[_0x17687f(0x150)],'cliName':_0x3dc8dd['cliName'],'type':_0x3dc8dd[_0x17687f(0x124)],'required':_0x3dc8dd[_0x17687f(0x125)]===!![]}))}))};}function summarizeLoadedManifest(_0x54162a){const _0x5089be=a74_0x2eedcf;return{'service':_0x54162a['normalizedManifest']?.[_0x5089be(0x11e)],'version':_0x54162a[_0x5089be(0x13b)]?.[_0x5089be(0x145)],'commandCount':_0x54162a[_0x5089be(0x13b)]?.[_0x5089be(0x14f)][_0x5089be(0x117)]??0x0,'commands':_0x54162a[_0x5089be(0x13b)]?.[_0x5089be(0x14f)][_0x5089be(0x11a)](_0x1cdc94=>({'path':_0x1cdc94[_0x5089be(0x12c)],'risk':_0x1cdc94[_0x5089be(0x135)],'target':toPublicServiceTreeTarget(_0x1cdc94['target'])}))??[],'registryIndex':_0x54162a[_0x5089be(0x141)],'registryServiceCode':_0x54162a[_0x5089be(0x147)],'errors':_0x54162a['report']['errors'],'warnings':_0x54162a[_0x5089be(0x162)][_0x5089be(0x136)]};}export const serviceDefinitions=[{'service':'service','command':a74_0x2eedcf(0x134),'description':a74_0x2eedcf(0x14c),'risk':a74_0x2eedcf(0x13a),'requiresAuth':![],'requiresAppCode':![],'flags':[FILE_FLAG],async 'execute'(_0x5cd002){const _0x3c54cb=a74_0x2eedcf,_0x338cfd=loadServiceManifestFromFile(_0x5cd002[_0x3c54cb(0x148)](_0x3c54cb(0x151)));if(!_0x338cfd[_0x3c54cb(0x162)]['ok'])return{'ok':![],'data':{'file':_0x338cfd[_0x3c54cb(0x126)],'hash':_0x338cfd[_0x3c54cb(0x159)],'kind':_0x338cfd[_0x3c54cb(0x15e)],'serviceCount':_0x338cfd[_0x3c54cb(0x120)][_0x3c54cb(0x117)],'services':_0x338cfd[_0x3c54cb(0x120)][_0x3c54cb(0x11a)](summarizeLoadedManifest),'errors':_0x338cfd[_0x3c54cb(0x162)][_0x3c54cb(0x118)],'warnings':_0x338cfd['report'][_0x3c54cb(0x136)]},'message':formatValidationFailure(_0x338cfd[_0x3c54cb(0x162)])};if(_0x338cfd['kind']===_0x3c54cb(0x12e)||_0x338cfd[_0x3c54cb(0x120)][_0x3c54cb(0x117)]!==0x1)return{'ok':!![],'data':{'file':_0x338cfd[_0x3c54cb(0x126)],'hash':_0x338cfd['hash'],'kind':_0x338cfd[_0x3c54cb(0x15e)],'serviceCount':_0x338cfd[_0x3c54cb(0x120)][_0x3c54cb(0x117)],'commandCount':_0x338cfd[_0x3c54cb(0x120)][_0x3c54cb(0x116)]((_0x59b756,_0x1faaba)=>_0x59b756+(_0x1faaba[_0x3c54cb(0x13b)]?.['commands'][_0x3c54cb(0x117)]??0x0),0x0),'services':_0x338cfd[_0x3c54cb(0x120)]['map'](summarizeLoadedManifest),'warnings':_0x338cfd[_0x3c54cb(0x162)][_0x3c54cb(0x136)]},'message':_0x3c54cb(0x15a)};return{'ok':!![],'data':{'file':_0x338cfd[_0x3c54cb(0x126)],'hash':_0x338cfd[_0x3c54cb(0x159)],'kind':_0x338cfd[_0x3c54cb(0x15e)],'service':_0x338cfd[_0x3c54cb(0x13b)]?.[_0x3c54cb(0x11e)],'version':_0x338cfd[_0x3c54cb(0x13b)]?.[_0x3c54cb(0x145)],'commandCount':_0x338cfd[_0x3c54cb(0x13b)]?.[_0x3c54cb(0x14f)][_0x3c54cb(0x117)]??0x0,'commands':_0x338cfd[_0x3c54cb(0x13b)]?.[_0x3c54cb(0x14f)][_0x3c54cb(0x11a)](_0x2d9d81=>({'path':_0x2d9d81['cliPath'],'risk':_0x2d9d81[_0x3c54cb(0x135)],'target':toPublicServiceTreeTarget(_0x2d9d81[_0x3c54cb(0x12a)])})),'warnings':_0x338cfd[_0x3c54cb(0x162)][_0x3c54cb(0x136)]},'message':_0x3c54cb(0x15d)};}},{'service':'service','command':'import','description':a74_0x2eedcf(0x144),'risk':a74_0x2eedcf(0x142),'confirmationDescription':a74_0x2eedcf(0x157),'requiresAuth':![],'requiresAppCode':![],'flags':[FILE_FLAG],async 'dryRun'(_0x37d53e){const _0x39833b=a74_0x2eedcf,_0xbb1316=loadServiceManifestFromFile(_0x37d53e['str'](_0x39833b(0x151)));return{'method':_0x39833b(0x122),'url':getServiceRegistryPath(),'body':{'file':_0xbb1316[_0x39833b(0x126)],'hash':_0xbb1316[_0x39833b(0x159)],'kind':_0xbb1316[_0x39833b(0x15e)],'ok':_0xbb1316[_0x39833b(0x162)]['ok'],'service':_0xbb1316[_0x39833b(0x13b)]?.['service'],'version':_0xbb1316[_0x39833b(0x13b)]?.[_0x39833b(0x145)],'serviceCount':_0xbb1316[_0x39833b(0x120)][_0x39833b(0x117)],'services':_0xbb1316[_0x39833b(0x120)][_0x39833b(0x11a)](_0x306895=>({'service':_0x306895[_0x39833b(0x13b)]?.[_0x39833b(0x11e)],'version':_0x306895[_0x39833b(0x13b)]?.[_0x39833b(0x145)],'commandCount':_0x306895[_0x39833b(0x13b)]?.[_0x39833b(0x14f)][_0x39833b(0x117)]??0x0,'errors':_0x306895[_0x39833b(0x162)][_0x39833b(0x118)]})),'errors':_0xbb1316[_0x39833b(0x162)][_0x39833b(0x118)],'commandCount':_0xbb1316[_0x39833b(0x13b)]?.[_0x39833b(0x14f)][_0x39833b(0x117)]??0x0},'description':_0x39833b(0x15b)};},async 'execute'(_0x5b17ef){const _0x1aeedc=a74_0x2eedcf,_0x4adb7d=importServiceManifest(_0x5b17ef[_0x1aeedc(0x148)](_0x1aeedc(0x151)));if(_0x4adb7d[_0x1aeedc(0x158)][_0x1aeedc(0x117)]!==0x1)return{'ok':!![],'data':{'registryPath':_0x4adb7d[_0x1aeedc(0x11c)],'imported':_0x4adb7d[_0x1aeedc(0x130)],'updated':_0x4adb7d[_0x1aeedc(0x119)],'serviceCount':_0x4adb7d[_0x1aeedc(0x14a)],'services':_0x4adb7d[_0x1aeedc(0x158)][_0x1aeedc(0x11a)](summarizeService)},'message':_0x1aeedc(0x143)+_0x4adb7d[_0x1aeedc(0x130)]+_0x1aeedc(0x13c)+_0x4adb7d['updated']+_0x1aeedc(0x128)};return{'ok':!![],'data':{'registryPath':_0x4adb7d[_0x1aeedc(0x11c)],'replaced':_0x4adb7d[_0x1aeedc(0x12d)],'imported':_0x4adb7d[_0x1aeedc(0x130)],'updated':_0x4adb7d[_0x1aeedc(0x119)],'serviceCount':_0x4adb7d[_0x1aeedc(0x14a)],'service':summarizeService(_0x4adb7d[_0x1aeedc(0x132)])},'message':(_0x4adb7d[_0x1aeedc(0x12d)]?_0x1aeedc(0x153):_0x1aeedc(0x11b))+_0x1aeedc(0x138)+_0x4adb7d[_0x1aeedc(0x132)][_0x1aeedc(0x13f)]+'.'};}},{'service':'service','command':'export','description':a74_0x2eedcf(0x161),'risk':'write','confirmationDescription':'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.','requiresAuth':![],'requiresAppCode':![],'flags':[SERVICE_FLAG,FILE_FLAG],async 'dryRun'(_0x376ff5){const _0xb29066=a74_0x2eedcf,_0x359540=getLocalServiceEntry(_0x376ff5['str'](_0xb29066(0x11e)));return{'method':'WRITE','url':_0x376ff5[_0xb29066(0x148)](_0xb29066(0x151)),'body':{'service':_0x376ff5['str'](_0xb29066(0x11e)),'found':Boolean(_0x359540),'version':_0x359540?.['version'],'source':_0x359540?.[_0xb29066(0x139)]},'description':_0xb29066(0x11d)};},async 'execute'(_0x1833ad){const _0x499fb0=a74_0x2eedcf,_0x555cb0=exportServiceManifest(_0x1833ad[_0x499fb0(0x148)]('service'),_0x1833ad[_0x499fb0(0x148)](_0x499fb0(0x151)));return{'ok':!![],'data':{'registryPath':_0x555cb0[_0x499fb0(0x11c)],'file':_0x555cb0[_0x499fb0(0x126)],'service':summarizeService(_0x555cb0[_0x499fb0(0x132)])},'message':_0x499fb0(0x12b)+_0x555cb0['entry']['serviceCode']+'.'};}},{'service':a74_0x2eedcf(0x11e),'command':a74_0x2eedcf(0x160),'description':'List\x20locally\x20imported\x20Service\x20Tree\x20manifests','risk':a74_0x2eedcf(0x13a),'requiresAuth':![],'requiresAppCode':![],'flags':[],async 'execute'(){const _0x2c421e=a74_0x2eedcf,_0x4c8b0c=listLocalServices();return{'ok':!![],'data':{'registryPath':getServiceRegistryPath(),'total':_0x4c8b0c[_0x2c421e(0x117)],'services':_0x4c8b0c[_0x2c421e(0x11a)](summarizeService)}};}},{'service':'service','command':'remove','description':a74_0x2eedcf(0x131),'risk':a74_0x2eedcf(0x142),'confirmationDescription':a74_0x2eedcf(0x11f),'requiresAuth':![],'requiresAppCode':![],'flags':[SERVICE_FLAG],async 'dryRun'(_0x3f77bc){const _0x1d19bc=a74_0x2eedcf,_0x10e985=getLocalServiceEntry(_0x3f77bc[_0x1d19bc(0x148)](_0x1d19bc(0x11e)));return{'method':_0x1d19bc(0x122),'url':getServiceRegistryPath(),'body':{'service':_0x3f77bc[_0x1d19bc(0x148)](_0x1d19bc(0x11e)),'found':Boolean(_0x10e985),'version':_0x10e985?.['version'],'source':_0x10e985?.[_0x1d19bc(0x139)]},'description':_0x1d19bc(0x129)};},async 'execute'(_0x5d9997){const _0xc79110=a74_0x2eedcf,_0x4a28b1=removeServiceManifest(_0x5d9997[_0xc79110(0x148)]('service'));return{'ok':!![],'data':{'registryPath':_0x4a28b1[_0xc79110(0x11c)],'serviceCount':_0x4a28b1[_0xc79110(0x14a)],'service':summarizeService(_0x4a28b1[_0xc79110(0x132)])},'message':_0xc79110(0x149)+_0x4a28b1['entry'][_0xc79110(0x13f)]+'.'};}},{'service':a74_0x2eedcf(0x11e),'command':'detail','description':a74_0x2eedcf(0x137),'risk':a74_0x2eedcf(0x13a),'requiresAuth':![],'requiresAppCode':![],'flags':[SERVICE_FLAG],async 'execute'(_0x1bbbdc){const _0x405715=a74_0x2eedcf,_0x5ade26=getLocalServiceEntry(_0x1bbbdc[_0x405715(0x148)](_0x405715(0x11e)));if(!_0x5ade26)return{'ok':![],'data':{'registryPath':getServiceRegistryPath(),'service':_0x1bbbdc[_0x405715(0x148)]('service')},'message':'Local\x20service\x20not\x20found:\x20'+_0x1bbbdc[_0x405715(0x148)](_0x405715(0x11e))};return{'ok':!![],'data':{'registryPath':getServiceRegistryPath(),'service':summarizeService(_0x5ade26),'manifest':_0x5ade26[_0x405715(0x156)],'normalizedManifest':toPublicNormalizedServiceTree(_0x5ade26[_0x405715(0x13b)])}};}}];function a74_0x90a7(){const _0x449841=['serviceCount','4157352aTxBvm','Validate\x20a\x20Service\x20Tree\x20JSON\x20manifest','7LjlBdJ','importedAt','commands','name','file','lower\x20kebab-case\x20service\x20code','Updated','231815RYUUjW','1119120hNqhvR','manifest','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.','entries','hash','Service\x20registry\x20validation\x20passed.','Preview\x20Service\x20Tree\x20import\x20into\x20~/.lovrabet/service.json','53779hANTzp','Service\x20manifest\x20validation\x20passed.','kind','Local\x20service\x20code,\x20for\x20example\x20crm','list','Export\x20the\x20local\x20Service\x20Tree\x20manifest\x20to\x20a\x20JSON\x20file','report','414605uzdqTh','reduce','length','errors','updated','map','Imported','registryPath','Preview\x20Service\x20Tree\x20export\x20from\x20~/.lovrabet/service.json','service','Removes\x20the\x20given\x20service\x20manifest\x20from\x20the\x20local\x20Service\x20Tree\x20registry.\x20Dynamic\x20commands\x20from\x20that\x20manifest\x20will\x20no\x20longer\x20be\x20available.','manifests','2178580MGiBCX','WRITE','468861aRGWFK','type','required','filePath','4QFePCX','\x20service(s).','Preview\x20Service\x20Tree\x20removal\x20from\x20~/.lovrabet/service.json','target','Exported\x20service\x20','cliPath','replaced','registry','30jZVQLZ','imported','Remove\x20a\x20Service\x20Tree\x20manifest\x20from\x20the\x20local\x20runtime\x20registry','entry','flags','validate','risk','warnings','Show\x20a\x20locally\x20imported\x20Service\x20Tree\x20manifest','\x20service\x20','source','read','normalizedManifest','\x20service(s),\x20updated\x20','4mEPreY','168ezNrLb','serviceCode','Service\x20Tree\x20manifest\x20file\x20path','registryIndex','write','Imported\x20','Import\x20a\x20Service\x20Tree\x20manifest\x20into\x20the\x20local\x20runtime\x20registry','version','string','registryServiceCode','str','Removed\x20service\x20'];a74_0x90a7=function(){return _0x449841;};return a74_0x90a7();}
|
|
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
|
-
const a75_0x2bb9e1=a75_0x3383;(function(_0x32e86b,_0x2f13fe){const _0x493297=a75_0x3383,_0x28f2a3=_0x32e86b();while(!![]){try{const _0x123f6f=-parseInt(_0x493297(0x201))/0x1+parseInt(_0x493297(0x223))/0x2*(parseInt(_0x493297(0x200))/0x3)+-parseInt(_0x493297(0x1d5))/0x4*(parseInt(_0x493297(0x1e2))/0x5)+parseInt(_0x493297(0x1d4))/0x6+parseInt(_0x493297(0x224))/0x7*(parseInt(_0x493297(0x214))/0x8)+-parseInt(_0x493297(0x1ee))/0x9*(parseInt(_0x493297(0x1f9))/0xa)+parseInt(_0x493297(0x1eb))/0xb;if(_0x123f6f===_0x2f13fe)break;else _0x28f2a3['push'](_0x28f2a3['shift']());}catch(_0x58ba7d){_0x28f2a3['push'](_0x28f2a3['shift']());}}}(a75_0x5b9b,0xe3f99));import{createHash}from'node:crypto';import{existsSync,mkdirSync,readFileSync,renameSync,unlinkSync,writeFileSync}from'node:fs';function a75_0x5b9b(){const _0x47d76e=['serviceCode','invalid','empty','Invalid\x20service\x20registry\x20JSON:\x20','Service\x20manifest\x20file\x20not\x20found:\x20','Add\x20at\x20least\x20one\x20service\x20manifest,\x20then\x20run\x20service\x20import\x20again.','flatMap','path','startsWith','bff\x20target\x20requires\x20functionName.','20tRSqev','].manifest','file','find','target','stringify','Local\x20service\x20not\x20found:\x20','2715747CwwPnW','1544077XTPNHn','Service\x20manifest\x20validation\x20failed:\x0a','slice','string','schemaVersion','$.services[','Unsupported\x20service\x20registry\x20schemaVersion:\x20','registry','filePath','object','push','isArray','report','splice','now','risk','commands','message','errors','8GKLSfS','ENOENT','manifest','Unsupported\x20schemaVersion:\x20','Cannot\x20write\x20service\x20registry:\x20','length','kind','commandCount','Service\x20registry\x20has\x20no\x20services\x20to\x20import.','map','toISOString','CliError','Run\x20lovrabet\x20service\x20list\x20to\x20see\x20imported\x20services.','Remove\x20or\x20migrate\x20','validation','4QfnrLm','2991653ZbnilQ','warnings','manifests','digest','402546QoKRDh','312CnLyRW','.tmp','service','source','utf8','Fix\x20the\x20service\x20manifest\x20and\x20run\x20service\x20validate\x20again.','trim','].manifest.','services','hex','service.json','Fix\x20the\x20JSON\x20syntax\x20and\x20run\x20service\x20validate\x20again.','Fix\x20the\x20JSON\x20file\x20or\x20move\x20it\x20aside\x20and\x20import\x20services\x20again.','48445RsjfCm','parse','normalizedManifest','missing','name','command','updatedAt','registryIndex','code','30363520DlPCtV','localeCompare','version','8242578LjyhVq'];a75_0x5b9b=function(){return _0x47d76e;};return a75_0x5b9b();}import{homedir}from'node:os';import{dirname,resolve}from'node:path';function a75_0x3383(_0x5b055d,_0xfcb31c){_0x5b055d=_0x5b055d-0x1d4;const _0x5b9b5d=a75_0x5b9b();let _0x3383d7=_0x5b9b5d[_0x5b055d];return _0x3383d7;}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=0x1;export const SERVICE_REGISTRY_FILE_NAME=a75_0x2bb9e1(0x1df);export function getServiceRegistryPath(_0x155b74={}){return resolve(_0x155b74['homeDir']??homedir(),PRODUCT_CONFIG['homeDirName'],SERVICE_REGISTRY_FILE_NAME);}export function emptyServiceRegistry(){return{'schemaVersion':SERVICE_REGISTRY_SCHEMA_VERSION,'services':[]};}export function readServiceRegistry(_0x1738a9={}){const _0x1337f6=a75_0x2bb9e1,_0x29f91b=getServiceRegistryPath(_0x1738a9);if(!existsSync(_0x29f91b))return emptyServiceRegistry();try{const _0x346855=readFileSync(_0x29f91b,_0x1337f6(0x1d9));if(!_0x346855[_0x1337f6(0x1db)]())return emptyServiceRegistry();const _0x47db1e=JSON[_0x1337f6(0x1e3)](_0x346855);if(_0x47db1e['schemaVersion']!==SERVICE_REGISTRY_SCHEMA_VERSION)throw CliErrors[_0x1337f6(0x222)](_0x1337f6(0x207)+String(_0x47db1e[_0x1337f6(0x205)]),_0x1337f6(0x221)+_0x29f91b+'.');if(!Array[_0x1337f6(0x20c)](_0x47db1e[_0x1337f6(0x1dd)]))return emptyServiceRegistry();return{'schemaVersion':SERVICE_REGISTRY_SCHEMA_VERSION,'updatedAt':_0x47db1e[_0x1337f6(0x1e8)],'services':_0x47db1e[_0x1337f6(0x1dd)]};}catch(_0x482b3e){if(_0x482b3e instanceof Error&&_0x482b3e[_0x1337f6(0x1e6)]===_0x1337f6(0x21f))throw _0x482b3e;throw CliErrors[_0x1337f6(0x222)](_0x1337f6(0x1f2)+_0x29f91b,_0x1337f6(0x1e1));}}export function writeServiceRegistry(_0x377774,_0x404517={}){const _0x137821=a75_0x2bb9e1,_0x5ada27=getServiceRegistryPath(_0x404517),_0x15ea92=dirname(_0x5ada27);!existsSync(_0x15ea92)&&mkdirSync(_0x15ea92,{'recursive':!![]});const _0x1c55fb=_0x5ada27+_0x137821(0x1d6);try{writeFileSync(_0x1c55fb,JSON[_0x137821(0x1fe)](_0x377774,null,0x2)+'\x0a',{'encoding':'utf8','mode':0x180}),renameSync(_0x1c55fb,_0x5ada27);}catch(_0x1f7d28){try{unlinkSync(_0x1c55fb);}catch{}if(_0x1f7d28?.[_0x137821(0x1ea)]===_0x137821(0x215))throw CliErrors[_0x137821(0x222)](_0x137821(0x218)+_0x5ada27);throw _0x1f7d28;}return _0x5ada27;}export function loadServiceManifestFromFile(_0xe02317){const _0x5f284b=a75_0x2bb9e1,_0x2dab8b=resolve(_0xe02317);if(!existsSync(_0x2dab8b))throw CliErrors[_0x5f284b(0x222)](_0x5f284b(0x1f3)+_0xe02317);let _0x271d3f;const _0x237777=readFileSync(_0x2dab8b,_0x5f284b(0x1d9));try{_0x271d3f=JSON[_0x5f284b(0x1e3)](_0x237777);}catch{throw CliErrors[_0x5f284b(0x222)]('Invalid\x20service\x20manifest\x20JSON:\x20'+_0xe02317,_0x5f284b(0x1e0));}const _0x2f6570=sha256(_0x237777),_0x1b5061=extractLoadedServiceManifests(_0x271d3f,_0x2f6570),_0x7785d4=aggregateValidationReports(_0x1b5061),_0x2958fd=_0x1b5061[0x0];return{'filePath':_0x2dab8b,'hash':_0x2f6570,'kind':isServiceRegistryLike(_0x271d3f)?_0x5f284b(0x208):_0x5f284b(0x216),'manifest':_0x2958fd?.[_0x5f284b(0x216)]??_0x271d3f,'report':_0x7785d4,'normalizedManifest':_0x1b5061[_0x5f284b(0x219)]===0x1?_0x2958fd?.['normalizedManifest']:undefined,'manifests':_0x1b5061};}export function importServiceManifest(_0x388caa,_0x421d14={}){const _0x54ebd5=a75_0x2bb9e1,_0x5ca5af=loadServiceManifestFromFile(_0x388caa);if(!_0x5ca5af[_0x54ebd5(0x20d)]['ok'])throw CliErrors[_0x54ebd5(0x222)](formatValidationFailure(_0x5ca5af[_0x54ebd5(0x20d)]),_0x54ebd5(0x1da));if(_0x5ca5af['manifests'][_0x54ebd5(0x219)]===0x0)throw CliErrors[_0x54ebd5(0x222)](_0x54ebd5(0x21c),_0x54ebd5(0x1f4));const _0x199780=readServiceRegistry(_0x421d14),_0x1bf882=(_0x421d14[_0x54ebd5(0x20f)]??(()=>new Date()))()['toISOString'](),_0x10c57c=[];let _0x4e0443=0x0,_0x124434=0x0;for(const _0x5b39c9 of _0x5ca5af[_0x54ebd5(0x226)]){if(!_0x5b39c9[_0x54ebd5(0x1e4)])continue;const _0x3113eb=_0x5b39c9[_0x54ebd5(0x1e4)][_0x54ebd5(0x1d7)][_0x54ebd5(0x1ea)],_0x235ebc={'serviceCode':_0x3113eb,'version':_0x5b39c9[_0x54ebd5(0x1e4)][_0x54ebd5(0x1ed)],'importedAt':_0x1bf882,'source':{'type':_0x54ebd5(0x1fb),'path':_0x5ca5af[_0x54ebd5(0x209)],'hash':_0x5b39c9['sourceHash']},'manifest':_0x5b39c9[_0x54ebd5(0x216)],'normalizedManifest':_0x5b39c9[_0x54ebd5(0x1e4)]},_0x1d5023=_0x199780[_0x54ebd5(0x1dd)]['findIndex'](_0x5e2864=>_0x5e2864[_0x54ebd5(0x1ef)]===_0x3113eb);_0x1d5023>=0x0?(_0x199780['services'][_0x1d5023]=_0x235ebc,_0x124434++):(_0x199780['services'][_0x54ebd5(0x20b)](_0x235ebc),_0x4e0443++),_0x10c57c[_0x54ebd5(0x20b)](_0x235ebc);}_0x199780[_0x54ebd5(0x1dd)]['sort']((_0xf9ec8d,_0x43d8ca)=>_0xf9ec8d[_0x54ebd5(0x1ef)][_0x54ebd5(0x1ec)](_0x43d8ca[_0x54ebd5(0x1ef)])),_0x199780[_0x54ebd5(0x1e8)]=_0x1bf882;const _0x4d851c=writeServiceRegistry(_0x199780,_0x421d14);return{'registryPath':_0x4d851c,'entry':_0x10c57c[0x0],'replaced':_0x10c57c[_0x54ebd5(0x219)]===0x1?_0x124434===0x1:_0x124434>0x0,'entries':_0x10c57c,'imported':_0x4e0443,'updated':_0x124434,'serviceCount':_0x199780[_0x54ebd5(0x1dd)][_0x54ebd5(0x219)]};}export function exportServiceManifest(_0x3408fc,_0x3ca50b,_0x3ea81d={}){const _0x50e6c6=a75_0x2bb9e1,_0x602570=getServiceRegistryPath(_0x3ea81d),_0x47e6e0=getLocalServiceEntry(_0x3408fc,_0x3ea81d);if(!_0x47e6e0)throw CliErrors[_0x50e6c6(0x222)](_0x50e6c6(0x1ff)+_0x3408fc,_0x50e6c6(0x220));const _0x3de951=resolve(_0x3ca50b),_0x1dcf60=dirname(_0x3de951);return!existsSync(_0x1dcf60)&&mkdirSync(_0x1dcf60,{'recursive':!![]}),writeFileSync(_0x3de951,JSON[_0x50e6c6(0x1fe)](_0x47e6e0[_0x50e6c6(0x216)],null,0x2)+'\x0a',{'encoding':_0x50e6c6(0x1d9),'mode':0x180}),{'registryPath':_0x602570,'filePath':_0x3de951,'entry':_0x47e6e0};}export function removeServiceManifest(_0x1f2140,_0x3714ac={}){const _0x67bf62=a75_0x2bb9e1,_0x44737b=readServiceRegistry(_0x3714ac),_0x5d96e2=_0x1f2140[_0x67bf62(0x1db)](),_0x4c8076=_0x44737b[_0x67bf62(0x1dd)]['findIndex'](_0x3da43f=>_0x3da43f['serviceCode']===_0x5d96e2);if(_0x4c8076<0x0)throw CliErrors[_0x67bf62(0x222)](_0x67bf62(0x1ff)+_0x5d96e2,_0x67bf62(0x220));const [_0x3da0bf]=_0x44737b['services'][_0x67bf62(0x20e)](_0x4c8076,0x1),_0x22987d=(_0x3714ac['now']??(()=>new Date()))()[_0x67bf62(0x21e)]();_0x44737b[_0x67bf62(0x1e8)]=_0x22987d;const _0x39d9ee=writeServiceRegistry(_0x44737b,_0x3714ac);return{'registryPath':_0x39d9ee,'entry':_0x3da0bf,'serviceCount':_0x44737b['services'][_0x67bf62(0x219)]};}export function listLocalServices(_0x544bff={}){const _0x1a073d=a75_0x2bb9e1;return readServiceRegistry(_0x544bff)[_0x1a073d(0x1dd)];}export function getLocalServiceEntry(_0x2a0ace,_0x27ece7={}){const _0x56ab66=a75_0x2bb9e1;return readServiceRegistry(_0x27ece7)['services'][_0x56ab66(0x1fc)](_0x5ca2a3=>_0x5ca2a3[_0x56ab66(0x1ef)]===_0x2a0ace[_0x56ab66(0x1db)]());}export function listLocalServiceTrees(_0x26a938={}){const _0x12b5d3=a75_0x2bb9e1;return readServiceRegistry(_0x26a938)[_0x12b5d3(0x1dd)]['map'](_0xdccbe0=>_0xdccbe0[_0x12b5d3(0x1e4)]);}export function inspectServiceRegistry(_0x246959={}){const _0x1d9c01=a75_0x2bb9e1,_0x30a7b0=getServiceRegistryPath(_0x246959);if(!existsSync(_0x30a7b0))return emptyServiceRegistryInspection(_0x30a7b0,_0x1d9c01(0x1e5),![]);try{const _0x326264=readFileSync(_0x30a7b0,_0x1d9c01(0x1d9));if(!_0x326264[_0x1d9c01(0x1db)]())return emptyServiceRegistryInspection(_0x30a7b0,_0x1d9c01(0x1f1),!![]);const _0x40c177=JSON[_0x1d9c01(0x1e3)](_0x326264);if(_0x40c177['schemaVersion']!==SERVICE_REGISTRY_SCHEMA_VERSION)return{...emptyServiceRegistryInspection(_0x30a7b0,_0x1d9c01(0x1f0),!![]),'schemaVersion':_0x40c177[_0x1d9c01(0x205)],'message':_0x1d9c01(0x217)+String(_0x40c177[_0x1d9c01(0x205)])};if(!Array[_0x1d9c01(0x20c)](_0x40c177[_0x1d9c01(0x1dd)]))return{...emptyServiceRegistryInspection(_0x30a7b0,'invalid',!![]),'schemaVersion':SERVICE_REGISTRY_SCHEMA_VERSION,'updatedAt':_0x40c177['updatedAt'],'message':'services\x20must\x20be\x20an\x20array'};const _0x34dc82=_0x40c177[_0x1d9c01(0x1dd)][_0x1d9c01(0x21d)](summarizeLocalServiceEntry);return{'registryPath':_0x30a7b0,'exists':!![],'status':'ok','schemaVersion':SERVICE_REGISTRY_SCHEMA_VERSION,'updatedAt':_0x40c177[_0x1d9c01(0x1e8)],'serviceCount':_0x34dc82[_0x1d9c01(0x219)],'commandCount':_0x34dc82['reduce']((_0xd46006,_0x3ae1ac)=>_0xd46006+_0x3ae1ac[_0x1d9c01(0x21b)],0x0),'services':_0x34dc82};}catch(_0x342e32){return{...emptyServiceRegistryInspection(_0x30a7b0,_0x1d9c01(0x1f0),!![]),'message':_0x342e32 instanceof Error?_0x342e32[_0x1d9c01(0x212)]:String(_0x342e32)};}}export function formatValidationFailure(_0x65b3bc){const _0x18c7ef=a75_0x2bb9e1,_0x34bb55=_0x65b3bc[_0x18c7ef(0x213)][_0x18c7ef(0x21d)](_0x2c1e28=>_0x2c1e28[_0x18c7ef(0x1f6)]+':\x20'+_0x2c1e28[_0x18c7ef(0x212)]);return _0x18c7ef(0x202)+_0x34bb55['join']('\x0a');}function extractLoadedServiceManifests(_0x21b321,_0x531643){const _0x1e6340=a75_0x2bb9e1;if(!isServiceRegistryLike(_0x21b321)){const _0x34d549=_0x21b321,{manifest:_0x505770,errors:_0x1853e7}=adaptServiceTreeManifestForLegacyFramework(_0x34d549),_0x5a8502=validateServiceTreeManifest(_0x505770),_0xd6c8e6=mergeValidationErrors(_0x5a8502,_0x1853e7);return[{'manifest':_0x34d549,'report':_0xd6c8e6,'normalizedManifest':_0xd6c8e6['ok']?normalizeServiceTreeManifest(_0x505770):undefined,'sourceHash':_0x531643}];}return _0x21b321[_0x1e6340(0x1dd)][_0x1e6340(0x21d)]((_0x4b8d7c,_0x5274ab)=>{const _0x4c90e8=_0x1e6340,_0x52d049=isObjectRecord(_0x4b8d7c)?_0x4b8d7c[_0x4c90e8(0x216)]:undefined,{manifest:_0x2ae008,errors:_0x23446b}=adaptServiceTreeManifestForLegacyFramework(_0x52d049),_0xf6c33a=validateServiceTreeManifest(_0x2ae008),_0x4b8e8c=mergeValidationErrors(_0xf6c33a,_0x23446b),_0x4a6c8e=isObjectRecord(_0x4b8d7c)&&typeof _0x4b8d7c['serviceCode']===_0x4c90e8(0x204)?_0x4b8d7c[_0x4c90e8(0x1ef)]:undefined;return{'manifest':_0x52d049,'report':_0x4b8e8c,'normalizedManifest':_0x4b8e8c['ok']?normalizeServiceTreeManifest(_0x2ae008):undefined,'sourceHash':sha256(JSON[_0x4c90e8(0x1fe)](_0x52d049,null,0x2)+'\x0a'),'registryIndex':_0x5274ab,'registryServiceCode':_0x4a6c8e};});}function mergeValidationErrors(_0x386cc6,_0x5da1f5){const _0x49839c=a75_0x2bb9e1,_0x52471d=_0x386cc6[_0x49839c(0x213)][_0x49839c(0x21d)](_0x417f21=>_0x417f21[_0x49839c(0x212)]==='bff\x20target\x20requires\x20bffCode,\x20bffId,\x20or\x20scriptName.'?{..._0x417f21,'message':_0x49839c(0x1f8)}:_0x417f21),_0x912c1e=[..._0x5da1f5,..._0x52471d];return{'ok':_0x912c1e['length']===0x0,'errors':_0x912c1e,'warnings':_0x386cc6[_0x49839c(0x225)]};}function aggregateValidationReports(_0x1e6b93){const _0x39a294=a75_0x2bb9e1,_0xee335b=_0x1e6b93[_0x39a294(0x1f5)](_0x597a87=>_0x597a87[_0x39a294(0x1e9)]===undefined?_0x597a87[_0x39a294(0x20d)][_0x39a294(0x213)]:_0x597a87[_0x39a294(0x20d)][_0x39a294(0x213)][_0x39a294(0x21d)](_0xf3bccf=>({..._0xf3bccf,'path':prefixRegistryIssuePath(_0x597a87[_0x39a294(0x1e9)],_0xf3bccf[_0x39a294(0x1f6)])}))),_0x242aa9=_0x1e6b93[_0x39a294(0x1f5)](_0x3e9f49=>_0x3e9f49[_0x39a294(0x1e9)]===undefined?_0x3e9f49['report']['warnings']:_0x3e9f49[_0x39a294(0x20d)][_0x39a294(0x225)]['map'](_0x2cf356=>({..._0x2cf356,'path':prefixRegistryIssuePath(_0x3e9f49['registryIndex'],_0x2cf356[_0x39a294(0x1f6)])})));return{'ok':_0xee335b[_0x39a294(0x219)]===0x0,'errors':_0xee335b,'warnings':_0x242aa9};}function prefixRegistryIssuePath(_0x315514,_0xf828e9){const _0x150d94=a75_0x2bb9e1;if(_0xf828e9==='$')return'$.services['+_0x315514+'].manifest';if(_0xf828e9[_0x150d94(0x1f7)]('$.'))return _0x150d94(0x206)+_0x315514+_0x150d94(0x1fa)+_0xf828e9[_0x150d94(0x203)](0x1);if(_0xf828e9[_0x150d94(0x1f7)]('$['))return _0x150d94(0x206)+_0x315514+_0x150d94(0x1fa)+_0xf828e9['slice'](0x1);return _0x150d94(0x206)+_0x315514+_0x150d94(0x1dc)+_0xf828e9;}function isServiceRegistryLike(_0x404e07){const _0x348483=a75_0x2bb9e1;return isObjectRecord(_0x404e07)&&_0x404e07[_0x348483(0x205)]===SERVICE_REGISTRY_SCHEMA_VERSION&&Array[_0x348483(0x20c)](_0x404e07[_0x348483(0x1dd)]);}function isObjectRecord(_0x378d93){const _0x2500cf=a75_0x2bb9e1;return Boolean(_0x378d93)&&typeof _0x378d93===_0x2500cf(0x20a)&&!Array[_0x2500cf(0x20c)](_0x378d93);}function emptyServiceRegistryInspection(_0x3b9fe5,_0x33357c,_0x4c8c99){return{'registryPath':_0x3b9fe5,'exists':_0x4c8c99,'status':_0x33357c,'serviceCount':0x0,'commandCount':0x0,'services':[]};}function summarizeLocalServiceEntry(_0x3a392a){const _0x5a8599=a75_0x2bb9e1,_0x2cd18e=_0x3a392a['normalizedManifest'],_0x2ab293=_0x2cd18e[_0x5a8599(0x211)][_0x5a8599(0x21d)](_0x2ac7ac=>({'path':_0x2ac7ac['cliPath'],'description':_0x2ac7ac['description'],'risk':_0x2ac7ac[_0x5a8599(0x210)],'targetKind':_0x2ac7ac[_0x5a8599(0x1fd)][_0x5a8599(0x21a)],'targetCommand':_0x2ac7ac['target'][_0x5a8599(0x1e7)]}));return{'serviceCode':_0x3a392a[_0x5a8599(0x1ef)],'name':_0x2cd18e[_0x5a8599(0x1d7)][_0x5a8599(0x1e6)],'description':_0x2cd18e['service']['description'],'version':_0x3a392a['version'],'importedAt':_0x3a392a['importedAt'],'source':_0x3a392a[_0x5a8599(0x1d8)],'commandCount':_0x2ab293[_0x5a8599(0x219)],'commands':_0x2ab293};}function sha256(_0x1b449b){const _0x21ef08=a75_0x2bb9e1;return createHash('sha256')['update'](_0x1b449b)[_0x21ef08(0x227)](_0x21ef08(0x1de));}
|
|
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(_0x29f074,_0x435d96){const _0xfae773=a86_0x3734,_0x50d09f=_0x29f074();while(!![]){try{const _0x33b413=parseInt(_0xfae773(0xd0))/0x1*(-parseInt(_0xfae773(0xaf))/0x2)+parseInt(_0xfae773(0xe1))/0x3*(-parseInt(_0xfae773(0xba))/0x4)+parseInt(_0xfae773(0xe6))/0x5*(parseInt(_0xfae773(0xbc))/0x6)+parseInt(_0xfae773(0xb5))/0x7*(-parseInt(_0xfae773(0xd6))/0x8)+-parseInt(_0xfae773(0xbd))/0x9*(-parseInt(_0xfae773(0xb6))/0xa)+parseInt(_0xfae773(0xdc))/0xb+parseInt(_0xfae773(0xcf))/0xc;if(_0x33b413===_0x435d96)break;else _0x50d09f['push'](_0x50d09f['shift']());}catch(_0xe0f37c){_0x50d09f['push'](_0x50d09f['shift']());}}}(a86_0x5e5d,0x461eb));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';function a86_0x3734(_0x41e882,_0x2ac229){_0x41e882=_0x41e882-0xaa;const _0x5e5d21=a86_0x5e5d();let _0x3734ea=_0x5e5d21[_0x41e882];return _0x3734ea;}import{summarizeRuntimeSkill}from'./summary.js';function a86_0x5e5d(){const _0x38c6c7=['input','status','/publish/validate','personal','394712lrrtDZ','appcode','authRequired','../../core/api-client.js','../../skills/runtime-skill-sync.js','files','1380577yMmEHp','scope','Updated\x20personal\x20Skill\x20','NAMESPACE_ONLY','accessKey','1077XQkcRI','valid','Validate\x20a\x20company\x20Skill\x20push\x20package\x20without\x20creating\x20a\x20version\x20or\x20review\x20task.','savedSkill','payload','67835mOKeul','existing','str','metadata','company','\x20for\x20review','appCode','242ZsQVUo','unknown','\x20has\x20scope=\x22','Only\x20personal\x20Skills\x20can\x20be\x20pushed;\x20remote\x20Skill\x20','warnings','errors','77IABWHe','40lDvHaw','/api/cli/v1/skills/','resolvedVersion','Company','3380ZFJWoc','resolvedSlug','180UPsIJT','34371IJXpGO','skillCode','PRIVATE','identical','submitted','diagramValidated','dir','publishInput','version','Submitted\x20company\x20Skill\x20','diagram-file','remoteForPreflight','frontmatterDisplayName','(unknown)','trim','validation','POST','Created\x20personal\x20Skill\x20','11017572GdzkJQ','2749Utubms','\x20is\x20already\x20published\x20and\x20content\x20is\x20identical'];a86_0x5e5d=function(){return _0x38c6c7;};return a86_0x5e5d();}import{readRequiredSkillDiagramInput}from'./diagram.js';import{throwIfSkillValidationFailed,validateSkillDirectory}from'./validate.js';export async function skillPushDryRun(_0x93b997){const _0x1913a3=a86_0x3734,{getRuntimeSkillByCode:_0x33c69d,validateRuntimeSkillPublish:_0x527119}=await import('../../core/api-client.js'),{readPushDirectory:_0x404d02,resolvePushDirectoryIdentity:_0x1cab16}=await import(_0x1913a3(0xda));if(!_0x93b997[_0x1913a3(0xe0)])throw CliErrors[_0x1913a3(0xd8)]();const _0x1cdd21=resolvePushScope(_0x93b997),_0x92ab17=validateSkillDirectory(_0x93b997[_0x1913a3(0xaa)](_0x1913a3(0xc3)));throwIfSkillValidationFailed(_0x92ab17);const {diagram:_0x3a4f70,sourceFilePath:_0x1cc07c}=await readRequiredSkillDiagramInput(_0x93b997[_0x1913a3(0xaa)](_0x1913a3(0xc7))),_0x352a51=diagramPackageExclusion(_0x1cc07c),_0x284fd2=_0x1cab16(_0x92ab17[_0x1913a3(0xc3)],_0x93b997[_0x1913a3(0xae)],remoteFirstMetadataOptions()),_0x3175df=await _0x33c69d(_0x93b997[_0x1913a3(0xae)],_0x284fd2['skillCode']);throwIfBuiltinPushTarget(_0x3175df);if(_0x1cdd21==='company'){const _0x2e87da=_0x404d02(_0x92ab17[_0x1913a3(0xc3)],_0x93b997['appCode'],{...remoteMissingCompanyReadOptions(),..._0x352a51}),_0x56fc18=await _0x527119(_0x93b997[_0x1913a3(0xae)],withDiagram(_0x2e87da[_0x1913a3(0xd2)],_0x3a4f70),{'visibility':'NAMESPACE_ONLY'});return{'method':'POST','url':_0x1913a3(0xb7)+_0x93b997[_0x1913a3(0xae)]+_0x1913a3(0xd4),'body':{'skillCode':_0x2e87da[_0x1913a3(0xbe)],'visibility':'NAMESPACE_ONLY','valid':_0x56fc18[_0x1913a3(0xe2)],'errors':_0x56fc18[_0x1913a3(0xb4)],'warnings':_0x56fc18[_0x1913a3(0xb3)],'resolvedSlug':_0x56fc18[_0x1913a3(0xbb)],'resolvedVersion':_0x56fc18[_0x1913a3(0xb8)],'diagramValidated':_0x56fc18[_0x1913a3(0xc2)]},'description':_0x1913a3(0xe3)};}if(_0x3175df&&_0x3175df['scope']!==_0x1913a3(0xd5))throw CliErrors[_0x1913a3(0xcc)](_0x1913a3(0xb2)+_0x284fd2[_0x1913a3(0xbe)]+'\x20has\x20scope=\x22'+(_0x3175df[_0x1913a3(0xdd)]??_0x1913a3(0xb0))+'\x22.');const _0x2922b5=_0x404d02(_0x92ab17['dir'],_0x93b997['appCode'],{..._0x3175df?remotePersonalReadOptions(!![]):remoteMissingPersonalReadOptions(),..._0x352a51}),_0x185da7=await _0x527119(_0x93b997[_0x1913a3(0xae)],withDiagram(_0x2922b5[_0x1913a3(0xd2)],_0x3a4f70),{'visibility':_0x1913a3(0xbf)});return{'method':_0x1913a3(0xcd),'url':_0x1913a3(0xb7)+_0x93b997[_0x1913a3(0xae)]+_0x1913a3(0xd4),'body':{'skillCode':_0x2922b5[_0x1913a3(0xbe)],'visibility':'PRIVATE','valid':_0x185da7['valid'],'errors':_0x185da7[_0x1913a3(0xb4)],'warnings':_0x185da7[_0x1913a3(0xb3)],'resolvedSlug':_0x185da7[_0x1913a3(0xbb)],'resolvedVersion':_0x185da7[_0x1913a3(0xb8)],'diagramValidated':_0x185da7[_0x1913a3(0xc2)]},'description':'Validate\x20a\x20personal\x20Skill\x20push\x20package\x20without\x20creating\x20or\x20updating\x20a\x20remote\x20Skill.'};}export async function skillPushExecute(_0x189bc0){const _0x25eb18=a86_0x3734,{createPersonalRuntimeSkill:_0x1933f3,downloadRuntimeSkillPackage:_0x3f330a,getRuntimeSkillByCode:_0x53bfd1,publishCompanyRuntimeSkill:_0x5b6a3e,updatePersonalRuntimeSkill:_0x5d456e,validateRuntimeSkillPublish:_0x55fa5e}=await import(_0x25eb18(0xd9)),{verifyRuntimeSkillPackage:_0xd0d926,verifyRuntimeSkillBundle:_0x4a9bdf,readPushDirectory:_0x29ca90,refreshPushDirectoryMetadataFromRemote:_0x7ba656,recordPushedRuntimeSkill:_0x543fc5,resolvePushDirectoryIdentity:_0x3518ab}=await import(_0x25eb18(0xda));if(!_0x189bc0['accessKey'])throw CliErrors[_0x25eb18(0xd8)]();const _0x51b006=resolvePushScope(_0x189bc0),_0x37fc46=_0x189bc0['bool']('confirm-warnings')||_0x189bc0['bool']('confirmWarnings'),_0x2ed735=validateSkillDirectory(_0x189bc0[_0x25eb18(0xaa)](_0x25eb18(0xc3)));throwIfSkillValidationFailed(_0x2ed735);const {diagram:_0x375ae3,sourceFilePath:_0x14510c}=await readRequiredSkillDiagramInput(_0x189bc0[_0x25eb18(0xaa)](_0x25eb18(0xc7))),_0x449bd3=diagramPackageExclusion(_0x14510c),_0x549302=_0x2ed735[_0x25eb18(0xc3)];let _0x310876;if(_0x51b006===_0x25eb18(0xac)){const _0x8b264d=_0x3518ab(_0x549302,_0x189bc0[_0x25eb18(0xae)],remoteFirstMetadataOptions()),_0xfe780e=await _0x53bfd1(_0x189bc0[_0x25eb18(0xae)],_0x8b264d[_0x25eb18(0xbe)]);throwIfBuiltinPushTarget(_0xfe780e);if(_0xfe780e)_0x7ba656(_0x549302,_0xfe780e,_0x189bc0[_0x25eb18(0xae)]);const _0x399d87=_0x29ca90(_0x549302,_0x189bc0['appCode'],{..._0xfe780e?{'targetScope':_0x25eb18(0xac),'ignoreInvalidMetadata':!![]}:remoteMissingCompanyReadOptions(),..._0x449bd3});_0x310876={'scope':'company','payload':_0x399d87,'publishInput':withDiagram(_0x399d87[_0x25eb18(0xd2)],_0x375ae3),'remoteForPreflight':_0xfe780e,'warnings':[]};}else{const _0x2733f1=_0x189bc0[_0x25eb18(0xaa)](_0x25eb18(0xd7))[_0x25eb18(0xcb)](),_0x17386e=Boolean(_0x2733f1),_0x597d67=allowRetargetArgs(_0x17386e),_0x50e147=_0x3518ab(_0x549302,_0x189bc0['appCode'],{...remoteFirstMetadataOptions(),..._0x597d67[0x0]}),_0x3aaa42=await _0x53bfd1(_0x189bc0[_0x25eb18(0xae)],_0x50e147[_0x25eb18(0xbe)]);throwIfBuiltinPushTarget(_0x3aaa42);if(_0x3aaa42){if(_0x3aaa42['scope']!==_0x25eb18(0xd5)){if(_0x17386e)throw CliErrors[_0x25eb18(0xcc)](_0x25eb18(0xb2)+_0x50e147[_0x25eb18(0xbe)]+_0x25eb18(0xb1)+(_0x3aaa42[_0x25eb18(0xdd)]??_0x25eb18(0xb0))+'\x22.');_0x7ba656(_0x549302,_0x3aaa42,_0x189bc0[_0x25eb18(0xae)]);}else!_0x17386e&&_0x7ba656(_0x549302,_0x3aaa42,_0x189bc0['appCode']);}const _0x44efac=_0x29ca90(_0x549302,_0x189bc0[_0x25eb18(0xae)],{..._0x3aaa42?remotePersonalReadOptions(_0x17386e,_0x597d67[0x0]):remoteMissingPersonalReadOptions(_0x597d67[0x0]),..._0x449bd3}),_0x1569ac=_0x3aaa42?.[_0x25eb18(0xdd)]===_0x25eb18(0xd5)&&_0x3aaa42[_0x25eb18(0xbe)]===_0x44efac[_0x25eb18(0xbe)]?_0x3aaa42:undefined,_0x225eae=_0x17386e&&_0x1569ac?withRetargetExistingMetadata(_0x44efac[_0x25eb18(0xd2)],_0x1569ac,{'preferInputSkillName':Boolean(_0x44efac[_0x25eb18(0xc9)])}):_0x44efac[_0x25eb18(0xd2)],_0x5a4528=_0x17386e?buildRetargetWarning(_0x50e147[_0x25eb18(0xab)],_0x189bc0['appCode']):[];_0x310876={'scope':_0x25eb18(0xd5),'payload':_0x44efac,'publishInput':withDiagram(_0x225eae,_0x375ae3),'remoteForPreflight':_0x1569ac,'existing':_0x1569ac,'warnings':[..._0x2ed735[_0x25eb18(0xb3)],..._0x5a4528]};}const _0x148d70=await runRemoteContentPreflight({'scope':_0x310876[_0x25eb18(0xdd)],'remote':_0x310876[_0x25eb18(0xc8)],'publishInput':_0x310876[_0x25eb18(0xc4)],'skillCode':_0x310876[_0x25eb18(0xe5)][_0x25eb18(0xbe)],'appCode':_0x189bc0[_0x25eb18(0xae)],'downloadRuntimeSkillPackage':_0x3f330a,'verifyRuntimeSkillBundle':_0x4a9bdf});if(_0x148d70[_0x25eb18(0xd3)]===_0x25eb18(0xc0))return _0x310876['scope']===_0x25eb18(0xac)?_0x543fc5(_0x549302,_0x148d70[_0x25eb18(0xe4)],_0x189bc0[_0x25eb18(0xae)],{'scope':_0x25eb18(0xac)}):_0x543fc5(_0x549302,_0x148d70[_0x25eb18(0xe4)],_0x189bc0[_0x25eb18(0xae)]),{'ok':!![],'data':{...summarizeRuntimeSkill(_0x148d70[_0x25eb18(0xe4)]),'scope':_0x310876[_0x25eb18(0xdd)],..._0x310876['scope']===_0x25eb18(0xd5)?{'warnings':_0x310876['warnings']}:{},'alreadyPublished':!![],'contentIdentical':!![],'diagramSubmitted':![]},'message':scopeLabel(_0x310876['scope'])+'\x20Skill\x20'+_0x310876['payload'][_0x25eb18(0xbe)]+_0x25eb18(0xd1)};if(_0x310876[_0x25eb18(0xdd)]===_0x25eb18(0xac)){const _0x468b2b=await _0x55fa5e(_0x189bc0[_0x25eb18(0xae)],_0x310876['publishInput'],{'visibility':_0x25eb18(0xdf)});throwIfPublishValidationFailed(_0x25eb18(0xac),_0x310876['payload'][_0x25eb18(0xbe)],_0x468b2b),throwIfUnconfirmedPublishWarnings(_0x25eb18(0xac),_0x310876[_0x25eb18(0xe5)][_0x25eb18(0xbe)],_0x468b2b[_0x25eb18(0xb3)],_0x37fc46);const _0x2bbe27=await _0x5b6a3e(_0x189bc0[_0x25eb18(0xae)],_0x310876[_0x25eb18(0xc4)],{'confirmWarnings':_0x37fc46});return _0x543fc5(_0x549302,{..._0x2bbe27,'files':_0x310876[_0x25eb18(0xc4)]['files']},_0x189bc0[_0x25eb18(0xae)],{'scope':_0x25eb18(0xac)}),{'ok':!![],'data':{...summarizeRuntimeSkill(_0x2bbe27),'scope':_0x25eb18(0xac),'reviewState':_0x25eb18(0xc1),'submittedForReview':!![],'diagramBound':!![],'validation':{'warnings':_0x468b2b['warnings']}},'message':_0x25eb18(0xc6)+_0x310876[_0x25eb18(0xe5)]['skillCode']+'\x20version\x20'+(_0x2bbe27[_0x25eb18(0xc5)]??_0x25eb18(0xca))+_0x25eb18(0xad)};}const _0x58d19d=await _0x55fa5e(_0x189bc0[_0x25eb18(0xae)],_0x310876[_0x25eb18(0xc4)],{'visibility':'PRIVATE'});throwIfPublishValidationFailed(_0x25eb18(0xd5),_0x310876['payload'][_0x25eb18(0xbe)],_0x58d19d),throwIfUnconfirmedPublishWarnings(_0x25eb18(0xd5),_0x310876[_0x25eb18(0xe5)][_0x25eb18(0xbe)],_0x58d19d[_0x25eb18(0xb3)],_0x37fc46);const _0x5048c8={'confirmWarnings':_0x37fc46},_0x3b6fed=_0x310876['existing']?await _0x5d456e(_0x310876[_0x25eb18(0xe5)][_0x25eb18(0xbe)],_0x189bc0[_0x25eb18(0xae)],_0x310876['publishInput'],_0x5048c8):await _0x1933f3(_0x189bc0[_0x25eb18(0xae)],_0x310876[_0x25eb18(0xc4)],_0x5048c8);let _0x7c37b2=_0x3b6fed;if(isMultiFileManifest(_0x310876[_0x25eb18(0xc4)][_0x25eb18(0xdb)])){const _0x6da73e=await _0x3f330a(_0x25eb18(0xd5),_0x3b6fed[_0x25eb18(0xbe)]||_0x310876['payload'][_0x25eb18(0xbe)],_0x189bc0[_0x25eb18(0xae)]);_0x4a9bdf(_0x310876[_0x25eb18(0xc4)][_0x25eb18(0xdb)],_0x6da73e),_0x7c37b2={..._0x3b6fed,'files':_0x310876[_0x25eb18(0xc4)][_0x25eb18(0xdb)]};}else{if(isPackageBackedManifest(_0x3b6fed[_0x25eb18(0xdb)])){const _0x3a3d89=await _0x3f330a(_0x25eb18(0xd5),_0x3b6fed['skillCode']||_0x310876['payload'][_0x25eb18(0xbe)],_0x189bc0[_0x25eb18(0xae)]);_0xd0d926(_0x3b6fed[_0x25eb18(0xdb)],_0x3a3d89);}}return _0x543fc5(_0x549302,_0x7c37b2,_0x189bc0[_0x25eb18(0xae)]),{'ok':!![],'data':{...summarizeRuntimeSkill(_0x3b6fed),'warnings':_0x310876[_0x25eb18(0xb3)],'validation':{'warnings':_0x58d19d[_0x25eb18(0xb3)]},'diagramBound':!![]},'message':_0x310876[_0x25eb18(0xe7)]?_0x25eb18(0xde)+_0x310876[_0x25eb18(0xe5)]['skillCode']:_0x25eb18(0xce)+_0x310876[_0x25eb18(0xe5)][_0x25eb18(0xbe)]};}function scopeLabel(_0x54a190){const _0xa829c9=a86_0x3734;return _0x54a190===_0xa829c9(0xac)?_0xa829c9(0xb9):'Personal';}function withDiagram(_0x48da70,_0x3308e4){return{..._0x48da70,'diagram':_0x3308e4};}function diagramPackageExclusion(_0x3c1492){return _0x3c1492?{'excludedFilePaths':[_0x3c1492]}:{};}
|
|
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]}:{}}
|