@lovrabet/lovrabet-cli 2.3.12 → 2.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -14
- package/lib/cli.js +4 -1
- package/lib/commands/api-doc/index.js +11 -1
- package/lib/commands/app/cache.js +2 -1
- package/lib/commands/app/definitions.js +7 -1
- package/lib/commands/app/eligibility.js +2 -1
- package/lib/commands/app/mock-loader.js +1 -1
- package/lib/commands/app/remote-source.js +2 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/approval/index.js +7 -1
- package/lib/commands/artifact/index.js +11 -1
- package/lib/commands/auth/device.js +8 -1
- package/lib/commands/auth/index.js +9 -1
- package/lib/commands/auth/prompt.js +2 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/exec.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/cli-skill/index.js +2 -1
- package/lib/commands/common/config-policy.js +2 -1
- package/lib/commands/common/constraints.js +2 -1
- package/lib/commands/common/flags.js +2 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/config/definitions.js +8 -1
- package/lib/commands/config/init.js +4 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/import-excel.js +10 -1
- package/lib/commands/data/index.js +10 -1
- package/lib/commands/dataset/detail.js +6 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +2 -1
- package/lib/commands/dataset/sdk-doc.js +1 -1
- package/lib/commands/doctor.js +9 -1
- package/lib/commands/file/index.js +3 -1
- package/lib/commands/init.js +4 -1
- package/lib/commands/issue/context.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/report.js +5 -1
- package/lib/commands/kb/index.js +7 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/metric/contract.d.ts +8 -0
- package/lib/commands/metric/contract.js +5 -0
- package/lib/commands/metric/definition.d.ts +35 -0
- package/lib/commands/metric/definition.js +4 -0
- package/lib/commands/metric/detail.d.ts +2 -0
- package/lib/commands/metric/detail.js +1 -0
- package/lib/commands/metric/exec.d.ts +2 -0
- package/lib/commands/metric/exec.js +3 -0
- package/lib/commands/metric/index.d.ts +1 -0
- package/lib/commands/metric/index.js +1 -0
- package/lib/commands/metric/list.d.ts +2 -0
- package/lib/commands/metric/list.js +2 -0
- package/lib/commands/metric/shared.d.ts +17 -0
- package/lib/commands/metric/shared.js +2 -0
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +2 -1
- package/lib/commands/ocr/index.js +4 -1
- package/lib/commands/permit/dataset-get.js +1 -1
- package/lib/commands/permit/dataset-set.js +5 -1
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.js +3 -1
- package/lib/commands/permit/role-menus-set.js +4 -1
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.js +7 -1
- package/lib/commands/personal-bff/index.js +7 -1
- package/lib/commands/registry.js +6 -1
- package/lib/commands/role/create.js +2 -1
- package/lib/commands/role/delete.js +2 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +2 -1
- package/lib/commands/role/shared.js +8 -1
- package/lib/commands/role/update.js +3 -1
- package/lib/commands/role/user-add.js +2 -1
- package/lib/commands/role/user-remove.js +2 -1
- package/lib/commands/schedule/index.js +7 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/service/dynamic.js +10 -1
- package/lib/commands/service/function-name-adapter.js +3 -1
- package/lib/commands/service/index.js +8 -1
- package/lib/commands/service/registry.js +12 -1
- package/lib/commands/skill/commands/create.js +3 -1
- package/lib/commands/skill/commands/diagram.js +4 -1
- package/lib/commands/skill/commands/install.js +6 -1
- package/lib/commands/skill/commands/list.js +3 -1
- package/lib/commands/skill/commands/push.js +1 -1
- package/lib/commands/skill/commands/validate.js +1 -1
- package/lib/commands/skill/diagram.js +3 -1
- package/lib/commands/skill/flags.js +4 -1
- package/lib/commands/skill/index.js +1 -1
- package/lib/commands/skill/manifest-helpers.js +1 -1
- package/lib/commands/skill/push-execute.js +11 -1
- package/lib/commands/skill/push-flow-helpers.js +4 -1
- package/lib/commands/skill/push-retarget.js +1 -1
- package/lib/commands/skill/scopes.js +1 -1
- package/lib/commands/skill/summary.js +1 -1
- package/lib/commands/skill/templates.js +8 -1
- package/lib/commands/skill/validate.js +8 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +2 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/update.d.ts +2 -1
- package/lib/commands/update.js +8 -1
- package/lib/commands/user-account/bind.js +3 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/index.js +7 -1
- package/lib/config/domain-config.js +6 -1
- package/lib/config/schema.js +5 -1
- package/lib/constant/app.js +1 -1
- package/lib/constant/auth-mode.js +1 -1
- package/lib/constant/cli.js +3 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/distribution.js +1 -1
- package/lib/constant/domain.js +2 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/product.js +2 -1
- package/lib/constant/region.js +2 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/url.js +1 -1
- package/lib/context.js +11 -1
- package/lib/core/api-client.d.ts +4 -0
- package/lib/core/api-client.js +38 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/kb-management-client.js +6 -1
- package/lib/core/kb-sdk-errors.js +2 -1
- package/lib/core/kb-search-client.js +2 -1
- package/lib/core/sdk-client.js +5 -1
- package/lib/errors.js +2 -1
- package/lib/framework/access-error.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/dryrun.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +2 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/preparse.js +3 -1
- package/lib/framework/rate-limit.js +2 -1
- package/lib/framework/raw-flags.js +2 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-confirmation.js +2 -1
- package/lib/framework/runner-error.js +2 -1
- package/lib/framework/runner.js +9 -1
- package/lib/framework/schema-export.js +2 -1
- package/lib/framework/service-order.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +2 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +4 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +2 -1
- package/lib/runtime/types.js +1 -1
- package/lib/services/dataset-import/auto-id-runner.js +9 -1
- package/lib/services/dataset-import/excel-reader.js +25 -1
- package/lib/services/dataset-import/image-bytes.js +6 -1
- package/lib/services/dataset-import/image-ooxml.js +15 -1
- package/lib/services/dataset-import/image-runner.js +9 -1
- package/lib/services/dataset-import/metadata.js +1 -1
- package/lib/services/dataset-import/preview.js +1 -1
- package/lib/services/dataset-import/runner.js +13 -1
- package/lib/services/dataset-import/types.js +1 -1
- package/lib/skills/builtin-skill.js +8 -1
- package/lib/skills/install-updated-skill.d.ts +8 -0
- package/lib/skills/install-updated-skill.js +3 -0
- package/lib/skills/local-skills-installer.d.ts +2 -0
- package/lib/skills/local-skills-installer.js +1 -0
- package/lib/skills/npx-skills-add.d.ts +2 -2
- package/lib/skills/npx-skills-add.js +4 -1
- package/lib/skills/runtime-skill-sync/constants.js +1 -1
- package/lib/skills/runtime-skill-sync/fs-utils.js +3 -1
- package/lib/skills/runtime-skill-sync/hashing.js +1 -1
- package/lib/skills/runtime-skill-sync/install-target.js +1 -1
- package/lib/skills/runtime-skill-sync/links.js +9 -1
- package/lib/skills/runtime-skill-sync/list-local.js +4 -1
- package/lib/skills/runtime-skill-sync/local-files.js +5 -1
- package/lib/skills/runtime-skill-sync/materialize.js +9 -1
- package/lib/skills/runtime-skill-sync/metadata.js +3 -1
- package/lib/skills/runtime-skill-sync/paths.js +2 -1
- package/lib/skills/runtime-skill-sync/push.js +8 -1
- package/lib/skills/runtime-skill-sync/scopes.js +1 -1
- package/lib/skills/runtime-skill-sync/types.js +1 -1
- package/lib/skills/runtime-skill-sync/zip-codec.js +2 -1
- package/lib/skills/runtime-skill-sync/zip-package.js +6 -1
- package/lib/skills/runtime-skill-sync.js +1 -1
- package/lib/skills/skill-presence.d.ts +1 -34
- package/lib/skills/skill-presence.js +2 -1
- package/lib/utils/access-key-redaction.js +2 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cli-version-check.js +2 -1
- package/lib/utils/cli-version-policy.js +3 -1
- package/lib/utils/logger.js +3 -1
- package/lib/utils/lossless-json.js +3 -1
- package/lib/utils/params.js +3 -1
- package/lib/utils/positive-safe-integer.js +1 -1
- package/lib/utils/redaction.js +2 -1
- package/lib/utils/runtime-user-id.js +1 -1
- package/lib/utils/update-notice.js +3 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +9 -8
- package/skills/lovrabet/SKILL.md +14 -6
- package/skills/lovrabet/guides/app-resolution.md +2 -0
- package/skills/lovrabet/guides/dataset-and-data-workflow.md +2 -0
- package/skills/lovrabet/guides/development-intent-handoff.md +19 -3
- package/skills/lovrabet/guides/metric-consumption.md +134 -0
- package/skills/lovrabet/guides/sql-and-bff-workflow.md +2 -0
- package/skills/lovrabet/references/lovrabet-auth.md +4 -0
- package/skills/lovrabet/references/lovrabet-schedule-workflow.md +16 -0
- package/skills/lovrabet/references/lovrabet-skill-authoring.md +27 -0
- package/skills/lovrabet/references/lovrabet-skill-install.md +1 -1
- package/skills/lovrabet/references/lovrabet-update.md +6 -4
- package/skills/lovrabet-report-generation/SKILL.md +28 -0
- package/skills/lovrabet-report-generation/references/business-skill-reuse.md +19 -0
- package/skills/lovrabet-report-generation/references/quality-checks.md +16 -0
- package/skills/lovrabet-report-generation/references/report-workflow.md +42 -0
- package/skills/lovrabet-report-generation/templates/report-outline.md +10 -0
- package/skills/lovrabet.manifest.json +4 -3
- package/lib/postinstall.d.ts +0 -2
- package/lib/postinstall.js +0 -1
- package/scripts/postinstall.mjs +0 -24
|
@@ -1 +1,8 @@
|
|
|
1
|
-
const a152_0xb79467=a152_0x4c42;(function(_0x55ff5b,_0x3a7572){const _0x240ebb=a152_0x4c42,_0x5c1099=_0x55ff5b();while(!![]){try{const _0xea0f73=parseInt(_0x240ebb(0x89))/0x1+parseInt(_0x240ebb(0xa6))/0x2+parseInt(_0x240ebb(0x97))/0x3*(parseInt(_0x240ebb(0xb0))/0x4)+parseInt(_0x240ebb(0xb1))/0x5+parseInt(_0x240ebb(0xaa))/0x6*(parseInt(_0x240ebb(0xa5))/0x7)+-parseInt(_0x240ebb(0xbb))/0x8*(parseInt(_0x240ebb(0x9c))/0x9)+-parseInt(_0x240ebb(0xb3))/0xa;if(_0xea0f73===_0x3a7572)break;else _0x5c1099['push'](_0x5c1099['shift']());}catch(_0x39e19d){_0x5c1099['push'](_0x5c1099['shift']());}}}(a152_0x5d70,0x6fd38));import{createHash}from'node:crypto';import{lstatSync,readFileSync,readdirSync}from'node:fs';import{homedir}from'node:os';function a152_0x4c42(_0x3d6124,_0x46bb1e){_0x3d6124=_0x3d6124-0x7e;const _0x5d70ce=a152_0x5d70();let _0x4c42fb=_0x5d70ce[_0x3d6124];return _0x4c42fb;}import{dirname,join,relative,resolve,sep}from'node:path';import{fileURLToPath}from'node:url';import{debuglog}from'node:util';import{runNpxSkillsAddGlobal}from'../skills/npx-skills-add.js';import{resolveInstalledSkill}from'../skills/skill-presence.js';const DEFAULT_PACKAGE_ROOT=resolve(dirname(fileURLToPath(import.meta.url)),'..','..'),REPAIR_COMMAND='lovrabet\x20cli-skill\x20install',SKILL_NAME=a152_0xb79467(0xa1),debug=debuglog('lovrabet-skills');function frontmatterValue(_0x2ff0a7,_0x3c0acf){const _0x586bf8=a152_0xb79467;return _0x2ff0a7[_0x586bf8(0x87)](new RegExp('^'+_0x3c0acf+_0x586bf8(0xb4),'m'))?.[0x1]?.[_0x586bf8(0xa0)]()??'';}function listFiles(_0x180d51,_0x6252f2=_0x180d51){const _0x3915d5=a152_0xb79467;return readdirSync(_0x6252f2,{'withFileTypes':!![]})[_0x3915d5(0xa7)](_0x116a27=>{const _0x2f0232=_0x3915d5,_0x57be1c=join(_0x6252f2,_0x116a27['name']),_0x548f86=lstatSync(_0x57be1c);if(_0x548f86[_0x2f0232(0x86)]())throw new Error(_0x2f0232(0x8c)+_0x57be1c);if(_0x548f86[_0x2f0232(0x94)]())return listFiles(_0x180d51,_0x57be1c);if(!_0x548f86[_0x2f0232(0x83)]())throw new Error(_0x2f0232(0x8f)+_0x57be1c);return[relative(_0x180d51,_0x57be1c)[_0x2f0232(0xc1)](sep)[_0x2f0232(0x9e)]('/')];})[_0x3915d5(0x8d)]((_0x5b6a19,_0x1002f7)=>_0x5b6a19<_0x1002f7?-0x1:_0x5b6a19>_0x1002f7?0x1:0x0);}function digestFiles(_0x2c6c40,_0x132a35){const _0x2d5c06=a152_0xb79467,_0x16fc2d=createHash(_0x2d5c06(0xae));for(const _0xca6059 of _0x132a35){if(_0xca6059[_0x2d5c06(0xb9)]('/')||_0xca6059[_0x2d5c06(0xc1)]('/')[_0x2d5c06(0x9f)]('..')||_0xca6059[_0x2d5c06(0x9f)]('\x5c'))throw new Error(_0x2d5c06(0xa9)+_0xca6059);_0x16fc2d[_0x2d5c06(0x7e)](_0xca6059),_0x16fc2d[_0x2d5c06(0x7e)]('\x00'),_0x16fc2d[_0x2d5c06(0x7e)](readFileSync(join(_0x2c6c40,..._0xca6059[_0x2d5c06(0xc1)]('/')))),_0x16fc2d['update']('\x00');}return _0x16fc2d[_0x2d5c06(0x9d)](_0x2d5c06(0x92));}function sameFiles(_0x31921d,_0x1dfca4){const _0xe5a542=a152_0xb79467;return _0x31921d[_0xe5a542(0x9a)]===_0x1dfca4[_0xe5a542(0x9a)]&&_0x31921d[_0xe5a542(0x91)]((_0x55d690,_0x4e03db)=>_0x55d690===_0x1dfca4[_0x4e03db]);}function readSource(_0x3a46ea){const _0x315021=a152_0xb79467,_0x3e7b98=JSON[_0x315021(0x88)](readFileSync(join(_0x3a46ea,_0x315021(0xc2)),_0x315021(0x82))),_0x2571c0=JSON[_0x315021(0x88)](readFileSync(join(_0x3a46ea,'skills',_0x315021(0x8a)),_0x315021(0x82))),_0xe46e11=join(_0x3a46ea,_0x315021(0xbd),SKILL_NAME),_0x14793e=frontmatterValue(readFileSync(join(_0xe46e11,_0x315021(0xa2)),_0x315021(0x82)),_0x315021(0x9b)),_0x32bebc=listFiles(_0xe46e11);if(_0x2571c0[_0x315021(0x7f)]!==0x1||_0x2571c0['name']!==SKILL_NAME||!_0x3e7b98[_0x315021(0x9b)]||_0x2571c0['packageVersion']!==_0x3e7b98[_0x315021(0x9b)]||_0x2571c0[_0x315021(0xac)]!==_0x3e7b98['version']||_0x14793e!==_0x3e7b98[_0x315021(0x9b)]||!sameFiles(_0x32bebc,_0x2571c0['files'])||digestFiles(_0xe46e11,_0x32bebc)!==_0x2571c0[_0x315021(0x9d)])throw new Error(_0x315021(0xa4));return{'packageVersion':_0x3e7b98['version'],'skillVersion':_0x14793e,'root':_0xe46e11,'manifest':_0x2571c0};}function installedSkillPath(_0x433693){const _0x1ea4ed=a152_0xb79467,_0x1c13ba=resolveInstalledSkill(SKILL_NAME,{'home':_0x433693});if(_0x1c13ba[_0x1ea4ed(0x98)]==='present')return{'state':'present','path':dirname(_0x1c13ba[_0x1ea4ed(0xad)])};if(_0x1c13ba['state']===_0x1ea4ed(0xb8))return{'state':_0x1ea4ed(0xbc)};return{'state':_0x1ea4ed(0xbf),'reason':_0x1c13ba[_0x1ea4ed(0xb7)]};}export function inspectInstalledBuiltinSkillVersion(_0x5b7f5d,_0x29c3bd={}){const _0x116a94=a152_0xb79467,_0x30b153=installedSkillPath(_0x29c3bd[_0x116a94(0xc0)]??homedir());if(_0x30b153['state']===_0x116a94(0xbc))return{'state':'missing','expectedVersion':_0x5b7f5d,'repairCommand':REPAIR_COMMAND};if(_0x30b153[_0x116a94(0x98)]===_0x116a94(0xbf))return{'state':'unverifiable','expectedVersion':_0x5b7f5d,'reason':_0x30b153[_0x116a94(0xb7)],'repairCommand':REPAIR_COMMAND};try{const _0x295320=frontmatterValue(readFileSync(join(_0x30b153[_0x116a94(0xad)],_0x116a94(0xa2)),_0x116a94(0x82)),_0x116a94(0x9b));return{'state':_0x295320===_0x5b7f5d?_0x116a94(0x93):'version_mismatch','expectedVersion':_0x5b7f5d,'skillVersion':_0x295320,'installedPath':_0x30b153[_0x116a94(0xad)],'repairCommand':REPAIR_COMMAND};}catch(_0x4bca64){return{'state':_0x116a94(0xbf),'expectedVersion':_0x5b7f5d,'installedPath':_0x30b153[_0x116a94(0xad)],'reason':_0x4bca64 instanceof Error?_0x4bca64['message']:String(_0x4bca64),'repairCommand':REPAIR_COMMAND};}}function a152_0x5d70(){const _0x25edf9=['length','version','50859EgaoTp','digest','join','includes','trim','lovrabet','SKILL.md','log','Built-in\x20Skill\x20source\x20does\x20not\x20match\x20its\x20package\x20manifest','28zJHbAH','424168HcDASY','flatMap','status','Unsafe\x20manifest\x20path:\x20','738810xDVnlp','CLI\x20Built-in\x20Skill\x20','skillVersion','path','sha256','message','4MfwhAB','4420315xJZVCo','pipe','21956920oGljfm',':\x5cs*(.+)$','packageVersion','\x20verified;\x20','reason','absent','startsWith','output','56FrwEHB','missing','skills','files','unverifiable','home','split','package.json','partialFailure','Installer\x20reported\x20partial\x20target\x20failures:\x0a%s','manifest','update','schemaVersion','content_mismatch','skipped','utf8','isFile','packageRoot','count','isSymbolicLink','match','parse','824798rjqAuF','lovrabet.manifest.json','installedPath','Symbolic\x20link\x20is\x20not\x20allowed:\x20','sort','VERIFY_FAILED','Unsupported\x20Skill\x20entry:\x20','unknown','every','hex','current','isDirectory','skills@latest\x20exited\x20','version_mismatch','839412NqROcK','state','Installed\x20Skill\x20state\x20is\x20'];a152_0x5d70=function(){return _0x25edf9;};return a152_0x5d70();}export function inspectBuiltinSkill(_0x3c8e20={}){const _0x1bd34b=a152_0xb79467,_0x2a4aa2=_0x3c8e20[_0x1bd34b(0x84)]??DEFAULT_PACKAGE_ROOT;let _0x4f83dc;try{_0x4f83dc=readSource(_0x2a4aa2);}catch(_0x3c2484){return{'state':_0x1bd34b(0xbf),'packageVersion':_0x1bd34b(0x90),'reason':_0x3c2484 instanceof Error?_0x3c2484[_0x1bd34b(0xaf)]:String(_0x3c2484),'repairCommand':REPAIR_COMMAND};}const _0x5ddf54=installedSkillPath(_0x3c8e20[_0x1bd34b(0xc0)]??homedir());if(_0x5ddf54['state']===_0x1bd34b(0xbc))return{'state':_0x1bd34b(0xbc),'packageVersion':_0x4f83dc['packageVersion'],'repairCommand':REPAIR_COMMAND};if(_0x5ddf54[_0x1bd34b(0x98)]===_0x1bd34b(0xbf))return{'state':'unverifiable','packageVersion':_0x4f83dc['packageVersion'],'reason':_0x5ddf54[_0x1bd34b(0xb7)],'repairCommand':REPAIR_COMMAND};try{const _0x28d2f7=frontmatterValue(readFileSync(join(_0x5ddf54['path'],_0x1bd34b(0xa2)),_0x1bd34b(0x82)),'version');if(_0x28d2f7!==_0x4f83dc[_0x1bd34b(0xac)])return{'state':_0x1bd34b(0x96),'packageVersion':_0x4f83dc['packageVersion'],'skillVersion':_0x28d2f7,'installedPath':_0x5ddf54['path'],'repairCommand':REPAIR_COMMAND};const _0x166f79=listFiles(_0x5ddf54[_0x1bd34b(0xad)]),_0x39fed7=digestFiles(_0x5ddf54[_0x1bd34b(0xad)],_0x166f79);return{'state':sameFiles(_0x166f79,_0x4f83dc[_0x1bd34b(0xc5)][_0x1bd34b(0xbe)])&&_0x39fed7===_0x4f83dc[_0x1bd34b(0xc5)][_0x1bd34b(0x9d)]?_0x1bd34b(0x93):_0x1bd34b(0x80),'packageVersion':_0x4f83dc[_0x1bd34b(0xb5)],'skillVersion':_0x28d2f7,'installedPath':_0x5ddf54[_0x1bd34b(0xad)],'digest':_0x39fed7,'repairCommand':REPAIR_COMMAND};}catch(_0xbcb031){return{'state':'unverifiable','packageVersion':_0x4f83dc['packageVersion'],'installedPath':_0x5ddf54['path'],'reason':_0xbcb031 instanceof Error?_0xbcb031[_0x1bd34b(0xaf)]:String(_0xbcb031),'repairCommand':REPAIR_COMMAND};}}function failure(_0x11816f,_0x505399,_0x2ccc76,_0x25e2cb){const _0x599664=a152_0xb79467;return{'ok':![],'code':_0x11816f,'packageVersion':_0x505399[_0x599664(0xb5)],'skillVersion':_0x505399[_0x599664(0xac)],'installedPath':_0x25e2cb,'changed':![],'repairCommand':REPAIR_COMMAND,'error':_0x2ccc76 instanceof Error?_0x2ccc76[_0x599664(0xaf)]:String(_0x2ccc76)};}export function installBuiltinSkill(_0x34b480={}){const _0x1b23bd=a152_0xb79467,_0x3ccf95=_0x34b480[_0x1b23bd(0x84)]??DEFAULT_PACKAGE_ROOT,_0x24a289=_0x34b480[_0x1b23bd(0xc0)]??homedir();let _0x26eeb6;try{_0x26eeb6=readSource(_0x3ccf95);}catch(_0x383a65){return failure('SOURCE_INVALID',{'packageVersion':_0x1b23bd(0x90),'skillVersion':'unknown'},_0x383a65);}const _0x3d71e3=inspectBuiltinSkill({'packageRoot':_0x3ccf95,'home':_0x24a289}),_0x31ec75=runNpxSkillsAddGlobal(_0x3ccf95,_0x26eeb6['root'],{'stdio':_0x34b480['stdio']??_0x1b23bd(0xb2),'expectedSkillName':SKILL_NAME,'presence':{'home':_0x24a289}});if(_0x31ec75[_0x1b23bd(0x81)])return{'ok':!![],'packageVersion':_0x26eeb6[_0x1b23bd(0xb5)],'skillVersion':_0x26eeb6['skillVersion'],'installedPath':_0x3d71e3[_0x1b23bd(0x8b)],'changed':![],'repairCommand':REPAIR_COMMAND};if(!_0x31ec75['ok'])return failure('INSTALL_FAILED',_0x26eeb6,_0x31ec75['error']??_0x1b23bd(0x95)+_0x31ec75[_0x1b23bd(0xa8)]);const _0x466db4=inspectBuiltinSkill({'packageRoot':_0x3ccf95,'home':_0x24a289});if(_0x466db4[_0x1b23bd(0x98)]!=='current'){const _0x329d28=_0x466db4['reason']??_0x1b23bd(0x99)+_0x466db4[_0x1b23bd(0x98)];return failure(_0x1b23bd(0x8e),_0x26eeb6,_0x31ec75['partialFailure']?_0x329d28+'\x0a'+_0x31ec75[_0x1b23bd(0xc3)]['output']:_0x329d28,_0x466db4[_0x1b23bd(0x8b)]);}return _0x31ec75[_0x1b23bd(0xc3)]&&(debug(_0x1b23bd(0xc4),_0x31ec75[_0x1b23bd(0xc3)][_0x1b23bd(0xba)]),console[_0x1b23bd(0xa3)](_0x1b23bd(0xab)+_0x26eeb6[_0x1b23bd(0xac)]+_0x1b23bd(0xb6)+_0x31ec75['partialFailure'][_0x1b23bd(0x85)]+'\x20automatically\x20selected\x20installation\x20target(s)\x20could\x20not\x20be\x20installed.')),{'ok':!![],'packageVersion':_0x26eeb6[_0x1b23bd(0xb5)],'skillVersion':_0x26eeb6[_0x1b23bd(0xac)],'installedPath':_0x466db4[_0x1b23bd(0x8b)],'changed':_0x3d71e3[_0x1b23bd(0x98)]!==_0x1b23bd(0x93),'repairCommand':REPAIR_COMMAND};}
|
|
1
|
+
import{createHash}from"node:crypto";import{lstatSync,readFileSync,readdirSync}from"node:fs";import{homedir}from"node:os";import{dirname,join,relative,resolve,sep}from"node:path";import{fileURLToPath}from"node:url";import{debuglog}from"node:util";import{runNpxSkillsAddGlobal}from"../skills/npx-skills-add.js";import{resolveInstalledSkill}from"../skills/skill-presence.js";const DEFAULT_PACKAGE_ROOT=resolve(dirname(fileURLToPath(import.meta.url)),"..","..");const REPAIR_COMMAND="lovrabet cli-skill install";const SKILL_NAME="lovrabet";const debug=debuglog("lovrabet-skills");function frontmatterValue(content,key){return content.match(new RegExp(`^${key}:\\s*(.+)$`,"m"))?.[1]?.trim()??""}function listFiles(root,current=root){return readdirSync(current,{withFileTypes:true}).flatMap(entry=>{const absolute=join(current,entry.name);const stat=lstatSync(absolute);if(stat.isSymbolicLink())throw new Error(`Symbolic link is not allowed: ${absolute}`)
|
|
2
|
+
;if(stat.isDirectory())return listFiles(root,absolute);if(!stat.isFile())throw new Error(`Unsupported Skill entry: ${absolute}`);return[relative(root,absolute).split(sep).join("/")]}).sort((left,right)=>left<right?-1:left>right?1:0)}function digestFiles(root,files){const aggregate=createHash("sha256");for(const file of files){if(file.startsWith("/")||file.split("/").includes("..")||file.includes("\\")){throw new Error(`Unsafe manifest path: ${file}`)}aggregate.update(file);aggregate.update("\0");aggregate.update(readFileSync(join(root,...file.split("/"))));aggregate.update("\0")}return aggregate.digest("hex")}function sameFiles(actual,expected){return actual.length===expected.length&&actual.every((file,index)=>file===expected[index])}function readSource(packageRoot){const pkg=JSON.parse(readFileSync(join(packageRoot,"package.json"),"utf8"));const manifest=JSON.parse(readFileSync(join(packageRoot,"skills","lovrabet.manifest.json"),"utf8"))
|
|
3
|
+
;const root=join(packageRoot,"skills",SKILL_NAME);const skillVersion=frontmatterValue(readFileSync(join(root,"SKILL.md"),"utf8"),"version");const files=listFiles(root);if(manifest.schemaVersion!==1||manifest.name!==SKILL_NAME||!pkg.version||manifest.packageVersion!==pkg.version||manifest.skillVersion!==pkg.version||skillVersion!==pkg.version||!sameFiles(files,manifest.files)||digestFiles(root,files)!==manifest.digest){throw new Error("Built-in Skill source does not match its package manifest")}return{packageVersion:pkg.version,skillVersion:skillVersion,root:root,manifest:manifest}}function installedSkillPath(home){const presence=resolveInstalledSkill(SKILL_NAME,{home:home});if(presence.state==="present")return{state:"present",path:dirname(presence.path)};if(presence.state==="absent")return{state:"missing"};return{state:"unverifiable",reason:presence.reason}}export function inspectInstalledBuiltinSkillVersion(expectedVersion,options={}){
|
|
4
|
+
const installed=installedSkillPath(options.home??homedir());if(installed.state==="missing"){return{state:"missing",expectedVersion:expectedVersion,repairCommand:REPAIR_COMMAND}}if(installed.state==="unverifiable"){return{state:"unverifiable",expectedVersion:expectedVersion,reason:installed.reason,repairCommand:REPAIR_COMMAND}}try{const skillVersion=frontmatterValue(readFileSync(join(installed.path,"SKILL.md"),"utf8"),"version");return{state:skillVersion===expectedVersion?"current":"version_mismatch",expectedVersion:expectedVersion,skillVersion:skillVersion,installedPath:installed.path,repairCommand:REPAIR_COMMAND}}catch(error){return{state:"unverifiable",expectedVersion:expectedVersion,installedPath:installed.path,reason:error instanceof Error?error.message:String(error),repairCommand:REPAIR_COMMAND}}}export function inspectBuiltinSkill(options={}){const packageRoot=options.packageRoot??DEFAULT_PACKAGE_ROOT;let source;try{source=readSource(packageRoot)}catch(error){return{
|
|
5
|
+
state:"unverifiable",packageVersion:"unknown",reason:error instanceof Error?error.message:String(error),repairCommand:REPAIR_COMMAND}}const installed=installedSkillPath(options.home??homedir());if(installed.state==="missing"){return{state:"missing",packageVersion:source.packageVersion,repairCommand:REPAIR_COMMAND}}if(installed.state==="unverifiable"){return{state:"unverifiable",packageVersion:source.packageVersion,reason:installed.reason,repairCommand:REPAIR_COMMAND}}try{const skillVersion=frontmatterValue(readFileSync(join(installed.path,"SKILL.md"),"utf8"),"version");if(skillVersion!==source.skillVersion){return{state:"version_mismatch",packageVersion:source.packageVersion,skillVersion:skillVersion,installedPath:installed.path,repairCommand:REPAIR_COMMAND}}const files=listFiles(installed.path);const digest=digestFiles(installed.path,files);return{state:sameFiles(files,source.manifest.files)&&digest===source.manifest.digest?"current":"content_mismatch",
|
|
6
|
+
packageVersion:source.packageVersion,skillVersion:skillVersion,installedPath:installed.path,digest:digest,repairCommand:REPAIR_COMMAND}}catch(error){return{state:"unverifiable",packageVersion:source.packageVersion,installedPath:installed.path,reason:error instanceof Error?error.message:String(error),repairCommand:REPAIR_COMMAND}}}function failure(code,source,error,installedPath){return{ok:false,code:code,packageVersion:source.packageVersion,skillVersion:source.skillVersion,installedPath:installedPath,changed:false,repairCommand:REPAIR_COMMAND,error:error instanceof Error?error.message:String(error)}}export function installBuiltinSkill(options={}){const packageRoot=options.packageRoot??DEFAULT_PACKAGE_ROOT;const home=options.home??homedir();let source;try{source=readSource(packageRoot)}catch(error){return failure("SOURCE_INVALID",{packageVersion:"unknown",skillVersion:"unknown"},error)}const before=inspectBuiltinSkill({packageRoot:packageRoot,home:home})
|
|
7
|
+
;const result=runNpxSkillsAddGlobal(packageRoot,source.root,{stdio:options.stdio??"pipe",expectedSkillName:SKILL_NAME,presence:{home:home}});if(result.skipped){return{ok:true,packageVersion:source.packageVersion,skillVersion:source.skillVersion,installedPath:before.installedPath,changed:false,repairCommand:REPAIR_COMMAND}}if(!result.ok){return failure("INSTALL_FAILED",source,result.error??`local skills installer exited ${result.status}`)}const after=inspectBuiltinSkill({packageRoot:packageRoot,home:home});if(after.state!=="current"){const reason=after.reason??`Installed Skill state is ${after.state}`;return failure("VERIFY_FAILED",source,result.partialFailure?`${reason}\n${result.partialFailure.output}`:reason,after.installedPath)}if(result.partialFailure){debug("Installer reported partial target failures:\n%s",result.partialFailure.output)
|
|
8
|
+
;console.log(`CLI Built-in Skill ${source.skillVersion} verified; ${result.partialFailure.count} automatically selected installation target(s) could not be installed.`)}return{ok:true,packageVersion:source.packageVersion,skillVersion:source.skillVersion,installedPath:after.installedPath,changed:before.state!=="current",repairCommand:REPAIR_COMMAND}}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface UpdatedSkillOptions {
|
|
2
|
+
version: string;
|
|
3
|
+
packageManager: "npm" | "bun";
|
|
4
|
+
packageManagerCommand: string;
|
|
5
|
+
/** Only set when installation used an explicit npm prefix. */
|
|
6
|
+
prefix?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function installUpdatedBuiltinSkill(options: UpdatedSkillOptions): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{readFileSync,realpathSync}from"node:fs";import{dirname,isAbsolute,join,relative,resolve}from"node:path";import{execaSync}from"execa";function run(command,args){const result=execaSync(command,args,{stdio:"pipe",shell:false,reject:false,env:{...process.env,DO_NOT_TRACK:"1",LOVRABET_NO_UPDATE_NOTICE:"1"},extendEnv:false});if(result.exitCode!==0){throw new Error(String(result.stderr||result.stdout||result.shortMessage||"Command failed").trim())}return String(result.stdout).trim()}export function installUpdatedBuiltinSkill(options){let packageRoot;if(options.packageManager==="bun"){const binDirectory=run(options.packageManagerCommand,["pm","bin","-g"]);if(!isAbsolute(binDirectory))throw new Error("Unable to resolve Bun global bin directory");packageRoot=dirname(dirname(realpathSync(join(binDirectory,"lovrabet"))))}else{const modules=run(options.packageManagerCommand,["root","-g",...options.prefix?["--prefix",options.prefix]:[]])
|
|
2
|
+
;if(!isAbsolute(modules))throw new Error("Unable to resolve npm global package directory");packageRoot=join(modules,"@lovrabet/lovrabet-cli")}const pkg=JSON.parse(readFileSync(join(packageRoot,"package.json"),"utf8"));if(pkg.name!=="@lovrabet/lovrabet-cli"||pkg.version!==options.version){throw new Error(`Installed lovrabet package/version mismatch: expected @lovrabet/lovrabet-cli@${options.version}, found ${pkg.name}@${pkg.version}`)}const bin=pkg.bin?.lovrabet;if(!bin)throw new Error("Installed lovrabet has no executable entry");const entry=resolve(packageRoot,bin);if(relative(packageRoot,entry).startsWith("..")||isAbsolute(relative(packageRoot,entry))){throw new Error("Installed lovrabet executable is outside its package")}const versionOutput=run(process.execPath,[entry,"--version"]);if(versionOutput.split(/\s+/)[0]!==options.version){throw new Error(`Installed lovrabet executable version mismatch: expected ${options.version}, found ${versionOutput}`)}
|
|
3
|
+
run(process.execPath,[entry,"cli-skill","install"])}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire}from"node:module";export function resolveLocalSkillsInstaller(){try{const require=createRequire(import.meta.url);const expected=require("../../package.json").dependencies?.skills;const actual=require("skills/package.json").version;if(!expected||!/^\d+\.\d+\.\d+$/.test(expected)||actual!==expected){throw new Error(`Local skills installer version mismatch: expected ${expected??"an exact dependency"}, found ${actual??"unknown"}`)}return require.resolve("skills/bin/cli.mjs")}catch(error){const reason=error instanceof Error?error.message:String(error);throw new Error(`Local skills installer unavailable: ${reason}. Reinstall this CLI package.`)}}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Official `skills` CLI integration used by `lovrabet cli-skill install`.
|
|
3
3
|
*
|
|
4
|
-
* The runtime CLI
|
|
4
|
+
* The runtime CLI only needs the package-local `skills add <source> -g -y`
|
|
5
5
|
* flow, so this module intentionally keeps the surface area narrow.
|
|
6
6
|
*/
|
|
7
7
|
import { type ResolveSkillPresenceOptions } from "../skills/skill-presence.js";
|
|
@@ -61,7 +61,7 @@ export interface RunNpxSkillsAddOptions {
|
|
|
61
61
|
* output-derived classification is the installer's `Failed to install N` summary;
|
|
62
62
|
* all other installer text is attached to `error` as diagnostics.
|
|
63
63
|
*/
|
|
64
|
-
export type NpxSkillsErrorCode = "
|
|
64
|
+
export type NpxSkillsErrorCode = "NODE_NOT_FOUND" | "INSTALLER_UNAVAILABLE" | "PERMISSION_DENIED" | "SPAWN_FAILED" | "CHILD_TERMINATED" | "CHILD_EXIT_NONZERO" | "INSTALL_PARTIAL" | "SKILL_NOT_INSTALLED";
|
|
65
65
|
/**
|
|
66
66
|
* Returns whether the external `skills` invocation should be skipped.
|
|
67
67
|
*
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{execaSync}from"execa";import{resolveLocalSkillsInstaller}from"../skills/local-skills-installer.js";import{LOVRABET_SKILL_SOURCE as OFFICIAL_LOVRABET_SKILL_SOURCE}from"../constant/distribution.js";import{PRODUCT_CONFIG,productEnvName}from"../constant/product.js";import{resolveInstalledSkill}from"../skills/skill-presence.js";export const LOVRABET_SKILL_SOURCE=OFFICIAL_LOVRABET_SKILL_SOURCE;export const LOVRABET_SKILL_GIT_SOURCE=PRODUCT_CONFIG.internalSkillSource;export const LOVRABET_GLOBAL_SKILL_NAME=PRODUCT_CONFIG.globalSkillName;export function resolveGlobalSkillName(source){switch(source.trim()){case LOVRABET_SKILL_SOURCE:case LOVRABET_SKILL_GIT_SOURCE:return LOVRABET_GLOBAL_SKILL_NAME;default:return undefined}}export const LOVRABET_SKIP_NPX_SKILLS_ENV=productEnvName(PRODUCT_CONFIG.skipNpxSkillsEnvSuffix);const CHILD_OUTPUT_MAX_BUFFER=16*1024*1024;function failure(code,status,detail){return{ok:false,status:status,code:code,error:`[${code}] ${detail}`}}
|
|
2
|
+
export function shouldSkipNpxSkillsAdd(){return process.env[LOVRABET_SKIP_NPX_SKILLS_ENV]==="1"}export function runNpxSkillsAddGlobal(projectRoot,source=LOVRABET_SKILL_SOURCE,options){if(shouldSkipNpxSkillsAdd()){return{ok:true,status:0,skipped:true}}let installer;try{installer=resolveLocalSkillsInstaller()}catch(error){return failure("INSTALLER_UNAVAILABLE",null,error instanceof Error?error.message:String(error))}const args=[installer,"add",source,"-g","-y"];console.log(`* ${["skills",...args.slice(1)].join(" ")}`);const env={...process.env,DISABLE_TELEMETRY:"1"};delete env.npm_config_global;delete env.NPM_CONFIG_GLOBAL;const result=execaSync(process.execPath,args,{cwd:projectRoot,stdio:"pipe",env:env,extendEnv:false,shell:false,reject:false,maxBuffer:CHILD_OUTPUT_MAX_BUFFER});const output=[result.stdout?String(result.stdout):"",result.stderr?String(result.stderr):""].filter(Boolean).join("\n").trim();const status=result.exitCode??null;const finalize=normalized=>{
|
|
3
|
+
if(options?.stdio!=="pipe"&&!normalized.partialFailure&&output){console.log(output)}return normalized};if(result.code){const code=result.code==="ENOENT"?"NODE_NOT_FOUND":result.code==="EPERM"||result.code==="EACCES"?"PERMISSION_DENIED":"SPAWN_FAILED";return finalize(failure(code,status,result.shortMessage??result.message??result.code))}if(result.signal){return finalize(failure("CHILD_TERMINATED",status,`Skills installer terminated by signal ${result.signal}`))}if(result.failed&&status===null){return finalize(failure("SPAWN_FAILED",status,result.shortMessage??result.message??"Skills installer failed to start"))}if(status!==0){return finalize(failure("CHILD_EXIT_NONZERO",status,output||result.shortMessage||`exit ${status??"unknown"}`))}const skillName=options?.expectedSkillName??resolveGlobalSkillName(source);const presence=skillName?resolveInstalledSkill(skillName,options?.presence):undefined;const failedCount=output.match(/Failed to install\s+(\d+)/i)
|
|
4
|
+
;if(failedCount&&Number(failedCount[1])>0){const detail=`Installer reported ${failedCount[1]} failed target(s)${output?`:\n${output}`:""}`;if(presence?.state==="present"){return{ok:true,status:0,partialFailure:{count:Number(failedCount[1]),output:output}}}return finalize(failure("INSTALL_PARTIAL",0,detail))}if(skillName&&presence){if(presence.state==="absent"){return finalize(failure("SKILL_NOT_INSTALLED",0,`Skill "${skillName}" not listed as installed by Skills CLI`))}if(presence.state==="unverifiable"){console.warn(`! Could not verify "${skillName}" install state: ${presence.reason}`)}}return finalize({ok:true,status:0})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export const METADATA_FILE="lovrabet.skill.json";export const SKILL_FILE="SKILL.md";export const IGNORED_FILE_NAMES=new Set([METADATA_FILE,".DS_Store"]);export const IGNORED_DIR_NAMES=new Set([".git",".hg",".svn","node_modules",".next","dist","build","coverage",".turbo",".cache"]);
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{lstatSync,readlinkSync,realpathSync,renameSync,rmSync,writeFileSync}from"node:fs";import{dirname,isAbsolute,resolve,sep}from"node:path";import{CliErrors}from"../../errors.js";import{normalizeSkillRelativePath}from"./local-files.js";export function resolveManagedFilePath(dir,relativePath){const normalizedPath=normalizeSkillRelativePath(relativePath);const root=realOrResolved(dir);const target=resolve(root,...normalizedPath.split("/"));if(!isPathInside(target,root)){throw CliErrors.validation(`Unsafe Skill file path: ${relativePath}`)}ensureNoSymlinkInManagedPath(root,normalizedPath);return target}export function ensureNoSymlinkInManagedPath(root,relativePath){let current=root;for(const segment of relativePath.split("/")){current=resolve(current,segment);const stat=lstatIfPresent(current);if(stat?.isSymbolicLink()){throw CliErrors.validation(`Refusing to write through Skill symlink path: ${relativePath}`)}}}export function isDanglingSymlink(path){try{
|
|
2
|
+
return lstatSync(path).isSymbolicLink()}catch{return false}}export function resolveSymlinkTarget(linkPath){const target=readlinkSync(linkPath);return isAbsolute(target)?target:resolve(dirname(linkPath),target)}export function isPathInside(child,parent){const normalizedChild=child.endsWith(sep)?child:`${child}${sep}`;const normalizedParent=parent.endsWith(sep)?parent:`${parent}${sep}`;return child===parent||normalizedChild.startsWith(normalizedParent)}export function realOrResolved(path){try{return realpathSync(path)}catch{return resolve(path)}}export function lstatIfPresent(path){try{return lstatSync(path)}catch{return undefined}}export function writeTextAtomic(path,content,mode){writeBytesAtomic(path,Buffer.from(content,"utf8"),mode)}export function writeBytesAtomic(path,content,mode){const tempPath=`${path}.tmp`;try{writeFileSync(tempPath,content,{mode:mode});renameSync(tempPath,path)}catch(error){try{rmSync(tempPath,{force:true})}catch{}throw error}}
|
|
3
|
+
export function writeJsonAtomic(path,value){writeTextAtomic(path,`${JSON.stringify(value,null,2)}\n`,384)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{createHash}from"node:crypto";import{fileContent,normalizeManifestFiles}from"./local-files.js";export function contentHash(content){return createHash("sha256").update(content).digest("hex")}export function fileHash(file){return bufferSha256(fileContent(file))}export function bufferSha256(buffer){return createHash("sha256").update(buffer).digest("hex")}export function fileTreeHash(files){const hash=createHash("sha256");for(const file of normalizeManifestFiles(files)){hash.update(file.path);hash.update("\0");hash.update(file.sha256);hash.update("\0");hash.update(String(file.size));hash.update("\0")}return hash.digest("hex")}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{resolve}from"node:path";import{resolveSkillSyncPaths,runtimeAgentSkillRoots,safePathSegment}from"./paths.js";export function resolveRuntimeSkillInstallTarget(appCode,scope="global",options={}){const paths=resolveSkillSyncPaths(options);const safeAppCode=safePathSegment(appCode,"appCode");const skillRoots=scope==="project"?[resolve(options.cwd??process.cwd(),".agents","skills")]:runtimeAgentSkillRoots(paths);return Object.freeze({scope:scope,appCode:safeAppCode,skillRoots:Object.freeze(skillRoots),managedRoot:paths.managedRoot})}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
const a158_0x5b06f6=a158_0x389e;(function(_0x1759c9,_0x55e11b){const _0x35bb74=a158_0x389e,_0x34fa6c=_0x1759c9();while(!![]){try{const _0x847707=-parseInt(_0x35bb74(0x179))/0x1*(parseInt(_0x35bb74(0x193))/0x2)+parseInt(_0x35bb74(0x187))/0x3+-parseInt(_0x35bb74(0x185))/0x4+-parseInt(_0x35bb74(0x18d))/0x5*(parseInt(_0x35bb74(0x186))/0x6)+parseInt(_0x35bb74(0x17f))/0x7+parseInt(_0x35bb74(0x17e))/0x8*(parseInt(_0x35bb74(0x195))/0x9)+-parseInt(_0x35bb74(0x18a))/0xa;if(_0x847707===_0x55e11b)break;else _0x34fa6c['push'](_0x34fa6c['shift']());}catch(_0x324d92){_0x34fa6c['push'](_0x34fa6c['shift']());}}}(a158_0x200a,0xd6148));import{existsSync,lstatSync,mkdirSync,readdirSync,symlinkSync,unlinkSync}from'node:fs';import{basename,dirname,resolve}from'node:path';import a158_0xc0b92c from'fs-extra';import{CliErrors}from'../../errors.js';import{METADATA_FILE}from'./constants.js';import{isDanglingSymlink,isPathInside,lstatIfPresent,realOrResolved,resolveSymlinkTarget}from'./fs-utils.js';import{readMetadataIfPresent,requireSkillCode}from'./metadata.js';import{getRuntimeSkillCacheRoot,resolveSkillSyncPaths,safePathSegment}from'./paths.js';function a158_0x389e(_0x2dfa3c,_0x5831cb){_0x2dfa3c=_0x2dfa3c-0x164;const _0x200a5d=a158_0x200a();let _0x389ea3=_0x200a5d[_0x2dfa3c];return _0x389ea3;}const {copySync,ensureDirSync,removeSync}=a158_0xc0b92c,RESERVED_PROJECT_SKILL_CODES=new Set([a158_0x5b06f6(0x199),a158_0x5b06f6(0x177),a158_0x5b06f6(0x165)]);export function linkEffectiveRuntimeSkills(_0x2cf057,_0x3590ad){const _0x4a04fe=a158_0x5b06f6,_0x52ce6a=new Map();for(const _0x3ab827 of _0x2cf057){const _0x444905=_0x3ab827['skill'][_0x4a04fe(0x169)];if(!_0x444905)continue;const _0x5efb79=_0x52ce6a[_0x4a04fe(0x197)](_0x444905);(!_0x5efb79||_0x3ab827[_0x4a04fe(0x18c)]==='personal')&&_0x52ce6a['set'](_0x444905,_0x3ab827);}const _0x31c72b=[];for(const _0x27bd3b of _0x52ce6a['values']()){const _0x54610f=requireSkillCode(_0x27bd3b[_0x4a04fe(0x16d)]),_0x1fec6b=readMetadataIfPresent(_0x27bd3b[_0x4a04fe(0x18e)]);if(_0x1fec6b?.['appCode']!==_0x3590ad[_0x4a04fe(0x17c)]||_0x1fec6b[_0x4a04fe(0x169)]!==_0x54610f)throw CliErrors[_0x4a04fe(0x181)]('Refusing\x20to\x20link\x20Skill\x20metadata\x20outside\x20target\x20'+_0x3590ad[_0x4a04fe(0x17c)]+':\x20'+_0x27bd3b[_0x4a04fe(0x18e)]);const _0xa1728f=runtimeSkillLinkName(_0x3590ad,_0x54610f);for(const _0x149f95 of _0x3590ad[_0x4a04fe(0x17a)]){_0x31c72b[_0x4a04fe(0x17b)](ensureManagedSymlink(resolve(_0x149f95,_0xa1728f),_0x27bd3b['dir'],_0x3590ad,_0x54610f));}}return _0x31c72b;}export function pruneStaleRuntimeSkillLinks(_0x5e0de3,_0x2c502f,_0x3d55cb){const _0x390ab2=a158_0x5b06f6,_0x180e7f=new Set([..._0x2c502f][_0x390ab2(0x18b)](_0x4ef42b=>_0x4ef42b[_0x390ab2(0x184)]())[_0x390ab2(0x167)](Boolean)),_0x5b2f04=_0x3d55cb?new Set([..._0x3d55cb]['map'](_0x20ffa9=>_0x20ffa9['trim']())['filter'](Boolean)):undefined,_0x1486af=[];for(const _0xc1ef3c of _0x5e0de3['skillRoots']){for(const _0x2ab468 of managedTargetSkillLinkPaths(_0xc1ef3c,_0x5e0de3)){const _0x5e158c=runtimeSkillCodeFromLink(_0x5e0de3,_0x2ab468);if(_0x5b2f04&&!_0x5b2f04[_0x390ab2(0x166)](_0x5e158c))continue;if(_0x180e7f[_0x390ab2(0x166)](_0x5e158c))continue;_0x1486af[_0x390ab2(0x17b)](removeManagedSkillLink(_0x2ab468,_0x5e0de3,_0x5e158c));}}return _0x1486af;}export function pruneStaleRuntimeSkillCache(_0x243266,_0x559589={}){const _0x1df652=a158_0x5b06f6,_0x32e8d2=new Set([..._0x243266[_0x1df652(0x183)]][_0x1df652(0x18b)](_0x3e8e35=>_0x3e8e35[_0x1df652(0x184)]())[_0x1df652(0x167)](Boolean)),_0x234e9d=_0x243266[_0x1df652(0x190)]?new Set([..._0x243266[_0x1df652(0x190)]]['map'](_0x584f72=>_0x584f72[_0x1df652(0x184)]())[_0x1df652(0x167)](Boolean)):undefined,_0x47a16b=_0x243266[_0x1df652(0x16b)]??[_0x1df652(0x173),_0x1df652(0x188)],_0x271836=resolve(getRuntimeSkillCacheRoot(_0x243266[_0x1df652(0x170)],_0x243266[_0x1df652(0x168)],_0x559589),safePathSegment(_0x243266[_0x1df652(0x17c)],'appCode')),_0x367c67=[];for(const _0x1fdb83 of _0x47a16b){const _0x2bbef4=resolve(_0x271836,_0x1fdb83);if(!existsSync(_0x2bbef4))continue;for(const _0x3d7a3c of readdirSync(_0x2bbef4,{'withFileTypes':!![]})){if(!_0x3d7a3c[_0x1df652(0x196)]())continue;const _0x52da42=_0x3d7a3c[_0x1df652(0x16e)];if(_0x234e9d&&!_0x234e9d['has'](_0x52da42))continue;if(_0x32e8d2[_0x1df652(0x166)](_0x52da42))continue;const _0x1b1ce7=resolve(_0x2bbef4,_0x52da42),_0xc77977=readMetadataIfPresent(resolve(_0x1b1ce7,METADATA_FILE));if(_0xc77977?.['appCode']!==_0x243266[_0x1df652(0x17c)]||_0xc77977[_0x1df652(0x18c)]!==_0x1fdb83||_0xc77977[_0x1df652(0x169)]!==_0x52da42){_0x367c67[_0x1df652(0x17b)]({'path':_0x1b1ce7,'action':'skipped','reason':_0x1df652(0x192)});continue;}if(isLinkedFromAnyRoot(_0x1b1ce7,_0x243266[_0x1df652(0x19a)]??[])){_0x367c67[_0x1df652(0x17b)]({'path':_0x1b1ce7,'action':_0x1df652(0x174),'reason':'linked-from-protected-root'});continue;}removeSync(_0x1b1ce7),_0x367c67['push']({'path':_0x1b1ce7,'action':_0x1df652(0x16a)});}}return _0x367c67;}export function linkGlobalRuntimeSkills(_0x4f68a9,_0x44d7ba={}){const _0x141c9f=a158_0x5b06f6,_0x3275a5=resolveSkillSyncPaths(_0x44d7ba),_0x30263c=[];for(const _0x4726fd of _0x4f68a9){if(_0x4726fd[_0x141c9f(0x18c)]!=='builtin')throw CliErrors['validation']('Only\x20builtin\x20Skills\x20can\x20be\x20linked\x20into\x20the\x20global\x20Skill\x20root:\x20'+_0x4726fd[_0x141c9f(0x18c)]);const _0x416e6b=requireSkillCode(_0x4726fd['skill']),_0xc02a8d=copyManagedSkillDirectory(_0x4726fd[_0x141c9f(0x16f)],resolve(_0x3275a5[_0x141c9f(0x194)],_0x416e6b));_0x30263c[_0x141c9f(0x17b)]({..._0xc02a8d,'contentHash':_0x4726fd[_0x141c9f(0x18f)]});}return _0x30263c;}function ensureManagedSymlink(_0x97ec02,_0x21f769,_0x92ac2a,_0x3a3d6d){const _0x58bb7e=a158_0x5b06f6;mkdirSync(dirname(_0x97ec02),{'recursive':!![],'mode':0x1c0});if(existsSync(_0x97ec02)||isDanglingSymlink(_0x97ec02)){const _0x4d2e73=lstatSync(_0x97ec02);if(!_0x4d2e73[_0x58bb7e(0x172)]())throw CliErrors[_0x58bb7e(0x181)](_0x58bb7e(0x164)+_0x97ec02);const _0x43ded0=resolveSymlinkTarget(_0x97ec02);if(!isPathInside(realOrResolved(_0x43ded0),realOrResolved(_0x92ac2a[_0x58bb7e(0x19b)])))throw CliErrors[_0x58bb7e(0x181)]('Refusing\x20to\x20overwrite\x20unmanaged\x20symlink:\x20'+_0x97ec02);if(realOrResolved(_0x43ded0)===realOrResolved(_0x21f769))return{'path':_0x97ec02,'target':_0x21f769,'action':_0x58bb7e(0x198)};const _0x1f3821=readMetadataIfPresent(resolve(_0x43ded0,METADATA_FILE));if(_0x92ac2a[_0x58bb7e(0x18c)]===_0x58bb7e(0x180)&&(_0x1f3821?.['appCode']!==_0x92ac2a[_0x58bb7e(0x17c)]||_0x1f3821['skillCode']!==_0x3a3d6d))throw CliErrors[_0x58bb7e(0x181)]('Refusing\x20to\x20overwrite\x20managed\x20Skill\x20link\x20owned\x20by\x20another\x20app\x20or\x20code:\x20'+_0x97ec02);return unlinkSync(_0x97ec02),symlinkSync(_0x21f769,_0x97ec02,_0x58bb7e(0x16f)),{'path':_0x97ec02,'target':_0x21f769,'action':_0x58bb7e(0x178)};}return symlinkSync(_0x21f769,_0x97ec02,_0x58bb7e(0x16f)),{'path':_0x97ec02,'target':_0x21f769,'action':_0x58bb7e(0x182)};}function managedTargetSkillLinkPaths(_0x502f9d,_0xf3eda){const _0x31ce9b=a158_0x5b06f6;if(!existsSync(_0x502f9d))return[];const _0x5e7143=_0xf3eda[_0x31ce9b(0x17c)]+'--';return readdirSync(_0x502f9d,{'withFileTypes':!![]})[_0x31ce9b(0x167)](_0x3a950c=>_0xf3eda[_0x31ce9b(0x18c)]===_0x31ce9b(0x180)||_0x3a950c['name'][_0x31ce9b(0x189)](_0x5e7143))[_0x31ce9b(0x18b)](_0x4bda3e=>resolve(_0x502f9d,_0x4bda3e[_0x31ce9b(0x16e)]));}function removeManagedSkillLink(_0x5aaefd,_0x2eea9f,_0x4343cb){const _0x4d5039=a158_0x5b06f6,_0x344722=lstatIfPresent(_0x5aaefd);if(!_0x344722?.[_0x4d5039(0x172)]())return{'path':_0x5aaefd,'action':_0x4d5039(0x174),'reason':_0x4d5039(0x175)};const _0x1fbbbd=resolveSymlinkTarget(_0x5aaefd);if(!isPathInside(realOrResolved(_0x1fbbbd),realOrResolved(_0x2eea9f[_0x4d5039(0x19b)])))return{'path':_0x5aaefd,'action':_0x4d5039(0x174),'reason':'external-symlink'};const _0x25c8d0=readMetadataIfPresent(resolve(_0x1fbbbd,METADATA_FILE));if(_0x2eea9f['scope']===_0x4d5039(0x180)&&(_0x25c8d0?.[_0x4d5039(0x17c)]!==_0x2eea9f[_0x4d5039(0x17c)]||_0x25c8d0['skillCode']!==_0x4343cb))return{'path':_0x5aaefd,'action':_0x4d5039(0x174),'reason':_0x4d5039(0x192)};return unlinkSync(_0x5aaefd),{'path':_0x5aaefd,'action':_0x4d5039(0x16a)};}function isLinkedFromAnyRoot(_0x146cf9,_0x327494){const _0x4d1409=a158_0x5b06f6,_0x4902ce=realOrResolved(_0x146cf9);for(const _0x5bad59 of _0x327494){if(!existsSync(_0x5bad59))continue;for(const _0x534f1c of readdirSync(_0x5bad59,{'withFileTypes':!![]})){if(!_0x534f1c[_0x4d1409(0x172)]())continue;const _0x310bf1=resolve(_0x5bad59,_0x534f1c[_0x4d1409(0x16e)]);if(realOrResolved(resolveSymlinkTarget(_0x310bf1))===_0x4902ce)return!![];}}return![];}function runtimeSkillLinkName(_0x542565,_0x2f6425){const _0x1090ab=a158_0x5b06f6,_0x4c7cb2=safePathSegment(_0x2f6425,_0x1090ab(0x169));if(_0x542565[_0x1090ab(0x18c)]===_0x1090ab(0x180)&&RESERVED_PROJECT_SKILL_CODES[_0x1090ab(0x166)](_0x4c7cb2))throw CliErrors['validation']('Refusing\x20to\x20shadow\x20reserved\x20Agent\x20Skill\x20in\x20project\x20scope:\x20'+_0x4c7cb2);return _0x542565[_0x1090ab(0x18c)]===_0x1090ab(0x180)?_0x4c7cb2:_0x542565[_0x1090ab(0x17c)]+'--'+_0x4c7cb2;}function runtimeSkillCodeFromLink(_0x4c4f2c,_0x1688d1){const _0x3dc92f=a158_0x5b06f6,_0x3052ee=basename(_0x1688d1);return _0x4c4f2c[_0x3dc92f(0x18c)]==='project'?_0x3052ee:_0x3052ee['slice']((_0x4c4f2c[_0x3dc92f(0x17c)]+'--')[_0x3dc92f(0x17d)]);}function a158_0x200a(){const _0x36935e=['9885780QUhrVf','map','scope','5bLNbNO','metadataPath','contentHash','pruneSkillCodes','Refusing\x20to\x20overwrite\x20unmanaged\x20global\x20Skill\x20directory:\x20','metadata-mismatch','1790AWHPhk','agentsSkillsDir','32229PwxuIz','isDirectory','get','unchanged','lovrabet','protectedLinkRoots','managedRoot','Refusing\x20to\x20overwrite\x20unmanaged\x20path:\x20','secret-retriever','has','filter','accessKey','skillCode','removed','scopes','Refusing\x20to\x20overwrite\x20global\x20Skill\x20symlink:\x20','skill','name','dir','env','builtin','isSymbolicLink','personal','skipped','not-managed-symlink','Refusing\x20to\x20copy\x20Skill\x20symlink:\x20','runtime-observe','updated','491QgXyOj','skillRoots','push','appCode','length','2920YcZUun','8116563oxvQHB','project','validation','created','activeSkillCodes','trim','2980700bCmQfo','6744834dysbAI','5122905gausmq','company','startsWith'];a158_0x200a=function(){return _0x36935e;};return a158_0x200a();}export function copyManagedSkillDirectory(_0x1370b4,_0x317411){const _0x2c913c=a158_0x5b06f6,_0x59a393=resolve(_0x317411,METADATA_FILE),_0x38b8d2=existsSync(_0x317411);if(_0x38b8d2){const _0x232561=lstatSync(_0x317411);if(_0x232561[_0x2c913c(0x172)]())throw CliErrors[_0x2c913c(0x181)](_0x2c913c(0x16c)+_0x317411);if(!_0x232561[_0x2c913c(0x196)]())throw CliErrors[_0x2c913c(0x181)]('Refusing\x20to\x20overwrite\x20global\x20Skill\x20path:\x20'+_0x317411);const _0x376578=readMetadataIfPresent(_0x59a393);if(_0x376578?.['scope']!==_0x2c913c(0x171))throw CliErrors[_0x2c913c(0x181)](_0x2c913c(0x191)+_0x317411);}ensureDirSync(dirname(_0x317411));const _0x4dc323=_0x38b8d2?readMetadataIfPresent(_0x59a393)?.[_0x2c913c(0x18f)]:undefined,_0x5bb9b3=readMetadataIfPresent(resolve(_0x1370b4,METADATA_FILE))?.['contentHash'];return _0x38b8d2&&removeSync(_0x317411),copySkillDirectory(_0x1370b4,_0x317411),{'path':_0x317411,'target':_0x1370b4,'action':!_0x38b8d2?'created':_0x4dc323===_0x5bb9b3?_0x2c913c(0x198):_0x2c913c(0x178)};}function copySkillDirectory(_0x15dae5,_0x15d00c){copySync(_0x15dae5,_0x15d00c,{'dereference':![],'overwrite':!![],'filter'(_0x3c8b41){const _0x3dad75=a158_0x389e;if(lstatSync(_0x3c8b41)[_0x3dad75(0x172)]())throw CliErrors['validation'](_0x3dad75(0x176)+_0x3c8b41);return!![];}});}
|
|
1
|
+
import{existsSync,lstatSync,mkdirSync,readdirSync,symlinkSync,unlinkSync}from"node:fs";import{basename,dirname,resolve}from"node:path";import fsExtra from"fs-extra";import{CliErrors}from"../../errors.js";import{METADATA_FILE}from"./constants.js";import{isDanglingSymlink,isPathInside,lstatIfPresent,realOrResolved,resolveSymlinkTarget}from"./fs-utils.js";import{readMetadataIfPresent,requireSkillCode}from"./metadata.js";import{getRuntimeSkillCacheRoot,resolveSkillSyncPaths,safePathSegment}from"./paths.js";const{copySync:copySync,ensureDirSync:ensureDirSync,removeSync:removeSync}=fsExtra;const RESERVED_PROJECT_SKILL_CODES=new Set(["lovrabet","runtime-observe","secret-retriever"]);export function linkEffectiveRuntimeSkills(materialized,target){const effective=new Map;for(const item of materialized){const key=item.skill.skillCode;if(!key)continue;const current=effective.get(key);if(!current||item.scope==="personal"){effective.set(key,item)}}const results=[]
|
|
2
|
+
;for(const item of effective.values()){const skillCode=requireSkillCode(item.skill);const metadata=readMetadataIfPresent(item.metadataPath);if(metadata?.appCode!==target.appCode||metadata.skillCode!==skillCode){throw CliErrors.validation(`Refusing to link Skill metadata outside target ${target.appCode}: ${item.metadataPath}`)}const linkName=runtimeSkillLinkName(target,skillCode);for(const parent of target.skillRoots){results.push(ensureManagedSymlink(resolve(parent,linkName),item.dir,target,skillCode))}}return results}export function pruneStaleRuntimeSkillLinks(target,activeSkillCodes,pruneSkillCodes){const active=new Set([...activeSkillCodes].map(item=>item.trim()).filter(Boolean));const candidates=pruneSkillCodes?new Set([...pruneSkillCodes].map(item=>item.trim()).filter(Boolean)):undefined;const results=[];for(const parent of target.skillRoots){for(const linkPath of managedTargetSkillLinkPaths(parent,target)){const skillCode=runtimeSkillCodeFromLink(target,linkPath)
|
|
3
|
+
;if(candidates&&!candidates.has(skillCode))continue;if(active.has(skillCode))continue;results.push(removeManagedSkillLink(linkPath,target,skillCode))}}return results}export function pruneStaleRuntimeSkillCache(input,options={}){const active=new Set([...input.activeSkillCodes].map(item=>item.trim()).filter(Boolean));const candidates=input.pruneSkillCodes?new Set([...input.pruneSkillCodes].map(item=>item.trim()).filter(Boolean)):undefined;const scopes=input.scopes??["personal","company"];const root=resolve(getRuntimeSkillCacheRoot(input.env,input.accessKey,options),safePathSegment(input.appCode,"appCode"));const results=[];for(const scope of scopes){const scopeDir=resolve(root,scope);if(!existsSync(scopeDir))continue;for(const entry of readdirSync(scopeDir,{withFileTypes:true})){if(!entry.isDirectory())continue;const skillCode=entry.name;if(candidates&&!candidates.has(skillCode))continue;if(active.has(skillCode))continue;const dir=resolve(scopeDir,skillCode)
|
|
4
|
+
;const metadata=readMetadataIfPresent(resolve(dir,METADATA_FILE));if(metadata?.appCode!==input.appCode||metadata.scope!==scope||metadata.skillCode!==skillCode){results.push({path:dir,action:"skipped",reason:"metadata-mismatch"});continue}if(isLinkedFromAnyRoot(dir,input.protectedLinkRoots??[])){results.push({path:dir,action:"skipped",reason:"linked-from-protected-root"});continue}removeSync(dir);results.push({path:dir,action:"removed"})}}return results}export function linkGlobalRuntimeSkills(materialized,options={}){const paths=resolveSkillSyncPaths(options);const results=[];for(const item of materialized){if(item.scope!=="builtin"){throw CliErrors.validation(`Only builtin Skills can be linked into the global Skill root: ${item.scope}`)}const skillCode=requireSkillCode(item.skill);const result=copyManagedSkillDirectory(item.dir,resolve(paths.agentsSkillsDir,skillCode));results.push({...result,contentHash:item.contentHash})}return results}
|
|
5
|
+
function ensureManagedSymlink(linkPath,targetPath,target,skillCode){mkdirSync(dirname(linkPath),{recursive:true,mode:448});if(existsSync(linkPath)||isDanglingSymlink(linkPath)){const stat=lstatSync(linkPath);if(!stat.isSymbolicLink()){throw CliErrors.validation(`Refusing to overwrite unmanaged path: ${linkPath}`)}const currentTarget=resolveSymlinkTarget(linkPath);if(!isPathInside(realOrResolved(currentTarget),realOrResolved(target.managedRoot))){throw CliErrors.validation(`Refusing to overwrite unmanaged symlink: ${linkPath}`)}if(realOrResolved(currentTarget)===realOrResolved(targetPath)){return{path:linkPath,target:targetPath,action:"unchanged"}}const metadata=readMetadataIfPresent(resolve(currentTarget,METADATA_FILE));if(target.scope==="project"&&(metadata?.appCode!==target.appCode||metadata.skillCode!==skillCode)){throw CliErrors.validation(`Refusing to overwrite managed Skill link owned by another app or code: ${linkPath}`)}unlinkSync(linkPath)
|
|
6
|
+
;symlinkSync(targetPath,linkPath,"dir");return{path:linkPath,target:targetPath,action:"updated"}}symlinkSync(targetPath,linkPath,"dir");return{path:linkPath,target:targetPath,action:"created"}}function managedTargetSkillLinkPaths(parent,target){if(!existsSync(parent))return[];const prefix=`${target.appCode}--`;return readdirSync(parent,{withFileTypes:true}).filter(entry=>target.scope==="project"||entry.name.startsWith(prefix)).map(entry=>resolve(parent,entry.name))}function removeManagedSkillLink(linkPath,target,skillCode){const stat=lstatIfPresent(linkPath);if(!stat?.isSymbolicLink()){return{path:linkPath,action:"skipped",reason:"not-managed-symlink"}}const currentTarget=resolveSymlinkTarget(linkPath);if(!isPathInside(realOrResolved(currentTarget),realOrResolved(target.managedRoot))){return{path:linkPath,action:"skipped",reason:"external-symlink"}}const metadata=readMetadataIfPresent(resolve(currentTarget,METADATA_FILE))
|
|
7
|
+
;if(target.scope==="project"&&(metadata?.appCode!==target.appCode||metadata.skillCode!==skillCode)){return{path:linkPath,action:"skipped",reason:"metadata-mismatch"}}unlinkSync(linkPath);return{path:linkPath,action:"removed"}}function isLinkedFromAnyRoot(cacheDir,protectedLinkRoots){const expectedTarget=realOrResolved(cacheDir);for(const root of protectedLinkRoots){if(!existsSync(root))continue;for(const entry of readdirSync(root,{withFileTypes:true})){if(!entry.isSymbolicLink())continue;const linkPath=resolve(root,entry.name);if(realOrResolved(resolveSymlinkTarget(linkPath))===expectedTarget){return true}}}return false}function runtimeSkillLinkName(target,skillCode){const safeSkillCode=safePathSegment(skillCode,"skillCode");if(target.scope==="project"&&RESERVED_PROJECT_SKILL_CODES.has(safeSkillCode)){throw CliErrors.validation(`Refusing to shadow reserved Agent Skill in project scope: ${safeSkillCode}`)}
|
|
8
|
+
return target.scope==="project"?safeSkillCode:`${target.appCode}--${safeSkillCode}`}function runtimeSkillCodeFromLink(target,linkPath){const name=basename(linkPath);return target.scope==="project"?name:name.slice(`${target.appCode}--`.length)}export function copyManagedSkillDirectory(sourceDir,targetDir){const targetMetadata=resolve(targetDir,METADATA_FILE);const existing=existsSync(targetDir);if(existing){const stat=lstatSync(targetDir);if(stat.isSymbolicLink()){throw CliErrors.validation(`Refusing to overwrite global Skill symlink: ${targetDir}`)}if(!stat.isDirectory()){throw CliErrors.validation(`Refusing to overwrite global Skill path: ${targetDir}`)}const metadata=readMetadataIfPresent(targetMetadata);if(metadata?.scope!=="builtin"){throw CliErrors.validation(`Refusing to overwrite unmanaged global Skill directory: ${targetDir}`)}}ensureDirSync(dirname(targetDir));const previousHash=existing?readMetadataIfPresent(targetMetadata)?.contentHash:undefined
|
|
9
|
+
;const sourceHash=readMetadataIfPresent(resolve(sourceDir,METADATA_FILE))?.contentHash;if(existing){removeSync(targetDir)}copySkillDirectory(sourceDir,targetDir);return{path:targetDir,target:sourceDir,action:!existing?"created":previousHash===sourceHash?"unchanged":"updated"}}function copySkillDirectory(sourceDir,targetDir){copySync(sourceDir,targetDir,{dereference:false,overwrite:true,filter(sourcePath){if(lstatSync(sourcePath).isSymbolicLink()){throw CliErrors.validation(`Refusing to copy Skill symlink: ${sourcePath}`)}return true}})}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{existsSync,readdirSync}from"node:fs";import{resolve}from"node:path";import{CliErrors}from"../../errors.js";import{METADATA_FILE,SKILL_FILE}from"./constants.js";import{readMetadataIfPresent}from"./metadata.js";import{getRuntimeSkillCacheRoot,safePathSegment}from"./paths.js";import{isRuntimeSkillScope,normalizeRuntimeSkillScopes}from"./scopes.js";export function listLocalRuntimeSkills(input,target,options={}){const appCode=safePathSegment(input.appCode,"appCode");if(target.appCode!==appCode){throw CliErrors.validation(`Runtime Skill install target app mismatch: ${target.appCode} != ${appCode}`)}const scopes=normalizeRuntimeSkillScopes(input.scopes);const scopeSet=new Set(scopes);const code=input.code?.trim();const items=new Map;const cacheAppRoot=resolve(getRuntimeSkillCacheRoot(input.env,input.accessKey,options),appCode);for(const scope of scopes){for(const dir of localSkillEntryDirs(resolve(cacheAppRoot,scope))){collectLocalRuntimeSkill(items,dir,{appCode:appCode,
|
|
2
|
+
scopes:scopeSet,code:code,source:"cache"})}}for(const parent of target.skillRoots){for(const dir of localSkillLinkCandidates(parent,target,scopeSet)){collectLocalRuntimeSkill(items,dir,{appCode:appCode,scopes:scopeSet,code:code,source:"link",linkedPath:dir})}}return Array.from(items.values()).sort(compareLocalRuntimeSkills)}function localSkillEntryDirs(parent){if(!existsSync(parent))return[];return readdirSync(parent,{withFileTypes:true}).filter(entry=>entry.isDirectory()||entry.isSymbolicLink()).map(entry=>resolve(parent,entry.name))}function localSkillLinkCandidates(parent,target,scopes){if(!existsSync(parent))return[];const appPrefix=`${target.appCode}--`;return readdirSync(parent,{withFileTypes:true}).filter(entry=>entry.isDirectory()||entry.isSymbolicLink()).filter(entry=>target.scope==="project"||entry.name.startsWith(appPrefix)||scopes.has("builtin")).map(entry=>resolve(parent,entry.name))}function collectLocalRuntimeSkill(items,dir,options){
|
|
3
|
+
const metadataPath=resolve(dir,METADATA_FILE);const metadata=readMetadataIfPresent(metadataPath);if(!metadata)return;if(metadata.appCode!==options.appCode)return;if(!isRuntimeSkillScope(metadata.scope)||!options.scopes.has(metadata.scope))return;const skillCode=metadata.skillCode?.trim();if(!skillCode)return;if(options.code&&skillCode!==options.code)return;const key=`${metadata.scope}:${skillCode}`;const linkedPaths=options.linkedPath?[options.linkedPath]:[];const existing=items.get(key);if(existing){if(options.source==="cache"){existing.dir=dir;existing.cacheDir=dir;existing.skillMdPath=resolve(dir,SKILL_FILE);existing.metadataPath=metadataPath}for(const linkedPath of linkedPaths){if(!existing.linkedPaths.includes(linkedPath)){existing.linkedPaths.push(linkedPath)}}existing.linkedPaths.sort();return}items.set(key,{...metadata,tags:Array.isArray(metadata.tags)?metadata.tags:[],scope:metadata.scope,source:"local",dir:dir,cacheDir:options.source==="cache"?dir:undefined,
|
|
4
|
+
skillMdPath:resolve(dir,SKILL_FILE),metadataPath:metadataPath,linkedPaths:linkedPaths})}function compareLocalRuntimeSkills(a,b){const scopeOrder={personal:0,company:1,builtin:2};return scopeOrder[a.scope]-scopeOrder[b.scope]||a.skillCode.localeCompare(b.skillCode)||a.dir.localeCompare(b.dir)}
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import{readFileSync,readdirSync,realpathSync}from"node:fs";import{relative,resolve}from"node:path";import{CliErrors}from"../../errors.js";import{IGNORED_DIR_NAMES,IGNORED_FILE_NAMES,SKILL_FILE}from"./constants.js";export function fileContent(file){return file.bytes??Buffer.from(file.content??"","utf8")}export function fileText(file){return fileContent(file).toString("utf8")}export function normalizeLocalFiles(files){if(!Array.isArray(files)||files.length===0){return[]}const normalized=new Map;for(const file of files){if(!file||typeof file!=="object"||typeof file.path!=="string"){throw CliErrors.validation("Skill file path must be text.")}const path=normalizeSkillRelativePath(file.path);if(normalized.has(path)){throw CliErrors.validation(`Duplicate Skill file path: ${path}`)}if(file.bytes!==undefined&&!Buffer.isBuffer(file.bytes)){throw CliErrors.validation(`Skill file bytes must be a Buffer: ${path}`)}if(file.bytes===undefined&&typeof file.content!=="string"){
|
|
2
|
+
throw CliErrors.validation(`Skill file content must be text or bytes: ${path}`)}const bytes=fileContent(file);normalized.set(path,{path:path,bytes:bytes})}return Array.from(normalized.values()).sort(compareSkillFiles)}export function normalizeManifestFiles(files){if(!Array.isArray(files)||files.length===0){return[]}const normalized=new Map;for(const file of files){if(!file||typeof file!=="object"||typeof file.path!=="string"){throw CliErrors.validation("Skill file path must be text.")}const path=normalizeSkillRelativePath(file.path);if(normalized.has(path)){throw CliErrors.validation(`Duplicate Skill file path: ${path}`)}if(!isSha256Hex(file.sha256)){throw CliErrors.validation(`Skill file sha256 is invalid: ${path}`)}if(!Number.isSafeInteger(file.size)||file.size<0){throw CliErrors.validation(`Skill file size is invalid: ${path}`)}normalized.set(path,{path:path,sha256:file.sha256.toLowerCase(),size:file.size})}return Array.from(normalized.values()).sort(compareSkillFiles)}
|
|
3
|
+
export function scanSkillDirectory(dir,options={}){const root=realpathSync(dir);const excludedFilePaths=canonicalExcludedFilePaths(options.excludedFilePaths);const files=[];function visit(current){const entries=readdirSync(current,{withFileTypes:true}).sort((a,b)=>a.name.localeCompare(b.name));for(const entry of entries){if(entry.isDirectory()&&IGNORED_DIR_NAMES.has(entry.name)){continue}if(IGNORED_FILE_NAMES.has(entry.name)){continue}const absolutePath=resolve(current,entry.name);if(isExcludedFilePath(absolutePath,excludedFilePaths)){continue}if(entry.isSymbolicLink()){throw CliErrors.validation(`Skill directory contains unsupported symlink: ${absolutePath}`)}const relativePath=toPosixPath(relative(root,absolutePath));if(entry.isDirectory()){visit(absolutePath);continue}if(!entry.isFile()){continue}validateSkillRelativePath(relativePath);const buffer=readFileSync(absolutePath);files.push({path:relativePath,bytes:buffer})}}visit(root);return normalizeLocalFiles(files)}
|
|
4
|
+
function canonicalExcludedFilePaths(paths){const excluded=new Set;for(const path of paths??[]){const absolutePath=resolve(path);excluded.add(absolutePath);try{excluded.add(realpathSync(absolutePath))}catch{}}return excluded}function isExcludedFilePath(absolutePath,excluded){if(excluded.has(absolutePath))return true;if(excluded.size===0)return false;try{return excluded.has(realpathSync(absolutePath))}catch{return false}}export function compareSkillFiles(a,b){if(a.path===SKILL_FILE)return b.path===SKILL_FILE?0:-1;if(b.path===SKILL_FILE)return 1;return Buffer.compare(Buffer.from(a.path,"utf8"),Buffer.from(b.path,"utf8"))}export function normalizeSkillRelativePath(path){const normalized=toPosixPath(path.trim());validateSkillRelativePath(normalized);return normalized}export function validateSkillRelativePath(path){if(!path||path.startsWith("/")||path.includes("//")){throw CliErrors.validation(`Unsafe Skill file path: ${path}`)}for(const segment of path.split("/")){
|
|
5
|
+
if(!segment||segment==="."||segment===".."){throw CliErrors.validation(`Unsafe Skill file path: ${path}`)}}}export function toPosixPath(path){return path.replace(/\\/g,"/")}export function isSha256Hex(value){return typeof value==="string"&&/^[a-fA-F0-9]{64}$/.test(value)}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
function a161_0x2a6b(){const _0xed498e=['.\x20Changed\x20file:\x20','version','delete','1479198GgfVbT','displayName','name:\x20','hasOwn','---','map','22896648JGsIFF','path','status','Runtime\x20Skill\x20package\x20is\x20missing\x20','displayName:\x20','trimEnd','paths','schemaVersion','isFile','stringify','replace','---\x0a','Push\x20the\x20directory\x20first,\x20then\x20rerun\x20skill\x20install.','pulledAt','Local\x20SKILL.md\x20has\x20unpushed\x20edits:\x20','Remote\x20Skill\x20would\x20overwrite\x20a\x20local\x20non-file\x20path:\x20','match','trim','accessKey','scope','30fVPdHp','entries','env','flow','contents','force','keys','errors','set','example','name','appCode','has','760218VDVFJy','description:\x20','find','utf8','\x0a---\x0a\x0a','fileHashes','6996972ugdAuL','13432643LwdJey','contentHash','test','1078000YPsBdz','length','description','join','1286589HBlPyb','Push\x20the\x20directory\x20first,\x20then\x20rerun\x20skill\x20install.\x20Changed\x20file:\x20','2IjlDpR','skillName','validation','Local\x20Skill\x20files\x20have\x20unpushed\x20edits:\x20'];a161_0x2a6b=function(){return _0xed498e;};return a161_0x2a6b();}(function(_0x3a56fa,_0x5631f8){const _0x53c5c0=a161_0x3498,_0x1f6ffc=_0x3a56fa();while(!![]){try{const _0x37078d=-parseInt(_0x53c5c0(0xa2))/0x1*(parseInt(_0x53c5c0(0xa9))/0x2)+parseInt(_0x53c5c0(0xa0))/0x3+parseInt(_0x53c5c0(0x98))/0x4+parseInt(_0x53c5c0(0x85))/0x5*(parseInt(_0x53c5c0(0x92))/0x6)+parseInt(_0x53c5c0(0x99))/0x7+parseInt(_0x53c5c0(0x9c))/0x8+-parseInt(_0x53c5c0(0xaf))/0x9;if(_0x37078d===_0x5631f8)break;else _0x1f6ffc['push'](_0x1f6ffc['shift']());}catch(_0xc1126e){_0x1f6ffc['push'](_0x1f6ffc['shift']());}}}(a161_0x2a6b,0xec831));import{existsSync,lstatSync,mkdirSync,readFileSync,rmSync}from'node:fs';import{dirname,resolve}from'node:path';import{isCollection,isMap,isNode,parseDocument,visit}from'yaml';import{CliErrors}from'../../errors.js';import{METADATA_FILE,SKILL_FILE}from'./constants.js';import{resolveManagedFilePath,writeBytesAtomic,writeJsonAtomic}from'./fs-utils.js';import{bufferSha256,contentHash,fileHash}from'./hashing.js';import{fileContent,fileText,normalizeLocalFiles}from'./local-files.js';import{buildMetadata,readMetadataIfPresent,requireSkillCode}from'./metadata.js';import{getRuntimeSkillDir}from'./paths.js';import{extractDownloadedPackage,requirePackageBytes}from'./zip-package.js';function a161_0x3498(_0x253867,_0x6a0306){_0x253867=_0x253867-0x81;const _0x2a6b72=a161_0x2a6b();let _0x34981d=_0x2a6b72[_0x253867];return _0x34981d;}export function materializeRuntimeSkill(_0x1c0e52,_0x19a75f,_0x2901fb){const _0x36abd1=a161_0x3498,_0x158c2b=requireSkillCode(_0x1c0e52),_0x547136=requirePackageBytes(_0x158c2b,_0x2901fb['packageBytes']),_0x4fcf66=extractDownloadedPackage(_0x547136),_0x5d150e=_0x4fcf66[_0x36abd1(0x94)](_0x15db7a=>_0x15db7a[_0x36abd1(0xb0)]===SKILL_FILE);if(!_0x5d150e)throw CliErrors[_0x36abd1(0xa4)](_0x36abd1(0xb2)+SKILL_FILE+':\x20'+_0x158c2b);const _0x404196=withMaterializedSkillFrontmatter(_0x4fcf66,_0x1c0e52,_0x158c2b),_0x1cbf4d=_0x404196['find'](_0x5461fa=>_0x5461fa[_0x36abd1(0xb0)]===SKILL_FILE),_0x5e6f7c=fileText(_0x1cbf4d),_0xca915a=getRuntimeSkillDir(_0x2901fb[_0x36abd1(0x87)],_0x2901fb['accessKey'],_0x2901fb['appCode'],_0x19a75f,_0x158c2b,_0x2901fb['paths']),_0x39d5a0=resolve(_0xca915a,SKILL_FILE),_0x3d6837=resolve(_0xca915a,METADATA_FILE),_0x4fe6d0=contentHash(_0x5e6f7c),_0x268735=readMetadataIfPresent(_0x3d6837)?.[_0x36abd1(0x97)];ensurePulledFilesCanBeOverwritten(_0xca915a,_0x3d6837,_0x404196,_0x2901fb[_0x36abd1(0x8a)]===!![]),mkdirSync(_0xca915a,{'recursive':!![],'mode':0x1c0});const _0x426614=existsSync(_0x39d5a0)?readFileSync(_0x39d5a0,_0x36abd1(0x95)):undefined;return materializeFiles(_0xca915a,_0x404196),removeStaleManagedFiles(_0xca915a,_0x268735,_0x404196),writeJsonAtomic(_0x3d6837,buildMetadata(_0x1c0e52,_0x19a75f,_0x2901fb[_0x36abd1(0x90)],_0x4fe6d0,_0x2901fb[_0x36abd1(0xbc)],_0x404196,_0x547136)),{'skill':_0x1c0e52,'scope':_0x19a75f,'dir':_0xca915a,'skillMdPath':_0x39d5a0,'metadataPath':_0x3d6837,'contentHash':_0x4fe6d0,'changed':_0x426614!==_0x5e6f7c};}export function reuseMaterializedRuntimeSkill(_0x13e224,_0x14ab6,_0x1f8ca2){const _0x2a9896=a161_0x3498,_0xbf8dc8=_0x13e224[_0x2a9896(0xa7)]?.['trim']();if(!_0xbf8dc8)return undefined;const _0xd9db4e=requireSkillCode(_0x13e224),_0x153541=getRuntimeSkillDir(_0x1f8ca2[_0x2a9896(0x87)],_0x1f8ca2[_0x2a9896(0x83)],_0x1f8ca2['appCode'],_0x14ab6,_0xd9db4e,_0x1f8ca2[_0x2a9896(0xb5)]),_0x275e5e=resolve(_0x153541,SKILL_FILE),_0x5046ee=resolve(_0x153541,METADATA_FILE),_0x345c77=readMetadataIfPresent(_0x5046ee);if(!_0x345c77||_0x345c77[_0x2a9896(0xb6)]!==0x2||_0x345c77[_0x2a9896(0x90)]!==_0x1f8ca2[_0x2a9896(0x90)]||_0x345c77[_0x2a9896(0x84)]!==_0x14ab6||_0x345c77['skillCode']!==_0xd9db4e||_0x345c77['version']!==_0xbf8dc8||_0x345c77['id']!==_0x13e224['id']||_0x345c77[_0x2a9896(0xa3)]!==_0x13e224['skillName']||_0x345c77['description']!==_0x13e224[_0x2a9896(0x9e)]||_0x345c77[_0x2a9896(0x8e)]!==_0x13e224[_0x2a9896(0x8e)]||_0x345c77[_0x2a9896(0xb1)]!==_0x13e224['status']||!_0x345c77[_0x2a9896(0x9a)]||!_0x345c77[_0x2a9896(0x97)]||!Object[_0x2a9896(0xac)](_0x345c77['fileHashes'],SKILL_FILE))return undefined;for(const [_0x428390,_0x3ec660]of Object['entries'](_0x345c77[_0x2a9896(0x97)])){if(!/^[a-f0-9]{64}$/[_0x2a9896(0x9b)](_0x3ec660))return undefined;const _0x39cb9c=resolveManagedFilePath(_0x153541,_0x428390);if(!existsSync(_0x39cb9c)||!lstatSync(_0x39cb9c)[_0x2a9896(0xb7)]())return undefined;if(bufferSha256(readFileSync(_0x39cb9c))!==_0x3ec660)return undefined;}return{'skill':_0x13e224,'scope':_0x14ab6,'dir':_0x153541,'skillMdPath':_0x275e5e,'metadataPath':_0x5046ee,'contentHash':_0x345c77['contentHash'],'changed':![]};}function withMaterializedSkillFrontmatter(_0x3895ed,_0x43584f,_0x2ba11a){const _0x109fc5=a161_0x3498,_0x41e723=skillDisplayName(_0x43584f,_0x2ba11a),_0x4938fd=_0x43584f['description']?.[_0x109fc5(0x82)]()||_0x41e723||_0x2ba11a;return normalizeLocalFiles(_0x3895ed)['map'](_0x1527f7=>{const _0xe8ad75=_0x109fc5,_0x340827=fileText(_0x1527f7);if(_0x1527f7[_0xe8ad75(0xb0)]!==SKILL_FILE)return _0x1527f7;if(hasYamlFrontmatter(_0x340827))return{'path':_0x1527f7['path'],'content':withSyncedDisplayName(_0x340827,_0x41e723)};return{'path':_0x1527f7[_0xe8ad75(0xb0)],'content':prependSkillFrontmatter(_0x340827,{'name':_0x2ba11a,'displayName':_0x41e723,'description':_0x4938fd})};});}function hasYamlFrontmatter(_0x514ae6){const _0x52d96b=a161_0x3498;return/^\uFEFF?---\s*\r?\n/[_0x52d96b(0x9b)](_0x514ae6);}function prependSkillFrontmatter(_0x3ec3de,_0x1fc2cc){const _0x4faaee=a161_0x3498,_0x2d50c1=_0x3ec3de[_0x4faaee(0xb9)](/^\uFEFF/,'');return[_0x4faaee(0xad),_0x4faaee(0xab)+yamlString(_0x1fc2cc[_0x4faaee(0x8f)]),_0x1fc2cc['displayName']?_0x4faaee(0xb3)+yamlString(_0x1fc2cc[_0x4faaee(0xaa)]):undefined,_0x4faaee(0x93)+yamlString(_0x1fc2cc[_0x4faaee(0x9e)]),'---','',_0x2d50c1]['filter'](_0x5be7c5=>_0x5be7c5!==undefined)[_0x4faaee(0x9f)]('\x0a');}function yamlString(_0x2fea14){const _0x4471f1=a161_0x3498;return JSON[_0x4471f1(0xb8)](_0x2fea14[_0x4471f1(0xb9)](/\r/g,'')[_0x4471f1(0x82)]());}function skillDisplayName(_0x53ef19,_0x25eaa7){const _0x5abcd1=a161_0x3498,_0x2a3c79=_0x53ef19[_0x5abcd1(0xa3)]?.[_0x5abcd1(0x82)]();return _0x2a3c79||_0x25eaa7;}function withSyncedDisplayName(_0xc45704,_0x54287e){const _0xb1a439=a161_0x3498,_0x192d45=_0xc45704[_0xb1a439(0x81)](/^(\uFEFF?)---\s*\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);if(!_0x192d45)return _0xc45704;const _0x439cd6=_0x192d45[0x1]??'',_0x33a302=_0x192d45[0x2]??'',_0x267dc3=parseDocument(_0x33a302);if(_0x267dc3[_0xb1a439(0x8c)][_0xb1a439(0x9d)]>0x0||!isMap(_0x267dc3['contents']))return _0xc45704;if(_0x54287e)_0x267dc3[_0xb1a439(0x8d)](_0xb1a439(0xaa),_0x54287e);else{if(_0x267dc3['has'](_0xb1a439(0xaa)))_0x267dc3[_0xb1a439(0xa8)](_0xb1a439(0xaa));else return _0xc45704;}forceBlockCollections(_0x267dc3[_0xb1a439(0x89)]);const _0x4c36a9=_0x267dc3['toString']({'lineWidth':0x0})[_0xb1a439(0xb4)](),_0x1d54bb=_0xc45704['slice'](_0x192d45[0x0][_0xb1a439(0x9d)])[_0xb1a439(0xb9)](/^\r?\n/,'');return _0x439cd6+_0xb1a439(0xba)+_0x4c36a9+_0xb1a439(0x96)+_0x1d54bb;}function forceBlockCollections(_0x6f0829){if(!isNode(_0x6f0829))return;visit(_0x6f0829,(_0x13a282,_0x2c967d)=>{const _0x2f7113=a161_0x3498;isCollection(_0x2c967d)&&(_0x2c967d[_0x2f7113(0x88)]=![]);});}function ensurePulledFilesCanBeOverwritten(_0x2b4993,_0x16323c,_0x572192,_0x4cd455){const _0x28053e=a161_0x3498;if(_0x4cd455||!existsSync(_0x16323c))return;const _0x6ba330=readMetadataIfPresent(_0x16323c);if(!_0x6ba330)return;const _0x34fed0=_0x6ba330[_0x28053e(0x97)]&&Object[_0x28053e(0x8b)](_0x6ba330[_0x28053e(0x97)])[_0x28053e(0x9d)]>0x0?_0x6ba330[_0x28053e(0x97)]:undefined;if(_0x34fed0)for(const [_0x5ea872,_0x4285c5]of Object[_0x28053e(0x86)](_0x34fed0)){const _0x33243a=resolveManagedFilePath(_0x2b4993,_0x5ea872);if(!existsSync(_0x33243a))throw CliErrors['validation'](_0x28053e(0xa5)+_0x2b4993,'Managed\x20file\x20was\x20removed\x20locally:\x20'+_0x5ea872);const _0x558a59=lstatSync(_0x33243a);if(!_0x558a59[_0x28053e(0xb7)]())throw CliErrors['validation']('Local\x20Skill\x20files\x20have\x20unpushed\x20edits:\x20'+_0x2b4993,'Managed\x20file\x20is\x20no\x20longer\x20a\x20regular\x20file:\x20'+_0x5ea872);const _0x5d15a7=bufferSha256(readFileSync(_0x33243a));if(_0x5d15a7!==_0x4285c5)throw CliErrors['validation'](_0x28053e(0xa5)+_0x2b4993+_0x28053e(0xa6)+_0x5ea872,_0x28053e(0xa1)+_0x5ea872);}else{const _0x1393fd=resolve(_0x2b4993,SKILL_FILE);if(existsSync(_0x1393fd)&&_0x6ba330[_0x28053e(0x9a)]){const _0x210255=contentHash(readFileSync(_0x1393fd,_0x28053e(0x95)));if(_0x210255!==_0x6ba330[_0x28053e(0x9a)])throw CliErrors['validation'](_0x28053e(0xbd)+_0x1393fd,_0x28053e(0xbb));}}for(const _0x2c13e0 of normalizeLocalFiles(_0x572192)){if(_0x34fed0?.[_0x2c13e0[_0x28053e(0xb0)]])continue;if(!_0x34fed0&&_0x2c13e0[_0x28053e(0xb0)]===SKILL_FILE)continue;const _0x910002=resolveManagedFilePath(_0x2b4993,_0x2c13e0['path']);if(!existsSync(_0x910002))continue;const _0x2eae8e=lstatSync(_0x910002);if(!_0x2eae8e[_0x28053e(0xb7)]())throw CliErrors[_0x28053e(0xa4)](_0x28053e(0xa5)+_0x2b4993,_0x28053e(0xbe)+_0x2c13e0[_0x28053e(0xb0)]);const _0x1acd89=bufferSha256(readFileSync(_0x910002));if(_0x1acd89!==fileHash(_0x2c13e0))throw CliErrors['validation'](_0x28053e(0xa5)+_0x2b4993,'Remote\x20Skill\x20would\x20overwrite\x20an\x20unmanaged\x20local\x20file:\x20'+_0x2c13e0[_0x28053e(0xb0)]);}}function materializeFiles(_0x4f78ec,_0xad69e0){const _0x49edcb=a161_0x3498;for(const _0x220c99 of normalizeLocalFiles(_0xad69e0)){const _0x2bd87f=resolveManagedFilePath(_0x4f78ec,_0x220c99[_0x49edcb(0xb0)]);mkdirSync(dirname(_0x2bd87f),{'recursive':!![],'mode':0x1c0}),writeBytesAtomic(_0x2bd87f,fileContent(_0x220c99),0x180);}}function removeStaleManagedFiles(_0x5c81c1,_0x244e1d,_0x10acbe){const _0x1031dd=a161_0x3498;if(!_0x244e1d)return;const _0x4717b7=new Set(normalizeLocalFiles(_0x10acbe)[_0x1031dd(0xae)](_0x18d846=>_0x18d846[_0x1031dd(0xb0)]));for(const _0x5f11dc of Object[_0x1031dd(0x8b)](_0x244e1d)){if(_0x4717b7[_0x1031dd(0x91)](_0x5f11dc))continue;const _0x19fbce=resolveManagedFilePath(_0x5c81c1,_0x5f11dc);existsSync(_0x19fbce)&&lstatSync(_0x19fbce)[_0x1031dd(0xb7)]()&&rmSync(_0x19fbce,{'force':!![]});}}
|
|
1
|
+
import{existsSync,lstatSync,mkdirSync,readFileSync,rmSync}from"node:fs";import{dirname,resolve}from"node:path";import{isCollection,isMap,isNode,parseDocument,visit}from"yaml";import{CliErrors}from"../../errors.js";import{METADATA_FILE,SKILL_FILE}from"./constants.js";import{resolveManagedFilePath,writeBytesAtomic,writeJsonAtomic}from"./fs-utils.js";import{bufferSha256,contentHash,fileHash}from"./hashing.js";import{fileContent,fileText,normalizeLocalFiles}from"./local-files.js";import{buildMetadata,readMetadataIfPresent,requireSkillCode}from"./metadata.js";import{getRuntimeSkillDir}from"./paths.js";import{extractDownloadedPackage,requirePackageBytes}from"./zip-package.js";export function materializeRuntimeSkill(skill,scope,options){const skillCode=requireSkillCode(skill);const packageBytes=requirePackageBytes(skillCode,options.packageBytes);const effectiveFiles=extractDownloadedPackage(packageBytes);const mainFile=effectiveFiles.find(file=>file.path===SKILL_FILE);if(!mainFile){
|
|
2
|
+
throw CliErrors.validation(`Runtime Skill package is missing ${SKILL_FILE}: ${skillCode}`)}const materializedFiles=withMaterializedSkillFrontmatter(effectiveFiles,skill,skillCode);const materializedMainFile=materializedFiles.find(file=>file.path===SKILL_FILE);const content=fileText(materializedMainFile);const dir=getRuntimeSkillDir(options.env,options.accessKey,options.appCode,scope,skillCode,options.paths);const skillMdPath=resolve(dir,SKILL_FILE);const metadataPath=resolve(dir,METADATA_FILE);const hash=contentHash(content);const previousFiles=readMetadataIfPresent(metadataPath)?.fileHashes;ensurePulledFilesCanBeOverwritten(dir,metadataPath,materializedFiles,options.force===true);mkdirSync(dir,{recursive:true,mode:448});const previous=existsSync(skillMdPath)?readFileSync(skillMdPath,"utf8"):undefined;materializeFiles(dir,materializedFiles);removeStaleManagedFiles(dir,previousFiles,materializedFiles)
|
|
3
|
+
;writeJsonAtomic(metadataPath,buildMetadata(skill,scope,options.appCode,hash,options.pulledAt,materializedFiles,packageBytes));return{skill:skill,scope:scope,dir:dir,skillMdPath:skillMdPath,metadataPath:metadataPath,contentHash:hash,changed:previous!==content}}export function reuseMaterializedRuntimeSkill(skill,scope,options){const version=skill.version?.trim();if(!version)return undefined;const skillCode=requireSkillCode(skill);const dir=getRuntimeSkillDir(options.env,options.accessKey,options.appCode,scope,skillCode,options.paths);const skillMdPath=resolve(dir,SKILL_FILE);const metadataPath=resolve(dir,METADATA_FILE);const metadata=readMetadataIfPresent(metadataPath)
|
|
4
|
+
;if(!metadata||metadata.schemaVersion!==2||metadata.appCode!==options.appCode||metadata.scope!==scope||metadata.skillCode!==skillCode||metadata.version!==version||metadata.id!==skill.id||metadata.skillName!==skill.skillName||metadata.description!==skill.description||metadata.example!==skill.example||metadata.status!==skill.status||!metadata.contentHash||!metadata.fileHashes||!Object.hasOwn(metadata.fileHashes,SKILL_FILE)){return undefined}for(const[path,expectedHash]of Object.entries(metadata.fileHashes)){if(!/^[a-f0-9]{64}$/.test(expectedHash))return undefined;const filePath=resolveManagedFilePath(dir,path);if(!existsSync(filePath)||!lstatSync(filePath).isFile())return undefined;if(bufferSha256(readFileSync(filePath))!==expectedHash)return undefined}return{skill:skill,scope:scope,dir:dir,skillMdPath:skillMdPath,metadataPath:metadataPath,contentHash:metadata.contentHash,changed:false}}function withMaterializedSkillFrontmatter(files,skill,skillCode){
|
|
5
|
+
const displayName=skillDisplayName(skill,skillCode);const description=skill.description?.trim()||displayName||skillCode;return normalizeLocalFiles(files).map(file=>{const content=fileText(file);if(file.path!==SKILL_FILE)return file;if(hasYamlFrontmatter(content)){return{path:file.path,content:withSyncedDisplayName(content,displayName)}}return{path:file.path,content:prependSkillFrontmatter(content,{name:skillCode,displayName:displayName,description:description})}})}function hasYamlFrontmatter(content){return/^\uFEFF?---\s*\r?\n/.test(content)}function prependSkillFrontmatter(content,frontmatter){const body=content.replace(/^\uFEFF/,"");return["---",`name: ${yamlString(frontmatter.name)}`,frontmatter.displayName?`displayName: ${yamlString(frontmatter.displayName)}`:undefined,`description: ${yamlString(frontmatter.description)}`,"---","",body].filter(line=>line!==undefined).join("\n")}function yamlString(value){return JSON.stringify(value.replace(/\r/g,"").trim())}
|
|
6
|
+
function skillDisplayName(skill,skillCode){const skillName=skill.skillName?.trim();return skillName||skillCode}function withSyncedDisplayName(content,displayName){const match=content.match(/^(\uFEFF?)---\s*\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);if(!match)return content;const bom=match[1]??"";const yaml=match[2]??"";const document=parseDocument(yaml);if(document.errors.length>0||!isMap(document.contents)){return content}if(displayName){document.set("displayName",displayName)}else if(document.has("displayName")){document.delete("displayName")}else{return content}forceBlockCollections(document.contents);const frontmatter=document.toString({lineWidth:0}).trimEnd();const body=content.slice(match[0].length).replace(/^\r?\n/,"");return`${bom}---\n${frontmatter}\n---\n\n${body}`}function forceBlockCollections(node){if(!isNode(node))return;visit(node,(_key,value)=>{if(isCollection(value)){value.flow=false}})}function ensurePulledFilesCanBeOverwritten(dir,metadataPath,nextFiles,force){
|
|
7
|
+
if(force||!existsSync(metadataPath)){return}const metadata=readMetadataIfPresent(metadataPath);if(!metadata)return;const previousFileHashes=metadata.fileHashes&&Object.keys(metadata.fileHashes).length>0?metadata.fileHashes:undefined;if(previousFileHashes){for(const[path,expectedHash]of Object.entries(previousFileHashes)){const filePath=resolveManagedFilePath(dir,path);if(!existsSync(filePath)){throw CliErrors.validation(`Local Skill files have unpushed edits: ${dir}`,`Managed file was removed locally: ${path}`)}const stat=lstatSync(filePath);if(!stat.isFile()){throw CliErrors.validation(`Local Skill files have unpushed edits: ${dir}`,`Managed file is no longer a regular file: ${path}`)}const currentHash=bufferSha256(readFileSync(filePath));if(currentHash!==expectedHash){throw CliErrors.validation(`Local Skill files have unpushed edits: ${dir}. Changed file: ${path}`,`Push the directory first, then rerun skill install. Changed file: ${path}`)}}}else{
|
|
8
|
+
const skillMdPath=resolve(dir,SKILL_FILE);if(existsSync(skillMdPath)&&metadata.contentHash){const currentHash=contentHash(readFileSync(skillMdPath,"utf8"));if(currentHash!==metadata.contentHash){throw CliErrors.validation(`Local SKILL.md has unpushed edits: ${skillMdPath}`,"Push the directory first, then rerun skill install.")}}}for(const nextFile of normalizeLocalFiles(nextFiles)){if(previousFileHashes?.[nextFile.path])continue;if(!previousFileHashes&&nextFile.path===SKILL_FILE)continue;const filePath=resolveManagedFilePath(dir,nextFile.path);if(!existsSync(filePath))continue;const stat=lstatSync(filePath);if(!stat.isFile()){throw CliErrors.validation(`Local Skill files have unpushed edits: ${dir}`,`Remote Skill would overwrite a local non-file path: ${nextFile.path}`)}const currentHash=bufferSha256(readFileSync(filePath));if(currentHash!==fileHash(nextFile)){
|
|
9
|
+
throw CliErrors.validation(`Local Skill files have unpushed edits: ${dir}`,`Remote Skill would overwrite an unmanaged local file: ${nextFile.path}`)}}}function materializeFiles(dir,files){for(const file of normalizeLocalFiles(files)){const filePath=resolveManagedFilePath(dir,file.path);mkdirSync(dirname(filePath),{recursive:true,mode:448});writeBytesAtomic(filePath,fileContent(file),384)}}function removeStaleManagedFiles(dir,previousFileHashes,nextFiles){if(!previousFileHashes)return;const nextPaths=new Set(normalizeLocalFiles(nextFiles).map(file=>file.path));for(const previousPath of Object.keys(previousFileHashes)){if(nextPaths.has(previousPath))continue;const filePath=resolveManagedFilePath(dir,previousPath);if(existsSync(filePath)&&lstatSync(filePath).isFile()){rmSync(filePath,{force:true})}}}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{existsSync,readFileSync}from"node:fs";import{CliErrors}from"../../errors.js";import{METADATA_FILE}from"./constants.js";import{bufferSha256,fileHash,fileTreeHash}from"./hashing.js";import{fileContent,normalizeLocalFiles}from"./local-files.js";import{buildSkillPackage,localFilesToManifestFiles}from"./zip-package.js";export function buildMetadata(skill,scope,appCode,hash,pulledAt,files,packageBytes){const normalizedFiles=files?normalizeLocalFiles(files):[];const localPackage=!packageBytes&&normalizedFiles.length>0?buildSkillPackage(normalizedFiles):undefined;const packageSha256=packageBytes?bufferSha256(packageBytes):localPackage?.manifest.zipSha256;const packageSize=packageBytes?.length??localPackage?.manifest.zipSize;const fileHashes=normalizedFiles.length>0?Object.fromEntries(normalizedFiles.map(file=>[file.path,fileHash(file)])):undefined;return{schemaVersion:normalizedFiles.length>0?2:1,id:skill.id,appCode:appCode,skillCode:requireSkillCode(skill),skillName:skill.skillName,
|
|
2
|
+
description:skill.description,example:skill.example,scope:scope,readonly:scope!=="personal"||skill.readonly===true,tenantCode:skill.tenantCode,userId:skill.userId,version:skill.version,status:skill.status,tags:Array.isArray(skill.tags)?skill.tags:[],hasUpstreamUpdate:skill.hasUpstreamUpdate,forkedFromSkillId:skill.forkedFromSkillId,forkedFromVersion:skill.forkedFromVersion,sourceSessionId:skill.sourceSessionId,contentHash:hash,fileHashes:fileHashes,treeHash:normalizedFiles.length>0?fileTreeHash(localFilesToManifestFiles(normalizedFiles)):undefined,ossPath:remoteManifestOssPath(skill.files),zipSha256:packageSha256,zipSize:packageSize,files:normalizedFiles.length>0?normalizedFiles.map(file=>({path:file.path,hash:fileHash(file),size:fileContent(file).length})):undefined,pulledAt:pulledAt??(new Date).toISOString()}}export function requireSkillCode(skill){const skillCode=skill.skillCode?.trim();if(!skillCode){throw CliErrors.validation("Runtime Skill is missing skillCode.")}return skillCode
|
|
3
|
+
}export function readMetadataIfPresent(path){if(!existsSync(path))return undefined;try{const data=JSON.parse(readFileSync(path,"utf8"));return data}catch{throw CliErrors.validation(`Invalid ${METADATA_FILE}: ${path}`)}}function remoteManifestOssPath(manifest){if(!manifest||typeof manifest!=="object"||Array.isArray(manifest)){return undefined}const value=manifest.ossPath;return typeof value==="string"&&value.trim()?value.trim():undefined}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{existsSync}from"node:fs";import{homedir}from"node:os";import{resolve}from"node:path";import{fingerprintAccessKey}from"../../commands/app/cache.js";import{PRODUCT_CONFIG,productEnv}from"../../constant/product.js";import{CliErrors}from"../../errors.js";export function resolveSkillSyncPaths(options={}){const home=options.homeDir??homedir();const cacheRoot=resolve(home,PRODUCT_CONFIG.homeDirName,"cache");const envAgentsSkillsDir=trimmedEnv("SKILL_ROOT");const envClaudeSkillsDir=trimmedEnv("CLAUDE_SKILL_ROOT");const workbuddyHome=resolve(home,".workbuddy");const workbuddySkillsDir=options.workbuddySkillsDir??(existsSync(workbuddyHome)?resolve(workbuddyHome,"skills"):undefined);return{homeDir:home,cacheRoot:cacheRoot,managedRoot:resolve(home,PRODUCT_CONFIG.homeDirName),agentsSkillsDir:options.agentsSkillsDir??envAgentsSkillsDir??resolve(home,".agents","skills"),claudeSkillsDir:options.claudeSkillsDir??envClaudeSkillsDir??resolve(home,".claude","skills"),
|
|
2
|
+
workbuddySkillsDir:workbuddySkillsDir}}export function runtimeAgentSkillRoots(paths){return[paths.agentsSkillsDir,paths.claudeSkillsDir,paths.workbuddySkillsDir].filter(path=>Boolean(path))}export function getRuntimeSkillCacheRoot(env,accessKey,options={}){const paths=resolveSkillSyncPaths(options);return resolve(paths.cacheRoot,env,fingerprintAccessKey(accessKey),"skills")}export function getRuntimeSkillDir(env,accessKey,appCode,scope,skillCode,options={}){return resolve(getRuntimeSkillCacheRoot(env,accessKey,options),safePathSegment(appCode,"appCode"),scope,safePathSegment(skillCode,"skillCode"))}export function safePathSegment(value,label="path segment"){if(!value||value.includes("/")||value.includes("\\")||value.includes("..")){throw CliErrors.validation(`Unsafe ${label} for local path: ${value}`)}return value}function trimmedEnv(name){const value=productEnv(name)?.trim();return value?value:undefined}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
(function(_0x47f9e0,_0x58cffa){const _0x17ecb7=a164_0x500e,_0xe4fff5=_0x47f9e0();while(!![]){try{const _0x1dbfc1=-parseInt(_0x17ecb7(0x1b3))/0x1+-parseInt(_0x17ecb7(0x1de))/0x2+-parseInt(_0x17ecb7(0x1c0))/0x3*(-parseInt(_0x17ecb7(0x1dc))/0x4)+parseInt(_0x17ecb7(0x1ab))/0x5+parseInt(_0x17ecb7(0x1bc))/0x6*(parseInt(_0x17ecb7(0x1a1))/0x7)+parseInt(_0x17ecb7(0x1be))/0x8*(parseInt(_0x17ecb7(0x1ca))/0x9)+-parseInt(_0x17ecb7(0x1bf))/0xa*(parseInt(_0x17ecb7(0x1a9))/0xb);if(_0x1dbfc1===_0x58cffa)break;else _0xe4fff5['push'](_0xe4fff5['shift']());}catch(_0x3d75f0){_0xe4fff5['push'](_0xe4fff5['shift']());}}}(a164_0x4c83,0x2bac3));import{existsSync,lstatSync,readFileSync,realpathSync}from'node:fs';import{basename,resolve}from'node:path';import{parse as a164_0x168c7f}from'yaml';import{CliErrors}from'../../errors.js';import{METADATA_FILE,SKILL_FILE}from'./constants.js';import{writeJsonAtomic}from'./fs-utils.js';import{contentHash}from'./hashing.js';import{fileText,normalizeLocalFiles,scanSkillDirectory}from'./local-files.js';import{buildMetadata,readMetadataIfPresent}from'./metadata.js';import{buildSkillPackage,tryNormalizePackageManifest}from'./zip-package.js';export function resolvePushDirectoryIdentity(_0xb499d5,_0x59ba90,_0x58e1ed={}){const _0x20da8f=a164_0x500e,_0x28c60c=resolvePushDirectoryRoot(_0xb499d5),_0x3a7244=readPushMetadataIfPresent(resolve(_0x28c60c,METADATA_FILE),{'ignoreInvalidMetadata':_0x58e1ed[_0x20da8f(0x1cf)]});if(_0x3a7244?.[_0x20da8f(0x19e)]&&_0x3a7244[_0x20da8f(0x19e)]!==_0x59ba90&&!_0x58e1ed[_0x20da8f(0x1d1)]&&!_0x58e1ed['ignoreMetadataAppCodeMismatch'])throw CliErrors['validation'](_0x20da8f(0x1a8)+_0x3a7244[_0x20da8f(0x19e)]+_0x20da8f(0x1cc)+_0x59ba90+'\x22.');const _0x12c5c0=resolvePushSkillCode(_0x28c60c,_0x59ba90,_0x3a7244,_0x58e1ed);if(!_0x12c5c0)throw CliErrors[_0x20da8f(0x1ae)](_0x20da8f(0x1ad)+SKILL_FILE+',\x20'+METADATA_FILE+_0x20da8f(0x1b2));return{'dir':_0x28c60c,'skillCode':_0x12c5c0,'metadata':_0x3a7244};}export function readPushDirectory(_0x3e9f10,_0x4258df,_0x22fcb3={}){const _0x38ecda=a164_0x500e,_0x1b269c=resolvePushDirectoryIdentity(_0x3e9f10,_0x4258df,_0x22fcb3),_0x250301=_0x1b269c[_0x38ecda(0x1e4)],_0x146855=resolve(_0x250301,SKILL_FILE);if(!existsSync(_0x146855)||!lstatSync(_0x146855)[_0x38ecda(0x1c2)]())throw CliErrors[_0x38ecda(0x1ae)](_0x38ecda(0x1e3)+SKILL_FILE+':\x20'+_0x146855);const _0x20192e=_0x1b269c[_0x38ecda(0x1a0)],_0x5c78b2=_0x22fcb3['targetScope']??'personal';if(!_0x22fcb3[_0x38ecda(0x1a5)]&&_0x20192e?.[_0x38ecda(0x1a4)]===_0x38ecda(0x1e1))throw CliErrors[_0x38ecda(0x1ae)](_0x38ecda(0x1ac)+METADATA_FILE+_0x38ecda(0x1c8)+_0x20192e[_0x38ecda(0x1a4)]+'\x22.');if(!_0x22fcb3['ignoreMetadataScope']&&_0x5c78b2===_0x38ecda(0x1aa)&&_0x20192e?.['scope']&&_0x20192e[_0x38ecda(0x1a4)]!==_0x38ecda(0x1aa))throw CliErrors[_0x38ecda(0x1ae)]('Only\x20personal\x20Skills\x20can\x20be\x20pushed;\x20'+METADATA_FILE+_0x38ecda(0x1c8)+_0x20192e[_0x38ecda(0x1a4)]+'\x22.',_0x38ecda(0x1a2)+_0x250301+_0x38ecda(0x1a3));const _0x40bc15=scanSkillDirectory(_0x250301,{'excludedFilePaths':_0x22fcb3[_0x38ecda(0x1b0)]}),_0x277957=buildSkillPackage(_0x40bc15),_0x4ae0ae=readFileSync(_0x146855,_0x38ecda(0x1b5)),_0xe9c560=_0x1b269c[_0x38ecda(0x1da)],_0x111ceb=_0x22fcb3[_0x38ecda(0x1d6)]?undefined:_0x20192e,_0x541b9c=readSkillDisplayName(_0x4ae0ae);return{'skillCode':_0xe9c560,'metadata':_0x20192e,'frontmatterDisplayName':_0x541b9c,'input':{'skillCode':_0xe9c560,'skillName':_0x541b9c??_0x111ceb?.[_0x38ecda(0x1bb)],'description':_0x111ceb?.[_0x38ecda(0x1a6)],'content':_0x4ae0ae,'files':_0x277957[_0x38ecda(0x1c6)],'packageBase64':_0x277957[_0x38ecda(0x1c1)],'tags':_0x111ceb?.[_0x38ecda(0x1b6)],'version':_0x111ceb?.['version'],'sourceSessionId':_0x111ceb?.[_0x38ecda(0x1db)]}};}export function refreshPushDirectoryMetadataFromRemote(_0x2d7a4e,_0xf61c4c,_0x4ae41f,_0x287aab={}){const _0x313ce3=a164_0x500e,_0x28241f=resolvePushDirectoryRoot(_0x2d7a4e),_0x38c4e5=readPushMetadataIfPresent(resolve(_0x28241f,METADATA_FILE),{'ignoreInvalidMetadata':!![]}),_0x2b1c6b=requireRemoteScope(_0xf61c4c),_0x257028=readLocalSkillContent(_0x28241f),_0xa61ed8={..._0xf61c4c,'appCode':_0xf61c4c[_0x313ce3(0x19e)]??_0x4ae41f,'skillName':_0xf61c4c[_0x313ce3(0x1bb)]??_0x38c4e5?.[_0x313ce3(0x1bb)],'description':_0xf61c4c[_0x313ce3(0x1a6)]??_0x38c4e5?.[_0x313ce3(0x1a6)],'example':_0xf61c4c[_0x313ce3(0x1d5)]??_0x38c4e5?.[_0x313ce3(0x1d5)],'tags':Array[_0x313ce3(0x1c4)](_0xf61c4c['tags'])?_0xf61c4c[_0x313ce3(0x1b6)]:_0x38c4e5?.[_0x313ce3(0x1b6)],'sourceSessionId':_0xf61c4c['sourceSessionId']??_0x38c4e5?.[_0x313ce3(0x1db)],'content':_0xf61c4c[_0x313ce3(0x1d0)]??_0x257028},_0x585379=buildMetadata(_0xa61ed8,_0x2b1c6b,_0x4ae41f,contentHash(_0x257028),_0x287aab['refreshedAt']);writeJsonAtomic(resolve(_0x28241f,METADATA_FILE),_0x585379);}export function recordPushedRuntimeSkill(_0x2c9d61,_0x3c2230,_0x2266de,_0x27ce7e={}){const _0x17ca01=a164_0x500e,_0x31c38f=resolvePushDirectoryRoot(_0x2c9d61),_0x4c5629=scanSkillDirectory(_0x31c38f),_0x47853d=_0x4c5629[_0x17ca01(0x1c7)](_0x4a1e73=>_0x4a1e73[_0x17ca01(0x1af)]===SKILL_FILE),_0x27f9f0=_0x47853d?fileText(_0x47853d):'',_0x4ce173=tryNormalizePackageManifest(_0x3c2230['files']),_0x3f62d7={..._0x3c2230,'content':_0x3c2230[_0x17ca01(0x1d0)]??_0x27f9f0,'files':_0x4ce173},_0x2d391c=_0x4ce173?normalizeLocalFiles(_0x4c5629)[_0x17ca01(0x1d8)](_0x525d68=>_0x4ce173['files'][_0x17ca01(0x19f)](_0x24778d=>_0x24778d[_0x17ca01(0x1af)]===_0x525d68['path'])):undefined,_0x1bec0e=buildMetadata(_0x3f62d7,_0x27ce7e[_0x17ca01(0x1a4)]??_0x17ca01(0x1aa),_0x2266de,contentHash(_0x3f62d7[_0x17ca01(0x1d0)]??''),_0x27ce7e[_0x17ca01(0x1c9)],_0x2d391c);writeJsonAtomic(resolve(_0x31c38f,METADATA_FILE),_0x1bec0e);}export function deriveSkillCodeFromDirectory(_0x261306,_0x49ee1c){const _0xbb051f=a164_0x500e,_0x3c0d02=basename(resolve(_0x261306)),_0x45d117=_0x49ee1c+'--';return _0x3c0d02[_0xbb051f(0x1df)](_0x45d117)?_0x3c0d02[_0xbb051f(0x1bd)](_0x45d117[_0xbb051f(0x1e2)]):_0x3c0d02;}function resolvePushSkillCode(_0x188265,_0x10388e,_0x60746f,_0x3539ca){const _0x4bd51a=a164_0x500e,_0x63ff10=deriveSkillCodeFromSkillFile(_0x188265)||deriveSkillCodeFromDirectory(_0x188265,_0x10388e);if(_0x3539ca[_0x4bd51a(0x1d3)])return _0x63ff10;return _0x60746f?.[_0x4bd51a(0x1da)]?.[_0x4bd51a(0x1b9)]()||_0x63ff10;}function deriveSkillCodeFromSkillFile(_0x21d5b7){const _0x57d971=a164_0x500e,_0x300f99=resolve(_0x21d5b7,SKILL_FILE);if(!existsSync(_0x300f99)||!lstatSync(_0x300f99)[_0x57d971(0x1c2)]())return undefined;const _0x94ca05=readFileSync(_0x300f99,_0x57d971(0x1b5)),_0x4f6e1e=_0x94ca05['match'](/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);if(!_0x4f6e1e)return undefined;const _0x5819ba=parseFrontmatterObject(_0x4f6e1e[0x1]??''),_0x51b665=scalarToString(_0x5819ba?.[_0x57d971(0x1dd)]);return _0x51b665?slugifySkillName(_0x51b665):undefined;}function readSkillDisplayName(_0x5b4fbd){const _0x5697b1=a164_0x500e,_0x159032=_0x5b4fbd[_0x5697b1(0x1d2)](/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);if(!_0x159032)return undefined;const _0xc97866=parseFrontmatterObject(_0x159032[0x1]??'');return scalarToString(_0xc97866?.[_0x5697b1(0x1cb)]);}function slugifySkillName(_0x1ea801){const _0x3df131=a164_0x500e,_0x1f052e=_0x1ea801['trim']()[_0x3df131(0x1e0)]()[_0x3df131(0x1d7)](/[^\p{L}\p{N}\p{So}]+/gu,'-')['replace'](/^-+/,'')[_0x3df131(0x1d7)](/-+$/,'')['replace'](/-{2,}/g,'-');if(!_0x1f052e)throw CliErrors[_0x3df131(0x1ae)](_0x3df131(0x1d9)+SKILL_FILE+'\x20name\x20for\x20SkillHub\x20slug\x20generation.');return _0x1f052e;}function parseFrontmatterObject(_0x4b25f3){const _0x3f8e97=a164_0x500e;try{const _0x49b69b=a164_0x168c7f(_0x4b25f3);return _0x49b69b&&typeof _0x49b69b===_0x3f8e97(0x1ba)&&!Array[_0x3f8e97(0x1c4)](_0x49b69b)?_0x49b69b:undefined;}catch{return undefined;}}function scalarToString(_0x3c72ae){const _0x2c7576=a164_0x500e;if(typeof _0x3c72ae===_0x2c7576(0x1d4))return _0x3c72ae[_0x2c7576(0x1b9)]();if(typeof _0x3c72ae===_0x2c7576(0x1b8)||typeof _0x3c72ae===_0x2c7576(0x1a7))return String(_0x3c72ae);return undefined;}function a164_0x500e(_0x28cc29,_0x46c28b){_0x28cc29=_0x28cc29-0x19e;const _0x4c8388=a164_0x4c83();let _0x500e09=_0x4c8388[_0x28cc29];return _0x500e09;}function resolvePushDirectoryRoot(_0x569c24){const _0x32cc7a=a164_0x500e,_0x11889b=resolve(_0x569c24);if(!existsSync(_0x11889b))throw CliErrors[_0x32cc7a(0x1ae)](_0x32cc7a(0x1b1)+_0x569c24);const _0x9e2d26=lstatSync(_0x11889b);if(_0x9e2d26['isDirectory']())return _0x11889b;if(_0x9e2d26[_0x32cc7a(0x1ce)]()){const _0x2ab77f=realpathSync(_0x11889b);if(lstatSync(_0x2ab77f)[_0x32cc7a(0x1c5)]())return _0x2ab77f;}throw CliErrors['validation'](_0x32cc7a(0x1b1)+_0x569c24);}function requireRemoteScope(_0x15cf80){const _0xc1ab00=a164_0x500e;if(_0x15cf80[_0xc1ab00(0x1a4)]==='personal'||_0x15cf80[_0xc1ab00(0x1a4)]==='company'||_0x15cf80[_0xc1ab00(0x1a4)]==='builtin')return _0x15cf80[_0xc1ab00(0x1a4)];throw CliErrors['validation'](_0xc1ab00(0x1cd)+(_0x15cf80[_0xc1ab00(0x1da)]||_0xc1ab00(0x1b4))+_0xc1ab00(0x1c3)+(_0x15cf80[_0xc1ab00(0x1a4)]??_0xc1ab00(0x1b7))+'\x22.');}function readLocalSkillContent(_0x401a4c){const _0x5e490b=a164_0x500e,_0x4176e4=resolve(_0x401a4c,SKILL_FILE);return existsSync(_0x4176e4)&&lstatSync(_0x4176e4)[_0x5e490b(0x1c2)]()?readFileSync(_0x4176e4,_0x5e490b(0x1b5)):'';}function readPushMetadataIfPresent(_0x2234c2,_0x383751={}){const _0x50a6c5=a164_0x500e;try{return readMetadataIfPresent(_0x2234c2);}catch(_0x2dabd2){if(_0x383751[_0x50a6c5(0x1cf)])return undefined;throw _0x2dabd2;}}function a164_0x4c83(){const _0x32a492=['displayName','\x22\x20does\x20not\x20match\x20current\x20appCode\x20\x22','Remote\x20Skill\x20','isSymbolicLink','ignoreInvalidMetadata','content','allowAppCodeRetarget','match','ignoreMetadataSkillCode','string','example','ignoreMetadataForPayload','replace','filter','Invalid\x20','skillCode','sourceSessionId','205652HRvHai','name','530276FvWalY','startsWith','toLowerCase','builtin','length','Missing\x20','dir','appCode','some','metadata','1543878ZeHfen','Use\x20lovrabet\x20skill\x20push\x20--scope\x20company\x20--dir\x20','\x20to\x20submit\x20company\x20Skills\x20for\x20review.','scope','ignoreMetadataScope','description','boolean','Skill\x20metadata\x20appCode\x20\x22','473539zOSdEj','personal','1532205rMptKQ','Builtin\x20Skills\x20cannot\x20be\x20pushed;\x20','Unable\x20to\x20resolve\x20skillCode\x20from\x20','validation','path','excludedFilePaths','Skill\x20directory\x20not\x20found:\x20',',\x20or\x20directory\x20name.','61382ySRLkI','(unknown)','utf8','tags','unknown','number','trim','object','skillName','6tplyQg','slice','5352phxYeq','130JJvBqp','15BcaQLx','packageBase64','isFile','\x20has\x20unsupported\x20scope\x20\x22','isArray','isDirectory','manifest','find','\x20has\x20scope=\x22','pushedAt','3780nZUgZT'];a164_0x4c83=function(){return _0x32a492;};return a164_0x4c83();}
|
|
1
|
+
import{existsSync,lstatSync,readFileSync,realpathSync}from"node:fs";import{basename,resolve}from"node:path";import{parse as parseYaml}from"yaml";import{CliErrors}from"../../errors.js";import{METADATA_FILE,SKILL_FILE}from"./constants.js";import{writeJsonAtomic}from"./fs-utils.js";import{contentHash}from"./hashing.js";import{fileText,normalizeLocalFiles,scanSkillDirectory}from"./local-files.js";import{buildMetadata,readMetadataIfPresent}from"./metadata.js";import{buildSkillPackage,tryNormalizePackageManifest}from"./zip-package.js";export function resolvePushDirectoryIdentity(dir,appCode,options={}){const resolvedDir=resolvePushDirectoryRoot(dir);const metadata=readPushMetadataIfPresent(resolve(resolvedDir,METADATA_FILE),{ignoreInvalidMetadata:options.ignoreInvalidMetadata});if(metadata?.appCode&&metadata.appCode!==appCode&&!options.allowAppCodeRetarget&&!options.ignoreMetadataAppCodeMismatch){
|
|
2
|
+
throw CliErrors.validation(`Skill metadata appCode "${metadata.appCode}" does not match current appCode "${appCode}".`)}const skillCode=resolvePushSkillCode(resolvedDir,appCode,metadata,options);if(!skillCode){throw CliErrors.validation(`Unable to resolve skillCode from ${SKILL_FILE}, ${METADATA_FILE}, or directory name.`)}return{dir:resolvedDir,skillCode:skillCode,metadata:metadata}}export function readPushDirectory(dir,appCode,options={}){const identity=resolvePushDirectoryIdentity(dir,appCode,options);const resolvedDir=identity.dir;const skillMdPath=resolve(resolvedDir,SKILL_FILE);if(!existsSync(skillMdPath)||!lstatSync(skillMdPath).isFile()){throw CliErrors.validation(`Missing ${SKILL_FILE}: ${skillMdPath}`)}const metadata=identity.metadata;const targetScope=options.targetScope??"personal";if(!options.ignoreMetadataScope&&metadata?.scope==="builtin"){throw CliErrors.validation(`Builtin Skills cannot be pushed; ${METADATA_FILE} has scope="${metadata.scope}".`)}
|
|
3
|
+
if(!options.ignoreMetadataScope&&targetScope==="personal"&&metadata?.scope&&metadata.scope!=="personal"){throw CliErrors.validation(`Only personal Skills can be pushed; ${METADATA_FILE} has scope="${metadata.scope}".`,`Use lovrabet skill push --scope company --dir ${resolvedDir} to submit company Skills for review.`)}const files=scanSkillDirectory(resolvedDir,{excludedFilePaths:options.excludedFilePaths});const skillPackage=buildSkillPackage(files);const content=readFileSync(skillMdPath,"utf8");const skillCode=identity.skillCode;const metadataForPayload=options.ignoreMetadataForPayload?undefined:metadata;const displayName=readSkillDisplayName(content);return{skillCode:skillCode,metadata:metadata,frontmatterDisplayName:displayName,input:{skillCode:skillCode,skillName:displayName??metadataForPayload?.skillName,description:metadataForPayload?.description,content:content,files:skillPackage.manifest,packageBase64:skillPackage.packageBase64,tags:metadataForPayload?.tags,
|
|
4
|
+
version:metadataForPayload?.version,sourceSessionId:metadataForPayload?.sourceSessionId}}}export function refreshPushDirectoryMetadataFromRemote(dir,remote,appCode,options={}){const resolvedDir=resolvePushDirectoryRoot(dir);const metadata=readPushMetadataIfPresent(resolve(resolvedDir,METADATA_FILE),{ignoreInvalidMetadata:true});const scope=requireRemoteScope(remote);const content=readLocalSkillContent(resolvedDir);const mergedRemote={...remote,appCode:remote.appCode??appCode,skillName:remote.skillName??metadata?.skillName,description:remote.description??metadata?.description,example:remote.example??metadata?.example,tags:Array.isArray(remote.tags)?remote.tags:metadata?.tags,sourceSessionId:remote.sourceSessionId??metadata?.sourceSessionId,content:remote.content??content};const refreshed=buildMetadata(mergedRemote,scope,appCode,contentHash(content),options.refreshedAt);writeJsonAtomic(resolve(resolvedDir,METADATA_FILE),refreshed)}
|
|
5
|
+
export function recordPushedRuntimeSkill(dir,saved,appCode,options={}){const resolvedDir=resolvePushDirectoryRoot(dir);const files=scanSkillDirectory(resolvedDir);const localSkillFile=files.find(file=>file.path===SKILL_FILE);const content=localSkillFile?fileText(localSkillFile):"";const savedManifest=tryNormalizePackageManifest(saved.files);const normalizedSaved={...saved,content:saved.content??content,files:savedManifest};const metadataFiles=savedManifest?normalizeLocalFiles(files).filter(file=>savedManifest.files.some(item=>item.path===file.path)):undefined;const metadata=buildMetadata(normalizedSaved,options.scope??"personal",appCode,contentHash(normalizedSaved.content??""),options.pushedAt,metadataFiles);writeJsonAtomic(resolve(resolvedDir,METADATA_FILE),metadata)}export function deriveSkillCodeFromDirectory(dir,appCode){const name=basename(resolve(dir));const prefix=`${appCode}--`;return name.startsWith(prefix)?name.slice(prefix.length):name}
|
|
6
|
+
function resolvePushSkillCode(dir,appCode,metadata,options){const localSkillCode=deriveSkillCodeFromSkillFile(dir)||deriveSkillCodeFromDirectory(dir,appCode);if(options.ignoreMetadataSkillCode){return localSkillCode}return metadata?.skillCode?.trim()||localSkillCode}function deriveSkillCodeFromSkillFile(dir){const skillMdPath=resolve(dir,SKILL_FILE);if(!existsSync(skillMdPath)||!lstatSync(skillMdPath).isFile()){return undefined}const content=readFileSync(skillMdPath,"utf8");const match=content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);if(!match){return undefined}const frontmatter=parseFrontmatterObject(match[1]??"");const name=scalarToString(frontmatter?.name);return name?slugifySkillName(name):undefined}function readSkillDisplayName(content){const match=content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);if(!match){return undefined}const frontmatter=parseFrontmatterObject(match[1]??"");return scalarToString(frontmatter?.displayName)}function slugifySkillName(raw){
|
|
7
|
+
const slug=raw.trim().toLowerCase().replace(/[^\p{L}\p{N}\p{So}]+/gu,"-").replace(/^-+/,"").replace(/-+$/,"").replace(/-{2,}/g,"-");if(!slug){throw CliErrors.validation(`Invalid ${SKILL_FILE} name for SkillHub slug generation.`)}return slug}function parseFrontmatterObject(yaml){try{const value=parseYaml(yaml);return value&&typeof value==="object"&&!Array.isArray(value)?value:undefined}catch{return undefined}}function scalarToString(value){if(typeof value==="string")return value.trim();if(typeof value==="number"||typeof value==="boolean")return String(value);return undefined}function resolvePushDirectoryRoot(dir){const root=resolve(dir);if(!existsSync(root)){throw CliErrors.validation(`Skill directory not found: ${dir}`)}const stat=lstatSync(root);if(stat.isDirectory()){return root}if(stat.isSymbolicLink()){const realRoot=realpathSync(root);if(lstatSync(realRoot).isDirectory()){return realRoot}}throw CliErrors.validation(`Skill directory not found: ${dir}`)}
|
|
8
|
+
function requireRemoteScope(skill){if(skill.scope==="personal"||skill.scope==="company"||skill.scope==="builtin"){return skill.scope}throw CliErrors.validation(`Remote Skill ${skill.skillCode||"(unknown)"} has unsupported scope "${skill.scope??"unknown"}".`)}function readLocalSkillContent(dir){const skillMdPath=resolve(dir,SKILL_FILE);return existsSync(skillMdPath)&&lstatSync(skillMdPath).isFile()?readFileSync(skillMdPath,"utf8"):""}function readPushMetadataIfPresent(path,options={}){try{return readMetadataIfPresent(path)}catch(error){if(options.ignoreInvalidMetadata){return undefined}throw error}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";export function normalizeRuntimeSkillScopes(scopes){const source=scopes&&scopes.length>0?scopes:["personal","company","builtin"];const normalized=[];for(const scope of source){if(!isRuntimeSkillScope(scope)){throw CliErrors.validation(`Unsupported runtime Skill scope: ${scope}`)}if(!normalized.includes(scope)){normalized.push(scope)}}return normalized}export function isRuntimeSkillScope(value){return value==="personal"||value==="company"||value==="builtin"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export{};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{unzipSync,zipSync}from"fflate";import{CliErrors}from"../../errors.js";import{compareSkillFiles,fileContent,normalizeLocalFiles,normalizeSkillRelativePath}from"./local-files.js";const ZIP_MTIME=new Date("1980-01-01T00:00:00.000Z");export function createDeterministicZipPackage(files){const entries={};for(const file of normalizeLocalFiles(files)){entries[file.path]=fileContent(file)}return Buffer.from(zipSync(entries,{level:0,mtime:ZIP_MTIME}))}export function parseZipPackage(packageBytes){if(packageBytes.length<22){throw CliErrors.validation("Runtime Skill package is not a valid zip file.")}let unzipped;try{unzipped=unzipSync(packageBytes,{filter(file){const path=normalizeSkillRelativePath(file.name);if(path.endsWith("/")){throw CliErrors.validation(`Runtime Skill package contains directory entry: ${path}`)}return true}})}catch(error){if(isRuntimeSkillValidationError(error)){throw error}throw CliErrors.validation("Runtime Skill package is not a valid zip file.")}
|
|
2
|
+
return Object.entries(unzipped).map(([path,bytes])=>({path:normalizeSkillRelativePath(path),bytes:Buffer.from(bytes)})).sort(compareSkillFiles)}function isRuntimeSkillValidationError(error){return typeof error==="object"&&error!==null&&"code"in error&&error.code==="validation_error"}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";import{SKILL_FILE}from"./constants.js";import{bufferSha256,fileHash,fileTreeHash}from"./hashing.js";import{fileContent,isSha256Hex,normalizeLocalFiles,normalizeManifestFiles}from"./local-files.js";import{createDeterministicZipPackage,parseZipPackage}from"./zip-codec.js";export function buildSkillPackage(files){const normalizedFiles=normalizeLocalFiles(files);if(!normalizedFiles.some(file=>file.path===SKILL_FILE)){throw CliErrors.validation(`Missing ${SKILL_FILE} in Skill file package.`)}const manifestFiles=localFilesToManifestFiles(normalizedFiles);const packageBytes=createDeterministicZipPackage(normalizedFiles);return{manifest:{schemaVersion:2,treeSha256:fileTreeHash(manifestFiles),zipSha256:bufferSha256(packageBytes),zipSize:packageBytes.length,files:manifestFiles},packageBytes:packageBytes,packageBase64:packageBytes.toString("base64")}}export function verifyRuntimeSkillPackage(manifest,packageBytes){
|
|
2
|
+
const normalizedManifest=normalizePackageManifest(manifest,{requireOssPath:false});if(!normalizedManifest){throw CliErrors.validation("Runtime Skill package manifest is missing.")}return extractAndVerifyPackage(normalizedManifest,packageBytes)}export function verifyRuntimeSkillBundle(manifest,packageBytes){const normalizedManifest=normalizePackageManifest(manifest,{requireOssPath:false});if(!normalizedManifest){throw CliErrors.validation("Runtime Skill package manifest is missing.")}return extractAndVerifyPackageFiles(normalizedManifest,packageBytes)}export function tryNormalizePackageManifest(manifest){return normalizePackageManifest(manifest,{requireOssPath:false})}export function requirePackageBytes(skillCode,packageBytes){if(!packageBytes||packageBytes.length===0){throw CliErrors.validation(`Runtime Skill package is required for Skill install: ${skillCode}`)}return packageBytes}export function extractDownloadedPackage(packageBytes){
|
|
3
|
+
const extracted=parseZipPackage(packageBytes).map(file=>({path:file.path,bytes:file.bytes}));if(!extracted.some(file=>file.path===SKILL_FILE)){throw CliErrors.validation(`Runtime Skill package is missing ${SKILL_FILE}.`)}return normalizeLocalFiles(extracted)}export function localFilesToManifestFiles(files){return normalizeLocalFiles(files).map(file=>({path:file.path,sha256:fileHash(file),size:fileContent(file).length}))}function normalizePackageManifest(manifest,options){if(!manifest||typeof manifest!=="object"||Array.isArray(manifest)){return undefined}const record=manifest;const ossPath=typeof record.ossPath==="string"?record.ossPath.trim():undefined;if(options.requireOssPath&&!ossPath){return undefined}if(!Array.isArray(record.files)||record.files.length===0){return undefined}if(!isSha256Hex(record.treeSha256)){throw CliErrors.validation("Runtime Skill file tree sha256 is invalid.")}if(!isSha256Hex(record.zipSha256)){
|
|
4
|
+
throw CliErrors.validation("Runtime Skill package sha256 is invalid.")}if(!Number.isSafeInteger(record.zipSize)||record.zipSize<0){throw CliErrors.validation("Runtime Skill package size is invalid.")}const files=normalizeManifestFiles(record.files);if(!files.some(file=>file.path===SKILL_FILE)){throw CliErrors.validation(`Runtime Skill manifest is missing ${SKILL_FILE}.`)}const treeSha256=fileTreeHash(files);if(treeSha256!==record.treeSha256.toLowerCase()){throw CliErrors.validation("Runtime Skill file tree sha256 mismatch.")}return{schemaVersion:Number.isSafeInteger(record.schemaVersion)?record.schemaVersion:2,ossPath:ossPath,treeSha256:treeSha256,zipSha256:record.zipSha256.toLowerCase(),zipSize:record.zipSize,files:files}}function extractAndVerifyPackage(manifest,packageBytes){const normalizedManifest=normalizePackageManifest(manifest,{requireOssPath:false});if(!normalizedManifest){throw CliErrors.validation("Runtime Skill package manifest is missing.")}
|
|
5
|
+
if(packageBytes.length!==normalizedManifest.zipSize){throw CliErrors.validation("Runtime Skill package size mismatch.")}const actualZipSha256=bufferSha256(packageBytes);if(actualZipSha256!==normalizedManifest.zipSha256){throw CliErrors.validation("Runtime Skill package sha256 mismatch.")}return extractAndVerifyPackageFiles(normalizedManifest,packageBytes)}function extractAndVerifyPackageFiles(normalizedManifest,packageBytes){const extracted=parseZipPackage(packageBytes);if(extracted.length!==normalizedManifest.files.length){throw CliErrors.validation("Runtime Skill package entry list mismatch.")}const extractedByPath=new Map;for(const file of extracted){if(extractedByPath.has(file.path)){throw CliErrors.validation(`Duplicate Skill package entry: ${file.path}`)}extractedByPath.set(file.path,file)}const materialized=[];for(const expected of normalizedManifest.files){const actual=extractedByPath.get(expected.path);if(!actual){
|
|
6
|
+
throw CliErrors.validation(`Runtime Skill package is missing entry: ${expected.path}`)}if(actual.bytes.length!==expected.size){throw CliErrors.validation(`Runtime Skill package file size mismatch: ${expected.path}`)}const actualSha256=bufferSha256(actual.bytes);if(actualSha256!==expected.sha256){throw CliErrors.validation(`Runtime Skill package file sha256 mismatch: ${expected.path}`)}materialized.push({path:expected.path,bytes:actual.bytes})}return normalizeLocalFiles(materialized)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export{contentHash,fileTreeHash}from"./runtime-skill-sync/hashing.js";export{linkEffectiveRuntimeSkills,linkGlobalRuntimeSkills,pruneStaleRuntimeSkillCache,pruneStaleRuntimeSkillLinks}from"./runtime-skill-sync/links.js";export{resolveRuntimeSkillInstallTarget}from"./runtime-skill-sync/install-target.js";export{listLocalRuntimeSkills}from"./runtime-skill-sync/list-local.js";export{materializeRuntimeSkill,reuseMaterializedRuntimeSkill}from"./runtime-skill-sync/materialize.js";export{readMetadataIfPresent}from"./runtime-skill-sync/metadata.js";export{getRuntimeSkillCacheRoot,getRuntimeSkillDir,resolveSkillSyncPaths,runtimeAgentSkillRoots}from"./runtime-skill-sync/paths.js";export{deriveSkillCodeFromDirectory,readPushDirectory,refreshPushDirectoryMetadataFromRemote,recordPushedRuntimeSkill,resolvePushDirectoryIdentity}from"./runtime-skill-sync/push.js";export{buildSkillPackage,verifyRuntimeSkillBundle,verifyRuntimeSkillPackage}from"./runtime-skill-sync/zip-package.js";
|