@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.
Files changed (208) hide show
  1. package/README.md +22 -14
  2. package/lib/cli.js +4 -1
  3. package/lib/commands/api-doc/index.js +11 -1
  4. package/lib/commands/app/cache.js +2 -1
  5. package/lib/commands/app/definitions.js +7 -1
  6. package/lib/commands/app/eligibility.js +2 -1
  7. package/lib/commands/app/mock-loader.js +1 -1
  8. package/lib/commands/app/remote-source.js +2 -1
  9. package/lib/commands/app/shared.js +1 -1
  10. package/lib/commands/app-config/get.js +1 -1
  11. package/lib/commands/app-config/index.js +1 -1
  12. package/lib/commands/approval/index.js +7 -1
  13. package/lib/commands/artifact/index.js +11 -1
  14. package/lib/commands/auth/device.js +8 -1
  15. package/lib/commands/auth/index.js +9 -1
  16. package/lib/commands/auth/prompt.js +2 -1
  17. package/lib/commands/bff/detail.js +1 -1
  18. package/lib/commands/bff/exec.js +1 -1
  19. package/lib/commands/bff/index.js +1 -1
  20. package/lib/commands/cli-skill/index.js +2 -1
  21. package/lib/commands/common/config-policy.js +2 -1
  22. package/lib/commands/common/constraints.js +2 -1
  23. package/lib/commands/common/flags.js +2 -1
  24. package/lib/commands/common/local-file.js +1 -1
  25. package/lib/commands/config/definitions.js +8 -1
  26. package/lib/commands/config/init.js +4 -1
  27. package/lib/commands/config/shared.js +1 -1
  28. package/lib/commands/data/import-excel.js +10 -1
  29. package/lib/commands/data/index.js +10 -1
  30. package/lib/commands/dataset/detail.js +6 -1
  31. package/lib/commands/dataset/index.js +1 -1
  32. package/lib/commands/dataset/list.js +2 -1
  33. package/lib/commands/dataset/sdk-doc.js +1 -1
  34. package/lib/commands/doctor.js +9 -1
  35. package/lib/commands/file/index.js +3 -1
  36. package/lib/commands/init.js +4 -1
  37. package/lib/commands/issue/context.js +1 -1
  38. package/lib/commands/issue/index.js +1 -1
  39. package/lib/commands/issue/report.js +5 -1
  40. package/lib/commands/kb/index.js +7 -1
  41. package/lib/commands/logs/index.js +1 -1
  42. package/lib/commands/metric/contract.js +5 -1
  43. package/lib/commands/metric/definition.js +4 -1
  44. package/lib/commands/metric/detail.js +1 -1
  45. package/lib/commands/metric/exec.js +3 -1
  46. package/lib/commands/metric/index.js +1 -1
  47. package/lib/commands/metric/list.js +2 -1
  48. package/lib/commands/metric/shared.js +2 -1
  49. package/lib/commands/notification/config-list.js +1 -1
  50. package/lib/commands/notification/index.js +1 -1
  51. package/lib/commands/notification/shared.js +2 -1
  52. package/lib/commands/ocr/index.js +4 -1
  53. package/lib/commands/permit/dataset-get.js +1 -1
  54. package/lib/commands/permit/dataset-set.js +5 -1
  55. package/lib/commands/permit/index.js +1 -1
  56. package/lib/commands/permit/page-get.js +1 -1
  57. package/lib/commands/permit/page-set.js +3 -1
  58. package/lib/commands/permit/role-menus-set.js +4 -1
  59. package/lib/commands/permit/role-menus.js +1 -1
  60. package/lib/commands/permit/shared.js +7 -1
  61. package/lib/commands/personal-bff/index.js +7 -1
  62. package/lib/commands/registry.js +6 -1
  63. package/lib/commands/role/create.js +2 -1
  64. package/lib/commands/role/delete.js +2 -1
  65. package/lib/commands/role/detail.js +1 -1
  66. package/lib/commands/role/index.js +1 -1
  67. package/lib/commands/role/list.js +2 -1
  68. package/lib/commands/role/shared.js +8 -1
  69. package/lib/commands/role/update.js +3 -1
  70. package/lib/commands/role/user-add.js +2 -1
  71. package/lib/commands/role/user-remove.js +2 -1
  72. package/lib/commands/schedule/index.js +7 -1
  73. package/lib/commands/schema.js +1 -1
  74. package/lib/commands/service/dynamic.js +10 -1
  75. package/lib/commands/service/function-name-adapter.js +3 -1
  76. package/lib/commands/service/index.js +8 -1
  77. package/lib/commands/service/registry.js +12 -1
  78. package/lib/commands/skill/commands/create.js +3 -1
  79. package/lib/commands/skill/commands/diagram.js +4 -1
  80. package/lib/commands/skill/commands/install.js +6 -1
  81. package/lib/commands/skill/commands/list.js +3 -1
  82. package/lib/commands/skill/commands/push.js +1 -1
  83. package/lib/commands/skill/commands/validate.js +1 -1
  84. package/lib/commands/skill/diagram.js +3 -1
  85. package/lib/commands/skill/flags.js +4 -1
  86. package/lib/commands/skill/index.js +1 -1
  87. package/lib/commands/skill/manifest-helpers.js +1 -1
  88. package/lib/commands/skill/push-execute.js +11 -1
  89. package/lib/commands/skill/push-flow-helpers.js +4 -1
  90. package/lib/commands/skill/push-retarget.js +1 -1
  91. package/lib/commands/skill/scopes.js +1 -1
  92. package/lib/commands/skill/summary.js +1 -1
  93. package/lib/commands/skill/templates.js +8 -1
  94. package/lib/commands/skill/validate.js +8 -1
  95. package/lib/commands/sql/detail.js +1 -1
  96. package/lib/commands/sql/exec.js +2 -1
  97. package/lib/commands/sql/index.js +1 -1
  98. package/lib/commands/update.d.ts +2 -1
  99. package/lib/commands/update.js +8 -1
  100. package/lib/commands/user-account/bind.js +3 -1
  101. package/lib/commands/user-account/index.js +1 -1
  102. package/lib/commands/workspace/index.js +7 -1
  103. package/lib/config/domain-config.js +6 -1
  104. package/lib/config/schema.js +5 -1
  105. package/lib/constant/app.js +1 -1
  106. package/lib/constant/auth-mode.js +1 -1
  107. package/lib/constant/cli.js +3 -1
  108. package/lib/constant/defaults.js +1 -1
  109. package/lib/constant/distribution.js +1 -1
  110. package/lib/constant/domain.js +2 -1
  111. package/lib/constant/env.js +1 -1
  112. package/lib/constant/output.js +1 -1
  113. package/lib/constant/product.js +2 -1
  114. package/lib/constant/region.js +2 -1
  115. package/lib/constant/risk.js +1 -1
  116. package/lib/constant/url.js +1 -1
  117. package/lib/context.js +11 -1
  118. package/lib/core/api-client.js +38 -1
  119. package/lib/core/db-resolver.js +1 -1
  120. package/lib/core/kb-management-client.js +6 -1
  121. package/lib/core/kb-sdk-errors.js +2 -1
  122. package/lib/core/kb-search-client.js +2 -1
  123. package/lib/core/sdk-client.js +5 -1
  124. package/lib/errors.js +2 -1
  125. package/lib/framework/access-error.js +1 -1
  126. package/lib/framework/build-all-flags.js +1 -1
  127. package/lib/framework/dryrun.js +1 -1
  128. package/lib/framework/flags.js +1 -1
  129. package/lib/framework/help.js +2 -1
  130. package/lib/framework/index.js +1 -1
  131. package/lib/framework/output.js +1 -1
  132. package/lib/framework/preparse.js +3 -1
  133. package/lib/framework/rate-limit.js +2 -1
  134. package/lib/framework/raw-flags.js +2 -1
  135. package/lib/framework/response.js +1 -1
  136. package/lib/framework/runner-confirmation.js +2 -1
  137. package/lib/framework/runner-error.js +2 -1
  138. package/lib/framework/runner.js +9 -1
  139. package/lib/framework/schema-export.js +2 -1
  140. package/lib/framework/service-order.js +1 -1
  141. package/lib/framework/types.js +1 -1
  142. package/lib/generated/build-info.d.ts +4 -4
  143. package/lib/generated/build-info.js +1 -1
  144. package/lib/generated/official-routing.js +2 -1
  145. package/lib/generated/routing-contract.js +1 -1
  146. package/lib/help.js +1 -1
  147. package/lib/runtime/confirmation.js +1 -1
  148. package/lib/runtime/event.js +1 -1
  149. package/lib/runtime/index.js +4 -1
  150. package/lib/runtime/queue.js +1 -1
  151. package/lib/runtime/resolve.js +2 -1
  152. package/lib/runtime/types.js +1 -1
  153. package/lib/services/dataset-import/auto-id-runner.js +9 -1
  154. package/lib/services/dataset-import/excel-reader.js +25 -1
  155. package/lib/services/dataset-import/image-bytes.js +6 -1
  156. package/lib/services/dataset-import/image-ooxml.js +15 -1
  157. package/lib/services/dataset-import/image-runner.js +9 -1
  158. package/lib/services/dataset-import/metadata.js +1 -1
  159. package/lib/services/dataset-import/preview.js +1 -1
  160. package/lib/services/dataset-import/runner.js +13 -1
  161. package/lib/services/dataset-import/types.js +1 -1
  162. package/lib/skills/builtin-skill.js +8 -1
  163. package/lib/skills/install-updated-skill.d.ts +8 -0
  164. package/lib/skills/install-updated-skill.js +3 -0
  165. package/lib/skills/local-skills-installer.d.ts +2 -0
  166. package/lib/skills/local-skills-installer.js +1 -0
  167. package/lib/skills/npx-skills-add.d.ts +2 -2
  168. package/lib/skills/npx-skills-add.js +4 -1
  169. package/lib/skills/runtime-skill-sync/constants.js +1 -1
  170. package/lib/skills/runtime-skill-sync/fs-utils.js +3 -1
  171. package/lib/skills/runtime-skill-sync/hashing.js +1 -1
  172. package/lib/skills/runtime-skill-sync/install-target.js +1 -1
  173. package/lib/skills/runtime-skill-sync/links.js +9 -1
  174. package/lib/skills/runtime-skill-sync/list-local.js +4 -1
  175. package/lib/skills/runtime-skill-sync/local-files.js +5 -1
  176. package/lib/skills/runtime-skill-sync/materialize.js +9 -1
  177. package/lib/skills/runtime-skill-sync/metadata.js +3 -1
  178. package/lib/skills/runtime-skill-sync/paths.js +2 -1
  179. package/lib/skills/runtime-skill-sync/push.js +8 -1
  180. package/lib/skills/runtime-skill-sync/scopes.js +1 -1
  181. package/lib/skills/runtime-skill-sync/types.js +1 -1
  182. package/lib/skills/runtime-skill-sync/zip-codec.js +2 -1
  183. package/lib/skills/runtime-skill-sync/zip-package.js +6 -1
  184. package/lib/skills/runtime-skill-sync.js +1 -1
  185. package/lib/skills/skill-presence.d.ts +1 -34
  186. package/lib/skills/skill-presence.js +2 -1
  187. package/lib/utils/access-key-redaction.js +2 -1
  188. package/lib/utils/apply-jq-filter.js +1 -1
  189. package/lib/utils/cli-version-check.js +2 -1
  190. package/lib/utils/cli-version-policy.js +3 -1
  191. package/lib/utils/logger.js +3 -1
  192. package/lib/utils/lossless-json.js +3 -1
  193. package/lib/utils/params.js +3 -1
  194. package/lib/utils/positive-safe-integer.js +1 -1
  195. package/lib/utils/redaction.js +2 -1
  196. package/lib/utils/runtime-user-id.js +1 -1
  197. package/lib/utils/update-notice.js +3 -1
  198. package/lib/utils/version.js +1 -1
  199. package/lib/utils/write-cli-side-channel.js +1 -1
  200. package/package.json +5 -7
  201. package/skills/lovrabet/SKILL.md +3 -3
  202. package/skills/lovrabet/references/lovrabet-skill-install.md +1 -1
  203. package/skills/lovrabet/references/lovrabet-update.md +6 -4
  204. package/skills/lovrabet-report-generation/SKILL.md +1 -1
  205. package/skills/lovrabet.manifest.json +3 -3
  206. package/lib/postinstall.d.ts +0 -2
  207. package/lib/postinstall.js +0 -1
  208. 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
