@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,804 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import { GENERATED_OUTPUT_MARKER_FILENAME, validatePublishedCatalogSnapshot, } from '@lesliechan721/aw-plugin-core';
|
|
6
|
+
import { disposeCatalogPublicationInspection, inspectCatalogPublicationApplyContext, inspectCatalogPublicationLiveContext, parseRemoteRefs, prepareCatalogPublicationInspection, publicationGit, publicationGitExit, readCatalogPublicationBranchState, } from './catalog-publication-inspection.js';
|
|
7
|
+
import { catalogPublicationDirectoryPath, catalogPublicationJournalPath, catalogPublicationPlanDigest, catalogPublicationRepositoryName, catalogPublicationRepositoryPath, findCatalogPublicationJournalByPlanDigest, readCatalogPublicationJournal, writeCatalogPublicationJournalAtomic, } from './catalog-publication-journal.js';
|
|
8
|
+
import { resolveCatalogPublicationTarget, } from './catalog-publication-target.js';
|
|
9
|
+
import { resolveCatalogWorkspaceRoot, } from './catalog-workspace-resolution.js';
|
|
10
|
+
export { catalogPublicationPlanDigest, parseCatalogPublicationJournal, } from './catalog-publication-journal.js';
|
|
11
|
+
export { safeRemoteIdentity, sanitizedGitEnvironment } from './catalog-publication-inspection.js';
|
|
12
|
+
export const CATALOG_PUBLICATION_CLEANUP_WARNING = 'Catalog publication succeeded, but local repository cleanup did not complete. Retry apply with the same plan digest.';
|
|
13
|
+
async function assertPublicationStatePathSafe(workspaceRoot) {
|
|
14
|
+
for (const candidate of [
|
|
15
|
+
path.join(workspaceRoot, '.aw'),
|
|
16
|
+
path.join(workspaceRoot, '.aw', 'publish'),
|
|
17
|
+
]) {
|
|
18
|
+
if (!(await fs.pathExists(candidate)))
|
|
19
|
+
continue;
|
|
20
|
+
const stats = await fs.lstat(candidate);
|
|
21
|
+
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
22
|
+
throw new Error('Catalog publication state path must contain only regular local directories.');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function assertPublicationDirectorySafe(directoryPath, catalogVersion) {
|
|
27
|
+
let stats;
|
|
28
|
+
try {
|
|
29
|
+
stats = await fs.lstat(directoryPath);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (error.code === 'ENOENT')
|
|
33
|
+
return false;
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
37
|
+
throw new Error(`Catalog ${catalogVersion} publication state directory is damaged. Increase the Catalog version.`);
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
function sameDescriptor(left, right) {
|
|
42
|
+
const comparisonCommit = '0'.repeat(40);
|
|
43
|
+
return catalogPublicationPlanDigest(left, comparisonCommit)
|
|
44
|
+
=== catalogPublicationPlanDigest(right, comparisonCommit);
|
|
45
|
+
}
|
|
46
|
+
async function clearWorktree(repositoryRoot) {
|
|
47
|
+
for (const name of await fs.readdir(repositoryRoot)) {
|
|
48
|
+
if (name !== '.git')
|
|
49
|
+
await fs.remove(path.join(repositoryRoot, name));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function assertNoGitAttributes(root, relative = '') {
|
|
53
|
+
for (const entry of await fs.readdir(path.join(root, relative), { withFileTypes: true })) {
|
|
54
|
+
const child = relative ? path.posix.join(relative, entry.name) : entry.name;
|
|
55
|
+
if (entry.name === '.gitattributes') {
|
|
56
|
+
throw new Error(`Catalog publication snapshot must not contain .gitattributes (${child}).`);
|
|
57
|
+
}
|
|
58
|
+
if (entry.isDirectory())
|
|
59
|
+
await assertNoGitAttributes(root, child);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function assertSnapshotBinding(snapshotRoot, descriptor, display) {
|
|
63
|
+
const markerPath = path.join(snapshotRoot, GENERATED_OUTPUT_MARKER_FILENAME);
|
|
64
|
+
const [stats, markerStats] = await Promise.all([
|
|
65
|
+
fs.lstat(snapshotRoot),
|
|
66
|
+
fs.lstat(markerPath),
|
|
67
|
+
]);
|
|
68
|
+
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
69
|
+
throw new Error('Prepared Catalog snapshot must be a regular local directory.');
|
|
70
|
+
}
|
|
71
|
+
if (!markerStats.isFile() || markerStats.isSymbolicLink()) {
|
|
72
|
+
throw new Error('Prepared Catalog snapshot marker must be a regular local file.');
|
|
73
|
+
}
|
|
74
|
+
const [marker, validation] = await Promise.all([
|
|
75
|
+
fs.readJson(markerPath),
|
|
76
|
+
validatePublishedCatalogSnapshot(snapshotRoot),
|
|
77
|
+
]);
|
|
78
|
+
const release = validation.manifest.release;
|
|
79
|
+
if (marker.workspaceIdentity !== descriptor.workspaceIdentity
|
|
80
|
+
|| validation.manifest.catalogVersion !== display.catalogVersion
|
|
81
|
+
|| validation.manifest.channel !== display.channel
|
|
82
|
+
|| validation.manifest.entries.length !== display.pluginCount
|
|
83
|
+
|| validation.snapshotDigest !== descriptor.snapshotDigest
|
|
84
|
+
|| release.state !== 'published'
|
|
85
|
+
|| release.sourceHead !== descriptor.sourceHead) {
|
|
86
|
+
throw new Error('Prepared Catalog descriptor, snapshot, or plan identity changed.');
|
|
87
|
+
}
|
|
88
|
+
await assertNoGitAttributes(snapshotRoot);
|
|
89
|
+
}
|
|
90
|
+
function displayFromPreparation(preparation) {
|
|
91
|
+
return {
|
|
92
|
+
catalogVersion: preparation.prepared.catalogVersion,
|
|
93
|
+
channel: preparation.prepared.channel,
|
|
94
|
+
pluginCount: preparation.prepared.pluginNames.length,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function assertLiveContextMatchesDescriptor(context, descriptor) {
|
|
98
|
+
if (context.workspaceIdentity !== descriptor.workspaceIdentity
|
|
99
|
+
|| context.sourceHead !== descriptor.sourceHead
|
|
100
|
+
|| context.remoteName !== descriptor.remote.name
|
|
101
|
+
|| context.remoteIdentityDigest !== descriptor.remote.identityDigest
|
|
102
|
+
|| context.branch !== descriptor.branch
|
|
103
|
+
|| context.tag !== descriptor.tag) {
|
|
104
|
+
throw new Error('Catalog publication identity changed. Increase the Catalog version and create a new plan.');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function assertApplyContextMatchesDescriptor(context, descriptor) {
|
|
108
|
+
if (context.workspaceIdentity !== descriptor.workspaceIdentity
|
|
109
|
+
|| context.remoteIdentityDigest !== descriptor.remote.identityDigest
|
|
110
|
+
|| context.branch !== descriptor.branch) {
|
|
111
|
+
throw new Error('Catalog publication identity changed. Increase the Catalog version and create a new plan.');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function createPublicationCommit(preparation, descriptor, snapshotRoot, display) {
|
|
115
|
+
const { repositoryRoot, parent, tag, env } = preparation;
|
|
116
|
+
await assertSnapshotBinding(snapshotRoot, descriptor, display);
|
|
117
|
+
if (parent) {
|
|
118
|
+
await publicationGit(repositoryRoot, [
|
|
119
|
+
'checkout', '--quiet', '--detach', 'refs/aw/catalog-parent',
|
|
120
|
+
], env, 'publicationCommitFailed', 'Could not select the publication parent.');
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
await publicationGit(repositoryRoot, [
|
|
124
|
+
'checkout', '--quiet', '--orphan', 'catalog-publication',
|
|
125
|
+
], env, 'publicationCommitFailed', 'Could not create the initial Catalog publication.');
|
|
126
|
+
}
|
|
127
|
+
await clearWorktree(repositoryRoot);
|
|
128
|
+
await fs.copy(snapshotRoot, repositoryRoot, { dereference: false });
|
|
129
|
+
await publicationGit(repositoryRoot, [
|
|
130
|
+
'add', '--force', '--all',
|
|
131
|
+
], env, 'publicationCommitFailed', 'Could not stage the Catalog publication tree.');
|
|
132
|
+
await publicationGit(repositoryRoot, [
|
|
133
|
+
'-c', 'user.name=AW Catalog Publisher',
|
|
134
|
+
'-c', 'user.email=catalog-publisher@agent-workflows.invalid',
|
|
135
|
+
'commit', '--quiet', '-m', `Catalog ${display.catalogVersion}`,
|
|
136
|
+
], env, 'publicationCommitFailed', 'Could not create the Catalog publication commit.');
|
|
137
|
+
const commit = await publicationGit(repositoryRoot, [
|
|
138
|
+
'rev-parse', 'HEAD',
|
|
139
|
+
], env, 'publicationCommitFailed', 'Could not resolve the Catalog publication commit.');
|
|
140
|
+
const parents = (await publicationGit(repositoryRoot, [
|
|
141
|
+
'show', '-s', '--format=%P', commit,
|
|
142
|
+
], env, 'publicationCommitFailed', 'Could not verify the Catalog publication parent.'))
|
|
143
|
+
.split(/\s+/u)
|
|
144
|
+
.filter(Boolean);
|
|
145
|
+
if ((parent && (parents.length !== 1 || parents[0] !== parent)) || (!parent && parents.length !== 0)) {
|
|
146
|
+
throw new Error('Catalog publication commit has an invalid parent.');
|
|
147
|
+
}
|
|
148
|
+
const verificationRoot = path.join(preparation.temporaryRoot, 'verification');
|
|
149
|
+
await fs.ensureDir(verificationRoot);
|
|
150
|
+
await publicationGit(repositoryRoot, [
|
|
151
|
+
'--work-tree', verificationRoot, 'checkout', '--quiet', commit, '--', '.',
|
|
152
|
+
], env, 'publicationCommitFailed', 'Could not verify the Catalog publication commit tree.');
|
|
153
|
+
await assertSnapshotBinding(verificationRoot, descriptor, display);
|
|
154
|
+
await publicationGit(repositoryRoot, [
|
|
155
|
+
'-c', 'user.name=AW Catalog Publisher',
|
|
156
|
+
'-c', 'user.email=catalog-publisher@agent-workflows.invalid',
|
|
157
|
+
'tag', '--annotate', tag, '--message', `Catalog ${display.catalogVersion}`,
|
|
158
|
+
], env, 'publicationCommitFailed', 'Could not create the annotated Catalog tag.');
|
|
159
|
+
return commit;
|
|
160
|
+
}
|
|
161
|
+
async function remoteRefState(cwd, remote, branchRef, tagRef, env) {
|
|
162
|
+
const refs = parseRemoteRefs(await publicationGit(cwd, [
|
|
163
|
+
'ls-remote', remote, branchRef, tagRef, `${tagRef}^{}`,
|
|
164
|
+
], env, 'remoteReadFailed', 'Could not inspect the Catalog publication remote.'));
|
|
165
|
+
const tagPresent = refs.has(tagRef) || refs.has(`${tagRef}^{}`);
|
|
166
|
+
return {
|
|
167
|
+
branchCommit: refs.get(branchRef) ?? null,
|
|
168
|
+
tagCommit: refs.get(`${tagRef}^{}`) ?? null,
|
|
169
|
+
tagPresent,
|
|
170
|
+
tagAnnotated: refs.has(tagRef) && refs.has(`${tagRef}^{}`),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function assertReconciliableRemoteState(state, journal) {
|
|
174
|
+
const branchAtExpected = state.branchCommit === journal.expectedCommit;
|
|
175
|
+
const branchAtParent = state.branchCommit === journal.descriptor.parent;
|
|
176
|
+
const tagAtExpected = state.tagAnnotated && state.tagCommit === journal.expectedCommit;
|
|
177
|
+
const tagAbsent = !state.tagPresent;
|
|
178
|
+
if ((branchAtExpected && tagAtExpected)
|
|
179
|
+
|| (branchAtParent && tagAbsent)
|
|
180
|
+
|| (branchAtExpected && tagAbsent)
|
|
181
|
+
|| (branchAtParent && tagAtExpected))
|
|
182
|
+
return;
|
|
183
|
+
throw new Error(`Catalog ${journal.display.catalogVersion} remote refs conflict with the prepared plan. Increase the Catalog version.`);
|
|
184
|
+
}
|
|
185
|
+
const PERSISTED_REPOSITORY_CONFIG = new Map([
|
|
186
|
+
['core.repositoryformatversion', new Set(['0'])],
|
|
187
|
+
['core.filemode', new Set(['true', 'false'])],
|
|
188
|
+
['core.bare', new Set(['false'])],
|
|
189
|
+
['core.logallrefupdates', new Set(['true'])],
|
|
190
|
+
['core.ignorecase', new Set(['true'])],
|
|
191
|
+
['core.precomposeunicode', new Set(['true'])],
|
|
192
|
+
['core.hookspath', new Set([os.devNull])],
|
|
193
|
+
['core.symlinks', new Set(['true'])],
|
|
194
|
+
]);
|
|
195
|
+
const REQUIRED_PERSISTED_REPOSITORY_CONFIG = [
|
|
196
|
+
'core.repositoryformatversion',
|
|
197
|
+
'core.filemode',
|
|
198
|
+
'core.bare',
|
|
199
|
+
'core.logallrefupdates',
|
|
200
|
+
'core.hookspath',
|
|
201
|
+
'core.symlinks',
|
|
202
|
+
];
|
|
203
|
+
async function assertRegularGitDirectory(root) {
|
|
204
|
+
const stats = await fs.lstat(root);
|
|
205
|
+
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
206
|
+
throw new Error('Pending Catalog publication Git directory is unsafe.');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async function assertRegularGitFile(filePath) {
|
|
210
|
+
const stats = await fs.lstat(filePath);
|
|
211
|
+
if (!stats.isFile() || stats.isSymbolicLink()) {
|
|
212
|
+
throw new Error('Pending Catalog publication Git control file is unsafe.');
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async function assertGitTreeContainsOnlyLocalFiles(root) {
|
|
216
|
+
for (const entry of await fs.readdir(root, { withFileTypes: true })) {
|
|
217
|
+
const child = path.join(root, entry.name);
|
|
218
|
+
const stats = await fs.lstat(child);
|
|
219
|
+
if (stats.isSymbolicLink()) {
|
|
220
|
+
throw new Error('Pending Catalog publication Git data must not contain symbolic links.');
|
|
221
|
+
}
|
|
222
|
+
if (stats.isDirectory()) {
|
|
223
|
+
await assertGitTreeContainsOnlyLocalFiles(child);
|
|
224
|
+
}
|
|
225
|
+
else if (!stats.isFile()) {
|
|
226
|
+
throw new Error('Pending Catalog publication Git data must contain only regular local files.');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
async function assertPathMissing(filePath) {
|
|
231
|
+
try {
|
|
232
|
+
await fs.lstat(filePath);
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
if (error.code === 'ENOENT')
|
|
236
|
+
return;
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
throw new Error('Pending Catalog publication repository must not use alternate object stores.');
|
|
240
|
+
}
|
|
241
|
+
async function validatePersistentRepositoryControlState(repositoryRoot, env) {
|
|
242
|
+
const gitRoot = path.join(repositoryRoot, '.git');
|
|
243
|
+
const configPath = path.join(gitRoot, 'config');
|
|
244
|
+
await assertRegularGitDirectory(gitRoot);
|
|
245
|
+
await assertRegularGitFile(configPath);
|
|
246
|
+
await assertRegularGitFile(path.join(gitRoot, 'HEAD'));
|
|
247
|
+
await assertRegularGitFile(path.join(gitRoot, 'index'));
|
|
248
|
+
await assertRegularGitDirectory(path.join(gitRoot, 'objects'));
|
|
249
|
+
await assertRegularGitDirectory(path.join(gitRoot, 'refs'));
|
|
250
|
+
await assertPathMissing(path.join(gitRoot, 'objects', 'info', 'alternates'));
|
|
251
|
+
await assertPathMissing(path.join(gitRoot, 'objects', 'info', 'http-alternates'));
|
|
252
|
+
await assertGitTreeContainsOnlyLocalFiles(gitRoot);
|
|
253
|
+
const entries = (await publicationGit(repositoryRoot, [
|
|
254
|
+
'config', '--file', configPath, '--no-includes', '--null', '--list',
|
|
255
|
+
], env, 'pendingRepositoryInvalid', 'Pending Catalog publication config is damaged.'))
|
|
256
|
+
.split('\0')
|
|
257
|
+
.filter(Boolean);
|
|
258
|
+
const seen = new Set();
|
|
259
|
+
for (const entry of entries) {
|
|
260
|
+
const separator = entry.indexOf('\n');
|
|
261
|
+
if (separator <= 0)
|
|
262
|
+
throw new Error('Pending Catalog publication config is damaged.');
|
|
263
|
+
const key = entry.slice(0, separator).toLowerCase();
|
|
264
|
+
const value = entry.slice(separator + 1);
|
|
265
|
+
if (seen.has(key) || !PERSISTED_REPOSITORY_CONFIG.get(key)?.has(value)) {
|
|
266
|
+
throw new Error('Pending Catalog publication config contains unsafe local settings.');
|
|
267
|
+
}
|
|
268
|
+
seen.add(key);
|
|
269
|
+
}
|
|
270
|
+
if (REQUIRED_PERSISTED_REPOSITORY_CONFIG.some((key) => !seen.has(key))) {
|
|
271
|
+
throw new Error('Pending Catalog publication config is incomplete.');
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
async function validatePersistentRepository(repositoryRoot, journal, env) {
|
|
275
|
+
const version = journal.display.catalogVersion;
|
|
276
|
+
let stats;
|
|
277
|
+
try {
|
|
278
|
+
stats = await fs.lstat(repositoryRoot);
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
throw new Error(`Catalog ${version} pending publication repository is missing or damaged. Increase the Catalog version.`, { cause: error });
|
|
282
|
+
}
|
|
283
|
+
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
284
|
+
throw new Error(`Catalog ${version} pending publication repository is missing or damaged. Increase the Catalog version.`);
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
await validatePersistentRepositoryControlState(repositoryRoot, env);
|
|
288
|
+
const [head, tagCommit, tagType, remotes, parents] = await Promise.all([
|
|
289
|
+
publicationGit(repositoryRoot, ['rev-parse', '--verify', 'HEAD'], env, 'pendingRepositoryInvalid', 'Pending Catalog publication repository is damaged.'),
|
|
290
|
+
publicationGit(repositoryRoot, ['rev-parse', `${journal.descriptor.tag}^{commit}`], env, 'pendingRepositoryInvalid', 'Pending Catalog publication tag is damaged.'),
|
|
291
|
+
publicationGit(repositoryRoot, ['cat-file', '-t', `refs/tags/${journal.descriptor.tag}`], env, 'pendingRepositoryInvalid', 'Pending Catalog publication tag is damaged.'),
|
|
292
|
+
publicationGit(repositoryRoot, ['remote'], env, 'pendingRepositoryInvalid', 'Pending Catalog publication repository is damaged.'),
|
|
293
|
+
publicationGit(repositoryRoot, ['show', '-s', '--format=%P', journal.expectedCommit], env, 'pendingRepositoryInvalid', 'Pending Catalog publication commit is damaged.'),
|
|
294
|
+
]);
|
|
295
|
+
const parentList = parents.split(/\s+/u).filter(Boolean);
|
|
296
|
+
if (head !== journal.expectedCommit
|
|
297
|
+
|| tagCommit !== journal.expectedCommit
|
|
298
|
+
|| tagType !== 'tag'
|
|
299
|
+
|| remotes !== ''
|
|
300
|
+
|| (journal.descriptor.parent === null
|
|
301
|
+
? parentList.length !== 0
|
|
302
|
+
: parentList.length !== 1 || parentList[0] !== journal.descriptor.parent))
|
|
303
|
+
throw new Error('Pending Catalog publication repository identity changed.');
|
|
304
|
+
const verificationRoot = path.join(path.dirname(repositoryRoot), `.${path.basename(repositoryRoot)}.${crypto.randomUUID()}.verify`);
|
|
305
|
+
try {
|
|
306
|
+
await fs.ensureDir(verificationRoot);
|
|
307
|
+
await publicationGit(repositoryRoot, [
|
|
308
|
+
'--work-tree', verificationRoot, 'checkout', '--quiet', journal.expectedCommit, '--', '.',
|
|
309
|
+
], env, 'pendingRepositoryInvalid', 'Pending Catalog publication commit tree is damaged.');
|
|
310
|
+
await assertSnapshotBinding(verificationRoot, journal.descriptor, journal.display);
|
|
311
|
+
}
|
|
312
|
+
finally {
|
|
313
|
+
await fs.remove(verificationRoot);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
throw new Error(`Catalog ${version} pending publication repository is missing or damaged. Increase the Catalog version.`, { cause: error });
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
async function persistPublicationState(preparation, finalStateRoot, journal, hooks) {
|
|
321
|
+
const parent = path.dirname(finalStateRoot);
|
|
322
|
+
await fs.ensureDir(parent);
|
|
323
|
+
const staging = path.join(parent, `.${path.basename(finalStateRoot)}.${crypto.randomUUID()}.tmp`);
|
|
324
|
+
const repositoryPath = path.join(staging, catalogPublicationRepositoryName());
|
|
325
|
+
const journalPath = path.join(staging, 'journal.json');
|
|
326
|
+
try {
|
|
327
|
+
await publicationGit(preparation.repositoryRoot, [
|
|
328
|
+
'remote', 'remove', 'publish',
|
|
329
|
+
], preparation.env, 'temporaryRepositoryFailed', 'Could not seal the publication repository.');
|
|
330
|
+
await fs.ensureDir(staging);
|
|
331
|
+
await fs.copy(preparation.repositoryRoot, repositoryPath, { dereference: false, errorOnExist: true });
|
|
332
|
+
await writeCatalogPublicationJournalAtomic(journalPath, journal);
|
|
333
|
+
const persisted = await readCatalogPublicationJournal(journalPath, journal.display.catalogVersion);
|
|
334
|
+
if (!persisted || persisted.planDigest !== journal.planDigest) {
|
|
335
|
+
throw new Error(`Catalog ${journal.display.catalogVersion} publication state could not be verified.`);
|
|
336
|
+
}
|
|
337
|
+
await validatePersistentRepository(repositoryPath, persisted, preparation.env);
|
|
338
|
+
await hooks.beforeFinalRename?.({
|
|
339
|
+
temporaryStateRoot: staging,
|
|
340
|
+
finalStateRoot,
|
|
341
|
+
});
|
|
342
|
+
try {
|
|
343
|
+
await fs.rename(staging, finalStateRoot);
|
|
344
|
+
return persisted;
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
if (!(await fs.pathExists(finalStateRoot)))
|
|
348
|
+
throw error;
|
|
349
|
+
if (!(await assertPublicationDirectorySafe(finalStateRoot, journal.display.catalogVersion)))
|
|
350
|
+
throw error;
|
|
351
|
+
const existing = await readCatalogPublicationJournal(path.join(finalStateRoot, 'journal.json'), journal.display.catalogVersion);
|
|
352
|
+
if (!existing) {
|
|
353
|
+
throw new Error(`Catalog ${journal.display.catalogVersion} publication state is incomplete. Increase the Catalog version.`);
|
|
354
|
+
}
|
|
355
|
+
if (existing.planDigest !== journal.planDigest) {
|
|
356
|
+
throw new Error(`Catalog ${journal.display.catalogVersion} already has a different publication plan. Increase the Catalog version.`);
|
|
357
|
+
}
|
|
358
|
+
if (existing.state !== 'published') {
|
|
359
|
+
await validatePersistentRepository(path.join(finalStateRoot, catalogPublicationRepositoryName()), existing, preparation.env);
|
|
360
|
+
}
|
|
361
|
+
return existing;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
finally {
|
|
365
|
+
await fs.remove(staging);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function receiptBase(context, journal, resolution) {
|
|
369
|
+
const repositoryPath = journal.repository === null
|
|
370
|
+
? null
|
|
371
|
+
: catalogPublicationRepositoryPath(context.catalogWorkspaceRoot, journal.display.catalogVersion);
|
|
372
|
+
return {
|
|
373
|
+
ok: true,
|
|
374
|
+
workspaceRoot: context.catalogWorkspaceRoot,
|
|
375
|
+
workspaceRootResolvedFrom: resolution.workspaceRootResolvedFrom ?? 'explicit',
|
|
376
|
+
workspaceIdentity: journal.descriptor.workspaceIdentity,
|
|
377
|
+
catalogVersion: journal.display.catalogVersion,
|
|
378
|
+
channel: journal.display.channel,
|
|
379
|
+
remote: context.remote,
|
|
380
|
+
remoteResolvedFrom: resolution.remoteResolvedFrom ?? 'explicit',
|
|
381
|
+
remoteUrl: context.safeFetchUrl,
|
|
382
|
+
fetchUrl: context.safeFetchUrl,
|
|
383
|
+
pushUrl: context.safePushUrl,
|
|
384
|
+
branch: journal.descriptor.branch,
|
|
385
|
+
branchResolvedFrom: resolution.branchResolvedFrom ?? 'explicit',
|
|
386
|
+
parent: journal.descriptor.parent,
|
|
387
|
+
tag: journal.descriptor.tag,
|
|
388
|
+
expectedCommit: journal.expectedCommit,
|
|
389
|
+
sourceHead: journal.descriptor.sourceHead,
|
|
390
|
+
pluginCount: journal.display.pluginCount,
|
|
391
|
+
snapshotDigest: journal.descriptor.snapshotDigest,
|
|
392
|
+
planDigest: journal.planDigest,
|
|
393
|
+
descriptor: journal.descriptor,
|
|
394
|
+
journalPath: catalogPublicationJournalPath(context.catalogWorkspaceRoot, journal.display.catalogVersion),
|
|
395
|
+
repositoryPath,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
async function readExistingPlan(context, resolution) {
|
|
399
|
+
await assertPublicationStatePathSafe(context.catalogWorkspaceRoot);
|
|
400
|
+
const stateRoot = catalogPublicationDirectoryPath(context.catalogWorkspaceRoot, context.catalogVersion);
|
|
401
|
+
const journalPath = catalogPublicationJournalPath(context.catalogWorkspaceRoot, context.catalogVersion);
|
|
402
|
+
const repositoryPath = catalogPublicationRepositoryPath(context.catalogWorkspaceRoot, context.catalogVersion);
|
|
403
|
+
const stateRootExists = await assertPublicationDirectorySafe(stateRoot, context.catalogVersion);
|
|
404
|
+
const journal = await readCatalogPublicationJournal(journalPath, context.catalogVersion);
|
|
405
|
+
if (!journal) {
|
|
406
|
+
if (stateRootExists) {
|
|
407
|
+
throw new Error(`Catalog ${context.catalogVersion} pending publication journal is missing. Increase the Catalog version.`);
|
|
408
|
+
}
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
assertLiveContextMatchesDescriptor(context, journal.descriptor);
|
|
412
|
+
if (journal.state !== 'published') {
|
|
413
|
+
await validatePersistentRepository(repositoryPath, journal, context.env);
|
|
414
|
+
}
|
|
415
|
+
const state = await remoteRefState(context.repoRoot, context.pushUrl, context.branchRef, context.tagRef, context.env);
|
|
416
|
+
if (journal.state === 'published'
|
|
417
|
+
&& (state.branchCommit !== journal.expectedCommit
|
|
418
|
+
|| !state.tagAnnotated
|
|
419
|
+
|| state.tagCommit !== journal.expectedCommit)) {
|
|
420
|
+
throw new Error(`Catalog ${journal.display.catalogVersion} published journal conflicts with remote refs. Increase the Catalog version.`);
|
|
421
|
+
}
|
|
422
|
+
assertReconciliableRemoteState(state, journal);
|
|
423
|
+
return {
|
|
424
|
+
command: 'catalog:publish:plan',
|
|
425
|
+
state: journal.state,
|
|
426
|
+
...receiptBase(context, journal, resolution),
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
async function persistNewPlan(options) {
|
|
430
|
+
const { preparation, descriptor, snapshotRoot, resolution } = options;
|
|
431
|
+
await assertPublicationStatePathSafe(preparation.catalogWorkspaceRoot);
|
|
432
|
+
if (!sameDescriptor(preparation.descriptor, descriptor)) {
|
|
433
|
+
throw new Error('Catalog publication descriptor changed during preparation.');
|
|
434
|
+
}
|
|
435
|
+
const display = displayFromPreparation(preparation);
|
|
436
|
+
const stateRoot = catalogPublicationDirectoryPath(preparation.catalogWorkspaceRoot, display.catalogVersion);
|
|
437
|
+
const journalPath = catalogPublicationJournalPath(preparation.catalogWorkspaceRoot, display.catalogVersion);
|
|
438
|
+
if (!(await publicationGitExit(preparation.repoRoot, ['check-ignore', '-q', journalPath], preparation.env))) {
|
|
439
|
+
throw new Error('Catalog publish state under .aw/publish must be ignored by Git. Add .aw/ to .gitignore.');
|
|
440
|
+
}
|
|
441
|
+
if (await fs.pathExists(stateRoot)) {
|
|
442
|
+
throw new Error(`Catalog ${display.catalogVersion} already has publication state. Use its existing plan or increase the Catalog version.`);
|
|
443
|
+
}
|
|
444
|
+
if (!preparation.tagAvailable) {
|
|
445
|
+
throw new Error(`Remote Catalog tag ${descriptor.tag} already exists. Increase the Catalog version.`);
|
|
446
|
+
}
|
|
447
|
+
const expectedCommit = await createPublicationCommit(preparation, descriptor, snapshotRoot, display);
|
|
448
|
+
let context = await inspectCatalogPublicationLiveContext({
|
|
449
|
+
workspaceRoot: preparation.catalogWorkspaceRoot,
|
|
450
|
+
...(descriptor.remote.name === null ? { remoteUrl: preparation.pushUrl } : { remote: descriptor.remote.name }),
|
|
451
|
+
branch: descriptor.branch,
|
|
452
|
+
env: preparation.env,
|
|
453
|
+
});
|
|
454
|
+
assertLiveContextMatchesDescriptor(context, descriptor);
|
|
455
|
+
const liveRefs = await remoteRefState(preparation.repositoryRoot, 'publish', preparation.branchRef, preparation.tagRef, preparation.env);
|
|
456
|
+
if (liveRefs.branchCommit !== descriptor.parent || liveRefs.tagPresent) {
|
|
457
|
+
throw new Error(`Catalog ${display.catalogVersion} remote changed during plan creation. Increase the Catalog version.`);
|
|
458
|
+
}
|
|
459
|
+
const journal = {
|
|
460
|
+
schemaVersion: 2,
|
|
461
|
+
state: 'prepared',
|
|
462
|
+
planDigest: catalogPublicationPlanDigest(descriptor, expectedCommit),
|
|
463
|
+
descriptor,
|
|
464
|
+
expectedCommit,
|
|
465
|
+
repository: catalogPublicationRepositoryName(),
|
|
466
|
+
display,
|
|
467
|
+
preparedAt: new Date().toISOString(),
|
|
468
|
+
};
|
|
469
|
+
const persisted = await persistPublicationState(preparation, stateRoot, journal, {
|
|
470
|
+
beforeFinalRename: async (paths) => {
|
|
471
|
+
await options.beforeFinalRename?.(paths);
|
|
472
|
+
context = await inspectCatalogPublicationLiveContext({
|
|
473
|
+
workspaceRoot: preparation.catalogWorkspaceRoot,
|
|
474
|
+
...(descriptor.remote.name === null
|
|
475
|
+
? { remoteUrl: preparation.pushUrl }
|
|
476
|
+
: { remote: descriptor.remote.name }),
|
|
477
|
+
branch: descriptor.branch,
|
|
478
|
+
env: preparation.env,
|
|
479
|
+
});
|
|
480
|
+
assertLiveContextMatchesDescriptor(context, descriptor);
|
|
481
|
+
const finalRefs = await remoteRefState(context.repoRoot, context.pushUrl, context.branchRef, context.tagRef, context.env);
|
|
482
|
+
if (finalRefs.branchCommit !== descriptor.parent || finalRefs.tagPresent) {
|
|
483
|
+
throw new Error(`Catalog ${display.catalogVersion} remote changed during plan creation. Increase the Catalog version.`);
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
});
|
|
487
|
+
return {
|
|
488
|
+
command: 'catalog:publish:plan',
|
|
489
|
+
state: persisted.state,
|
|
490
|
+
...receiptBase(context, persisted, resolution),
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
export async function persistCatalogPublicationPlan(options) {
|
|
494
|
+
return persistNewPlan({
|
|
495
|
+
preparation: options.preparation,
|
|
496
|
+
descriptor: options.descriptor ?? options.preparation.descriptor,
|
|
497
|
+
snapshotRoot: options.snapshotRoot ?? options.preparation.prepared.outputRoot,
|
|
498
|
+
resolution: options,
|
|
499
|
+
beforeFinalRename: options.beforeFinalRename,
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
export async function prepareCatalogPublicationPlan(options) {
|
|
503
|
+
const context = await inspectCatalogPublicationLiveContext(options);
|
|
504
|
+
const existing = await readExistingPlan(context, options);
|
|
505
|
+
if (existing)
|
|
506
|
+
return existing;
|
|
507
|
+
const initialState = await remoteRefState(context.repoRoot, context.pushUrl, context.branchRef, context.tagRef, context.env);
|
|
508
|
+
if (initialState.tagPresent) {
|
|
509
|
+
throw new Error(`Remote Catalog tag ${context.tag} already exists. Increase the Catalog version.`);
|
|
510
|
+
}
|
|
511
|
+
if (initialState.branchCommit !== null) {
|
|
512
|
+
const branchState = await readCatalogPublicationBranchState({
|
|
513
|
+
workspaceRoot: context.catalogWorkspaceRoot,
|
|
514
|
+
...(options.remoteUrl === undefined ? { remote: options.remote } : { remoteUrl: options.remoteUrl }),
|
|
515
|
+
branch: context.branch,
|
|
516
|
+
env: options.env,
|
|
517
|
+
});
|
|
518
|
+
if (branchState?.version === context.catalogVersion) {
|
|
519
|
+
throw new Error(`Remote Catalog branch already contains version ${context.catalogVersion} without its journal. Increase the Catalog version.`);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
const preparation = await prepareCatalogPublicationInspection(options);
|
|
523
|
+
try {
|
|
524
|
+
return await persistNewPlan({
|
|
525
|
+
preparation,
|
|
526
|
+
descriptor: preparation.descriptor,
|
|
527
|
+
snapshotRoot: preparation.prepared.outputRoot,
|
|
528
|
+
resolution: options,
|
|
529
|
+
beforeFinalRename: options.beforeFinalRename,
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
finally {
|
|
533
|
+
await disposeCatalogPublicationInspection(preparation);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
async function markUncertain(journalPath, journal) {
|
|
537
|
+
const uncertain = {
|
|
538
|
+
schemaVersion: 2,
|
|
539
|
+
state: 'uncertain',
|
|
540
|
+
planDigest: journal.planDigest,
|
|
541
|
+
descriptor: journal.descriptor,
|
|
542
|
+
expectedCommit: journal.expectedCommit,
|
|
543
|
+
repository: journal.repository,
|
|
544
|
+
display: journal.display,
|
|
545
|
+
preparedAt: journal.preparedAt,
|
|
546
|
+
uncertainAt: new Date().toISOString(),
|
|
547
|
+
};
|
|
548
|
+
await writeCatalogPublicationJournalAtomic(journalPath, uncertain);
|
|
549
|
+
return uncertain;
|
|
550
|
+
}
|
|
551
|
+
async function readAuthorizedPublicationPlan(options) {
|
|
552
|
+
await assertPublicationStatePathSafe(options.workspaceRoot);
|
|
553
|
+
const located = await findCatalogPublicationJournalByPlanDigest(options.workspaceRoot, options.expectedPlanDigest);
|
|
554
|
+
const context = await inspectCatalogPublicationApplyContext(options);
|
|
555
|
+
assertApplyContextMatchesDescriptor(context, located.journal.descriptor);
|
|
556
|
+
return {
|
|
557
|
+
context,
|
|
558
|
+
journalPath: located.journalPath,
|
|
559
|
+
repositoryPath: catalogPublicationRepositoryPath(context.catalogWorkspaceRoot, located.catalogVersion),
|
|
560
|
+
tagRef: `refs/tags/${located.journal.descriptor.tag}`,
|
|
561
|
+
journal: located.journal,
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
async function cleanupPublishedRepository(repositoryPath, journal, env, removeRepository) {
|
|
565
|
+
try {
|
|
566
|
+
await fs.lstat(repositoryPath);
|
|
567
|
+
}
|
|
568
|
+
catch (error) {
|
|
569
|
+
if (error.code === 'ENOENT')
|
|
570
|
+
return [];
|
|
571
|
+
return [CATALOG_PUBLICATION_CLEANUP_WARNING];
|
|
572
|
+
}
|
|
573
|
+
const pendingJournal = {
|
|
574
|
+
schemaVersion: 2,
|
|
575
|
+
state: 'prepared',
|
|
576
|
+
planDigest: journal.planDigest,
|
|
577
|
+
descriptor: journal.descriptor,
|
|
578
|
+
expectedCommit: journal.expectedCommit,
|
|
579
|
+
repository: catalogPublicationRepositoryName(),
|
|
580
|
+
display: journal.display,
|
|
581
|
+
preparedAt: journal.preparedAt,
|
|
582
|
+
};
|
|
583
|
+
try {
|
|
584
|
+
await validatePersistentRepository(repositoryPath, pendingJournal, env);
|
|
585
|
+
await removeRepository(repositoryPath);
|
|
586
|
+
return [];
|
|
587
|
+
}
|
|
588
|
+
catch {
|
|
589
|
+
return [CATALOG_PUBLICATION_CLEANUP_WARNING];
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
async function inspectCatalogPublicationPlanForApply(options) {
|
|
593
|
+
const authorized = await readAuthorizedPublicationPlan(options);
|
|
594
|
+
const { context, journal, repositoryPath, tagRef } = authorized;
|
|
595
|
+
if (journal.state !== 'published') {
|
|
596
|
+
await validatePersistentRepository(repositoryPath, journal, context.env);
|
|
597
|
+
}
|
|
598
|
+
const state = await remoteRefState(journal.state === 'published' ? context.repoRoot : repositoryPath, context.pushUrl, context.branchRef, tagRef, context.env);
|
|
599
|
+
if (journal.state === 'published'
|
|
600
|
+
&& (state.branchCommit !== journal.expectedCommit
|
|
601
|
+
|| !state.tagAnnotated
|
|
602
|
+
|| state.tagCommit !== journal.expectedCommit)) {
|
|
603
|
+
throw new Error(`Catalog ${journal.display.catalogVersion} published journal conflicts with remote refs. Increase the Catalog version.`);
|
|
604
|
+
}
|
|
605
|
+
assertReconciliableRemoteState(state, journal);
|
|
606
|
+
return {
|
|
607
|
+
command: 'catalog:publish:plan',
|
|
608
|
+
state: journal.state,
|
|
609
|
+
...receiptBase(context, journal, options),
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
export async function applyCatalogPublicationPlan(options) {
|
|
613
|
+
if (!/^sha256:[0-9a-f]{64}$/u.test(options.expectedPlanDigest)) {
|
|
614
|
+
throw new Error('Catalog publish apply requires --expected-plan-digest from catalog publish plan.');
|
|
615
|
+
}
|
|
616
|
+
const authorized = await readAuthorizedPublicationPlan(options);
|
|
617
|
+
const { context, journalPath, repositoryPath, tagRef } = authorized;
|
|
618
|
+
let { journal } = authorized;
|
|
619
|
+
if (journal.state === 'published') {
|
|
620
|
+
const state = await remoteRefState(context.repoRoot, context.pushUrl, context.branchRef, tagRef, context.env);
|
|
621
|
+
if (state.branchCommit !== journal.expectedCommit || !state.tagAnnotated || state.tagCommit !== journal.expectedCommit) {
|
|
622
|
+
throw new Error(`Catalog ${journal.display.catalogVersion} published journal conflicts with remote refs. Increase the Catalog version.`);
|
|
623
|
+
}
|
|
624
|
+
const warnings = await cleanupPublishedRepository(repositoryPath, journal, context.env, options.removeRepository ?? fs.remove);
|
|
625
|
+
return {
|
|
626
|
+
command: 'catalog:publish:apply',
|
|
627
|
+
state: 'published',
|
|
628
|
+
commit: journal.expectedCommit,
|
|
629
|
+
reconciliation: 'already-published',
|
|
630
|
+
warnings,
|
|
631
|
+
...receiptBase(context, journal, options),
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
await validatePersistentRepository(repositoryPath, journal, context.env);
|
|
635
|
+
let state = await remoteRefState(repositoryPath, context.pushUrl, context.branchRef, tagRef, context.env);
|
|
636
|
+
assertReconciliableRemoteState(state, journal);
|
|
637
|
+
let reconciliation;
|
|
638
|
+
const branchAtExpected = state.branchCommit === journal.expectedCommit;
|
|
639
|
+
const tagAtExpected = state.tagAnnotated && state.tagCommit === journal.expectedCommit;
|
|
640
|
+
if (branchAtExpected && tagAtExpected) {
|
|
641
|
+
reconciliation = 'already-remote';
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
await options.beforeRemoteWrite?.();
|
|
645
|
+
const writeContext = await inspectCatalogPublicationApplyContext(options);
|
|
646
|
+
assertApplyContextMatchesDescriptor(writeContext, journal.descriptor);
|
|
647
|
+
await validatePersistentRepository(repositoryPath, journal, writeContext.env);
|
|
648
|
+
state = await remoteRefState(repositoryPath, writeContext.pushUrl, writeContext.branchRef, tagRef, writeContext.env);
|
|
649
|
+
assertReconciliableRemoteState(state, journal);
|
|
650
|
+
try {
|
|
651
|
+
if (state.branchCommit === journal.expectedCommit
|
|
652
|
+
&& state.tagAnnotated
|
|
653
|
+
&& state.tagCommit === journal.expectedCommit) {
|
|
654
|
+
reconciliation = 'already-remote';
|
|
655
|
+
}
|
|
656
|
+
else if (state.branchCommit === journal.descriptor.parent && !state.tagPresent) {
|
|
657
|
+
reconciliation = 'atomic';
|
|
658
|
+
await publicationGit(repositoryPath, [
|
|
659
|
+
'push', '--atomic',
|
|
660
|
+
`--force-with-lease=${writeContext.branchRef}:${journal.descriptor.parent ?? ''}`,
|
|
661
|
+
writeContext.pushUrl,
|
|
662
|
+
`${journal.expectedCommit}:${writeContext.branchRef}`,
|
|
663
|
+
`${tagRef}:${tagRef}`,
|
|
664
|
+
], writeContext.env, 'publicationUncertain', 'Catalog atomic push failed or its result is uncertain.');
|
|
665
|
+
}
|
|
666
|
+
else if (state.branchCommit === journal.expectedCommit && !state.tagPresent) {
|
|
667
|
+
reconciliation = 'tag';
|
|
668
|
+
await publicationGit(repositoryPath, [
|
|
669
|
+
'push', writeContext.pushUrl, `${tagRef}:${tagRef}`,
|
|
670
|
+
], writeContext.env, 'publicationUncertain', 'Catalog tag push failed or its result is uncertain.');
|
|
671
|
+
}
|
|
672
|
+
else {
|
|
673
|
+
reconciliation = 'branch';
|
|
674
|
+
await publicationGit(repositoryPath, [
|
|
675
|
+
'push', `--force-with-lease=${writeContext.branchRef}:${journal.descriptor.parent ?? ''}`,
|
|
676
|
+
writeContext.pushUrl, `${journal.expectedCommit}:${writeContext.branchRef}`,
|
|
677
|
+
], writeContext.env, 'publicationUncertain', 'Catalog branch push failed or its result is uncertain.');
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
catch (error) {
|
|
681
|
+
journal = await markUncertain(journalPath, journal);
|
|
682
|
+
throw new Error(`Catalog ${journal.display.catalogVersion} publication result is uncertain. Retry apply with the same plan digest.`, { cause: error });
|
|
683
|
+
}
|
|
684
|
+
try {
|
|
685
|
+
state = await remoteRefState(repositoryPath, writeContext.pushUrl, writeContext.branchRef, tagRef, writeContext.env);
|
|
686
|
+
}
|
|
687
|
+
catch (error) {
|
|
688
|
+
journal = await markUncertain(journalPath, journal);
|
|
689
|
+
throw new Error(`Catalog ${journal.display.catalogVersion} publication result is uncertain. Retry apply with the same plan digest.`, { cause: error });
|
|
690
|
+
}
|
|
691
|
+
if (state.branchCommit !== journal.expectedCommit || !state.tagAnnotated || state.tagCommit !== journal.expectedCommit) {
|
|
692
|
+
journal = await markUncertain(journalPath, journal);
|
|
693
|
+
throw new Error(`Catalog ${journal.display.catalogVersion} publication result is uncertain. Retry apply with the same plan digest.`);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
const published = {
|
|
697
|
+
schemaVersion: 2,
|
|
698
|
+
state: 'published',
|
|
699
|
+
planDigest: journal.planDigest,
|
|
700
|
+
descriptor: journal.descriptor,
|
|
701
|
+
expectedCommit: journal.expectedCommit,
|
|
702
|
+
repository: null,
|
|
703
|
+
display: journal.display,
|
|
704
|
+
preparedAt: journal.preparedAt,
|
|
705
|
+
publishedAt: new Date().toISOString(),
|
|
706
|
+
};
|
|
707
|
+
await writeCatalogPublicationJournalAtomic(journalPath, published);
|
|
708
|
+
const warnings = await cleanupPublishedRepository(repositoryPath, published, context.env, options.removeRepository ?? fs.remove);
|
|
709
|
+
return {
|
|
710
|
+
command: 'catalog:publish:apply',
|
|
711
|
+
state: 'published',
|
|
712
|
+
commit: published.expectedCommit,
|
|
713
|
+
reconciliation,
|
|
714
|
+
warnings,
|
|
715
|
+
...receiptBase(context, published, options),
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
export async function runCatalogPublishPlanCommand(options) {
|
|
719
|
+
const workspace = await resolveCatalogWorkspaceRoot({
|
|
720
|
+
cwd: options.cwd,
|
|
721
|
+
...(options.workspaceRoot === undefined ? {} : { explicitRoot: options.workspaceRoot }),
|
|
722
|
+
mode: 'existing',
|
|
723
|
+
});
|
|
724
|
+
const target = await resolveCatalogPublicationTarget({
|
|
725
|
+
workspaceRoot: workspace.workspaceRoot,
|
|
726
|
+
remote: options.remote,
|
|
727
|
+
branch: options.branch,
|
|
728
|
+
env: options.env,
|
|
729
|
+
requireRemote: true,
|
|
730
|
+
});
|
|
731
|
+
return prepareCatalogPublicationPlan({
|
|
732
|
+
workspaceRoot: workspace.workspaceRoot,
|
|
733
|
+
remote: target.remote,
|
|
734
|
+
branch: target.branch,
|
|
735
|
+
env: options.env,
|
|
736
|
+
workspaceRootResolvedFrom: workspace.workspaceRootResolvedFrom,
|
|
737
|
+
remoteResolvedFrom: target.remoteResolvedFrom,
|
|
738
|
+
branchResolvedFrom: target.branchResolvedFrom,
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
export async function runCatalogPublishApplyCommand(options) {
|
|
742
|
+
if (options.json && !options.yes)
|
|
743
|
+
throw new Error('Catalog publish apply with --json requires --yes.');
|
|
744
|
+
if (!options.interactive && !options.yes)
|
|
745
|
+
throw new Error('Non-interactive Catalog publish apply requires --yes.');
|
|
746
|
+
if (!/^sha256:[0-9a-f]{64}$/u.test(options.expectedPlanDigest ?? '')) {
|
|
747
|
+
throw new Error('Catalog publish apply requires --expected-plan-digest from catalog publish plan.');
|
|
748
|
+
}
|
|
749
|
+
const workspace = await resolveCatalogWorkspaceRoot({
|
|
750
|
+
cwd: options.cwd,
|
|
751
|
+
...(options.workspaceRoot === undefined ? {} : { explicitRoot: options.workspaceRoot }),
|
|
752
|
+
mode: 'existing',
|
|
753
|
+
});
|
|
754
|
+
const target = await resolveCatalogPublicationTarget({
|
|
755
|
+
workspaceRoot: workspace.workspaceRoot,
|
|
756
|
+
remote: options.remote,
|
|
757
|
+
branch: options.branch,
|
|
758
|
+
env: options.env,
|
|
759
|
+
requireRemote: true,
|
|
760
|
+
});
|
|
761
|
+
if (!options.yes) {
|
|
762
|
+
const plan = await inspectCatalogPublicationPlanForApply({
|
|
763
|
+
workspaceRoot: workspace.workspaceRoot,
|
|
764
|
+
remote: target.remote,
|
|
765
|
+
branch: target.branch,
|
|
766
|
+
expectedPlanDigest: options.expectedPlanDigest,
|
|
767
|
+
env: options.env,
|
|
768
|
+
workspaceRootResolvedFrom: workspace.workspaceRootResolvedFrom,
|
|
769
|
+
remoteResolvedFrom: target.remoteResolvedFrom,
|
|
770
|
+
branchResolvedFrom: target.branchResolvedFrom,
|
|
771
|
+
});
|
|
772
|
+
options.io.stderr([
|
|
773
|
+
`Workspace identity: ${plan.workspaceIdentity}`,
|
|
774
|
+
`Source HEAD: ${plan.sourceHead}`,
|
|
775
|
+
`Remote: ${plan.remote}`,
|
|
776
|
+
`Fetch URL: ${plan.fetchUrl}`,
|
|
777
|
+
`Push URL: ${plan.pushUrl}`,
|
|
778
|
+
`Branch: refs/heads/${plan.branch}`,
|
|
779
|
+
`Parent: ${plan.parent ?? '<root>'}`,
|
|
780
|
+
`Tag: refs/tags/${plan.tag}`,
|
|
781
|
+
`Snapshot digest: ${plan.snapshotDigest}`,
|
|
782
|
+
`Expected commit: ${plan.expectedCommit}`,
|
|
783
|
+
`Plan digest: ${plan.planDigest}`,
|
|
784
|
+
].join('\n') + '\n');
|
|
785
|
+
if (!options.confirm || !(await options.confirm('Apply this Catalog publication plan?'))) {
|
|
786
|
+
options.io.stderr('Catalog publication cancelled.\n');
|
|
787
|
+
return null;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
const result = await applyCatalogPublicationPlan({
|
|
791
|
+
workspaceRoot: workspace.workspaceRoot,
|
|
792
|
+
remote: target.remote,
|
|
793
|
+
branch: target.branch,
|
|
794
|
+
expectedPlanDigest: options.expectedPlanDigest,
|
|
795
|
+
env: options.env,
|
|
796
|
+
workspaceRootResolvedFrom: workspace.workspaceRootResolvedFrom,
|
|
797
|
+
remoteResolvedFrom: target.remoteResolvedFrom,
|
|
798
|
+
branchResolvedFrom: target.branchResolvedFrom,
|
|
799
|
+
});
|
|
800
|
+
for (const warning of result.warnings)
|
|
801
|
+
options.io.stderr(`${warning}\n`);
|
|
802
|
+
return result;
|
|
803
|
+
}
|
|
804
|
+
//# sourceMappingURL=catalog-publish.js.map
|