@skaile/workspaces 5.10.0 → 5.11.0
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/CHANGELOG.md +49 -0
- package/README.md +12 -0
- package/dist/{asset-feeds-ELEBTNUS.js → asset-feeds-CXGQIDFR.js} +18 -18
- package/dist/{asset-feeds-ELEBTNUS.js.map → asset-feeds-CXGQIDFR.js.map} +1 -1
- package/dist/asset-manager/catalog-deployer.js +7 -7
- package/dist/asset-manager/index.js +13 -13
- package/dist/asset-manager/installer.js +9 -9
- package/dist/asset-manager/renderers.js +8 -8
- package/dist/asset-manager/src/index.d.ts +103 -2
- package/dist/asset-manager/src/index.d.ts.map +1 -1
- package/dist/asset-manager/src/install-instances.d.ts.map +1 -1
- package/dist/asset-manager/src/installer.d.ts +23 -3
- package/dist/asset-manager/src/installer.d.ts.map +1 -1
- package/dist/bridge/drivers/claude-sdk.js +10 -10
- package/dist/bridge/drivers/codex.js +9 -9
- package/dist/bridge/drivers/continue.js +9 -9
- package/dist/bridge/drivers/echo.js +1 -1
- package/dist/bridge/drivers/gemini.js +6 -6
- package/dist/bridge/drivers/goose.js +9 -9
- package/dist/bridge/drivers/omp.js +18 -2
- package/dist/bridge/drivers/omp.js.map +1 -1
- package/dist/bridge/drivers/opencode.js +9 -9
- package/dist/bridge/drivers/qwen.js +6 -6
- package/dist/bridge/index.js +11 -11
- package/dist/bridge/src/drivers/omp.d.ts.map +1 -1
- package/dist/{chunk-3BEY4WK3.js → chunk-2F5AWQX5.js} +77 -11
- package/dist/chunk-2F5AWQX5.js.map +1 -0
- package/dist/{chunk-IJHH4DSW.js → chunk-3SM2DL2T.js} +8 -8
- package/dist/{chunk-IJHH4DSW.js.map → chunk-3SM2DL2T.js.map} +1 -1
- package/dist/{chunk-HJ5MCB3L.js → chunk-47U4GZ4M.js} +2 -2
- package/dist/{chunk-HJ5MCB3L.js.map → chunk-47U4GZ4M.js.map} +1 -1
- package/dist/{chunk-7CR6HT2X.js → chunk-4A4OD24G.js} +9 -9
- package/dist/{chunk-7CR6HT2X.js.map → chunk-4A4OD24G.js.map} +1 -1
- package/dist/{chunk-5QI2JYJC.js → chunk-6O2X3GPW.js} +2 -2
- package/dist/{chunk-5QI2JYJC.js.map → chunk-6O2X3GPW.js.map} +1 -1
- package/dist/{chunk-JZCSNEHK.js → chunk-ALEYHUC5.js} +42 -20
- package/dist/chunk-ALEYHUC5.js.map +1 -0
- package/dist/{chunk-4OV5DSBB.js → chunk-BNMZVPYA.js} +5 -5
- package/dist/chunk-BNMZVPYA.js.map +1 -0
- package/dist/{chunk-SBFW3CJH.js → chunk-CAHB6MHA.js} +5 -5
- package/dist/{chunk-SBFW3CJH.js.map → chunk-CAHB6MHA.js.map} +1 -1
- package/dist/{chunk-4P3KTUZH.js → chunk-CJERAGFY.js} +24 -13
- package/dist/chunk-CJERAGFY.js.map +1 -0
- package/dist/{chunk-MVQ3Q2HM.js → chunk-COH6FQAG.js} +4 -4
- package/dist/{chunk-MVQ3Q2HM.js.map → chunk-COH6FQAG.js.map} +1 -1
- package/dist/{chunk-ZGQTS3Y4.js → chunk-CPWLNZGJ.js} +3 -3
- package/dist/{chunk-ZGQTS3Y4.js.map → chunk-CPWLNZGJ.js.map} +1 -1
- package/dist/{chunk-MGGFBZWA.js → chunk-D3B36CYC.js} +4 -3
- package/dist/chunk-D3B36CYC.js.map +1 -0
- package/dist/{chunk-2JMLDZLP.js → chunk-DZMNFCWB.js} +416 -55
- package/dist/chunk-DZMNFCWB.js.map +1 -0
- package/dist/{chunk-GFCXNFTW.js → chunk-EDYHEMJA.js} +4 -4
- package/dist/{chunk-GFCXNFTW.js.map → chunk-EDYHEMJA.js.map} +1 -1
- package/dist/{chunk-PE36IF2D.js → chunk-FH7W6TJ4.js} +65 -31
- package/dist/chunk-FH7W6TJ4.js.map +1 -0
- package/dist/{chunk-G54USEUP.js → chunk-G4FFOV3N.js} +4 -4
- package/dist/{chunk-G54USEUP.js.map → chunk-G4FFOV3N.js.map} +1 -1
- package/dist/{chunk-HOHUEKES.js → chunk-GCHPUTA3.js} +3 -3
- package/dist/{chunk-HOHUEKES.js.map → chunk-GCHPUTA3.js.map} +1 -1
- package/dist/{chunk-TRSQP3JD.js → chunk-GV4DZ6MT.js} +20 -4
- package/dist/chunk-GV4DZ6MT.js.map +1 -0
- package/dist/{chunk-QG3HOJEK.js → chunk-HCEVNYSH.js} +3 -3
- package/dist/{chunk-QG3HOJEK.js.map → chunk-HCEVNYSH.js.map} +1 -1
- package/dist/{chunk-6HHE63CO.js → chunk-HZXUXHIV.js} +4 -4
- package/dist/{chunk-6HHE63CO.js.map → chunk-HZXUXHIV.js.map} +1 -1
- package/dist/{chunk-FRPBSUFH.js → chunk-IER3KIPH.js} +5 -5
- package/dist/{chunk-FRPBSUFH.js.map → chunk-IER3KIPH.js.map} +1 -1
- package/dist/{chunk-GEWAIQZ5.js → chunk-J4RBUFGM.js} +10 -12
- package/dist/chunk-J4RBUFGM.js.map +1 -0
- package/dist/{chunk-OOWHXOK6.js → chunk-M3B6EIJD.js} +4 -4
- package/dist/{chunk-OOWHXOK6.js.map → chunk-M3B6EIJD.js.map} +1 -1
- package/dist/{chunk-VLXDXRRX.js → chunk-MZG34MBZ.js} +3 -3
- package/dist/{chunk-VLXDXRRX.js.map → chunk-MZG34MBZ.js.map} +1 -1
- package/dist/{chunk-2FMEGSBN.js → chunk-PBBPZYVG.js} +31 -9
- package/dist/chunk-PBBPZYVG.js.map +1 -0
- package/dist/{chunk-CLTHEKHR.js → chunk-PQFHMQHQ.js} +4 -4
- package/dist/{chunk-CLTHEKHR.js.map → chunk-PQFHMQHQ.js.map} +1 -1
- package/dist/{chunk-SX5U422E.js → chunk-QVFAS5IO.js} +3 -3
- package/dist/{chunk-SX5U422E.js.map → chunk-QVFAS5IO.js.map} +1 -1
- package/dist/{chunk-JFXQEVLF.js → chunk-QZNJOHN6.js} +3 -3
- package/dist/{chunk-JFXQEVLF.js.map → chunk-QZNJOHN6.js.map} +1 -1
- package/dist/{chunk-V5TZH4GF.js → chunk-R7NHYEJF.js} +4 -4
- package/dist/{chunk-V5TZH4GF.js.map → chunk-R7NHYEJF.js.map} +1 -1
- package/dist/{chunk-V7PQZOBR.js → chunk-RYYLMBA2.js} +5 -5
- package/dist/{chunk-V7PQZOBR.js.map → chunk-RYYLMBA2.js.map} +1 -1
- package/dist/{chunk-WBYDAL6X.js → chunk-S3O3GKB7.js} +4 -4
- package/dist/{chunk-WBYDAL6X.js.map → chunk-S3O3GKB7.js.map} +1 -1
- package/dist/{chunk-Y34MSWEZ.js → chunk-SBSA3IQA.js} +3 -3
- package/dist/{chunk-Y34MSWEZ.js.map → chunk-SBSA3IQA.js.map} +1 -1
- package/dist/{chunk-Y63UQZ7P.js → chunk-T42WRQ4O.js} +3 -3
- package/dist/{chunk-Y63UQZ7P.js.map → chunk-T42WRQ4O.js.map} +1 -1
- package/dist/{chunk-OBVJ7RPW.js → chunk-T7CTHHG7.js} +3 -3
- package/dist/{chunk-OBVJ7RPW.js.map → chunk-T7CTHHG7.js.map} +1 -1
- package/dist/{chunk-7I5VRVDP.js → chunk-TCHRMVTO.js} +4 -4
- package/dist/{chunk-7I5VRVDP.js.map → chunk-TCHRMVTO.js.map} +1 -1
- package/dist/{chunk-NRDSGLCQ.js → chunk-VLTQGE2E.js} +65 -22
- package/dist/chunk-VLTQGE2E.js.map +1 -0
- package/dist/{chunk-Z2K6BGUR.js → chunk-WSBKB4CJ.js} +13 -13
- package/dist/{chunk-Z2K6BGUR.js.map → chunk-WSBKB4CJ.js.map} +1 -1
- package/dist/{chunk-3MKPZZRE.js → chunk-X77SUM4P.js} +3 -3
- package/dist/{chunk-3MKPZZRE.js.map → chunk-X77SUM4P.js.map} +1 -1
- package/dist/{chunk-XCNK4UE5.js → chunk-XDKH7XSA.js} +5 -5
- package/dist/{chunk-XCNK4UE5.js.map → chunk-XDKH7XSA.js.map} +1 -1
- package/dist/{chunk-TH4CTXHX.js → chunk-XUSALIEI.js} +6 -6
- package/dist/{chunk-TH4CTXHX.js.map → chunk-XUSALIEI.js.map} +1 -1
- package/dist/{chunk-3KHYGOEY.js → chunk-Y3HTGHJC.js} +3 -3
- package/dist/{chunk-3KHYGOEY.js.map → chunk-Y3HTGHJC.js.map} +1 -1
- package/dist/{chunk-YBQONMH2.js → chunk-YOH2L76X.js} +90 -50
- package/dist/chunk-YOH2L76X.js.map +1 -0
- package/dist/{chunk-32XKCNCL.js → chunk-ZCAJZ4B2.js} +3 -3
- package/dist/chunk-ZCAJZ4B2.js.map +1 -0
- package/dist/{chunk-IXWODEED.js → chunk-ZPWTOUTK.js} +43 -7
- package/dist/chunk-ZPWTOUTK.js.map +1 -0
- package/dist/cli/index.js +210 -163
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/src/commands/catalog.d.ts.map +1 -1
- package/dist/cli/src/commands/diff.d.ts +1 -1
- package/dist/cli/src/commands/diff.d.ts.map +1 -1
- package/dist/cli/src/commands/library-cmd.d.ts.map +1 -1
- package/dist/cli/src/commands/library-publish.d.ts.map +1 -1
- package/dist/cli/src/commands/manage.d.ts +6 -0
- package/dist/cli/src/commands/manage.d.ts.map +1 -1
- package/dist/cli/src/commands/outdated.d.ts.map +1 -1
- package/dist/cli/src/commands/project.d.ts +3 -1
- package/dist/cli/src/commands/project.d.ts.map +1 -1
- package/dist/cli/src/commands/run.d.ts.map +1 -1
- package/dist/cli/src/commands/update.d.ts.map +1 -1
- package/dist/cli/src/commands/validate.d.ts.map +1 -1
- package/dist/cli/src/commands/why.d.ts +1 -0
- package/dist/cli/src/commands/why.d.ts.map +1 -1
- package/dist/cli/src/helpers.d.ts +12 -0
- package/dist/cli/src/helpers.d.ts.map +1 -1
- package/dist/cli/src/skill-checks.d.ts +14 -6
- package/dist/cli/src/skill-checks.d.ts.map +1 -1
- package/dist/connectors/config.js +5 -5
- package/dist/connectors/index.js +15 -15
- package/dist/{connectors-OXP2JBGI.js → connectors-4QWAKPHB.js} +18 -18
- package/dist/{connectors-OXP2JBGI.js.map → connectors-4QWAKPHB.js.map} +1 -1
- package/dist/core/index.js +6 -6
- package/dist/core/manifest.js +2 -2
- package/dist/core/models.js +1 -1
- package/dist/core/publish-manifest.js +2 -2
- package/dist/core/ref.js +1 -1
- package/dist/core/runtime-assets.js +5 -5
- package/dist/core/src/lock.d.ts +4 -3
- package/dist/core/src/lock.d.ts.map +1 -1
- package/dist/core/src/models.d.ts +1 -1
- package/dist/core/src/models.d.ts.map +1 -1
- package/dist/core/src/publish-manifest.d.ts +11 -1
- package/dist/core/src/publish-manifest.d.ts.map +1 -1
- package/dist/core/src/workspace-config.d.ts +4 -1
- package/dist/core/src/workspace-config.d.ts.map +1 -1
- package/dist/core/workspace-config.js +4 -4
- package/dist/deploy/index.js +6 -6
- package/dist/discovery/index.js +5 -5
- package/dist/discovery/src/source-config.d.ts.map +1 -1
- package/dist/{ensure-sources-5ISVIA4T.js → ensure-sources-2RONZKCU.js} +16 -16
- package/dist/{ensure-sources-5ISVIA4T.js.map → ensure-sources-2RONZKCU.js.map} +1 -1
- package/dist/factory-assets/connectors/box.js +15 -15
- package/dist/factory-assets/connectors/deploy.js +15 -15
- package/dist/factory-assets/connectors/devserver.js +15 -15
- package/dist/factory-assets/connectors/flow/adapter.js +15 -15
- package/dist/factory-assets/connectors/flow/contract/normalize.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/contract.js +1 -1
- package/dist/factory-assets/connectors/flow/engine.js +8 -8
- package/dist/factory-assets/connectors/flow/run-flow.js +17 -17
- package/dist/factory-assets/connectors/flow.js +15 -15
- package/dist/factory-assets/connectors/git.js +15 -15
- package/dist/factory-assets/connectors/gmail.js +15 -15
- package/dist/factory-assets/connectors/googledrive.js +15 -15
- package/dist/factory-assets/connectors/local.js +15 -15
- package/dist/factory-assets/connectors/mattermost.js +15 -15
- package/dist/factory-assets/connectors/memory.js +15 -15
- package/dist/factory-assets/connectors/minio.js +15 -15
- package/dist/factory-assets/connectors/postgres.js +15 -15
- package/dist/factory-assets/connectors/s3.js +15 -15
- package/dist/factory-assets/connectors/sharepoint.js +15 -15
- package/dist/factory-assets/connectors/sqlite.js +15 -15
- package/dist/factory-assets/connectors/static-server.js +15 -15
- package/dist/factory-assets/connectors/tunnel.js +15 -15
- package/dist/factory-assets/connectors/webdav.js +15 -15
- package/dist/factory-assets/connectors/xstate-store.js +15 -15
- package/dist/factory-assets/connectors/xstate.js +15 -15
- package/dist/factory-assets/skills/authoring-skaile-manifests/references/dependency-standard.md +4 -2
- package/dist/{flows-HMSE76PO.js → flows-EQF2CH4U.js} +11 -11
- package/dist/{flows-HMSE76PO.js.map → flows-EQF2CH4U.js.map} +1 -1
- package/dist/{helpers-X6URBGSF.js → helpers-CFK6YP6R.js} +16 -16
- package/dist/{helpers-X6URBGSF.js.map → helpers-CFK6YP6R.js.map} +1 -1
- package/dist/library/index.js +10 -10
- package/dist/library/install.js +3 -3
- package/dist/library/src/index.d.ts +1 -1
- package/dist/library/src/index.d.ts.map +1 -1
- package/dist/library/src/local/library-dir.d.ts +26 -0
- package/dist/library/src/local/library-dir.d.ts.map +1 -1
- package/dist/library/src/local/library-manager.d.ts.map +1 -1
- package/dist/library/src/sync/git-driver.d.ts +2 -0
- package/dist/library/src/sync/git-driver.d.ts.map +1 -1
- package/dist/{library-publish-OS3JDW4S.js → library-publish-53UTB3MB.js} +51 -24
- package/dist/library-publish-53UTB3MB.js.map +1 -0
- package/dist/open-library-BOSPJVID.js +40 -0
- package/dist/{open-library-4QSUORI6.js.map → open-library-BOSPJVID.js.map} +1 -1
- package/dist/open-registry-4FI7HKET.js +32 -0
- package/dist/{open-registry-VCKS3MP5.js.map → open-registry-4FI7HKET.js.map} +1 -1
- package/dist/{paths-BVO56A25.js → paths-SUS4S4YT.js} +9 -9
- package/dist/{paths-BVO56A25.js.map → paths-SUS4S4YT.js.map} +1 -1
- package/dist/{plugin-store-X7GPWGBG.js → plugin-store-AGQDMING.js} +8 -8
- package/dist/{plugin-store-X7GPWGBG.js.map → plugin-store-AGQDMING.js.map} +1 -1
- package/dist/{project-PAXP46RD.js → project-I55A4O2T.js} +20 -20
- package/dist/{project-PAXP46RD.js.map → project-I55A4O2T.js.map} +1 -1
- package/dist/resolver/index.js +7 -7
- package/dist/runner/index.js +28 -28
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/runner/src/usage-limit-turn-hold.d.ts +51 -0
- package/dist/runner/src/usage-limit-turn-hold.d.ts.map +1 -0
- package/dist/sdk/asset-manager.js +13 -13
- package/dist/sdk/bridge.js +11 -11
- package/dist/sdk/core.js +6 -6
- package/dist/sdk/flow.js +8 -8
- package/dist/sdk/index.js +28 -28
- package/dist/sdk/resolver.js +7 -7
- package/dist/sdk/runner.js +28 -28
- package/dist/{setup-BV55VHWC.js → setup-7DQJKHUI.js} +21 -21
- package/dist/{setup-BV55VHWC.js.map → setup-7DQJKHUI.js.map} +1 -1
- package/dist/{skills-EDFUCJPX.js → skills-NUEN5NDX.js} +12 -12
- package/dist/{skills-EDFUCJPX.js.map → skills-NUEN5NDX.js.map} +1 -1
- package/dist/{source-E4VAT5RZ.js → source-G2LV5LVD.js} +21 -21
- package/dist/{source-E4VAT5RZ.js.map → source-G2LV5LVD.js.map} +1 -1
- package/dist/{source-manifest-publish-CLEE6TNH.js → source-manifest-publish-6RM7SWLZ.js} +23 -23
- package/dist/{source-manifest-publish-CLEE6TNH.js.map → source-manifest-publish-6RM7SWLZ.js.map} +1 -1
- package/dist/tui/index.js +59 -39
- package/dist/tui/index.js.map +1 -1
- package/dist/tui/src/repl.d.ts.map +1 -1
- package/dist/types/manifests.js +1 -1
- package/dist/types/src/manifests/preset.d.ts +1 -1
- package/dist/workspace-plugin/adapters/mcp.js +22 -22
- package/dist/workspace-plugin/adapters/omp.js +14 -14
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2FMEGSBN.js.map +0 -1
- package/dist/chunk-2JMLDZLP.js.map +0 -1
- package/dist/chunk-32XKCNCL.js.map +0 -1
- package/dist/chunk-3BEY4WK3.js.map +0 -1
- package/dist/chunk-4OV5DSBB.js.map +0 -1
- package/dist/chunk-4P3KTUZH.js.map +0 -1
- package/dist/chunk-GEWAIQZ5.js.map +0 -1
- package/dist/chunk-IXWODEED.js.map +0 -1
- package/dist/chunk-JZCSNEHK.js.map +0 -1
- package/dist/chunk-MGGFBZWA.js.map +0 -1
- package/dist/chunk-NRDSGLCQ.js.map +0 -1
- package/dist/chunk-PE36IF2D.js.map +0 -1
- package/dist/chunk-TRSQP3JD.js.map +0 -1
- package/dist/chunk-YBQONMH2.js.map +0 -1
- package/dist/library-publish-OS3JDW4S.js.map +0 -1
- package/dist/open-library-4QSUORI6.js +0 -40
- package/dist/open-registry-VCKS3MP5.js +0 -32
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolveSkWorkspaceConfig, readLinks, getGlobalCacheDir, sourceCacheKey } from './chunk-
|
|
2
|
-
import { scanDirectory, tryWithFsDeadline } from './chunk-
|
|
1
|
+
import { resolveSkWorkspaceConfig, readLinks, getGlobalCacheDir, sourceCacheKey } from './chunk-ALEYHUC5.js';
|
|
2
|
+
import { scanDirectory, tryWithFsDeadline } from './chunk-SBSA3IQA.js';
|
|
3
3
|
import { existsSync, readFileSync } from 'fs';
|
|
4
4
|
import { lstat, stat } from 'fs/promises';
|
|
5
5
|
import { createRequire } from 'module';
|
|
@@ -224,5 +224,5 @@ function findCatalogEntry(entries, query) {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
export { FACTORY_ASSETS_REPO_NAME, factoryAssetRoots, resolveFactoryAssetsRoot, resolveFactoryAssetsRootOrNull, resolvePackagedAssetsDir, resolveRuntimeAssets, resolveWorkspacesPackageRoot };
|
|
227
|
-
//# sourceMappingURL=chunk-
|
|
228
|
-
//# sourceMappingURL=chunk-
|
|
227
|
+
//# sourceMappingURL=chunk-EDYHEMJA.js.map
|
|
228
|
+
//# sourceMappingURL=chunk-EDYHEMJA.js.map
|
|
@@ -1 +1 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AQ,CAAC,KAAK,GAAA,EAAK;AAChE,IAAA,OACE,CAAA,oHAAA,CAAA;AAAA,EAGJ;AACA,EAAA,IAAI,KAAK,GAAA,EAAK;AACZ,IAAA,OAAO,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,IAAA,CAAK,GAAG,CAAA,8EAAA,CAAA;AAAA,EAC1C;AACA,EAAA,IAAI,KAAK,IAAA,EAAM;AACb,IAAA,OAAO,CAAA,YAAA,EAAe,IAAI,CAAA,kBAAA,EAAqB,IAAA,CAAK,IAAI,CAAA,CAAA;AAAA,EAC1D;AACA,EAAA,OAAO,eAAe,IAAI,CAAA,2BAAA,CAAA;AAC5B;AAEA,SAAS,gBAAA,CACP,SACA,KAAA,EACiC;AACjC,EAAA,IAAI,MAAM,IAAA,EAAM;AACd,IAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,KAAS,KAAA,CAAM,IAAA,IAAQ,CAAA,CAAE,IAAA,KAAS,KAAA,CAAM,IAAI,CAAA;AAAA,EAC3E;AACA,EAAA,MAAM,OAAA,GAAU,QAAQ,MAAA,CAAO,CAAC,MAAM,CAAA,CAAE,IAAA,KAAS,MAAM,IAAI,CAAA;AAC3D,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG,OAAO,QAAQ,CAAC,CAAA;AAE1C,EAAA,OAAO,MAAA;AACT","file":"chunk-GFCXNFTW.js","sourcesContent":["/**\n * Runtime asset resolution — read `skaile.yaml`, scan all declared repositories\n * (including the built-in `factory-assets/` directory as an implicit default),\n * and produce a unified view of connector catalog entries plus the implicit refs\n * that the `skaile.yaml` `connectors:` section adds to the dependency graph.\n *\n * This module is the single source of truth for \"which connectors does this\n * project see at runtime, and where do their implementations live on disk\".\n * Both the runner (serve, REPL, flow) and the platform's mid-session\n * `add_resource` flow consume `RuntimeAssetsResult.catalogEntries` and pass\n * it into `ConnectorManager` for catalog-based resolution.\n *\n * `factory-assets/` is the single first-party content tree (built-in connectors\n * + first-party skills + bundles) shipped inside the `@skaile/workspaces`\n * package — not a standalone package.\n *\n * It resolves to an **ordered list of roots** ({@link factoryAssetRoots}), not a\n * single dir. The bundled tree is always the baseline; an optional\n * `SKAILE_FACTORY_ASSETS_DIR` (legacy: `SKAILE_BASE_ASSETS_DIR`) is layered\n * **in front** as an additive override source — the agent container points it at\n * `/app/factory-assets/` (or a bind-mounted host dir) to ship updated skills /\n * flows / bundles / connector manifests without rebuilding the image. The two\n * roots resolve uniformly across every consumer (connector catalog scan, skill /\n * flow / completion discovery, the asset-manager factory source):\n * 1. `SKAILE_FACTORY_ASSETS_DIR` env dir, when set and existing (override layer).\n * 2. the bundled tree via {@link resolvePackagedAssetsDir} — the in-repo source\n * `packages/workspaces/factory-assets/` during dev, else the published\n * `dist/factory-assets/` after install (always-present baseline).\n *\n * Override semantics are **env-first**: on a name conflict the env root wins and\n * the bundled root fills the rest. Connector *code* still loads via the package's\n * static `exports` map, so the env root can override/add skills, flows, bundles,\n * and connector **manifests/metadata**, but cannot ship a new executable\n * connector — its `.js` is not on the package's import graph.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { lstat, stat } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve as resolvePath } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { tryWithFsDeadline } from \"./fs-deadline.js\";\nimport { scanDirectory } from \"./manifest.js\";\nimport type { CatalogEntry } from \"./models.js\";\nimport { getGlobalCacheDir, readLinks, sourceCacheKey } from \"./repo-manager.js\";\nimport type { SourceDeclaration, SourceEntry } from \"./workspace-config.js\";\nimport { resolveSkWorkspaceConfig } from \"./workspace-config.js\";\n\n/**\n * Map declared `sources[]` to internal `SourceDeclaration`s keyed by the\n * collision-free {@link sourceCacheKey} (`<host>/<owner>/<repo>`), pointing at\n * the unified machine-cache clone path (`getGlobalCacheDir()/<key>/`). Keyed by\n * the same function every other cache writer/reader uses so the path resolves.\n */\nfunction sourcesToDeclarations(\n sources: SourceEntry[] | undefined,\n): Record<string, SourceDeclaration> {\n const sourcesDir = getGlobalCacheDir();\n const out: Record<string, SourceDeclaration> = {};\n for (const s of sources ?? []) {\n const key = sourceCacheKey(s.url);\n if (out[key]) continue;\n out[key] = { path: join(sourcesDir, key), url: s.url, branch: s.pin };\n }\n return out;\n}\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Catalog entry filtered to mount/connector kinds. Same shape as `CatalogEntry`.\n * @docLink packages/core/concepts#runtime-catalog-entry\n */\nexport type RuntimeCatalogEntry = CatalogEntry;\n\n/**\n * Implicit catalog reference derived from a `connectors:` declaration in `skaile.yaml`.\n * Each connector driver becomes an implicit ref that must be resolved in the catalog.\n * @docLink packages/core/concepts#runtime-asset-ref\n */\nexport interface RuntimeAssetRef {\n kind: \"connector\";\n /** Driver name — matches `RuntimeCatalogEntry.name`. */\n name: string;\n /** Source declaration id from `skaile.yaml`. */\n declarationId: string;\n}\n\n/**\n * Aggregated npm packages required by all resolved mount/connector adapters.\n * Populated from `metadata.npm_deps` in each matched catalog entry.\n * @docLink packages/core/concepts#runtime-npm-deps\n */\nexport interface RuntimeNpmDeps {\n required: string[];\n optional: string[];\n}\n\n/**\n * Non-fatal warning emitted during `resolveRuntimeAssets` when a repo is unavailable\n * or a driver is not found in any catalog.\n * @docLink packages/core/concepts#runtime-asset-warning\n */\nexport interface RuntimeAssetWarning {\n /** Stable code for filtering / structured logging. */\n code: \"missing_driver\" | \"repo_unavailable\" | \"invalid_repo_decl\";\n message: string;\n /** Declaration id when applicable. */\n declarationId?: string;\n /** Driver / repository name when applicable. */\n name?: string;\n}\n\n/**\n * Repository name used for the implicit built-in `factory-assets` catalog entry\n * (the in-package connector tree).\n * @docLink packages/core/concepts#factory-assets-repo-name\n */\nexport const FACTORY_ASSETS_REPO_NAME = \"factory-assets\";\n\n/**\n * Repository name for the optional `SKAILE_FACTORY_ASSETS_DIR` override layer,\n * scanned ahead of (and overriding) the bundled {@link FACTORY_ASSETS_REPO_NAME}.\n */\nconst FACTORY_ASSETS_OVERRIDE_REPO_NAME = \"factory-assets:override\";\n\n/**\n * Result of `resolveRuntimeAssets`.\n * The same object is mutated in place by `refresh()`, allowing callers to hold\n * a stable reference and observe updates after a new repository is cloned or\n * a driver is installed mid-session.\n * @docLink packages/core/concepts#runtime-assets-result\n */\nexport interface RuntimeAssetsResult {\n catalogEntries: RuntimeCatalogEntry[];\n implicitRefs: RuntimeAssetRef[];\n requiredNpmDeps: RuntimeNpmDeps;\n warnings: RuntimeAssetWarning[];\n /** Re-scan repositories and re-derive implicit refs. Mutates in place. */\n refresh(): Promise<void>;\n /**\n * Catalog lookup. When `kind` is omitted and multiple entries share the\n * `name`, returns `undefined` (caller must disambiguate).\n */\n findEntry(query: { kind?: \"connector\"; name: string }): RuntimeCatalogEntry | undefined;\n}\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\n/**\n * Resolve all runtime assets visible to a project by scanning declared repositories.\n *\n * Reads `skaile.yaml`, scans every declared repository (plus the implicit\n * built-in `factory-assets` repo), and derives implicit refs from `mounts:` /\n * `connectors:` declarations. Does not clone or install anything — purely a\n * read-only scan of what is already on disk. URL-only repositories that have\n * not been cloned yet are reported as `repo_unavailable` warnings.\n *\n * @param projectDir - Absolute path to the project workspace root\n * @returns `RuntimeAssetsResult` with catalog entries, implicit refs, npm deps, and warnings\n * @docLink packages/core/concepts#resolve-runtime-assets\n */\nexport async function resolveRuntimeAssets(projectDir: string): Promise<RuntimeAssetsResult> {\n const result: RuntimeAssetsResult = {\n catalogEntries: [],\n implicitRefs: [],\n requiredNpmDeps: { required: [], optional: [] },\n warnings: [],\n refresh: async () => {\n await populate(projectDir, result);\n },\n findEntry: (query) => findCatalogEntry(result.catalogEntries, query),\n };\n\n await populate(projectDir, result);\n return result;\n}\n\n/**\n * Resolve the ordered list of on-disk roots for the built-in `factory-assets`\n * tree (built-in connectors + first-party skills + bundles). This is the single\n * shared resolver every consumer goes through, so the env override and the\n * bundled baseline are honoured uniformly.\n *\n * Order (env-first = override-wins):\n * 1. `SKAILE_FACTORY_ASSETS_DIR` env dir (legacy: `SKAILE_BASE_ASSETS_DIR`),\n * when set and existing — an additive override layer.\n * 2. {@link resolvePackagedAssetsDir} — the bundled tree (in-repo source in dev,\n * `dist/factory-assets/` after install). Always-present baseline.\n *\n * Returns `[]` only when the package cannot be located at all. De-duplicated, so\n * pointing the env var at the bundled dir collapses to one root.\n *\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function factoryAssetRoots(): string[] {\n const roots: string[] = [];\n const envDir = process.env.SKAILE_FACTORY_ASSETS_DIR ?? process.env.SKAILE_BASE_ASSETS_DIR;\n // Deliberately still synchronous after #454: both candidates are\n // container-local (the image's `/app/factory-assets/`, or the installed\n // package tree resolved by `resolvePackagedAssetsDir`), never the FUSE\n // workspace mount. The mount-reachable probes on this module's scan path —\n // the project-relative `sources[].path` candidates in `resolveRepoDir` — are\n // async and deadline-bounded.\n if (envDir && existsSync(envDir)) roots.push(resolvePath(envDir));\n const bundled = resolvePackagedAssetsDir(\"factory-assets\");\n if (bundled) roots.push(bundled);\n return [...new Set(roots)];\n}\n\n/**\n * Resolve the primary on-disk root of the `factory-assets` tree — the first of\n * {@link factoryAssetRoots} (the env override when set, else the bundled tree).\n * Prefer {@link factoryAssetRoots} when you need to scan every layer; this\n * single-dir form is for callers that want one canonical path.\n *\n * @returns Absolute path to the highest-precedence `factory-assets` directory\n * @throws When no root can be located\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function resolveFactoryAssetsRoot(): string {\n const hit = resolveFactoryAssetsRootOrNull();\n if (hit) return hit;\n\n throw new Error(\n `Cannot resolve the factory-assets directory. ` +\n `Set SKAILE_FACTORY_ASSETS_DIR to the on-disk path, ` +\n `ensure @skaile/workspaces is installed, ` +\n `or run from within the @skaile/workspaces package tree.`,\n );\n}\n\n/**\n * Non-throwing variant of {@link resolveFactoryAssetsRoot}: the same\n * env-then-packaged resolution tiers, returning `null` instead of throwing when\n * none locate the directory. Callers that treat a missing factory tree as a\n * soft \"not present\" (e.g. the asset-manager's implicit-source injection) MUST\n * use this so they honour the `SKAILE_FACTORY_ASSETS_DIR` container override\n * identically to the runtime path.\n */\nexport function resolveFactoryAssetsRootOrNull(): string | null {\n return factoryAssetRoots()[0] ?? null;\n}\n\n/**\n * Resolve the `@skaile/workspaces` package root — the directory containing its\n * `package.json`. Tries `require.resolve` first (works when installed as a\n * dependency *and* in-repo via the self-reference), then walks upward from this\n * module looking for a `package.json` whose `name` is `@skaile/workspaces`\n * (bounded to 8 levels). Returns `null` when neither locates it.\n *\n * The single source of truth for finding content shipped inside the package —\n * the unified `factory-assets/` tree (built-in connectors + first-party skills\n * + bundles) resolves through {@link resolvePackagedAssetsDir} on top of this.\n *\n * Memoized: the package location is immutable for the process lifetime, but\n * this sits on the CLI hot path (every `findSkills` / flow / completion call\n * funnels through here), so the `require.resolve` + upward `package.json` walk\n * runs once. `undefined` = not yet computed.\n *\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nlet workspacesPackageRootCache: string | null | undefined;\n\nexport function resolveWorkspacesPackageRoot(): string | null {\n if (workspacesPackageRootCache !== undefined) return workspacesPackageRootCache;\n workspacesPackageRootCache = computeWorkspacesPackageRoot();\n return workspacesPackageRootCache;\n}\n\nfunction computeWorkspacesPackageRoot(): string | null {\n try {\n const require = createRequire(import.meta.url);\n return dirname(require.resolve(\"@skaile/workspaces/package.json\"));\n } catch {\n // Fall through to the workspace walk.\n }\n let dir: string;\n try {\n dir = dirname(fileURLToPath(import.meta.url));\n } catch {\n return null;\n }\n for (let i = 0; i < 8; i++) {\n const pkgPath = join(dir, \"package.json\");\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as { name?: string };\n if (pkg.name === \"@skaile/workspaces\") return dir;\n } catch {\n // Ignore malformed package.json and keep walking.\n }\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/**\n * Locate a content-asset directory inside the package. Prefers the in-repo\n * **source** dir `<pkgRoot>/<subdir>` when present — in a dev checkout it is the\n * full tree (e.g. `factory-assets/` keeps the connector `.ts` entry files that\n * `dist/` does not) — then the published `dist/<subdir>` copy (what\n * `files: [\"dist\"]` ships, the only one present after `npm i`). Returns `null`\n * when neither exists.\n *\n * `factory-assets/` resolves to the source tree in dev (code + skills + bundles)\n * and to `dist/factory-assets` post-install (compiled connectors + copied\n * manifests/skills/bundles).\n *\n * @param subdir - `\"factory-assets\"` | …\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function resolvePackagedAssetsDir(subdir: string): string | null {\n const root = resolveWorkspacesPackageRoot();\n if (!root) return null;\n for (const cand of [join(root, subdir), join(root, \"dist\", subdir)]) {\n if (existsSync(cand)) return cand;\n }\n return null;\n}\n\n// ─── Internals ────────────────────────────────────────────────────────────────\n\nconst CONNECTOR_SCAN_KINDS: ReadonlySet<string> = new Set([\"connector\"]);\n\nasync function populate(projectDir: string, target: RuntimeAssetsResult): Promise<void> {\n target.catalogEntries = [];\n target.implicitRefs = [];\n target.requiredNpmDeps = { required: [], optional: [] };\n target.warnings = [];\n\n const config = resolveSkWorkspaceConfig(projectDir);\n // Connector catalog scan runs over the project's declared sources[] (resolved\n // to their machine-cache clone paths) plus the implicit factory-assets repo.\n const repositories = buildEffectiveRepositories(sourcesToDeclarations(config.sources));\n const links = readLinks(projectDir);\n\n // Scan each repository for connector entries.\n for (const [name, decl] of Object.entries(repositories)) {\n const repoDir = await resolveRepoDir(name, decl, projectDir, links);\n if (!repoDir) {\n target.warnings.push({\n code: \"repo_unavailable\",\n name,\n message: repoUnavailableMessage(name, decl),\n });\n continue;\n }\n try {\n // Both factory layers carry the same `factory-assets` provenance — the\n // override repo is an internal scan-order device, not a distinct source.\n const repoName = name === FACTORY_ASSETS_OVERRIDE_REPO_NAME ? FACTORY_ASSETS_REPO_NAME : name;\n // Only connector descriptors are consumed here, so only that kind is\n // \"known\": typed manifests of any other kind are irrelevant to this scan.\n const scanned = await scanDirectory(repoDir, repoName, {\n knownKinds: CONNECTOR_SCAN_KINDS,\n onDiagnostic: () => {},\n });\n const entries = scanned.filter((e) => e.kind === \"connector\");\n target.catalogEntries.push(...entries);\n } catch (err) {\n target.warnings.push({\n code: \"repo_unavailable\",\n name,\n message: `Failed to scan repository \"${name}\" at ${repoDir}: ${\n err instanceof Error ? err.message : String(err)\n }`,\n });\n }\n }\n\n // De-duplicate by (kind, name), keeping the first occurrence. Scan order is\n // declared sources → env override → bundled baseline, so an env-supplied\n // connector manifest overrides the bundled one and the bundled one fills the\n // rest (the override layer can refresh built-in manifests in place).\n const seen = new Set<string>();\n target.catalogEntries = target.catalogEntries.filter((e) => {\n const key = `${e.kind}:${e.name}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n\n // Derive implicit refs from skaile.yaml connectors.\n for (const c of config.connectors ?? []) {\n target.implicitRefs.push({ kind: \"connector\", name: c.driver, declarationId: c.id });\n }\n\n // Validate refs and aggregate npm deps.\n const requiredSet = new Set<string>();\n const optionalSet = new Set<string>();\n for (const ref of target.implicitRefs) {\n const entry = findCatalogEntry(target.catalogEntries, ref);\n if (!entry) {\n target.warnings.push({\n code: \"missing_driver\",\n declarationId: ref.declarationId,\n name: ref.name,\n message:\n `Unknown ${ref.kind} driver \"${ref.name}\" referenced by ${ref.kind} \"${ref.declarationId}\". ` +\n `Run \\`skaile ${ref.kind} catalog\\` to see available drivers, ` +\n `or declare a repository in skaile.yaml that provides this driver.`,\n });\n continue;\n }\n const npm = (entry.metadata?.npm_deps ?? {}) as { required?: string[]; optional?: string[] };\n for (const p of npm.required ?? []) requiredSet.add(p);\n for (const p of npm.optional ?? []) optionalSet.add(p);\n }\n target.requiredNpmDeps.required = [...requiredSet];\n target.requiredNpmDeps.optional = [...optionalSet];\n}\n\n/**\n * Build the effective `repositories` map: caller's declarations first, then the\n * implicit built-in `factory-assets` repos. Each {@link factoryAssetRoots} layer\n * becomes its own repo, the env override inserted **before** the bundled\n * baseline so its connector entries win on the first-match dedup downstream.\n * When the package cannot be located at all, a path-less sentinel under\n * {@link FACTORY_ASSETS_REPO_NAME} drives the `repo_unavailable` warning.\n */\nfunction buildEffectiveRepositories(\n declared: Record<string, SourceDeclaration> | undefined,\n): Record<string, SourceDeclaration> {\n const result: Record<string, SourceDeclaration> = { ...(declared ?? {}) };\n const roots = factoryAssetRoots();\n if (roots.length === 0) {\n // Surface as a warning during scan rather than throwing here — let the\n // caller decide whether factory-assets is required. resolveRepoDir() /\n // repoUnavailableMessage re-discover the failure and emit it.\n if (!result[FACTORY_ASSETS_REPO_NAME]) result[FACTORY_ASSETS_REPO_NAME] = { path: \"\" };\n return result;\n }\n // override-first when both layers exist, so the env root's entries are scanned\n // (and matched) ahead of the bundled baseline.\n const keys =\n roots.length > 1\n ? [FACTORY_ASSETS_OVERRIDE_REPO_NAME, FACTORY_ASSETS_REPO_NAME]\n : [FACTORY_ASSETS_REPO_NAME];\n roots.forEach((dir, i) => {\n const key = keys[i] ?? `${FACTORY_ASSETS_REPO_NAME}:${i}`;\n if (!result[key]) result[key] = { path: dir };\n });\n return result;\n}\n\n/**\n * Resolve a repository declaration to an on-disk directory. Order:\n * 1. Linked override (`.skaile/links.yaml`).\n * 2. Local `path` — relative to `projectDir`.\n * 3. Cloned URL repo at `.skaile/cache/sources/<name>/` (must already exist).\n *\n * Returns `null` when none of these resolve. Does not clone.\n *\n * **Async and deadline-bounded since #454.** Every candidate here is a\n * project-relative or operator-supplied path, so a `sources[].path` of\n * `workspace/my-assets` resolves onto the rclone FUSE mount — the same tree the\n * scan that follows walks. Probing it with `existsSync`/`lstatSync` would park\n * the `skaile serve` event loop *before* the (now async) scan ever ran, which\n * would leave the H2 fix meaningless on the very declaration that triggers it.\n * A probe that misses its deadline reads as \"unavailable\", which is what the\n * caller already does with an absent path — it becomes a `repo_unavailable`\n * warning rather than a stall.\n */\nasync function resolveRepoDir(\n name: string,\n decl: SourceDeclaration,\n projectDir: string,\n links: Record<string, string>,\n): Promise<string | null> {\n // 1. Linked override\n const linked = links[name];\n if (linked && (await pathExists(linked))) return linked;\n\n // 2. Local path\n if (decl.path) {\n const resolved = resolvePath(projectDir, decl.path);\n return (await pathExists(resolved)) ? resolved : null;\n }\n\n // 3. URL repo cloned to project's .skaile/cache/sources/<name> — the\n // project-local clone dir (often a symlink into the global cache, which\n // lives at getGlobalCacheDir()); NOT the global clone root itself.\n if (decl.url) {\n const projectDest = join(projectDir, \".skaile\", \"cache\", \"sources\", name);\n // One `lstat` answers both questions the pre-#454 `existsSync` + `lstatSync`\n // pair asked, and `lstat` (not `stat`) keeps the \"a symlink into the global\n // cache counts\" behaviour intact.\n const found = await tryWithFsDeadline(\n `lstat ${projectDest}`,\n async () => {\n await lstat(projectDest);\n return true;\n },\n false,\n );\n return found ? projectDest : null;\n }\n\n return null;\n}\n\n/** Deadline-bounded `existsSync` replacement — a wedged mount reads as absent. */\nfunction pathExists(path: string): Promise<boolean> {\n return tryWithFsDeadline(\n `stat ${path}`,\n async () => {\n await stat(path);\n return true;\n },\n false,\n );\n}\n\nfunction repoUnavailableMessage(name: string, decl: SourceDeclaration): string {\n if (name === FACTORY_ASSETS_REPO_NAME && !decl.path && !decl.url) {\n return (\n `Cannot resolve the built-in factory-assets. ` +\n `Set SKAILE_FACTORY_ASSETS_DIR or ensure @skaile/workspaces is installed.`\n );\n }\n if (decl.url) {\n return `Repository \"${name}\" (${decl.url}) is not available. Register it as a Library Source via \\`skaile source add\\`.`;\n }\n if (decl.path) {\n return `Repository \"${name}\" path not found: ${decl.path}`;\n }\n return `Repository \"${name}\" has neither url nor path.`;\n}\n\nfunction findCatalogEntry(\n entries: RuntimeCatalogEntry[],\n query: { kind?: \"connector\"; name: string },\n): RuntimeCatalogEntry | undefined {\n if (query.kind) {\n return entries.find((e) => e.kind === query.kind && e.name === query.name);\n }\n const matches = entries.filter((e) => e.name === query.name);\n if (matches.length === 1) return matches[0];\n // 0 or >1 with no kind — caller must disambiguate.\n return undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../core/src/runtime-assets.ts"],"names":["resolvePath","require"],"mappings":";;;;;;;;AAsDA,SAAS,sBACP,OAAA,EACmC;AACnC,EAAA,MAAM,aAAa,iBAAA,EAAkB;AACrC,EAAA,MAAM,MAAyC,EAAC;AAChD,EAAA,KAAA,MAAW,CAAA,IAAK,OAAA,IAAW,EAAC,EAAG;AAC7B,IAAA,MAAM,GAAA,GAAM,cAAA,CAAe,CAAA,CAAE,GAAG,CAAA;AAChC,IAAA,IAAI,GAAA,CAAI,GAAG,CAAA,EAAG;AACd,IAAA,GAAA,CAAI,GAAG,CAAA,GAAI,EAAE,IAAA,EAAM,IAAA,CAAK,UAAA,EAAY,GAAG,CAAA,EAAG,GAAA,EAAK,CAAA,CAAE,GAAA,EAAK,MAAA,EAAQ,EAAE,GAAA,EAAI;AAAA,EACtE;AACA,EAAA,OAAO,GAAA;AACT;AAqDO,IAAM,wBAAA,GAA2B;AAMxC,IAAM,iCAAA,GAAoC,yBAAA;AAsC1C,eAAsB,qBAAqB,UAAA,EAAkD;AAC3F,EAAA,MAAM,MAAA,GAA8B;AAAA,IAClC,gBAAgB,EAAC;AAAA,IACjB,cAAc,EAAC;AAAA,IACf,iBAAiB,EAAE,QAAA,EAAU,EAAC,EAAG,QAAA,EAAU,EAAC,EAAE;AAAA,IAC9C,UAAU,EAAC;AAAA,IACX,SAAS,YAAY;AACnB,MAAA,MAAM,QAAA,CAAS,YAAY,MAAM,CAAA;AAAA,IACnC,CAAA;AAAA,IACA,WAAW,CAAC,KAAA,KAAU,gBAAA,CAAiB,MAAA,CAAO,gBAAgB,KAAK;AAAA,GACrE;AAEA,EAAA,MAAM,QAAA,CAAS,YAAY,MAAM,CAAA;AACjC,EAAA,OAAO,MAAA;AACT;AAmBO,SAAS,iBAAA,GAA8B;AAC5C,EAAA,MAAM,QAAkB,EAAC;AACzB,EAAA,MAAM,MAAA,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AAI,SAAS,wBAAA,IAA4B,CAAC,KAAK,IAAA,IAAQ,CAAC,KAAK,GAAA,EAAK;AAChE,IAAA,OACE,CAAA,oHAAA,CAAA;AAAA,EAGJ;AACA,EAAA,IAAI,KAAK,GAAA,EAAK;AACZ,IAAA,OAAO,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,IAAA,CAAK,GAAG,CAAA,8EAAA,CAAA;AAAA,EAC1C;AACA,EAAA,IAAI,KAAK,IAAA,EAAM;AACb,IAAA,OAAO,CAAA,YAAA,EAAe,IAAI,CAAA,kBAAA,EAAqB,IAAA,CAAK,IAAI,CAAA,CAAA;AAAA,EAC1D;AACA,EAAA,OAAO,eAAe,IAAI,CAAA,2BAAA,CAAA;AAC5B;AAEA,SAAS,gBAAA,CACP,SACA,KAAA,EACiC;AACjC,EAAA,IAAI,MAAM,IAAA,EAAM;AACd,IAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,KAAS,KAAA,CAAM,IAAA,IAAQ,CAAA,CAAE,IAAA,KAAS,KAAA,CAAM,IAAI,CAAA;AAAA,EAC3E;AACA,EAAA,MAAM,OAAA,GAAU,QAAQ,MAAA,CAAO,CAAC,MAAM,CAAA,CAAE,IAAA,KAAS,MAAM,IAAI,CAAA;AAC3D,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG,OAAO,QAAQ,CAAC,CAAA;AAE1C,EAAA,OAAO,MAAA;AACT","file":"chunk-EDYHEMJA.js","sourcesContent":["/**\n * Runtime asset resolution — read `skaile.yaml`, scan all declared repositories\n * (including the built-in `factory-assets/` directory as an implicit default),\n * and produce a unified view of connector catalog entries plus the implicit refs\n * that the `skaile.yaml` `connectors:` section adds to the dependency graph.\n *\n * This module is the single source of truth for \"which connectors does this\n * project see at runtime, and where do their implementations live on disk\".\n * Both the runner (serve, REPL, flow) and the platform's mid-session\n * `add_resource` flow consume `RuntimeAssetsResult.catalogEntries` and pass\n * it into `ConnectorManager` for catalog-based resolution.\n *\n * `factory-assets/` is the single first-party content tree (built-in connectors\n * + first-party skills + bundles) shipped inside the `@skaile/workspaces`\n * package — not a standalone package.\n *\n * It resolves to an **ordered list of roots** ({@link factoryAssetRoots}), not a\n * single dir. The bundled tree is always the baseline; an optional\n * `SKAILE_FACTORY_ASSETS_DIR` (legacy: `SKAILE_BASE_ASSETS_DIR`) is layered\n * **in front** as an additive override source — the agent container points it at\n * `/app/factory-assets/` (or a bind-mounted host dir) to ship updated skills /\n * flows / bundles / connector manifests without rebuilding the image. The two\n * roots resolve uniformly across every consumer (connector catalog scan, skill /\n * flow / completion discovery, the asset-manager factory source):\n * 1. `SKAILE_FACTORY_ASSETS_DIR` env dir, when set and existing (override layer).\n * 2. the bundled tree via {@link resolvePackagedAssetsDir} — the in-repo source\n * `packages/workspaces/factory-assets/` during dev, else the published\n * `dist/factory-assets/` after install (always-present baseline).\n *\n * Override semantics are **env-first**: on a name conflict the env root wins and\n * the bundled root fills the rest. Connector *code* still loads via the package's\n * static `exports` map, so the env root can override/add skills, flows, bundles,\n * and connector **manifests/metadata**, but cannot ship a new executable\n * connector — its `.js` is not on the package's import graph.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { lstat, stat } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve as resolvePath } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { tryWithFsDeadline } from \"./fs-deadline.js\";\nimport { scanDirectory } from \"./manifest.js\";\nimport type { CatalogEntry } from \"./models.js\";\nimport { getGlobalCacheDir, readLinks, sourceCacheKey } from \"./repo-manager.js\";\nimport type { SourceDeclaration, SourceEntry } from \"./workspace-config.js\";\nimport { resolveSkWorkspaceConfig } from \"./workspace-config.js\";\n\n/**\n * Map declared `sources[]` to internal `SourceDeclaration`s keyed by the\n * collision-free {@link sourceCacheKey} (`<host>/<owner>/<repo>`), pointing at\n * the unified machine-cache clone path (`getGlobalCacheDir()/<key>/`). Keyed by\n * the same function every other cache writer/reader uses so the path resolves.\n */\nfunction sourcesToDeclarations(\n sources: SourceEntry[] | undefined,\n): Record<string, SourceDeclaration> {\n const sourcesDir = getGlobalCacheDir();\n const out: Record<string, SourceDeclaration> = {};\n for (const s of sources ?? []) {\n const key = sourceCacheKey(s.url);\n if (out[key]) continue;\n out[key] = { path: join(sourcesDir, key), url: s.url, branch: s.pin };\n }\n return out;\n}\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Catalog entry filtered to mount/connector kinds. Same shape as `CatalogEntry`.\n * @docLink packages/core/concepts#runtime-catalog-entry\n */\nexport type RuntimeCatalogEntry = CatalogEntry;\n\n/**\n * Implicit catalog reference derived from a `connectors:` declaration in `skaile.yaml`.\n * Each connector driver becomes an implicit ref that must be resolved in the catalog.\n * @docLink packages/core/concepts#runtime-asset-ref\n */\nexport interface RuntimeAssetRef {\n kind: \"connector\";\n /** Driver name — matches `RuntimeCatalogEntry.name`. */\n name: string;\n /** Source declaration id from `skaile.yaml`. */\n declarationId: string;\n}\n\n/**\n * Aggregated npm packages required by all resolved mount/connector adapters.\n * Populated from `metadata.npm_deps` in each matched catalog entry.\n * @docLink packages/core/concepts#runtime-npm-deps\n */\nexport interface RuntimeNpmDeps {\n required: string[];\n optional: string[];\n}\n\n/**\n * Non-fatal warning emitted during `resolveRuntimeAssets` when a repo is unavailable\n * or a driver is not found in any catalog.\n * @docLink packages/core/concepts#runtime-asset-warning\n */\nexport interface RuntimeAssetWarning {\n /** Stable code for filtering / structured logging. */\n code: \"missing_driver\" | \"repo_unavailable\" | \"invalid_repo_decl\";\n message: string;\n /** Declaration id when applicable. */\n declarationId?: string;\n /** Driver / repository name when applicable. */\n name?: string;\n}\n\n/**\n * Repository name used for the implicit built-in `factory-assets` catalog entry\n * (the in-package connector tree).\n * @docLink packages/core/concepts#factory-assets-repo-name\n */\nexport const FACTORY_ASSETS_REPO_NAME = \"factory-assets\";\n\n/**\n * Repository name for the optional `SKAILE_FACTORY_ASSETS_DIR` override layer,\n * scanned ahead of (and overriding) the bundled {@link FACTORY_ASSETS_REPO_NAME}.\n */\nconst FACTORY_ASSETS_OVERRIDE_REPO_NAME = \"factory-assets:override\";\n\n/**\n * Result of `resolveRuntimeAssets`.\n * The same object is mutated in place by `refresh()`, allowing callers to hold\n * a stable reference and observe updates after a new repository is cloned or\n * a driver is installed mid-session.\n * @docLink packages/core/concepts#runtime-assets-result\n */\nexport interface RuntimeAssetsResult {\n catalogEntries: RuntimeCatalogEntry[];\n implicitRefs: RuntimeAssetRef[];\n requiredNpmDeps: RuntimeNpmDeps;\n warnings: RuntimeAssetWarning[];\n /** Re-scan repositories and re-derive implicit refs. Mutates in place. */\n refresh(): Promise<void>;\n /**\n * Catalog lookup. When `kind` is omitted and multiple entries share the\n * `name`, returns `undefined` (caller must disambiguate).\n */\n findEntry(query: { kind?: \"connector\"; name: string }): RuntimeCatalogEntry | undefined;\n}\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\n/**\n * Resolve all runtime assets visible to a project by scanning declared repositories.\n *\n * Reads `skaile.yaml`, scans every declared repository (plus the implicit\n * built-in `factory-assets` repo), and derives implicit refs from `mounts:` /\n * `connectors:` declarations. Does not clone or install anything — purely a\n * read-only scan of what is already on disk. URL-only repositories that have\n * not been cloned yet are reported as `repo_unavailable` warnings.\n *\n * @param projectDir - Absolute path to the project workspace root\n * @returns `RuntimeAssetsResult` with catalog entries, implicit refs, npm deps, and warnings\n * @docLink packages/core/concepts#resolve-runtime-assets\n */\nexport async function resolveRuntimeAssets(projectDir: string): Promise<RuntimeAssetsResult> {\n const result: RuntimeAssetsResult = {\n catalogEntries: [],\n implicitRefs: [],\n requiredNpmDeps: { required: [], optional: [] },\n warnings: [],\n refresh: async () => {\n await populate(projectDir, result);\n },\n findEntry: (query) => findCatalogEntry(result.catalogEntries, query),\n };\n\n await populate(projectDir, result);\n return result;\n}\n\n/**\n * Resolve the ordered list of on-disk roots for the built-in `factory-assets`\n * tree (built-in connectors + first-party skills + bundles). This is the single\n * shared resolver every consumer goes through, so the env override and the\n * bundled baseline are honoured uniformly.\n *\n * Order (env-first = override-wins):\n * 1. `SKAILE_FACTORY_ASSETS_DIR` env dir (legacy: `SKAILE_BASE_ASSETS_DIR`),\n * when set and existing — an additive override layer.\n * 2. {@link resolvePackagedAssetsDir} — the bundled tree (in-repo source in dev,\n * `dist/factory-assets/` after install). Always-present baseline.\n *\n * Returns `[]` only when the package cannot be located at all. De-duplicated, so\n * pointing the env var at the bundled dir collapses to one root.\n *\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function factoryAssetRoots(): string[] {\n const roots: string[] = [];\n const envDir = process.env.SKAILE_FACTORY_ASSETS_DIR ?? process.env.SKAILE_BASE_ASSETS_DIR;\n // Deliberately still synchronous after #454: both candidates are\n // container-local (the image's `/app/factory-assets/`, or the installed\n // package tree resolved by `resolvePackagedAssetsDir`), never the FUSE\n // workspace mount. The mount-reachable probes on this module's scan path —\n // the project-relative `sources[].path` candidates in `resolveRepoDir` — are\n // async and deadline-bounded.\n if (envDir && existsSync(envDir)) roots.push(resolvePath(envDir));\n const bundled = resolvePackagedAssetsDir(\"factory-assets\");\n if (bundled) roots.push(bundled);\n return [...new Set(roots)];\n}\n\n/**\n * Resolve the primary on-disk root of the `factory-assets` tree — the first of\n * {@link factoryAssetRoots} (the env override when set, else the bundled tree).\n * Prefer {@link factoryAssetRoots} when you need to scan every layer; this\n * single-dir form is for callers that want one canonical path.\n *\n * @returns Absolute path to the highest-precedence `factory-assets` directory\n * @throws When no root can be located\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function resolveFactoryAssetsRoot(): string {\n const hit = resolveFactoryAssetsRootOrNull();\n if (hit) return hit;\n\n throw new Error(\n `Cannot resolve the factory-assets directory. ` +\n `Set SKAILE_FACTORY_ASSETS_DIR to the on-disk path, ` +\n `ensure @skaile/workspaces is installed, ` +\n `or run from within the @skaile/workspaces package tree.`,\n );\n}\n\n/**\n * Non-throwing variant of {@link resolveFactoryAssetsRoot}: the same\n * env-then-packaged resolution tiers, returning `null` instead of throwing when\n * none locate the directory. Callers that treat a missing factory tree as a\n * soft \"not present\" (e.g. the asset-manager's implicit-source injection) MUST\n * use this so they honour the `SKAILE_FACTORY_ASSETS_DIR` container override\n * identically to the runtime path.\n */\nexport function resolveFactoryAssetsRootOrNull(): string | null {\n return factoryAssetRoots()[0] ?? null;\n}\n\n/**\n * Resolve the `@skaile/workspaces` package root — the directory containing its\n * `package.json`. Tries `require.resolve` first (works when installed as a\n * dependency *and* in-repo via the self-reference), then walks upward from this\n * module looking for a `package.json` whose `name` is `@skaile/workspaces`\n * (bounded to 8 levels). Returns `null` when neither locates it.\n *\n * The single source of truth for finding content shipped inside the package —\n * the unified `factory-assets/` tree (built-in connectors + first-party skills\n * + bundles) resolves through {@link resolvePackagedAssetsDir} on top of this.\n *\n * Memoized: the package location is immutable for the process lifetime, but\n * this sits on the CLI hot path (every `findSkills` / flow / completion call\n * funnels through here), so the `require.resolve` + upward `package.json` walk\n * runs once. `undefined` = not yet computed.\n *\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nlet workspacesPackageRootCache: string | null | undefined;\n\nexport function resolveWorkspacesPackageRoot(): string | null {\n if (workspacesPackageRootCache !== undefined) return workspacesPackageRootCache;\n workspacesPackageRootCache = computeWorkspacesPackageRoot();\n return workspacesPackageRootCache;\n}\n\nfunction computeWorkspacesPackageRoot(): string | null {\n try {\n const require = createRequire(import.meta.url);\n return dirname(require.resolve(\"@skaile/workspaces/package.json\"));\n } catch {\n // Fall through to the workspace walk.\n }\n let dir: string;\n try {\n dir = dirname(fileURLToPath(import.meta.url));\n } catch {\n return null;\n }\n for (let i = 0; i < 8; i++) {\n const pkgPath = join(dir, \"package.json\");\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as { name?: string };\n if (pkg.name === \"@skaile/workspaces\") return dir;\n } catch {\n // Ignore malformed package.json and keep walking.\n }\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/**\n * Locate a content-asset directory inside the package. Prefers the in-repo\n * **source** dir `<pkgRoot>/<subdir>` when present — in a dev checkout it is the\n * full tree (e.g. `factory-assets/` keeps the connector `.ts` entry files that\n * `dist/` does not) — then the published `dist/<subdir>` copy (what\n * `files: [\"dist\"]` ships, the only one present after `npm i`). Returns `null`\n * when neither exists.\n *\n * `factory-assets/` resolves to the source tree in dev (code + skills + bundles)\n * and to `dist/factory-assets` post-install (compiled connectors + copied\n * manifests/skills/bundles).\n *\n * @param subdir - `\"factory-assets\"` | …\n * @docLink packages/core/concepts#resolve-factory-assets-root\n */\nexport function resolvePackagedAssetsDir(subdir: string): string | null {\n const root = resolveWorkspacesPackageRoot();\n if (!root) return null;\n for (const cand of [join(root, subdir), join(root, \"dist\", subdir)]) {\n if (existsSync(cand)) return cand;\n }\n return null;\n}\n\n// ─── Internals ────────────────────────────────────────────────────────────────\n\nconst CONNECTOR_SCAN_KINDS: ReadonlySet<string> = new Set([\"connector\"]);\n\nasync function populate(projectDir: string, target: RuntimeAssetsResult): Promise<void> {\n target.catalogEntries = [];\n target.implicitRefs = [];\n target.requiredNpmDeps = { required: [], optional: [] };\n target.warnings = [];\n\n const config = resolveSkWorkspaceConfig(projectDir);\n // Connector catalog scan runs over the project's declared sources[] (resolved\n // to their machine-cache clone paths) plus the implicit factory-assets repo.\n const repositories = buildEffectiveRepositories(sourcesToDeclarations(config.sources));\n const links = readLinks(projectDir);\n\n // Scan each repository for connector entries.\n for (const [name, decl] of Object.entries(repositories)) {\n const repoDir = await resolveRepoDir(name, decl, projectDir, links);\n if (!repoDir) {\n target.warnings.push({\n code: \"repo_unavailable\",\n name,\n message: repoUnavailableMessage(name, decl),\n });\n continue;\n }\n try {\n // Both factory layers carry the same `factory-assets` provenance — the\n // override repo is an internal scan-order device, not a distinct source.\n const repoName = name === FACTORY_ASSETS_OVERRIDE_REPO_NAME ? FACTORY_ASSETS_REPO_NAME : name;\n // Only connector descriptors are consumed here, so only that kind is\n // \"known\": typed manifests of any other kind are irrelevant to this scan.\n const scanned = await scanDirectory(repoDir, repoName, {\n knownKinds: CONNECTOR_SCAN_KINDS,\n onDiagnostic: () => {},\n });\n const entries = scanned.filter((e) => e.kind === \"connector\");\n target.catalogEntries.push(...entries);\n } catch (err) {\n target.warnings.push({\n code: \"repo_unavailable\",\n name,\n message: `Failed to scan repository \"${name}\" at ${repoDir}: ${\n err instanceof Error ? err.message : String(err)\n }`,\n });\n }\n }\n\n // De-duplicate by (kind, name), keeping the first occurrence. Scan order is\n // declared sources → env override → bundled baseline, so an env-supplied\n // connector manifest overrides the bundled one and the bundled one fills the\n // rest (the override layer can refresh built-in manifests in place).\n const seen = new Set<string>();\n target.catalogEntries = target.catalogEntries.filter((e) => {\n const key = `${e.kind}:${e.name}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n\n // Derive implicit refs from skaile.yaml connectors.\n for (const c of config.connectors ?? []) {\n target.implicitRefs.push({ kind: \"connector\", name: c.driver, declarationId: c.id });\n }\n\n // Validate refs and aggregate npm deps.\n const requiredSet = new Set<string>();\n const optionalSet = new Set<string>();\n for (const ref of target.implicitRefs) {\n const entry = findCatalogEntry(target.catalogEntries, ref);\n if (!entry) {\n target.warnings.push({\n code: \"missing_driver\",\n declarationId: ref.declarationId,\n name: ref.name,\n message:\n `Unknown ${ref.kind} driver \"${ref.name}\" referenced by ${ref.kind} \"${ref.declarationId}\". ` +\n `Run \\`skaile ${ref.kind} catalog\\` to see available drivers, ` +\n `or declare a repository in skaile.yaml that provides this driver.`,\n });\n continue;\n }\n const npm = (entry.metadata?.npm_deps ?? {}) as { required?: string[]; optional?: string[] };\n for (const p of npm.required ?? []) requiredSet.add(p);\n for (const p of npm.optional ?? []) optionalSet.add(p);\n }\n target.requiredNpmDeps.required = [...requiredSet];\n target.requiredNpmDeps.optional = [...optionalSet];\n}\n\n/**\n * Build the effective `repositories` map: caller's declarations first, then the\n * implicit built-in `factory-assets` repos. Each {@link factoryAssetRoots} layer\n * becomes its own repo, the env override inserted **before** the bundled\n * baseline so its connector entries win on the first-match dedup downstream.\n * When the package cannot be located at all, a path-less sentinel under\n * {@link FACTORY_ASSETS_REPO_NAME} drives the `repo_unavailable` warning.\n */\nfunction buildEffectiveRepositories(\n declared: Record<string, SourceDeclaration> | undefined,\n): Record<string, SourceDeclaration> {\n const result: Record<string, SourceDeclaration> = { ...(declared ?? {}) };\n const roots = factoryAssetRoots();\n if (roots.length === 0) {\n // Surface as a warning during scan rather than throwing here — let the\n // caller decide whether factory-assets is required. resolveRepoDir() /\n // repoUnavailableMessage re-discover the failure and emit it.\n if (!result[FACTORY_ASSETS_REPO_NAME]) result[FACTORY_ASSETS_REPO_NAME] = { path: \"\" };\n return result;\n }\n // override-first when both layers exist, so the env root's entries are scanned\n // (and matched) ahead of the bundled baseline.\n const keys =\n roots.length > 1\n ? [FACTORY_ASSETS_OVERRIDE_REPO_NAME, FACTORY_ASSETS_REPO_NAME]\n : [FACTORY_ASSETS_REPO_NAME];\n roots.forEach((dir, i) => {\n const key = keys[i] ?? `${FACTORY_ASSETS_REPO_NAME}:${i}`;\n if (!result[key]) result[key] = { path: dir };\n });\n return result;\n}\n\n/**\n * Resolve a repository declaration to an on-disk directory. Order:\n * 1. Linked override (`.skaile/links.yaml`).\n * 2. Local `path` — relative to `projectDir`.\n * 3. Cloned URL repo at `.skaile/cache/sources/<name>/` (must already exist).\n *\n * Returns `null` when none of these resolve. Does not clone.\n *\n * **Async and deadline-bounded since #454.** Every candidate here is a\n * project-relative or operator-supplied path, so a `sources[].path` of\n * `workspace/my-assets` resolves onto the rclone FUSE mount — the same tree the\n * scan that follows walks. Probing it with `existsSync`/`lstatSync` would park\n * the `skaile serve` event loop *before* the (now async) scan ever ran, which\n * would leave the H2 fix meaningless on the very declaration that triggers it.\n * A probe that misses its deadline reads as \"unavailable\", which is what the\n * caller already does with an absent path — it becomes a `repo_unavailable`\n * warning rather than a stall.\n */\nasync function resolveRepoDir(\n name: string,\n decl: SourceDeclaration,\n projectDir: string,\n links: Record<string, string>,\n): Promise<string | null> {\n // 1. Linked override\n const linked = links[name];\n if (linked && (await pathExists(linked))) return linked;\n\n // 2. Local path\n if (decl.path) {\n const resolved = resolvePath(projectDir, decl.path);\n return (await pathExists(resolved)) ? resolved : null;\n }\n\n // 3. URL repo cloned to project's .skaile/cache/sources/<name> — the\n // project-local clone dir (often a symlink into the global cache, which\n // lives at getGlobalCacheDir()); NOT the global clone root itself.\n if (decl.url) {\n const projectDest = join(projectDir, \".skaile\", \"cache\", \"sources\", name);\n // One `lstat` answers both questions the pre-#454 `existsSync` + `lstatSync`\n // pair asked, and `lstat` (not `stat`) keeps the \"a symlink into the global\n // cache counts\" behaviour intact.\n const found = await tryWithFsDeadline(\n `lstat ${projectDest}`,\n async () => {\n await lstat(projectDest);\n return true;\n },\n false,\n );\n return found ? projectDest : null;\n }\n\n return null;\n}\n\n/** Deadline-bounded `existsSync` replacement — a wedged mount reads as absent. */\nfunction pathExists(path: string): Promise<boolean> {\n return tryWithFsDeadline(\n `stat ${path}`,\n async () => {\n await stat(path);\n return true;\n },\n false,\n );\n}\n\nfunction repoUnavailableMessage(name: string, decl: SourceDeclaration): string {\n if (name === FACTORY_ASSETS_REPO_NAME && !decl.path && !decl.url) {\n return (\n `Cannot resolve the built-in factory-assets. ` +\n `Set SKAILE_FACTORY_ASSETS_DIR or ensure @skaile/workspaces is installed.`\n );\n }\n if (decl.url) {\n return `Repository \"${name}\" (${decl.url}) is not available. Register it as a Library Source via \\`skaile source add\\`.`;\n }\n if (decl.path) {\n return `Repository \"${name}\" path not found: ${decl.path}`;\n }\n return `Repository \"${name}\" has neither url nor path.`;\n}\n\nfunction findCatalogEntry(\n entries: RuntimeCatalogEntry[],\n query: { kind?: \"connector\"; name: string },\n): RuntimeCatalogEntry | undefined {\n if (query.kind) {\n return entries.find((e) => e.kind === query.kind && e.name === query.name);\n }\n const matches = entries.filter((e) => e.name === query.name);\n if (matches.length === 1) return matches[0];\n // 0 or >1 with no kind — caller must disambiguate.\n return undefined;\n}\n"]}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { resolveFragments, loadPromptExtensions } from './chunk-CGYEHQOX.js';
|
|
2
|
-
import { renderAgentToFramework, CODEX_IDENTITY_DIR } from './chunk-
|
|
3
|
-
import { SKILL_DESCRIPTION_PLACEHOLDER_PREFIX, SKILL_DESCRIPTION_PLACEHOLDER,
|
|
4
|
-
import { computeHash, applyPatch } from './chunk-
|
|
5
|
-
import {
|
|
6
|
-
import { resolveSkWorkspaceConfig, agentSourceCacheDir, resolveAgentDefinitionDir, AGENT_INSTANCE_ID_PATTERN } from './chunk-
|
|
2
|
+
import { renderAgentToFramework, CODEX_IDENTITY_DIR } from './chunk-HZXUXHIV.js';
|
|
3
|
+
import { SKILL_DESCRIPTION_PLACEHOLDER_PREFIX, SKILL_DESCRIPTION_PLACEHOLDER, PRESET_ITEM_PLACEHOLDER_REF, AGENT_BODY_PLACEHOLDER, PROMPT_BODY_PLACEHOLDER, CONTRACT_BODY_PLACEHOLDER, SKILL_BODY_PLACEHOLDER } from './chunk-ZCAJZ4B2.js';
|
|
4
|
+
import { computeHash, applyPatch } from './chunk-PBBPZYVG.js';
|
|
5
|
+
import { deployedDir, deployedBase, isDeployed, deployedPaths } from './chunk-PMECEZK3.js';
|
|
6
|
+
import { resolveSkWorkspaceConfig, agentSourceCacheDir, resolveAgentDefinitionDir, AGENT_INSTANCE_ID_PATTERN } from './chunk-ALEYHUC5.js';
|
|
7
7
|
import { DRIVER_TARGETS } from './chunk-CPSIPIX7.js';
|
|
8
|
-
import { isNonAssetDir, isNonAssetFile, listSkippedSymlinks } from './chunk-
|
|
9
|
-
import { parseFrontmatter } from './chunk-
|
|
10
|
-
import { assetRefToStr, parseAssetRefLoose } from './chunk-
|
|
8
|
+
import { listAssetFiles, isNonAssetDir, isNonAssetFile, isEnvFileName, listSkippedSymlinks, listEnvFiles } from './chunk-ZPWTOUTK.js';
|
|
9
|
+
import { parseFrontmatter } from './chunk-SBSA3IQA.js';
|
|
10
|
+
import { assetRefToStr, parseAssetRefLoose } from './chunk-BNMZVPYA.js';
|
|
11
11
|
import { spawnSync } from 'child_process';
|
|
12
|
-
import {
|
|
12
|
+
import { lstatSync, existsSync, statSync, mkdirSync, mkdtempSync, readdirSync, rmSync, unlinkSync, writeFileSync, readFileSync, symlinkSync, cpSync } from 'fs';
|
|
13
13
|
import { tmpdir } from 'os';
|
|
14
|
-
import { resolve, basename,
|
|
14
|
+
import { resolve, basename, join, dirname, sep, relative } from 'path';
|
|
15
15
|
import { parse, stringify } from 'yaml';
|
|
16
16
|
|
|
17
17
|
var AGENT_MD_FILE = "AGENT.md";
|
|
@@ -329,7 +329,7 @@ function manifestFileOf(provider, source) {
|
|
|
329
329
|
const hit = readdirSync(source).find((f) => provider.matchesPath(f));
|
|
330
330
|
return hit ? join(source, hit) : void 0;
|
|
331
331
|
}
|
|
332
|
-
function copyAsset(provider, entry, dest, onSkippedSymlink) {
|
|
332
|
+
function copyAsset(provider, entry, dest, onSkippedSymlink, onEnvFile) {
|
|
333
333
|
const source = entry.source;
|
|
334
334
|
clearDest(dest);
|
|
335
335
|
const manifestPath = manifestFileOf(provider, source);
|
|
@@ -338,7 +338,12 @@ function copyAsset(provider, entry, dest, onSkippedSymlink) {
|
|
|
338
338
|
recursive: true,
|
|
339
339
|
filter: (src) => {
|
|
340
340
|
if (src === source) return true;
|
|
341
|
-
if (isNonAssetDir(basename(src)) || isNonAssetFile(basename(src)))
|
|
341
|
+
if (isNonAssetDir(basename(src)) || isNonAssetFile(basename(src))) {
|
|
342
|
+
if (isEnvFileName(basename(src))) {
|
|
343
|
+
onEnvFile?.(entry, join(basename(source), relative(source, src)));
|
|
344
|
+
}
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
342
347
|
if (lstatSync(src).isSymbolicLink()) {
|
|
343
348
|
onSkippedSymlink?.(entry, join(basename(source), relative(source, src)));
|
|
344
349
|
return false;
|
|
@@ -357,9 +362,14 @@ function copyAsset(provider, entry, dest, onSkippedSymlink) {
|
|
|
357
362
|
mkdirSync(dirname(target), { recursive: true });
|
|
358
363
|
cpSync(join(assetRoot, rel), target);
|
|
359
364
|
}
|
|
360
|
-
if (
|
|
361
|
-
|
|
362
|
-
|
|
365
|
+
if (files.length > 1 || basename(assetRoot) === entry.name) {
|
|
366
|
+
if (onSkippedSymlink) {
|
|
367
|
+
for (const rel of listSkippedSymlinks(assetRoot)) {
|
|
368
|
+
onSkippedSymlink(entry, join(basename(assetRoot), rel));
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (onEnvFile) {
|
|
372
|
+
for (const rel of listEnvFiles(assetRoot)) onEnvFile(entry, join(basename(assetRoot), rel));
|
|
363
373
|
}
|
|
364
374
|
}
|
|
365
375
|
}
|
|
@@ -379,6 +389,37 @@ function symlinkAsset(provider, source, dest, name) {
|
|
|
379
389
|
symlinkSync(resolve(manifestPath), join(dest, basename(manifestPath)));
|
|
380
390
|
}
|
|
381
391
|
}
|
|
392
|
+
function deployedAssetDrift(entry, opts) {
|
|
393
|
+
const provider = opts.registry.getProvider(entry.kind);
|
|
394
|
+
const component = provider?.installTarget;
|
|
395
|
+
if (!provider || !component || component === "agent") return null;
|
|
396
|
+
const dest = deployedDir(
|
|
397
|
+
component,
|
|
398
|
+
entry.name,
|
|
399
|
+
opts.driverTarget ?? "claude-code",
|
|
400
|
+
opts.global ?? false,
|
|
401
|
+
opts.cwd
|
|
402
|
+
);
|
|
403
|
+
try {
|
|
404
|
+
const deployed = lstatSync(dest);
|
|
405
|
+
if (deployed.isSymbolicLink() || !deployed.isDirectory()) return null;
|
|
406
|
+
const manifestPath = manifestFileOf(provider, entry.source);
|
|
407
|
+
const filter = manifestPath ? provider.defaultFileFilter(manifestPath) : void 0;
|
|
408
|
+
const assetRoot = filter ? filter.assetRoot : entry.source;
|
|
409
|
+
const files = filter ? entry.files ?? filter.files : listAssetFiles(entry.source);
|
|
410
|
+
const modified = [];
|
|
411
|
+
for (const rel of files) {
|
|
412
|
+
const deployedFile = join(dest, rel);
|
|
413
|
+
if (!existsSync(deployedFile)) continue;
|
|
414
|
+
if (computeHash(join(assetRoot, rel)) !== computeHash(deployedFile)) modified.push(rel);
|
|
415
|
+
}
|
|
416
|
+
const expected = new Set(files);
|
|
417
|
+
const extra = listAssetFiles(dest).filter((rel) => !expected.has(rel));
|
|
418
|
+
return { modified, extra };
|
|
419
|
+
} catch {
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
382
423
|
function materializeAgentSource(provider, entry, srcDir, workspaceRoot, log) {
|
|
383
424
|
const dest = join(agentSourceCacheDir(workspaceRoot), entry.name);
|
|
384
425
|
try {
|
|
@@ -454,7 +495,7 @@ function deployEntry(entry, repositories, opts, log) {
|
|
|
454
495
|
symlinkAsset(provider, entry.source, dest, entry.name);
|
|
455
496
|
log(` symlink ${entry.kind}:${entry.name}`);
|
|
456
497
|
} else {
|
|
457
|
-
copyAsset(provider, entry, dest, opts.onSkippedSymlink);
|
|
498
|
+
copyAsset(provider, entry, dest, opts.onSkippedSymlink, opts.onEnvFile);
|
|
458
499
|
log(` copy ${entry.kind}:${entry.name}`);
|
|
459
500
|
}
|
|
460
501
|
return { deployed: true, changed: true };
|
|
@@ -497,7 +538,8 @@ function deployAll(resolved, repositories, patches, opts, log = noop) {
|
|
|
497
538
|
return false;
|
|
498
539
|
}
|
|
499
540
|
});
|
|
500
|
-
|
|
541
|
+
const strayFiles = deployedAssetDrift(entry, { ...opts, driverTarget, global: globalInstall, cwd })?.extra.length ?? 0;
|
|
542
|
+
if (manifestUnchanged && companionsUnchanged && strayFiles === 0) {
|
|
501
543
|
log(` already deployed: ${ref}`);
|
|
502
544
|
continue;
|
|
503
545
|
}
|
|
@@ -655,19 +697,11 @@ function createScaffold(name, kind, destDir, opts = {}) {
|
|
|
655
697
|
return { ok: false, path: `Directory '${name}' already exists in ${destDir}` };
|
|
656
698
|
}
|
|
657
699
|
mkdirSync(dest, { recursive: true });
|
|
658
|
-
const mdDescription = opts.description ?? (["agent", "contract", "prompt"].includes(kind) ? `${SKILL_DESCRIPTION_PLACEHOLDER_PREFIX} describe this ${kind}.` : SKILL_DESCRIPTION_PLACEHOLDER);
|
|
700
|
+
const mdDescription = opts.description ?? (["agent", "contract", "prompt", "flow", "preset"].includes(kind) ? `${SKILL_DESCRIPTION_PLACEHOLDER_PREFIX} describe this ${kind}.` : SKILL_DESCRIPTION_PLACEHOLDER);
|
|
659
701
|
if (kind === "preset") {
|
|
660
|
-
writeFileSync(
|
|
661
|
-
join(dest, `${name}.preset.yaml`),
|
|
662
|
-
presetTemplate(name, opts.description ?? PRESET_DESCRIPTION_PLACEHOLDER),
|
|
663
|
-
"utf8"
|
|
664
|
-
);
|
|
702
|
+
writeFileSync(join(dest, `${name}.preset.yaml`), presetTemplate(name, mdDescription), "utf8");
|
|
665
703
|
} else if (kind === "flow") {
|
|
666
|
-
writeFileSync(
|
|
667
|
-
join(dest, `${name}.flow.yaml`),
|
|
668
|
-
flowTemplate(name, opts.description ?? "Flow description"),
|
|
669
|
-
"utf8"
|
|
670
|
-
);
|
|
704
|
+
writeFileSync(join(dest, `${name}.flow.yaml`), flowTemplate(name, mdDescription), "utf8");
|
|
671
705
|
} else if (kind === "prompt") {
|
|
672
706
|
writeFileSync(
|
|
673
707
|
join(dest, `${name}.prompt.md`),
|
|
@@ -693,6 +727,6 @@ function createScaffold(name, kind, destDir, opts = {}) {
|
|
|
693
727
|
return { ok: true, path: dest };
|
|
694
728
|
}
|
|
695
729
|
|
|
696
|
-
export { SCAFFOLD_KINDS, canonicalEntryRef, createScaffold, deployAll, deployAsset, diffDeployedAgent, installAgent, installTargetOf, removeAsset };
|
|
697
|
-
//# sourceMappingURL=chunk-
|
|
698
|
-
//# sourceMappingURL=chunk-
|
|
730
|
+
export { SCAFFOLD_KINDS, canonicalEntryRef, createScaffold, deployAll, deployAsset, deployedAssetDrift, diffDeployedAgent, installAgent, installTargetOf, removeAsset };
|
|
731
|
+
//# sourceMappingURL=chunk-FH7W6TJ4.js.map
|
|
732
|
+
//# sourceMappingURL=chunk-FH7W6TJ4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../asset-manager/src/install-agent.ts","../asset-manager/src/installer.ts"],"names":["parseYaml","parseFrontmatter","join","basename","relative","resolve","existsSync","stringifyYaml","deployed"],"mappings":";;;;;;;;;;;;;;;;AA+CA,IAAM,aAAA,GAAgB,UAAA;AAGtB,SAAS,kBAAkB,KAAA,EAAoD;AAC7E,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG,OAAO,EAAE,OAAA,EAAS,KAAA,CAAM,GAAA,CAAI,MAAM,CAAA,EAAE;AAC9D,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,MAAM,UAAU,KAAA,CAAM,KAAA,CAAM,QAAQ,CAAA,CAAE,OAAO,OAAO,CAAA;AACpD,IAAA,OAAO,OAAA,CAAQ,MAAA,GAAS,CAAA,GAAI,EAAE,SAAQ,GAAI,MAAA;AAAA,EAC5C;AACA,EAAA,OAAO,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,GAAY,KAAA,GAAmC,MAAA;AAClF;AAOA,SAAS,oBAAoB,QAAA,EAAoE;AAC/F,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,QAAA,EAAU,aAAa,CAAA;AAC3C,EAAA,IAAI,CAAC,UAAA,CAAW,MAAM,CAAA,EAAG,OAAO,IAAA;AAChC,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,MAAM,IAAA,EAAK,GAAI,iBAAyB,YAAA,CAAa,MAAA,EAAQ,OAAO,CAAC,CAAA;AAC7E,IAAA,MAAM,OAAO,IAAA,CAAK,QAAA;AAClB,IAAA,MAAM,QAAA,GAAoC,EAAE,GAAG,IAAA,EAAK;AACpD,IAAA,IAAI,QAAA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AG,MAAM,CAAA;AAAA,EACjE,CAAA,MAAA,IAAW,SAAS,UAAA,EAAY;AAC9B,IAAA,aAAA;AAAA,MACEA,IAAAA,CAAK,MAAM,aAAa,CAAA;AAAA,MACxB,gBAAA,CAAiB,IAAA,EAAM,aAAA,EAAe,yBAAyB,CAAA;AAAA,MAC/D;AAAA,KACF;AAAA,EACF,CAAA,MAAO;AACL,IAAA,aAAA;AAAA,MACEA,IAAAA,CAAK,MAAM,UAAU,CAAA;AAAA,MACrB,gBAAA,CAAiB,IAAA,EAAM,aAAA,EAAe,sBAAsB,CAAA;AAAA,MAC5D;AAAA,KACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,EAAA,EAAI,IAAA,EAAM,IAAA,EAAM,IAAA,EAAK;AAChC","file":"chunk-FH7W6TJ4.js","sourcesContent":["/**\n * Agent installation — renders a GitAgent package (agent.yaml + SOUL.md + RULES.md)\n * into the framework-native format (`.claude/agents/<name>.md`, `.omp/agents/<name>/`,\n * `.codex/agents/<name>.toml`) and resolves abilities, contracts, fragments, and\n * prompt extensions from the workspace config along the way.\n *\n * System prompt phases (per agent):\n * 1. extends merge — inherit from parent agent.yaml if manifest.extends is set\n * 2. instance overrides — model / budget / lifecycle of the `skaile.yaml` instance\n * 3. ability refs — read SKILL.md frontmatter of the composed skills\n * 4. contract refs — locate CONTRACT.md files of the composed contracts\n * 5. fragments — resolve framework fragments (agent-mode, handoff, etc.)\n * 6. prompt-extensions — load per-project markdown extensions from skaile.yaml\n *\n * Used by `installer.ts` (the asset-install path, one agent asset under its own\n * name) and `install-instances.ts` (`skaile install`, one rendering per\n * `skaile.yaml` agent instance, named by the instance id). Sub-agents composed as\n * `composes: [{ kind: agent }]` (binding `delegate`, the default) are installed\n * flat (no nesting) in the same deploy directory; `binding: run` sub-agents are\n * host-executed and get no native file.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { basename, join, relative, resolve } from \"node:path\";\nimport type { AgentInstanceConfig, DriverTarget, SkWorkspaceConfig } from \"@skaile/workspaces/core\";\nimport {\n AGENT_INSTANCE_ID_PATTERN,\n DRIVER_TARGETS,\n parseFrontmatter as parseMarkdownFrontmatter,\n parseAssetRefLoose,\n resolveAgentDefinitionDir,\n} from \"@skaile/workspaces/core\";\nimport type { AgentComposeItem, AgentLifecycle } from \"@skaile/workspaces/types/manifests\";\nimport { parse as parseYaml } from \"yaml\";\nimport {\n type AbilityRef,\n type ConnectorRef,\n type ContractRef,\n type FragmentContext,\n loadPromptExtensions,\n resolveFragments,\n} from \"./fragments.js\";\nimport { type AgentManifest, type AgentRenderInput, renderAgentToFramework } from \"./renderers.js\";\n\n// ── Helpers ───────────────────────────────────────────────────────────────────\n\n/** Source file of the legacy markdown agent form: frontmatter + the system prompt as body. */\nconst AGENT_MD_FILE = \"AGENT.md\";\n\n/** A Claude-style `tools:` value (`\"Read, Grep\"` or a list) as the manifest's `tools.allowed`. */\nfunction toolsFromMarkdown(value: unknown): AgentManifest[\"tools\"] | undefined {\n if (Array.isArray(value)) return { allowed: value.map(String) };\n if (typeof value === \"string\") {\n const allowed = value.split(/[,\\s]+/).filter(Boolean);\n return allowed.length > 0 ? { allowed } : undefined;\n }\n return value && typeof value === \"object\" ? (value as AgentManifest[\"tools\"]) : undefined;\n}\n\n/**\n * The `AGENT.md` form of an agent as a manifest: the frontmatter, with the\n * Claude-style scalar `model:` / `tools:` shapes mapped to the manifest's\n * `model.preferred` / `tools.allowed`, and `metadata.version` read as `version`.\n */\nfunction readAgentMdManifest(agentDir: string): { manifest: AgentManifest; body: string } | null {\n const mdPath = join(agentDir, AGENT_MD_FILE);\n if (!existsSync(mdPath)) return null;\n try {\n const { data, body } = parseMarkdownFrontmatter(readFileSync(mdPath, \"utf-8\"));\n const meta = data.metadata as { version?: unknown } | undefined;\n const manifest: Record<string, unknown> = { ...data };\n if (manifest.version === undefined && meta?.version !== undefined) {\n manifest.version = String(meta.version);\n }\n if (typeof data.model === \"string\") manifest.model = { preferred: data.model };\n if (data.tools !== undefined) manifest.tools = toolsFromMarkdown(data.tools);\n return { manifest: manifest as AgentManifest, body };\n } catch {\n return null;\n }\n}\n\n/**\n * The agent's manifest: `agent.yaml`, else the frontmatter of the legacy\n * `AGENT.md`. `null` when the directory holds neither (or it cannot be parsed).\n */\nexport function readManifest(agentDir: string): AgentManifest | null {\n const yamlPath = join(agentDir, \"agent.yaml\");\n if (!existsSync(yamlPath)) return readAgentMdManifest(agentDir)?.manifest ?? null;\n try {\n return parseYaml(readFileSync(yamlPath, \"utf-8\")) as AgentManifest;\n } catch {\n return null;\n }\n}\n\nfunction readFile(agentDir: string, name: string): string | null {\n const p = join(agentDir, name);\n if (!existsSync(p)) return null;\n try {\n return readFileSync(p, \"utf-8\");\n } catch {\n return null;\n }\n}\n\n/**\n * The agent's identity text: `SOUL.md`; for an `AGENT.md` agent the markdown body\n * comes first, so a `SOUL.md` next to it extends the prompt rather than replacing it.\n */\nexport function readSoul(agentDir: string): string | null {\n const soul = readFile(agentDir, \"SOUL.md\");\n if (existsSync(join(agentDir, \"agent.yaml\"))) return soul;\n const body = readAgentMdManifest(agentDir)?.body;\n if (!body) return soul;\n return soul ? `${body}\\n\\n${soul}` : body;\n}\n\n/**\n * A name becomes a file or directory name under the deploy dir; one with a path\n * segment (`../x`, `a/b`) would write outside it. Refused, never sanitized.\n */\nfunction isSafeFileName(name: string): boolean {\n return name.length > 0 && name !== \".\" && name !== \"..\" && !/[\\\\/\\0]/.test(name);\n}\n\n/** Extract YAML frontmatter from a markdown file (content between first two --- delimiters). */\nfunction parseFrontmatter(content: string): Record<string, unknown> {\n const match = content.match(/^---\\n([\\s\\S]*?)\\n---/);\n if (!match) return {};\n try {\n return (parseYaml(match[1]!) as Record<string, unknown>) ?? {};\n } catch {\n return {};\n }\n}\n\n/**\n * Merge parent and child agent manifests.\n * Scalars: child wins. Arrays: parent + child, deduplicated (`composes` by\n * kind + ref + slot id, other arrays by value).\n */\nfunction mergeManifests(parent: AgentManifest, child: AgentManifest): AgentManifest {\n const result: AgentManifest = { ...parent };\n for (const [k, val] of Object.entries(child) as [keyof AgentManifest, unknown][]) {\n if (val === undefined) continue;\n const parentVal = result[k as keyof AgentManifest];\n if (k === \"composes\" && Array.isArray(val) && Array.isArray(parentVal)) {\n const merged = new Map<string, AgentComposeItem>();\n for (const item of [...parentVal, ...val] as AgentComposeItem[]) {\n merged.set(`${item.kind}\\u0000${item.ref}\\u0000${item.id ?? \"\"}`, item);\n }\n result.composes = [...merged.values()];\n } else if (Array.isArray(val) && Array.isArray(parentVal)) {\n (result as Record<string, unknown>)[k] = [...new Set([...parentVal, ...val])];\n } else {\n (result as Record<string, unknown>)[k] = val;\n }\n }\n return result;\n}\n\n/**\n * Phase 1: inherit scalars/arrays from a parent agent when `manifest.extends` is set.\n * Returns the (possibly merged) manifest; pushes a warning when the parent is missing.\n */\nfunction applyExtendsMerge(\n manifest: AgentManifest,\n srcDir: string,\n warnings: string[],\n): AgentManifest {\n if (!manifest.extends) return manifest;\n const parentDir = resolve(srcDir, manifest.extends);\n const parentManifest = readManifest(parentDir);\n if (parentManifest) {\n return mergeManifests(parentManifest, manifest);\n }\n warnings.push(\n `extends: parent agent not found at \"${manifest.extends}\" (from ${srcDir}) — skipping inheritance`,\n );\n return manifest;\n}\n\n/**\n * Phase 2: apply the instance's overrides to the asset's manifest — the model\n * selector, the turn budget (`budget.max_turns` → `runtime.max_turns`) and the\n * lifecycle. Returns the effective manifest and lifecycle.\n */\nfunction applyInstanceOverrides(\n manifest: AgentManifest,\n instance: AgentInstanceConfig | undefined,\n): { manifest: AgentManifest; lifecycle: AgentLifecycle } {\n const lifecycle = instance?.lifecycle ?? manifest.lifecycle ?? \"standing\";\n if (!instance) return { manifest, lifecycle };\n const effective: AgentManifest = { ...manifest, lifecycle };\n if (instance.model) {\n effective.model = { ...manifest.model, ...instance.model } as AgentManifest[\"model\"];\n }\n if (instance.budget?.max_turns !== undefined) {\n effective.runtime = { ...manifest.runtime, max_turns: instance.budget.max_turns };\n }\n return { manifest: effective, lifecycle };\n}\n\n/**\n * The name a composed asset is installed under: the asset name of a canonical\n * ref (`skill:@pub/name#1.0.0` → `name`), else the last path segment\n * (`./skills/name` → `name`).\n */\nfunction composeRefName(ref: string): string {\n const parsed = parseAssetRefLoose(ref);\n if (parsed) return parsed.name;\n const tail = ref.replace(/\\/+$/, \"\").split(\"/\").pop() ?? ref;\n return tail.replace(/^[a-z-]+:/, \"\").replace(/#.*$/, \"\") || ref;\n}\n\n/** Names of the composed items of `kind`, in declaration order, de-duplicated. */\nfunction composedNames(manifest: AgentManifest, kind: string): string[] {\n const names = (manifest.composes ?? [])\n .filter((item) => item.kind === kind)\n .map((item) => composeRefName(item.ref));\n return [...new Set(names)];\n}\n\n/**\n * The MCP servers an agent's `mcp-server` slots are bound to: the server the\n * instance's `connectors` map binds the slot id to, else the composed asset's\n * own name (the id its server is rendered under).\n */\nfunction boundMcpServers(\n manifest: AgentManifest,\n instance: AgentInstanceConfig | undefined,\n): string[] {\n const names = (manifest.composes ?? [])\n .filter((item) => item.kind === \"mcp-server\")\n .map(\n (item) => (item.id ? instance?.connectors?.[item.id] : undefined) ?? composeRefName(item.ref),\n );\n return [...new Set(names)];\n}\n\n/** Phase 3: resolve ability refs — read description from the installed SKILL.md of each composed skill. */\nfunction resolveAbilityRefs(\n manifest: AgentManifest,\n workspaceRoot: string,\n skillsRelDir: string,\n): AbilityRef[] {\n const abilityRefs: AbilityRef[] = [];\n for (const name of composedNames(manifest, \"skill\")) {\n const skillMdPath = join(workspaceRoot, skillsRelDir, name, \"SKILL.md\");\n if (!existsSync(skillMdPath)) continue;\n try {\n const fm = parseFrontmatter(readFileSync(skillMdPath, \"utf-8\"));\n const desc = typeof fm.description === \"string\" ? fm.description : undefined;\n if (desc) abilityRefs.push({ name, description: desc });\n } catch {\n // skip unreadable SKILL.md\n }\n }\n return abilityRefs;\n}\n\n/** Phase 4: resolve contract refs — locate the CONTRACT.md of each composed contract in the skills dir. */\nfunction resolveContractRefs(\n manifest: AgentManifest,\n workspaceRoot: string,\n skillsRelDir: string,\n): ContractRef[] {\n const contractRefs: ContractRef[] = [];\n for (const name of composedNames(manifest, \"contract\")) {\n const contractAbsPath = join(workspaceRoot, skillsRelDir, name, \"CONTRACT.md\");\n if (!existsSync(contractAbsPath)) continue;\n contractRefs.push({ name, relativePath: relative(workspaceRoot, contractAbsPath) });\n }\n return contractRefs;\n}\n\n/** A `kind: agent` composition item rendered as its own native sub-agent file. */\ninterface DelegateSubAgent {\n /** `composes[].ref` as written. */\n ref: string;\n /** Absolute path of the sub-agent's source directory. */\n srcDir: string;\n /** File name: the item's `as`, else the sub-agent's own `name`. */\n name: string;\n /** `composes[].as`, forwarded as the install name override. */\n alias: string | undefined;\n}\n\n/**\n * Phase 5a: the `delegate` sub-agents of an agent — its `kind: agent` items\n * whose binding is not `run` (`delegate` is the default for the harnesses that\n * render native agent files). Catalog refs resolve like `agents.<id>.ref`;\n * anything else is a path relative to the composing agent's directory. An\n * unresolvable item is skipped with a warning.\n */\nfunction resolveDelegates(\n manifest: AgentManifest,\n agentName: string,\n srcDir: string,\n workspaceRoot: string,\n warnings: string[],\n): DelegateSubAgent[] {\n const delegates: DelegateSubAgent[] = [];\n for (const item of manifest.composes ?? []) {\n if (item.kind !== \"agent\" || item.binding === \"run\") continue;\n let subSrc: string | undefined;\n try {\n subSrc =\n item.ref.startsWith(\"agent:\") || item.ref.startsWith(\"ai-assets://\")\n ? resolveAgentDefinitionDir(workspaceRoot, item.ref)\n : resolve(srcDir, item.ref);\n } catch (err) {\n warnings.push(\n `Sub-agent ${item.ref} (from ${agentName}): ${err instanceof Error ? err.message : String(err)}`,\n );\n continue;\n }\n if (!subSrc || !existsSync(subSrc)) {\n warnings.push(`Sub-agent source not found: ${item.ref} (from ${agentName})`);\n continue;\n }\n const sub = readManifest(subSrc);\n const name = item.as ?? sub?.name ?? basename(subSrc);\n // The name is a file name under the deploy dir: refuse anything that is not a plain id.\n if (typeof name !== \"string\" || !AGENT_INSTANCE_ID_PATTERN.test(name)) {\n warnings.push(\n `Sub-agent ${item.ref} (from ${agentName}): name ${JSON.stringify(name)} must match ${AGENT_INSTANCE_ID_PATTERN} — skipped`,\n );\n continue;\n }\n delegates.push({\n ref: item.ref,\n srcDir: subSrc,\n name,\n alias: item.as,\n });\n }\n return delegates;\n}\n\n/** Phase 5b: assemble the fragment context from the manifest, workspace config, and resolved refs. */\nfunction buildFragmentContext(\n subAgentNames: string[],\n driverTarget: string,\n skillsRelDir: string,\n wsConfig: SkWorkspaceConfig | undefined,\n abilityRefs: AbilityRef[],\n contractRefs: ContractRef[],\n): FragmentContext {\n const connectors: ConnectorRef[] = (wsConfig?.connectors ?? []).map((c) => ({\n id: c.id,\n driver: c.driver,\n access: c.access ?? \"read-write\",\n }));\n\n const agentsRelDir = DRIVER_TARGETS[driverTarget as DriverTarget]?.local.agent ?? \"\";\n\n return {\n framework: driverTarget,\n skillsDir: skillsRelDir,\n agentsDir: agentsRelDir,\n subAgents: subAgentNames,\n connectors,\n abilityRefs,\n contractRefs,\n };\n}\n\n// ── Core installation ─────────────────────────────────────────────────────────\n\n/**\n * Install a single GitAgent source directory using the appropriate renderer.\n *\n * When `includeSubAgents` is `true`, recursively installs the `delegate`\n * sub-agents (`composes: [{ kind: agent }]`) as separate flat agents in the\n * same deploy directory (no nesting). Tracks visited directories to prevent\n * infinite loops in sub-agent cycles.\n *\n * @param srcDir - Absolute path to the GitAgent source directory (contains `agent.yaml`).\n * @param agentDeployDir - Absolute path to the framework's agent deploy directory.\n * @param workspaceRoot - Absolute path to the workspace root.\n * @param driverTarget - Agent framework ID used to select the renderer.\n * @param skillsRelDir - Relative path to the installed skills dir (e.g. `\".claude/skills\"`).\n * @param nameOverride - Override name for the installed agent. Defaults to `manifest.name`;\n * an instance render passes the instance id.\n * @param includeSubAgents - When `true`, recursively install `delegate` sub-agents.\n * @param visited - Set of resolved source paths already processed (cycle guard).\n * @param wsConfig - Workspace config from `skaile.yaml` (fragments, connectors, extensions).\n * @param log - Optional logger callback for progress messages.\n * @param instance - The `skaile.yaml` instance being rendered; its model / budget / lifecycle\n * override the asset's and its `connectors` map binds the `mcp-server` slots.\n * @returns Object with `created` file paths (every rendered file), `changed` (the subset whose\n * bytes differ from what was deployed before) and `warnings` list.\n * @docLink packages/asset-manager/concepts#install-agent\n */\nexport function installAgent(\n srcDir: string,\n agentDeployDir: string,\n workspaceRoot: string,\n driverTarget: string,\n /** Relative path to the installed skills dir (e.g. \".claude/skills\") */\n skillsRelDir: string,\n nameOverride: string | undefined,\n includeSubAgents: boolean,\n visited: Set<string>,\n wsConfig: SkWorkspaceConfig | undefined,\n log?: (msg: string) => void,\n instance?: AgentInstanceConfig,\n): { created: string[]; changed: string[]; warnings: string[] } {\n const created: string[] = [];\n const changed: string[] = [];\n const warnings: string[] = [];\n\n const realSrc = resolve(srcDir);\n if (visited.has(realSrc)) return { created, changed, warnings };\n visited.add(realSrc);\n\n const initialManifest = readManifest(srcDir);\n if (!initialManifest) {\n warnings.push(`${srcDir} has no agent.yaml or AGENT.md — skipping (not an agent package)`);\n return { created, changed, warnings };\n }\n\n // Phase 1: extends merge — inherit scalars/arrays from parent agent\n // Phase 2: instance overrides — model / budget / lifecycle\n const { manifest, lifecycle } = applyInstanceOverrides(\n applyExtendsMerge(initialManifest, srcDir, warnings),\n instance,\n );\n\n const agentName = nameOverride ?? manifest.name ?? basename(srcDir);\n if (typeof agentName !== \"string\" || !isSafeFileName(agentName)) {\n warnings.push(\n `${srcDir}: agent name ${JSON.stringify(agentName)} is not a valid file name (no path separators) — skipping`,\n );\n return { created, changed, warnings };\n }\n\n log?.(`Installing git-agent: ${agentName} (${driverTarget})`);\n\n // Phase 3: resolve ability refs — read description from installed SKILL.md files\n const abilityRefs = resolveAbilityRefs(manifest, workspaceRoot, skillsRelDir);\n\n // Phase 4: resolve contract refs — locate CONTRACT.md files in the skills dir\n const contractRefs = resolveContractRefs(manifest, workspaceRoot, skillsRelDir);\n\n // Phase 5: delegate sub-agents, fragment context, framework fragments + prompt extensions\n const delegates = resolveDelegates(manifest, agentName, srcDir, workspaceRoot, warnings);\n const fragmentCtx = buildFragmentContext(\n delegates.map((d) => d.name),\n driverTarget,\n skillsRelDir,\n wsConfig,\n abilityRefs,\n contractRefs,\n );\n\n const frameworkFragments = resolveFragments(\n fragmentCtx,\n wsConfig?.agent?.fragments,\n workspaceRoot,\n );\n const promptExtensions = loadPromptExtensions(\n wsConfig?.agent?.[\"prompt-extensions\"],\n workspaceRoot,\n );\n\n const input: AgentRenderInput = {\n manifest,\n soul: readSoul(srcDir),\n rules: readFile(srcDir, \"RULES.md\"),\n duties: readFile(srcDir, \"DUTIES.md\"),\n agentName,\n agentDeployDir,\n workspaceRoot,\n abilityRefs,\n contractRefs,\n frameworkFragments,\n promptExtensions,\n lifecycle,\n skills: composedNames(manifest, \"skill\"),\n mcpServers: boundMcpServers(manifest, instance),\n };\n\n const result = renderAgentToFramework(input, driverTarget, log);\n created.push(...result.created);\n changed.push(...result.changed);\n warnings.push(...result.warnings);\n\n // Recursively install delegate sub-agents as flat top-level agents\n if (includeSubAgents) {\n for (const delegate of delegates) {\n const sub = installAgent(\n delegate.srcDir,\n agentDeployDir,\n workspaceRoot,\n driverTarget,\n skillsRelDir,\n delegate.alias, // undefined → the sub-agent's own name from its agent.yaml\n includeSubAgents,\n visited,\n wsConfig,\n log,\n );\n created.push(...sub.created);\n changed.push(...sub.changed);\n warnings.push(...sub.warnings);\n }\n }\n\n return { created, changed, warnings };\n}\n","/**\n * Asset deployment — copies assets into framework dirs by default (self-contained,\n * cache-safe, portable); `--link` opts into a symlink for the local-path dev loop.\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport {\n cpSync,\n existsSync,\n lstatSync,\n mkdirSync,\n mkdtempSync,\n readdirSync,\n rmSync,\n statSync,\n symlinkSync,\n unlinkSync,\n writeFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join, relative, resolve, sep } from \"node:path\";\nimport type {\n AiComponent,\n CatalogEntry,\n DriverTarget,\n SourceDeclaration,\n} from \"@skaile/workspaces/core\";\nimport {\n agentSourceCacheDir,\n applyPatch,\n assetRefToStr,\n computeHash,\n DRIVER_TARGETS,\n deployedBase,\n deployedDir,\n deployedPaths,\n isDeployed,\n resolveSkWorkspaceConfig,\n} from \"@skaile/workspaces/core\";\nimport {\n isEnvFileName,\n isNonAssetDir,\n isNonAssetFile,\n listAssetFiles,\n listEnvFiles,\n listSkippedSymlinks,\n} from \"@skaile/workspaces/core/publish-manifest\";\nimport {\n AGENT_BODY_PLACEHOLDER,\n CONTRACT_BODY_PLACEHOLDER,\n PRESET_ITEM_PLACEHOLDER_REF,\n PROMPT_BODY_PLACEHOLDER,\n SKILL_BODY_PLACEHOLDER,\n SKILL_DESCRIPTION_PLACEHOLDER,\n SKILL_DESCRIPTION_PLACEHOLDER_PREFIX,\n} from \"@skaile/workspaces/types/manifests\";\nimport type { IAssetKindProvider, IAssetKindRegistry } from \"@skaile/workspaces/plugins\";\nimport { stringify as stringifyYaml } from \"yaml\";\nimport { installAgent, readManifest, readSoul } from \"./install-agent.js\";\nimport { CODEX_IDENTITY_DIR, type Log } from \"./renderers.js\";\n\nexport type { Log } from \"./renderers.js\";\n\nconst noop: Log = () => {};\n\n/**\n * The printable canonical ref of a resolved entry — `kind:@publisher/name#version`,\n * the one ref grammar the CLI shows. An entry whose `publisher` is a clone key\n * carries the real ref in `canonicalRef`; with neither a `canonicalRef` nor a\n * publisher there is nothing to namespace it by, so it falls back to `kind:name`.\n */\nexport function canonicalEntryRef(entry: CatalogEntry): string {\n if (entry.canonicalRef) return entry.canonicalRef;\n const publisher = entry.publisher?.replace(/^@/, \"\");\n if (!publisher) return `${entry.kind}:${entry.name}`;\n return assetRefToStr({\n kind: entry.kind,\n name: entry.name,\n publisher,\n pin: entry.version || undefined,\n });\n}\n\n// ── Filesystem helpers ────────────────────────────────────────────────────────\n\nfunction clearDest(dest: string): void {\n try {\n const s = lstatSync(dest);\n if (s.isSymbolicLink()) unlinkSync(dest);\n else rmSync(dest, { recursive: true, force: true });\n } catch {}\n}\n\n/**\n * The harness component directory a kind installs into — the provider's\n * `installTarget` — or `undefined` for composition-only kinds (connector,\n * mcp-server, knowledge, persona, ruleset, preset) and unregistered kinds.\n * The registry is the only authority: there is no static list of deployable kinds.\n */\nexport function installTargetOf(\n registry: IAssetKindRegistry,\n kind: string,\n): AiComponent | undefined {\n return registry.getProvider(kind)?.installTarget;\n}\n\n/**\n * The manifest file of a resolved entry. `source` is normally the manifest file\n * itself; a directory source is searched for the provider's manifest.\n * `undefined` when `source` is a directory holding none.\n */\nfunction manifestFileOf(provider: IAssetKindProvider, source: string): string | undefined {\n if (!statSync(source).isDirectory()) return source;\n const hit = readdirSync(source).find((f) => provider.matchesPath(f));\n return hit ? join(source, hit) : undefined;\n}\n\n/**\n * A resolved entry ready to deploy: a {@link CatalogEntry} that may carry the\n * asset's authoritative file list.\n */\nexport interface DeployableEntry extends CatalogEntry {\n /**\n * Asset files relative to the manifest's directory. Set for store-staged\n * assets, whose verified pointer (not the provider's default filter) defines\n * what the asset is — a manifest-mode publish may list files the default filter\n * would not pick. Absent → the provider's `defaultFileFilter`.\n */\n files?: readonly string[];\n}\n\n/**\n * Copy an asset into `dest`: the entry's explicit `files` when it has them, else\n * exactly the files the provider's `defaultFileFilter` selects (the same set the\n * store publishes and hashes). A directory source without a recognisable\n * manifest is copied whole.\n */\nfunction copyAsset(\n provider: IAssetKindProvider,\n entry: DeployableEntry,\n dest: string,\n onSkippedSymlink?: (entry: DeployableEntry, path: string) => void,\n onEnvFile?: (entry: DeployableEntry, path: string) => void,\n): void {\n const source = entry.source;\n clearDest(dest);\n const manifestPath = manifestFileOf(provider, source);\n if (!manifestPath) {\n // Same ignore list as the content hash: leftovers and symlinks are not part of the asset.\n cpSync(source, dest, {\n recursive: true,\n filter: (src) => {\n if (src === source) return true;\n if (isNonAssetDir(basename(src)) || isNonAssetFile(basename(src))) {\n if (isEnvFileName(basename(src))) {\n onEnvFile?.(entry, join(basename(source), relative(source, src)));\n }\n return false;\n }\n if (lstatSync(src).isSymbolicLink()) {\n onSkippedSymlink?.(entry, join(basename(source), relative(source, src)));\n return false;\n }\n return true;\n },\n });\n return;\n }\n const filter = provider.defaultFileFilter(manifestPath);\n const assetRoot = filter.assetRoot;\n const files = entry.files ?? filter.files;\n mkdirSync(dest, { recursive: true });\n for (const rel of files) {\n const target = join(dest, rel);\n mkdirSync(dirname(target), { recursive: true });\n cpSync(join(assetRoot, rel), target);\n }\n // A lone manifest file shares its directory with other assets: only an asset that owns its\n // directory (several files, or a directory named after it) can say which links it drops.\n if (files.length > 1 || basename(assetRoot) === entry.name) {\n if (onSkippedSymlink) {\n for (const rel of listSkippedSymlinks(assetRoot)) {\n onSkippedSymlink(entry, join(basename(assetRoot), rel));\n }\n }\n if (onEnvFile) {\n for (const rel of listEnvFiles(assetRoot)) onEnvFile(entry, join(basename(assetRoot), rel));\n }\n }\n}\n\n/**\n * Symlink an asset (the `--link` dev-loop). A multi-file asset, or one living in\n * a directory named after it, links its whole directory; a lone manifest file\n * links into `dest/`.\n */\nfunction symlinkAsset(\n provider: IAssetKindProvider,\n source: string,\n dest: string,\n name: string,\n): void {\n clearDest(dest);\n mkdirSync(dirname(dest), { recursive: true });\n const manifestPath = manifestFileOf(provider, source);\n if (!manifestPath) {\n symlinkSync(resolve(source), dest);\n return;\n }\n const { assetRoot, files } = provider.defaultFileFilter(manifestPath);\n if (files.length > 1 || basename(assetRoot) === name) {\n symlinkSync(resolve(assetRoot), dest);\n } else {\n mkdirSync(dest, { recursive: true });\n symlinkSync(resolve(manifestPath), join(dest, basename(manifestPath)));\n }\n}\n\n/** What differs between a deployed asset directory and the bytes a deploy of the entry writes. */\nexport interface DeployedDrift {\n /** Deployed files (relative to the deployed asset directory) whose bytes differ from the source. */\n modified: string[];\n /** Files in the deployed asset directory that the asset does not ship. */\n extra: string[];\n}\n\n/**\n * Compare the deployed copy of `entry` with the bytes a copy deploy writes from its source: the\n * same file set {@link copyAsset} copies, so a tool leftover (`__pycache__/`, `.env`) in the\n * deployed directory is not drift. `null` when there is nothing to compare: a kind that is\n * not copied into a harness directory (composition-only, or an agent, which is rendered), no\n * deployed directory, a symlinked deploy (`--link`) or an unreadable source.\n */\nexport function deployedAssetDrift(\n entry: DeployableEntry,\n opts: Pick<DeployOptions, \"registry\" | \"driverTarget\" | \"global\" | \"cwd\">,\n): DeployedDrift | null {\n const provider = opts.registry.getProvider(entry.kind);\n const component = provider?.installTarget;\n if (!provider || !component || component === \"agent\") return null;\n const dest = deployedDir(\n component,\n entry.name,\n opts.driverTarget ?? \"claude-code\",\n opts.global ?? false,\n opts.cwd,\n );\n try {\n const deployed = lstatSync(dest);\n if (deployed.isSymbolicLink() || !deployed.isDirectory()) return null;\n const manifestPath = manifestFileOf(provider, entry.source);\n const filter = manifestPath ? provider.defaultFileFilter(manifestPath) : undefined;\n const assetRoot = filter ? filter.assetRoot : entry.source;\n const files = filter ? (entry.files ?? filter.files) : listAssetFiles(entry.source);\n const modified: string[] = [];\n for (const rel of files) {\n const deployedFile = join(dest, rel);\n if (!existsSync(deployedFile)) continue;\n if (computeHash(join(assetRoot, rel)) !== computeHash(deployedFile)) modified.push(rel);\n }\n const expected = new Set(files);\n const extra = listAssetFiles(dest).filter((rel) => !expected.has(rel));\n return { modified, extra };\n } catch {\n return null;\n }\n}\n\n// ── Deploy options ───────────────────────────────────────────────────────────\n\n/**\n * Options controlling where and how assets are deployed.\n *\n * @docLink packages/asset-manager/api-reference#installer\n */\nexport interface DeployOptions {\n /** Asset-kind registry — decides, per kind, the harness install target and file set. */\n registry: IAssetKindRegistry;\n /** Agent framework to target (determines framework-specific directory layout). Defaults to `\"claude-code\"`. */\n driverTarget?: DriverTarget;\n /** When `true`, deploy into the global Skaile cache rather than a project workspace. */\n global?: boolean;\n /** Absolute path to the workspace root. Defaults to `process.cwd()`. */\n cwd?: string;\n /**\n * Opt into a symlink (the author dev-loop) instead of a copy — honoured only\n * when the source has a real local path. Machine-local / not for committing;\n * for store/factory sources (no stable local path) it is a no-op (still copy).\n */\n link?: boolean;\n /**\n * Called once per symlink inside an asset's own directory that a copy deploy\n * leaves out (symlinks are not part of an asset), with the asset entry and the\n * path of the link relative to the asset directory's parent (`<dir>/<rel>`).\n */\n onSkippedSymlink?: (entry: DeployableEntry, path: string) => void;\n /**\n * Called once per `.env` / `.env.*` file inside an asset's own directory that a copy deploy\n * leaves out (local secrets are never part of an asset), with the path relative to the asset\n * directory's parent.\n */\n onEnvFile?: (entry: DeployableEntry, path: string) => void;\n}\n\n/**\n * Keep the agent's source (`agent.yaml`, `SOUL.md`, …) under\n * `<project>/.skaile/cache/agents/<name>/`, the one place `agents.<id>.ref:\n * agent:@pub/name` resolves an added library / source / store agent from: the\n * deployed copy is a rendering (`.claude/agents/<name>.md`) that has lost the\n * composition, triggers and slots an instance needs. An `AGENT.md` agent is stored\n * in the `agent.yaml` + `SOUL.md` form so every instance consumer reads one shape.\n * A failure is logged, never fatal: the rendered agent is deployed either way.\n */\nfunction materializeAgentSource(\n provider: IAssetKindProvider,\n entry: DeployableEntry,\n srcDir: string,\n workspaceRoot: string,\n log: Log,\n): void {\n const dest = join(agentSourceCacheDir(workspaceRoot), entry.name);\n try {\n copyAsset(provider, entry, dest);\n if (existsSync(join(dest, \"agent.yaml\"))) return;\n const manifest = readManifest(srcDir);\n if (!manifest) return;\n writeFileSync(\n join(dest, \"agent.yaml\"),\n stringifyYaml({ ...manifest, name: manifest.name ?? entry.name }),\n \"utf8\",\n );\n const soul = readSoul(srcDir);\n if (soul) writeFileSync(join(dest, \"SOUL.md\"), `${soul}\\n`, \"utf8\");\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err);\n log(` warn: could not keep the source of agent ${entry.name}: ${reason}`);\n }\n}\n\n// ── Deploy / remove ──────────────────────────────────────────────────────────\n\n/**\n * Deploy a single asset to the framework-specific directory.\n *\n * Copies by default — self-contained, cache-safe, and portable, so a deployed\n * asset survives a `cache clean` of its source and a committed `.claude/` stays\n * machine-independent. `opts.link` opts into a symlink (the live dev-loop), but\n * only when the source has a real local path; store/factory sources (no stable\n * local path) ignore it and still copy. Agents are rendered via the enriched\n * `installAgent` path which resolves abilities, contracts, and framework\n * fragments before writing the native agent file.\n *\n * @param entry - Catalog entry describing the asset to deploy.\n * @param repositories - Repository declarations from `skaile.yaml` (used to\n * determine whether the source is a local path or a remote clone).\n * @param opts - Deployment target options.\n * @param log - Optional logger callback for progress messages.\n * @returns `true` when the asset was deployed successfully.\n * @docLink packages/asset-manager/api-reference#installer\n */\nexport function deployAsset(\n entry: DeployableEntry,\n repositories: Record<string, SourceDeclaration>,\n opts: DeployOptions,\n log: Log = noop,\n): boolean {\n return deployEntry(entry, repositories, opts, log).deployed;\n}\n\n/**\n * {@link deployAsset} plus whether the deploy altered anything on disk. A copied asset always\n * counts as changed; an agent is re-rendered every time but counts as changed only when a\n * rendered file's bytes differ from the deployed one (an unchanged agent is left untouched).\n */\nfunction deployEntry(\n entry: DeployableEntry,\n repositories: Record<string, SourceDeclaration>,\n opts: DeployOptions,\n log: Log,\n): { deployed: boolean; changed: boolean } {\n const driverTarget = opts.driverTarget ?? \"claude-code\";\n const globalInstall = opts.global ?? false;\n const cwd = opts.cwd;\n\n // Composition-only kinds (no `installTarget`) never land in a harness dir:\n // they are fetched + verified into the store cache and composed at session start.\n const provider = opts.registry.getProvider(entry.kind);\n const component = provider?.installTarget;\n if (!provider || !component) return { deployed: true, changed: false };\n\n // Agents need framework-specific rendering via the enriched installAgent path\n if (component === \"agent\") {\n const workspaceRoot = cwd ?? process.cwd();\n const agentDeployDir = deployedBase(\n component,\n driverTarget as DriverTarget,\n globalInstall,\n cwd,\n );\n const targetMap = DRIVER_TARGETS[driverTarget as DriverTarget];\n const skillsRelDir = targetMap?.local.skill ?? \"\";\n const wsConfig = resolveSkWorkspaceConfig(workspaceRoot);\n const srcDir = statSync(entry.source).isDirectory() ? entry.source : dirname(entry.source);\n const result = installAgent(\n srcDir,\n agentDeployDir,\n workspaceRoot,\n driverTarget,\n skillsRelDir,\n entry.name,\n /* includeSubAgents */ true,\n new Set<string>(),\n wsConfig,\n log,\n );\n for (const w of result.warnings) log(` warn: ${w}`);\n if (result.created.length > 0) {\n let changed = result.changed.length > 0;\n // An `AGENT.md` agent used to deploy raw into `<base>/<name>/AGENT.md`, which no\n // harness but omp (whose rendering is that directory) reads: drop the stale copy.\n const staleRawCopy = join(agentDeployDir, entry.name);\n if (driverTarget !== \"omp\" && existsSync(staleRawCopy)) {\n clearDest(staleRawCopy);\n changed = true;\n }\n if (!globalInstall) materializeAgentSource(provider, entry, srcDir, workspaceRoot, log);\n return { deployed: true, changed };\n }\n // Fall through to raw deploy if renderer produces no files (unsupported framework, etc.)\n }\n\n const dest = deployedDir(component, entry.name, driverTarget, globalInstall, cwd);\n mkdirSync(dirname(dest), { recursive: true });\n\n // Symlink only on explicit opt-in AND when the source has a real local path.\n // Factory sources have a `path` (the bundled dir under node_modules, replaced\n // on every upgrade) but no stable dev-loop, so they always copy. Default copy\n // keeps deploys cache-safe and portable.\n const repoDecl = entry.publisher ? repositories[entry.publisher] : undefined;\n const hasLocalPath = repoDecl?.path != null && repoDecl.factory !== true;\n\n if (opts.link === true && hasLocalPath) {\n symlinkAsset(provider, entry.source, dest, entry.name);\n log(` symlink ${entry.kind}:${entry.name}`);\n } else {\n copyAsset(provider, entry, dest, opts.onSkippedSymlink, opts.onEnvFile);\n log(` copy ${entry.kind}:${entry.name}`);\n }\n return { deployed: true, changed: true };\n}\n\n/**\n * Deploy all resolved assets, applying patches where configured.\n *\n * Already-deployed assets are skipped unless their deployed manifest content differs\n * from the source. This handles copies that have gone stale after a source update.\n * In copy mode (the default, `!opts.link`) an existing **symlink** dest is healed:\n * it is removed and re-deployed as a real copy, so an old/legacy symlink deploy is\n * silently upgraded. With `opts.link` an existing symlink is left alone.\n *\n * @param resolved - Catalog entries to deploy (output of `resolveAll`).\n * @param repositories - Repository declarations from `skaile.yaml`.\n * @param patches - Map of `kind:name` → patch file path for patch application.\n * @param opts - Deployment target options.\n * @param log - Optional logger callback for progress messages.\n * @returns Canonical refs (`kind:@publisher/name[#version]`; bare `kind:name`\n * when the entry carries no publisher) of the assets newly deployed in this call.\n * @docLink packages/asset-manager/api-reference#installer\n */\nexport function deployAll(\n resolved: DeployableEntry[],\n repositories: Record<string, SourceDeclaration>,\n patches: Record<string, string>,\n opts: DeployOptions,\n log: Log = noop,\n): string[] {\n const deployed: string[] = [];\n const driverTarget = opts.driverTarget ?? \"claude-code\";\n const globalInstall = opts.global ?? false;\n const cwd = opts.cwd;\n\n for (const entry of resolved) {\n // Skip composition-only kinds (no `installTarget`) — they live in the store\n // cache and are composed at session start, never copied into a harness dir.\n const component = installTargetOf(opts.registry, entry.kind);\n if (!component) continue;\n\n const ref = `${entry.kind}:${entry.name}`;\n\n // Agents are compiled artifacts: always re-rendered, never skipped on a manifest hash\n // (and a stale raw `<name>/AGENT.md` copy of the old layout must be replaced, not kept).\n if (\n component !== \"agent\" &&\n isDeployed(component, entry.name, driverTarget, globalInstall, cwd)\n ) {\n // Compare the deployed manifest file against the source to detect stale copies.\n // For symlinks the deployed path resolves through to the source file, so hashes\n // always match — symlinked installs are never needlessly re-linked.\n const dest = deployedDir(component, entry.name, driverTarget, globalInstall, cwd);\n // Heal: in copy mode an existing symlink dest is left to fall through to a\n // real copy below (cache-safe + portable) — bypass the hash skip entirely.\n // With --link a symlink dest is intentional, so it takes the normal skip path.\n let destIsSymlink = false;\n try {\n destIsSymlink = lstatSync(dest).isSymbolicLink();\n } catch {}\n const healSymlink = destIsSymlink && opts.link !== true;\n // Surface the one-time symlink→copy migration so an author who relied on a\n // live symlink dev-loop knows why edits stopped reflecting.\n if (healSymlink) log(` healed symlink → copy: ${ref} (use --link for the dev-loop)`);\n\n if (!healSymlink) {\n const manifestName = basename(entry.source);\n const deployedManifest = join(dest, manifestName);\n // isDeployed() only lstats the dir, so a present-but-empty dir (manifest\n // file deleted) reads as deployed. A missing manifest must never count as\n // \"already deployed\" — fall through to re-deploy instead of skipping.\n // (existsSync follows symlinks, so for symlinked installs the manifest\n // resolves through to the live source and the hash check below still\n // skips them.)\n if (existsSync(deployedManifest)) {\n let manifestUnchanged: boolean;\n try {\n manifestUnchanged = computeHash(entry.source) === computeHash(deployedManifest);\n } catch {\n // Deployed manifest unreadable (e.g. agent rendered to a different path) — skip\n log(` already deployed: ${ref}`);\n continue;\n }\n // Every other file the deploy writes must be present and identical too —\n // the manifest alone misses a deleted or stale companion (`.gitignore`,\n // `resources/`, `scripts/`) the copy below would restore. A companion\n // that cannot be compared counts as changed, so it is healed, not skipped.\n const srcRoot = dirname(entry.source);\n const companionsUnchanged = (entry.files ?? [])\n .filter((rel) => rel !== manifestName)\n .every((rel) => {\n const deployed = join(dest, rel);\n try {\n return (\n existsSync(deployed) && computeHash(join(srcRoot, rel)) === computeHash(deployed)\n );\n } catch {\n return false;\n }\n });\n // A file the asset does not ship (a stray `extra.txt`) is drift too: the copy below\n // clears the directory, so a repeat install restores the asset exactly.\n const strayFiles =\n deployedAssetDrift(entry, { ...opts, driverTarget, global: globalInstall, cwd })?.extra\n .length ?? 0;\n if (manifestUnchanged && companionsUnchanged && strayFiles === 0) {\n log(` already deployed: ${ref}`);\n continue;\n }\n log(` updating: ${ref} (content changed)`);\n // fall through to redeploy\n }\n }\n }\n\n // An agent is re-rendered every time; it is reported as deployed only when a rendered file\n // changed, so a repeat install leaves it (and the report) alone.\n const { changed } = deployEntry(entry, repositories, opts, log);\n if (changed) deployed.push(canonicalEntryRef(entry));\n\n // Apply patch if configured\n const patchFile = patches[ref];\n if (patchFile && existsSync(patchFile)) {\n const dest = deployedDir(component, entry.name, driverTarget, globalInstall, cwd);\n if (applyPatch(dest, patchFile)) {\n log(` patched ${ref}`);\n } else {\n log(` patch failed for ${ref}`);\n }\n }\n }\n\n return deployed;\n}\n\n/**\n * Unified diff from a deployed agent to its source, `-` lines in the deployed copy only and `+`\n * lines in the source only. An agent is a rendering, not a copy, so the source is rendered the way\n * {@link deployAsset} renders it (same renderer, same workspace context) into a scratch directory\n * and that is compared with what the harness holds: `<name>.md` for claude-code, `<name>.toml`\n * plus the `skaile-agents/<name>.md` identity for codex, the `<name>/` directory for omp.\n *\n * @param entry - The agent's catalog entry (`source` is its `agent.yaml` / `AGENT.md`).\n * @param opts - Deployment target options (must match the options used at install time).\n * @returns `null` when none of the agent's rendered files is deployed, else the diff text\n * (`\"\"` when the deployed agent matches its source).\n * @throws When `diff(1)` itself fails (exit status other than 0/1).\n */\nexport function diffDeployedAgent(entry: DeployableEntry, opts: DeployOptions): string | null {\n const driverTarget = opts.driverTarget ?? \"claude-code\";\n const workspaceRoot = opts.cwd ?? process.cwd();\n const deployedAgents = deployedBase(\"agent\", driverTarget, opts.global ?? false, opts.cwd);\n const scratch = mkdtempSync(join(tmpdir(), \"skaile-diff-agent-\"));\n try {\n const renderedAgents = join(scratch, \"agents\");\n const srcDir = statSync(entry.source).isDirectory() ? entry.source : dirname(entry.source);\n const rendered = installAgent(\n srcDir,\n renderedAgents,\n workspaceRoot,\n driverTarget,\n DRIVER_TARGETS[driverTarget]?.local.skill ?? \"\",\n entry.name,\n /* includeSubAgents */ false,\n new Set<string>(),\n resolveSkWorkspaceConfig(workspaceRoot),\n );\n if (rendered.created.length === 0) return null;\n\n // Each rendered top-level item pairs with the deployed item of the same name.\n const pairs: Array<[from: string, to: string]> = [];\n for (const [renderedRoot, deployedRoot] of [\n [renderedAgents, deployedAgents],\n [join(scratch, CODEX_IDENTITY_DIR), join(dirname(deployedAgents), CODEX_IDENTITY_DIR)],\n ] as const) {\n if (!existsSync(renderedRoot)) continue;\n for (const item of readdirSync(renderedRoot)) {\n pairs.push([join(deployedRoot, item), join(renderedRoot, item)]);\n }\n }\n if (!pairs.some(([from]) => existsSync(from))) return null;\n\n const diffs: string[] = [];\n for (const [from, to] of pairs) {\n const r = spawnSync(\"diff\", [\"-ruN\", from, to], { encoding: \"utf8\" });\n if (r.status === 1) diffs.push(r.stdout);\n else if (r.status !== 0) {\n throw new Error(\n `diff failed for agent:${entry.name}: ${r.stderr || r.error?.message || \"unknown error\"}`,\n );\n }\n }\n return diffs.join(\"\").split(`${scratch}${sep}`).join(`rendered${sep}`);\n } finally {\n rmSync(scratch, { recursive: true, force: true });\n }\n}\n\n/**\n * Remove a deployed asset from the framework directory.\n *\n * Removes symlinks with `unlink`; removes copied directories with `rm -rf`.\n *\n * @param kind - Asset kind (`skill`, `agent`, `prompt`, `flow`, `contract`).\n * @param name - Asset name as registered in the catalog.\n * @param opts - Deployment target options (must match the options used at install time).\n * @returns `true` if the asset existed and was removed; `false` if it was not deployed.\n * @docLink packages/asset-manager/api-reference#installer\n */\nexport function removeAsset(kind: string, name: string, opts: DeployOptions): boolean {\n const driverTarget = opts.driverTarget ?? \"claude-code\";\n const globalInstall = opts.global ?? false;\n const cwd = opts.cwd;\n\n // Composition-only kinds have no harness dir — never resolve (and delete) one.\n const component = installTargetOf(opts.registry, kind);\n if (!component) return false;\n let removed = false;\n for (const dest of deployedPaths(component, name, driverTarget, globalInstall, cwd)) {\n try {\n const s = lstatSync(dest);\n if (s.isSymbolicLink()) unlinkSync(dest);\n else rmSync(dest, { recursive: true, force: true });\n removed = true;\n } catch {\n // not deployed at this path\n }\n }\n if (component === \"agent\") {\n // The Codex identity file and the kept source live beside the deployed agent.\n const agentDir = deployedBase(component, driverTarget, globalInstall, cwd);\n const extras = [join(dirname(agentDir), CODEX_IDENTITY_DIR, `${name}.md`)];\n if (!globalInstall) extras.push(join(agentSourceCacheDir(cwd ?? process.cwd()), name));\n for (const extra of extras) {\n if (existsSync(extra)) {\n rmSync(extra, { recursive: true, force: true });\n removed = true;\n }\n }\n }\n return removed;\n}\n\n// ── Scaffold ─────────────────────────────────────────────────────────────────\n\n/** Markdown-marker scaffold (SKILL.md / CONTRACT.md / `*.prompt.md`); `body` is the kind's placeholder. */\nfunction markdownTemplate(name: string, description: string, body: string): string {\n // JSON.stringify yields a valid YAML double-quoted scalar, so any\n // user-supplied description (colons, quotes, `#`) survives the round-trip.\n return `---\nname: \"${name}\"\ndescription: ${JSON.stringify(description)}\nmetadata:\n version: \"0.1.0\"\n---\n\n# ${name}\n\n${body}\n`;\n}\n\n/** `agent.yaml` (spec 0.2) scaffold; the system prompt lives in the `SOUL.md` next to it. */\nfunction agentTemplate(name: string, description: string): string {\n return `spec_version: \"0.2\"\nname: \"${name}\"\nversion: 0.1.0\ndescription: ${JSON.stringify(description)}\nlifecycle: standing\n`;\n}\n\nfunction soulTemplate(name: string): string {\n return `# ${name}\n\n${AGENT_BODY_PLACEHOLDER}\n`;\n}\n\nfunction presetTemplate(name: string, description: string): string {\n return `name: ${name}\ndescription: ${JSON.stringify(description)}\nversion: 0.1.0\nitems:\n - ref: ${PRESET_ITEM_PLACEHOLDER_REF}\n`;\n}\n\nfunction flowTemplate(name: string, description: string): string {\n return `id: \"${name}\"\nversion: \"0.1.0\"\nname: \"${name}\"\ndescription: ${JSON.stringify(description)}\n\nglobals:\n approval_mode: checkpoint\n\nnodes: []\n`;\n}\n\n/** Asset kinds {@link createScaffold} has a real template for. */\nexport const SCAFFOLD_KINDS = [\"skill\", \"agent\", \"prompt\", \"flow\", \"preset\", \"contract\"] as const;\n\n/** Options for {@link createScaffold}. */\nexport interface ScaffoldOptions {\n /**\n * Description written into the manifest. Omitted: every kind gets a\n * `TODO:` placeholder that `skaile validate` rejects until it is replaced.\n */\n description?: string;\n}\n\n/**\n * Create a minimal scaffold directory for a new asset.\n *\n * Writes the appropriate manifest file (`SKILL.md`, `agent.yaml` + `SOUL.md`, `CONTRACT.md`,\n * `<name>.preset.yaml`, `<name>.flow.yaml`, or `<name>.prompt.md`) inside a\n * new `<destDir>/<name>/` directory.\n *\n * @param name - Asset name (also used as the directory name).\n * @param kind - Asset kind: `skill` | `agent` | `preset` | `flow` | `prompt` | `contract`.\n * @param destDir - Parent directory to create the asset in.\n * @param opts - Optional scaffold content ({@link ScaffoldOptions}).\n * @returns `{ ok: true, path }` on success, `{ ok: false, path: errorMessage }` if the\n * directory already exists or `kind` is not one of {@link SCAFFOLD_KINDS}\n * (`Cannot scaffold kind \"<kind>\". Expected: ...`); nothing is created then.\n * @docLink packages/asset-manager/api-reference#installer\n */\nexport function createScaffold(\n name: string,\n kind: string,\n destDir: string,\n opts: ScaffoldOptions = {},\n): { ok: boolean; path: string } {\n if (!(SCAFFOLD_KINDS as readonly string[]).includes(kind)) {\n return {\n ok: false,\n path: `Cannot scaffold kind \"${kind}\". Expected: ${SCAFFOLD_KINDS.join(\", \")}.`,\n };\n }\n const dest = join(destDir, name);\n if (existsSync(dest)) {\n return { ok: false, path: `Directory '${name}' already exists in ${destDir}` };\n }\n mkdirSync(dest, { recursive: true });\n\n const mdDescription =\n opts.description ??\n ([\"agent\", \"contract\", \"prompt\", \"flow\", \"preset\"].includes(kind)\n ? `${SKILL_DESCRIPTION_PLACEHOLDER_PREFIX} describe this ${kind}.`\n : SKILL_DESCRIPTION_PLACEHOLDER);\n\n if (kind === \"preset\") {\n writeFileSync(join(dest, `${name}.preset.yaml`), presetTemplate(name, mdDescription), \"utf8\");\n } else if (kind === \"flow\") {\n writeFileSync(join(dest, `${name}.flow.yaml`), flowTemplate(name, mdDescription), \"utf8\");\n } else if (kind === \"prompt\") {\n writeFileSync(\n join(dest, `${name}.prompt.md`),\n markdownTemplate(name, mdDescription, PROMPT_BODY_PLACEHOLDER),\n \"utf8\",\n );\n } else if (kind === \"agent\") {\n writeFileSync(join(dest, \"agent.yaml\"), agentTemplate(name, mdDescription), \"utf8\");\n writeFileSync(join(dest, \"SOUL.md\"), soulTemplate(name), \"utf8\");\n } else if (kind === \"contract\") {\n writeFileSync(\n join(dest, \"CONTRACT.md\"),\n markdownTemplate(name, mdDescription, CONTRACT_BODY_PLACEHOLDER),\n \"utf8\",\n );\n } else {\n writeFileSync(\n join(dest, \"SKILL.md\"),\n markdownTemplate(name, mdDescription, SKILL_BODY_PLACEHOLDER),\n \"utf8\",\n );\n }\n\n return { ok: true, path: dest };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { findAiAssetsRoot } from './chunk-
|
|
1
|
+
import { findAiAssetsRoot } from './chunk-T42WRQ4O.js';
|
|
2
2
|
import { okJson, err, ok } from './chunk-X5YPJV4N.js';
|
|
3
|
-
import { parseSkillRequirements, validateRequirements, buildRequiresPreamble, parseSkillFrontmatter } from './chunk-
|
|
3
|
+
import { parseSkillRequirements, validateRequirements, buildRequiresPreamble, parseSkillFrontmatter } from './chunk-X77SUM4P.js';
|
|
4
4
|
import { findKindDirs } from './chunk-A2ULN3KX.js';
|
|
5
5
|
import fs from 'fs/promises';
|
|
6
6
|
import path from 'path';
|
|
@@ -136,5 +136,5 @@ async function skillGetPreamble(projectDir, skillId) {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
export { skillCheckRequirements, skillGetPreamble, skillList, skillSearch, skillShow };
|
|
139
|
-
//# sourceMappingURL=chunk-
|
|
140
|
-
//# sourceMappingURL=chunk-
|
|
139
|
+
//# sourceMappingURL=chunk-G4FFOV3N.js.map
|
|
140
|
+
//# sourceMappingURL=chunk-G4FFOV3N.js.map
|