@bevel-software/platform-core-backend 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +6 -6
- package/dist/core/catalog-cache-invalidation.d.ts +29 -0
- package/dist/core/catalog-cache-invalidation.d.ts.map +1 -0
- package/dist/core/catalog-cache-invalidation.js +71 -0
- package/dist/core/catalog-cache-invalidation.js.map +1 -0
- package/dist/core/create-core-server.d.ts.map +1 -1
- package/dist/core/create-core-server.js +99 -8
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +18 -1
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +96 -43
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/modules/access/access-control.interface.d.ts +18 -6
- package/dist/modules/access/access-control.interface.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.d.ts +26 -1
- package/dist/modules/access/access-control.service.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.js +213 -71
- package/dist/modules/access/access-control.service.js.map +1 -1
- package/dist/modules/access/access.routes.d.ts.map +1 -1
- package/dist/modules/access/access.routes.js +59 -7
- package/dist/modules/access/access.routes.js.map +1 -1
- package/dist/modules/access-model/access-grammar.d.ts +51 -1
- package/dist/modules/access-model/access-grammar.d.ts.map +1 -1
- package/dist/modules/access-model/access-grammar.js +95 -1
- package/dist/modules/access-model/access-grammar.js.map +1 -1
- package/dist/modules/access-model/group-files.d.ts.map +1 -1
- package/dist/modules/access-model/group-files.js +4 -1
- package/dist/modules/access-model/group-files.js.map +1 -1
- package/dist/modules/access-model/plugin-principals.d.ts +49 -0
- package/dist/modules/access-model/plugin-principals.d.ts.map +1 -0
- package/dist/modules/access-model/plugin-principals.js +125 -0
- package/dist/modules/access-model/plugin-principals.js.map +1 -0
- package/dist/modules/database/core-schema.d.ts +326 -0
- package/dist/modules/database/core-schema.d.ts.map +1 -1
- package/dist/modules/database/core-schema.js +52 -0
- package/dist/modules/database/core-schema.js.map +1 -1
- package/dist/modules/kb-sync/index.d.ts +6 -0
- package/dist/modules/kb-sync/index.d.ts.map +1 -0
- package/dist/modules/kb-sync/index.js +5 -0
- package/dist/modules/kb-sync/index.js.map +1 -0
- package/dist/modules/kb-sync/kb-sync.interface.d.ts +77 -0
- package/dist/modules/kb-sync/kb-sync.interface.d.ts.map +1 -0
- package/dist/modules/kb-sync/kb-sync.interface.js +2 -0
- package/dist/modules/kb-sync/kb-sync.interface.js.map +1 -0
- package/dist/modules/kb-sync/kb-sync.routes.d.ts +70 -0
- package/dist/modules/kb-sync/kb-sync.routes.d.ts.map +1 -0
- package/dist/modules/kb-sync/kb-sync.routes.js +135 -0
- package/dist/modules/kb-sync/kb-sync.routes.js.map +1 -0
- package/dist/modules/kb-sync/kb-sync.service.d.ts +45 -0
- package/dist/modules/kb-sync/kb-sync.service.d.ts.map +1 -0
- package/dist/modules/kb-sync/kb-sync.service.js +183 -0
- package/dist/modules/kb-sync/kb-sync.service.js.map +1 -0
- package/dist/modules/kb-sync/sync-auth.d.ts +59 -0
- package/dist/modules/kb-sync/sync-auth.d.ts.map +1 -0
- package/dist/modules/kb-sync/sync-auth.js +62 -0
- package/dist/modules/kb-sync/sync-auth.js.map +1 -0
- package/dist/modules/kb-sync/sync-payload.d.ts +32 -0
- package/dist/modules/kb-sync/sync-payload.d.ts.map +1 -0
- package/dist/modules/kb-sync/sync-payload.js +105 -0
- package/dist/modules/kb-sync/sync-payload.js.map +1 -0
- package/dist/modules/marketplace/git-http.routes.d.ts +42 -0
- package/dist/modules/marketplace/git-http.routes.d.ts.map +1 -0
- package/dist/modules/marketplace/git-http.routes.js +190 -0
- package/dist/modules/marketplace/git-http.routes.js.map +1 -0
- package/dist/modules/marketplace/github-facade/github-facade-admin.routes.d.ts +23 -0
- package/dist/modules/marketplace/github-facade/github-facade-admin.routes.d.ts.map +1 -0
- package/dist/modules/marketplace/github-facade/github-facade-admin.routes.js +59 -0
- package/dist/modules/marketplace/github-facade/github-facade-admin.routes.js.map +1 -0
- package/dist/modules/marketplace/github-facade/github-facade-codes.store.d.ts +59 -0
- package/dist/modules/marketplace/github-facade/github-facade-codes.store.d.ts.map +1 -0
- package/dist/modules/marketplace/github-facade/github-facade-codes.store.js +96 -0
- package/dist/modules/marketplace/github-facade/github-facade-codes.store.js.map +1 -0
- package/dist/modules/marketplace/github-facade/github-facade-credentials.service.d.ts +99 -0
- package/dist/modules/marketplace/github-facade/github-facade-credentials.service.d.ts.map +1 -0
- package/dist/modules/marketplace/github-facade/github-facade-credentials.service.js +147 -0
- package/dist/modules/marketplace/github-facade/github-facade-credentials.service.js.map +1 -0
- package/dist/modules/marketplace/github-facade/github-facade.routes.d.ts +47 -0
- package/dist/modules/marketplace/github-facade/github-facade.routes.d.ts.map +1 -0
- package/dist/modules/marketplace/github-facade/github-facade.routes.js +228 -0
- package/dist/modules/marketplace/github-facade/github-facade.routes.js.map +1 -0
- package/dist/modules/marketplace/github-facade/github-facade.service.d.ts +109 -0
- package/dist/modules/marketplace/github-facade/github-facade.service.d.ts.map +1 -0
- package/dist/modules/marketplace/github-facade/github-facade.service.js +172 -0
- package/dist/modules/marketplace/github-facade/github-facade.service.js.map +1 -0
- package/dist/modules/marketplace/github-facade/index.d.ts +6 -0
- package/dist/modules/marketplace/github-facade/index.d.ts.map +1 -0
- package/dist/modules/marketplace/github-facade/index.js +6 -0
- package/dist/modules/marketplace/github-facade/index.js.map +1 -0
- package/dist/modules/marketplace/index.d.ts +4 -0
- package/dist/modules/marketplace/index.d.ts.map +1 -0
- package/dist/modules/marketplace/index.js +4 -0
- package/dist/modules/marketplace/index.js.map +1 -0
- package/dist/modules/marketplace/marketplace-repo.service.d.ts +122 -0
- package/dist/modules/marketplace/marketplace-repo.service.d.ts.map +1 -0
- package/dist/modules/marketplace/marketplace-repo.service.js +300 -0
- package/dist/modules/marketplace/marketplace-repo.service.js.map +1 -0
- package/dist/modules/mcp/oauth/bevel-oauth-provider.d.ts.map +1 -1
- package/dist/modules/mcp/oauth/bevel-oauth-provider.js +4 -0
- package/dist/modules/mcp/oauth/bevel-oauth-provider.js.map +1 -1
- package/dist/modules/mcp/oauth/oauth-consent.routes.d.ts +14 -8
- package/dist/modules/mcp/oauth/oauth-consent.routes.d.ts.map +1 -1
- package/dist/modules/mcp/oauth/oauth-consent.routes.js +13 -1
- package/dist/modules/mcp/oauth/oauth-consent.routes.js.map +1 -1
- package/dist/modules/mcp/oauth/oauth-state.d.ts +13 -2
- package/dist/modules/mcp/oauth/oauth-state.d.ts.map +1 -1
- package/dist/modules/mcp/oauth/oauth-state.js +3 -1
- package/dist/modules/mcp/oauth/oauth-state.js.map +1 -1
- package/dist/modules/plugins/compile/compile-marketplace.d.ts +97 -0
- package/dist/modules/plugins/compile/compile-marketplace.d.ts.map +1 -0
- package/dist/modules/plugins/compile/compile-marketplace.js +240 -0
- package/dist/modules/plugins/compile/compile-marketplace.js.map +1 -0
- package/dist/modules/plugins/compile/marketplace-compiler.service.d.ts +66 -0
- package/dist/modules/plugins/compile/marketplace-compiler.service.d.ts.map +1 -0
- package/dist/modules/plugins/compile/marketplace-compiler.service.js +132 -0
- package/dist/modules/plugins/compile/marketplace-compiler.service.js.map +1 -0
- package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.d.ts +37 -0
- package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.d.ts.map +1 -0
- package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.js +135 -0
- package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.js.map +1 -0
- package/dist/modules/plugins/discovery/bundle-dialect/registry.d.ts +45 -0
- package/dist/modules/plugins/discovery/bundle-dialect/registry.d.ts.map +1 -0
- package/dist/modules/plugins/discovery/bundle-dialect/registry.js +147 -0
- package/dist/modules/plugins/discovery/bundle-dialect/registry.js.map +1 -0
- package/dist/modules/plugins/discovery/kb-plugin-source.d.ts +37 -0
- package/dist/modules/plugins/discovery/kb-plugin-source.d.ts.map +1 -0
- package/dist/modules/plugins/discovery/kb-plugin-source.js +107 -0
- package/dist/modules/plugins/discovery/kb-plugin-source.js.map +1 -0
- package/dist/modules/plugins/discovery/native.source.d.ts +15 -0
- package/dist/modules/plugins/discovery/native.source.d.ts.map +1 -0
- package/dist/modules/plugins/discovery/native.source.js +102 -0
- package/dist/modules/plugins/discovery/native.source.js.map +1 -0
- package/dist/modules/plugins/discovery/plugin-source.d.ts +96 -0
- package/dist/modules/plugins/discovery/plugin-source.d.ts.map +1 -0
- package/dist/modules/plugins/discovery/plugin-source.js +2 -0
- package/dist/modules/plugins/discovery/plugin-source.js.map +1 -0
- package/dist/modules/plugins/index.d.ts +10 -1
- package/dist/modules/plugins/index.d.ts.map +1 -1
- package/dist/modules/plugins/index.js +8 -0
- package/dist/modules/plugins/index.js.map +1 -1
- package/dist/modules/plugins/plugin-links.d.ts +66 -0
- package/dist/modules/plugins/plugin-links.d.ts.map +1 -0
- package/dist/modules/plugins/plugin-links.js +160 -0
- package/dist/modules/plugins/plugin-links.js.map +1 -0
- package/dist/modules/plugins/plugin-links.service.d.ts +114 -0
- package/dist/modules/plugins/plugin-links.service.d.ts.map +1 -0
- package/dist/modules/plugins/plugin-links.service.js +304 -0
- package/dist/modules/plugins/plugin-links.service.js.map +1 -0
- package/dist/modules/plugins/plugin-provision.service.d.ts +39 -3
- package/dist/modules/plugins/plugin-provision.service.d.ts.map +1 -1
- package/dist/modules/plugins/plugin-provision.service.js +152 -52
- package/dist/modules/plugins/plugin-provision.service.js.map +1 -1
- package/dist/modules/plugins/plugin-rename.service.d.ts +69 -0
- package/dist/modules/plugins/plugin-rename.service.d.ts.map +1 -0
- package/dist/modules/plugins/plugin-rename.service.js +245 -0
- package/dist/modules/plugins/plugin-rename.service.js.map +1 -0
- package/dist/modules/plugins/plugins.contract.d.ts +27 -1
- package/dist/modules/plugins/plugins.contract.d.ts.map +1 -1
- package/dist/modules/plugins/plugins.routes.d.ts +7 -1
- package/dist/modules/plugins/plugins.routes.d.ts.map +1 -1
- package/dist/modules/plugins/plugins.routes.js +120 -12
- package/dist/modules/plugins/plugins.routes.js.map +1 -1
- package/dist/modules/plugins/plugins.service.d.ts +50 -3
- package/dist/modules/plugins/plugins.service.d.ts.map +1 -1
- package/dist/modules/plugins/plugins.service.js +108 -47
- package/dist/modules/plugins/plugins.service.js.map +1 -1
- package/dist/modules/settings/deployment-settings.service.d.ts +9 -0
- package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -1
- package/dist/modules/settings/deployment-settings.service.js +82 -2
- package/dist/modules/settings/deployment-settings.service.js.map +1 -1
- package/dist/modules/settings/setup.routes.d.ts +26 -0
- package/dist/modules/settings/setup.routes.d.ts.map +1 -1
- package/dist/modules/settings/setup.routes.js +9 -1
- package/dist/modules/settings/setup.routes.js.map +1 -1
- package/dist/modules/skills/index.d.ts +1 -0
- package/dist/modules/skills/index.d.ts.map +1 -1
- package/dist/modules/skills/index.js +1 -0
- package/dist/modules/skills/index.js.map +1 -1
- package/dist/modules/skills/pending-skills.service.d.ts.map +1 -1
- package/dist/modules/skills/pending-skills.service.js +9 -4
- package/dist/modules/skills/pending-skills.service.js.map +1 -1
- package/dist/modules/skills/skill-access-requests.routes.d.ts +38 -0
- package/dist/modules/skills/skill-access-requests.routes.d.ts.map +1 -0
- package/dist/modules/skills/skill-access-requests.routes.js +168 -0
- package/dist/modules/skills/skill-access-requests.routes.js.map +1 -0
- package/dist/modules/skills/skills.contract.d.ts +31 -0
- package/dist/modules/skills/skills.contract.d.ts.map +1 -1
- package/dist/modules/skills/skills.routes.d.ts +28 -3
- package/dist/modules/skills/skills.routes.d.ts.map +1 -1
- package/dist/modules/skills/skills.routes.js +42 -3
- package/dist/modules/skills/skills.routes.js.map +1 -1
- package/dist/modules/skills/skills.service.d.ts +4 -0
- package/dist/modules/skills/skills.service.d.ts.map +1 -1
- package/dist/modules/skills/skills.service.js +83 -22
- package/dist/modules/skills/skills.service.js.map +1 -1
- package/dist/modules/tool-auth/external-api-key.interface.d.ts +18 -1
- package/dist/modules/tool-auth/external-api-key.interface.d.ts.map +1 -1
- package/dist/modules/tool-auth/external-api-key.interface.js +2 -1
- package/dist/modules/tool-auth/external-api-key.interface.js.map +1 -1
- package/dist/modules/tool-auth/external-api-key.service.d.ts +13 -4
- package/dist/modules/tool-auth/external-api-key.service.d.ts.map +1 -1
- package/dist/modules/tool-auth/external-api-key.service.js +26 -9
- package/dist/modules/tool-auth/external-api-key.service.js.map +1 -1
- package/dist/modules/tool-manuals/mcp-json-discovery.d.ts +36 -0
- package/dist/modules/tool-manuals/mcp-json-discovery.d.ts.map +1 -1
- package/dist/modules/tool-manuals/mcp-json-discovery.js +130 -92
- package/dist/modules/tool-manuals/mcp-json-discovery.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts +6 -1
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.js +18 -25
- package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
- package/dist/modules/workflow/git/git.service.d.ts +40 -2
- package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/git.service.js +227 -54
- package/dist/modules/workflow/git/git.service.js.map +1 -1
- package/dist/modules/workflow/git/pull-request.service.d.ts +6 -0
- package/dist/modules/workflow/git/pull-request.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/pull-request.service.js +8 -0
- package/dist/modules/workflow/git/pull-request.service.js.map +1 -1
- package/dist/modules/workflow/workflow.service.d.ts +52 -1
- package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.service.js +242 -9
- package/dist/modules/workflow/workflow.service.js.map +1 -1
- package/dist/modules/workspace/startup/steps/plugin-manifests.step.d.ts +35 -0
- package/dist/modules/workspace/startup/steps/plugin-manifests.step.d.ts.map +1 -0
- package/dist/modules/workspace/startup/steps/plugin-manifests.step.js +121 -0
- package/dist/modules/workspace/startup/steps/plugin-manifests.step.js.map +1 -0
- package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/seed-tree.js +46 -2
- package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
- package/dist/modules/workspace/startup/steps/template-files.step.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/template-files.step.js +112 -25
- package/dist/modules/workspace/startup/steps/template-files.step.js.map +1 -1
- package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.routes.js +9 -9
- package/dist/modules/workspace/workspace.routes.js.map +1 -1
- package/dist/modules/workspace/workspace.service.d.ts +33 -0
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +110 -16
- package/dist/modules/workspace/workspace.service.js.map +1 -1
- package/dist/shared/domain-errors.d.ts +20 -0
- package/dist/shared/domain-errors.d.ts.map +1 -1
- package/dist/shared/domain-errors.js +29 -0
- package/dist/shared/domain-errors.js.map +1 -1
- package/dist/shared/fs-errors.d.ts +8 -0
- package/dist/shared/fs-errors.d.ts.map +1 -0
- package/dist/shared/fs-errors.js +11 -0
- package/dist/shared/fs-errors.js.map +1 -0
- package/dist/shared/fs-walk.d.ts +20 -6
- package/dist/shared/fs-walk.d.ts.map +1 -1
- package/dist/shared/fs-walk.js +35 -27
- package/dist/shared/fs-walk.js.map +1 -1
- package/dist/shared/kb-walk.d.ts +52 -0
- package/dist/shared/kb-walk.d.ts.map +1 -0
- package/dist/shared/kb-walk.js +76 -0
- package/dist/shared/kb-walk.js.map +1 -0
- package/dist/shared/path-order.d.ts +18 -0
- package/dist/shared/path-order.d.ts.map +1 -0
- package/dist/shared/path-order.js +35 -0
- package/dist/shared/path-order.js.map +1 -0
- package/dist/shared/ttl-cache.d.ts +28 -1
- package/dist/shared/ttl-cache.d.ts.map +1 -1
- package/dist/shared/ttl-cache.js +33 -1
- package/dist/shared/ttl-cache.js.map +1 -1
- package/kb-template/.bevelignore +1 -1
- package/kb-template/AGENTS.md +95 -30
- package/kb-template/Skills/.gitkeep +0 -0
- package/migrations/0005_github_facade.sql +25 -0
- package/migrations/meta/0005_snapshot.json +1717 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +6 -6
- package/src/__tests__/kb-layout-config.test.ts +110 -0
- package/src/core/__tests__/catalog-cache-invalidation.test.ts +146 -0
- package/src/core/catalog-cache-invalidation.ts +92 -0
- package/src/core/create-core-server.ts +123 -7
- package/src/core/create-core-services.ts +162 -41
- package/src/modules/access/__tests__/access-control.invalidate-race.test.ts +86 -0
- package/src/modules/access/__tests__/access-control.service.test.ts +19 -3
- package/src/modules/access/__tests__/access-plugin-principals.test.ts +368 -0
- package/src/modules/access/__tests__/groups-admin.service.test.ts +8 -0
- package/src/modules/access/access-control.interface.ts +20 -9
- package/src/modules/access/access-control.service.ts +240 -78
- package/src/modules/access/access.routes.ts +96 -14
- package/src/modules/access-model/__tests__/access-grammar.test.ts +18 -0
- package/src/modules/access-model/__tests__/plugin-token-canonical.test.ts +40 -0
- package/src/modules/access-model/access-grammar.ts +114 -2
- package/src/modules/access-model/group-files.ts +4 -0
- package/src/modules/access-model/plugin-principals.ts +137 -0
- package/src/modules/database/core-schema.ts +54 -0
- package/src/modules/kb-sync/__tests__/kb-sync.routes.test.ts +297 -0
- package/src/modules/kb-sync/__tests__/kb-sync.service.test.ts +295 -0
- package/src/modules/kb-sync/__tests__/sync-auth.test.ts +118 -0
- package/src/modules/kb-sync/__tests__/sync-payload.test.ts +148 -0
- package/src/modules/kb-sync/index.ts +19 -0
- package/src/modules/kb-sync/kb-sync.interface.ts +79 -0
- package/src/modules/kb-sync/kb-sync.routes.ts +197 -0
- package/src/modules/kb-sync/kb-sync.service.ts +201 -0
- package/src/modules/kb-sync/sync-auth.ts +118 -0
- package/src/modules/kb-sync/sync-payload.ts +143 -0
- package/src/modules/marketplace/__tests__/github-facade.test.ts +443 -0
- package/src/modules/marketplace/__tests__/marketplace-git.test.ts +179 -0
- package/src/modules/marketplace/git-http.routes.ts +193 -0
- package/src/modules/marketplace/github-facade/github-facade-admin.routes.ts +78 -0
- package/src/modules/marketplace/github-facade/github-facade-codes.store.ts +145 -0
- package/src/modules/marketplace/github-facade/github-facade-credentials.service.ts +208 -0
- package/src/modules/marketplace/github-facade/github-facade.routes.ts +268 -0
- package/src/modules/marketplace/github-facade/github-facade.service.ts +221 -0
- package/src/modules/marketplace/github-facade/index.ts +25 -0
- package/src/modules/marketplace/index.ts +3 -0
- package/src/modules/marketplace/marketplace-repo.service.ts +337 -0
- package/src/modules/mcp/oauth/bevel-oauth-provider.ts +3 -0
- package/src/modules/mcp/oauth/oauth-consent.routes.ts +24 -2
- package/src/modules/mcp/oauth/oauth-state.ts +15 -3
- package/src/modules/plugins/__tests__/bundle-dialect.e2e.test.ts +163 -0
- package/src/modules/plugins/__tests__/compile-marketplace.test.ts +294 -0
- package/src/modules/plugins/__tests__/plugin-index.service.test.ts +56 -12
- package/src/modules/plugins/__tests__/plugin-links.service.test.ts +287 -0
- package/src/modules/plugins/__tests__/plugin-provision.service.test.ts +205 -5
- package/src/modules/plugins/__tests__/plugin-rename.service.test.ts +394 -0
- package/src/modules/plugins/__tests__/plugins.routes.test.ts +80 -33
- package/src/modules/plugins/compile/compile-marketplace.ts +403 -0
- package/src/modules/plugins/compile/marketplace-compiler.service.ts +150 -0
- package/src/modules/plugins/discovery/__tests__/kb-plugin-source.test.ts +329 -0
- package/src/modules/plugins/discovery/bundle-dialect/bundle.source.ts +140 -0
- package/src/modules/plugins/discovery/bundle-dialect/registry.ts +175 -0
- package/src/modules/plugins/discovery/kb-plugin-source.ts +114 -0
- package/src/modules/plugins/discovery/native.source.ts +122 -0
- package/src/modules/plugins/discovery/plugin-source.ts +99 -0
- package/src/modules/plugins/index.ts +10 -0
- package/src/modules/plugins/plugin-links.service.ts +363 -0
- package/src/modules/plugins/plugin-links.ts +184 -0
- package/src/modules/plugins/plugin-provision.service.ts +160 -54
- package/src/modules/plugins/plugin-rename.service.ts +298 -0
- package/src/modules/plugins/plugins.contract.ts +28 -1
- package/src/modules/plugins/plugins.routes.ts +128 -11
- package/src/modules/plugins/plugins.service.ts +106 -53
- package/src/modules/settings/__tests__/deployment-settings.service.test.ts +57 -0
- package/src/modules/settings/__tests__/setup.routes.sync-status.test.ts +77 -0
- package/src/modules/settings/deployment-settings.service.ts +95 -2
- package/src/modules/settings/setup.routes.ts +24 -0
- package/src/modules/skills/__tests__/skill-access-requests.routes.test.ts +128 -0
- package/src/modules/skills/__tests__/skills.service.test.ts +85 -0
- package/src/modules/skills/index.ts +1 -0
- package/src/modules/skills/pending-skills.service.ts +7 -5
- package/src/modules/skills/skill-access-requests.routes.ts +199 -0
- package/src/modules/skills/skills.contract.ts +32 -0
- package/src/modules/skills/skills.routes.ts +59 -3
- package/src/modules/skills/skills.service.ts +84 -22
- package/src/modules/tool-auth/external-api-key.interface.ts +20 -1
- package/src/modules/tool-auth/external-api-key.service.ts +31 -13
- package/src/modules/tool-manuals/__tests__/mcp-json-discovery.test.ts +24 -1
- package/src/modules/tool-manuals/__tests__/tool-manuals.cli.test.ts +2 -0
- package/src/modules/tool-manuals/mcp-json-discovery.ts +154 -88
- package/src/modules/tool-manuals/tool-manuals.service.ts +14 -23
- package/src/modules/workflow/__tests__/preserve-roles-yaml.test.ts +1 -1
- package/src/modules/workflow/__tests__/workflow.service.commitFileWhileLocked.test.ts +1 -0
- package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +2 -2
- package/src/modules/workflow/__tests__/workflow.service.releaseLock.test.ts +119 -2
- package/src/modules/workflow/__tests__/workflow.service.sync.test.ts +437 -0
- package/src/modules/workflow/git/__tests__/git.service.postMergePull.test.ts +3 -3
- package/src/modules/workflow/git/__tests__/git.service.pull.test.ts +47 -4
- package/src/modules/workflow/git/__tests__/git.service.syncFromRemote.test.ts +253 -0
- package/src/modules/workflow/git/git.service.ts +239 -56
- package/src/modules/workflow/git/pull-request.service.ts +9 -0
- package/src/modules/workflow/workflow.service.ts +260 -9
- package/src/modules/workspace/__tests__/workspace.routes.read-gate.test.ts +6 -7
- package/src/modules/workspace/__tests__/workspace.service.list-cloned.test.ts +93 -0
- package/src/modules/workspace/__tests__/workspace.service.missing-branch.test.ts +28 -0
- package/src/modules/workspace/__tests__/workspace.service.read-filter.test.ts +42 -12
- package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +219 -4
- package/src/modules/workspace/startup/steps/plugin-manifests.step.ts +129 -0
- package/src/modules/workspace/startup/steps/seed-tree.ts +44 -2
- package/src/modules/workspace/startup/steps/template-files.step.ts +131 -27
- package/src/modules/workspace/workspace.routes.ts +9 -17
- package/src/modules/workspace/workspace.service.ts +107 -16
- package/src/shared/__tests__/filename.test.ts +0 -0
- package/src/shared/__tests__/fs-walk.test.ts +22 -1
- package/src/shared/__tests__/kb-walk.test.ts +107 -0
- package/src/shared/__tests__/path-order.test.ts +24 -0
- package/src/shared/__tests__/ttl-cache.test.ts +55 -0
- package/src/shared/domain-errors.ts +29 -0
- package/src/shared/fs-errors.ts +10 -0
- package/src/shared/fs-walk.ts +38 -23
- package/src/shared/kb-walk.ts +95 -0
- package/src/shared/path-order.ts +33 -0
- package/src/shared/ttl-cache.ts +33 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The customer's MCP registry — `configs/mcp/registry.json` — and how a
|
|
3
|
+
* bundle's `mcpProfile` expands through it into an `mcpServers` map of the
|
|
4
|
+
* shape `mcp.json` carries.
|
|
5
|
+
*
|
|
6
|
+
* The file holds two lists:
|
|
7
|
+
*
|
|
8
|
+
* servers each with an `id`, a `name`, and the real config — either a
|
|
9
|
+
* stdio launch (`command`, `args`, `env`) or `type: http` + `url`;
|
|
10
|
+
* the config may sit under a `config` key or flat on the entry.
|
|
11
|
+
* profiles each with an `id`, the server ids it selects, and an optional
|
|
12
|
+
* `extends` naming another profile (a chain, never a cycle).
|
|
13
|
+
*
|
|
14
|
+
* Pure: parse once, expand many. Unknown ids and cycles are warnings, never
|
|
15
|
+
* throws — a registry typo must not take every plugin down.
|
|
16
|
+
*/
|
|
17
|
+
import {
|
|
18
|
+
judgeMcpServerEntry,
|
|
19
|
+
type PortableHttpEntry,
|
|
20
|
+
type PortableStdioEntry,
|
|
21
|
+
} from '../../../tool-manuals/mcp-json-discovery.js';
|
|
22
|
+
|
|
23
|
+
export interface RegistryServer {
|
|
24
|
+
id: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
/** The server as one `mcp.json` entry — judged, and therefore usable, at parse time. */
|
|
27
|
+
entry: PortableStdioEntry | PortableHttpEntry;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface RegistryProfile {
|
|
31
|
+
id: string;
|
|
32
|
+
servers: string[];
|
|
33
|
+
extends?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface McpRegistry {
|
|
37
|
+
servers: Map<string, RegistryServer>;
|
|
38
|
+
profiles: Map<string, RegistryProfile>;
|
|
39
|
+
warnings: string[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function parseRegistry(text: string): McpRegistry {
|
|
43
|
+
const warnings: string[] = [];
|
|
44
|
+
const servers = new Map<string, RegistryServer>();
|
|
45
|
+
const profiles = new Map<string, RegistryProfile>();
|
|
46
|
+
let root: unknown;
|
|
47
|
+
try {
|
|
48
|
+
root = JSON.parse(text);
|
|
49
|
+
} catch {
|
|
50
|
+
return { servers, profiles, warnings: ['registry.json is not valid JSON'] };
|
|
51
|
+
}
|
|
52
|
+
if (!isRecord(root)) return { servers, profiles, warnings: ['registry.json must be a JSON object'] };
|
|
53
|
+
|
|
54
|
+
for (const raw of asArray(root.servers)) {
|
|
55
|
+
if (!isRecord(raw) || typeof raw.id !== 'string' || !raw.id) {
|
|
56
|
+
warnings.push('registry.json: a server without an id was skipped');
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (servers.has(raw.id)) {
|
|
60
|
+
warnings.push(`registry.json: server "${raw.id}" is declared twice — the second declaration is ignored`);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
// Converting IS the validation: a server the registry keeps is one whose
|
|
64
|
+
// entry a client can run — judged by the ONE rule every mcp.json entry
|
|
65
|
+
// meets (name, transport, required fields), after the customer's shape
|
|
66
|
+
// is translated into that of mcp.json.
|
|
67
|
+
const converted = mcpEntryOf(raw.id, isRecord(raw.config) ? raw.config : raw);
|
|
68
|
+
if ('reason' in converted) {
|
|
69
|
+
warnings.push(`registry.json: server "${raw.id}" ${converted.reason} — skipped`);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
servers.set(raw.id, { id: raw.id, name: typeof raw.name === 'string' ? raw.name : undefined, entry: converted.entry });
|
|
73
|
+
}
|
|
74
|
+
for (const raw of asArray(root.profiles)) {
|
|
75
|
+
if (!isRecord(raw) || typeof raw.id !== 'string' || !raw.id) {
|
|
76
|
+
warnings.push('registry.json: a profile without an id was skipped');
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (profiles.has(raw.id)) {
|
|
80
|
+
warnings.push(`registry.json: profile "${raw.id}" is declared twice — the second declaration is ignored`);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
profiles.set(raw.id, {
|
|
84
|
+
id: raw.id,
|
|
85
|
+
servers: asArray(raw.servers).filter((s): s is string => typeof s === 'string'),
|
|
86
|
+
extends: typeof raw.extends === 'string' ? raw.extends : undefined,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return { servers, profiles, warnings };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The `mcpServers` map a profile resolves to, in `mcp.json` terms. Keyed by
|
|
94
|
+
* server id — the namespace vault secrets bind to, so the same registry
|
|
95
|
+
* server in three plugins shares one credential, which is what a registry
|
|
96
|
+
* means.
|
|
97
|
+
*/
|
|
98
|
+
export function expandProfile(
|
|
99
|
+
registry: McpRegistry,
|
|
100
|
+
profileId: string,
|
|
101
|
+
): { mcpServers: Record<string, unknown>; warnings: string[] } {
|
|
102
|
+
const warnings: string[] = [];
|
|
103
|
+
const ids: string[] = [];
|
|
104
|
+
const seen = new Set<string>();
|
|
105
|
+
let current: string | undefined = profileId;
|
|
106
|
+
while (current !== undefined) {
|
|
107
|
+
if (seen.has(current)) {
|
|
108
|
+
warnings.push(`registry.json: profile "${current}" extends itself through a cycle — chain cut`);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
seen.add(current);
|
|
112
|
+
const profile = registry.profiles.get(current);
|
|
113
|
+
if (!profile) {
|
|
114
|
+
warnings.push(`registry.json: profile "${current}" does not exist`);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
// Nearest profile first, so a base profile's servers come after the
|
|
118
|
+
// extending one's; the map below keeps the first occurrence of an id.
|
|
119
|
+
for (const id of profile.servers) if (!ids.includes(id)) ids.push(id);
|
|
120
|
+
current = profile.extends;
|
|
121
|
+
}
|
|
122
|
+
const mcpServers: Record<string, unknown> = {};
|
|
123
|
+
for (const id of ids) {
|
|
124
|
+
const server = registry.servers.get(id);
|
|
125
|
+
if (!server) {
|
|
126
|
+
warnings.push(`registry.json: profile "${profileId}" selects unknown server "${id}"`);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
mcpServers[id] = server.entry;
|
|
130
|
+
}
|
|
131
|
+
return { mcpServers, warnings };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* A registry config → one `mcp.json` server entry, or why there is none.
|
|
136
|
+
*
|
|
137
|
+
* The registry's OWN knowledge is the customer's shape: a declared `type`
|
|
138
|
+
* names the transport (`http` is their spelling of `streamable-http`), an
|
|
139
|
+
* undeclared one is read off the fields — a `url` means http, else a
|
|
140
|
+
* `command` means stdio — and blank strings are absent. That translation
|
|
141
|
+
* done, whether the entry can work is the shared judgement's call, the same
|
|
142
|
+
* one every `mcp.json` entry meets: a name that can be a server name, a
|
|
143
|
+
* transport the client speaks (no `sse`), the field that transport needs.
|
|
144
|
+
*/
|
|
145
|
+
function mcpEntryOf(
|
|
146
|
+
id: string,
|
|
147
|
+
config: Record<string, unknown>,
|
|
148
|
+
): { entry: PortableStdioEntry | PortableHttpEntry } | { reason: string } {
|
|
149
|
+
const declared = typeof config.type === 'string' ? config.type.trim().toLowerCase() : undefined;
|
|
150
|
+
const url = nonBlank(config.url);
|
|
151
|
+
const command = nonBlank(config.command);
|
|
152
|
+
const type =
|
|
153
|
+
declared === undefined ? (url ? 'streamable-http' : command ? 'stdio' : undefined) : declared === 'http' ? 'streamable-http' : declared;
|
|
154
|
+
if (type === undefined) return { reason: 'has neither a url nor a command' };
|
|
155
|
+
const candidate: Record<string, unknown> = { type };
|
|
156
|
+
if (url) candidate.url = url;
|
|
157
|
+
if (command) candidate.command = command;
|
|
158
|
+
for (const key of ['args', 'env', 'cwd', 'headers'] as const) {
|
|
159
|
+
if (config[key] !== undefined) candidate[key] = config[key];
|
|
160
|
+
}
|
|
161
|
+
const verdict = judgeMcpServerEntry(id, candidate);
|
|
162
|
+
return verdict.ok ? { entry: verdict.entry } : { reason: verdict.reason };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function nonBlank(v: unknown): string | undefined {
|
|
166
|
+
return typeof v === 'string' && v.trim() ? v : undefined;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function isRecord(v: unknown): v is Record<string, unknown> {
|
|
170
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function asArray(v: unknown): unknown[] {
|
|
174
|
+
return Array.isArray(v) ? v : [];
|
|
175
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { PLUGINS_DIR, PLUGIN_MANIFEST_FILE, pluginManifestName } from '@bevel-software/platform-shared';
|
|
3
|
+
import type { DiscoveredPlugin, Discovery, PluginSource, PluginSourceWalk } from './plugin-source.js';
|
|
4
|
+
import { walkKb, type KbWalkListener } from '../../../shared/kb-walk.js';
|
|
5
|
+
import { readNativePlugin } from './native.source.js';
|
|
6
|
+
import { BUNDLE_FILE, loadRegistry, readBundlePlugin } from './bundle-dialect/bundle.source.js';
|
|
7
|
+
import type { McpRegistry } from './bundle-dialect/registry.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* THE plugin source: a LISTENER on the one walk of the checkout
|
|
11
|
+
* (`walkKb`), reading every folder under the plugins root in whichever of
|
|
12
|
+
* the two file shapes it carries.
|
|
13
|
+
*
|
|
14
|
+
* plugin.json → a native plugin (this platform's layout)
|
|
15
|
+
* plugin.bundle.json → a bundle (the customer dialect, read-only)
|
|
16
|
+
*
|
|
17
|
+
* Nothing else is a plugin. A folder's POSITION means nothing: the legacy
|
|
18
|
+
* rule "everything directly under the root is a plugin" is retired by the
|
|
19
|
+
* `plugin-manifests` boot step, which writes the manifest into every such
|
|
20
|
+
* folder once, so discovery never has to guess.
|
|
21
|
+
*
|
|
22
|
+
* A folder that IS a plugin claims everything beneath it (its `skills/` are
|
|
23
|
+
* its own) — the walk still visits what lies beneath, for the other
|
|
24
|
+
* listeners; this one ignores it. When a folder carries both files the
|
|
25
|
+
* manifest wins, so a bundle migrated in place stops being read as a bundle
|
|
26
|
+
* the moment a `plugin.json` lands beside it. Two plugins with one name keep
|
|
27
|
+
* the first by path (the walk's order) and warn about the second — a name is
|
|
28
|
+
* an identity to people and URLs, and two folders answering to it would be
|
|
29
|
+
* two plugins with one key.
|
|
30
|
+
*
|
|
31
|
+
* Holes — a folder under the root that could not be listed, an identity
|
|
32
|
+
* file that could not be read — are counted in `unreadable`: nothing behind
|
|
33
|
+
* them is listed, and a writer refuses while they exist.
|
|
34
|
+
*
|
|
35
|
+
* No setting picks a dialect. Nothing to configure means nothing to document
|
|
36
|
+
* and nothing to remove but the `else if` that reads bundles.
|
|
37
|
+
*/
|
|
38
|
+
export class KbPluginSource implements PluginSource {
|
|
39
|
+
readonly dialect = 'kb';
|
|
40
|
+
|
|
41
|
+
async discover(kbRoot: string): Promise<Discovery> {
|
|
42
|
+
return (await this.walkWith(kbRoot, [])).discovery;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async walkWith(kbRoot: string, listeners: readonly KbWalkListener[]): Promise<PluginSourceWalk> {
|
|
46
|
+
const warnings: string[] = [];
|
|
47
|
+
const registry = await loadRegistry(kbRoot, warnings);
|
|
48
|
+
const listener = pluginListener(kbRoot, registry, warnings);
|
|
49
|
+
const { holes } = await walkKb(kbRoot, [listener.listener, ...listeners]);
|
|
50
|
+
return { discovery: listener.result(), holes };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The discovery listener over one walk, and the `Discovery` it has built once the walk is done. */
|
|
55
|
+
function pluginListener(
|
|
56
|
+
kbRoot: string,
|
|
57
|
+
registry: McpRegistry | null,
|
|
58
|
+
warnings: string[],
|
|
59
|
+
): { listener: KbWalkListener; result(): Discovery } {
|
|
60
|
+
const unreadable: string[] = [];
|
|
61
|
+
const plugins: DiscoveredPlugin[] = [];
|
|
62
|
+
const seen = new Map<string, string>();
|
|
63
|
+
/** Folders claimed as plugins (or as holes standing where a plugin may be): nothing beneath is looked at. */
|
|
64
|
+
const claimed: string[] = [];
|
|
65
|
+
|
|
66
|
+
const underRoot = (rel: string) => rel === PLUGINS_DIR || rel.startsWith(`${PLUGINS_DIR}/`);
|
|
67
|
+
const beneathClaimed = (rel: string) => claimed.some((c) => rel === c || rel.startsWith(`${c}/`));
|
|
68
|
+
|
|
69
|
+
// Uniqueness is judged on the MANIFEST SLUG, not the raw name: `Sales Team`
|
|
70
|
+
// and `sales-team` fold to one slug, and the slug is what the compiled
|
|
71
|
+
// marketplace keys a plugin on — two folders sharing it would be two
|
|
72
|
+
// plugins with one key and one of them silently overwritten.
|
|
73
|
+
const claim = (plugin: DiscoveredPlugin): void => {
|
|
74
|
+
const key = pluginManifestName(plugin.name);
|
|
75
|
+
const twin = seen.get(key);
|
|
76
|
+
if (twin) {
|
|
77
|
+
warnings.push(`${plugin.folder}: plugin name "${plugin.name}" is already used by ${twin} — plugin skipped`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
seen.set(key, plugin.folder);
|
|
81
|
+
plugins.push(plugin);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
listener: {
|
|
86
|
+
async onDir(rel, entries) {
|
|
87
|
+
if (!underRoot(rel) || rel === PLUGINS_DIR || beneathClaimed(rel)) return;
|
|
88
|
+
const has = (name: string) => entries.some((e) => e.isFile() && e.name === name);
|
|
89
|
+
const dir = path.join(kbRoot, rel);
|
|
90
|
+
const relFolder = rel.slice(PLUGINS_DIR.length + 1);
|
|
91
|
+
if (has(PLUGIN_MANIFEST_FILE)) {
|
|
92
|
+
claimed.push(rel);
|
|
93
|
+
// A manifest that could not be read: a hole, and still claimed.
|
|
94
|
+
const native = await readNativePlugin(dir, rel, relFolder, warnings, unreadable);
|
|
95
|
+
if (native) claim(native);
|
|
96
|
+
} else if (has(BUNDLE_FILE)) {
|
|
97
|
+
claimed.push(rel);
|
|
98
|
+
const bundle = await readBundlePlugin(dir, rel, relFolder, registry, warnings, unreadable);
|
|
99
|
+
if (bundle) claim(bundle);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
onHole(rel, err) {
|
|
103
|
+
// A folder under the root that could not be listed hides every plugin
|
|
104
|
+
// beneath it; said out loud rather than letting the catalog shrink in
|
|
105
|
+
// silence, and COUNTED so a writer can tell an incomplete listing from
|
|
106
|
+
// a complete one. (Holes elsewhere in the tree are the walk's to report.)
|
|
107
|
+
if (!underRoot(rel) || beneathClaimed(rel)) return;
|
|
108
|
+
warnings.push(`${rel}: could not be read — ${err instanceof Error ? err.message : String(err)}`);
|
|
109
|
+
unreadable.push(rel);
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
result: () => ({ plugins, warnings, unreadable }),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {
|
|
4
|
+
PLUGIN_MANIFEST_FILE,
|
|
5
|
+
PLUGIN_MCP_FILE,
|
|
6
|
+
isPersonalPluginDir,
|
|
7
|
+
isPluginIdentifier,
|
|
8
|
+
linkedSkillRoots,
|
|
9
|
+
pluginDisplayNameOf,
|
|
10
|
+
pluginIdentityOf,
|
|
11
|
+
} from '@bevel-software/platform-shared';
|
|
12
|
+
import { isAbsence } from '../../../shared/fs-errors.js';
|
|
13
|
+
import type { DiscoveredPlugin } from './plugin-source.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A plugin in the layout this platform writes (see `kb-layout.ts`): a folder
|
|
17
|
+
* carrying `plugin.json`, optionally `mcp.json`, and the `access.md` that
|
|
18
|
+
* makes it exist to the index. Called by the walker for every folder it
|
|
19
|
+
* decides is a native plugin; reads the files, decides nothing else.
|
|
20
|
+
*
|
|
21
|
+
* Null when the manifest exists but could not be READ: the manifest is the
|
|
22
|
+
* identity, and a plugin whose identity nobody could see is not listed under
|
|
23
|
+
* a guessed one — it is a hole (`unreadable`), like a folder that could not
|
|
24
|
+
* be listed. The optional `mcp.json` carries no identity, so its read
|
|
25
|
+
* failure is a warning and nothing more.
|
|
26
|
+
*/
|
|
27
|
+
export async function readNativePlugin(
|
|
28
|
+
dir: string,
|
|
29
|
+
folder: string,
|
|
30
|
+
relFolder: string,
|
|
31
|
+
warnings: string[],
|
|
32
|
+
unreadable: string[],
|
|
33
|
+
): Promise<DiscoveredPlugin | null> {
|
|
34
|
+
const folderName = path.posix.basename(relFolder);
|
|
35
|
+
const manifestRead = await readText(path.join(dir, PLUGIN_MANIFEST_FILE), folder, warnings);
|
|
36
|
+
if (manifestRead.failed) {
|
|
37
|
+
unreadable.push(`${folder}/${PLUGIN_MANIFEST_FILE}`);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
// The walker probed the manifest a moment ago; gone now means it vanished
|
|
41
|
+
// between probe and read — then this is no plugin, not one under a guessed name.
|
|
42
|
+
if (manifestRead.text === null) return null;
|
|
43
|
+
const manifestText = manifestRead.text;
|
|
44
|
+
const mcpJsonText = (await readText(path.join(dir, PLUGIN_MCP_FILE), folder, warnings)).text;
|
|
45
|
+
const manifest = parseObject(manifestText);
|
|
46
|
+
if (manifest === null) {
|
|
47
|
+
warnings.push(`${folder}/${PLUGIN_MANIFEST_FILE} is not a JSON object — treated as absent`);
|
|
48
|
+
}
|
|
49
|
+
// The manifest's `name` IS the identity — the grants, the URLs, the
|
|
50
|
+
// marketplace all spell it — when it is an identifier. One that is not
|
|
51
|
+
// (spaces, capitals) is never silently reinterpreted: the folder stands
|
|
52
|
+
// in, and the mismatch is said out loud so a grant written against the
|
|
53
|
+
// manifest's spelling is not a mystery.
|
|
54
|
+
const name = pluginIdentityOf(manifest, folderName);
|
|
55
|
+
const displayName = pluginDisplayNameOf(manifest, folderName);
|
|
56
|
+
// Any PRESENT name that is not an identifier is worth a word — a number or
|
|
57
|
+
// an object as much as a capitalised string. Only an absent name is silent.
|
|
58
|
+
if (manifest && manifest.name !== undefined && !isPluginIdentifier(manifest.name)) {
|
|
59
|
+
// A diagnostic must never be the thing that fails: a non-string name is
|
|
60
|
+
// described by its type, not serialised (a value nested deep enough
|
|
61
|
+
// would blow the stack on the way to a warning).
|
|
62
|
+
const spelled =
|
|
63
|
+
typeof manifest.name === 'string'
|
|
64
|
+
? `"${manifest.name}"`
|
|
65
|
+
: `a value of type ${Array.isArray(manifest.name) ? 'array' : typeof manifest.name}`;
|
|
66
|
+
warnings.push(
|
|
67
|
+
`${folder}/${PLUGIN_MANIFEST_FILE} names ${spelled}, which is not a plugin identifier (lowercase kebab-case) — the folder stands in as "${name}"`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
const mcp = parseObject(mcpJsonText);
|
|
71
|
+
const mcpServers =
|
|
72
|
+
mcp && typeof mcp.mcpServers === 'object' && mcp.mcpServers !== null && !Array.isArray(mcp.mcpServers)
|
|
73
|
+
? (mcp.mcpServers as Record<string, unknown>)
|
|
74
|
+
: null;
|
|
75
|
+
const exists = await fs.stat(path.join(dir, 'access.md')).then((s) => s.isFile(), () => false);
|
|
76
|
+
return {
|
|
77
|
+
name,
|
|
78
|
+
displayName,
|
|
79
|
+
folder,
|
|
80
|
+
relFolder,
|
|
81
|
+
// The one structural rule: a direct child of the root with the prefix.
|
|
82
|
+
personal: isPersonalPluginDir(folder),
|
|
83
|
+
exists,
|
|
84
|
+
manifest,
|
|
85
|
+
manifestText,
|
|
86
|
+
linkedRoots: linkedSkillRoots(manifest),
|
|
87
|
+
mcpServers,
|
|
88
|
+
mcpJsonText,
|
|
89
|
+
linksAreManaged: true,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A file's text — null when there is no such file — and whether a file that
|
|
95
|
+
* IS there could not be read. Absence and failure are different answers;
|
|
96
|
+
* the caller decides what a failure means for the file in question.
|
|
97
|
+
*/
|
|
98
|
+
async function readText(
|
|
99
|
+
abs: string,
|
|
100
|
+
folder: string,
|
|
101
|
+
warnings: string[],
|
|
102
|
+
): Promise<{ text: string | null; failed: boolean }> {
|
|
103
|
+
try {
|
|
104
|
+
return { text: await fs.readFile(abs, 'utf-8'), failed: false };
|
|
105
|
+
} catch (err) {
|
|
106
|
+
if (isAbsence(err)) return { text: null, failed: false };
|
|
107
|
+
warnings.push(`${folder}/${path.basename(abs)} could not be read — ${err instanceof Error ? err.message : String(err)}`);
|
|
108
|
+
return { text: null, failed: true };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function parseObject(text: string | null): Record<string, unknown> | null {
|
|
113
|
+
if (text === null) return null;
|
|
114
|
+
try {
|
|
115
|
+
const parsed: unknown = JSON.parse(text);
|
|
116
|
+
return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)
|
|
117
|
+
? (parsed as Record<string, unknown>)
|
|
118
|
+
: null;
|
|
119
|
+
} catch {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { KbWalkListener } from '../../../shared/kb-walk.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Plugin DISCOVERY as an interface — the one seam between "what a plugin is
|
|
5
|
+
* on disk" and everything that consumes plugins (the plugin index, the link
|
|
6
|
+
* index, the tool-manual scanner, the compiler).
|
|
7
|
+
*
|
|
8
|
+
* Two providers implement it:
|
|
9
|
+
*
|
|
10
|
+
* - `native.source.ts` — the Agent Plugins layout this platform writes:
|
|
11
|
+
* `Plugins/<Name>/plugin.json` (+ `mcp.json`,
|
|
12
|
+
* `access.md`, the hexis extension block).
|
|
13
|
+
* - `bundle-dialect/` — a customer's source layout: `plugin.bundle.json`
|
|
14
|
+
* files at any depth, pointing at skill roots and at
|
|
15
|
+
* an MCP profile in a registry. Read-only, and
|
|
16
|
+
* deletable as a unit once that customer migrates.
|
|
17
|
+
*
|
|
18
|
+
* Consumers see only {@link DiscoveredPlugin}: parsed objects, never files.
|
|
19
|
+
* A provider that reads a different file shape changes nothing downstream.
|
|
20
|
+
*/
|
|
21
|
+
export interface DiscoveredPlugin {
|
|
22
|
+
/**
|
|
23
|
+
* The plugin's IDENTITY everywhere a URL, a grant or a marketplace names
|
|
24
|
+
* it: the manifest's `name` — an Agent Plugins identifier — or the folder
|
|
25
|
+
* name folded into one when the manifest declares none it can be. A bundle
|
|
26
|
+
* plugin's is the bundle's `name`. Unique per source.
|
|
27
|
+
*/
|
|
28
|
+
name: string;
|
|
29
|
+
/** What a person sees it called: the manifest's `displayName`, else the folder name. */
|
|
30
|
+
displayName: string;
|
|
31
|
+
/** Repo-relative folder holding the plugin, e.g. `Plugins/GTM`. */
|
|
32
|
+
folder: string;
|
|
33
|
+
/** The same folder relative to the plugins root, e.g. `GTM` or `functional/x/y`. */
|
|
34
|
+
relFolder: string;
|
|
35
|
+
/** A personal folder (`Plugins/personal-<id>`): a place, not a plugin. */
|
|
36
|
+
personal: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the plugin EXISTS by the index's rule. Native: its folder carries
|
|
39
|
+
* an `access.md` (a bare directory is a ghost git left behind). Dialect:
|
|
40
|
+
* always — the bundle file is the existence.
|
|
41
|
+
*/
|
|
42
|
+
exists: boolean;
|
|
43
|
+
/** The Agent Plugins manifest, parsed (a dialect synthesises one). Null when absent or unparsable. */
|
|
44
|
+
manifest: Record<string, unknown> | null;
|
|
45
|
+
/** The manifest's raw text, for readers that want the extension block verbatim (native only). */
|
|
46
|
+
manifestText: string | null;
|
|
47
|
+
/** Repo-relative roots the plugin LINKS skills from — a skill folder or a folder of skills. */
|
|
48
|
+
linkedRoots: string[];
|
|
49
|
+
/** The `mcpServers` map of the plugin's `mcp.json`, parsed; null when it has none. */
|
|
50
|
+
mcpServers: Record<string, unknown> | null;
|
|
51
|
+
/** The raw `mcp.json` text, when it exists on disk (native only). */
|
|
52
|
+
mcpJsonText: string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Whether hexis manages this plugin's links — writes them, grants the
|
|
55
|
+
* plugin's principal on the skill, reports a missing grant as needing
|
|
56
|
+
* repair. False for a dialect, whose links are plain references and whose
|
|
57
|
+
* skills' own scopes decide readability.
|
|
58
|
+
*/
|
|
59
|
+
linksAreManaged: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface Discovery {
|
|
63
|
+
plugins: DiscoveredPlugin[];
|
|
64
|
+
/** What was skipped and why — unparsable files, unknown profiles. */
|
|
65
|
+
warnings: string[];
|
|
66
|
+
/**
|
|
67
|
+
* HOLES: identity-bearing things that exist but could NOT be read
|
|
68
|
+
* (permissions, I/O), repo-relative — a folder that could not be listed,
|
|
69
|
+
* a manifest or bundle that could not be opened. Nothing behind a hole is
|
|
70
|
+
* in `plugins`: not absent, unseen, and never listed under a guessed name.
|
|
71
|
+
* A file that carries no identity (an `mcp.json`) is never a hole; its
|
|
72
|
+
* failure is a warning. A reader that only shows what it can carries on
|
|
73
|
+
* (the catalog does); a WRITER that keys a change on the set of plugins
|
|
74
|
+
* (a rename claiming a name) must refuse while this is not empty, or it
|
|
75
|
+
* may take an identity it could not see.
|
|
76
|
+
*/
|
|
77
|
+
unreadable: string[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** What one walk yields when discovery shares it: the plugins, and every hole the walk met anywhere. */
|
|
81
|
+
export interface PluginSourceWalk {
|
|
82
|
+
discovery: Discovery;
|
|
83
|
+
/** Every folder the walk could not list, repo-relative — under the plugins root or anywhere else. */
|
|
84
|
+
holes: string[];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface PluginSource {
|
|
88
|
+
/** A short name for logs and the settings screen. */
|
|
89
|
+
readonly dialect: string;
|
|
90
|
+
/** Enumerate the plugins in a KB checkout. Never throws: a broken tree yields warnings. */
|
|
91
|
+
discover(kbRoot: string): Promise<Discovery>;
|
|
92
|
+
/**
|
|
93
|
+
* Discover while driving other listeners from the SAME walk — a writer
|
|
94
|
+
* that needs plugins and grant files alike reads the tree once, and sees
|
|
95
|
+
* one set of holes. Optional: a source that cannot share its walk is
|
|
96
|
+
* discovered on its own and the caller walks separately.
|
|
97
|
+
*/
|
|
98
|
+
walkWith?(kbRoot: string, listeners: readonly KbWalkListener[]): Promise<PluginSourceWalk>;
|
|
99
|
+
}
|
|
@@ -6,11 +6,21 @@ export {
|
|
|
6
6
|
personalAccessMd,
|
|
7
7
|
} from './plugin-provision.service.js';
|
|
8
8
|
export { JoinRequestsService, type JoinRequest } from './join-requests.service.js';
|
|
9
|
+
export { PluginLinkIndex, type LinkMembership, type PluginLinks } from './plugin-links.js';
|
|
10
|
+
export { PluginLinksService, PluginLinkError } from './plugin-links.service.js';
|
|
11
|
+
export { PluginRenameService, PluginRenameError, renamePluginPrincipalInText } from './plugin-rename.service.js';
|
|
12
|
+
export { compileMarketplace, type VirtualTree, type CompileInput, type MarketplaceOptions } from './compile/compile-marketplace.js';
|
|
13
|
+
export { MarketplaceCompilerService, type CompileAudience } from './compile/marketplace-compiler.service.js';
|
|
14
|
+
export type { PluginSource, PluginSourceWalk, DiscoveredPlugin, Discovery } from './discovery/plugin-source.js';
|
|
15
|
+
export { walkKb, type KbWalkListener, type KbWalkResult } from '../../shared/kb-walk.js';
|
|
16
|
+
export { KbPluginSource } from './discovery/kb-plugin-source.js';
|
|
17
|
+
export { DEFAULT_REGISTRY_PATH } from './discovery/bundle-dialect/bundle.source.js';
|
|
9
18
|
export { pendingProposals, type JoinProposal } from './join-proposals.js';
|
|
10
19
|
export { createPluginsRoutes } from './plugins.routes.js';
|
|
11
20
|
export type {
|
|
12
21
|
IPluginIndexService,
|
|
13
22
|
PluginCatalogEntry,
|
|
23
|
+
PluginMembership,
|
|
14
24
|
PluginSummary,
|
|
15
25
|
ResolvedPrincipals,
|
|
16
26
|
ResolvedReaders,
|