@lesliechan721/aw 0.1.0-beta.10
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/dist/authoring/assets/aw-config.d.mts +51 -0
- package/dist/authoring/assets/aw-config.mjs +1025 -0
- package/dist/authoring/assets/aw-config.mjs.map +1 -0
- package/dist/authoring/scripts/add-skill.d.mts +2 -0
- package/dist/authoring/scripts/add-skill.mjs +355 -0
- package/dist/authoring/scripts/add-skill.mjs.map +1 -0
- package/dist/authoring/scripts/init-plugin.d.mts +2 -0
- package/dist/authoring/scripts/init-plugin.mjs +487 -0
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -0
- package/dist/authoring/scripts/lib/javascript-import-scanner.d.mts +4 -0
- package/dist/authoring/scripts/lib/javascript-import-scanner.mjs +261 -0
- package/dist/authoring/scripts/lib/javascript-import-scanner.mjs.map +1 -0
- package/dist/authoring/scripts/lib/plugin-root.d.mts +26 -0
- package/dist/authoring/scripts/lib/plugin-root.mjs +125 -0
- package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -0
- package/dist/authoring/scripts/lib/plugin-version-check.d.mts +69 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +563 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -0
- package/dist/authoring/scripts/lib/semver.d.mts +9 -0
- package/dist/authoring/scripts/lib/semver.mjs +63 -0
- package/dist/authoring/scripts/lib/semver.mjs.map +1 -0
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +111 -0
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +353 -0
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -0
- package/dist/authoring/scripts/plugin-status.d.mts +2 -0
- package/dist/authoring/scripts/plugin-status.mjs +93 -0
- package/dist/authoring/scripts/plugin-status.mjs.map +1 -0
- package/dist/authoring/scripts/remove-plugin.d.mts +2 -0
- package/dist/authoring/scripts/remove-plugin.mjs +367 -0
- package/dist/authoring/scripts/remove-plugin.mjs.map +1 -0
- package/dist/authoring/scripts/validate-plugin.d.mts +2 -0
- package/dist/authoring/scripts/validate-plugin.mjs +3465 -0
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -0
- package/dist/authoring/scripts/validate-skill.d.mts +2 -0
- package/dist/authoring/scripts/validate-skill.mjs +126 -0
- package/dist/authoring/scripts/validate-skill.mjs.map +1 -0
- package/dist/authoring/templates/aw-config-runtime.d.mts +2 -0
- package/dist/authoring/templates/aw-config-runtime.mjs +407 -0
- package/dist/authoring/templates/aw-config-runtime.mjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/scripts/aw-skill-eval-materializer.d.ts +24 -0
- package/dist/scripts/aw-skill-eval-materializer.js +309 -0
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
- package/dist/scripts/bundle-plugins.d.ts +17 -0
- package/dist/scripts/bundle-plugins.js +126 -0
- package/dist/scripts/bundle-plugins.js.map +1 -0
- package/dist/scripts/plugin-staging.d.ts +26 -0
- package/dist/scripts/plugin-staging.js +76 -0
- package/dist/scripts/plugin-staging.js.map +1 -0
- package/dist/scripts/test-plugin-scripts.d.ts +7 -0
- package/dist/scripts/test-plugin-scripts.js +610 -0
- package/dist/scripts/test-plugin-scripts.js.map +1 -0
- package/dist/src/adapters/helpers.d.ts +44 -0
- package/dist/src/adapters/helpers.js +95 -0
- package/dist/src/adapters/helpers.js.map +1 -0
- package/dist/src/authoring/workspace-commands.d.ts +70 -0
- package/dist/src/authoring/workspace-commands.js +158 -0
- package/dist/src/authoring/workspace-commands.js.map +1 -0
- package/dist/src/commands/aw-capabilities.d.ts +78 -0
- package/dist/src/commands/aw-capabilities.js +254 -0
- package/dist/src/commands/aw-capabilities.js.map +1 -0
- package/dist/src/commands/catalog-dev-source.d.ts +120 -0
- package/dist/src/commands/catalog-dev-source.js +434 -0
- package/dist/src/commands/catalog-dev-source.js.map +1 -0
- package/dist/src/commands/catalog-generation.d.ts +16 -0
- package/dist/src/commands/catalog-generation.js +9 -0
- package/dist/src/commands/catalog-generation.js.map +1 -0
- package/dist/src/commands/catalog-publication-inspection.d.ts +138 -0
- package/dist/src/commands/catalog-publication-inspection.js +711 -0
- package/dist/src/commands/catalog-publication-inspection.js.map +1 -0
- package/dist/src/commands/catalog-publication-journal.d.ts +56 -0
- package/dist/src/commands/catalog-publication-journal.js +215 -0
- package/dist/src/commands/catalog-publication-journal.js.map +1 -0
- package/dist/src/commands/catalog-publication-target.d.ts +18 -0
- package/dist/src/commands/catalog-publication-target.js +95 -0
- package/dist/src/commands/catalog-publication-target.js.map +1 -0
- package/dist/src/commands/catalog-publish.d.ts +103 -0
- package/dist/src/commands/catalog-publish.js +804 -0
- package/dist/src/commands/catalog-publish.js.map +1 -0
- package/dist/src/commands/catalog-source.d.ts +134 -0
- package/dist/src/commands/catalog-source.js +377 -0
- package/dist/src/commands/catalog-source.js.map +1 -0
- package/dist/src/commands/catalog-status.d.ts +56 -0
- package/dist/src/commands/catalog-status.js +217 -0
- package/dist/src/commands/catalog-status.js.map +1 -0
- package/dist/src/commands/catalog-store.d.ts +80 -0
- package/dist/src/commands/catalog-store.js +348 -0
- package/dist/src/commands/catalog-store.js.map +1 -0
- package/dist/src/commands/catalog-workspace-resolution.d.ts +13 -0
- package/dist/src/commands/catalog-workspace-resolution.js +42 -0
- package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
- package/dist/src/commands/console.d.ts +3 -0
- package/dist/src/commands/console.js +44 -0
- package/dist/src/commands/console.js.map +1 -0
- package/dist/src/commands/dependency-operation-plan.d.ts +58 -0
- package/dist/src/commands/dependency-operation-plan.js +261 -0
- package/dist/src/commands/dependency-operation-plan.js.map +1 -0
- package/dist/src/commands/init.d.ts +25 -0
- package/dist/src/commands/init.js +42 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/offline-cleanup-evidence.d.ts +59 -0
- package/dist/src/commands/offline-cleanup-evidence.js +163 -0
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -0
- package/dist/src/commands/operation-plan.d.ts +126 -0
- package/dist/src/commands/operation-plan.js +47 -0
- package/dist/src/commands/operation-plan.js.map +1 -0
- package/dist/src/commands/operation-planner.d.ts +46 -0
- package/dist/src/commands/operation-planner.js +139 -0
- package/dist/src/commands/operation-planner.js.map +1 -0
- package/dist/src/commands/options.d.ts +70 -0
- package/dist/src/commands/options.js +194 -0
- package/dist/src/commands/options.js.map +1 -0
- package/dist/src/commands/plugin-capabilities.d.ts +22 -0
- package/dist/src/commands/plugin-capabilities.js +159 -0
- package/dist/src/commands/plugin-capabilities.js.map +1 -0
- package/dist/src/commands/rebuild-command.d.ts +88 -0
- package/dist/src/commands/rebuild-command.js +3626 -0
- package/dist/src/commands/rebuild-command.js.map +1 -0
- package/dist/src/commands/rebuild-integration.d.ts +190 -0
- package/dist/src/commands/rebuild-integration.js +4439 -0
- package/dist/src/commands/rebuild-integration.js.map +1 -0
- package/dist/src/commands/rebuild-operations.d.ts +100 -0
- package/dist/src/commands/rebuild-operations.js +625 -0
- package/dist/src/commands/rebuild-operations.js.map +1 -0
- package/dist/src/commands/reconcile-operation-plan.d.ts +26 -0
- package/dist/src/commands/reconcile-operation-plan.js +28 -0
- package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
- package/dist/src/commands/review-publication.d.ts +99 -0
- package/dist/src/commands/review-publication.js +904 -0
- package/dist/src/commands/review-publication.js.map +1 -0
- package/dist/src/commands/runtime.d.ts +172 -0
- package/dist/src/commands/runtime.js +720 -0
- package/dist/src/commands/runtime.js.map +1 -0
- package/dist/src/commands/skill-eval.d.ts +33 -0
- package/dist/src/commands/skill-eval.js +363 -0
- package/dist/src/commands/skill-eval.js.map +1 -0
- package/dist/src/commands/status-v6.d.ts +206 -0
- package/dist/src/commands/status-v6.js +2175 -0
- package/dist/src/commands/status-v6.js.map +1 -0
- package/dist/src/commands/sync-command.d.ts +23 -0
- package/dist/src/commands/sync-command.js +242 -0
- package/dist/src/commands/sync-command.js.map +1 -0
- package/dist/src/commands/wizard.d.ts +56 -0
- package/dist/src/commands/wizard.js +58 -0
- package/dist/src/commands/wizard.js.map +1 -0
- package/dist/src/commands/write-commands.d.ts +7 -0
- package/dist/src/commands/write-commands.js +190 -0
- package/dist/src/commands/write-commands.js.map +1 -0
- package/dist/src/constants.d.ts +31 -0
- package/dist/src/constants.js +32 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/eval/manifest-v1.d.ts +67 -0
- package/dist/src/eval/manifest-v1.js +347 -0
- package/dist/src/eval/manifest-v1.js.map +1 -0
- package/dist/src/generators/agents.d.ts +3 -0
- package/dist/src/generators/agents.js +46 -0
- package/dist/src/generators/agents.js.map +1 -0
- package/dist/src/generators/hooks.d.ts +15 -0
- package/dist/src/generators/hooks.js +76 -0
- package/dist/src/generators/hooks.js.map +1 -0
- package/dist/src/generators/instructions.d.ts +13 -0
- package/dist/src/generators/instructions.js +66 -0
- package/dist/src/generators/instructions.js.map +1 -0
- package/dist/src/generators/local-plugin.d.ts +56 -0
- package/dist/src/generators/local-plugin.js +1373 -0
- package/dist/src/generators/local-plugin.js.map +1 -0
- package/dist/src/generators/permissions.d.ts +10 -0
- package/dist/src/generators/permissions.js +37 -0
- package/dist/src/generators/permissions.js.map +1 -0
- package/dist/src/generators/shared.d.ts +2 -0
- package/dist/src/generators/shared.js +15 -0
- package/dist/src/generators/shared.js.map +1 -0
- package/dist/src/index.d.ts +41 -0
- package/dist/src/index.js +3327 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/output/command-receipt.d.ts +87 -0
- package/dist/src/output/command-receipt.js +302 -0
- package/dist/src/output/command-receipt.js.map +1 -0
- package/dist/src/output/debug-log.d.ts +4 -0
- package/dist/src/output/debug-log.js +97 -0
- package/dist/src/output/debug-log.js.map +1 -0
- package/dist/src/output/equivalent-command.d.ts +9 -0
- package/dist/src/output/equivalent-command.js +39 -0
- package/dist/src/output/equivalent-command.js.map +1 -0
- package/dist/src/output/model.d.ts +76 -0
- package/dist/src/output/model.js +2 -0
- package/dist/src/output/model.js.map +1 -0
- package/dist/src/output/rebuild-progress.d.ts +21 -0
- package/dist/src/output/rebuild-progress.js +128 -0
- package/dist/src/output/rebuild-progress.js.map +1 -0
- package/dist/src/output/redact.d.ts +3 -0
- package/dist/src/output/redact.js +39 -0
- package/dist/src/output/redact.js.map +1 -0
- package/dist/src/output/reporter.d.ts +9 -0
- package/dist/src/output/reporter.js +133 -0
- package/dist/src/output/reporter.js.map +1 -0
- package/dist/src/portable/commands.d.ts +124 -0
- package/dist/src/portable/commands.js +557 -0
- package/dist/src/portable/commands.js.map +1 -0
- package/dist/src/portable/materializer.d.ts +50 -0
- package/dist/src/portable/materializer.js +462 -0
- package/dist/src/portable/materializer.js.map +1 -0
- package/dist/src/portable/skills-cli.d.ts +43 -0
- package/dist/src/portable/skills-cli.js +148 -0
- package/dist/src/portable/skills-cli.js.map +1 -0
- package/dist/src/tui/catalog-freshness.d.ts +1 -0
- package/dist/src/tui/catalog-freshness.js +2 -0
- package/dist/src/tui/catalog-freshness.js.map +1 -0
- package/dist/src/tui/catalog-generation.d.ts +21 -0
- package/dist/src/tui/catalog-generation.js +116 -0
- package/dist/src/tui/catalog-generation.js.map +1 -0
- package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
- package/dist/src/tui/catalog-sources/projection.js +17 -0
- package/dist/src/tui/catalog-sources/projection.js.map +1 -0
- package/dist/src/tui/catalog-sources/review.d.ts +3 -0
- package/dist/src/tui/catalog-sources/review.js +13 -0
- package/dist/src/tui/catalog-sources/review.js.map +1 -0
- package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
- package/dist/src/tui/catalog-sources/screens.js +33 -0
- package/dist/src/tui/catalog-sources/screens.js.map +1 -0
- package/dist/src/tui/catalog-sources/session.d.ts +22 -0
- package/dist/src/tui/catalog-sources/session.js +225 -0
- package/dist/src/tui/catalog-sources/session.js.map +1 -0
- package/dist/src/tui/catalog-sources/types.d.ts +41 -0
- package/dist/src/tui/catalog-sources/types.js +2 -0
- package/dist/src/tui/catalog-sources/types.js.map +1 -0
- package/dist/src/tui/components.d.ts +102 -0
- package/dist/src/tui/components.js +184 -0
- package/dist/src/tui/components.js.map +1 -0
- package/dist/src/tui/console-app-v4.d.ts +20 -0
- package/dist/src/tui/console-app-v4.js +5066 -0
- package/dist/src/tui/console-app-v4.js.map +1 -0
- package/dist/src/tui/controller-runtime.d.ts +23 -0
- package/dist/src/tui/controller-runtime.js +2011 -0
- package/dist/src/tui/controller-runtime.js.map +1 -0
- package/dist/src/tui/controller.d.ts +557 -0
- package/dist/src/tui/controller.js +2120 -0
- package/dist/src/tui/controller.js.map +1 -0
- package/dist/src/tui/diagnostics.d.ts +30 -0
- package/dist/src/tui/diagnostics.js +71 -0
- package/dist/src/tui/diagnostics.js.map +1 -0
- package/dist/src/tui/index.d.ts +17 -0
- package/dist/src/tui/index.js +17 -0
- package/dist/src/tui/index.js.map +1 -0
- package/dist/src/tui/input-display.d.ts +8 -0
- package/dist/src/tui/input-display.js +36 -0
- package/dist/src/tui/input-display.js.map +1 -0
- package/dist/src/tui/keys.d.ts +12 -0
- package/dist/src/tui/keys.js +22 -0
- package/dist/src/tui/keys.js.map +1 -0
- package/dist/src/tui/layout.d.ts +12 -0
- package/dist/src/tui/layout.js +19 -0
- package/dist/src/tui/layout.js.map +1 -0
- package/dist/src/tui/model.d.ts +424 -0
- package/dist/src/tui/model.js +1493 -0
- package/dist/src/tui/model.js.map +1 -0
- package/dist/src/tui/operation-review-planner.d.ts +21 -0
- package/dist/src/tui/operation-review-planner.js +622 -0
- package/dist/src/tui/operation-review-planner.js.map +1 -0
- package/dist/src/tui/prompt.d.ts +8 -0
- package/dist/src/tui/prompt.js +231 -0
- package/dist/src/tui/prompt.js.map +1 -0
- package/dist/src/tui/router.d.ts +206 -0
- package/dist/src/tui/router.js +137 -0
- package/dist/src/tui/router.js.map +1 -0
- package/dist/src/tui/runner.d.ts +11 -0
- package/dist/src/tui/runner.js +71 -0
- package/dist/src/tui/runner.js.map +1 -0
- package/dist/src/tui/source-ref-presets.d.ts +3 -0
- package/dist/src/tui/source-ref-presets.js +11 -0
- package/dist/src/tui/source-ref-presets.js.map +1 -0
- package/dist/src/tui/theme.d.ts +26 -0
- package/dist/src/tui/theme.js +28 -0
- package/dist/src/tui/theme.js.map +1 -0
- package/dist/src/tui/viewport.d.ts +20 -0
- package/dist/src/tui/viewport.js +29 -0
- package/dist/src/tui/viewport.js.map +1 -0
- package/dist/src/tui/views.d.ts +57 -0
- package/dist/src/tui/views.js +201 -0
- package/dist/src/tui/views.js.map +1 -0
- package/dist/src/tui/wizard.d.ts +11 -0
- package/dist/src/tui/wizard.js +323 -0
- package/dist/src/tui/wizard.js.map +1 -0
- package/dist/src/types.d.ts +474 -0
- package/dist/src/types.js +34 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/agent-version.d.ts +19 -0
- package/dist/src/utils/agent-version.js +205 -0
- package/dist/src/utils/agent-version.js.map +1 -0
- package/dist/src/utils/artifact-plan.d.ts +27 -0
- package/dist/src/utils/artifact-plan.js +453 -0
- package/dist/src/utils/artifact-plan.js.map +1 -0
- package/dist/src/utils/artifact-renderer.d.ts +129 -0
- package/dist/src/utils/artifact-renderer.js +400 -0
- package/dist/src/utils/artifact-renderer.js.map +1 -0
- package/dist/src/utils/artifact-request.d.ts +16 -0
- package/dist/src/utils/artifact-request.js +42 -0
- package/dist/src/utils/artifact-request.js.map +1 -0
- package/dist/src/utils/artifact-sources.d.ts +8 -0
- package/dist/src/utils/artifact-sources.js +10 -0
- package/dist/src/utils/artifact-sources.js.map +1 -0
- package/dist/src/utils/aw-home-mutation-lock.d.ts +11 -0
- package/dist/src/utils/aw-home-mutation-lock.js +83 -0
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -0
- package/dist/src/utils/bundle-integrity.d.ts +2 -0
- package/dist/src/utils/bundle-integrity.js +63 -0
- package/dist/src/utils/bundle-integrity.js.map +1 -0
- package/dist/src/utils/bundle-layout.d.ts +4 -0
- package/dist/src/utils/bundle-layout.js +531 -0
- package/dist/src/utils/bundle-layout.js.map +1 -0
- package/dist/src/utils/catalog-digests.d.ts +18 -0
- package/dist/src/utils/catalog-digests.js +156 -0
- package/dist/src/utils/catalog-digests.js.map +1 -0
- package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
- package/dist/src/utils/catalog-generation-error.d.ts +16 -0
- package/dist/src/utils/catalog-generation-error.js +30 -0
- package/dist/src/utils/catalog-generation-error.js.map +1 -0
- package/dist/src/utils/catalog-generation-resolver.d.ts +32 -0
- package/dist/src/utils/catalog-generation-resolver.js +251 -0
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -0
- package/dist/src/utils/catalog-generation-service.d.ts +161 -0
- package/dist/src/utils/catalog-generation-service.js +1237 -0
- package/dist/src/utils/catalog-generation-service.js.map +1 -0
- package/dist/src/utils/catalog-generation-state.d.ts +22 -0
- package/dist/src/utils/catalog-generation-state.js +192 -0
- package/dist/src/utils/catalog-generation-state.js.map +1 -0
- package/dist/src/utils/catalog-generation-store.d.ts +57 -0
- package/dist/src/utils/catalog-generation-store.js +397 -0
- package/dist/src/utils/catalog-generation-store.js.map +1 -0
- package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
- package/dist/src/utils/catalog-manifest-v7.js +98 -0
- package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
- package/dist/src/utils/catalog-operation-context.d.ts +20 -0
- package/dist/src/utils/catalog-operation-context.js +141 -0
- package/dist/src/utils/catalog-operation-context.js.map +1 -0
- package/dist/src/utils/catalog-public-error.d.ts +19 -0
- package/dist/src/utils/catalog-public-error.js +100 -0
- package/dist/src/utils/catalog-public-error.js.map +1 -0
- package/dist/src/utils/catalog-runtime-projection.d.ts +33 -0
- package/dist/src/utils/catalog-runtime-projection.js +77 -0
- package/dist/src/utils/catalog-runtime-projection.js.map +1 -0
- package/dist/src/utils/catalog-snapshot.d.ts +10 -0
- package/dist/src/utils/catalog-snapshot.js +20 -0
- package/dist/src/utils/catalog-snapshot.js.map +1 -0
- package/dist/src/utils/catalog-source-identity.d.ts +5 -0
- package/dist/src/utils/catalog-source-identity.js +137 -0
- package/dist/src/utils/catalog-source-identity.js.map +1 -0
- package/dist/src/utils/catalog-source-impact.d.ts +20 -0
- package/dist/src/utils/catalog-source-impact.js +222 -0
- package/dist/src/utils/catalog-source-impact.js.map +1 -0
- package/dist/src/utils/catalog-source-presentation.d.ts +1 -0
- package/dist/src/utils/catalog-source-presentation.js +32 -0
- package/dist/src/utils/catalog-source-presentation.js.map +1 -0
- package/dist/src/utils/catalog-source-references.d.ts +66 -0
- package/dist/src/utils/catalog-source-references.js +1180 -0
- package/dist/src/utils/catalog-source-references.js.map +1 -0
- package/dist/src/utils/catalog-sources.d.ts +53 -0
- package/dist/src/utils/catalog-sources.js +456 -0
- package/dist/src/utils/catalog-sources.js.map +1 -0
- package/dist/src/utils/codex-config.d.ts +126 -0
- package/dist/src/utils/codex-config.js +1032 -0
- package/dist/src/utils/codex-config.js.map +1 -0
- package/dist/src/utils/codex-manager.d.ts +81 -0
- package/dist/src/utils/codex-manager.js +810 -0
- package/dist/src/utils/codex-manager.js.map +1 -0
- package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
- package/dist/src/utils/codex-marketplace-path.js +45 -0
- package/dist/src/utils/codex-marketplace-path.js.map +1 -0
- package/dist/src/utils/codex-native-observation.d.ts +16 -0
- package/dist/src/utils/codex-native-observation.js +22 -0
- package/dist/src/utils/codex-native-observation.js.map +1 -0
- package/dist/src/utils/codex-native-render-receipt.d.ts +40 -0
- package/dist/src/utils/codex-native-render-receipt.js +205 -0
- package/dist/src/utils/codex-native-render-receipt.js.map +1 -0
- package/dist/src/utils/codex-reconciler.d.ts +128 -0
- package/dist/src/utils/codex-reconciler.js +294 -0
- package/dist/src/utils/codex-reconciler.js.map +1 -0
- package/dist/src/utils/codex-roles.d.ts +71 -0
- package/dist/src/utils/codex-roles.js +257 -0
- package/dist/src/utils/codex-roles.js.map +1 -0
- package/dist/src/utils/codex-shared-native.d.ts +63 -0
- package/dist/src/utils/codex-shared-native.js +142 -0
- package/dist/src/utils/codex-shared-native.js.map +1 -0
- package/dist/src/utils/codex-skill-staging.d.ts +11 -0
- package/dist/src/utils/codex-skill-staging.js +8 -0
- package/dist/src/utils/codex-skill-staging.js.map +1 -0
- package/dist/src/utils/codex-surface-analysis.d.ts +45 -0
- package/dist/src/utils/codex-surface-analysis.js +245 -0
- package/dist/src/utils/codex-surface-analysis.js.map +1 -0
- package/dist/src/utils/config-value.d.ts +3 -0
- package/dist/src/utils/config-value.js +23 -0
- package/dist/src/utils/config-value.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +36 -0
- package/dist/src/utils/dynamic-skill-tree.js +466 -0
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -0
- package/dist/src/utils/file-rules.d.ts +1 -0
- package/dist/src/utils/file-rules.js +2 -0
- package/dist/src/utils/file-rules.js.map +1 -0
- package/dist/src/utils/git-catalog-provider.d.ts +22 -0
- package/dist/src/utils/git-catalog-provider.js +497 -0
- package/dist/src/utils/git-catalog-provider.js.map +1 -0
- package/dist/src/utils/hooks-contract.d.ts +1 -0
- package/dist/src/utils/hooks-contract.js +2 -0
- package/dist/src/utils/hooks-contract.js.map +1 -0
- package/dist/src/utils/json.d.ts +4 -0
- package/dist/src/utils/json.js +29 -0
- package/dist/src/utils/json.js.map +1 -0
- package/dist/src/utils/local-marketplace.d.ts +41 -0
- package/dist/src/utils/local-marketplace.js +316 -0
- package/dist/src/utils/local-marketplace.js.map +1 -0
- package/dist/src/utils/manifest.d.ts +11 -0
- package/dist/src/utils/manifest.js +33 -0
- package/dist/src/utils/manifest.js.map +1 -0
- package/dist/src/utils/marketplace.d.ts +3 -0
- package/dist/src/utils/marketplace.js +76 -0
- package/dist/src/utils/marketplace.js.map +1 -0
- package/dist/src/utils/multi-source-catalog.d.ts +66 -0
- package/dist/src/utils/multi-source-catalog.js +345 -0
- package/dist/src/utils/multi-source-catalog.js.map +1 -0
- package/dist/src/utils/native-cli.d.ts +118 -0
- package/dist/src/utils/native-cli.js +518 -0
- package/dist/src/utils/native-cli.js.map +1 -0
- package/dist/src/utils/orphan-marketplace-cleanup.d.ts +18 -0
- package/dist/src/utils/orphan-marketplace-cleanup.js +198 -0
- package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -0
- package/dist/src/utils/ownership.d.ts +194 -0
- package/dist/src/utils/ownership.js +723 -0
- package/dist/src/utils/ownership.js.map +1 -0
- package/dist/src/utils/path-catalog-provider.d.ts +7 -0
- package/dist/src/utils/path-catalog-provider.js +74 -0
- package/dist/src/utils/path-catalog-provider.js.map +1 -0
- package/dist/src/utils/paths.d.ts +40 -0
- package/dist/src/utils/paths.js +137 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/platform-entries.d.ts +1 -0
- package/dist/src/utils/platform-entries.js +2 -0
- package/dist/src/utils/platform-entries.js.map +1 -0
- package/dist/src/utils/platform-support.d.ts +1 -0
- package/dist/src/utils/platform-support.js +2 -0
- package/dist/src/utils/platform-support.js.map +1 -0
- package/dist/src/utils/plugin-config-write.d.ts +110 -0
- package/dist/src/utils/plugin-config-write.js +773 -0
- package/dist/src/utils/plugin-config-write.js.map +1 -0
- package/dist/src/utils/plugin-config.d.ts +389 -0
- package/dist/src/utils/plugin-config.js +1642 -0
- package/dist/src/utils/plugin-config.js.map +1 -0
- package/dist/src/utils/plugin-dependencies.d.ts +12 -0
- package/dist/src/utils/plugin-dependencies.js +162 -0
- package/dist/src/utils/plugin-dependencies.js.map +1 -0
- package/dist/src/utils/plugin-intent-state.d.ts +34 -0
- package/dist/src/utils/plugin-intent-state.js +289 -0
- package/dist/src/utils/plugin-intent-state.js.map +1 -0
- package/dist/src/utils/plugin-script-contract.d.ts +1 -0
- package/dist/src/utils/plugin-script-contract.js +2 -0
- package/dist/src/utils/plugin-script-contract.js.map +1 -0
- package/dist/src/utils/plugin-scripts.d.ts +101 -0
- package/dist/src/utils/plugin-scripts.js +253 -0
- package/dist/src/utils/plugin-scripts.js.map +1 -0
- package/dist/src/utils/process-lock.d.ts +47 -0
- package/dist/src/utils/process-lock.js +532 -0
- package/dist/src/utils/process-lock.js.map +1 -0
- package/dist/src/utils/process-tree.d.ts +2 -0
- package/dist/src/utils/process-tree.js +2 -0
- package/dist/src/utils/process-tree.js.map +1 -0
- package/dist/src/utils/project-boundary.d.ts +9 -0
- package/dist/src/utils/project-boundary.js +67 -0
- package/dist/src/utils/project-boundary.js.map +1 -0
- package/dist/src/utils/rendered-contract.d.ts +8 -0
- package/dist/src/utils/rendered-contract.js +134 -0
- package/dist/src/utils/rendered-contract.js.map +1 -0
- package/dist/src/utils/runtime-skill-closure.d.ts +13 -0
- package/dist/src/utils/runtime-skill-closure.js +863 -0
- package/dist/src/utils/runtime-skill-closure.js.map +1 -0
- package/dist/src/utils/safe-fs.d.ts +21 -0
- package/dist/src/utils/safe-fs.js +111 -0
- package/dist/src/utils/safe-fs.js.map +1 -0
- package/dist/src/utils/skill-authoring.d.ts +1 -0
- package/dist/src/utils/skill-authoring.js +2 -0
- package/dist/src/utils/skill-authoring.js.map +1 -0
- package/dist/src/utils/skill-validation.d.ts +37 -0
- package/dist/src/utils/skill-validation.js +326 -0
- package/dist/src/utils/skill-validation.js.map +1 -0
- package/dist/src/utils/slash-commands.d.ts +1 -0
- package/dist/src/utils/slash-commands.js +2 -0
- package/dist/src/utils/slash-commands.js.map +1 -0
- package/dist/src/utils/state-paths.d.ts +14 -0
- package/dist/src/utils/state-paths.js +139 -0
- package/dist/src/utils/state-paths.js.map +1 -0
- package/dist/src/utils/target-eligibility.d.ts +13 -0
- package/dist/src/utils/target-eligibility.js +35 -0
- package/dist/src/utils/target-eligibility.js.map +1 -0
- package/dist/src/utils/target-order.d.ts +7 -0
- package/dist/src/utils/target-order.js +10 -0
- package/dist/src/utils/target-order.js.map +1 -0
- package/dist/src/utils/template-engine.d.ts +1 -0
- package/dist/src/utils/template-engine.js +2 -0
- package/dist/src/utils/template-engine.js.map +1 -0
- package/dist/src/utils/test-path-fence.d.ts +12 -0
- package/dist/src/utils/test-path-fence.js +31 -0
- package/dist/src/utils/test-path-fence.js.map +1 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +16 -0
- package/dist/vitest.config.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,1180 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { readClaudeSettings } from '../adapters/helpers.js';
|
|
4
|
+
import { readCodexConfigFile } from './codex-config.js';
|
|
5
|
+
import { readJsonFileIfExists } from './json.js';
|
|
6
|
+
import { getClaudeHome, getCodexHome, canonicalizePathThroughExistingAncestorSync, resolveAwHome, resolveAwHomeCanonical, resolveRepoRootSync, } from './state-paths.js';
|
|
7
|
+
import { OWNED_TEXT_HEADER_PREFIX, SHARED_OWNER_TOKEN_PREFIX, parseSharedOwnerToken, parseOwnedTextHeader, readSkillOwnerMarker, SKILL_OWNER_MARKER, } from './ownership.js';
|
|
8
|
+
import { sanitizeCatalogSourceErrorMessage } from './catalog-public-error.js';
|
|
9
|
+
import { readStrictNamespacedMarketplaceRoot } from './local-marketplace.js';
|
|
10
|
+
import { readPluginIntentState, resolvePluginIntentStatePath, } from './plugin-intent-state.js';
|
|
11
|
+
export function canonicalMarketplaceRegistrationNames(references, sourceId) {
|
|
12
|
+
return [...new Set(references.flatMap((reference) => reference.kind === 'namespacedMarketplace'
|
|
13
|
+
&& reference.sourceId === sourceId
|
|
14
|
+
&& reference.pluginName === undefined
|
|
15
|
+
&& reference.marketplaceName
|
|
16
|
+
? [reference.marketplaceName]
|
|
17
|
+
: []))];
|
|
18
|
+
}
|
|
19
|
+
function pluginNameFromMarketplaceId(pluginId, marketplaceName) {
|
|
20
|
+
const suffix = `@${marketplaceName}`;
|
|
21
|
+
return pluginId.endsWith(suffix) && pluginId.length > suffix.length
|
|
22
|
+
? pluginId.slice(0, -suffix.length)
|
|
23
|
+
: null;
|
|
24
|
+
}
|
|
25
|
+
function claudeConsumersFromSettings(value, marketplaceName, scope) {
|
|
26
|
+
if (!value)
|
|
27
|
+
return [];
|
|
28
|
+
const output = [];
|
|
29
|
+
for (const pluginId of Object.keys(isRecord(value.enabledPlugins) ? value.enabledPlugins : {})) {
|
|
30
|
+
const pluginName = pluginNameFromMarketplaceId(pluginId, marketplaceName);
|
|
31
|
+
if (pluginName)
|
|
32
|
+
output.push({ pluginName, platform: 'claude', scope });
|
|
33
|
+
}
|
|
34
|
+
const plugins = isRecord(value.plugins) && isRecord(value.plugins.installed)
|
|
35
|
+
? value.plugins.installed
|
|
36
|
+
: {};
|
|
37
|
+
for (const [key, raw] of Object.entries(plugins)) {
|
|
38
|
+
if (!isRecord(raw) || raw.marketplace !== marketplaceName)
|
|
39
|
+
continue;
|
|
40
|
+
const pluginName = typeof raw.name === 'string'
|
|
41
|
+
? raw.name
|
|
42
|
+
: pluginNameFromMarketplaceId(key, marketplaceName) ?? key;
|
|
43
|
+
output.push({ pluginName, platform: 'claude', scope });
|
|
44
|
+
}
|
|
45
|
+
return output;
|
|
46
|
+
}
|
|
47
|
+
function claudeConsumersFromInstalled(value, marketplaceName, currentProject, includeHistoricalProjects = false) {
|
|
48
|
+
const output = [];
|
|
49
|
+
if (value !== null && !isRecord(value)) {
|
|
50
|
+
throw new Error('Claude installed_plugins must be a JSON object.');
|
|
51
|
+
}
|
|
52
|
+
if (value?.plugins !== undefined && !isRecord(value.plugins)) {
|
|
53
|
+
throw new Error('Claude installed_plugins.plugins must be a JSON object.');
|
|
54
|
+
}
|
|
55
|
+
const plugins = value?.plugins ?? {};
|
|
56
|
+
for (const [key, raw] of Object.entries(plugins)) {
|
|
57
|
+
for (const item of Array.isArray(raw) ? raw : [raw]) {
|
|
58
|
+
if (!isRecord(item)) {
|
|
59
|
+
throw new Error(`Claude installed_plugins record ${key} must be a JSON object.`);
|
|
60
|
+
}
|
|
61
|
+
if (item.marketplace !== undefined
|
|
62
|
+
&& (typeof item.marketplace !== 'string' || item.marketplace.length === 0)) {
|
|
63
|
+
throw new Error(`Claude installed_plugins record ${key} has an invalid marketplace identity.`);
|
|
64
|
+
}
|
|
65
|
+
if (item.name !== undefined && (typeof item.name !== 'string' || item.name.length === 0)) {
|
|
66
|
+
throw new Error(`Claude installed_plugins record ${key} has an invalid plugin identity.`);
|
|
67
|
+
}
|
|
68
|
+
if (item.scope !== undefined
|
|
69
|
+
&& item.scope !== 'user'
|
|
70
|
+
&& item.scope !== 'project'
|
|
71
|
+
&& item.scope !== 'local') {
|
|
72
|
+
throw new Error(`Claude installed_plugins record ${key} has an invalid scope.`);
|
|
73
|
+
}
|
|
74
|
+
if (item.projectPath !== undefined && typeof item.projectPath !== 'string') {
|
|
75
|
+
throw new Error(`Claude installed_plugins record ${key} has an invalid projectPath.`);
|
|
76
|
+
}
|
|
77
|
+
const itemMarketplace = typeof item.marketplace === 'string'
|
|
78
|
+
? item.marketplace
|
|
79
|
+
: pluginNameFromMarketplaceId(key, marketplaceName) ? marketplaceName : undefined;
|
|
80
|
+
if (!itemMarketplace)
|
|
81
|
+
continue;
|
|
82
|
+
if (itemMarketplace !== marketplaceName)
|
|
83
|
+
continue;
|
|
84
|
+
const scope = item.scope === 'project' || item.scope === 'local' ? 'project' : 'user';
|
|
85
|
+
const projectKey = scope === 'project'
|
|
86
|
+
? typeof item.projectPath === 'string' && path.isAbsolute(item.projectPath)
|
|
87
|
+
? canonicalizePathThroughExistingAncestorSync(item.projectPath)
|
|
88
|
+
: null
|
|
89
|
+
: undefined;
|
|
90
|
+
if (scope === 'project' && !includeHistoricalProjects && projectKey !== currentProject)
|
|
91
|
+
continue;
|
|
92
|
+
const pluginName = typeof item.name === 'string'
|
|
93
|
+
? item.name
|
|
94
|
+
: pluginNameFromMarketplaceId(key, marketplaceName) ?? key;
|
|
95
|
+
output.push({ pluginName, platform: 'claude', scope, ...(scope === 'project' ? { projectKey } : {}) });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return output;
|
|
99
|
+
}
|
|
100
|
+
function pathSegmentsWithin(root, location) {
|
|
101
|
+
const relative = path.relative(path.resolve(root), path.resolve(location));
|
|
102
|
+
if (relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative))) {
|
|
103
|
+
return relative === '' ? [] : relative.split(path.sep);
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
function inventoryErrorRelevance(location, env, cwd) {
|
|
108
|
+
const repoRoot = resolveRepoRootSync(cwd);
|
|
109
|
+
const awHome = resolveAwHome(env);
|
|
110
|
+
const canonicalRepoRoot = (() => {
|
|
111
|
+
try {
|
|
112
|
+
return fs.realpathSync(repoRoot);
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return path.resolve(repoRoot);
|
|
116
|
+
}
|
|
117
|
+
})();
|
|
118
|
+
const canonicalAwHome = (() => {
|
|
119
|
+
try {
|
|
120
|
+
return canonicalizePathThroughExistingAncestorSync(awHome);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return path.resolve(awHome);
|
|
124
|
+
}
|
|
125
|
+
})();
|
|
126
|
+
const projectRoots = [
|
|
127
|
+
[path.join(repoRoot, '.codex'), 'codex'],
|
|
128
|
+
[path.join(repoRoot, '.agents'), 'codex'],
|
|
129
|
+
[path.join(repoRoot, '.claude'), 'claude'],
|
|
130
|
+
];
|
|
131
|
+
for (const [root, platform] of projectRoots) {
|
|
132
|
+
if (pathSegmentsWithin(root, location) !== null) {
|
|
133
|
+
return { global: false, platform, scope: 'project' };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
for (const fileName of ['installed_plugins.json', 'known_marketplaces.json']) {
|
|
137
|
+
if (pathSegmentsWithin(path.join(getClaudeHome(env), 'plugins', fileName), location) !== null) {
|
|
138
|
+
return { global: false, platform: 'claude' };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (pathSegmentsWithin(getCodexHome(env), location) !== null) {
|
|
142
|
+
return { global: false, platform: 'codex', scope: 'user' };
|
|
143
|
+
}
|
|
144
|
+
if (pathSegmentsWithin(getClaudeHome(env), location) !== null) {
|
|
145
|
+
return { global: false, platform: 'claude', scope: 'user' };
|
|
146
|
+
}
|
|
147
|
+
for (const root of new Set([awHome, canonicalAwHome])) {
|
|
148
|
+
const marketplace = pathSegmentsWithin(path.join(root, 'marketplaces'), location);
|
|
149
|
+
if (marketplace?.[0])
|
|
150
|
+
return { global: false, sourceId: marketplace[0] };
|
|
151
|
+
}
|
|
152
|
+
for (const [root, scope] of [
|
|
153
|
+
[path.join(awHome, 'plugin-config'), 'user'],
|
|
154
|
+
[path.join(canonicalAwHome, 'plugin-config'), 'user'],
|
|
155
|
+
[path.join(repoRoot, '.agent-workflows', 'plugin-config'), 'project'],
|
|
156
|
+
[path.join(canonicalRepoRoot, '.agent-workflows', 'plugin-config'), 'project'],
|
|
157
|
+
]) {
|
|
158
|
+
const segments = pathSegmentsWithin(root, location);
|
|
159
|
+
if (segments !== null) {
|
|
160
|
+
return {
|
|
161
|
+
global: false,
|
|
162
|
+
...(segments[0] ? { sourceId: segments[0] } : {}),
|
|
163
|
+
...(segments[1] ? { pluginName: segments[1] } : {}),
|
|
164
|
+
scope,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
for (const root of new Set([repoRoot, canonicalRepoRoot])) {
|
|
169
|
+
if (pathSegmentsWithin(path.join(root, '.agent-workflows'), location) !== null) {
|
|
170
|
+
return { global: false, scope: 'project' };
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return { global: true };
|
|
174
|
+
}
|
|
175
|
+
function isAbsentState(error) {
|
|
176
|
+
const code = error.code;
|
|
177
|
+
return code === 'ENOENT';
|
|
178
|
+
}
|
|
179
|
+
function inventoryError(error, location, kind, env, cwd, relevance) {
|
|
180
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
181
|
+
const sensitiveRoots = [getCodexHome(env), getClaudeHome(env), resolveRepoRootSync(cwd)];
|
|
182
|
+
return {
|
|
183
|
+
code: 'stateInventoryFailed',
|
|
184
|
+
kind,
|
|
185
|
+
location: sanitizeCatalogSourceErrorMessage(location, env, sensitiveRoots),
|
|
186
|
+
message: sanitizeCatalogSourceErrorMessage(message, env, sensitiveRoots),
|
|
187
|
+
relevance: relevance ?? inventoryErrorRelevance(location, env, cwd),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
async function inventoryRead(options) {
|
|
191
|
+
try {
|
|
192
|
+
return await options.operation();
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
if (options.reportAbsent || !isAbsentState(error)) {
|
|
196
|
+
options.errors.push(inventoryError(error, options.location, options.kind, options.env, options.cwd));
|
|
197
|
+
}
|
|
198
|
+
return options.absent;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async function inventoryCanonicalDirectory(options) {
|
|
202
|
+
const stats = await inventoryRead({
|
|
203
|
+
operation: () => fs.lstat(options.location),
|
|
204
|
+
absent: null,
|
|
205
|
+
errors: options.errors,
|
|
206
|
+
location: options.location,
|
|
207
|
+
kind: options.kind,
|
|
208
|
+
env: options.env,
|
|
209
|
+
cwd: options.cwd,
|
|
210
|
+
});
|
|
211
|
+
if (stats === null)
|
|
212
|
+
return false;
|
|
213
|
+
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
214
|
+
options.errors.push(inventoryError(new Error('State namespace root must be a canonical directory.'), options.location, options.kind, options.env, options.cwd));
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
async function inventoryCanonicalDirectoryEntries(options) {
|
|
220
|
+
if (!await inventoryCanonicalDirectory(options))
|
|
221
|
+
return [];
|
|
222
|
+
return inventoryRead({
|
|
223
|
+
operation: () => fs.readdir(options.location, { withFileTypes: true }),
|
|
224
|
+
absent: [],
|
|
225
|
+
errors: options.errors,
|
|
226
|
+
location: options.location,
|
|
227
|
+
kind: options.kind,
|
|
228
|
+
env: options.env,
|
|
229
|
+
cwd: options.cwd,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
async function inventoryCanonicalDescendantDirectory(options) {
|
|
233
|
+
let location = options.root;
|
|
234
|
+
for (const segment of options.segments) {
|
|
235
|
+
location = path.join(location, segment);
|
|
236
|
+
if (!await inventoryCanonicalDirectory({
|
|
237
|
+
errors: options.errors,
|
|
238
|
+
location,
|
|
239
|
+
kind: options.kind,
|
|
240
|
+
env: options.env,
|
|
241
|
+
cwd: options.cwd,
|
|
242
|
+
}))
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
return location;
|
|
246
|
+
}
|
|
247
|
+
async function inventoryPluginConfigRoots(options) {
|
|
248
|
+
const roots = [];
|
|
249
|
+
const rawAwHome = resolveAwHome(options.env);
|
|
250
|
+
const awHome = await inventoryRead({
|
|
251
|
+
operation: () => resolveAwHomeCanonical(options.env),
|
|
252
|
+
absent: null,
|
|
253
|
+
errors: options.errors,
|
|
254
|
+
location: rawAwHome,
|
|
255
|
+
kind: 'configDirectoryRead',
|
|
256
|
+
env: options.env,
|
|
257
|
+
cwd: options.cwd,
|
|
258
|
+
});
|
|
259
|
+
if (awHome && await inventoryCanonicalDirectory({
|
|
260
|
+
errors: options.errors,
|
|
261
|
+
location: awHome,
|
|
262
|
+
kind: 'configDirectoryRead',
|
|
263
|
+
env: options.env,
|
|
264
|
+
cwd: options.cwd,
|
|
265
|
+
})) {
|
|
266
|
+
const userRoot = await inventoryCanonicalDescendantDirectory({
|
|
267
|
+
root: rawAwHome,
|
|
268
|
+
segments: ['plugin-config'],
|
|
269
|
+
errors: options.errors,
|
|
270
|
+
kind: 'configDirectoryRead',
|
|
271
|
+
env: options.env,
|
|
272
|
+
cwd: options.cwd,
|
|
273
|
+
});
|
|
274
|
+
if (userRoot)
|
|
275
|
+
roots.push({ root: userRoot, scope: 'user' });
|
|
276
|
+
}
|
|
277
|
+
const rawRepoRoot = resolveRepoRootSync(options.cwd);
|
|
278
|
+
const repoRoot = await inventoryRead({
|
|
279
|
+
operation: () => fs.realpath(rawRepoRoot),
|
|
280
|
+
absent: null,
|
|
281
|
+
reportAbsent: true,
|
|
282
|
+
errors: options.errors,
|
|
283
|
+
location: rawRepoRoot,
|
|
284
|
+
kind: 'projectRootRead',
|
|
285
|
+
env: options.env,
|
|
286
|
+
cwd: options.cwd,
|
|
287
|
+
});
|
|
288
|
+
if (repoRoot && await inventoryCanonicalDirectory({
|
|
289
|
+
errors: options.errors,
|
|
290
|
+
location: repoRoot,
|
|
291
|
+
kind: 'projectRootRead',
|
|
292
|
+
env: options.env,
|
|
293
|
+
cwd: options.cwd,
|
|
294
|
+
})) {
|
|
295
|
+
const projectRoot = await inventoryCanonicalDescendantDirectory({
|
|
296
|
+
root: rawRepoRoot,
|
|
297
|
+
segments: ['.agent-workflows', 'plugin-config'],
|
|
298
|
+
errors: options.errors,
|
|
299
|
+
kind: 'configDirectoryRead',
|
|
300
|
+
env: options.env,
|
|
301
|
+
cwd: options.cwd,
|
|
302
|
+
});
|
|
303
|
+
if (projectRoot)
|
|
304
|
+
roots.push({ root: projectRoot, scope: 'project', projectKey: repoRoot });
|
|
305
|
+
}
|
|
306
|
+
return roots;
|
|
307
|
+
}
|
|
308
|
+
export async function inventoryLegacyOwnerReferences(options) {
|
|
309
|
+
const env = options.env ?? process.env;
|
|
310
|
+
const awHome = resolveAwHome(env);
|
|
311
|
+
const repoRoot = resolveRepoRootSync(options.cwd);
|
|
312
|
+
const references = [];
|
|
313
|
+
const errors = [];
|
|
314
|
+
const skillRoots = new Set([
|
|
315
|
+
path.join(getCodexHome(env), 'skills'),
|
|
316
|
+
path.join(getClaudeHome(env), 'skills'),
|
|
317
|
+
path.join(repoRoot, '.claude', 'skills'),
|
|
318
|
+
]);
|
|
319
|
+
const legacyPluginsRoot = path.join(awHome, 'plugins');
|
|
320
|
+
const legacyPlugins = await inventoryRead({
|
|
321
|
+
operation: () => fs.readdir(legacyPluginsRoot, { withFileTypes: true }),
|
|
322
|
+
absent: [], errors, location: legacyPluginsRoot, kind: 'pluginDirectoryRead', env, cwd: options.cwd,
|
|
323
|
+
});
|
|
324
|
+
for (const plugin of legacyPlugins) {
|
|
325
|
+
if (!plugin.isDirectory() || plugin.isSymbolicLink())
|
|
326
|
+
continue;
|
|
327
|
+
for (const root of await resolveCanonicalPluginSkillRoots(path.join(legacyPluginsRoot, plugin.name), true, errors, env, options.cwd))
|
|
328
|
+
skillRoots.add(root);
|
|
329
|
+
}
|
|
330
|
+
for (const root of skillRoots) {
|
|
331
|
+
references.push(...await findDirectSkillOwnerMarkers(root, errors, env, options.cwd));
|
|
332
|
+
}
|
|
333
|
+
for (const configRoot of [
|
|
334
|
+
getCodexHome(env),
|
|
335
|
+
getClaudeHome(env),
|
|
336
|
+
path.join(repoRoot, '.claude'),
|
|
337
|
+
]) {
|
|
338
|
+
references.push(...await findOwnedHeadersInDirectory(path.join(configRoot, 'rules'), new Set(['.md', '.rules']), true, errors, env, options.cwd), ...await findOwnedHeadersInDirectory(path.join(configRoot, 'agents'), new Set(['.md', '.toml']), true, errors, env, options.cwd));
|
|
339
|
+
}
|
|
340
|
+
for (const [directory, extensions] of [
|
|
341
|
+
[path.join(repoRoot, '.codex', 'rules'), new Set(['.md', '.rules'])],
|
|
342
|
+
[path.join(repoRoot, '.codex', 'agents'), new Set(['.md', '.toml'])],
|
|
343
|
+
]) {
|
|
344
|
+
references.push(...(await findOwnedHeadersInDirectory(directory, extensions, true, errors, env, options.cwd)).filter((reference) => reference.kind === 'namespacedOwner'));
|
|
345
|
+
}
|
|
346
|
+
for (const filePath of [path.join(getCodexHome(env), 'AGENTS.md')]) {
|
|
347
|
+
const reference = await readOwnedHeaderReference(filePath, false, errors, env, options.cwd);
|
|
348
|
+
if (reference)
|
|
349
|
+
references.push(reference);
|
|
350
|
+
}
|
|
351
|
+
const unique = [...new Map(references.map((reference) => [[
|
|
352
|
+
reference.kind,
|
|
353
|
+
reference.location,
|
|
354
|
+
reference.sourceId ?? '',
|
|
355
|
+
reference.sourceIdentity ?? '',
|
|
356
|
+
reference.pluginName ?? '',
|
|
357
|
+
reference.platform ?? '',
|
|
358
|
+
reference.scope ?? '',
|
|
359
|
+
reference.marketplaceName ?? '',
|
|
360
|
+
].join('\0'), reference])).values()];
|
|
361
|
+
unique.sort((left, right) => left.location.localeCompare(right.location));
|
|
362
|
+
return { inventorySchemaVersion: 1, references: unique, errors };
|
|
363
|
+
}
|
|
364
|
+
export async function inventoryLegacyConfigReferences(options) {
|
|
365
|
+
const env = options.env ?? process.env;
|
|
366
|
+
const references = [];
|
|
367
|
+
const errors = [];
|
|
368
|
+
for (const configRoot of await inventoryPluginConfigRoots({ errors, env, cwd: options.cwd })) {
|
|
369
|
+
const directory = configRoot.root;
|
|
370
|
+
const entries = await inventoryRead({
|
|
371
|
+
operation: () => fs.readdir(directory, { withFileTypes: true }),
|
|
372
|
+
absent: [], errors, location: directory, kind: 'configDirectoryRead', env, cwd: options.cwd,
|
|
373
|
+
});
|
|
374
|
+
for (const entry of entries) {
|
|
375
|
+
const entryRoot = path.join(directory, entry.name);
|
|
376
|
+
if (!await inventoryCanonicalDirectory({
|
|
377
|
+
errors, location: entryRoot, kind: 'configNamespaceValidation', env, cwd: options.cwd,
|
|
378
|
+
}))
|
|
379
|
+
continue;
|
|
380
|
+
const legacyFile = path.join(directory, entry.name, 'config.json');
|
|
381
|
+
const stat = await inventoryRead({
|
|
382
|
+
operation: () => fs.stat(legacyFile),
|
|
383
|
+
absent: null, errors, location: legacyFile, kind: 'configFileStat', env, cwd: options.cwd,
|
|
384
|
+
});
|
|
385
|
+
if (stat?.isFile()) {
|
|
386
|
+
references.push({
|
|
387
|
+
kind: 'legacyConfig',
|
|
388
|
+
location: legacyFile,
|
|
389
|
+
pluginName: entry.name,
|
|
390
|
+
scope: configRoot.scope,
|
|
391
|
+
...(configRoot.projectKey ? { projectKey: configRoot.projectKey } : {}),
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
references.sort((left, right) => left.location.localeCompare(right.location));
|
|
397
|
+
return { inventorySchemaVersion: 1, references, errors };
|
|
398
|
+
}
|
|
399
|
+
function ownerReferenceFromRaw(entryPath, raw) {
|
|
400
|
+
if (raw?.schemaVersion === 3 && raw.owner === 'agent-workflows'
|
|
401
|
+
&& typeof raw.sourceId === 'string'
|
|
402
|
+
&& raw.pluginId === `${raw.sourceId}/${raw.plugin}`) {
|
|
403
|
+
return {
|
|
404
|
+
kind: 'namespacedOwner',
|
|
405
|
+
location: entryPath,
|
|
406
|
+
sourceId: raw.sourceId,
|
|
407
|
+
...(typeof raw.plugin === 'string' ? { pluginName: raw.plugin } : {}),
|
|
408
|
+
...(typeof raw.platform === 'string' ? { platform: raw.platform } : {}),
|
|
409
|
+
...(typeof raw.scope === 'string' ? { scope: raw.scope } : {}),
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
async function readOwnedHeaderReference(filePath, requireGeneratedName, errors, env, cwd) {
|
|
415
|
+
const stats = await inventoryRead({
|
|
416
|
+
operation: () => fs.stat(filePath),
|
|
417
|
+
absent: null,
|
|
418
|
+
errors,
|
|
419
|
+
location: filePath,
|
|
420
|
+
kind: 'ownerHeaderStat',
|
|
421
|
+
env,
|
|
422
|
+
cwd,
|
|
423
|
+
});
|
|
424
|
+
if (!stats?.isFile() || stats.size > 1024 * 1024)
|
|
425
|
+
return null;
|
|
426
|
+
const content = await inventoryRead({
|
|
427
|
+
operation: () => fs.readFile(filePath, 'utf8'),
|
|
428
|
+
absent: null,
|
|
429
|
+
errors,
|
|
430
|
+
location: filePath,
|
|
431
|
+
kind: 'ownerHeaderRead',
|
|
432
|
+
env,
|
|
433
|
+
cwd,
|
|
434
|
+
});
|
|
435
|
+
if (content === null)
|
|
436
|
+
return null;
|
|
437
|
+
if (!content.includes(OWNED_TEXT_HEADER_PREFIX))
|
|
438
|
+
return null;
|
|
439
|
+
let parsed;
|
|
440
|
+
try {
|
|
441
|
+
parsed = parseOwnedTextHeader(content);
|
|
442
|
+
}
|
|
443
|
+
catch (error) {
|
|
444
|
+
errors.push(inventoryError(error, filePath, 'ownerHeaderParse', env, cwd));
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
447
|
+
if (!parsed)
|
|
448
|
+
return null;
|
|
449
|
+
if (requireGeneratedName
|
|
450
|
+
&& !path.basename(filePath).startsWith(`aw-${parsed.identity.plugin}-`)) {
|
|
451
|
+
errors.push(inventoryError(new Error('Owned text header path does not match its plugin identity.'), filePath, 'ownerHeaderPathValidation', env, cwd, {
|
|
452
|
+
global: false,
|
|
453
|
+
...(parsed.identity.sourceId ? { sourceId: parsed.identity.sourceId } : {}),
|
|
454
|
+
pluginName: parsed.identity.plugin,
|
|
455
|
+
platform: parsed.identity.platform,
|
|
456
|
+
scope: parsed.identity.scope,
|
|
457
|
+
}));
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
return ownerReferenceFromRaw(filePath, {
|
|
461
|
+
schemaVersion: 3,
|
|
462
|
+
...parsed.identity,
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
async function findOwnedHeadersInDirectory(directory, extensions, requireGeneratedName, errors, env, cwd) {
|
|
466
|
+
const output = [];
|
|
467
|
+
const entries = await inventoryRead({
|
|
468
|
+
operation: () => fs.readdir(directory, { withFileTypes: true }),
|
|
469
|
+
absent: [],
|
|
470
|
+
errors,
|
|
471
|
+
location: directory,
|
|
472
|
+
kind: 'ownerDirectoryRead',
|
|
473
|
+
env,
|
|
474
|
+
cwd,
|
|
475
|
+
});
|
|
476
|
+
for (const entry of entries) {
|
|
477
|
+
if (!entry.isFile() || entry.isSymbolicLink() || !extensions.has(path.extname(entry.name)))
|
|
478
|
+
continue;
|
|
479
|
+
const reference = await readOwnedHeaderReference(path.join(directory, entry.name), requireGeneratedName, errors, env, cwd);
|
|
480
|
+
if (reference)
|
|
481
|
+
output.push(reference);
|
|
482
|
+
}
|
|
483
|
+
return output;
|
|
484
|
+
}
|
|
485
|
+
function safeRelativeSkillRoot(value) {
|
|
486
|
+
if (typeof value !== 'string' || value.trim() === '')
|
|
487
|
+
return null;
|
|
488
|
+
const normalized = path.posix.normalize(value.replace(/^\.\//u, ''));
|
|
489
|
+
return normalized === '..' || normalized.startsWith('../') || path.isAbsolute(normalized)
|
|
490
|
+
? null
|
|
491
|
+
: normalized;
|
|
492
|
+
}
|
|
493
|
+
async function resolveCanonicalPluginSkillRoots(pluginRoot, includeLegacyFallbacks, errors, env, cwd) {
|
|
494
|
+
const [platformManifest, sourceManifest] = await Promise.all([
|
|
495
|
+
inventoryRead({
|
|
496
|
+
operation: () => fs.readJson(path.join(pluginRoot, '.codex-plugin', 'plugin.json')),
|
|
497
|
+
absent: null,
|
|
498
|
+
errors,
|
|
499
|
+
location: path.join(pluginRoot, '.codex-plugin', 'plugin.json'),
|
|
500
|
+
kind: 'pluginManifestRead',
|
|
501
|
+
env,
|
|
502
|
+
cwd,
|
|
503
|
+
}),
|
|
504
|
+
inventoryRead({
|
|
505
|
+
operation: () => fs.readJson(path.join(pluginRoot, '.agents-plugin', 'plugin.json')),
|
|
506
|
+
absent: null,
|
|
507
|
+
errors,
|
|
508
|
+
location: path.join(pluginRoot, '.agents-plugin', 'plugin.json'),
|
|
509
|
+
kind: 'pluginManifestRead',
|
|
510
|
+
env,
|
|
511
|
+
cwd,
|
|
512
|
+
}),
|
|
513
|
+
]);
|
|
514
|
+
const declared = safeRelativeSkillRoot(platformManifest?.skills ?? sourceManifest?.skills)
|
|
515
|
+
?? 'codex/skills';
|
|
516
|
+
return [...new Set([
|
|
517
|
+
path.join(pluginRoot, ...declared.split('/')),
|
|
518
|
+
...(includeLegacyFallbacks ? [
|
|
519
|
+
path.join(pluginRoot, 'skills'),
|
|
520
|
+
path.join(pluginRoot, 'codex', 'skills'),
|
|
521
|
+
] : []),
|
|
522
|
+
])];
|
|
523
|
+
}
|
|
524
|
+
async function findDirectSkillOwnerMarkers(root, errors, env, cwd) {
|
|
525
|
+
const output = [];
|
|
526
|
+
const entries = await inventoryRead({
|
|
527
|
+
operation: () => fs.readdir(root, { withFileTypes: true }),
|
|
528
|
+
absent: [],
|
|
529
|
+
errors,
|
|
530
|
+
location: root,
|
|
531
|
+
kind: 'skillRootRead',
|
|
532
|
+
env,
|
|
533
|
+
cwd,
|
|
534
|
+
});
|
|
535
|
+
for (const entry of entries) {
|
|
536
|
+
if (!entry.isDirectory() || entry.isSymbolicLink())
|
|
537
|
+
continue;
|
|
538
|
+
const skillRoot = path.join(root, entry.name);
|
|
539
|
+
const markerPath = path.join(root, entry.name, SKILL_OWNER_MARKER);
|
|
540
|
+
const markerStats = await inventoryRead({
|
|
541
|
+
operation: () => fs.lstat(markerPath),
|
|
542
|
+
absent: null,
|
|
543
|
+
errors,
|
|
544
|
+
location: markerPath,
|
|
545
|
+
kind: 'ownerMarkerRead',
|
|
546
|
+
env,
|
|
547
|
+
cwd,
|
|
548
|
+
});
|
|
549
|
+
if (!markerStats)
|
|
550
|
+
continue;
|
|
551
|
+
let marker;
|
|
552
|
+
try {
|
|
553
|
+
marker = await readSkillOwnerMarker({ skillRoot, allowedRoot: root });
|
|
554
|
+
}
|
|
555
|
+
catch (error) {
|
|
556
|
+
if (!isAbsentState(error)) {
|
|
557
|
+
const code = error.code;
|
|
558
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
559
|
+
errors.push(inventoryError(error, markerPath, code !== undefined || message.includes('JSON') ? 'ownerMarkerRead' : 'ownerMarkerValidation', env, cwd));
|
|
560
|
+
}
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
if (!marker)
|
|
564
|
+
continue;
|
|
565
|
+
const reference = ownerReferenceFromRaw(markerPath, { ...marker });
|
|
566
|
+
if (reference)
|
|
567
|
+
output.push(reference);
|
|
568
|
+
}
|
|
569
|
+
return output;
|
|
570
|
+
}
|
|
571
|
+
function sharedOwnerTokenReferences(filePath, tokens, errors, env, cwd) {
|
|
572
|
+
const output = [];
|
|
573
|
+
for (const token of new Set(tokens)) {
|
|
574
|
+
let identity;
|
|
575
|
+
try {
|
|
576
|
+
identity = parseSharedOwnerToken(token);
|
|
577
|
+
}
|
|
578
|
+
catch (error) {
|
|
579
|
+
errors.push(inventoryError(error, filePath, 'sharedOwnerTokenParse', env, cwd));
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
if (!identity?.sourceId)
|
|
583
|
+
continue;
|
|
584
|
+
output.push({
|
|
585
|
+
kind: 'namespacedOwner',
|
|
586
|
+
location: filePath,
|
|
587
|
+
sourceId: identity.sourceId,
|
|
588
|
+
pluginName: identity.plugin,
|
|
589
|
+
platform: identity.platform,
|
|
590
|
+
scope: identity.scope,
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
return output;
|
|
594
|
+
}
|
|
595
|
+
async function codexSharedOwnerReferences(filePath, _scope, errors, env, cwd) {
|
|
596
|
+
const config = await readCodexConfigFile(filePath);
|
|
597
|
+
const ownerValues = [
|
|
598
|
+
...Object.keys(config.snapshot.developerInstructions.managedBlocks).map((value) => ({
|
|
599
|
+
value,
|
|
600
|
+
location: filePath,
|
|
601
|
+
})),
|
|
602
|
+
];
|
|
603
|
+
const references = sharedOwnerTokenReferences(filePath, ownerValues.map((entry) => entry.value).filter((value) => value.startsWith(SHARED_OWNER_TOKEN_PREFIX)), errors, env, cwd);
|
|
604
|
+
return references;
|
|
605
|
+
}
|
|
606
|
+
async function claudeSharedOwnerReferences(filePath, _scope, errors, env, cwd) {
|
|
607
|
+
const settings = await readJsonFileIfExists(filePath);
|
|
608
|
+
const generated = settings && isRecord(settings.awGenerated) ? settings.awGenerated : null;
|
|
609
|
+
const permissions = generated && isRecord(generated.permissions) ? generated.permissions : {};
|
|
610
|
+
const keys = Object.keys(permissions);
|
|
611
|
+
const references = sharedOwnerTokenReferences(filePath, keys.filter((token) => token.startsWith(SHARED_OWNER_TOKEN_PREFIX)), errors, env, cwd);
|
|
612
|
+
return references;
|
|
613
|
+
}
|
|
614
|
+
function isRecord(value) {
|
|
615
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
616
|
+
}
|
|
617
|
+
function assertNamespacedConfigEnvelope(value, sourceId, pluginName) {
|
|
618
|
+
if (!isRecord(value)
|
|
619
|
+
|| value.schemaVersion !== 3
|
|
620
|
+
|| typeof value.sourceId !== 'string'
|
|
621
|
+
|| typeof value.sourceIdentity !== 'string'
|
|
622
|
+
|| !/^sha256:[0-9a-f]{64}$/u.test(value.sourceIdentity)
|
|
623
|
+
|| typeof value.pluginName !== 'string'
|
|
624
|
+
|| !isRecord(value.values)
|
|
625
|
+
|| Object.keys(value).some((key) => ![
|
|
626
|
+
'schemaVersion', 'sourceId', 'sourceIdentity', 'pluginName', 'values',
|
|
627
|
+
].includes(key))) {
|
|
628
|
+
throw new Error('Namespaced plugin config is not a valid schema 3 envelope.');
|
|
629
|
+
}
|
|
630
|
+
if (value.sourceId !== sourceId || value.pluginName !== pluginName) {
|
|
631
|
+
throw new Error('Namespaced plugin config identity does not match its directory path.');
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
function hasClaudeMarketplaceConsumer(value) {
|
|
635
|
+
if (Array.isArray(value))
|
|
636
|
+
return value.some(hasClaudeMarketplaceConsumer);
|
|
637
|
+
if (!isRecord(value))
|
|
638
|
+
return false;
|
|
639
|
+
if (value.marketplace === 'aw')
|
|
640
|
+
return true;
|
|
641
|
+
return Object.values(value).some(hasClaudeMarketplaceConsumer);
|
|
642
|
+
}
|
|
643
|
+
function isAwPluginConsumerKey(value) {
|
|
644
|
+
return value.length > '@aw'.length && value.endsWith('@aw');
|
|
645
|
+
}
|
|
646
|
+
function hasAwPluginConsumerKeys(value) {
|
|
647
|
+
return isRecord(value) && Object.keys(value).some(isAwPluginConsumerKey);
|
|
648
|
+
}
|
|
649
|
+
async function oldMarketplaceReferences(env, cwd, errors, includePlatformHistoricalProjects) {
|
|
650
|
+
const codexPath = path.join(getCodexHome(env), 'config.toml');
|
|
651
|
+
const claudeSettingsPath = path.join(getClaudeHome(env), 'settings.json');
|
|
652
|
+
const claudeKnownPath = path.join(getClaudeHome(env), 'plugins', 'known_marketplaces.json');
|
|
653
|
+
const claudeInstalledPath = path.join(getClaudeHome(env), 'plugins', 'installed_plugins.json');
|
|
654
|
+
const output = [];
|
|
655
|
+
const marketplacesRoot = path.join(resolveAwHome(env), 'marketplaces');
|
|
656
|
+
const namespacedPrimaryRoots = new Set();
|
|
657
|
+
const marketplaceEntries = await inventoryCanonicalDirectoryEntries({
|
|
658
|
+
errors, location: marketplacesRoot, kind: 'marketplaceDirectoryRead', env, cwd,
|
|
659
|
+
});
|
|
660
|
+
for (const entry of marketplaceEntries) {
|
|
661
|
+
const marketplaceRoot = path.join(marketplacesRoot, entry.name);
|
|
662
|
+
if (!await inventoryCanonicalDirectory({
|
|
663
|
+
errors, location: marketplaceRoot, kind: 'marketplaceRootValidation', env, cwd,
|
|
664
|
+
}))
|
|
665
|
+
continue;
|
|
666
|
+
const manifestPath = path.join(marketplacesRoot, entry.name, '.agents', 'plugins', 'marketplace.json');
|
|
667
|
+
const configPath = path.join(marketplacesRoot, entry.name, 'config.json');
|
|
668
|
+
const manifest = await inventoryRead({
|
|
669
|
+
operation: () => fs.readJson(manifestPath), absent: null, errors,
|
|
670
|
+
location: manifestPath, kind: 'marketplaceManifestRead', env, cwd,
|
|
671
|
+
});
|
|
672
|
+
const config = await inventoryRead({
|
|
673
|
+
operation: () => fs.readJson(configPath), absent: null, errors,
|
|
674
|
+
location: configPath, kind: 'marketplaceConfigRead', env, cwd,
|
|
675
|
+
});
|
|
676
|
+
if (manifest?.name === 'aw' && config?.schemaVersion === 2 && config.sourceId === entry.name) {
|
|
677
|
+
namespacedPrimaryRoots.add(path.normalize(path.join(marketplacesRoot, entry.name)));
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
const codex = await inventoryRead({
|
|
681
|
+
operation: () => readCodexConfigFile(codexPath), absent: null, errors,
|
|
682
|
+
location: codexPath, kind: 'nativeStateRead', env, cwd,
|
|
683
|
+
});
|
|
684
|
+
const codexAw = codex?.snapshot.marketplaces.aw;
|
|
685
|
+
const codexAwIsNamespaced = codexAw?.sourceType === 'local'
|
|
686
|
+
&& !codexAw.sourcePointsToManifest
|
|
687
|
+
&& namespacedPrimaryRoots.has(path.normalize(codexAw.source ?? ''));
|
|
688
|
+
if (codex && (Object.hasOwn(codex.snapshot.marketplaces, 'aw') || Object.keys(codex.snapshot.plugins).some(isAwPluginConsumerKey))
|
|
689
|
+
&& !codexAwIsNamespaced) {
|
|
690
|
+
output.push({ kind: 'legacyMarketplace', location: codexPath });
|
|
691
|
+
for (const pluginId of Object.keys(codex.snapshot.plugins)) {
|
|
692
|
+
const pluginName = pluginNameFromMarketplaceId(pluginId, 'aw');
|
|
693
|
+
if (pluginName)
|
|
694
|
+
output.push({
|
|
695
|
+
kind: 'legacyMarketplace',
|
|
696
|
+
location: codexPath,
|
|
697
|
+
pluginName,
|
|
698
|
+
platform: 'codex',
|
|
699
|
+
scope: 'user',
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
const settings = await inventoryRead({
|
|
704
|
+
operation: () => readClaudeSettings(claudeSettingsPath), absent: null, errors,
|
|
705
|
+
location: claudeSettingsPath, kind: 'nativeStateRead', env, cwd,
|
|
706
|
+
});
|
|
707
|
+
const known = await inventoryRead({
|
|
708
|
+
operation: () => readJsonFileIfExists(claudeKnownPath), absent: null, errors,
|
|
709
|
+
location: claudeKnownPath, kind: 'nativeStateRead', env, cwd,
|
|
710
|
+
});
|
|
711
|
+
const declarationPaths = [
|
|
712
|
+
settings?.extraKnownMarketplaces?.aw,
|
|
713
|
+
known?.aw,
|
|
714
|
+
isRecord(known?.marketplaces) ? known.marketplaces.aw : undefined,
|
|
715
|
+
].flatMap((value) => collectMarketplaceDeclarationPaths(value));
|
|
716
|
+
const claudeAwIsNamespaced = declarationPaths.length > 0
|
|
717
|
+
&& declarationPaths.every((entry) => namespacedPrimaryRoots.has(path.normalize(entry)));
|
|
718
|
+
if ((settings && (Object.hasOwn(settings.extraKnownMarketplaces ?? {}, 'aw')
|
|
719
|
+
|| hasAwPluginConsumerKeys(settings.enabledPlugins)
|
|
720
|
+
|| hasAwPluginConsumerKeys(settings.plugins?.installed)
|
|
721
|
+
|| hasClaudeMarketplaceConsumer(settings.plugins?.installed))) && !claudeAwIsNamespaced) {
|
|
722
|
+
output.push({ kind: 'legacyMarketplace', location: claudeSettingsPath });
|
|
723
|
+
for (const consumer of claudeConsumersFromSettings(settings, 'aw', 'user')) {
|
|
724
|
+
output.push({ kind: 'legacyMarketplace', location: claudeSettingsPath, ...consumer });
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (known && (Object.hasOwn(known, 'aw')
|
|
728
|
+
|| (isRecord(known.marketplaces) && Object.hasOwn(known.marketplaces, 'aw'))
|
|
729
|
+
|| hasClaudeMarketplaceConsumer(known)) && !claudeAwIsNamespaced) {
|
|
730
|
+
output.push({ kind: 'legacyMarketplace', location: claudeKnownPath });
|
|
731
|
+
}
|
|
732
|
+
const installed = await inventoryRead({
|
|
733
|
+
operation: () => readJsonFileIfExists(claudeInstalledPath), absent: null, errors,
|
|
734
|
+
location: claudeInstalledPath, kind: 'nativeStateRead', env, cwd,
|
|
735
|
+
});
|
|
736
|
+
if (installed && (hasAwPluginConsumerKeys(installed.plugins)
|
|
737
|
+
|| hasClaudeMarketplaceConsumer(installed.plugins)) && !claudeAwIsNamespaced) {
|
|
738
|
+
output.push({ kind: 'legacyMarketplace', location: claudeInstalledPath });
|
|
739
|
+
const canonicalProjectRoot = await inventoryRead({
|
|
740
|
+
operation: () => fs.realpath(resolveRepoRootSync(cwd)),
|
|
741
|
+
absent: path.resolve(resolveRepoRootSync(cwd)), errors,
|
|
742
|
+
location: resolveRepoRootSync(cwd), kind: 'projectRootRead', env, cwd,
|
|
743
|
+
});
|
|
744
|
+
try {
|
|
745
|
+
for (const consumer of claudeConsumersFromInstalled(installed, 'aw', path.normalize(canonicalProjectRoot), includePlatformHistoricalProjects)) {
|
|
746
|
+
output.push({ kind: 'legacyMarketplace', location: claudeInstalledPath, ...consumer });
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
catch (error) {
|
|
750
|
+
errors.push(inventoryError(error, claudeInstalledPath, 'nativeStateRead', env, cwd));
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
const projectSettingsPath = path.join(resolveRepoRootSync(cwd), '.claude', 'settings.json');
|
|
754
|
+
const projectSettings = await inventoryRead({
|
|
755
|
+
operation: () => readJsonFileIfExists(projectSettingsPath), absent: null, errors,
|
|
756
|
+
location: projectSettingsPath, kind: 'nativeStateRead', env, cwd,
|
|
757
|
+
});
|
|
758
|
+
if (!claudeAwIsNamespaced) {
|
|
759
|
+
for (const consumer of claudeConsumersFromSettings(projectSettings, 'aw', 'project')) {
|
|
760
|
+
output.push({ kind: 'legacyMarketplace', location: projectSettingsPath, ...consumer });
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
return output;
|
|
764
|
+
}
|
|
765
|
+
function collectMarketplaceDeclarationPaths(value) {
|
|
766
|
+
if (!isRecord(value))
|
|
767
|
+
return [];
|
|
768
|
+
const output = [];
|
|
769
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
770
|
+
if ((key === 'path' || key === 'installLocation') && typeof entry === 'string') {
|
|
771
|
+
output.push(entry);
|
|
772
|
+
}
|
|
773
|
+
else if (key === 'source' && typeof entry === 'string' && path.isAbsolute(entry)) {
|
|
774
|
+
output.push(entry);
|
|
775
|
+
}
|
|
776
|
+
else if (isRecord(entry)) {
|
|
777
|
+
output.push(...collectMarketplaceDeclarationPaths(entry));
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
return output;
|
|
781
|
+
}
|
|
782
|
+
function marketplaceNamesRegisteredAtRoot(value, marketplaceRoot) {
|
|
783
|
+
if (!isRecord(value))
|
|
784
|
+
return [];
|
|
785
|
+
return Object.entries(value).flatMap(([name, declaration]) => collectMarketplaceDeclarationPaths(declaration).some((candidate) => path.normalize(candidate) === path.normalize(marketplaceRoot))
|
|
786
|
+
? [name]
|
|
787
|
+
: []);
|
|
788
|
+
}
|
|
789
|
+
function sourceIdFromCanonicalMarketplacePath(candidate, marketplacesRoot) {
|
|
790
|
+
if (!path.isAbsolute(candidate))
|
|
791
|
+
return null;
|
|
792
|
+
const resolved = path.resolve(candidate);
|
|
793
|
+
const root = path.resolve(marketplacesRoot);
|
|
794
|
+
if (path.dirname(resolved) !== root)
|
|
795
|
+
return null;
|
|
796
|
+
const sourceId = path.basename(resolved);
|
|
797
|
+
return sourceId !== '' && sourceId !== '.' && sourceId !== '..' ? sourceId : null;
|
|
798
|
+
}
|
|
799
|
+
function registeredMarketplaceRoots(value, marketplacesRoot) {
|
|
800
|
+
if (!isRecord(value))
|
|
801
|
+
return [];
|
|
802
|
+
return Object.entries(value).flatMap(([marketplaceName, declaration]) => collectMarketplaceDeclarationPaths(declaration).flatMap((candidate) => {
|
|
803
|
+
const sourceId = sourceIdFromCanonicalMarketplacePath(candidate, marketplacesRoot);
|
|
804
|
+
return sourceId ? [{ marketplaceName, sourceId }] : [];
|
|
805
|
+
}));
|
|
806
|
+
}
|
|
807
|
+
export async function inventoryCatalogSourceReferences(options) {
|
|
808
|
+
const env = options.env ?? process.env;
|
|
809
|
+
const awHome = resolveAwHome(env);
|
|
810
|
+
const references = [];
|
|
811
|
+
const errors = [];
|
|
812
|
+
const canonicalProjectRoot = await inventoryRead({
|
|
813
|
+
operation: () => fs.realpath(resolveRepoRootSync(options.cwd)),
|
|
814
|
+
absent: path.resolve(resolveRepoRootSync(options.cwd)),
|
|
815
|
+
errors,
|
|
816
|
+
location: resolveRepoRootSync(options.cwd),
|
|
817
|
+
kind: 'projectRootRead',
|
|
818
|
+
env,
|
|
819
|
+
cwd: options.cwd,
|
|
820
|
+
});
|
|
821
|
+
const legacyConfig = await inventoryLegacyConfigReferences(options);
|
|
822
|
+
references.push(...legacyConfig.references);
|
|
823
|
+
errors.push(...legacyConfig.errors);
|
|
824
|
+
for (const scope of ['user', 'project']) {
|
|
825
|
+
const location = resolvePluginIntentStatePath({ scope, cwd: options.cwd, env });
|
|
826
|
+
const state = await inventoryRead({
|
|
827
|
+
operation: () => readPluginIntentState({ scope, cwd: options.cwd, env }),
|
|
828
|
+
absent: null,
|
|
829
|
+
errors,
|
|
830
|
+
location,
|
|
831
|
+
kind: 'lifecycleIntentRead',
|
|
832
|
+
env,
|
|
833
|
+
cwd: options.cwd,
|
|
834
|
+
});
|
|
835
|
+
if (!state)
|
|
836
|
+
continue;
|
|
837
|
+
for (const pluginId of new Set([
|
|
838
|
+
...state.roots.map((root) => root.pluginId),
|
|
839
|
+
...state.dependencyScopeOverrides.map((override) => override.pluginId),
|
|
840
|
+
])) {
|
|
841
|
+
const separator = pluginId.indexOf('/');
|
|
842
|
+
if (separator <= 0 || separator === pluginId.length - 1)
|
|
843
|
+
continue;
|
|
844
|
+
references.push({
|
|
845
|
+
kind: 'namespacedLifecycle',
|
|
846
|
+
location,
|
|
847
|
+
sourceId: pluginId.slice(0, separator),
|
|
848
|
+
pluginName: pluginId.slice(separator + 1),
|
|
849
|
+
scope,
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
for (const configInventory of await inventoryPluginConfigRoots({ errors, env, cwd: options.cwd })) {
|
|
854
|
+
const configRoot = configInventory.root;
|
|
855
|
+
const sourceEntries = await inventoryRead({
|
|
856
|
+
operation: () => fs.readdir(configRoot, { withFileTypes: true }),
|
|
857
|
+
absent: [], errors, location: configRoot, kind: 'configDirectoryRead', env, cwd: options.cwd,
|
|
858
|
+
});
|
|
859
|
+
for (const sourceEntry of sourceEntries) {
|
|
860
|
+
const sourceConfigRoot = path.join(configRoot, sourceEntry.name);
|
|
861
|
+
const pluginEntries = await inventoryCanonicalDirectoryEntries({
|
|
862
|
+
errors, location: sourceConfigRoot, kind: 'configNamespaceValidation', env, cwd: options.cwd,
|
|
863
|
+
});
|
|
864
|
+
for (const pluginEntry of pluginEntries) {
|
|
865
|
+
if (pluginEntry.name === 'config.json')
|
|
866
|
+
continue;
|
|
867
|
+
const pluginConfigRoot = path.join(sourceConfigRoot, pluginEntry.name);
|
|
868
|
+
if (!await inventoryCanonicalDirectory({
|
|
869
|
+
errors,
|
|
870
|
+
location: pluginConfigRoot,
|
|
871
|
+
kind: 'configPluginRootValidation',
|
|
872
|
+
env,
|
|
873
|
+
cwd: options.cwd,
|
|
874
|
+
}))
|
|
875
|
+
continue;
|
|
876
|
+
const configPath = path.join(configRoot, sourceEntry.name, pluginEntry.name, 'config.json');
|
|
877
|
+
const configStats = await inventoryRead({
|
|
878
|
+
operation: () => fs.lstat(configPath), absent: null, errors,
|
|
879
|
+
location: configPath, kind: 'configFileRead', env, cwd: options.cwd,
|
|
880
|
+
});
|
|
881
|
+
if (configStats === null)
|
|
882
|
+
continue;
|
|
883
|
+
if (!configStats.isFile() || configStats.isSymbolicLink()) {
|
|
884
|
+
errors.push(inventoryError(new Error('Config inventory target must be a regular file.'), configPath, 'configFileValidation', env, options.cwd));
|
|
885
|
+
continue;
|
|
886
|
+
}
|
|
887
|
+
const value = await inventoryRead({
|
|
888
|
+
operation: () => fs.readJson(configPath), absent: null, errors,
|
|
889
|
+
location: configPath, kind: 'configFileRead', env, cwd: options.cwd,
|
|
890
|
+
});
|
|
891
|
+
if (value === null)
|
|
892
|
+
continue;
|
|
893
|
+
try {
|
|
894
|
+
assertNamespacedConfigEnvelope(value, sourceEntry.name, pluginEntry.name);
|
|
895
|
+
}
|
|
896
|
+
catch (error) {
|
|
897
|
+
errors.push(inventoryError(error, configPath, 'configFileValidation', env, options.cwd));
|
|
898
|
+
continue;
|
|
899
|
+
}
|
|
900
|
+
references.push({
|
|
901
|
+
kind: 'namespacedConfig',
|
|
902
|
+
location: configPath,
|
|
903
|
+
sourceId: sourceEntry.name,
|
|
904
|
+
pluginName: pluginEntry.name,
|
|
905
|
+
scope: configInventory.scope,
|
|
906
|
+
...(configInventory.projectKey ? { projectKey: configInventory.projectKey } : {}),
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
const ownerInventory = await inventoryLegacyOwnerReferences(options);
|
|
912
|
+
references.push(...ownerInventory.references);
|
|
913
|
+
errors.push(...ownerInventory.errors);
|
|
914
|
+
for (const [location, kind, operation] of [
|
|
915
|
+
[path.join(getCodexHome(env), 'config.toml'), 'nativeStateRead', () => codexSharedOwnerReferences(path.join(getCodexHome(env), 'config.toml'), 'user', errors, env, options.cwd)],
|
|
916
|
+
[path.join(getClaudeHome(env), 'settings.json'), 'nativeStateRead', () => claudeSharedOwnerReferences(path.join(getClaudeHome(env), 'settings.json'), 'user', errors, env, options.cwd)],
|
|
917
|
+
[path.join(resolveRepoRootSync(options.cwd), '.codex', 'config.toml'), 'nativeStateRead', () => codexSharedOwnerReferences(path.join(resolveRepoRootSync(options.cwd), '.codex', 'config.toml'), 'project', errors, env, options.cwd)],
|
|
918
|
+
[path.join(resolveRepoRootSync(options.cwd), '.claude', 'settings.json'), 'nativeStateRead', () => claudeSharedOwnerReferences(path.join(resolveRepoRootSync(options.cwd), '.claude', 'settings.json'), 'project', errors, env, options.cwd)],
|
|
919
|
+
]) {
|
|
920
|
+
references.push(...await inventoryRead({
|
|
921
|
+
operation, absent: [], errors, location, kind, env, cwd: options.cwd,
|
|
922
|
+
}));
|
|
923
|
+
}
|
|
924
|
+
references.push(...await oldMarketplaceReferences(env, options.cwd, errors, options.includePlatformHistoricalProjects === true));
|
|
925
|
+
const marketplacesRoot = path.join(awHome, 'marketplaces');
|
|
926
|
+
const codexConfigPath = path.join(getCodexHome(env), 'config.toml');
|
|
927
|
+
const codexConfig = await inventoryRead({
|
|
928
|
+
operation: () => readCodexConfigFile(codexConfigPath), absent: null, errors,
|
|
929
|
+
location: codexConfigPath, kind: 'nativeStateRead', env, cwd: options.cwd,
|
|
930
|
+
});
|
|
931
|
+
const projectCodexConfigPath = path.join(resolveRepoRootSync(options.cwd), '.codex', 'config.toml');
|
|
932
|
+
const projectCodexConfig = await inventoryRead({
|
|
933
|
+
operation: () => readCodexConfigFile(projectCodexConfigPath), absent: null, errors,
|
|
934
|
+
location: projectCodexConfigPath, kind: 'nativeStateRead', env, cwd: options.cwd,
|
|
935
|
+
});
|
|
936
|
+
const userClaudeSettingsPath = path.join(getClaudeHome(env), 'settings.json');
|
|
937
|
+
const userClaudeSettings = await inventoryRead({
|
|
938
|
+
operation: () => readJsonFileIfExists(userClaudeSettingsPath), absent: null, errors,
|
|
939
|
+
location: userClaudeSettingsPath, kind: 'nativeStateRead', env, cwd: options.cwd,
|
|
940
|
+
});
|
|
941
|
+
const projectClaudeSettingsPath = path.join(resolveRepoRootSync(options.cwd), '.claude', 'settings.json');
|
|
942
|
+
const projectClaudeSettings = await inventoryRead({
|
|
943
|
+
operation: () => readJsonFileIfExists(projectClaudeSettingsPath), absent: null, errors,
|
|
944
|
+
location: projectClaudeSettingsPath, kind: 'nativeStateRead', env, cwd: options.cwd,
|
|
945
|
+
});
|
|
946
|
+
const claudeKnownPath = path.join(getClaudeHome(env), 'plugins', 'known_marketplaces.json');
|
|
947
|
+
const claudeKnown = await inventoryRead({
|
|
948
|
+
operation: () => readJsonFileIfExists(claudeKnownPath), absent: null, errors,
|
|
949
|
+
location: claudeKnownPath, kind: 'nativeStateRead', env, cwd: options.cwd,
|
|
950
|
+
});
|
|
951
|
+
const claudeInstalledPath = path.join(getClaudeHome(env), 'plugins', 'installed_plugins.json');
|
|
952
|
+
const claudeInstalled = await inventoryRead({
|
|
953
|
+
operation: () => readJsonFileIfExists(claudeInstalledPath), absent: null, errors,
|
|
954
|
+
location: claudeInstalledPath, kind: 'nativeStateRead', env, cwd: options.cwd,
|
|
955
|
+
});
|
|
956
|
+
const marketplaceEntries = await inventoryCanonicalDirectoryEntries({
|
|
957
|
+
errors, location: marketplacesRoot, kind: 'marketplaceDirectoryRead', env, cwd: options.cwd,
|
|
958
|
+
});
|
|
959
|
+
for (const pluginId of Object.keys(codexConfig?.snapshot.plugins ?? {})) {
|
|
960
|
+
const separator = pluginId.lastIndexOf('@');
|
|
961
|
+
if (separator <= 0 || separator === pluginId.length - 1)
|
|
962
|
+
continue;
|
|
963
|
+
references.push({
|
|
964
|
+
kind: 'namespacedMarketplace',
|
|
965
|
+
location: codexConfigPath,
|
|
966
|
+
pluginName: pluginId.slice(0, separator),
|
|
967
|
+
marketplaceName: pluginId.slice(separator + 1),
|
|
968
|
+
platform: 'codex',
|
|
969
|
+
scope: 'user',
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
for (const pluginId of Object.keys(projectCodexConfig?.snapshot.plugins ?? {})) {
|
|
973
|
+
const separator = pluginId.lastIndexOf('@');
|
|
974
|
+
if (separator <= 0 || separator === pluginId.length - 1)
|
|
975
|
+
continue;
|
|
976
|
+
references.push({
|
|
977
|
+
kind: 'namespacedMarketplace',
|
|
978
|
+
location: projectCodexConfigPath,
|
|
979
|
+
pluginName: pluginId.slice(0, separator),
|
|
980
|
+
marketplaceName: pluginId.slice(separator + 1),
|
|
981
|
+
platform: 'codex',
|
|
982
|
+
scope: 'project',
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
for (const [location, registrations] of [
|
|
986
|
+
[codexConfigPath, Object.entries(codexConfig?.snapshot.marketplaces ?? {}).flatMap(([marketplaceName, marketplace]) => {
|
|
987
|
+
const sourceId = marketplace.sourceType === 'local' && !marketplace.sourcePointsToManifest
|
|
988
|
+
&& marketplace.source
|
|
989
|
+
? sourceIdFromCanonicalMarketplacePath(marketplace.source, marketplacesRoot)
|
|
990
|
+
: null;
|
|
991
|
+
return sourceId ? [{ marketplaceName, sourceId }] : [];
|
|
992
|
+
})],
|
|
993
|
+
[userClaudeSettingsPath, registeredMarketplaceRoots(userClaudeSettings?.extraKnownMarketplaces, marketplacesRoot)],
|
|
994
|
+
[projectClaudeSettingsPath, registeredMarketplaceRoots(projectClaudeSettings?.extraKnownMarketplaces, marketplacesRoot)],
|
|
995
|
+
[claudeKnownPath, [
|
|
996
|
+
...registeredMarketplaceRoots(claudeKnown, marketplacesRoot),
|
|
997
|
+
...registeredMarketplaceRoots(claudeKnown?.marketplaces, marketplacesRoot),
|
|
998
|
+
]],
|
|
999
|
+
]) {
|
|
1000
|
+
for (const registration of registrations)
|
|
1001
|
+
references.push({
|
|
1002
|
+
kind: 'namespacedMarketplace',
|
|
1003
|
+
location,
|
|
1004
|
+
sourceId: registration.sourceId,
|
|
1005
|
+
marketplaceName: registration.marketplaceName,
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
for (const sourceEntry of marketplaceEntries) {
|
|
1009
|
+
const marketplaceRoot = path.join(marketplacesRoot, sourceEntry.name);
|
|
1010
|
+
const configPath = path.join(marketplaceRoot, 'config.json');
|
|
1011
|
+
const agentsManifestPath = path.join(marketplaceRoot, '.agents', 'plugins', 'marketplace.json');
|
|
1012
|
+
const canonicalRoot = await inventoryCanonicalDirectory({
|
|
1013
|
+
errors,
|
|
1014
|
+
location: marketplaceRoot,
|
|
1015
|
+
kind: 'marketplaceRootValidation',
|
|
1016
|
+
env,
|
|
1017
|
+
cwd: options.cwd,
|
|
1018
|
+
});
|
|
1019
|
+
const strictRoot = canonicalRoot
|
|
1020
|
+
? await inventoryRead({
|
|
1021
|
+
operation: () => readStrictNamespacedMarketplaceRoot({
|
|
1022
|
+
rootDir: marketplaceRoot,
|
|
1023
|
+
sourceId: sourceEntry.name,
|
|
1024
|
+
}),
|
|
1025
|
+
absent: null,
|
|
1026
|
+
reportAbsent: true,
|
|
1027
|
+
errors,
|
|
1028
|
+
location: marketplaceRoot,
|
|
1029
|
+
kind: 'marketplaceRootValidation',
|
|
1030
|
+
env,
|
|
1031
|
+
cwd: options.cwd,
|
|
1032
|
+
})
|
|
1033
|
+
: null;
|
|
1034
|
+
const [rawConfig, rawAgentsManifest, rawClaudeManifest] = strictRoot
|
|
1035
|
+
? [strictRoot.config, strictRoot.agentsManifest, strictRoot.claudeManifest]
|
|
1036
|
+
: canonicalRoot ? await Promise.all([
|
|
1037
|
+
fs.readJson(configPath).catch(() => null),
|
|
1038
|
+
fs.readJson(agentsManifestPath).catch(() => null),
|
|
1039
|
+
fs.readJson(path.join(marketplaceRoot, '.claude-plugin', 'marketplace.json'))
|
|
1040
|
+
.catch(() => null),
|
|
1041
|
+
]) : [null, null, null];
|
|
1042
|
+
const candidateMarketplaceNames = new Set();
|
|
1043
|
+
for (const candidate of [
|
|
1044
|
+
rawConfig?.marketplaceName,
|
|
1045
|
+
rawAgentsManifest?.name,
|
|
1046
|
+
rawClaudeManifest?.name,
|
|
1047
|
+
]) {
|
|
1048
|
+
if (typeof candidate === 'string' && candidate.length > 0) {
|
|
1049
|
+
candidateMarketplaceNames.add(candidate);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
for (const [name, marketplace] of Object.entries(codexConfig?.snapshot.marketplaces ?? {})) {
|
|
1053
|
+
if (marketplace.sourceType === 'local'
|
|
1054
|
+
&& !marketplace.sourcePointsToManifest
|
|
1055
|
+
&& path.normalize(marketplace.source ?? '') === path.normalize(marketplaceRoot)) {
|
|
1056
|
+
candidateMarketplaceNames.add(name);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
for (const name of [
|
|
1060
|
+
...marketplaceNamesRegisteredAtRoot(userClaudeSettings?.extraKnownMarketplaces, marketplaceRoot),
|
|
1061
|
+
...marketplaceNamesRegisteredAtRoot(projectClaudeSettings?.extraKnownMarketplaces, marketplaceRoot),
|
|
1062
|
+
...marketplaceNamesRegisteredAtRoot(claudeKnown, marketplaceRoot),
|
|
1063
|
+
...marketplaceNamesRegisteredAtRoot(claudeKnown?.marketplaces, marketplaceRoot),
|
|
1064
|
+
])
|
|
1065
|
+
candidateMarketplaceNames.add(name);
|
|
1066
|
+
const marketplaceName = strictRoot?.config.marketplaceName
|
|
1067
|
+
?? (candidateMarketplaceNames.size === 1 ? [...candidateMarketplaceNames][0] : null);
|
|
1068
|
+
const sourceIdentity = typeof rawConfig?.sourceIdentity === 'string'
|
|
1069
|
+
&& /^sha256:[0-9a-f]{64}$/.test(rawConfig.sourceIdentity)
|
|
1070
|
+
? rawConfig.sourceIdentity
|
|
1071
|
+
: undefined;
|
|
1072
|
+
const codexMarketplace = marketplaceName
|
|
1073
|
+
? codexConfig?.snapshot.marketplaces[marketplaceName]
|
|
1074
|
+
: undefined;
|
|
1075
|
+
const codexMarketplaceIsCanonical = codexMarketplace?.sourceType === 'local'
|
|
1076
|
+
&& !codexMarketplace.sourcePointsToManifest
|
|
1077
|
+
&& path.normalize(codexMarketplace.source ?? '') === path.normalize(marketplaceRoot);
|
|
1078
|
+
const consumers = [];
|
|
1079
|
+
if (marketplaceName !== null && (strictRoot !== null || codexMarketplaceIsCanonical)) {
|
|
1080
|
+
for (const pluginId of Object.keys(codexConfig?.snapshot.plugins ?? {})) {
|
|
1081
|
+
const pluginName = pluginNameFromMarketplaceId(pluginId, marketplaceName);
|
|
1082
|
+
if (pluginName)
|
|
1083
|
+
consumers.push({ pluginName, platform: 'codex', scope: 'user' });
|
|
1084
|
+
}
|
|
1085
|
+
for (const pluginId of Object.keys(projectCodexConfig?.snapshot.plugins ?? {})) {
|
|
1086
|
+
const pluginName = pluginNameFromMarketplaceId(pluginId, marketplaceName);
|
|
1087
|
+
if (pluginName)
|
|
1088
|
+
consumers.push({ pluginName, platform: 'codex', scope: 'project' });
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
if (marketplaceName !== null) {
|
|
1092
|
+
consumers.push(...claudeConsumersFromSettings(userClaudeSettings, marketplaceName, 'user'), ...claudeConsumersFromSettings(projectClaudeSettings, marketplaceName, 'project'));
|
|
1093
|
+
try {
|
|
1094
|
+
consumers.push(...claudeConsumersFromInstalled(claudeInstalled, marketplaceName, path.normalize(canonicalProjectRoot), options.includePlatformHistoricalProjects === true));
|
|
1095
|
+
}
|
|
1096
|
+
catch (error) {
|
|
1097
|
+
errors.push(inventoryError(error, claudeInstalledPath, 'nativeStateRead', env, options.cwd));
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
if (marketplaceName !== null && strictRoot !== null) {
|
|
1101
|
+
references.push({
|
|
1102
|
+
kind: 'namespacedMarketplace',
|
|
1103
|
+
location: configPath,
|
|
1104
|
+
sourceId: sourceEntry.name,
|
|
1105
|
+
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
1106
|
+
marketplaceName,
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
if (marketplaceName !== null) {
|
|
1110
|
+
for (const consumer of consumers)
|
|
1111
|
+
references.push({
|
|
1112
|
+
kind: 'namespacedMarketplace',
|
|
1113
|
+
location: configPath,
|
|
1114
|
+
sourceId: sourceEntry.name,
|
|
1115
|
+
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
1116
|
+
marketplaceName,
|
|
1117
|
+
...consumer,
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
for (const reference of references) {
|
|
1122
|
+
if (reference.scope === 'project' && reference.projectKey === undefined) {
|
|
1123
|
+
reference.projectKey = canonicalProjectRoot;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
const unique = [...new Map(references.map((reference) => [[
|
|
1127
|
+
reference.kind,
|
|
1128
|
+
reference.location,
|
|
1129
|
+
reference.sourceId ?? '',
|
|
1130
|
+
reference.sourceIdentity ?? '',
|
|
1131
|
+
reference.pluginName ?? '',
|
|
1132
|
+
reference.platform ?? '',
|
|
1133
|
+
reference.scope ?? '',
|
|
1134
|
+
reference.marketplaceName ?? '',
|
|
1135
|
+
reference.projectKey ?? '',
|
|
1136
|
+
].join('\0'), reference])).values()];
|
|
1137
|
+
unique.sort((left, right) => left.location.localeCompare(right.location));
|
|
1138
|
+
return { inventorySchemaVersion: 1, references: unique, errors };
|
|
1139
|
+
}
|
|
1140
|
+
export class LegacyCatalogStateUnsupportedError extends Error {
|
|
1141
|
+
code = 'legacyStateUnsupported';
|
|
1142
|
+
inventory;
|
|
1143
|
+
constructor(inventory) {
|
|
1144
|
+
super('legacyStateUnsupported: legacy owner or config state is unsupported. Use a new AW_HOME, or cleanup with the old CLI first.');
|
|
1145
|
+
this.name = 'LegacyCatalogStateUnsupportedError';
|
|
1146
|
+
this.inventory = inventory;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
export class CatalogSourceReferencedError extends Error {
|
|
1150
|
+
code = 'catalogSourceInUse';
|
|
1151
|
+
inventory;
|
|
1152
|
+
constructor(inventory) {
|
|
1153
|
+
super(`catalogSourceInUse: catalog source has active references: ${inventory.references.map((reference) => reference.location).join(', ')}`);
|
|
1154
|
+
this.name = 'CatalogSourceReferencedError';
|
|
1155
|
+
this.inventory = inventory;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
export class CatalogSourceInventoryIncompleteError extends Error {
|
|
1159
|
+
code = 'stateInventoryFailed';
|
|
1160
|
+
inventory;
|
|
1161
|
+
constructor(inventory) {
|
|
1162
|
+
super(`stateInventoryFailed: catalog source state inventory is incomplete: ${(inventory.errors ?? []).map((error) => `${error.kind}@${error.location}: ${error.message}`).join('; ')}`);
|
|
1163
|
+
this.name = 'CatalogSourceInventoryIncompleteError';
|
|
1164
|
+
this.inventory = inventory;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
export function assertCatalogSourceInventoryComplete(inventory) {
|
|
1168
|
+
if ((inventory.errors ?? []).length > 0)
|
|
1169
|
+
throw new CatalogSourceInventoryIncompleteError(inventory);
|
|
1170
|
+
}
|
|
1171
|
+
export function assertCatalogSourceReferencesSupported(inventory) {
|
|
1172
|
+
assertCatalogSourceInventoryComplete(inventory);
|
|
1173
|
+
if (inventory.references.length > 0) {
|
|
1174
|
+
if (inventory.references.some((reference) => reference.kind.startsWith('legacy'))) {
|
|
1175
|
+
throw new LegacyCatalogStateUnsupportedError(inventory);
|
|
1176
|
+
}
|
|
1177
|
+
throw new CatalogSourceReferencedError(inventory);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
//# sourceMappingURL=catalog-source-references.js.map
|