- (function(_0x4558f5,_0x2a337c){const _0x26d90a=a73_0x4d5e,_0x30b3f3=_0x4558f5();while(!![]){try{const _0x1790aa=parseInt(_0x26d90a(0xdb))/0x1+parseInt(_0x26d90a(0xd7))/0x2*(parseInt(_0x26d90a(0xe8))/0x3)+-parseInt(_0x26d90a(0xe2))/0x4+-parseInt(_0x26d90a(0xf2))/0x5*(parseInt(_0x26d90a(0xd8))/0x6)+parseInt(_0x26d90a(0xf1))/0x7*(-parseInt(_0x26d90a(0xeb))/0x8)+-parseInt(_0x26d90a(0xe9))/0x9+parseInt(_0x26d90a(0xd9))/0xa;if(_0x1790aa===_0x2a337c)break;else _0x30b3f3['push'](_0x30b3f3['shift']());}catch(_0x2923f0){_0x30b3f3['push'](_0x30b3f3['shift']());}}}(a73_0x4462,0x2f800));export function adaptServiceTreeManifestForLegacyFramework(_0x172760){const _0x216176=a73_0x4d5e,_0x3c26e8=cloneJsonValue(_0x172760),_0x5a7011=[];if(!isObjectRecord(_0x3c26e8))return{'manifest':_0x3c26e8,'errors':_0x5a7011};return Array[_0x216176(0xd2)](_0x3c26e8['commands'])&&_0x3c26e8[_0x216176(0xe4)]['forEach']((_0x1f4d2a,_0x47fc7f)=>{const _0x312b8f=_0x216176;if(!isObjectRecord(_0x1f4d2a))return;adaptBffTarget(_0x1f4d2a[_0x312b8f(0xe3)],_0x312b8f(0xe1)+_0x47fc7f+_0x312b8f(0xee),_0x5a7011);}),adaptResources(_0x3c26e8[_0x216176(0xdc)],'$.resources',_0x5a7011),{'manifest':_0x3c26e8,'errors':_0x5a7011};}export function toPublicServiceTreeTarget(_0x45abed){const _0x4e2fa6=a73_0x4d5e,{scriptName:_0x16b87a,..._0x55b7c5}=_0x45abed;return typeof _0x16b87a===_0x4e2fa6(0xf4)&&_0x16b87a[_0x4e2fa6(0xdd)]()&&(_0x55b7c5[_0x4e2fa6(0xdf)]=_0x16b87a),_0x55b7c5;}export function toPublicNormalizedServiceTree(_0xe392cb){const _0x38e27a=a73_0x4d5e;return{..._0xe392cb,'commands':_0xe392cb['commands'][_0x38e27a(0xea)](_0x41ca3e=>({..._0x41ca3e,'target':toPublicServiceTreeTarget(_0x41ca3e[_0x38e27a(0xe3)])}))};}function a73_0x4d5e(_0x449982,_0x3a38a0){_0x449982=_0x449982-0xd2;const _0x446291=a73_0x4462();let _0x4d5ef6=_0x446291[_0x449982];return _0x4d5ef6;}function adaptResources(_0x1dbe30,_0xd5f857,_0x5ad4cb){const _0x3ceba8=a73_0x4d5e;if(!isObjectRecord(_0x1dbe30))return;for(const [_0x464a1a,_0x2d5a0f]of Object[_0x3ceba8(0xec)](_0x1dbe30)){if(!isObjectRecord(_0x2d5a0f))continue;const _0x5c8e47=_0xd5f857+'.'+_0x464a1a;if(isObjectRecord(_0x2d5a0f['actions']))for(const [_0x4fb3ac,_0x1c39b4]of Object[_0x3ceba8(0xec)](_0x2d5a0f['actions'])){if(!isObjectRecord(_0x1c39b4))continue;const _0x79f471=_0x5c8e47+_0x3ceba8(0xf6)+_0x4fb3ac,_0x2cd467=isObjectRecord(_0x1c39b4['target'])&&_0x1c39b4[_0x3ceba8(0xe3)][_0x3ceba8(0xe0)]===_0x3ceba8(0xf3);adaptBffTarget(_0x1c39b4[_0x3ceba8(0xe3)],_0x79f471+_0x3ceba8(0xd4),_0x5ad4cb),(_0x2cd467||isBffAction(_0x1c39b4))&&adaptFunctionNameField(_0x1c39b4,_0x79f471,_0x5ad4cb);}adaptResources(_0x2d5a0f['resources'],_0x5c8e47+_0x3ceba8(0xd3),_0x5ad4cb);}}function adaptBffTarget(_0x5afd91,_0x258d6c,_0x4e9594){const _0x3458c2=a73_0x4d5e;if(!isObjectRecord(_0x5afd91)||_0x5afd91['kind']!==_0x3458c2(0xf3))return;adaptFunctionNameField(_0x5afd91,_0x258d6c,_0x4e9594);}function a73_0x4462(){const _0x322075=['1988685jQRNGx','map','8juKJwm','entries','bff.exec','].target','prototype','error','1165696BrYJJD','5eQCiNW','bff','string','.scriptName','.actions.','push','isArray','.resources','.target','action','.functionName','680732uWCLuq','1514028jdAqEx','2253930AakNcJ','hasOwnProperty','319364yohQMt','resources','trim','fromEntries','functionName','kind','$.commands[','202928tHdvmx','target','commands','object','scriptName','call','3DXCRpN'];a73_0x4462=function(){return _0x322075;};return a73_0x4462();}function adaptFunctionNameField(_0x4a296e,_0x329187,_0x3632c7){const _0x260332=a73_0x4d5e;Object[_0x260332(0xef)]['hasOwnProperty']['call'](_0x4a296e,_0x260332(0xe6))&&_0x3632c7[_0x260332(0xf7)]({'level':_0x260332(0xf0),'path':_0x329187+_0x260332(0xf5),'message':'Use\x20functionName;\x20scriptName\x20is\x20not\x20part\x20of\x20the\x20runtime\x20Service\x20Tree\x20contract.'});if(Object[_0x260332(0xef)][_0x260332(0xda)][_0x260332(0xe7)](_0x4a296e,'functionName')){if(typeof _0x4a296e[_0x260332(0xdf)]!==_0x260332(0xf4)||!_0x4a296e['functionName'][_0x260332(0xdd)]()){_0x3632c7['push']({'level':_0x260332(0xf0),'path':_0x329187+_0x260332(0xd6),'message':'functionName\x20must\x20be\x20a\x20non-empty\x20string.'}),delete _0x4a296e['functionName'];return;}_0x4a296e[_0x260332(0xe6)]=_0x4a296e[_0x260332(0xdf)],delete _0x4a296e[_0x260332(0xdf)];}}function isBffAction(_0x3f2986){const _0xdf42d5=a73_0x4d5e;return _0x3f2986['kind']===_0xdf42d5(0xf3)||_0x3f2986[_0xdf42d5(0xd5)]===_0xdf42d5(0xed)||_0x3f2986[_0xdf42d5(0xe3)]===_0xdf42d5(0xed);}function cloneJsonValue(_0x564be0){const _0x55ab72=a73_0x4d5e;if(Array[_0x55ab72(0xd2)](_0x564be0))return _0x564be0[_0x55ab72(0xea)](_0x2d661b=>cloneJsonValue(_0x2d661b));if(isObjectRecord(_0x564be0))return Object[_0x55ab72(0xde)](Object['entries'](_0x564be0)[_0x55ab72(0xea)](([_0x9a03ba,_0x182481])=>[_0x9a03ba,cloneJsonValue(_0x182481)]));return _0x564be0;}function isObjectRecord(_0x31eb97){const _0x314e0e=a73_0x4d5e;return Boolean(_0x31eb97)&&typeof _0x31eb97===_0x314e0e(0xe5)&&!Array[_0x314e0e(0xd2)](_0x31eb97);}
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
- const a76_0x407a94=a76_0x1704;function a76_0x329e(){const _0xcd5074=['Refusing\x20to\x20overwrite\x20symlink:\x20','type','files','2178062vXJqNy','create','244085vaHDcg','8581632pEQVoD','rendered','bool','content','Create\x20a\x20local\x20self-contained\x20runtime\x20Skill\x20draft','965160TeXjsB','skillName','1101647vFaPme','skillDir','110310KaUrhL','681XAOPtQ','Omitting\x20--type\x20is\x20deprecated;\x20defaulting\x20to\x20write\x20for\x20compatibility.\x20Pass\x20--type\x20read\x20or\x20--type\x20write\x20explicitly.','map','66VAlJzu','target','WRITE','read','Skill\x20path\x20already\x20exists\x20and\x20is\x20not\x20a\x20writable\x20directory:\x20','Create\x20a\x20local\x20runtime\x20Skill\x20draft\x20without\x20uploading\x20or\x20publishing\x20it.','trim','3852hkEqor','str','validation','force','path','Created\x20local\x20Skill\x20draft\x20','name','8612PJhyCM'];a76_0x329e=function(){return _0xcd5074;};return a76_0x329e();}(function(_0x564161,_0x48876c){const _0x3cd591=a76_0x1704,_0x178427=_0x564161();while(!![]){try{const _0x6d67cb=-parseInt(_0x3cd591(0xe3))/0x1+-parseInt(_0x3cd591(0xd9))/0x2+parseInt(_0x3cd591(0xe6))/0x3*(-parseInt(_0x3cd591(0xd5))/0x4)+-parseInt(_0x3cd591(0xdb))/0x5*(parseInt(_0x3cd591(0xc7))/0x6)+parseInt(_0x3cd591(0xe1))/0x7+-parseInt(_0x3cd591(0xdc))/0x8+-parseInt(_0x3cd591(0xce))/0x9*(-parseInt(_0x3cd591(0xe5))/0xa);if(_0x6d67cb===_0x48876c)break;else _0x178427['push'](_0x178427['shift']());}catch(_0x3316cd){_0x178427['push'](_0x178427['shift']());}}}(a76_0x329e,0x8b2c0));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';function a76_0x1704(_0x2206e7,_0x435c2d){_0x2206e7=_0x2206e7-0xc6;const _0x329ec9=a76_0x329e();let _0x170411=_0x329ec9[_0x2206e7];return _0x170411;}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':a76_0x407a94(0xda),'description':a76_0x407a94(0xe0),'risk':a76_0x407a94(0xca),'requiresAuth':![],'requiresAppCode':![],'flags':[CREATE_NAME_FLAG,TYPE_FLAG,TARGET_FLAG,FORCE_FLAG],async 'dryRun'(_0x569d47){const _0x169f39=a76_0x407a94,_0x1b47bf=buildSkillCreatePlan(_0x569d47[_0x169f39(0xcf)](_0x169f39(0xd4)),_0x569d47['str'](_0x169f39(0xd7)),_0x569d47['str'](_0x169f39(0xc8)));return{'method':_0x169f39(0xc9),'url':_0x1b47bf[_0x169f39(0xe4)],'body':{'skillName':_0x1b47bf[_0x169f39(0xdd)][_0x169f39(0xe2)],'type':_0x1b47bf['rendered'][_0x169f39(0xd7)],'selfContained':!![],'files':_0x1b47bf['rendered']['files'][_0x169f39(0xc6)](_0x537000=>_0x537000['path'])},'description':_0x169f39(0xcc)};},async 'execute'(_0x4a7312){const _0x58b32f=a76_0x407a94,_0x6ab139=buildSkillCreatePlan(_0x4a7312[_0x58b32f(0xcf)]('name'),_0x4a7312[_0x58b32f(0xcf)](_0x58b32f(0xd7)),_0x4a7312[_0x58b32f(0xcf)](_0x58b32f(0xc8)));return writeSkillDraft(_0x6ab139,_0x4a7312[_0x58b32f(0xde)](_0x58b32f(0xd1))),{'ok':!![],'data':{'skillName':_0x6ab139['rendered'][_0x58b32f(0xe2)],'type':_0x6ab139['rendered']['type'],'dir':_0x6ab139[_0x58b32f(0xe4)],'files':_0x6ab139[_0x58b32f(0xdd)][_0x58b32f(0xd8)]['map'](_0x4ac26a=>_0x4ac26a[_0x58b32f(0xd2)])},'message':_0x58b32f(0xd3)+_0x6ab139[_0x58b32f(0xdd)][_0x58b32f(0xe2)]};}};function buildSkillCreatePlan(_0x117a21,_0x3ae701,_0x46ef3c){const _0x1c4802=a76_0x407a94,_0x4e10a3=_0x3ae701[_0x1c4802(0xcd)](),_0x457d5d=renderSkillTemplate({'skillName':_0x117a21,'type':_0x4e10a3});!_0x4e10a3&&writeCliSideChannelLine(_0x1c4802(0xe7));const _0x338321=resolve(normalizeSkillTarget(_0x46ef3c));return{'rendered':_0x457d5d,'targetRoot':_0x338321,'skillDir':resolve(_0x338321,_0x457d5d[_0x1c4802(0xe2)])};}function normalizeSkillTarget(_0x1407f4){const _0x5dd790=a76_0x407a94;return(_0x1407f4||DEFAULT_SKILL_TARGET)[_0x5dd790(0xcd)]()||DEFAULT_SKILL_TARGET;}function writeSkillDraft(_0x44a67a,_0x7a7c81){const _0x345a04=a76_0x407a94;if(existsSync(_0x44a67a[_0x345a04(0xe4)])){const _0x231f61=lstatSync(_0x44a67a[_0x345a04(0xe4)]);if(!_0x231f61['isDirectory']()||_0x231f61['isSymbolicLink']())throw CliErrors['validation'](_0x345a04(0xcb)+_0x44a67a[_0x345a04(0xe4)]);if(!_0x7a7c81)throw CliErrors[_0x345a04(0xd0)]('Skill\x20directory\x20already\x20exists:\x20'+_0x44a67a[_0x345a04(0xe4)],'Pass\x20--force\x20to\x20overwrite\x20generated\x20template\x20files.');}for(const _0x111490 of _0x44a67a['rendered'][_0x345a04(0xd8)]){const _0x176158=resolve(_0x44a67a[_0x345a04(0xe4)],_0x111490[_0x345a04(0xd2)]),_0xc1c701=dirname(_0x176158);mkdirSync(_0xc1c701,{'recursive':!![]});if(existsSync(_0x176158)&&lstatSync(_0x176158)['isSymbolicLink']())throw CliErrors[_0x345a04(0xd0)](_0x345a04(0xd6)+_0x176158);writeFileSync(_0x176158,_0x111490[_0x345a04(0xdf)],'utf8');}}
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
- const a77_0x435b27=a77_0x3516;(function(_0x3dd3c7,_0x461ace){const _0x547111=a77_0x3516,_0x497ef0=_0x3dd3c7();while(!![]){try{const _0x2966a4=parseInt(_0x547111(0xcc))/0x1*(-parseInt(_0x547111(0xc7))/0x2)+parseInt(_0x547111(0xb5))/0x3+-parseInt(_0x547111(0xce))/0x4*(parseInt(_0x547111(0xc1))/0x5)+-parseInt(_0x547111(0xc2))/0x6+-parseInt(_0x547111(0xac))/0x7*(-parseInt(_0x547111(0xbe))/0x8)+-parseInt(_0x547111(0xcf))/0x9*(parseInt(_0x547111(0xbb))/0xa)+parseInt(_0x547111(0xa3))/0xb;if(_0x2966a4===_0x461ace)break;else _0x497ef0['push'](_0x497ef0['shift']());}catch(_0x103f75){_0x497ef0['push'](_0x497ef0['shift']());}}}(a77_0x4bdf,0x37452));import{getRuntimeSkillVersionDiagram,putRuntimeSkillVersionDiagram,validateRuntimeSkillVersionDiagram}from'../../../core/api-client.js';import{CliErrors}from'../../../errors.js';function a77_0x3516(_0x42f903,_0x2e52cb){_0x42f903=_0x42f903-0xa1;const _0x4bdf8d=a77_0x4bdf();let _0x3516a8=_0x4bdf8d[_0x42f903];return _0x3516a8;}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';function a77_0x4bdf(){const _0x455a87=['str','Skill\x20diagram\x20validation\x20passed\x20for\x20',';\x20first\x20write\x20expects\x20revision\x20','4580532KspiLn','\x20is\x20unchanged.','\x20Skill\x20diagram\x20for\x20','--source-fingerprint\x20must\x20be\x20lowercase\x20sha256:<64\x20hex\x20characters>.','read','skill','diagram-file','appCode','isInteger','77WneBBY','test','No\x20Skill\x20diagram\x20is\x20stored\x20for\x20','action','validation','Show\x20the\x20current\x20Mermaid\x20diagram\x20for\x20one\x20exact\x20Skill\x20version','created','Create\x20or\x20replace\x20a\x20Mermaid\x20diagram\x20for\x20a\x20specific\x20Skill\x20version','Validate\x20a\x20Mermaid\x20diagram\x20replacement\x20for\x20one\x20exact\x20Skill\x20version','497967HMXRAx','skillCode','scope','Found\x20Skill\x20diagram\x20for\x20','unchanged','diagram-push','787690nJLsVe','trim','num','115288NXDsbL','Skill\x20diagram\x20for\x20','skill-code','673345NFbJmF','513576XXWyfy','--expected-diagram-revision\x20must\x20be\x20a\x20non-negative\x20integer.','write','Updated','Creates\x20or\x20replaces\x20a\x20Mermaid\x20diagram\x20for\x20an\x20exact\x20Skill\x20version.\x20The\x20write\x20is\x20rejected\x20if\x20the\x20server\x20version\x20has\x20changed.\x20The\x20confirmation\x20UI\x20does\x20not\x20show\x20the\x20diagram\x20body.','6wXmwjs','personal','expectedDiagramRevision','Created','--skill-code,\x20--version,\x20and\x20--scope\x20personal|company\x20are\x20required.','71834DqpFAo','version','4XGaxKw','9raqULJ'];a77_0x4bdf=function(){return _0x455a87;};return a77_0x4bdf();}const TARGET_FLAGS=[DIAGRAM_SKILL_CODE_FLAG,DIAGRAM_VERSION_FLAG,DIAGRAM_SCOPE_FLAG],WRITE_FLAGS=[...TARGET_FLAGS,SOURCE_FINGERPRINT_FLAG,EXPECTED_DIAGRAM_REVISION_FLAG,DIAGRAM_FILE_FLAG];function readDiagramTarget(_0x5c548f){const _0x3548a8=a77_0x3516,_0x34a948=_0x5c548f['str'](_0x3548a8(0xc0))[_0x3548a8(0xbc)](),_0x15d52c=_0x5c548f[_0x3548a8(0xd0)](_0x3548a8(0xcd))[_0x3548a8(0xbc)](),_0x222f15=_0x5c548f[_0x3548a8(0xd0)](_0x3548a8(0xb7));if(!_0x34a948||!_0x15d52c||_0x222f15!==_0x3548a8(0xc8)&&_0x222f15!=='company')throw CliErrors['validation'](_0x3548a8(0xcb));return{'skillCode':_0x34a948,'version':_0x15d52c,'scope':_0x222f15};}async function readDiagramWriteInput(_0x5b315){const _0x263348=a77_0x3516,_0x4bf583=_0x5b315[_0x263348(0xbd)]('expected-diagram-revision'),_0x5b7b58=_0x5b315[_0x263348(0xd0)]('source-fingerprint')[_0x263348(0xbc)]();if(!Number[_0x263348(0xab)](_0x4bf583)||_0x4bf583<0x0)throw CliErrors[_0x263348(0xb0)](_0x263348(0xc3));if(!/^sha256:[0-9a-f]{64}$/[_0x263348(0xad)](_0x5b7b58))throw CliErrors['validation'](_0x263348(0xa6));return{'expectedDiagramRevision':_0x4bf583,'sourceFingerprint':_0x5b7b58,'diagram':await readRequiredSkillDiagram(_0x5b315[_0x263348(0xd0)](_0x263348(0xa9)))};}export const diagramValidateCommand={'service':a77_0x435b27(0xa8),'command':'diagram-validate','description':a77_0x435b27(0xb4),'risk':a77_0x435b27(0xa7),'flags':WRITE_FLAGS,async 'execute'(_0x2e3254){const _0x5b5019=a77_0x435b27,_0x2e993d=readDiagramTarget(_0x2e3254),_0x410b91=await validateRuntimeSkillVersionDiagram(_0x2e3254['appCode'],_0x2e993d['skillCode'],_0x2e993d[_0x5b5019(0xcd)],_0x2e993d[_0x5b5019(0xb7)],await readDiagramWriteInput(_0x2e3254));return{'ok':!![],'data':_0x410b91,'message':_0x5b5019(0xa1)+_0x2e993d[_0x5b5019(0xb6)]+'@'+_0x2e993d[_0x5b5019(0xcd)]+'.'};}};export const diagramPushCommand={'service':a77_0x435b27(0xa8),'command':a77_0x435b27(0xba),'description':a77_0x435b27(0xb3),'risk':a77_0x435b27(0xc4),'confirmationDescription':a77_0x435b27(0xc6),'flags':WRITE_FLAGS,async 'execute'(_0x2a2cc3){const _0x38d68b=a77_0x435b27,_0x3c9d18=readDiagramTarget(_0x2a2cc3),_0x4632f2=await putRuntimeSkillVersionDiagram(_0x2a2cc3[_0x38d68b(0xaa)],_0x3c9d18[_0x38d68b(0xb6)],_0x3c9d18[_0x38d68b(0xcd)],_0x3c9d18[_0x38d68b(0xb7)],await readDiagramWriteInput(_0x2a2cc3));return{'ok':!![],'data':_0x4632f2,'message':_0x4632f2['action']===_0x38d68b(0xb9)?_0x38d68b(0xbf)+_0x3c9d18[_0x38d68b(0xb6)]+'@'+_0x3c9d18[_0x38d68b(0xcd)]+_0x38d68b(0xa4):(_0x4632f2[_0x38d68b(0xaf)]===_0x38d68b(0xb2)?_0x38d68b(0xca):_0x38d68b(0xc5))+_0x38d68b(0xa5)+_0x3c9d18['skillCode']+'@'+_0x3c9d18[_0x38d68b(0xcd)]+'.'};}};export const diagramShowCommand={'service':'skill','command':'diagram-show','description':a77_0x435b27(0xb1),'risk':a77_0x435b27(0xa7),'flags':TARGET_FLAGS,async 'execute'(_0x5b0d37){const _0x5a534b=a77_0x435b27,_0x59b2c2=readDiagramTarget(_0x5b0d37),_0x42a37e=await getRuntimeSkillVersionDiagram(_0x5b0d37['appCode'],_0x59b2c2[_0x5a534b(0xb6)],_0x59b2c2[_0x5a534b(0xcd)],_0x59b2c2['scope']);return{'ok':!![],'data':_0x42a37e,'message':_0x42a37e['found']?_0x5a534b(0xb8)+_0x59b2c2[_0x5a534b(0xb6)]+'@'+_0x59b2c2['version']+';\x20next\x20write\x20expects\x20revision\x20'+_0x42a37e[_0x5a534b(0xc9)]+'.':_0x5a534b(0xae)+_0x59b2c2[_0x5a534b(0xb6)]+'@'+_0x59b2c2[_0x5a534b(0xcd)]+_0x5a534b(0xa2)+_0x42a37e[_0x5a534b(0xc9)]+'.'};}};
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
- const a78_0x2eac6e=a78_0x1afa;function a78_0x1afa(_0x408595,_0x48ed9b){_0x408595=_0x408595-0x14a;const _0x496cc5=a78_0x496c();let _0x1afa5f=_0x496cc5[_0x408595];return _0x1afa5f;}(function(_0x55a34f,_0x3e71c5){const _0xb9c029=a78_0x1afa,_0x8a5f4=_0x55a34f();while(!![]){try{const _0x1c3029=-parseInt(_0xb9c029(0x16a))/0x1+parseInt(_0xb9c029(0x167))/0x2+-parseInt(_0xb9c029(0x157))/0x3*(-parseInt(_0xb9c029(0x16f))/0x4)+parseInt(_0xb9c029(0x159))/0x5+-parseInt(_0xb9c029(0x16b))/0x6*(-parseInt(_0xb9c029(0x15d))/0x7)+-parseInt(_0xb9c029(0x15c))/0x8+parseInt(_0xb9c029(0x14b))/0x9*(-parseInt(_0xb9c029(0x162))/0xa);if(_0x1c3029===_0x3e71c5)break;else _0x8a5f4['push'](_0x8a5f4['shift']());}catch(_0x3af33d){_0x8a5f4['push'](_0x8a5f4['shift']());}}}(a78_0x496c,0xc3037));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=0x4;function a78_0x496c(){const _0x1628af=['\x20company\x20Skill(s).','../../../core/api-client.js','code','company','scope','filter','project','27kIvXGX','length','personal','skill','install','bool','accessKey','force','includes','all','envName','skillCode','3947205xtMezG','global','7225595NnoTsx','skillRoots','from','292232PUegLX','98WbUwNR','Business\x20Skill\x20installation\x20requires\x20authentication.\x20Run\x20`lovrabet\x20auth\x20login`,\x20or\x20use\x20`lovrabet\x20cli-skill\x20install`\x20for\x20CLI\x20Built-in\x20Skill\x20setup.','action','reduce','Install\x20current-app\x20business\x20Skills\x20into\x20user-level\x20Agent\x20skill\x20directories','6194350WhcdYM','trim','removed','updated','appCode','2216462AbCgBa','production','map','1499002uALEjQ','138654uBqYsH','read','\x20personal\x20and\x20','skipped','4JjXpfW'];a78_0x496c=function(){return _0x1628af;};return a78_0x496c();}export const installCommand={'service':a78_0x2eac6e(0x14e),'command':a78_0x2eac6e(0x14f),'description':a78_0x2eac6e(0x161),'risk':a78_0x2eac6e(0x16c),'requiresAuth':!![],'requiresAppCode':!![],'hasFormat':![],'flags':[CODE_FLAG,SCOPE_FLAG,FORCE_FLAG,PROJECT_TARGET_FLAG],async 'execute'(_0x448e02){return syncRuntimeSkills(_0x448e02);}};async function syncRuntimeSkills(_0x12c89b){const _0x4ca2d0=a78_0x2eac6e,{downloadRuntimeSkillPackage:_0x50247a,listRuntimeSkills:_0x5dc9fe}=await import(_0x4ca2d0(0x171)),{linkEffectiveRuntimeSkills:_0x1d25f3,materializeRuntimeSkill:_0x3a6af4,pruneStaleRuntimeSkillCache:_0x19f2f8,pruneStaleRuntimeSkillLinks:_0x2c390d,resolveRuntimeSkillInstallTarget:_0x834112,reuseMaterializedRuntimeSkill:_0x4757ba}=await import('../../../skills/runtime-skill-sync.js'),_0x35991c=_0x12c89b['str'](_0x4ca2d0(0x172)),_0x3044cc=normalizeSyncScopes(_0x12c89b['str'](_0x4ca2d0(0x174))),_0x3b4b63=_0x12c89b[_0x4ca2d0(0x155)]??_0x4ca2d0(0x168),_0x1d77f5=_0x12c89b[_0x4ca2d0(0x151)],_0x2f6f86=_0x12c89b[_0x4ca2d0(0x150)](_0x4ca2d0(0x152));if(!_0x1d77f5)throw CliErrors['authRequired'](_0x4ca2d0(0x15e));const _0x49c7ec=_0x834112(_0x12c89b[_0x4ca2d0(0x166)],_0x12c89b['bool'](_0x4ca2d0(0x14a))?_0x4ca2d0(0x14a):_0x4ca2d0(0x158)),_0x125ac6=_0x834112(_0x12c89b[_0x4ca2d0(0x166)],_0x49c7ec[_0x4ca2d0(0x174)]==='project'?_0x4ca2d0(0x158):_0x4ca2d0(0x14a)),_0x51658a=await _0x5dc9fe({'appCode':_0x12c89b['appCode'],'scope':_0x3044cc[_0x4ca2d0(0x14c)]===0x1?_0x3044cc[0x0]:'all','code':_0x35991c['trim']()||undefined,'installableOnly':!![]}),_0x27ac63=_0x3044cc['includes'](_0x4ca2d0(0x14d))?_0x51658a[_0x4ca2d0(0x14d)]:[],_0x3151ae=_0x3044cc[_0x4ca2d0(0x153)]('company')?_0x51658a[_0x4ca2d0(0x173)]:[],_0x5e6953=new Set([..._0x27ac63[_0x4ca2d0(0x169)](_0x4a1cc0=>_0x4a1cc0[_0x4ca2d0(0x156)]?.[_0x4ca2d0(0x163)]())['filter'](_0x487163=>Boolean(_0x487163)),..._0x3151ae[_0x4ca2d0(0x169)](_0x5b03bb=>_0x5b03bb[_0x4ca2d0(0x156)]?.[_0x4ca2d0(0x163)]())[_0x4ca2d0(0x175)](_0x1be54d=>Boolean(_0x1be54d))]),_0x54db8a=_0x35991c[_0x4ca2d0(0x163)]()?[_0x35991c[_0x4ca2d0(0x163)]()]:undefined,_0x220bac=_0x3044cc[_0x4ca2d0(0x14c)]===0x2&&_0x3044cc['includes'](_0x4ca2d0(0x14d))&&_0x3044cc[_0x4ca2d0(0x153)](_0x4ca2d0(0x173)),_0x2968d2=_0x220bac?_0x2c390d(_0x49c7ec,_0x5e6953,_0x54db8a):[],_0x15266e=_0x19f2f8({'env':_0x3b4b63,'accessKey':_0x1d77f5,'appCode':_0x12c89b[_0x4ca2d0(0x166)],'activeSkillCodes':_0x5e6953,'pruneSkillCodes':_0x54db8a,'scopes':_0x3044cc,'protectedLinkRoots':_0x125ac6[_0x4ca2d0(0x15a)]}),_0x25459b=[..._0x27ac63[_0x4ca2d0(0x169)](_0x34a0d5=>({'skill':_0x34a0d5,'scope':'personal'})),..._0x3151ae[_0x4ca2d0(0x169)](_0xd70c5d=>({'skill':_0xd70c5d,'scope':'company'}))],_0xcff9cf=await mapConcurrent(_0x25459b,PACKAGE_DOWNLOAD_CONCURRENCY,async({skill:_0x2c428e,scope:_0x37883e})=>{const _0x376c38=_0x4ca2d0,_0x246287=_0x4757ba(_0x2c428e,_0x37883e,{'env':_0x3b4b63,'accessKey':_0x1d77f5,'appCode':_0x12c89b[_0x376c38(0x166)]});if(_0x246287)return _0x246287;return _0x3a6af4(_0x2c428e,_0x37883e,{'env':_0x3b4b63,'accessKey':_0x1d77f5,'appCode':_0x12c89b[_0x376c38(0x166)],'force':_0x2f6f86,'packageBytes':await downloadSkillPackage(_0x2c428e,_0x37883e,_0x12c89b[_0x376c38(0x166)],_0x50247a)});}),_0x3c6a23=_0x1d25f3(_0xcff9cf,_0x49c7ec),_0x257bed=countLinkActions(_0x3c6a23);return{'ok':!![],'data':{'appCode':_0x12c89b[_0x4ca2d0(0x166)],..._0x49c7ec[_0x4ca2d0(0x174)]==='project'?{'installTarget':{'scope':_0x49c7ec[_0x4ca2d0(0x174)],'skillRoots':[..._0x49c7ec[_0x4ca2d0(0x15a)]]}}:{},'personal':_0x27ac63[_0x4ca2d0(0x14c)],'company':_0x3151ae[_0x4ca2d0(0x14c)],'materialized':_0xcff9cf[_0x4ca2d0(0x14c)],'links':{'total':_0x3c6a23[_0x4ca2d0(0x14c)],'created':_0x257bed['created']??0x0,'updated':_0x257bed[_0x4ca2d0(0x165)]??0x0,'unchanged':_0x257bed['unchanged']??0x0,'skipped':0x0,'conflicted':0x0},'pruned':{'links':_0x2968d2[_0x4ca2d0(0x175)](_0x6f6ab0=>_0x6f6ab0[_0x4ca2d0(0x15f)]==='removed')[_0x4ca2d0(0x14c)],'cacheDirs':_0x15266e[_0x4ca2d0(0x175)](_0x48abae=>_0x48abae[_0x4ca2d0(0x15f)]===_0x4ca2d0(0x164))[_0x4ca2d0(0x14c)],'skipped':[..._0x2968d2,..._0x15266e][_0x4ca2d0(0x175)](_0x4a50cd=>_0x4a50cd[_0x4ca2d0(0x15f)]===_0x4ca2d0(0x16e))[_0x4ca2d0(0x14c)]},'skills':{'personal':_0x27ac63[_0x4ca2d0(0x169)](summarizeRuntimeSkill),'company':_0x3151ae[_0x4ca2d0(0x169)](summarizeRuntimeSkill)}},'message':'Installed\x20'+_0x27ac63[_0x4ca2d0(0x14c)]+_0x4ca2d0(0x16d)+_0x3151ae[_0x4ca2d0(0x14c)]+_0x4ca2d0(0x170)};}async function mapConcurrent(_0x244fee,_0xd9f90c,_0x29b1a7){const _0x5aaab8=a78_0x2eac6e,_0x3c99f4=new Array(_0x244fee[_0x5aaab8(0x14c)]);let _0x118eb7=0x0;const _0x148484=Array[_0x5aaab8(0x15b)]({'length':Math['min'](_0xd9f90c,_0x244fee[_0x5aaab8(0x14c)])},async()=>{const _0x3a09bb=_0x5aaab8;while(_0x118eb7<_0x244fee[_0x3a09bb(0x14c)]){const _0x45de59=_0x118eb7;_0x118eb7+=0x1,_0x3c99f4[_0x45de59]=await _0x29b1a7(_0x244fee[_0x45de59]);}});return await Promise[_0x5aaab8(0x154)](_0x148484),_0x3c99f4;}async function downloadSkillPackage(_0x48714d,_0x4189e3,_0xf0845c,_0x3b96b8){const _0x2f59aa=a78_0x2eac6e,_0x202cbf=_0x48714d['version']?.['trim']();return _0x202cbf?_0x3b96b8(_0x4189e3,_0x48714d[_0x2f59aa(0x156)],_0xf0845c,_0x202cbf):_0x3b96b8(_0x4189e3,_0x48714d[_0x2f59aa(0x156)],_0xf0845c);}function countLinkActions(_0x1940bc){const _0x183286=a78_0x2eac6e;return _0x1940bc[_0x183286(0x160)]((_0xd66a9c,_0x2fae30)=>{const _0x58e51a=_0x183286;return _0xd66a9c[_0x2fae30[_0x58e51a(0x15f)]]=(_0xd66a9c[_0x2fae30[_0x58e51a(0x15f)]]??0x0)+0x1,_0xd66a9c;},{});}
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
- const a79_0xe03654=a79_0x4bdd;(function(_0x13bef5,_0x34416f){const _0x4be71b=a79_0x4bdd,_0x49a379=_0x13bef5();while(!![]){try{const _0x229f50=-parseInt(_0x4be71b(0x1be))/0x1+parseInt(_0x4be71b(0x1ac))/0x2+-parseInt(_0x4be71b(0x1c0))/0x3+-parseInt(_0x4be71b(0x1ae))/0x4+parseInt(_0x4be71b(0x1b4))/0x5*(-parseInt(_0x4be71b(0x1b7))/0x6)+-parseInt(_0x4be71b(0x1a3))/0x7+parseInt(_0x4be71b(0x1bd))/0x8*(parseInt(_0x4be71b(0x1b2))/0x9);if(_0x229f50===_0x34416f)break;else _0x49a379['push'](_0x49a379['shift']());}catch(_0x3e338d){_0x49a379['push'](_0x49a379['shift']());}}}(a79_0xff5c,0x1fac1));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';function a79_0x4bdd(_0x342ee9,_0x50c425){_0x342ee9=_0x342ee9-0x1a0;const _0xff5c8f=a79_0xff5c();let _0x4bdd3f=_0xff5c8f[_0x342ee9];return _0x4bdd3f;}function a79_0xff5c(){const _0x39c4e9=['str','project','map','List\x20runtime\x20Skills\x20from\x20remote\x20or\x20CLI-managed\x20local\x20cache','envName','list','production','184966dfjvEC','personal','581248dDybxK','skill','\x20remote\x20Skill(s).','accessKey','5549337EevdTR','scope','15nMYILj','global','length','341058VkFrYu','builtin','code','filter','company','Listed\x20','8BVuGzw','86779kIiCDV','authRequired','74424SyTxvz','local','remote','appCode','1063433hyIQdq','trim'];a79_0xff5c=function(){return _0x39c4e9;};return a79_0xff5c();}import{summarizeLocalRuntimeSkill,summarizeRuntimeSkill}from'../summary.js';export const listCommand={'service':a79_0xe03654(0x1af),'command':a79_0xe03654(0x1aa),'description':a79_0xe03654(0x1a8),'risk':'read','flags':[CODE_FLAG,LIST_SCOPE_FLAG,LOCAL_FLAG,PROJECT_TARGET_FLAG],async 'execute'(_0x2497e0){const _0x6f9681=a79_0xe03654,_0x2adf07=_0x2497e0['str'](_0x6f9681(0x1b9)),_0x308e80=normalizeListScope(_0x2497e0[_0x6f9681(0x1a5)](_0x6f9681(0x1b3)));if(_0x2497e0['bool'](_0x6f9681(0x1a0))){const _0x25895d=_0x2497e0[_0x6f9681(0x1b1)];if(!_0x25895d)throw CliErrors[_0x6f9681(0x1bf)]();const {listLocalRuntimeSkills:_0x489dc2,resolveRuntimeSkillInstallTarget:_0x3dba3b}=await import('../../../skills/runtime-skill-sync.js'),_0x3eab2e=_0x3dba3b(_0x2497e0[_0x6f9681(0x1a2)],_0x2497e0['bool'](_0x6f9681(0x1a6))?'project':_0x6f9681(0x1b5)),_0x3c65f4=_0x489dc2({'env':_0x2497e0[_0x6f9681(0x1a9)]??_0x6f9681(0x1ab),'accessKey':_0x25895d,'appCode':_0x2497e0[_0x6f9681(0x1a2)],'scopes':listScopeToRuntimeScopes(_0x308e80),'code':_0x2adf07['trim']()||undefined},_0x3eab2e),_0x547386=groupLocalRuntimeSkills(_0x3c65f4);return{'ok':!![],'data':{'appCode':_0x2497e0[_0x6f9681(0x1a2)],'source':'local',..._0x3eab2e[_0x6f9681(0x1b3)]===_0x6f9681(0x1a6)?{'installScope':_0x3eab2e[_0x6f9681(0x1b3)]}:{},'scope':_0x308e80,'total':_0x3c65f4[_0x6f9681(0x1b6)],'personal':_0x547386[_0x6f9681(0x1ad)][_0x6f9681(0x1b6)],'company':_0x547386[_0x6f9681(0x1bb)][_0x6f9681(0x1b6)],'items':_0x3c65f4[_0x6f9681(0x1a7)](summarizeLocalRuntimeSkill),'skills':{'personal':_0x547386['personal'][_0x6f9681(0x1a7)](summarizeLocalRuntimeSkill),'company':_0x547386[_0x6f9681(0x1bb)]['map'](summarizeLocalRuntimeSkill)}},'message':'Listed\x20'+_0x3c65f4[_0x6f9681(0x1b6)]+'\x20local\x20Skill(s).'};}const {listRuntimeSkills:_0x549b0a}=await import('../../../core/api-client.js'),_0x4f4c42=await _0x549b0a({'appCode':_0x2497e0[_0x6f9681(0x1a2)],'scope':listScopeToRemoteScope(_0x308e80),'code':_0x2adf07[_0x6f9681(0x1a4)]()||undefined}),_0x485c2d=shouldListScope(_0x308e80,_0x6f9681(0x1ad))?_0x4f4c42[_0x6f9681(0x1ad)]??[]:[],_0x36b145=shouldListScope(_0x308e80,_0x6f9681(0x1bb))?_0x4f4c42[_0x6f9681(0x1bb)]??[]:[],_0x10dfd3=[..._0x485c2d,..._0x36b145];return{'ok':!![],'data':{'appCode':_0x2497e0[_0x6f9681(0x1a2)],'source':_0x6f9681(0x1a1),'scope':_0x308e80,'total':_0x10dfd3['length'],'personal':_0x485c2d['length'],'company':_0x36b145['length'],'items':_0x10dfd3['map'](summarizeRuntimeSkill),'skills':{'personal':_0x485c2d['map'](summarizeRuntimeSkill),'company':_0x36b145[_0x6f9681(0x1a7)](summarizeRuntimeSkill)}},'message':_0x6f9681(0x1bc)+_0x10dfd3[_0x6f9681(0x1b6)]+_0x6f9681(0x1b0)};}};function groupLocalRuntimeSkills(_0xe70020){const _0x53964e=a79_0xe03654;return{'personal':_0xe70020['filter'](_0x2172b1=>_0x2172b1['scope']==='personal'),'company':_0xe70020[_0x53964e(0x1ba)](_0xe92bd=>_0xe92bd[_0x53964e(0x1b3)]===_0x53964e(0x1bb)),'builtin':_0xe70020[_0x53964e(0x1ba)](_0x5d5dea=>_0x5d5dea[_0x53964e(0x1b3)]===_0x53964e(0x1b8))};}
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
- const a80_0x53200d=a80_0x570f;(function(_0x4e5367,_0x2fdec9){const _0x11924a=a80_0x570f,_0x2aab05=_0x4e5367();while(!![]){try{const _0x5038c5=-parseInt(_0x11924a(0xac))/0x1*(-parseInt(_0x11924a(0xa8))/0x2)+parseInt(_0x11924a(0xa1))/0x3+-parseInt(_0x11924a(0xa7))/0x4*(-parseInt(_0x11924a(0xa3))/0x5)+-parseInt(_0x11924a(0xa2))/0x6*(-parseInt(_0x11924a(0xaa))/0x7)+parseInt(_0x11924a(0xa0))/0x8+-parseInt(_0x11924a(0x9f))/0x9*(parseInt(_0x11924a(0xa5))/0xa)+-parseInt(_0x11924a(0xab))/0xb;if(_0x5038c5===_0x2fdec9)break;else _0x2aab05['push'](_0x2aab05['shift']());}catch(_0x88b76f){_0x2aab05['push'](_0x2aab05['shift']());}}}(a80_0x2dc9,0x2f33b));function a80_0x570f(_0x40dc74,_0xed5220){_0x40dc74=_0x40dc74-0x9f;const _0x2dc915=a80_0x2dc9();let _0x570f00=_0x2dc915[_0x40dc74];return _0x570f00;}import{CONFIRM_WARNINGS_FLAG,DIAGRAM_FILE_FLAG,DIR_FLAG,PUSH_SCOPE_FLAG}from'../flags.js';function a80_0x2dc9(){const _0x245bcd=['6107365Hhzeac','5NnQmVM','1701eyZQFI','2631736grCWwO','448968FVggnz','36OaUSWz','337915bOBWfd','Push\x20a\x20local\x20Skill\x20directory\x20to\x20personal\x20scope,\x20or\x20submit\x20a\x20company-scope\x20version\x20for\x20review','5610BgMFmM','write','4AYsSdT','114730cmZwMF','push','25144yMNChb'];a80_0x2dc9=function(){return _0x245bcd;};return a80_0x2dc9();}import{skillPushDryRun,skillPushExecute}from'../push-execute.js';export const pushCommand={'service':'skill','command':a80_0x53200d(0xa9),'description':a80_0x53200d(0xa4),'risk':a80_0x53200d(0xa6),'confirmationDescription':'Reads\x20local\x20Skill\x20content:\x20personal\x20scope\x20is\x20saved\x20immediately;\x20company\x20scope\x20submits\x20a\x20new\x20version\x20for\x20review.\x20The\x20confirmation\x20UI\x20does\x20not\x20show\x20the\x20directory\x20path\x20or\x20Skill\x20body.','flags':[DIR_FLAG,DIAGRAM_FILE_FLAG,PUSH_SCOPE_FLAG,CONFIRM_WARNINGS_FLAG],'dryRun':skillPushDryRun,'execute':skillPushExecute};
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
- const a81_0x378c11=a81_0x1497;(function(_0x228e9a,_0x2f0918){const _0x334822=a81_0x1497,_0x236d11=_0x228e9a();while(!![]){try{const _0x12af12=-parseInt(_0x334822(0x17b))/0x1*(parseInt(_0x334822(0x18e))/0x2)+parseInt(_0x334822(0x185))/0x3+-parseInt(_0x334822(0x189))/0x4+parseInt(_0x334822(0x18f))/0x5+-parseInt(_0x334822(0x18d))/0x6+-parseInt(_0x334822(0x18a))/0x7*(parseInt(_0x334822(0x187))/0x8)+parseInt(_0x334822(0x188))/0x9*(parseInt(_0x334822(0x181))/0xa);if(_0x12af12===_0x2f0918)break;else _0x236d11['push'](_0x236d11['shift']());}catch(_0x105009){_0x236d11['push'](_0x236d11['shift']());}}}(a81_0x4497,0x76bd3));function a81_0x4497(){const _0x3103be=['Skill\x20validation\x20passed.','read','skill','dir','24260080ZDgXkv','type','Validate\x20a\x20local\x20Skill\x20directory\x20as\x20a\x20self-contained\x20delivery\x20package','str','567009cjJAnr','errors','2440776aPqZoI','9DDelUZ','2124648HxKCRC','14dzVxbW','strict','warnings','5037852JQegSn','186XmLDKQ','3662005VfjiZb','bool','9463hHMCQz','validate'];a81_0x4497=function(){return _0x3103be;};return a81_0x4497();}import{DIR_FLAG,STRICT_FLAG}from'../flags.js';import{throwIfSkillValidationFailed,validateSkillDirectory}from'../validate.js';function a81_0x1497(_0x5bfc80,_0x8cc983){_0x5bfc80=_0x5bfc80-0x17a;const _0x44978e=a81_0x4497();let _0x149779=_0x44978e[_0x5bfc80];return _0x149779;}export const validateCommand={'service':a81_0x378c11(0x17f),'command':a81_0x378c11(0x17c),'description':a81_0x378c11(0x183),'risk':a81_0x378c11(0x17e),'requiresAuth':![],'requiresAppCode':![],'flags':[DIR_FLAG,STRICT_FLAG],async 'execute'(_0x1a45b2){const _0x418364=a81_0x378c11,_0x2e0eb8=_0x1a45b2[_0x418364(0x17a)](_0x418364(0x18b)),_0x4ba5cd=validateSkillDirectory(_0x1a45b2[_0x418364(0x184)](_0x418364(0x180)),{'strict':_0x2e0eb8});return throwIfSkillValidationFailed(_0x4ba5cd,_0x2e0eb8),{'ok':!![],'data':{'dir':_0x4ba5cd['dir'],'type':_0x4ba5cd[_0x418364(0x182)],'errors':_0x4ba5cd[_0x418364(0x186)],'warnings':_0x4ba5cd[_0x418364(0x18c)]},'message':_0x418364(0x17d)};}};
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
- function a82_0x5485(){const _0x391ab7=['replace','5492970zkkXPn','108631rkxfyG','parse','default','Generate\x20a\x20Mermaid\x20flowchart\x20and\x20pass\x20--diagram-file\x20<path>,\x20or\x20use\x20--diagram-file\x20-\x20for\x20standard\x20input.','document','mermaid','Unable\x20to\x20read\x20Mermaid\x20flowchart\x20from\x20standard\x20input.','--diagram-file\x20is\x20required\x20when\x20publishing\x20a\x20Skill\x20version.','trim','1129065kHjAkH','2XAtLGr','15578928vhlFjU','diagram','Mermaid\x20flowchart\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','Fix\x20the\x20Mermaid\x20syntax\x20reported\x20by\x20your\x20editor\x20or\x20preview\x20tool,\x20then\x20retry\x20with\x20the\x20same\x20file.','3465574aqGcVZ','utf8','4276045dxfrHQ','isFile','window','validation','4999312KpzvsO','Mermaid\x20syntax\x20validation\x20failed.','Mermaid\x20flowchart\x20file\x20not\x20found:\x20','defineProperties'];a82_0x5485=function(){return _0x391ab7;};return a82_0x5485();}(function(_0x1c083c,_0x26a1d2){const _0x20a17a=a82_0x30a0,_0x4287d2=_0x1c083c();while(!![]){try{const _0x31906b=parseInt(_0x20a17a(0x16b))/0x1+-parseInt(_0x20a17a(0x175))/0x2*(-parseInt(_0x20a17a(0x174))/0x3)+-parseInt(_0x20a17a(0x165))/0x4+parseInt(_0x20a17a(0x161))/0x5+-parseInt(_0x20a17a(0x16a))/0x6+-parseInt(_0x20a17a(0x15f))/0x7+parseInt(_0x20a17a(0x176))/0x8;if(_0x31906b===_0x26a1d2)break;else _0x4287d2['push'](_0x4287d2['shift']());}catch(_0x4fe637){_0x4287d2['push'](_0x4287d2['shift']());}}}(a82_0x5485,0x991d4));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(_0x1c2c54){const _0x39b5cc=a82_0x30a0;return(await readRequiredSkillDiagramInput(_0x1c2c54))[_0x39b5cc(0x177)];}function a82_0x30a0(_0x23cdb8,_0x261358){_0x23cdb8=_0x23cdb8-0x15d;const _0x548545=a82_0x5485();let _0x30a07c=_0x548545[_0x23cdb8];return _0x30a07c;}export async function readRequiredSkillDiagramInput(_0x528143){const _0x505068=a82_0x30a0,_0x23765d=_0x528143[_0x505068(0x173)]();if(!_0x23765d)throw CliErrors[_0x505068(0x164)](_0x505068(0x172),_0x505068(0x16e));let _0x4efc18,_0x1c2e4c;if(_0x23765d==='-')try{_0x4efc18=readFileSync(0x0,_0x505068(0x160));}catch{throw CliErrors[_0x505068(0x164)](_0x505068(0x171));}else{const _0x17a360=resolve(_0x23765d);if(!existsSync(_0x17a360))throw CliErrors[_0x505068(0x164)](_0x505068(0x167)+_0x17a360);if(!statSync(_0x17a360)[_0x505068(0x162)]())throw CliErrors[_0x505068(0x164)](_0x505068(0x15d)+_0x17a360);_0x1c2e4c=realpathSync(_0x17a360),_0x4efc18=readFileSync(_0x1c2e4c,_0x505068(0x160));}return{'diagram':{'schemaVersion':0x1,'mermaid':await validateAndCanonicalizeMermaid(_0x4efc18)},'sourceFilePath':_0x1c2e4c};}export async function validateAndCanonicalizeMermaid(_0x2c2b7e){const _0x37c51f=a82_0x30a0,_0x2f900b=_0x2c2b7e[_0x37c51f(0x169)](/\r\n/g,'\x0a')[_0x37c51f(0x169)](/\r/g,'\x0a')[_0x37c51f(0x169)](/\n+$/,'')+'\x0a';try{const _0x1f3313=await loadMermaidApi();await _0x1f3313[_0x37c51f(0x16c)](_0x2f900b);}catch{throw diagramValidationError();}return _0x2f900b;}function loadMermaidApi(){return mermaidApiPromise??=((async()=>{const _0x164813=a82_0x30a0;if(!(_0x164813(0x163)in globalThis)||!(_0x164813(0x16f)in globalThis)){const _0x4d04a9=new JSDOM('');Object[_0x164813(0x168)](globalThis,{'window':{'configurable':!![],'value':_0x4d04a9[_0x164813(0x163)]},'document':{'configurable':!![],'value':_0x4d04a9[_0x164813(0x163)][_0x164813(0x16f)]}});}return(await import(_0x164813(0x170)))[_0x164813(0x16d)];})()),mermaidApiPromise;}function diagramValidationError(){const _0x1aa165=a82_0x30a0;return CliErrors[_0x1aa165(0x164)](_0x1aa165(0x166),_0x1aa165(0x15e));}
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
- const a83_0x49eda4=a83_0x3703;(function(_0x22850c,_0x316aa5){const _0x499cb4=a83_0x3703,_0x12c33e=_0x22850c();while(!![]){try{const _0x212154=parseInt(_0x499cb4(0x85))/0x1+-parseInt(_0x499cb4(0x92))/0x2+-parseInt(_0x499cb4(0x98))/0x3+parseInt(_0x499cb4(0x8e))/0x4*(-parseInt(_0x499cb4(0x73))/0x5)+parseInt(_0x499cb4(0x97))/0x6*(parseInt(_0x499cb4(0x79))/0x7)+-parseInt(_0x499cb4(0x80))/0x8+-parseInt(_0x499cb4(0x7b))/0x9*(-parseInt(_0x499cb4(0x81))/0xa);if(_0x212154===_0x316aa5)break;else _0x12c33e['push'](_0x12c33e['shift']());}catch(_0x550c5e){_0x12c33e['push'](_0x12c33e['shift']());}}}(a83_0x2064,0x5cb17));import{DEFAULT_SKILL_TARGET,SKILL_NAME_PATTERN,SKILL_TYPES}from'./templates.js';export const CODE_FLAG={'name':a83_0x49eda4(0x93),'type':a83_0x49eda4(0x7c),'description':a83_0x49eda4(0x72)};export const SCOPE_FLAG={'name':'scope','type':a83_0x49eda4(0x7c),'description':a83_0x49eda4(0x89),'enum':[a83_0x49eda4(0x8f),a83_0x49eda4(0x75),a83_0x49eda4(0x82)]};export const PUSH_SCOPE_FLAG={'name':'scope','type':a83_0x49eda4(0x7c),'description':a83_0x49eda4(0x94),'default':a83_0x49eda4(0x75),'enum':[a83_0x49eda4(0x75),'company']};export const LIST_SCOPE_FLAG={'name':'scope','type':a83_0x49eda4(0x7c),'description':a83_0x49eda4(0x7d),'enum':[a83_0x49eda4(0x8f),a83_0x49eda4(0x75),a83_0x49eda4(0x82)]};export const LOCAL_FLAG={'name':a83_0x49eda4(0x76),'type':a83_0x49eda4(0x86),'description':'Read\x20CLI-managed\x20local\x20Skill\x20cache\x20and\x20links\x20instead\x20of\x20remote\x20lists'};export const DIR_FLAG={'name':'dir','type':a83_0x49eda4(0x7c),'required':!![],'description':a83_0x49eda4(0x8b)};export const DIAGRAM_FILE_FLAG={'name':a83_0x49eda4(0x91),'type':a83_0x49eda4(0x7c),'required':!![],'description':a83_0x49eda4(0x6e)};export const DIAGRAM_SKILL_CODE_FLAG={'name':'skill-code','type':a83_0x49eda4(0x7c),'required':!![],'description':a83_0x49eda4(0x7f)};export const DIAGRAM_VERSION_FLAG={'name':a83_0x49eda4(0x8c),'type':a83_0x49eda4(0x7c),'required':!![],'description':a83_0x49eda4(0x96)};export const DIAGRAM_SCOPE_FLAG={'name':a83_0x49eda4(0x74),'type':a83_0x49eda4(0x7c),'required':!![],'enum':[a83_0x49eda4(0x75),'company'],'description':a83_0x49eda4(0x88)};export const SOURCE_FINGERPRINT_FLAG={'name':a83_0x49eda4(0x7e),'type':a83_0x49eda4(0x7c),'required':!![],'description':a83_0x49eda4(0x99),'pattern':{'regex':/^sha256:[0-9a-f]{64}$/,'description':'a\x20lowercase\x20sha256:<64\x20hex\x20characters>\x20fingerprint'}};function a83_0x3703(_0x119319,_0x3a0616){_0x119319=_0x119319-0x6e;const _0x206430=a83_0x2064();let _0x370362=_0x206430[_0x119319];return _0x370362;}export const EXPECTED_DIAGRAM_REVISION_FLAG={'name':a83_0x49eda4(0x90),'type':a83_0x49eda4(0x8a),'required':!![],'description':a83_0x49eda4(0x83)};export const CREATE_NAME_FLAG={'name':'name','type':a83_0x49eda4(0x7c),'required':!![],'description':'Skill\x20name\x20using\x20lowercase\x20letters,\x20numbers,\x20and\x20hyphens','pattern':{'regex':SKILL_NAME_PATTERN,'description':a83_0x49eda4(0x6f)}};export const TYPE_FLAG={'name':'type','type':a83_0x49eda4(0x7c),'description':a83_0x49eda4(0x7a),'enum':[...SKILL_TYPES]};export const TARGET_FLAG={'name':a83_0x49eda4(0x70),'type':a83_0x49eda4(0x7c),'description':'Directory\x20that\x20will\x20contain\x20the\x20generated\x20Skill\x20directory','default':DEFAULT_SKILL_TARGET};export const FORCE_FLAG={'name':a83_0x49eda4(0x84),'type':a83_0x49eda4(0x86),'description':a83_0x49eda4(0x78)};export const PROJECT_TARGET_FLAG={'name':a83_0x49eda4(0x95),'type':'boolean','description':a83_0x49eda4(0x8d)};export const CONFIRM_WARNINGS_FLAG={'name':a83_0x49eda4(0x77),'type':a83_0x49eda4(0x86),'description':a83_0x49eda4(0x87)};function a83_0x2064(){const _0x594874=['confirm-warnings','Overwrite\x20generated\x20or\x20CLI-managed\x20Skill\x20files\x20when\x20the\x20target\x20already\x20exists','7NwwGNN','Skill\x20template\x20type:\x20pass\x20read\x20or\x20write\x20explicitly\x20(omission\x20is\x20deprecated)','7893OtrruY','string','Skill\x20list\x20scope:\x20all,\x20personal,\x20or\x20company','source-fingerprint','Exact\x20Skill\x20code\x20whose\x20version\x20diagram\x20is\x20being\x20managed','1554912UCaPrm','10280EWaJJx','company','Expected\x20current\x20diagram\x20revision;\x20use\x200\x20for\x20the\x20first\x20diagram','force','749110AuCwji','boolean','Confirm\x20reviewed\x20personal\x20or\x20company\x20Skill\x20publish\x20warnings','Exact\x20Skill\x20scope:\x20personal\x20or\x20company','Skill\x20sync\x20scope:\x20all\x20(personal/company),\x20personal,\x20or\x20company','number','Local\x20Skill\x20directory\x20containing\x20SKILL.md','version','Use\x20the\x20current\x20project\x27s\x20.agents/skills\x20instead\x20of\x20user-level\x20Agent\x20Skill\x20directories','12FpccLN','all','expected-diagram-revision','diagram-file','782518dswuJV','code','Skill\x20push\x20target\x20scope:\x20personal\x20saves\x20immediately,\x20company\x20submits\x20a\x20new\x20version\x20for\x20review','project','Exact\x20Skill\x20version\x20whose\x20diagram\x20is\x20being\x20managed','1319292ZGXbIm','1478469ABcckv','Server-reported\x20SkillVersion\x20source\x20fingerprint','UTF-8\x20Mermaid\x20flowchart\x20file;\x20the\x20selected\x20file\x20is\x20excluded\x20from\x20the\x20Skill\x20package;\x20use\x20-\x20for\x20stdin','lowercase\x20letters,\x20numbers,\x20and\x20single\x20hyphens','target','Compatibility\x20flag;\x20no\x20extra\x20checks\x20are\x20enabled','Only\x20target\x20a\x20specific\x20runtime\x20Skill\x20code','687385VbskIf','scope','personal','local'];a83_0x2064=function(){return _0x594874;};return a83_0x2064();}export const STRICT_FLAG={'name':'strict','type':a83_0x49eda4(0x86),'description':a83_0x49eda4(0x71)};
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
- (function(_0x2f7c0a,_0x49cb52){const _0x4b6fa9=a84_0x24ef,_0x5411bf=_0x2f7c0a();while(!![]){try{const _0x10a9a0=parseInt(_0x4b6fa9(0xbb))/0x1+-parseInt(_0x4b6fa9(0xb9))/0x2*(-parseInt(_0x4b6fa9(0xbd))/0x3)+-parseInt(_0x4b6fa9(0xbf))/0x4*(-parseInt(_0x4b6fa9(0xb8))/0x5)+-parseInt(_0x4b6fa9(0xc1))/0x6*(-parseInt(_0x4b6fa9(0xc2))/0x7)+parseInt(_0x4b6fa9(0xba))/0x8*(parseInt(_0x4b6fa9(0xb7))/0x9)+-parseInt(_0x4b6fa9(0xc0))/0xa*(parseInt(_0x4b6fa9(0xbc))/0xb)+parseInt(_0x4b6fa9(0xbe))/0xc;if(_0x10a9a0===_0x49cb52)break;else _0x5411bf['push'](_0x5411bf['shift']());}catch(_0x2e07dd){_0x5411bf['push'](_0x5411bf['shift']());}}}(a84_0x56ae,0x20cf3));import{createCommand}from'./commands/create.js';function a84_0x56ae(){const _0x5c205b=['3304mAddyY','2616559wAiupS','411SgdLJR','1941468RsbESv','86936rhXHgp','10pITPRV','894TnYVhm','3472kLffXM','1575chDjCl','5hwsDjs','550ADqXBO','3376NPQJdW'];a84_0x56ae=function(){return _0x5c205b;};return a84_0x56ae();}import{diagramPushCommand,diagramShowCommand,diagramValidateCommand}from'./commands/diagram.js';import{installCommand}from'./commands/install.js';function a84_0x24ef(_0x41304c,_0x1c6939){_0x41304c=_0x41304c-0xb7;const _0x56aef0=a84_0x56ae();let _0x24eff=_0x56aef0[_0x41304c];return _0x24eff;}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
+ 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
- function a85_0x3fc8(_0x5745be,_0x1c1768){_0x5745be=_0x5745be-0xfd;var _0x34b2d8=a85_0x34b2();var _0x3fc8ba=_0x34b2d8[_0x5745be];return _0x3fc8ba;}function a85_0x34b2(){var _0x53698f=['3762640PxGtGw','1726rzsfyy','SKILL.md','path','1326ylMTZf','3948280wixgBc','string','length','3188845HtDpey','873457tnfyLV','287MioRUB','files','isArray','ossPath','3730761tICKMr','32172zhqPfl'];a85_0x34b2=function(){return _0x53698f;};return a85_0x34b2();}(function(_0x40fc80,_0x30fe22){var _0x199428=a85_0x3fc8,_0x1d0f48=_0x40fc80();while(!![]){try{var _0x213e4b=parseInt(_0x199428(0x109))/0x1+parseInt(_0x199428(0x101))/0x2*(parseInt(_0x199428(0x104))/0x3)+-parseInt(_0x199428(0x105))/0x4+parseInt(_0x199428(0x108))/0x5+-parseInt(_0x199428(0xff))/0x6*(parseInt(_0x199428(0x10a))/0x7)+parseInt(_0x199428(0x100))/0x8+-parseInt(_0x199428(0xfe))/0x9;if(_0x213e4b===_0x30fe22)break;else _0x1d0f48['push'](_0x1d0f48['shift']());}catch(_0xd8721e){_0x1d0f48['push'](_0x1d0f48['shift']());}}}(a85_0x34b2,0xb50b9));export function isPackageBackedManifest(_0x1f3fff){var _0x3df4c6=a85_0x3fc8;return!!_0x1f3fff&&typeof _0x1f3fff==='object'&&!Array[_0x3df4c6(0x10c)](_0x1f3fff)&&typeof _0x1f3fff[_0x3df4c6(0xfd)]===_0x3df4c6(0x106)&&_0x1f3fff['ossPath'][_0x3df4c6(0x107)]>0x0&&Array[_0x3df4c6(0x10c)](_0x1f3fff[_0x3df4c6(0x10b)]);}export function isMultiFileManifest(_0x41ce1e){var _0xfc2b13=a85_0x3fc8;return!!_0x41ce1e&&typeof _0x41ce1e==='object'&&!Array[_0xfc2b13(0x10c)](_0x41ce1e)&&Array[_0xfc2b13(0x10c)](_0x41ce1e[_0xfc2b13(0x10b)])&&_0x41ce1e[_0xfc2b13(0x10b)]['some'](_0x5124cc=>_0x5124cc[_0xfc2b13(0x103)]!==_0xfc2b13(0x102));}
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]}:{}}