@opensip-cli/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +31 -0
- package/dist/__tests__/config-resolution.test.d.ts +2 -0
- package/dist/__tests__/config-resolution.test.d.ts.map +1 -0
- package/dist/__tests__/config-resolution.test.js +94 -0
- package/dist/__tests__/config-resolution.test.js.map +1 -0
- package/dist/__tests__/public-api.test.d.ts +16 -0
- package/dist/__tests__/public-api.test.d.ts.map +1 -0
- package/dist/__tests__/public-api.test.js +209 -0
- package/dist/__tests__/public-api.test.js.map +1 -0
- package/dist/__tests__/signal-batch.test.d.ts +2 -0
- package/dist/__tests__/signal-batch.test.d.ts.map +1 -0
- package/dist/__tests__/signal-batch.test.js +39 -0
- package/dist/__tests__/signal-batch.test.js.map +1 -0
- package/dist/__tests__/signal-sink.test.d.ts +2 -0
- package/dist/__tests__/signal-sink.test.d.ts.map +1 -0
- package/dist/__tests__/signal-sink.test.js +25 -0
- package/dist/__tests__/signal-sink.test.js.map +1 -0
- package/dist/__tests__/strip-utils.test.d.ts +2 -0
- package/dist/__tests__/strip-utils.test.d.ts.map +1 -0
- package/dist/__tests__/strip-utils.test.js +397 -0
- package/dist/__tests__/strip-utils.test.js.map +1 -0
- package/dist/__tests__/text-tree.test.d.ts +2 -0
- package/dist/__tests__/text-tree.test.d.ts.map +1 -0
- package/dist/__tests__/text-tree.test.js +31 -0
- package/dist/__tests__/text-tree.test.js.map +1 -0
- package/dist/baseline/__tests__/fingerprint-strategy.test.d.ts +2 -0
- package/dist/baseline/__tests__/fingerprint-strategy.test.d.ts.map +1 -0
- package/dist/baseline/__tests__/fingerprint-strategy.test.js +69 -0
- package/dist/baseline/__tests__/fingerprint-strategy.test.js.map +1 -0
- package/dist/baseline/fingerprint-strategy.d.ts +70 -0
- package/dist/baseline/fingerprint-strategy.d.ts.map +1 -0
- package/dist/baseline/fingerprint-strategy.js +90 -0
- package/dist/baseline/fingerprint-strategy.js.map +1 -0
- package/dist/config-resolution.d.ts +27 -0
- package/dist/config-resolution.d.ts.map +1 -0
- package/dist/config-resolution.js +92 -0
- package/dist/config-resolution.js.map +1 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +165 -0
- package/dist/index.js.map +1 -0
- package/dist/languages/__tests__/content-filter-dispatch.test.d.ts +2 -0
- package/dist/languages/__tests__/content-filter-dispatch.test.d.ts.map +1 -0
- package/dist/languages/__tests__/content-filter-dispatch.test.js +87 -0
- package/dist/languages/__tests__/content-filter-dispatch.test.js.map +1 -0
- package/dist/languages/__tests__/non-code-formats.test.d.ts +2 -0
- package/dist/languages/__tests__/non-code-formats.test.d.ts.map +1 -0
- package/dist/languages/__tests__/non-code-formats.test.js +31 -0
- package/dist/languages/__tests__/non-code-formats.test.js.map +1 -0
- package/dist/languages/__tests__/parse-cache.test.d.ts +2 -0
- package/dist/languages/__tests__/parse-cache.test.d.ts.map +1 -0
- package/dist/languages/__tests__/parse-cache.test.js +228 -0
- package/dist/languages/__tests__/parse-cache.test.js.map +1 -0
- package/dist/languages/__tests__/registry.test.d.ts +2 -0
- package/dist/languages/__tests__/registry.test.d.ts.map +1 -0
- package/dist/languages/__tests__/registry.test.js +193 -0
- package/dist/languages/__tests__/registry.test.js.map +1 -0
- package/dist/languages/__tests__/workspace-unit-contract.test.d.ts +2 -0
- package/dist/languages/__tests__/workspace-unit-contract.test.d.ts.map +1 -0
- package/dist/languages/__tests__/workspace-unit-contract.test.js +66 -0
- package/dist/languages/__tests__/workspace-unit-contract.test.js.map +1 -0
- package/dist/languages/adapter.d.ts +66 -0
- package/dist/languages/adapter.d.ts.map +1 -0
- package/dist/languages/adapter.js +2 -0
- package/dist/languages/adapter.js.map +1 -0
- package/dist/languages/content-filter-dispatch.d.ts +36 -0
- package/dist/languages/content-filter-dispatch.d.ts.map +1 -0
- package/dist/languages/content-filter-dispatch.js +75 -0
- package/dist/languages/content-filter-dispatch.js.map +1 -0
- package/dist/languages/generic-types.d.ts +22 -0
- package/dist/languages/generic-types.d.ts.map +1 -0
- package/dist/languages/generic-types.js +3 -0
- package/dist/languages/generic-types.js.map +1 -0
- package/dist/languages/index.d.ts +12 -0
- package/dist/languages/index.d.ts.map +1 -0
- package/dist/languages/index.js +7 -0
- package/dist/languages/index.js.map +1 -0
- package/dist/languages/non-code-formats.d.ts +37 -0
- package/dist/languages/non-code-formats.d.ts.map +1 -0
- package/dist/languages/non-code-formats.js +45 -0
- package/dist/languages/non-code-formats.js.map +1 -0
- package/dist/languages/parse-cache-class.d.ts +69 -0
- package/dist/languages/parse-cache-class.d.ts.map +1 -0
- package/dist/languages/parse-cache-class.js +135 -0
- package/dist/languages/parse-cache-class.js.map +1 -0
- package/dist/languages/parse-cache.d.ts +54 -0
- package/dist/languages/parse-cache.d.ts.map +1 -0
- package/dist/languages/parse-cache.js +88 -0
- package/dist/languages/parse-cache.js.map +1 -0
- package/dist/languages/registry.d.ts +35 -0
- package/dist/languages/registry.d.ts.map +1 -0
- package/dist/languages/registry.js +123 -0
- package/dist/languages/registry.js.map +1 -0
- package/dist/languages/strip-scanners.d.ts +170 -0
- package/dist/languages/strip-scanners.d.ts.map +1 -0
- package/dist/languages/strip-scanners.js +233 -0
- package/dist/languages/strip-scanners.js.map +1 -0
- package/dist/languages/strip-utils.d.ts +66 -0
- package/dist/languages/strip-utils.d.ts.map +1 -0
- package/dist/languages/strip-utils.js +88 -0
- package/dist/languages/strip-utils.js.map +1 -0
- package/dist/languages/text-tree.d.ts +44 -0
- package/dist/languages/text-tree.d.ts.map +1 -0
- package/dist/languages/text-tree.js +34 -0
- package/dist/languages/text-tree.js.map +1 -0
- package/dist/languages/workspace-unit.d.ts +18 -0
- package/dist/languages/workspace-unit.d.ts.map +1 -0
- package/dist/languages/workspace-unit.js +2 -0
- package/dist/languages/workspace-unit.js.map +1 -0
- package/dist/lib/__tests__/config-version.test.d.ts +12 -0
- package/dist/lib/__tests__/config-version.test.d.ts.map +1 -0
- package/dist/lib/__tests__/config-version.test.js +92 -0
- package/dist/lib/__tests__/config-version.test.js.map +1 -0
- package/dist/lib/__tests__/diagnostics-bus.test.d.ts +7 -0
- package/dist/lib/__tests__/diagnostics-bus.test.d.ts.map +1 -0
- package/dist/lib/__tests__/diagnostics-bus.test.js +44 -0
- package/dist/lib/__tests__/diagnostics-bus.test.js.map +1 -0
- package/dist/lib/__tests__/env-registry.test.d.ts +7 -0
- package/dist/lib/__tests__/env-registry.test.d.ts.map +1 -0
- package/dist/lib/__tests__/env-registry.test.js +82 -0
- package/dist/lib/__tests__/env-registry.test.js.map +1 -0
- package/dist/lib/__tests__/errors.test.d.ts +2 -0
- package/dist/lib/__tests__/errors.test.d.ts.map +1 -0
- package/dist/lib/__tests__/errors.test.js +218 -0
- package/dist/lib/__tests__/errors.test.js.map +1 -0
- package/dist/lib/__tests__/format.test.d.ts +2 -0
- package/dist/lib/__tests__/format.test.d.ts.map +1 -0
- package/dist/lib/__tests__/format.test.js +23 -0
- package/dist/lib/__tests__/format.test.js.map +1 -0
- package/dist/lib/__tests__/ids.test.d.ts +2 -0
- package/dist/lib/__tests__/ids.test.d.ts.map +1 -0
- package/dist/lib/__tests__/ids.test.js +80 -0
- package/dist/lib/__tests__/ids.test.js.map +1 -0
- package/dist/lib/__tests__/logger.test.d.ts +2 -0
- package/dist/lib/__tests__/logger.test.d.ts.map +1 -0
- package/dist/lib/__tests__/logger.test.js +284 -0
- package/dist/lib/__tests__/logger.test.js.map +1 -0
- package/dist/lib/__tests__/package-version.test.d.ts +2 -0
- package/dist/lib/__tests__/package-version.test.d.ts.map +1 -0
- package/dist/lib/__tests__/package-version.test.js +47 -0
- package/dist/lib/__tests__/package-version.test.js.map +1 -0
- package/dist/lib/__tests__/paths.test.d.ts +5 -0
- package/dist/lib/__tests__/paths.test.d.ts.map +1 -0
- package/dist/lib/__tests__/paths.test.js +59 -0
- package/dist/lib/__tests__/paths.test.js.map +1 -0
- package/dist/lib/__tests__/payload-version.test.d.ts +2 -0
- package/dist/lib/__tests__/payload-version.test.d.ts.map +1 -0
- package/dist/lib/__tests__/payload-version.test.js +35 -0
- package/dist/lib/__tests__/payload-version.test.js.map +1 -0
- package/dist/lib/__tests__/phantom-detect.test.d.ts +10 -0
- package/dist/lib/__tests__/phantom-detect.test.d.ts.map +1 -0
- package/dist/lib/__tests__/phantom-detect.test.js +84 -0
- package/dist/lib/__tests__/phantom-detect.test.js.map +1 -0
- package/dist/lib/__tests__/project-context.test.d.ts +10 -0
- package/dist/lib/__tests__/project-context.test.d.ts.map +1 -0
- package/dist/lib/__tests__/project-context.test.js +240 -0
- package/dist/lib/__tests__/project-context.test.js.map +1 -0
- package/dist/lib/__tests__/registry.test.d.ts +2 -0
- package/dist/lib/__tests__/registry.test.d.ts.map +1 -0
- package/dist/lib/__tests__/registry.test.js +333 -0
- package/dist/lib/__tests__/registry.test.js.map +1 -0
- package/dist/lib/__tests__/retry.test.d.ts +2 -0
- package/dist/lib/__tests__/retry.test.d.ts.map +1 -0
- package/dist/lib/__tests__/retry.test.js +71 -0
- package/dist/lib/__tests__/retry.test.js.map +1 -0
- package/dist/lib/__tests__/run-diagnostics.test.d.ts +9 -0
- package/dist/lib/__tests__/run-diagnostics.test.d.ts.map +1 -0
- package/dist/lib/__tests__/run-diagnostics.test.js +61 -0
- package/dist/lib/__tests__/run-diagnostics.test.js.map +1 -0
- package/dist/lib/__tests__/run-scope.test.d.ts +2 -0
- package/dist/lib/__tests__/run-scope.test.d.ts.map +1 -0
- package/dist/lib/__tests__/run-scope.test.js +202 -0
- package/dist/lib/__tests__/run-scope.test.js.map +1 -0
- package/dist/lib/__tests__/run-timer.test.d.ts +2 -0
- package/dist/lib/__tests__/run-timer.test.d.ts.map +1 -0
- package/dist/lib/__tests__/run-timer.test.js +152 -0
- package/dist/lib/__tests__/run-timer.test.js.map +1 -0
- package/dist/lib/__tests__/severity-policy.test.d.ts +6 -0
- package/dist/lib/__tests__/severity-policy.test.d.ts.map +1 -0
- package/dist/lib/__tests__/severity-policy.test.js +47 -0
- package/dist/lib/__tests__/severity-policy.test.js.map +1 -0
- package/dist/lib/__tests__/telemetry.test.d.ts +2 -0
- package/dist/lib/__tests__/telemetry.test.d.ts.map +1 -0
- package/dist/lib/__tests__/telemetry.test.js +212 -0
- package/dist/lib/__tests__/telemetry.test.js.map +1 -0
- package/dist/lib/__tests__/verdict-policy.test.d.ts +7 -0
- package/dist/lib/__tests__/verdict-policy.test.d.ts.map +1 -0
- package/dist/lib/__tests__/verdict-policy.test.js +91 -0
- package/dist/lib/__tests__/verdict-policy.test.js.map +1 -0
- package/dist/lib/__tests__/yaml.test.d.ts +6 -0
- package/dist/lib/__tests__/yaml.test.d.ts.map +1 -0
- package/dist/lib/__tests__/yaml.test.js +79 -0
- package/dist/lib/__tests__/yaml.test.js.map +1 -0
- package/dist/lib/config-version.d.ts +49 -0
- package/dist/lib/config-version.d.ts.map +1 -0
- package/dist/lib/config-version.js +56 -0
- package/dist/lib/config-version.js.map +1 -0
- package/dist/lib/diagnostics-bus.d.ts +48 -0
- package/dist/lib/diagnostics-bus.d.ts.map +1 -0
- package/dist/lib/diagnostics-bus.js +74 -0
- package/dist/lib/diagnostics-bus.js.map +1 -0
- package/dist/lib/env-registry.d.ts +108 -0
- package/dist/lib/env-registry.d.ts.map +1 -0
- package/dist/lib/env-registry.js +92 -0
- package/dist/lib/env-registry.js.map +1 -0
- package/dist/lib/errors.d.ts +132 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +160 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/execution/__tests__/execution.test.d.ts +7 -0
- package/dist/lib/execution/__tests__/execution.test.d.ts.map +1 -0
- package/dist/lib/execution/__tests__/execution.test.js +254 -0
- package/dist/lib/execution/__tests__/execution.test.js.map +1 -0
- package/dist/lib/execution/index.d.ts +15 -0
- package/dist/lib/execution/index.d.ts.map +1 -0
- package/dist/lib/execution/index.js +10 -0
- package/dist/lib/execution/index.js.map +1 -0
- package/dist/lib/execution/options.d.ts +32 -0
- package/dist/lib/execution/options.d.ts.map +1 -0
- package/dist/lib/execution/options.js +15 -0
- package/dist/lib/execution/options.js.map +1 -0
- package/dist/lib/execution/pipeline.d.ts +36 -0
- package/dist/lib/execution/pipeline.d.ts.map +1 -0
- package/dist/lib/execution/pipeline.js +38 -0
- package/dist/lib/execution/pipeline.js.map +1 -0
- package/dist/lib/execution/retry.d.ts +38 -0
- package/dist/lib/execution/retry.d.ts.map +1 -0
- package/dist/lib/execution/retry.js +56 -0
- package/dist/lib/execution/retry.js.map +1 -0
- package/dist/lib/execution/run-with-timeout.d.ts +46 -0
- package/dist/lib/execution/run-with-timeout.d.ts.map +1 -0
- package/dist/lib/execution/run-with-timeout.js +86 -0
- package/dist/lib/execution/run-with-timeout.js.map +1 -0
- package/dist/lib/execution/schedule.d.ts +62 -0
- package/dist/lib/execution/schedule.d.ts.map +1 -0
- package/dist/lib/execution/schedule.js +130 -0
- package/dist/lib/execution/schedule.js.map +1 -0
- package/dist/lib/format.d.ts +17 -0
- package/dist/lib/format.d.ts.map +1 -0
- package/dist/lib/format.js +26 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/ids.d.ts +13 -0
- package/dist/lib/ids.d.ts.map +1 -0
- package/dist/lib/ids.js +48 -0
- package/dist/lib/ids.js.map +1 -0
- package/dist/lib/logger.d.ts +166 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +283 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/package-version.d.ts +17 -0
- package/dist/lib/package-version.d.ts.map +1 -0
- package/dist/lib/package-version.js +52 -0
- package/dist/lib/package-version.js.map +1 -0
- package/dist/lib/paths.d.ts +139 -0
- package/dist/lib/paths.d.ts.map +1 -0
- package/dist/lib/paths.js +105 -0
- package/dist/lib/paths.js.map +1 -0
- package/dist/lib/payload-version.d.ts +15 -0
- package/dist/lib/payload-version.d.ts.map +1 -0
- package/dist/lib/payload-version.js +24 -0
- package/dist/lib/payload-version.js.map +1 -0
- package/dist/lib/phantom-detect.d.ts +21 -0
- package/dist/lib/phantom-detect.d.ts.map +1 -0
- package/dist/lib/phantom-detect.js +76 -0
- package/dist/lib/phantom-detect.js.map +1 -0
- package/dist/lib/project-context.d.ts +66 -0
- package/dist/lib/project-context.d.ts.map +1 -0
- package/dist/lib/project-context.js +112 -0
- package/dist/lib/project-context.js.map +1 -0
- package/dist/lib/recipe-id.d.ts +13 -0
- package/dist/lib/recipe-id.d.ts.map +1 -0
- package/dist/lib/recipe-id.js +15 -0
- package/dist/lib/recipe-id.js.map +1 -0
- package/dist/lib/registry.d.ts +98 -0
- package/dist/lib/registry.d.ts.map +1 -0
- package/dist/lib/registry.js +152 -0
- package/dist/lib/registry.js.map +1 -0
- package/dist/lib/retry.d.ts +26 -0
- package/dist/lib/retry.d.ts.map +1 -0
- package/dist/lib/retry.js +48 -0
- package/dist/lib/retry.js.map +1 -0
- package/dist/lib/run-diagnostics.d.ts +64 -0
- package/dist/lib/run-diagnostics.d.ts.map +1 -0
- package/dist/lib/run-diagnostics.js +25 -0
- package/dist/lib/run-diagnostics.js.map +1 -0
- package/dist/lib/run-scope.d.ts +167 -0
- package/dist/lib/run-scope.d.ts.map +1 -0
- package/dist/lib/run-scope.js +176 -0
- package/dist/lib/run-scope.js.map +1 -0
- package/dist/lib/run-timer.d.ts +82 -0
- package/dist/lib/run-timer.d.ts.map +1 -0
- package/dist/lib/run-timer.js +79 -0
- package/dist/lib/run-timer.js.map +1 -0
- package/dist/lib/scope-types.d.ts +172 -0
- package/dist/lib/scope-types.d.ts.map +1 -0
- package/dist/lib/scope-types.js +27 -0
- package/dist/lib/scope-types.js.map +1 -0
- package/dist/lib/severity-policy.d.ts +38 -0
- package/dist/lib/severity-policy.d.ts.map +1 -0
- package/dist/lib/severity-policy.js +44 -0
- package/dist/lib/severity-policy.js.map +1 -0
- package/dist/lib/telemetry.d.ts +93 -0
- package/dist/lib/telemetry.d.ts.map +1 -0
- package/dist/lib/telemetry.js +144 -0
- package/dist/lib/telemetry.js.map +1 -0
- package/dist/lib/ui-context.d.ts +34 -0
- package/dist/lib/ui-context.d.ts.map +1 -0
- package/dist/lib/ui-context.js +16 -0
- package/dist/lib/ui-context.js.map +1 -0
- package/dist/lib/verdict-policy.d.ts +71 -0
- package/dist/lib/verdict-policy.d.ts.map +1 -0
- package/dist/lib/verdict-policy.js +82 -0
- package/dist/lib/verdict-policy.js.map +1 -0
- package/dist/lib/yaml.d.ts +74 -0
- package/dist/lib/yaml.d.ts.map +1 -0
- package/dist/lib/yaml.js +118 -0
- package/dist/lib/yaml.js.map +1 -0
- package/dist/plugins/__tests__/as-if-external.test.d.ts +18 -0
- package/dist/plugins/__tests__/as-if-external.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/as-if-external.test.js +159 -0
- package/dist/plugins/__tests__/as-if-external.test.js.map +1 -0
- package/dist/plugins/__tests__/authored-tool-discovery.test.d.ts +8 -0
- package/dist/plugins/__tests__/authored-tool-discovery.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/authored-tool-discovery.test.js +97 -0
- package/dist/plugins/__tests__/authored-tool-discovery.test.js.map +1 -0
- package/dist/plugins/__tests__/capability-discovery.test.d.ts +2 -0
- package/dist/plugins/__tests__/capability-discovery.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/capability-discovery.test.js +349 -0
- package/dist/plugins/__tests__/capability-discovery.test.js.map +1 -0
- package/dist/plugins/__tests__/capability-from-manifest.test.d.ts +2 -0
- package/dist/plugins/__tests__/capability-from-manifest.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/capability-from-manifest.test.js +172 -0
- package/dist/plugins/__tests__/capability-from-manifest.test.js.map +1 -0
- package/dist/plugins/__tests__/capability-loader.test.d.ts +2 -0
- package/dist/plugins/__tests__/capability-loader.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/capability-loader.test.js +122 -0
- package/dist/plugins/__tests__/capability-loader.test.js.map +1 -0
- package/dist/plugins/__tests__/capability-registry.test.d.ts +2 -0
- package/dist/plugins/__tests__/capability-registry.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/capability-registry.test.js +185 -0
- package/dist/plugins/__tests__/capability-registry.test.js.map +1 -0
- package/dist/plugins/__tests__/discover.test.d.ts +2 -0
- package/dist/plugins/__tests__/discover.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/discover.test.js +311 -0
- package/dist/plugins/__tests__/discover.test.js.map +1 -0
- package/dist/plugins/__tests__/loader.test.d.ts +2 -0
- package/dist/plugins/__tests__/loader.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/loader.test.js +191 -0
- package/dist/plugins/__tests__/loader.test.js.map +1 -0
- package/dist/plugins/__tests__/manifest-discovery.test.d.ts +2 -0
- package/dist/plugins/__tests__/manifest-discovery.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/manifest-discovery.test.js +132 -0
- package/dist/plugins/__tests__/manifest-discovery.test.js.map +1 -0
- package/dist/plugins/__tests__/manifest-loader.test.d.ts +2 -0
- package/dist/plugins/__tests__/manifest-loader.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/manifest-loader.test.js +434 -0
- package/dist/plugins/__tests__/manifest-loader.test.js.map +1 -0
- package/dist/plugins/__tests__/marker-discovery.test.d.ts +2 -0
- package/dist/plugins/__tests__/marker-discovery.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/marker-discovery.test.js +164 -0
- package/dist/plugins/__tests__/marker-discovery.test.js.map +1 -0
- package/dist/plugins/__tests__/node-modules-walk.test.d.ts +2 -0
- package/dist/plugins/__tests__/node-modules-walk.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/node-modules-walk.test.js +76 -0
- package/dist/plugins/__tests__/node-modules-walk.test.js.map +1 -0
- package/dist/plugins/__tests__/package-entry.test.d.ts +9 -0
- package/dist/plugins/__tests__/package-entry.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/package-entry.test.js +117 -0
- package/dist/plugins/__tests__/package-entry.test.js.map +1 -0
- package/dist/plugins/__tests__/recipe-loader.test.d.ts +2 -0
- package/dist/plugins/__tests__/recipe-loader.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/recipe-loader.test.js +130 -0
- package/dist/plugins/__tests__/recipe-loader.test.js.map +1 -0
- package/dist/plugins/__tests__/scope-validation.test.d.ts +2 -0
- package/dist/plugins/__tests__/scope-validation.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/scope-validation.test.js +68 -0
- package/dist/plugins/__tests__/scope-validation.test.js.map +1 -0
- package/dist/plugins/__tests__/single-core-guard.test.d.ts +10 -0
- package/dist/plugins/__tests__/single-core-guard.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/single-core-guard.test.js +89 -0
- package/dist/plugins/__tests__/single-core-guard.test.js.map +1 -0
- package/dist/plugins/__tests__/tool-package-discovery.test.d.ts +2 -0
- package/dist/plugins/__tests__/tool-package-discovery.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/tool-package-discovery.test.js +215 -0
- package/dist/plugins/__tests__/tool-package-discovery.test.js.map +1 -0
- package/dist/plugins/authored-tool-discovery.d.ts +45 -0
- package/dist/plugins/authored-tool-discovery.d.ts.map +1 -0
- package/dist/plugins/authored-tool-discovery.js +61 -0
- package/dist/plugins/authored-tool-discovery.js.map +1 -0
- package/dist/plugins/capability-discovery.d.ts +80 -0
- package/dist/plugins/capability-discovery.d.ts.map +1 -0
- package/dist/plugins/capability-discovery.js +278 -0
- package/dist/plugins/capability-discovery.js.map +1 -0
- package/dist/plugins/capability-loader.d.ts +50 -0
- package/dist/plugins/capability-loader.d.ts.map +1 -0
- package/dist/plugins/capability-loader.js +85 -0
- package/dist/plugins/capability-loader.js.map +1 -0
- package/dist/plugins/capability-registry.d.ts +169 -0
- package/dist/plugins/capability-registry.d.ts.map +1 -0
- package/dist/plugins/capability-registry.js +319 -0
- package/dist/plugins/capability-registry.js.map +1 -0
- package/dist/plugins/discover.d.ts +64 -0
- package/dist/plugins/discover.d.ts.map +1 -0
- package/dist/plugins/discover.js +303 -0
- package/dist/plugins/discover.js.map +1 -0
- package/dist/plugins/index.d.ts +37 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +40 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/json-guards.d.ts +11 -0
- package/dist/plugins/json-guards.d.ts.map +1 -0
- package/dist/plugins/json-guards.js +15 -0
- package/dist/plugins/json-guards.js.map +1 -0
- package/dist/plugins/loader.d.ts +67 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +137 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/manifest-discovery.d.ts +28 -0
- package/dist/plugins/manifest-discovery.d.ts.map +1 -0
- package/dist/plugins/manifest-discovery.js +103 -0
- package/dist/plugins/manifest-discovery.js.map +1 -0
- package/dist/plugins/manifest-loader.d.ts +120 -0
- package/dist/plugins/manifest-loader.d.ts.map +1 -0
- package/dist/plugins/manifest-loader.js +410 -0
- package/dist/plugins/manifest-loader.js.map +1 -0
- package/dist/plugins/marker-discovery.d.ts +115 -0
- package/dist/plugins/marker-discovery.d.ts.map +1 -0
- package/dist/plugins/marker-discovery.js +172 -0
- package/dist/plugins/marker-discovery.js.map +1 -0
- package/dist/plugins/node-modules-walk.d.ts +61 -0
- package/dist/plugins/node-modules-walk.d.ts.map +1 -0
- package/dist/plugins/node-modules-walk.js +99 -0
- package/dist/plugins/node-modules-walk.js.map +1 -0
- package/dist/plugins/package-entry.d.ts +38 -0
- package/dist/plugins/package-entry.d.ts.map +1 -0
- package/dist/plugins/package-entry.js +86 -0
- package/dist/plugins/package-entry.js.map +1 -0
- package/dist/plugins/recipe-loader.d.ts +63 -0
- package/dist/plugins/recipe-loader.d.ts.map +1 -0
- package/dist/plugins/recipe-loader.js +67 -0
- package/dist/plugins/recipe-loader.js.map +1 -0
- package/dist/plugins/scope-validation.d.ts +35 -0
- package/dist/plugins/scope-validation.d.ts.map +1 -0
- package/dist/plugins/scope-validation.js +55 -0
- package/dist/plugins/scope-validation.js.map +1 -0
- package/dist/plugins/single-core-guard.d.ts +28 -0
- package/dist/plugins/single-core-guard.d.ts.map +1 -0
- package/dist/plugins/single-core-guard.js +69 -0
- package/dist/plugins/single-core-guard.js.map +1 -0
- package/dist/plugins/tool-package-discovery.d.ts +93 -0
- package/dist/plugins/tool-package-discovery.d.ts.map +1 -0
- package/dist/plugins/tool-package-discovery.js +118 -0
- package/dist/plugins/tool-package-discovery.js.map +1 -0
- package/dist/plugins/types.d.ts +78 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +15 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/recipes/__tests__/registry.test.d.ts +2 -0
- package/dist/recipes/__tests__/registry.test.d.ts.map +1 -0
- package/dist/recipes/__tests__/registry.test.js +170 -0
- package/dist/recipes/__tests__/registry.test.js.map +1 -0
- package/dist/recipes/__tests__/selector.test.d.ts +20 -0
- package/dist/recipes/__tests__/selector.test.d.ts.map +1 -0
- package/dist/recipes/__tests__/selector.test.js +173 -0
- package/dist/recipes/__tests__/selector.test.js.map +1 -0
- package/dist/recipes/__tests__/unit-config.test.d.ts +7 -0
- package/dist/recipes/__tests__/unit-config.test.d.ts.map +1 -0
- package/dist/recipes/__tests__/unit-config.test.js +52 -0
- package/dist/recipes/__tests__/unit-config.test.js.map +1 -0
- package/dist/recipes/registry.d.ts +105 -0
- package/dist/recipes/registry.d.ts.map +1 -0
- package/dist/recipes/registry.js +141 -0
- package/dist/recipes/registry.js.map +1 -0
- package/dist/recipes/selector.d.ts +112 -0
- package/dist/recipes/selector.d.ts.map +1 -0
- package/dist/recipes/selector.js +134 -0
- package/dist/recipes/selector.js.map +1 -0
- package/dist/recipes/unit-config.d.ts +63 -0
- package/dist/recipes/unit-config.d.ts.map +1 -0
- package/dist/recipes/unit-config.js +68 -0
- package/dist/recipes/unit-config.js.map +1 -0
- package/dist/runtime/__tests__/in-process-transport.test.d.ts +6 -0
- package/dist/runtime/__tests__/in-process-transport.test.d.ts.map +1 -0
- package/dist/runtime/__tests__/in-process-transport.test.js +73 -0
- package/dist/runtime/__tests__/in-process-transport.test.js.map +1 -0
- package/dist/runtime/__tests__/subprocess-transport.test.d.ts +11 -0
- package/dist/runtime/__tests__/subprocess-transport.test.d.ts.map +1 -0
- package/dist/runtime/__tests__/subprocess-transport.test.js +118 -0
- package/dist/runtime/__tests__/subprocess-transport.test.js.map +1 -0
- package/dist/runtime/in-process-transport.d.ts +20 -0
- package/dist/runtime/in-process-transport.d.ts.map +1 -0
- package/dist/runtime/in-process-transport.js +49 -0
- package/dist/runtime/in-process-transport.js.map +1 -0
- package/dist/runtime/progress-transport.d.ts +73 -0
- package/dist/runtime/progress-transport.d.ts.map +1 -0
- package/dist/runtime/progress-transport.js +17 -0
- package/dist/runtime/progress-transport.js.map +1 -0
- package/dist/runtime/subprocess-transport.d.ts +43 -0
- package/dist/runtime/subprocess-transport.d.ts.map +1 -0
- package/dist/runtime/subprocess-transport.js +134 -0
- package/dist/runtime/subprocess-transport.js.map +1 -0
- package/dist/signals/comment-openers.d.ts +29 -0
- package/dist/signals/comment-openers.d.ts.map +1 -0
- package/dist/signals/comment-openers.js +41 -0
- package/dist/signals/comment-openers.js.map +1 -0
- package/dist/signals/comment-openers.test.d.ts +7 -0
- package/dist/signals/comment-openers.test.d.ts.map +1 -0
- package/dist/signals/comment-openers.test.js +41 -0
- package/dist/signals/comment-openers.test.js.map +1 -0
- package/dist/signals/create-signal-from-violation.d.ts +29 -0
- package/dist/signals/create-signal-from-violation.d.ts.map +1 -0
- package/dist/signals/create-signal-from-violation.js +29 -0
- package/dist/signals/create-signal-from-violation.js.map +1 -0
- package/dist/signals/signal-sink.d.ts +49 -0
- package/dist/signals/signal-sink.d.ts.map +1 -0
- package/dist/signals/signal-sink.js +6 -0
- package/dist/signals/signal-sink.js.map +1 -0
- package/dist/signals/suppress.d.ts +102 -0
- package/dist/signals/suppress.d.ts.map +1 -0
- package/dist/signals/suppress.js +325 -0
- package/dist/signals/suppress.js.map +1 -0
- package/dist/signals/suppress.test.d.ts +2 -0
- package/dist/signals/suppress.test.d.ts.map +1 -0
- package/dist/signals/suppress.test.js +213 -0
- package/dist/signals/suppress.test.js.map +1 -0
- package/dist/tools/__tests__/command-spec.test.d.ts +2 -0
- package/dist/tools/__tests__/command-spec.test.d.ts.map +1 -0
- package/dist/tools/__tests__/command-spec.test.js +191 -0
- package/dist/tools/__tests__/command-spec.test.js.map +1 -0
- package/dist/tools/__tests__/compatibility.test.d.ts +5 -0
- package/dist/tools/__tests__/compatibility.test.d.ts.map +1 -0
- package/dist/tools/__tests__/compatibility.test.js +41 -0
- package/dist/tools/__tests__/compatibility.test.js.map +1 -0
- package/dist/tools/__tests__/ids.test.d.ts +5 -0
- package/dist/tools/__tests__/ids.test.d.ts.map +1 -0
- package/dist/tools/__tests__/ids.test.js +56 -0
- package/dist/tools/__tests__/ids.test.js.map +1 -0
- package/dist/tools/__tests__/manifest-assert.test.d.ts +5 -0
- package/dist/tools/__tests__/manifest-assert.test.d.ts.map +1 -0
- package/dist/tools/__tests__/manifest-assert.test.js +66 -0
- package/dist/tools/__tests__/manifest-assert.test.js.map +1 -0
- package/dist/tools/__tests__/registry.test.d.ts +2 -0
- package/dist/tools/__tests__/registry.test.d.ts.map +1 -0
- package/dist/tools/__tests__/registry.test.js +93 -0
- package/dist/tools/__tests__/registry.test.js.map +1 -0
- package/dist/tools/__tests__/types.test.d.ts +2 -0
- package/dist/tools/__tests__/types.test.d.ts.map +1 -0
- package/dist/tools/__tests__/types.test.js +51 -0
- package/dist/tools/__tests__/types.test.js.map +1 -0
- package/dist/tools/capability.d.ts +257 -0
- package/dist/tools/capability.d.ts.map +1 -0
- package/dist/tools/capability.js +46 -0
- package/dist/tools/capability.js.map +1 -0
- package/dist/tools/command-spec.d.ts +211 -0
- package/dist/tools/command-spec.d.ts.map +1 -0
- package/dist/tools/command-spec.js +110 -0
- package/dist/tools/command-spec.js.map +1 -0
- package/dist/tools/compatibility.d.ts +45 -0
- package/dist/tools/compatibility.d.ts.map +1 -0
- package/dist/tools/compatibility.js +49 -0
- package/dist/tools/compatibility.js.map +1 -0
- package/dist/tools/ids.d.ts +61 -0
- package/dist/tools/ids.d.ts.map +1 -0
- package/dist/tools/ids.js +61 -0
- package/dist/tools/ids.js.map +1 -0
- package/dist/tools/index.d.ts +22 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +28 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/manifest-assert.d.ts +35 -0
- package/dist/tools/manifest-assert.d.ts.map +1 -0
- package/dist/tools/manifest-assert.js +67 -0
- package/dist/tools/manifest-assert.js.map +1 -0
- package/dist/tools/manifest.d.ts +178 -0
- package/dist/tools/manifest.d.ts.map +1 -0
- package/dist/tools/manifest.js +35 -0
- package/dist/tools/manifest.js.map +1 -0
- package/dist/tools/registry.d.ts +37 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +49 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/types.d.ts +1021 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +77 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/types/__tests__/signal.test.d.ts +2 -0
- package/dist/types/__tests__/signal.test.d.ts.map +1 -0
- package/dist/types/__tests__/signal.test.js +111 -0
- package/dist/types/__tests__/signal.test.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/signal-batch.d.ts +56 -0
- package/dist/types/signal-batch.d.ts.map +1 -0
- package/dist/types/signal-batch.js +54 -0
- package/dist/types/signal-batch.js.map +1 -0
- package/dist/types/signal.d.ts +77 -0
- package/dist/types/signal.d.ts.map +1 -0
- package/dist/types/signal.js +42 -0
- package/dist/types/signal.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
// @fitness-ignore-file error-handling-quality -- safeIsDirectory/safeIsFile/isPathInside are filesystem probes where exception → false is the function's contract; missing path or unresolvable realpath legitimately means "not present" / "not inside", not a swallowed error.
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Plugin discovery for the project-local layout.
|
|
4
|
+
*
|
|
5
|
+
* Discovery is descriptor-driven: the caller passes a `PluginLayout`
|
|
6
|
+
* (`{ domain, userSubdirs }`) declared by the owning tool. The kernel
|
|
7
|
+
* never enumerates tool domains itself (ADR-0009 corollary 1). Two
|
|
8
|
+
* artifact sources are walked for the layout:
|
|
9
|
+
*
|
|
10
|
+
* 1. USER SOURCE — recursive `.js` / `.mjs` files under
|
|
11
|
+
* `<project>/opensip-cli/<domain>/<kind>/`
|
|
12
|
+
* for each `kind` in `layout.userSubdirs` (e.g. `checks`/`recipes`
|
|
13
|
+
* for fitness, `scenarios`/`recipes` for simulation). Auto-loaded
|
|
14
|
+
* by directory presence; no config opt-in.
|
|
15
|
+
*
|
|
16
|
+
* 2. NPM PLUGINS — packages installed under
|
|
17
|
+
* `<project>/opensip-cli/.runtime/plugins/<domain>/node_modules/`
|
|
18
|
+
* whose names appear in the project's
|
|
19
|
+
* `opensip-cli.config.yml#plugins.<domain>: [...]`. The explicit
|
|
20
|
+
* list is required so a `plugin install` step is intentional, not
|
|
21
|
+
* an accidental load of every transitive devDep.
|
|
22
|
+
*
|
|
23
|
+
* A layout with an empty `userSubdirs` and no declared npm plugins
|
|
24
|
+
* (e.g. the language-adapter domain, whose adapters ship as direct CLI
|
|
25
|
+
* deps) discovers nothing — an emergent property, not a special case.
|
|
26
|
+
*/
|
|
27
|
+
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
28
|
+
import { join, extname, relative, sep } from 'node:path';
|
|
29
|
+
import { resolveProjectConfigPath } from '../config-resolution.js';
|
|
30
|
+
import { logger } from '../lib/logger.js';
|
|
31
|
+
import { isPathInside, resolveProjectPaths } from '../lib/paths.js';
|
|
32
|
+
import { readYamlFile } from '../lib/yaml.js';
|
|
33
|
+
import { resolvePackageEntryPoint } from './package-entry.js';
|
|
34
|
+
/** Logger module tag used by every event in this file. */
|
|
35
|
+
const MODULE_TAG = 'core:plugins';
|
|
36
|
+
// =============================================================================
|
|
37
|
+
// PUBLIC ENTRY POINT
|
|
38
|
+
// =============================================================================
|
|
39
|
+
/**
|
|
40
|
+
* Discover all plugins for a layout in the project layout.
|
|
41
|
+
*
|
|
42
|
+
* Returns a list of `DiscoveredPlugin` entries (loose .mjs files +
|
|
43
|
+
* npm packages) for the loader to import. Discovery is silent on a
|
|
44
|
+
* missing project directory or absent subdirs — callers that care
|
|
45
|
+
* about "did we find anything?" should check the returned length.
|
|
46
|
+
*
|
|
47
|
+
* @param layout The owning tool's `PluginLayout` (`{ domain,
|
|
48
|
+
* userSubdirs }`).
|
|
49
|
+
* @param projectDir Project root. Required — there is no user-global
|
|
50
|
+
* fallback. Pass undefined to discover nothing
|
|
51
|
+
* (used by callers that don't have a project
|
|
52
|
+
* context yet).
|
|
53
|
+
*/
|
|
54
|
+
export function discoverPlugins(layout, projectDir) {
|
|
55
|
+
if (!projectDir)
|
|
56
|
+
return [];
|
|
57
|
+
const { domain, userSubdirs } = layout;
|
|
58
|
+
const projectPaths = resolveProjectPaths(projectDir);
|
|
59
|
+
const plugins = [];
|
|
60
|
+
// 1. User-source loose files: opensip-cli/<domain>/<kind>/*.{js,mjs}
|
|
61
|
+
const toolDir = join(projectPaths.userSourceDir, domain);
|
|
62
|
+
for (const kind of userSubdirs) {
|
|
63
|
+
const kindDir = join(toolDir, kind);
|
|
64
|
+
if (!existsSync(kindDir))
|
|
65
|
+
continue;
|
|
66
|
+
plugins.push(...discoverLooseFiles(kindDir, `${domain}/${kind}`));
|
|
67
|
+
}
|
|
68
|
+
// 2. Npm-installed plugins under .runtime/plugins/<domain>/.
|
|
69
|
+
// Only walked when the config explicitly declares
|
|
70
|
+
// plugins.<domain>: [...]. The runtime dir is gitignored, so
|
|
71
|
+
// silently auto-loading anything in it would be a recipe for
|
|
72
|
+
// "where did this check come from?" surprises. Explicit listing
|
|
73
|
+
// is the contract for npm plugins.
|
|
74
|
+
const declared = readProjectPluginsList(projectDir, domain);
|
|
75
|
+
if (declared && declared.length > 0) {
|
|
76
|
+
const pluginsDir = projectPaths.pluginsDir(domain);
|
|
77
|
+
const nodeModulesDir = join(pluginsDir, 'node_modules');
|
|
78
|
+
if (existsSync(nodeModulesDir)) {
|
|
79
|
+
plugins.push(...discoverNpmPackages(nodeModulesDir, declared));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
logger.info({
|
|
83
|
+
evt: 'plugin.loader.discover',
|
|
84
|
+
module: MODULE_TAG,
|
|
85
|
+
domain,
|
|
86
|
+
packageCount: plugins.filter((p) => p.type === 'package').length,
|
|
87
|
+
fileCount: plugins.filter((p) => p.type === 'file').length,
|
|
88
|
+
});
|
|
89
|
+
return plugins;
|
|
90
|
+
}
|
|
91
|
+
// =============================================================================
|
|
92
|
+
// CONFIG READING (plugins.<domain> from opensip-cli.config.yml)
|
|
93
|
+
// =============================================================================
|
|
94
|
+
/**
|
|
95
|
+
* Read the declared plugin list for a domain from the project config.
|
|
96
|
+
* Returns undefined when the config is absent, unreadable, or has no
|
|
97
|
+
* entry for the domain. Does NOT throw on YAML parse errors — returns
|
|
98
|
+
* undefined so discovery falls through gracefully and the config-layer
|
|
99
|
+
* schema validation surfaces parse errors on its own path.
|
|
100
|
+
*
|
|
101
|
+
* Config-path resolution mirrors `resolveProjectConfigPath` (the same
|
|
102
|
+
* helper the targets loader uses): --config flag → `package.json#
|
|
103
|
+
* opensip-cli.configPath` pointer → default `<projectDir>/opensip-
|
|
104
|
+
* tools.config.yml`. Without this, projects that locate their config
|
|
105
|
+
* via the package.json pointer have their `plugins.<domain>: [...]`
|
|
106
|
+
* declaration silently ignored — discovery falls through to the empty
|
|
107
|
+
* default path and the plugin pack never registers.
|
|
108
|
+
*
|
|
109
|
+
* The `--config` precedence is honored only when callers pass through
|
|
110
|
+
* their explicit value via `explicitConfigPath`; this entry point is
|
|
111
|
+
* the implicit one (no --config available at the discovery seam), so
|
|
112
|
+
* we resolve without an explicit path and rely on the pointer + default.
|
|
113
|
+
*/
|
|
114
|
+
export function readProjectPluginsList(projectDir, domain) {
|
|
115
|
+
let configPath;
|
|
116
|
+
try {
|
|
117
|
+
configPath = resolveProjectConfigPath(projectDir);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// resolveProjectConfigPath throws on "no config found anywhere" —
|
|
121
|
+
// discovery is implicit (no --config), so a missing config falls
|
|
122
|
+
// through gracefully here (the explicit-path layer surfaces its own
|
|
123
|
+
// error when the caller asked for one).
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
// Parse YAML via the shared permissive helper to avoid a circular dep
|
|
127
|
+
// between plugins/ and targets/. We only need the `plugins.<domain>`
|
|
128
|
+
// array; anything else is validated by the targets loader.
|
|
129
|
+
const doc = readYamlFile(configPath);
|
|
130
|
+
if (!doc || typeof doc !== 'object')
|
|
131
|
+
return undefined;
|
|
132
|
+
const plugins = doc.plugins;
|
|
133
|
+
if (!plugins || typeof plugins !== 'object')
|
|
134
|
+
return undefined;
|
|
135
|
+
const list = plugins[domain];
|
|
136
|
+
if (!Array.isArray(list))
|
|
137
|
+
return undefined;
|
|
138
|
+
return list.filter((v) => typeof v === 'string');
|
|
139
|
+
}
|
|
140
|
+
// =============================================================================
|
|
141
|
+
// NPM PACKAGE DISCOVERY
|
|
142
|
+
// =============================================================================
|
|
143
|
+
function discoverNpmPackages(nodeModulesDir, declared) {
|
|
144
|
+
const plugins = [];
|
|
145
|
+
for (const name of declared) {
|
|
146
|
+
// Reject names that could traverse before they ever touch the filesystem.
|
|
147
|
+
// The plugin list comes from opensip-cli.config.yml — user-controlled
|
|
148
|
+
// content under a project that runs `opensip fit` would otherwise
|
|
149
|
+
// act as an attacker-influenced input flowing into a path join.
|
|
150
|
+
if (name.length === 0 || name.includes('..') || name.startsWith('/') || name.includes('\0')) {
|
|
151
|
+
logger.warn({
|
|
152
|
+
evt: 'plugin.loader.discover.reject',
|
|
153
|
+
module: MODULE_TAG,
|
|
154
|
+
reason: 'invalid plugin name',
|
|
155
|
+
name,
|
|
156
|
+
});
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const packageDir = join(nodeModulesDir, name);
|
|
160
|
+
// Containment check: the resolved real path (after symlinks) must
|
|
161
|
+
// stay inside node_modules. Catches symlink-based escapes if an
|
|
162
|
+
// attacker plants a symlink.
|
|
163
|
+
if (!isPathInside(packageDir, nodeModulesDir)) {
|
|
164
|
+
logger.warn({
|
|
165
|
+
evt: 'plugin.loader.discover.reject',
|
|
166
|
+
module: MODULE_TAG,
|
|
167
|
+
reason: 'package path resolves outside node_modules',
|
|
168
|
+
name,
|
|
169
|
+
});
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const plugin = tryDiscoverPackage(packageDir, name);
|
|
173
|
+
if (plugin)
|
|
174
|
+
plugins.push(plugin);
|
|
175
|
+
}
|
|
176
|
+
return plugins;
|
|
177
|
+
}
|
|
178
|
+
function tryDiscoverPackage(packageDir, name) {
|
|
179
|
+
if (!safeIsDirectory(packageDir))
|
|
180
|
+
return undefined;
|
|
181
|
+
const resolved = resolvePackageEntryPoint(packageDir, name);
|
|
182
|
+
if (!resolved) {
|
|
183
|
+
logger.debug({
|
|
184
|
+
evt: 'plugin.loader.discover.skip',
|
|
185
|
+
module: MODULE_TAG,
|
|
186
|
+
reason: 'invalid package.json',
|
|
187
|
+
name,
|
|
188
|
+
});
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
// Containment check: the resolved entry must stay inside `packageDir`
|
|
192
|
+
// after symlink resolution. A malicious or accidentally-malformed
|
|
193
|
+
// `pkg.main` / `pkg.exports` such as `../../escape.js` would otherwise
|
|
194
|
+
// traverse out of node_modules and be dynamically imported. The earlier
|
|
195
|
+
// package-dir containment check (discoverNpmPackages) does not cover
|
|
196
|
+
// the entry-file path, so we re-check it here.
|
|
197
|
+
if (!isPathInside(resolved.entry, packageDir)) {
|
|
198
|
+
logger.warn({
|
|
199
|
+
evt: 'plugin.loader.discover.reject',
|
|
200
|
+
module: MODULE_TAG,
|
|
201
|
+
reason: 'entry point resolves outside package directory',
|
|
202
|
+
name,
|
|
203
|
+
entry: resolved.entry,
|
|
204
|
+
});
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
if (!existsSync(resolved.entry)) {
|
|
208
|
+
logger.debug({
|
|
209
|
+
evt: 'plugin.loader.discover.skip',
|
|
210
|
+
module: MODULE_TAG,
|
|
211
|
+
reason: 'entry point not found',
|
|
212
|
+
packageName: resolved.name,
|
|
213
|
+
entryPoint: resolved.entry,
|
|
214
|
+
});
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
type: 'package',
|
|
219
|
+
entryPoint: resolved.entry,
|
|
220
|
+
namespace: resolved.name,
|
|
221
|
+
source: resolved.name,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
// =============================================================================
|
|
225
|
+
// LOOSE FILE DISCOVERY
|
|
226
|
+
// =============================================================================
|
|
227
|
+
const LOOSE_FILE_EXTENSIONS = new Set(['.js', '.mjs']);
|
|
228
|
+
function discoverLooseFiles(dir, namespacePrefix) {
|
|
229
|
+
return discoverLooseFilesInDir(dir, namespacePrefix, dir);
|
|
230
|
+
}
|
|
231
|
+
function discoverLooseFilesInDir(dir, namespacePrefix, rootDir) {
|
|
232
|
+
const plugins = [];
|
|
233
|
+
let entries;
|
|
234
|
+
try {
|
|
235
|
+
entries = readdirSync(dir);
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
return plugins;
|
|
239
|
+
}
|
|
240
|
+
for (const entry of entries) {
|
|
241
|
+
const fullPath = join(dir, entry);
|
|
242
|
+
if (safeIsDirectory(fullPath)) {
|
|
243
|
+
if (!isPathInside(fullPath, rootDir)) {
|
|
244
|
+
logger.warn({
|
|
245
|
+
evt: 'plugin.loader.discover.reject',
|
|
246
|
+
module: MODULE_TAG,
|
|
247
|
+
reason: 'loose file directory resolves outside plugin dir',
|
|
248
|
+
entry,
|
|
249
|
+
});
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
plugins.push(...discoverLooseFilesInDir(fullPath, namespacePrefix, rootDir));
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
const ext = extname(entry);
|
|
256
|
+
if (!LOOSE_FILE_EXTENSIONS.has(ext))
|
|
257
|
+
continue;
|
|
258
|
+
if (!safeIsFile(fullPath))
|
|
259
|
+
continue;
|
|
260
|
+
if (!isPathInside(fullPath, rootDir)) {
|
|
261
|
+
logger.warn({
|
|
262
|
+
evt: 'plugin.loader.discover.reject',
|
|
263
|
+
module: MODULE_TAG,
|
|
264
|
+
reason: 'loose file resolves outside plugin dir',
|
|
265
|
+
entry,
|
|
266
|
+
});
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const relativePath = normalizePluginRelativePath(relative(rootDir, fullPath));
|
|
270
|
+
const namespacePath = relativePath.slice(0, -ext.length);
|
|
271
|
+
plugins.push({
|
|
272
|
+
type: 'file',
|
|
273
|
+
entryPoint: fullPath,
|
|
274
|
+
namespace: `${namespacePrefix}/${namespacePath}`,
|
|
275
|
+
source: relativePath,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
return plugins;
|
|
279
|
+
}
|
|
280
|
+
function normalizePluginRelativePath(path) {
|
|
281
|
+
return path.split(sep).join('/');
|
|
282
|
+
}
|
|
283
|
+
// =============================================================================
|
|
284
|
+
// HELPERS
|
|
285
|
+
// =============================================================================
|
|
286
|
+
function safeIsDirectory(path) {
|
|
287
|
+
try {
|
|
288
|
+
return statSync(path).isDirectory();
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function safeIsFile(path) {
|
|
295
|
+
try {
|
|
296
|
+
return statSync(path).isFile();
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
// isPathInside is centralized in core (lib/paths) for reuse by targeting etc.
|
|
303
|
+
//# sourceMappingURL=discover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../../src/plugins/discover.ts"],"names":[],"mappings":"AAAA,iRAAiR;AACjR;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAI9D,0DAA0D;AAC1D,MAAM,UAAU,GAAG,cAAc,CAAC;AAElC,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAAC,MAAoB,EAAE,UAAmB;IACvE,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAE3B,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACvC,MAAM,YAAY,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACrD,MAAM,OAAO,GAAuB,EAAE,CAAC;IAEvC,qEAAqE;IACrE,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,E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,EAAE,QAAQ;YACpB,SAAS,EAAE,GAAG,eAAe,IAAI,aAAa,EAAE;YAChD,MAAM,EAAE,YAAY;SACrB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,2BAA2B,CAAC,IAAY;IAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AAED,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,SAAS,eAAe,CAAC,IAAY;IACnC,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,8EAA8E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Plugin system barrel export
|
|
3
|
+
*
|
|
4
|
+
* Public API for plugin discovery and the kernel-level plugin types.
|
|
5
|
+
* The generic plugin loader lives here too — tools (fitness, sim) plug
|
|
6
|
+
* a domain-specific registerExports callback in. Tool-specific
|
|
7
|
+
* discovery helpers (check-package-discovery, scenario-package-
|
|
8
|
+
* discovery) still live with the tool that owns them.
|
|
9
|
+
*/
|
|
10
|
+
export { discoverPlugins, readProjectPluginsList } from './discover.js';
|
|
11
|
+
export { loadPlugin, loadAllPlugins } from './loader.js';
|
|
12
|
+
export type { RegisterCtx, RegisteredCounts, RegisterExportsFn } from './loader.js';
|
|
13
|
+
export { resolvePackageEntryPoint } from './package-entry.js';
|
|
14
|
+
export { VALID_NPM_SCOPE_REGEX, resolveScopes } from './scope-validation.js';
|
|
15
|
+
export type { PackageEntryResolution } from './package-entry.js';
|
|
16
|
+
export { discoverToolPackages, discoverToolPackagesFromAnchors, readToolPackageMetadata, } from './tool-package-discovery.js';
|
|
17
|
+
export type { ToolPackageDiscoveryOptions, ToolDiscoverySource, DiscoveredToolPackage, ToolPackageMetadata, } from './tool-package-discovery.js';
|
|
18
|
+
export { isRecord, isStringArray } from './json-guards.js';
|
|
19
|
+
export { discoverPackagesByMarker, discoverPackagesByDeclaredKind, discoverPackagesInNodeModules, isMarkerKind, readMarkerKind, readDeclaredKind, MARKER_KINDS, } from './marker-discovery.js';
|
|
20
|
+
export type { DiscoveredDeclaredPackage } from './marker-discovery.js';
|
|
21
|
+
export { discoverCapabilityContributions } from './capability-discovery.js';
|
|
22
|
+
export type { CapabilityDiscoveryPreferences, RawCapabilityContribution, CapabilityDiscoveryDiagnostic, DiscoverCapabilityContributionsOptions, } from './capability-discovery.js';
|
|
23
|
+
export { discoverScopedPackages, hasPackageJson, resolvePackageDir } from './node-modules-walk.js';
|
|
24
|
+
export type { DiscoveredScopedPackage, DiscoverScopedPackagesOptions, } from './node-modules-walk.js';
|
|
25
|
+
export type { MarkerKind, MarkerDiscoveryOptions, DiscoveredMarkerPackage, } from './marker-discovery.js';
|
|
26
|
+
export { loadToolManifest, admitTool, PROJECT_LOCAL_MANIFEST_FILE } from './manifest-loader.js';
|
|
27
|
+
export type { AdmissionResult } from './manifest-loader.js';
|
|
28
|
+
export { discoverAuthoredToolSidecars } from './authored-tool-discovery.js';
|
|
29
|
+
export type { AuthoredToolCandidate } from './authored-tool-discovery.js';
|
|
30
|
+
export { CapabilityRegistry, createCapabilityRegistry, currentCapabilityRegistry, registerCapabilityDomainsFromManifest, } from './capability-registry.js';
|
|
31
|
+
export type { CapabilityRegistrar } from './capability-registry.js';
|
|
32
|
+
export { loadCapabilityDomain } from './capability-loader.js';
|
|
33
|
+
export type { LoadCapabilityDomainOptions } from './capability-loader.js';
|
|
34
|
+
export { registerRecipesFromMod } from './recipe-loader.js';
|
|
35
|
+
export type { RegisterRecipesOptions, RegisterRecipesResult } from './recipe-loader.js';
|
|
36
|
+
export type { PluginLayout, DiscoveredPlugin, LoadedPlugin, PluginLoadResult, LangPluginExports, PluginExports, } from './types.js';
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7E,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EACL,oBAAoB,EACpB,+BAA+B,EAC/B,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,6BAA6B,EAC7B,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,YAAY,GACb,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAIvE,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,YAAY,EACV,8BAA8B,EAC9B,yBAAyB,EACzB,6BAA6B,EAC7B,sCAAsC,GACvC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACnG,YAAY,EACV,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,UAAU,EACV,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAChG,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,YAAY,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAK1E,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,yBAAyB,EACzB,qCAAqC,GACtC,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAIpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACxF,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Plugin system barrel export
|
|
3
|
+
*
|
|
4
|
+
* Public API for plugin discovery and the kernel-level plugin types.
|
|
5
|
+
* The generic plugin loader lives here too — tools (fitness, sim) plug
|
|
6
|
+
* a domain-specific registerExports callback in. Tool-specific
|
|
7
|
+
* discovery helpers (check-package-discovery, scenario-package-
|
|
8
|
+
* discovery) still live with the tool that owns them.
|
|
9
|
+
*/
|
|
10
|
+
export { discoverPlugins, readProjectPluginsList } from './discover.js';
|
|
11
|
+
export { loadPlugin, loadAllPlugins } from './loader.js';
|
|
12
|
+
export { resolvePackageEntryPoint } from './package-entry.js';
|
|
13
|
+
export { VALID_NPM_SCOPE_REGEX, resolveScopes } from './scope-validation.js';
|
|
14
|
+
export { discoverToolPackages, discoverToolPackagesFromAnchors, readToolPackageMetadata, } from './tool-package-discovery.js';
|
|
15
|
+
// Universal JSON-value guards shared by the manifest loader, the discovery
|
|
16
|
+
// normalizer, and the config-layer preference resolver (one definition, no
|
|
17
|
+
// cross-package duplicated bodies).
|
|
18
|
+
export { isRecord, isStringArray } from './json-guards.js';
|
|
19
|
+
export { discoverPackagesByMarker, discoverPackagesByDeclaredKind, discoverPackagesInNodeModules, isMarkerKind, readMarkerKind, readDeclaredKind, MARKER_KINDS, } from './marker-discovery.js';
|
|
20
|
+
// The generic capability-contribution discovery substrate (§5.3): one walker
|
|
21
|
+
// over marker + name-pattern modes that the host registry drives, replacing the
|
|
22
|
+
// three bespoke per-tool loaders. Yields raw contributions for routing.
|
|
23
|
+
export { discoverCapabilityContributions } from './capability-discovery.js';
|
|
24
|
+
export { discoverScopedPackages, hasPackageJson, resolvePackageDir } from './node-modules-walk.js';
|
|
25
|
+
export { loadToolManifest, admitTool, PROJECT_LOCAL_MANIFEST_FILE } from './manifest-loader.js';
|
|
26
|
+
// Authored-Tool sidecar discovery: a source-agnostic walk over a single
|
|
27
|
+
// authored `tools/` root that returns sidecar-bearing candidate dirs. The
|
|
28
|
+
// host assigns the ToolSource per root (project vs user-global).
|
|
29
|
+
export { discoverAuthoredToolSidecars } from './authored-tool-discovery.js';
|
|
30
|
+
// Scope-owned capability registry (launch, §5.3): the host-side
|
|
31
|
+
// runtime that registers manifest-declared capability domains and routes
|
|
32
|
+
// contributions to their owning tool's registrar. Per-RunScope — mirrors
|
|
33
|
+
// the simulation scenario-registry template.
|
|
34
|
+
export { CapabilityRegistry, createCapabilityRegistry, currentCapabilityRegistry, registerCapabilityDomainsFromManifest, } from './capability-registry.js';
|
|
35
|
+
// The scope-owned capability loader (§5.3, Phase 2): drives the generic
|
|
36
|
+
// discovery substrate for one domain and routes every contribution through
|
|
37
|
+
// `routeContribution` — the live conduit. Memoized per scope (fixes F1).
|
|
38
|
+
export { loadCapabilityDomain } from './capability-loader.js';
|
|
39
|
+
export { registerRecipesFromMod } from './recipe-loader.js';
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE7E,OAAO,EACL,oBAAoB,EACpB,+BAA+B,EAC/B,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AAOrC,2EAA2E;AAC3E,2EAA2E;AAC3E,oCAAoC;AACpC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,6BAA6B,EAC7B,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,YAAY,GACb,MAAM,uBAAuB,CAAC;AAE/B,6EAA6E;AAC7E,gFAAgF;AAChF,wEAAwE;AACxE,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAO5E,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAUnG,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAEhG,wEAAwE;AACxE,0EAA0E;AAC1E,iEAAiE;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAE5E,gEAAgE;AAChE,yEAAyE;AACzE,yEAAyE;AACzE,6CAA6C;AAC7C,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,yBAAyB,EACzB,qCAAqC,GACtC,MAAM,0BAA0B,CAAC;AAElC,wEAAwE;AACxE,2EAA2E;AAC3E,yEAAyE;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Universal JSON-value type guards shared by the manifest loader
|
|
3
|
+
* and the capability-discovery normalizer. Kept tiny and dependency-free — these
|
|
4
|
+
* are the shallow shape checks that gate untrusted manifest JSON before it is
|
|
5
|
+
* read as a typed structure.
|
|
6
|
+
*/
|
|
7
|
+
/** Type guard: a value is a plain `Record<string, unknown>` (object, non-null, non-array). */
|
|
8
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
9
|
+
/** Type guard: a value is a `readonly string[]`. */
|
|
10
|
+
export declare function isStringArray(value: unknown): value is readonly string[];
|
|
11
|
+
//# sourceMappingURL=json-guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-guards.d.ts","sourceRoot":"","sources":["../../src/plugins/json-guards.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,8FAA8F;AAC9F,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,oDAAoD;AACpD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,MAAM,EAAE,CAExE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Universal JSON-value type guards shared by the manifest loader
|
|
3
|
+
* and the capability-discovery normalizer. Kept tiny and dependency-free — these
|
|
4
|
+
* are the shallow shape checks that gate untrusted manifest JSON before it is
|
|
5
|
+
* read as a typed structure.
|
|
6
|
+
*/
|
|
7
|
+
/** Type guard: a value is a plain `Record<string, unknown>` (object, non-null, non-array). */
|
|
8
|
+
export function isRecord(value) {
|
|
9
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
/** Type guard: a value is a `readonly string[]`. */
|
|
12
|
+
export function isStringArray(value) {
|
|
13
|
+
return Array.isArray(value) && value.every((a) => typeof a === 'string');
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=json-guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-guards.js","sourceRoot":"","sources":["../../src/plugins/json-guards.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,8FAA8F;AAC9F,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic plugin loader.
|
|
3
|
+
*
|
|
4
|
+
* Owns the machinery that's identical for every plugin domain:
|
|
5
|
+
*
|
|
6
|
+
* 1. Discover plugins for a domain (via discoverPlugins).
|
|
7
|
+
* 2. Dynamic-import each discovered entry point.
|
|
8
|
+
* 3. Hand the imported module to a domain-supplied `registerExports`
|
|
9
|
+
* callback that performs the actual registration (into the fitness
|
|
10
|
+
* check registry, the sim scenario registry, the kernel language
|
|
11
|
+
* registry, etc.).
|
|
12
|
+
* 4. Roll up per-plugin counts into a PluginLoadResult, catching and
|
|
13
|
+
* reporting per-plugin failures without aborting the whole batch.
|
|
14
|
+
*
|
|
15
|
+
* What we deliberately do NOT own here: the *contents* of registration.
|
|
16
|
+
* Each domain (fit, sim, lang) knows what shape its plugins export and
|
|
17
|
+
* which registry to feed; that lives with the tool that owns the
|
|
18
|
+
* registry. The callback receives a `RegisterCtx` so it can emit
|
|
19
|
+
* structured warnings without re-deriving plugin metadata.
|
|
20
|
+
*
|
|
21
|
+
* This file replaces what used to be a fit-coupled loader in
|
|
22
|
+
* @opensip-cli/fitness. The fitness loader is now a thin adapter
|
|
23
|
+
* that supplies a fit-specific registerExports callback and re-exports
|
|
24
|
+
* loadPlugin / loadAllPlugins with the same public signatures it had
|
|
25
|
+
* before, so existing callers (fit.ts) don't change.
|
|
26
|
+
*/
|
|
27
|
+
import type { DiscoveredPlugin, LoadedPlugin, PluginLayout, PluginLoadResult } from './types.js';
|
|
28
|
+
/**
|
|
29
|
+
* Per-plugin context handed to a domain's `registerExports` callback.
|
|
30
|
+
* Lets the callback emit structured warnings (with namespace/source
|
|
31
|
+
* already filled in) without re-deriving plugin metadata.
|
|
32
|
+
*/
|
|
33
|
+
export interface RegisterCtx {
|
|
34
|
+
readonly plugin: DiscoveredPlugin;
|
|
35
|
+
/** Emit a structured warning about a malformed plugin export. */
|
|
36
|
+
readonly warn: (evt: string, msg: string, fields?: Record<string, unknown>) => void;
|
|
37
|
+
/** Emit a structured debug event. */
|
|
38
|
+
readonly debug: (evt: string, fields?: Record<string, unknown>) => void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Per-plugin registration counts returned from the callback — a generic
|
|
42
|
+
* map keyed by whatever artifact kinds the domain registers (e.g.
|
|
43
|
+
* `{ checks: 3, recipes: 1 }`, `{ scenarios: 2 }`, `{ adapters: 1 }`).
|
|
44
|
+
* The kernel carries no tool-specific counter names (ADR-0009 M2).
|
|
45
|
+
*/
|
|
46
|
+
export type RegisteredCounts = Readonly<Record<string, number>>;
|
|
47
|
+
/**
|
|
48
|
+
* Callback that registers a plugin's exports into the right registries
|
|
49
|
+
* for its domain. Returns the per-kind counts for that plugin. Kinds a
|
|
50
|
+
* domain doesn't produce are simply absent from the map.
|
|
51
|
+
*/
|
|
52
|
+
export type RegisterExportsFn = (mod: Record<string, unknown>, ctx: RegisterCtx) => Promise<RegisteredCounts> | RegisteredCounts;
|
|
53
|
+
/**
|
|
54
|
+
* Load a single discovered plugin: dynamic-import its entry, run the
|
|
55
|
+
* domain's `registerExports` callback, and wrap any thrown error so a
|
|
56
|
+
* single bad plugin doesn't take down the rest of the batch.
|
|
57
|
+
*/
|
|
58
|
+
export declare function loadPlugin(plugin: DiscoveredPlugin, registerExports: RegisterExportsFn): Promise<LoadedPlugin>;
|
|
59
|
+
/**
|
|
60
|
+
* Discover and load every plugin for a domain. Plugins are loaded
|
|
61
|
+
* sequentially to keep registration order deterministic.
|
|
62
|
+
*
|
|
63
|
+
* Without `projectDir`, no plugins are discovered — there is no
|
|
64
|
+
* user-global fallback, by design.
|
|
65
|
+
*/
|
|
66
|
+
export declare function loadAllPlugins(layout: PluginLayout, projectDir: string | undefined, registerExports: RegisterExportsFn): Promise<PluginLoadResult>;
|
|
67
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/plugins/loader.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAQH,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAKjG;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACpF,qCAAqC;IACrC,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACzE;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,WAAW,KACb,OAAO,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;AAElD;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,gBAAgB,EACxB,eAAe,EAAE,iBAAiB,GACjC,OAAO,CAAC,YAAY,CAAC,CA6EvB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,eAAe,EAAE,iBAAiB,GACjC,OAAO,CAAC,gBAAgB,CAAC,CAwB3B"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// @fitness-ignore-file performance-anti-patterns -- sequential await across discovered plugin modules preserves load order for deterministic conflict detection; bounded by installed plugin count
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Generic plugin loader.
|
|
4
|
+
*
|
|
5
|
+
* Owns the machinery that's identical for every plugin domain:
|
|
6
|
+
*
|
|
7
|
+
* 1. Discover plugins for a domain (via discoverPlugins).
|
|
8
|
+
* 2. Dynamic-import each discovered entry point.
|
|
9
|
+
* 3. Hand the imported module to a domain-supplied `registerExports`
|
|
10
|
+
* callback that performs the actual registration (into the fitness
|
|
11
|
+
* check registry, the sim scenario registry, the kernel language
|
|
12
|
+
* registry, etc.).
|
|
13
|
+
* 4. Roll up per-plugin counts into a PluginLoadResult, catching and
|
|
14
|
+
* reporting per-plugin failures without aborting the whole batch.
|
|
15
|
+
*
|
|
16
|
+
* What we deliberately do NOT own here: the *contents* of registration.
|
|
17
|
+
* Each domain (fit, sim, lang) knows what shape its plugins export and
|
|
18
|
+
* which registry to feed; that lives with the tool that owns the
|
|
19
|
+
* registry. The callback receives a `RegisterCtx` so it can emit
|
|
20
|
+
* structured warnings without re-deriving plugin metadata.
|
|
21
|
+
*
|
|
22
|
+
* This file replaces what used to be a fit-coupled loader in
|
|
23
|
+
* @opensip-cli/fitness. The fitness loader is now a thin adapter
|
|
24
|
+
* that supplies a fit-specific registerExports callback and re-exports
|
|
25
|
+
* loadPlugin / loadAllPlugins with the same public signatures it had
|
|
26
|
+
* before, so existing callers (fit.ts) don't change.
|
|
27
|
+
*/
|
|
28
|
+
import { pathToFileURL } from 'node:url';
|
|
29
|
+
import { logger } from '../lib/logger.js';
|
|
30
|
+
import { discoverPlugins } from './discover.js';
|
|
31
|
+
/** Logger module tag used by every event emitted from the generic loader. */
|
|
32
|
+
const MODULE_TAG = 'core:plugins';
|
|
33
|
+
/**
|
|
34
|
+
* Load a single discovered plugin: dynamic-import its entry, run the
|
|
35
|
+
* domain's `registerExports` callback, and wrap any thrown error so a
|
|
36
|
+
* single bad plugin doesn't take down the rest of the batch.
|
|
37
|
+
*/
|
|
38
|
+
export async function loadPlugin(plugin, registerExports) {
|
|
39
|
+
const ctx = {
|
|
40
|
+
plugin,
|
|
41
|
+
warn: (evt, msg, fields) => {
|
|
42
|
+
logger.warn({
|
|
43
|
+
evt,
|
|
44
|
+
module: MODULE_TAG,
|
|
45
|
+
namespace: plugin.namespace,
|
|
46
|
+
source: plugin.source,
|
|
47
|
+
msg,
|
|
48
|
+
...fields,
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
debug: (evt, fields) => {
|
|
52
|
+
logger.debug({
|
|
53
|
+
evt,
|
|
54
|
+
module: MODULE_TAG,
|
|
55
|
+
namespace: plugin.namespace,
|
|
56
|
+
source: plugin.source,
|
|
57
|
+
...fields,
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
try {
|
|
62
|
+
const moduleUrl = pathToFileURL(plugin.entryPoint).href;
|
|
63
|
+
const mod = (await import(moduleUrl));
|
|
64
|
+
const registered = await registerExports(mod, ctx);
|
|
65
|
+
const nothingRegistered = Object.values(registered).every((n) => n === 0);
|
|
66
|
+
if (nothingRegistered) {
|
|
67
|
+
logger.warn({
|
|
68
|
+
evt: 'plugin.loader.no_exports',
|
|
69
|
+
module: MODULE_TAG,
|
|
70
|
+
namespace: plugin.namespace,
|
|
71
|
+
source: plugin.source,
|
|
72
|
+
msg: `Plugin "${plugin.namespace}" registered nothing — nothing to run.`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
logger.info({
|
|
76
|
+
evt: 'plugin.loader.load.success',
|
|
77
|
+
module: MODULE_TAG,
|
|
78
|
+
namespace: plugin.namespace,
|
|
79
|
+
source: plugin.source,
|
|
80
|
+
registered,
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
namespace: plugin.namespace,
|
|
84
|
+
source: plugin.source,
|
|
85
|
+
type: plugin.type,
|
|
86
|
+
registered,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
91
|
+
logger.warn({
|
|
92
|
+
evt: 'plugin.loader.load.error',
|
|
93
|
+
module: MODULE_TAG,
|
|
94
|
+
namespace: plugin.namespace,
|
|
95
|
+
source: plugin.source,
|
|
96
|
+
error: errorMsg,
|
|
97
|
+
err: error instanceof Error ? error : undefined,
|
|
98
|
+
msg: `Plugin "${plugin.namespace}" failed to load: ${errorMsg}. Continuing without this plugin.`,
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
namespace: plugin.namespace,
|
|
102
|
+
source: plugin.source,
|
|
103
|
+
type: plugin.type,
|
|
104
|
+
registered: {},
|
|
105
|
+
error: errorMsg,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Discover and load every plugin for a domain. Plugins are loaded
|
|
111
|
+
* sequentially to keep registration order deterministic.
|
|
112
|
+
*
|
|
113
|
+
* Without `projectDir`, no plugins are discovered — there is no
|
|
114
|
+
* user-global fallback, by design.
|
|
115
|
+
*/
|
|
116
|
+
export async function loadAllPlugins(layout, projectDir, registerExports) {
|
|
117
|
+
const discovered = discoverPlugins(layout, projectDir);
|
|
118
|
+
const plugins = [];
|
|
119
|
+
const errors = [];
|
|
120
|
+
for (const plugin of discovered) {
|
|
121
|
+
const result = await loadPlugin(plugin, registerExports);
|
|
122
|
+
plugins.push(result);
|
|
123
|
+
if (result.error) {
|
|
124
|
+
errors.push(`${result.source}: ${result.error}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Sum each plugin's per-kind counts into generic totals. No tool
|
|
128
|
+
// vocabulary here — whatever keys the domain reported roll up.
|
|
129
|
+
const totals = {};
|
|
130
|
+
for (const plugin of plugins) {
|
|
131
|
+
for (const [kind, count] of Object.entries(plugin.registered)) {
|
|
132
|
+
totals[kind] = (totals[kind] ?? 0) + count;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return { plugins, totals, errors };
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=loader.js.map
|