@bevel-software/platform-core-backend 0.13.6 → 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 +101 -9
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +20 -1
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +105 -43
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/core-config.d.ts.map +1 -1
- package/dist/core-config.js +12 -5
- package/dist/core-config.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/kb-read-filter.d.ts +12 -0
- package/dist/modules/access-model/kb-read-filter.d.ts.map +1 -1
- package/dist/modules/access-model/kb-read-filter.js +15 -0
- package/dist/modules/access-model/kb-read-filter.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/connection-probe/connection-probe.contract.d.ts +43 -0
- package/dist/modules/connection-probe/connection-probe.contract.d.ts.map +1 -0
- package/dist/modules/connection-probe/connection-probe.contract.js +2 -0
- package/dist/modules/connection-probe/connection-probe.contract.js.map +1 -0
- package/dist/modules/connection-probe/connection-probe.service.d.ts +94 -0
- package/dist/modules/connection-probe/connection-probe.service.d.ts.map +1 -0
- package/dist/modules/connection-probe/connection-probe.service.js +684 -0
- package/dist/modules/connection-probe/connection-probe.service.js.map +1 -0
- package/dist/modules/connection-probe/index.d.ts +3 -0
- package/dist/modules/connection-probe/index.d.ts.map +1 -0
- package/dist/modules/connection-probe/index.js +3 -0
- package/dist/modules/connection-probe/index.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/diff/diff.routes.d.ts.map +1 -1
- package/dist/modules/diff/diff.routes.js +3 -5
- package/dist/modules/diff/diff.routes.js.map +1 -1
- package/dist/modules/kb-fs/mutex.d.ts +37 -0
- package/dist/modules/kb-fs/mutex.d.ts.map +1 -1
- package/dist/modules/kb-fs/mutex.js +48 -5
- package/dist/modules/kb-fs/mutex.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/secrets-vault/db-secrets-vault.service.js +1 -1
- package/dist/modules/secrets-vault/db-secrets-vault.service.js.map +1 -1
- package/dist/modules/secrets-vault/secrets-vault.routes.d.ts +6 -0
- package/dist/modules/secrets-vault/secrets-vault.routes.d.ts.map +1 -1
- package/dist/modules/secrets-vault/secrets-vault.routes.js +31 -1
- package/dist/modules/secrets-vault/secrets-vault.routes.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 -83
- package/dist/modules/tool-manuals/mcp-json-discovery.js.map +1 -1
- package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/mcp-server-edit.service.js +10 -4
- package/dist/modules/tool-manuals/mcp-server-edit.service.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.contract.d.ts +83 -0
- package/dist/modules/tool-manuals/tool-manuals.contract.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts +15 -2
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.js +199 -38
- package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
- package/dist/modules/workflow/git/git.service.d.ts +58 -3
- package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/git.service.js +325 -60
- 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.routes.d.ts +2 -1
- package/dist/modules/workflow/workflow.routes.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.routes.js +98 -9
- package/dist/modules/workflow/workflow.routes.js.map +1 -1
- package/dist/modules/workflow/workflow.service.d.ts +133 -9
- package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.service.js +462 -52
- 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 +11 -14
- package/dist/modules/workspace/workspace.routes.js.map +1 -1
- package/dist/modules/workspace/workspace.service.d.ts +38 -1
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +131 -20
- 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/token-crypto.d.ts +17 -2
- package/dist/shared/token-crypto.d.ts.map +1 -1
- package/dist/shared/token-crypto.js +25 -8
- package/dist/shared/token-crypto.js.map +1 -1
- 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__/core-config.admin.test.ts +21 -0
- 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 +126 -7
- package/src/core/create-core-services.ts +173 -41
- package/src/core-config.ts +14 -7
- 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/kb-read-filter.ts +22 -0
- package/src/modules/access-model/plugin-principals.ts +137 -0
- package/src/modules/connection-probe/__tests__/connection-probe.service.test.ts +685 -0
- package/src/modules/connection-probe/connection-probe.contract.ts +44 -0
- package/src/modules/connection-probe/connection-probe.service.ts +734 -0
- package/src/modules/connection-probe/index.ts +2 -0
- package/src/modules/database/core-schema.ts +54 -0
- package/src/modules/diff/diff.routes.ts +9 -5
- package/src/modules/kb-fs/__tests__/mutex.test.ts +107 -0
- package/src/modules/kb-fs/mutex.ts +50 -5
- 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/secrets-vault/__tests__/connect-pending.route.test.ts +12 -0
- package/src/modules/secrets-vault/__tests__/oauth-return-to.route.test.ts +10 -3
- package/src/modules/secrets-vault/__tests__/tool-owner-gate.route.test.ts +26 -0
- package/src/modules/secrets-vault/db-secrets-vault.service.ts +1 -1
- package/src/modules/secrets-vault/secrets-vault.routes.ts +35 -1
- 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 +35 -1
- package/src/modules/tool-manuals/__tests__/tool-manuals.cli.test.ts +2 -0
- package/src/modules/tool-manuals/__tests__/tool-manuals.health-check.test.ts +104 -0
- package/src/modules/tool-manuals/__tests__/tool-manuals.service.test.ts +56 -0
- package/src/modules/tool-manuals/mcp-json-discovery.ts +154 -76
- package/src/modules/tool-manuals/mcp-server-edit.service.ts +13 -4
- package/src/modules/tool-manuals/tool-manuals.contract.ts +89 -0
- package/src/modules/tool-manuals/tool-manuals.service.ts +210 -37
- package/src/modules/workflow/__tests__/preserve-roles-yaml.test.ts +1 -1
- package/src/modules/workflow/__tests__/workflow.routes.history-read-gate.test.ts +139 -0
- package/src/modules/workflow/__tests__/workflow.service.branch-in-use.test.ts +337 -0
- package/src/modules/workflow/__tests__/workflow.service.commitFileWhileLocked.test.ts +1 -0
- package/src/modules/workflow/__tests__/workflow.service.deleted-branch-sweep.test.ts +7 -1
- package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +97 -10
- 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.history-guards.test.ts +86 -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 +354 -63
- package/src/modules/workflow/git/pull-request.service.ts +9 -0
- package/src/modules/workflow/workflow.routes.ts +104 -4
- package/src/modules/workflow/workflow.service.ts +505 -64
- 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 +17 -21
- package/src/modules/workspace/workspace.service.ts +128 -19
- 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__/token-crypto.test.ts +34 -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/token-crypto.ts +28 -10
- package/src/shared/ttl-cache.ts +33 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kb-plugin-source.d.ts","sourceRoot":"","sources":["../../../../src/modules/plugins/discovery/kb-plugin-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,SAAS,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtG,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAKzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,cAAe,YAAW,YAAY;IACjD,QAAQ,CAAC,OAAO,QAAQ;IAElB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAI5C,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,cAAc,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAOhG"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { PLUGINS_DIR, PLUGIN_MANIFEST_FILE, pluginManifestName } from '@bevel-software/platform-shared';
|
|
3
|
+
import { walkKb } from '../../../shared/kb-walk.js';
|
|
4
|
+
import { readNativePlugin } from './native.source.js';
|
|
5
|
+
import { BUNDLE_FILE, loadRegistry, readBundlePlugin } from './bundle-dialect/bundle.source.js';
|
|
6
|
+
/**
|
|
7
|
+
* THE plugin source: a LISTENER on the one walk of the checkout
|
|
8
|
+
* (`walkKb`), reading every folder under the plugins root in whichever of
|
|
9
|
+
* the two file shapes it carries.
|
|
10
|
+
*
|
|
11
|
+
* plugin.json → a native plugin (this platform's layout)
|
|
12
|
+
* plugin.bundle.json → a bundle (the customer dialect, read-only)
|
|
13
|
+
*
|
|
14
|
+
* Nothing else is a plugin. A folder's POSITION means nothing: the legacy
|
|
15
|
+
* rule "everything directly under the root is a plugin" is retired by the
|
|
16
|
+
* `plugin-manifests` boot step, which writes the manifest into every such
|
|
17
|
+
* folder once, so discovery never has to guess.
|
|
18
|
+
*
|
|
19
|
+
* A folder that IS a plugin claims everything beneath it (its `skills/` are
|
|
20
|
+
* its own) — the walk still visits what lies beneath, for the other
|
|
21
|
+
* listeners; this one ignores it. When a folder carries both files the
|
|
22
|
+
* manifest wins, so a bundle migrated in place stops being read as a bundle
|
|
23
|
+
* the moment a `plugin.json` lands beside it. Two plugins with one name keep
|
|
24
|
+
* the first by path (the walk's order) and warn about the second — a name is
|
|
25
|
+
* an identity to people and URLs, and two folders answering to it would be
|
|
26
|
+
* two plugins with one key.
|
|
27
|
+
*
|
|
28
|
+
* Holes — a folder under the root that could not be listed, an identity
|
|
29
|
+
* file that could not be read — are counted in `unreadable`: nothing behind
|
|
30
|
+
* them is listed, and a writer refuses while they exist.
|
|
31
|
+
*
|
|
32
|
+
* No setting picks a dialect. Nothing to configure means nothing to document
|
|
33
|
+
* and nothing to remove but the `else if` that reads bundles.
|
|
34
|
+
*/
|
|
35
|
+
export class KbPluginSource {
|
|
36
|
+
dialect = 'kb';
|
|
37
|
+
async discover(kbRoot) {
|
|
38
|
+
return (await this.walkWith(kbRoot, [])).discovery;
|
|
39
|
+
}
|
|
40
|
+
async walkWith(kbRoot, listeners) {
|
|
41
|
+
const warnings = [];
|
|
42
|
+
const registry = await loadRegistry(kbRoot, warnings);
|
|
43
|
+
const listener = pluginListener(kbRoot, registry, warnings);
|
|
44
|
+
const { holes } = await walkKb(kbRoot, [listener.listener, ...listeners]);
|
|
45
|
+
return { discovery: listener.result(), holes };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** The discovery listener over one walk, and the `Discovery` it has built once the walk is done. */
|
|
49
|
+
function pluginListener(kbRoot, registry, warnings) {
|
|
50
|
+
const unreadable = [];
|
|
51
|
+
const plugins = [];
|
|
52
|
+
const seen = new Map();
|
|
53
|
+
/** Folders claimed as plugins (or as holes standing where a plugin may be): nothing beneath is looked at. */
|
|
54
|
+
const claimed = [];
|
|
55
|
+
const underRoot = (rel) => rel === PLUGINS_DIR || rel.startsWith(`${PLUGINS_DIR}/`);
|
|
56
|
+
const beneathClaimed = (rel) => claimed.some((c) => rel === c || rel.startsWith(`${c}/`));
|
|
57
|
+
// Uniqueness is judged on the MANIFEST SLUG, not the raw name: `Sales Team`
|
|
58
|
+
// and `sales-team` fold to one slug, and the slug is what the compiled
|
|
59
|
+
// marketplace keys a plugin on — two folders sharing it would be two
|
|
60
|
+
// plugins with one key and one of them silently overwritten.
|
|
61
|
+
const claim = (plugin) => {
|
|
62
|
+
const key = pluginManifestName(plugin.name);
|
|
63
|
+
const twin = seen.get(key);
|
|
64
|
+
if (twin) {
|
|
65
|
+
warnings.push(`${plugin.folder}: plugin name "${plugin.name}" is already used by ${twin} — plugin skipped`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
seen.set(key, plugin.folder);
|
|
69
|
+
plugins.push(plugin);
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
listener: {
|
|
73
|
+
async onDir(rel, entries) {
|
|
74
|
+
if (!underRoot(rel) || rel === PLUGINS_DIR || beneathClaimed(rel))
|
|
75
|
+
return;
|
|
76
|
+
const has = (name) => entries.some((e) => e.isFile() && e.name === name);
|
|
77
|
+
const dir = path.join(kbRoot, rel);
|
|
78
|
+
const relFolder = rel.slice(PLUGINS_DIR.length + 1);
|
|
79
|
+
if (has(PLUGIN_MANIFEST_FILE)) {
|
|
80
|
+
claimed.push(rel);
|
|
81
|
+
// A manifest that could not be read: a hole, and still claimed.
|
|
82
|
+
const native = await readNativePlugin(dir, rel, relFolder, warnings, unreadable);
|
|
83
|
+
if (native)
|
|
84
|
+
claim(native);
|
|
85
|
+
}
|
|
86
|
+
else if (has(BUNDLE_FILE)) {
|
|
87
|
+
claimed.push(rel);
|
|
88
|
+
const bundle = await readBundlePlugin(dir, rel, relFolder, registry, warnings, unreadable);
|
|
89
|
+
if (bundle)
|
|
90
|
+
claim(bundle);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
onHole(rel, err) {
|
|
94
|
+
// A folder under the root that could not be listed hides every plugin
|
|
95
|
+
// beneath it; said out loud rather than letting the catalog shrink in
|
|
96
|
+
// silence, and COUNTED so a writer can tell an incomplete listing from
|
|
97
|
+
// a complete one. (Holes elsewhere in the tree are the walk's to report.)
|
|
98
|
+
if (!underRoot(rel) || beneathClaimed(rel))
|
|
99
|
+
return;
|
|
100
|
+
warnings.push(`${rel}: could not be read — ${err instanceof Error ? err.message : String(err)}`);
|
|
101
|
+
unreadable.push(rel);
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
result: () => ({ plugins, warnings, unreadable }),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=kb-plugin-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kb-plugin-source.js","sourceRoot":"","sources":["../../../../src/modules/plugins/discovery/kb-plugin-source.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAExG,OAAO,EAAE,MAAM,EAAuB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAGhG;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,cAAc;IAChB,OAAO,GAAG,IAAI,CAAC;IAExB,KAAK,CAAC,QAAQ,CAAC,MAAc;QAC3B,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAc,EAAE,SAAoC;QACjE,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC5D,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;QAC1E,OAAO,EAAE,SAAS,EAAE,QAAQ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,CAAC,GAAG,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC;oBAAE,OAAO;gBACnD,QAAQ,CAAC,IAAI,CAAC,GAAG,GAAG,yBAAyB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACjG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvB,CAAC;SACF;QACD,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;KAClD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DiscoveredPlugin } from './plugin-source.js';
|
|
2
|
+
/**
|
|
3
|
+
* A plugin in the layout this platform writes (see `kb-layout.ts`): a folder
|
|
4
|
+
* carrying `plugin.json`, optionally `mcp.json`, and the `access.md` that
|
|
5
|
+
* makes it exist to the index. Called by the walker for every folder it
|
|
6
|
+
* decides is a native plugin; reads the files, decides nothing else.
|
|
7
|
+
*
|
|
8
|
+
* Null when the manifest exists but could not be READ: the manifest is the
|
|
9
|
+
* identity, and a plugin whose identity nobody could see is not listed under
|
|
10
|
+
* a guessed one — it is a hole (`unreadable`), like a folder that could not
|
|
11
|
+
* be listed. The optional `mcp.json` carries no identity, so its read
|
|
12
|
+
* failure is a warning and nothing more.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readNativePlugin(dir: string, folder: string, relFolder: string, warnings: string[], unreadable: string[]): Promise<DiscoveredPlugin | null>;
|
|
15
|
+
//# sourceMappingURL=native.source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.source.d.ts","sourceRoot":"","sources":["../../../../src/modules/plugins/discovery/native.source.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAAE,EAClB,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CA0DlC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { PLUGIN_MANIFEST_FILE, PLUGIN_MCP_FILE, isPersonalPluginDir, isPluginIdentifier, linkedSkillRoots, pluginDisplayNameOf, pluginIdentityOf, } from '@bevel-software/platform-shared';
|
|
4
|
+
import { isAbsence } from '../../../shared/fs-errors.js';
|
|
5
|
+
/**
|
|
6
|
+
* A plugin in the layout this platform writes (see `kb-layout.ts`): a folder
|
|
7
|
+
* carrying `plugin.json`, optionally `mcp.json`, and the `access.md` that
|
|
8
|
+
* makes it exist to the index. Called by the walker for every folder it
|
|
9
|
+
* decides is a native plugin; reads the files, decides nothing else.
|
|
10
|
+
*
|
|
11
|
+
* Null when the manifest exists but could not be READ: the manifest is the
|
|
12
|
+
* identity, and a plugin whose identity nobody could see is not listed under
|
|
13
|
+
* a guessed one — it is a hole (`unreadable`), like a folder that could not
|
|
14
|
+
* be listed. The optional `mcp.json` carries no identity, so its read
|
|
15
|
+
* failure is a warning and nothing more.
|
|
16
|
+
*/
|
|
17
|
+
export async function readNativePlugin(dir, folder, relFolder, warnings, unreadable) {
|
|
18
|
+
const folderName = path.posix.basename(relFolder);
|
|
19
|
+
const manifestRead = await readText(path.join(dir, PLUGIN_MANIFEST_FILE), folder, warnings);
|
|
20
|
+
if (manifestRead.failed) {
|
|
21
|
+
unreadable.push(`${folder}/${PLUGIN_MANIFEST_FILE}`);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
// The walker probed the manifest a moment ago; gone now means it vanished
|
|
25
|
+
// between probe and read — then this is no plugin, not one under a guessed name.
|
|
26
|
+
if (manifestRead.text === null)
|
|
27
|
+
return null;
|
|
28
|
+
const manifestText = manifestRead.text;
|
|
29
|
+
const mcpJsonText = (await readText(path.join(dir, PLUGIN_MCP_FILE), folder, warnings)).text;
|
|
30
|
+
const manifest = parseObject(manifestText);
|
|
31
|
+
if (manifest === null) {
|
|
32
|
+
warnings.push(`${folder}/${PLUGIN_MANIFEST_FILE} is not a JSON object — treated as absent`);
|
|
33
|
+
}
|
|
34
|
+
// The manifest's `name` IS the identity — the grants, the URLs, the
|
|
35
|
+
// marketplace all spell it — when it is an identifier. One that is not
|
|
36
|
+
// (spaces, capitals) is never silently reinterpreted: the folder stands
|
|
37
|
+
// in, and the mismatch is said out loud so a grant written against the
|
|
38
|
+
// manifest's spelling is not a mystery.
|
|
39
|
+
const name = pluginIdentityOf(manifest, folderName);
|
|
40
|
+
const displayName = pluginDisplayNameOf(manifest, folderName);
|
|
41
|
+
// Any PRESENT name that is not an identifier is worth a word — a number or
|
|
42
|
+
// an object as much as a capitalised string. Only an absent name is silent.
|
|
43
|
+
if (manifest && manifest.name !== undefined && !isPluginIdentifier(manifest.name)) {
|
|
44
|
+
// A diagnostic must never be the thing that fails: a non-string name is
|
|
45
|
+
// described by its type, not serialised (a value nested deep enough
|
|
46
|
+
// would blow the stack on the way to a warning).
|
|
47
|
+
const spelled = typeof manifest.name === 'string'
|
|
48
|
+
? `"${manifest.name}"`
|
|
49
|
+
: `a value of type ${Array.isArray(manifest.name) ? 'array' : typeof manifest.name}`;
|
|
50
|
+
warnings.push(`${folder}/${PLUGIN_MANIFEST_FILE} names ${spelled}, which is not a plugin identifier (lowercase kebab-case) — the folder stands in as "${name}"`);
|
|
51
|
+
}
|
|
52
|
+
const mcp = parseObject(mcpJsonText);
|
|
53
|
+
const mcpServers = mcp && typeof mcp.mcpServers === 'object' && mcp.mcpServers !== null && !Array.isArray(mcp.mcpServers)
|
|
54
|
+
? mcp.mcpServers
|
|
55
|
+
: null;
|
|
56
|
+
const exists = await fs.stat(path.join(dir, 'access.md')).then((s) => s.isFile(), () => false);
|
|
57
|
+
return {
|
|
58
|
+
name,
|
|
59
|
+
displayName,
|
|
60
|
+
folder,
|
|
61
|
+
relFolder,
|
|
62
|
+
// The one structural rule: a direct child of the root with the prefix.
|
|
63
|
+
personal: isPersonalPluginDir(folder),
|
|
64
|
+
exists,
|
|
65
|
+
manifest,
|
|
66
|
+
manifestText,
|
|
67
|
+
linkedRoots: linkedSkillRoots(manifest),
|
|
68
|
+
mcpServers,
|
|
69
|
+
mcpJsonText,
|
|
70
|
+
linksAreManaged: true,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A file's text — null when there is no such file — and whether a file that
|
|
75
|
+
* IS there could not be read. Absence and failure are different answers;
|
|
76
|
+
* the caller decides what a failure means for the file in question.
|
|
77
|
+
*/
|
|
78
|
+
async function readText(abs, folder, warnings) {
|
|
79
|
+
try {
|
|
80
|
+
return { text: await fs.readFile(abs, 'utf-8'), failed: false };
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
if (isAbsence(err))
|
|
84
|
+
return { text: null, failed: false };
|
|
85
|
+
warnings.push(`${folder}/${path.basename(abs)} could not be read — ${err instanceof Error ? err.message : String(err)}`);
|
|
86
|
+
return { text: null, failed: true };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function parseObject(text) {
|
|
90
|
+
if (text === null)
|
|
91
|
+
return null;
|
|
92
|
+
try {
|
|
93
|
+
const parsed = JSON.parse(text);
|
|
94
|
+
return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)
|
|
95
|
+
? parsed
|
|
96
|
+
: null;
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=native.source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.source.js","sourceRoot":"","sources":["../../../../src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AAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAC5E,CAAC,CAAE,MAAkC;YACrC,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { KbWalkListener } from '../../../shared/kb-walk.js';
|
|
2
|
+
/**
|
|
3
|
+
* Plugin DISCOVERY as an interface — the one seam between "what a plugin is
|
|
4
|
+
* on disk" and everything that consumes plugins (the plugin index, the link
|
|
5
|
+
* index, the tool-manual scanner, the compiler).
|
|
6
|
+
*
|
|
7
|
+
* Two providers implement it:
|
|
8
|
+
*
|
|
9
|
+
* - `native.source.ts` — the Agent Plugins layout this platform writes:
|
|
10
|
+
* `Plugins/<Name>/plugin.json` (+ `mcp.json`,
|
|
11
|
+
* `access.md`, the hexis extension block).
|
|
12
|
+
* - `bundle-dialect/` — a customer's source layout: `plugin.bundle.json`
|
|
13
|
+
* files at any depth, pointing at skill roots and at
|
|
14
|
+
* an MCP profile in a registry. Read-only, and
|
|
15
|
+
* deletable as a unit once that customer migrates.
|
|
16
|
+
*
|
|
17
|
+
* Consumers see only {@link DiscoveredPlugin}: parsed objects, never files.
|
|
18
|
+
* A provider that reads a different file shape changes nothing downstream.
|
|
19
|
+
*/
|
|
20
|
+
export interface DiscoveredPlugin {
|
|
21
|
+
/**
|
|
22
|
+
* The plugin's IDENTITY everywhere a URL, a grant or a marketplace names
|
|
23
|
+
* it: the manifest's `name` — an Agent Plugins identifier — or the folder
|
|
24
|
+
* name folded into one when the manifest declares none it can be. A bundle
|
|
25
|
+
* plugin's is the bundle's `name`. Unique per source.
|
|
26
|
+
*/
|
|
27
|
+
name: string;
|
|
28
|
+
/** What a person sees it called: the manifest's `displayName`, else the folder name. */
|
|
29
|
+
displayName: string;
|
|
30
|
+
/** Repo-relative folder holding the plugin, e.g. `Plugins/GTM`. */
|
|
31
|
+
folder: string;
|
|
32
|
+
/** The same folder relative to the plugins root, e.g. `GTM` or `functional/x/y`. */
|
|
33
|
+
relFolder: string;
|
|
34
|
+
/** A personal folder (`Plugins/personal-<id>`): a place, not a plugin. */
|
|
35
|
+
personal: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the plugin EXISTS by the index's rule. Native: its folder carries
|
|
38
|
+
* an `access.md` (a bare directory is a ghost git left behind). Dialect:
|
|
39
|
+
* always — the bundle file is the existence.
|
|
40
|
+
*/
|
|
41
|
+
exists: boolean;
|
|
42
|
+
/** The Agent Plugins manifest, parsed (a dialect synthesises one). Null when absent or unparsable. */
|
|
43
|
+
manifest: Record<string, unknown> | null;
|
|
44
|
+
/** The manifest's raw text, for readers that want the extension block verbatim (native only). */
|
|
45
|
+
manifestText: string | null;
|
|
46
|
+
/** Repo-relative roots the plugin LINKS skills from — a skill folder or a folder of skills. */
|
|
47
|
+
linkedRoots: string[];
|
|
48
|
+
/** The `mcpServers` map of the plugin's `mcp.json`, parsed; null when it has none. */
|
|
49
|
+
mcpServers: Record<string, unknown> | null;
|
|
50
|
+
/** The raw `mcp.json` text, when it exists on disk (native only). */
|
|
51
|
+
mcpJsonText: string | null;
|
|
52
|
+
/**
|
|
53
|
+
* Whether hexis manages this plugin's links — writes them, grants the
|
|
54
|
+
* plugin's principal on the skill, reports a missing grant as needing
|
|
55
|
+
* repair. False for a dialect, whose links are plain references and whose
|
|
56
|
+
* skills' own scopes decide readability.
|
|
57
|
+
*/
|
|
58
|
+
linksAreManaged: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface Discovery {
|
|
61
|
+
plugins: DiscoveredPlugin[];
|
|
62
|
+
/** What was skipped and why — unparsable files, unknown profiles. */
|
|
63
|
+
warnings: string[];
|
|
64
|
+
/**
|
|
65
|
+
* HOLES: identity-bearing things that exist but could NOT be read
|
|
66
|
+
* (permissions, I/O), repo-relative — a folder that could not be listed,
|
|
67
|
+
* a manifest or bundle that could not be opened. Nothing behind a hole is
|
|
68
|
+
* in `plugins`: not absent, unseen, and never listed under a guessed name.
|
|
69
|
+
* A file that carries no identity (an `mcp.json`) is never a hole; its
|
|
70
|
+
* failure is a warning. A reader that only shows what it can carries on
|
|
71
|
+
* (the catalog does); a WRITER that keys a change on the set of plugins
|
|
72
|
+
* (a rename claiming a name) must refuse while this is not empty, or it
|
|
73
|
+
* may take an identity it could not see.
|
|
74
|
+
*/
|
|
75
|
+
unreadable: string[];
|
|
76
|
+
}
|
|
77
|
+
/** What one walk yields when discovery shares it: the plugins, and every hole the walk met anywhere. */
|
|
78
|
+
export interface PluginSourceWalk {
|
|
79
|
+
discovery: Discovery;
|
|
80
|
+
/** Every folder the walk could not list, repo-relative — under the plugins root or anywhere else. */
|
|
81
|
+
holes: string[];
|
|
82
|
+
}
|
|
83
|
+
export interface PluginSource {
|
|
84
|
+
/** A short name for logs and the settings screen. */
|
|
85
|
+
readonly dialect: string;
|
|
86
|
+
/** Enumerate the plugins in a KB checkout. Never throws: a broken tree yields warnings. */
|
|
87
|
+
discover(kbRoot: string): Promise<Discovery>;
|
|
88
|
+
/**
|
|
89
|
+
* Discover while driving other listeners from the SAME walk — a writer
|
|
90
|
+
* that needs plugins and grant files alike reads the tree once, and sees
|
|
91
|
+
* one set of holes. Optional: a source that cannot share its walk is
|
|
92
|
+
* discovered on its own and the caller walks separately.
|
|
93
|
+
*/
|
|
94
|
+
walkWith?(kbRoot: string, listeners: readonly KbWalkListener[]): Promise<PluginSourceWalk>;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=plugin-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-source.d.ts","sourceRoot":"","sources":["../../../../src/modules/plugins/discovery/plugin-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;;;;;;;;;;;;;GAiBG;AACH,MA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EAAE,SAAS,cAAc,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC5F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-source.js","sourceRoot":"","sources":["../../../../src/modules/plugins/discovery/plugin-source.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
export { PluginIndexService, pluginsWorkspaceId } from './plugins.service.js';
|
|
2
2
|
export { PluginProvisionService, PluginProvisionError, pluginAccessMd, personalAccessMd, } from './plugin-provision.service.js';
|
|
3
3
|
export { JoinRequestsService, type JoinRequest } from './join-requests.service.js';
|
|
4
|
+
export { PluginLinkIndex, type LinkMembership, type PluginLinks } from './plugin-links.js';
|
|
5
|
+
export { PluginLinksService, PluginLinkError } from './plugin-links.service.js';
|
|
6
|
+
export { PluginRenameService, PluginRenameError, renamePluginPrincipalInText } from './plugin-rename.service.js';
|
|
7
|
+
export { compileMarketplace, type VirtualTree, type CompileInput, type MarketplaceOptions } from './compile/compile-marketplace.js';
|
|
8
|
+
export { MarketplaceCompilerService, type CompileAudience } from './compile/marketplace-compiler.service.js';
|
|
9
|
+
export type { PluginSource, PluginSourceWalk, DiscoveredPlugin, Discovery } from './discovery/plugin-source.js';
|
|
10
|
+
export { walkKb, type KbWalkListener, type KbWalkResult } from '../../shared/kb-walk.js';
|
|
11
|
+
export { KbPluginSource } from './discovery/kb-plugin-source.js';
|
|
12
|
+
export { DEFAULT_REGISTRY_PATH } from './discovery/bundle-dialect/bundle.source.js';
|
|
4
13
|
export { pendingProposals, type JoinProposal } from './join-proposals.js';
|
|
5
14
|
export { createPluginsRoutes } from './plugins.routes.js';
|
|
6
|
-
export type { IPluginIndexService, PluginCatalogEntry, PluginSummary, ResolvedPrincipals, ResolvedReaders, } from './plugins.contract.js';
|
|
15
|
+
export type { IPluginIndexService, PluginCatalogEntry, PluginMembership, PluginSummary, ResolvedPrincipals, ResolvedReaders, } from './plugins.contract.js';
|
|
7
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,eAAe,GAChB,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACjH,OAAO,EAAE,kBAAkB,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACpI,OAAO,EAAE,0BAA0B,EAAE,KAAK,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC7G,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAChH,OAAO,EAAE,MAAM,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,eAAe,GAChB,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export { PluginIndexService, pluginsWorkspaceId } from './plugins.service.js';
|
|
2
2
|
export { PluginProvisionService, PluginProvisionError, pluginAccessMd, personalAccessMd, } from './plugin-provision.service.js';
|
|
3
3
|
export { JoinRequestsService } from './join-requests.service.js';
|
|
4
|
+
export { PluginLinkIndex } from './plugin-links.js';
|
|
5
|
+
export { PluginLinksService, PluginLinkError } from './plugin-links.service.js';
|
|
6
|
+
export { PluginRenameService, PluginRenameError, renamePluginPrincipalInText } from './plugin-rename.service.js';
|
|
7
|
+
export { compileMarketplace } from './compile/compile-marketplace.js';
|
|
8
|
+
export { MarketplaceCompilerService } from './compile/marketplace-compiler.service.js';
|
|
9
|
+
export { walkKb } from '../../shared/kb-walk.js';
|
|
10
|
+
export { KbPluginSource } from './discovery/kb-plugin-source.js';
|
|
11
|
+
export { DEFAULT_REGISTRY_PATH } from './discovery/bundle-dialect/bundle.source.js';
|
|
4
12
|
export { pendingProposals } from './join-proposals.js';
|
|
5
13
|
export { createPluginsRoutes } from './plugins.routes.js';
|
|
6
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAoB,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAqB,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAoB,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,eAAe,EAAyC,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACjH,OAAO,EAAE,kBAAkB,EAAgE,MAAM,kCAAkC,CAAC;AACpI,OAAO,EAAE,0BAA0B,EAAwB,MAAM,2CAA2C,CAAC;AAE7G,OAAO,EAAE,MAAM,EAA0C,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAqB,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { WorkspaceService } from '../workspace/workspace.service.js';
|
|
2
|
+
import type { IAccessControl } from '../access/access-control.interface.js';
|
|
3
|
+
import type { ISkillService } from '../skills/skills.contract.js';
|
|
4
|
+
import type { PluginMembership } from './plugins.contract.js';
|
|
5
|
+
import type { PluginSource } from './discovery/plugin-source.js';
|
|
6
|
+
/** One plugin's links, resolved against the released catalog. */
|
|
7
|
+
export interface PluginLinks {
|
|
8
|
+
/** The plugin's name — its identity to people and URLs. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Repo-relative plugin folder. */
|
|
11
|
+
folder: string;
|
|
12
|
+
/** The roots the manifest declares, normalised. */
|
|
13
|
+
roots: string[];
|
|
14
|
+
/** Skill folders the roots resolve to (released catalog only). */
|
|
15
|
+
linkedSkills: string[];
|
|
16
|
+
/** Roots that resolve to no released skill — a typo, or a skill not yet merged. */
|
|
17
|
+
unresolvedRoots: string[];
|
|
18
|
+
/** Whether hexis writes these links and checks their grants — see `DiscoveredPlugin`. */
|
|
19
|
+
linksAreManaged: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface LinkMembership {
|
|
22
|
+
/** skill path → every plugin that holds it, inline or by link. */
|
|
23
|
+
bySkill: Map<string, PluginMembership[]>;
|
|
24
|
+
/** plugin folder → its links. Every plugin folder appears, linked or not. */
|
|
25
|
+
byPlugin: Map<string, PluginLinks>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The link index: which shared skills each plugin links, and — the other way
|
|
29
|
+
* round — which plugins each skill belongs to, whether by sitting inside the
|
|
30
|
+
* plugin folder or by being linked from its manifest.
|
|
31
|
+
*
|
|
32
|
+
* Plugins come from the configured {@link PluginSource} (native manifests, or
|
|
33
|
+
* a customer dialect); resolution runs against the RELEASED catalog
|
|
34
|
+
* (`skillService.listSkills()`, unfiltered), never the file system: the
|
|
35
|
+
* catalog already applies the leaf-folder rule, the `.bevelignore` layers
|
|
36
|
+
* and the global-name dedup, and a second walk here would be a second
|
|
37
|
+
* opinion about what a skill is.
|
|
38
|
+
*
|
|
39
|
+
* `granted` is the consistency check the amber dot renders: a linked skill
|
|
40
|
+
* whose own access rules DO grant the plugin's `plugin/<Name>/read`
|
|
41
|
+
* principal (directly or from a scope above it). The link service writes
|
|
42
|
+
* that grant with the link; only a hand edit takes it away.
|
|
43
|
+
*
|
|
44
|
+
* Cached briefly, dropped by `invalidate()` from the same file-change
|
|
45
|
+
* subscriber that drops the plugin index, so a link committed on the default
|
|
46
|
+
* branch shows within one round-trip.
|
|
47
|
+
*/
|
|
48
|
+
export declare class PluginLinkIndex {
|
|
49
|
+
private readonly workspaceService;
|
|
50
|
+
private readonly skillService;
|
|
51
|
+
private readonly accessControl;
|
|
52
|
+
private readonly kbDirName;
|
|
53
|
+
private readonly source;
|
|
54
|
+
private readonly cache;
|
|
55
|
+
constructor(workspaceService: WorkspaceService, skillService: ISkillService, accessControl: IAccessControl, kbDirName: string, now?: () => number, source?: PluginSource);
|
|
56
|
+
invalidate(): void;
|
|
57
|
+
membership(): Promise<LinkMembership>;
|
|
58
|
+
/** Convenience: the memberships of one skill (empty when it is in no plugin). */
|
|
59
|
+
pluginsOf(skillPath: string): Promise<PluginMembership[]>;
|
|
60
|
+
private build;
|
|
61
|
+
/** Whether the skill folder's effective readers include the plugin's read principal. */
|
|
62
|
+
private isGranted;
|
|
63
|
+
}
|
|
64
|
+
/** The default-branch workspace id every link resolution runs against. */
|
|
65
|
+
export declare function linksWorkspaceId(): string;
|
|
66
|
+
//# sourceMappingURL=plugin-links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-links.d.ts","sourceRoot":"","sources":["../../../src/modules/plugins/plugin-links.ts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C,GAAG,GAAE,MAAM,MAAiB,EACX,MAAM,GAAE,YAAmC;IAK9D,UAAU,IAAI,IAAI;IAIZ,UAAU,IAAI,OAAO,CAAC,cAAc,CAAC;IAgB3C,iFAAiF;IAC3E,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAMjD,KAAK;IAoEnB,wFAAwF;YAC1E,SAAS;CAUxB;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { DEFAULT_BRANCH, pluginManifestName, skillUnderRoot } from '@bevel-software/platform-shared';
|
|
3
|
+
import { workspaceIdForBranch } from '../../shared/workspace-id.js';
|
|
4
|
+
import { TtlCache } from '../../shared/ttl-cache.js';
|
|
5
|
+
import { canonicalRoleName, pluginPrincipalKey } from '../access-model/access-grammar.js';
|
|
6
|
+
import { KbPluginSource } from './discovery/kb-plugin-source.js';
|
|
7
|
+
const CACHE_TTL_MS = 60_000;
|
|
8
|
+
/**
|
|
9
|
+
* The link index: which shared skills each plugin links, and — the other way
|
|
10
|
+
* round — which plugins each skill belongs to, whether by sitting inside the
|
|
11
|
+
* plugin folder or by being linked from its manifest.
|
|
12
|
+
*
|
|
13
|
+
* Plugins come from the configured {@link PluginSource} (native manifests, or
|
|
14
|
+
* a customer dialect); resolution runs against the RELEASED catalog
|
|
15
|
+
* (`skillService.listSkills()`, unfiltered), never the file system: the
|
|
16
|
+
* catalog already applies the leaf-folder rule, the `.bevelignore` layers
|
|
17
|
+
* and the global-name dedup, and a second walk here would be a second
|
|
18
|
+
* opinion about what a skill is.
|
|
19
|
+
*
|
|
20
|
+
* `granted` is the consistency check the amber dot renders: a linked skill
|
|
21
|
+
* whose own access rules DO grant the plugin's `plugin/<Name>/read`
|
|
22
|
+
* principal (directly or from a scope above it). The link service writes
|
|
23
|
+
* that grant with the link; only a hand edit takes it away.
|
|
24
|
+
*
|
|
25
|
+
* Cached briefly, dropped by `invalidate()` from the same file-change
|
|
26
|
+
* subscriber that drops the plugin index, so a link committed on the default
|
|
27
|
+
* branch shows within one round-trip.
|
|
28
|
+
*/
|
|
29
|
+
export class PluginLinkIndex {
|
|
30
|
+
workspaceService;
|
|
31
|
+
skillService;
|
|
32
|
+
accessControl;
|
|
33
|
+
kbDirName;
|
|
34
|
+
source;
|
|
35
|
+
cache;
|
|
36
|
+
constructor(workspaceService, skillService, accessControl, kbDirName, now = Date.now, source = new KbPluginSource()) {
|
|
37
|
+
this.workspaceService = workspaceService;
|
|
38
|
+
this.skillService = skillService;
|
|
39
|
+
this.accessControl = accessControl;
|
|
40
|
+
this.kbDirName = kbDirName;
|
|
41
|
+
this.source = source;
|
|
42
|
+
this.cache = new TtlCache(CACHE_TTL_MS, now);
|
|
43
|
+
}
|
|
44
|
+
invalidate() {
|
|
45
|
+
this.cache.invalidate();
|
|
46
|
+
}
|
|
47
|
+
async membership() {
|
|
48
|
+
const cached = this.cache.get();
|
|
49
|
+
if (cached)
|
|
50
|
+
return cached;
|
|
51
|
+
// Token first, like the other catalogs: an `invalidate()` landing while
|
|
52
|
+
// the build reads the pre-change tree must not be undone by storing that
|
|
53
|
+
// read afterwards.
|
|
54
|
+
const token = this.cache.begin();
|
|
55
|
+
const built = await this.build();
|
|
56
|
+
// A degraded read (no workspace yet) is served but not stored — the same
|
|
57
|
+
// reasoning as the plugin index: caching a failure hides every link for
|
|
58
|
+
// a full TTL after its cause is gone.
|
|
59
|
+
if (built === null)
|
|
60
|
+
return { bySkill: new Map(), byPlugin: new Map() };
|
|
61
|
+
this.cache.set(built, token);
|
|
62
|
+
return built;
|
|
63
|
+
}
|
|
64
|
+
/** Convenience: the memberships of one skill (empty when it is in no plugin). */
|
|
65
|
+
async pluginsOf(skillPath) {
|
|
66
|
+
return (await this.membership()).bySkill.get(skillPath) ?? [];
|
|
67
|
+
}
|
|
68
|
+
// --- internal --------------------------------------------------------------
|
|
69
|
+
async build() {
|
|
70
|
+
let wsId;
|
|
71
|
+
let kbRoot;
|
|
72
|
+
try {
|
|
73
|
+
wsId = (await this.workspaceService.getOrCreateForBranch(DEFAULT_BRANCH)).id;
|
|
74
|
+
kbRoot = path.join(await this.workspaceService.getWorkspacePath(wsId), this.kbDirName);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const skills = await this.skillService.listSkills(undefined);
|
|
80
|
+
const bySkill = new Map();
|
|
81
|
+
const byPlugin = new Map();
|
|
82
|
+
const add = (skillPath, m) => {
|
|
83
|
+
const list = bySkill.get(skillPath) ?? [];
|
|
84
|
+
if (!list.some((x) => x.name === m.name))
|
|
85
|
+
list.push(m);
|
|
86
|
+
bySkill.set(skillPath, list);
|
|
87
|
+
};
|
|
88
|
+
const discovered = await this.source.discover(kbRoot);
|
|
89
|
+
for (const w of discovered.warnings)
|
|
90
|
+
console.warn(`[plugins] ${w}`);
|
|
91
|
+
// Inline skills: the ones sitting INSIDE a plugin's folder, matched by
|
|
92
|
+
// folder prefix (a plugin may sit at any depth, so the second path
|
|
93
|
+
// segment says nothing). Personal folders are places, not plugins —
|
|
94
|
+
// their skills belong to nobody's plugin.
|
|
95
|
+
const ownerOf = (skillPath) => discovered.plugins.find((p) => !p.personal && p.exists && skillPath.startsWith(`${p.folder}/`));
|
|
96
|
+
for (const s of skills) {
|
|
97
|
+
const owner = ownerOf(s.path);
|
|
98
|
+
if (owner)
|
|
99
|
+
add(s.path, { name: owner.name, linked: false, granted: true });
|
|
100
|
+
}
|
|
101
|
+
for (const plugin of discovered.plugins) {
|
|
102
|
+
// Personal folders are places, not plugins; a manifest without the
|
|
103
|
+
// access.md that makes a plugin EXIST is a ghost the index and the
|
|
104
|
+
// compiler omit, so it must not be linkable or hold grants either.
|
|
105
|
+
if (plugin.personal || !plugin.exists)
|
|
106
|
+
continue;
|
|
107
|
+
const roots = plugin.linkedRoots;
|
|
108
|
+
const linkedSkills = [];
|
|
109
|
+
const unresolvedRoots = [];
|
|
110
|
+
for (const root of roots) {
|
|
111
|
+
const hits = skills.filter((s) => skillUnderRoot(s.path, root)).map((s) => s.path);
|
|
112
|
+
if (hits.length === 0)
|
|
113
|
+
unresolvedRoots.push(root);
|
|
114
|
+
for (const hit of hits)
|
|
115
|
+
if (!linkedSkills.includes(hit))
|
|
116
|
+
linkedSkills.push(hit);
|
|
117
|
+
}
|
|
118
|
+
byPlugin.set(plugin.name, {
|
|
119
|
+
name: plugin.name,
|
|
120
|
+
folder: plugin.folder,
|
|
121
|
+
roots,
|
|
122
|
+
linkedSkills,
|
|
123
|
+
unresolvedRoots,
|
|
124
|
+
linksAreManaged: plugin.linksAreManaged,
|
|
125
|
+
});
|
|
126
|
+
if (linkedSkills.length === 0)
|
|
127
|
+
continue;
|
|
128
|
+
const token = pluginPrincipalKey(pluginManifestName(plugin.name), 'read');
|
|
129
|
+
for (const skillPath of linkedSkills) {
|
|
130
|
+
// A skill that also sits INSIDE this plugin folder is inline, and its
|
|
131
|
+
// inline membership already stands.
|
|
132
|
+
if (skillPath.startsWith(`${plugin.folder}/`))
|
|
133
|
+
continue;
|
|
134
|
+
// An unmanaged (dialect) link is a plain reference: nothing to grant,
|
|
135
|
+
// nothing to repair — the skill's own scope decides who reads it.
|
|
136
|
+
const granted = plugin.linksAreManaged ? await this.isGranted(wsId, skillPath, token) : true;
|
|
137
|
+
add(skillPath, { name: plugin.name, linked: true, granted });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { bySkill, byPlugin };
|
|
141
|
+
}
|
|
142
|
+
/** Whether the skill folder's effective readers include the plugin's read principal. */
|
|
143
|
+
async isGranted(wsId, skillPath, token) {
|
|
144
|
+
try {
|
|
145
|
+
const readers = await this.accessControl.eligibleReaders(wsId, skillPath);
|
|
146
|
+
if (!readers.restricted)
|
|
147
|
+
return true; // readable by everyone — the plugin's members included
|
|
148
|
+
// The resolver reports display names; compare through the one canonicaliser.
|
|
149
|
+
return (readers.principals ?? []).some((p) => p.kind === 'plugin' && canonicalRoleName(p.name) === token);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return false; // fail closed: an unreadable tree reports the link as needing repair
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** The default-branch workspace id every link resolution runs against. */
|
|
157
|
+
export function linksWorkspaceId() {
|
|
158
|
+
return workspaceIdForBranch(DEFAULT_BRANCH);
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=plugin-links.js.map
|