@lesliechan721/aw 0.1.0-beta.4 → 0.1.0-beta.40
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.mjs +100 -501
- package/dist/authoring/assets/aw-config.mjs.map +1 -1
- package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
- package/dist/authoring/assets/aw-runtime-config.mjs +199 -0
- package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
- package/dist/authoring/scripts/add-skill.mjs +4 -4
- package/dist/authoring/scripts/add-skill.mjs.map +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +67 -97
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-version-check.d.mts +15 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +239 -232
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +77 -90
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +99 -120
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
- package/dist/authoring/scripts/plugin-status.mjs +8 -11
- package/dist/authoring/scripts/plugin-status.mjs.map +1 -1
- 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.mjs +353 -1175
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/scripts/aw-skill-eval-materializer.d.ts +26 -0
- package/dist/scripts/aw-skill-eval-materializer.js +306 -0
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
- package/dist/scripts/bundle-plugins.d.ts +1 -2
- package/dist/scripts/bundle-plugins.js +24 -7
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/plugin-staging.d.ts +7 -24
- package/dist/scripts/plugin-staging.js +22 -142
- package/dist/scripts/plugin-staging.js.map +1 -1
- package/dist/scripts/test-plugin-scripts.d.ts +2 -0
- package/dist/scripts/test-plugin-scripts.js +30 -75
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- package/dist/src/adapters/helpers.js +2 -2
- package/dist/src/adapters/helpers.js.map +1 -1
- package/dist/src/authoring/workspace-commands.d.ts +26 -2
- package/dist/src/authoring/workspace-commands.js +44 -19
- package/dist/src/authoring/workspace-commands.js.map +1 -1
- package/dist/src/commands/aw-capabilities.d.ts +78 -0
- package/dist/src/commands/aw-capabilities.js +263 -0
- package/dist/src/commands/aw-capabilities.js.map +1 -0
- package/dist/src/commands/catalog-dev-source.d.ts +154 -0
- package/dist/src/commands/catalog-dev-source.js +655 -0
- package/dist/src/commands/catalog-dev-source.js.map +1 -0
- package/dist/src/commands/catalog-generation.d.ts +21 -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 +757 -0
- package/dist/src/commands/catalog-publication-inspection.js.map +1 -0
- package/dist/src/commands/catalog-publication-journal.d.ts +68 -0
- package/dist/src/commands/catalog-publication-journal.js +292 -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 +77 -7
- package/dist/src/commands/catalog-publish.js +746 -316
- package/dist/src/commands/catalog-publish.js.map +1 -1
- package/dist/src/commands/catalog-source.d.ts +60 -22
- package/dist/src/commands/catalog-source.js +311 -91
- package/dist/src/commands/catalog-source.js.map +1 -1
- 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 +104 -0
- package/dist/src/commands/catalog-store.js +685 -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.js +28 -17
- package/dist/src/commands/console.js.map +1 -1
- package/dist/src/commands/dependency-operation-plan.d.ts +52 -15
- package/dist/src/commands/dependency-operation-plan.js +289 -7
- package/dist/src/commands/dependency-operation-plan.js.map +1 -1
- package/dist/src/commands/init.d.ts +5 -11
- package/dist/src/commands/init.js +30 -51
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/offline-cleanup-evidence.d.ts +67 -0
- package/dist/src/commands/offline-cleanup-evidence.js +181 -0
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -0
- package/dist/src/commands/operation-plan.d.ts +146 -0
- package/dist/src/commands/operation-plan.js +71 -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 +141 -0
- package/dist/src/commands/operation-planner.js.map +1 -0
- package/dist/src/commands/options.d.ts +9 -7
- package/dist/src/commands/options.js +83 -21
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.d.ts +22 -0
- package/dist/src/commands/plugin-capabilities.js +163 -0
- package/dist/src/commands/plugin-capabilities.js.map +1 -0
- package/dist/src/commands/rebuild-command.d.ts +78 -30
- package/dist/src/commands/rebuild-command.js +4877 -713
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +132 -21
- package/dist/src/commands/rebuild-integration.js +2853 -1327
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +58 -30
- package/dist/src/commands/rebuild-operations.js +260 -319
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/reconcile-operation-plan.d.ts +28 -0
- package/dist/src/commands/reconcile-operation-plan.js +47 -0
- package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
- package/dist/src/commands/review-inspection.d.ts +228 -0
- package/dist/src/commands/review-inspection.js +1341 -0
- package/dist/src/commands/review-inspection.js.map +1 -0
- package/dist/src/commands/review-preparation.d.ts +49 -0
- package/dist/src/commands/review-preparation.js +427 -0
- package/dist/src/commands/review-preparation.js.map +1 -0
- package/dist/src/commands/runtime.d.ts +1 -5
- package/dist/src/commands/runtime.js +24 -50
- package/dist/src/commands/runtime.js.map +1 -1
- package/dist/src/commands/skill-eval.d.ts +39 -0
- package/dist/src/commands/skill-eval.js +400 -0
- package/dist/src/commands/skill-eval.js.map +1 -0
- package/dist/src/commands/status-v6.d.ts +279 -0
- package/dist/src/commands/status-v6.js +2787 -0
- package/dist/src/commands/status-v6.js.map +1 -0
- package/dist/src/commands/sync-command.d.ts +40 -0
- package/dist/src/commands/sync-command.js +250 -0
- package/dist/src/commands/sync-command.js.map +1 -0
- package/dist/src/commands/wizard.d.ts +8 -5
- package/dist/src/commands/wizard.js +6 -4
- package/dist/src/commands/wizard.js.map +1 -1
- package/dist/src/commands/write-commands.d.ts +9 -3
- package/dist/src/commands/write-commands.js +127 -31
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/constants.d.ts +7 -1
- package/dist/src/constants.js +7 -1
- package/dist/src/constants.js.map +1 -1
- package/dist/src/eval/manifest-v1.d.ts +71 -0
- package/dist/src/eval/manifest-v1.js +370 -0
- package/dist/src/eval/manifest-v1.js.map +1 -0
- package/dist/src/generators/local-plugin.d.ts +5 -1
- package/dist/src/generators/local-plugin.js +228 -104
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/index.d.ts +10 -4
- package/dist/src/index.js +1835 -469
- package/dist/src/index.js.map +1 -1
- package/dist/src/output/command-receipt.d.ts +43 -46
- package/dist/src/output/command-receipt.js +256 -80
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/model.d.ts +3 -44
- package/dist/src/output/model.js +1 -144
- package/dist/src/output/model.js.map +1 -1
- package/dist/src/output/rebuild-progress.js +1 -13
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/portable/commands.d.ts +46 -7
- package/dist/src/portable/commands.js +349 -37
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/materializer.d.ts +17 -4
- package/dist/src/portable/materializer.js +179 -41
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/skills-cli.d.ts +15 -7
- package/dist/src/portable/skills-cli.js +66 -19
- package/dist/src/portable/skills-cli.js.map +1 -1
- package/dist/src/review/eval-source-input.d.ts +43 -0
- package/dist/src/review/eval-source-input.js +207 -0
- package/dist/src/review/eval-source-input.js.map +1 -0
- package/dist/src/review/review-profile.d.ts +17 -0
- package/dist/src/review/review-profile.js +234 -0
- package/dist/src/review/review-profile.js.map +1 -0
- package/dist/src/review/review-selection.d.ts +30 -0
- package/dist/src/review/review-selection.js +527 -0
- package/dist/src/review/review-selection.js.map +1 -0
- package/dist/src/review/review-types.d.ts +68 -0
- package/dist/src/review/review-types.js +16 -0
- package/dist/src/review/review-types.js.map +1 -0
- package/dist/src/review/skill-materialization.d.ts +13 -0
- package/dist/src/review/skill-materialization.js +75 -0
- package/dist/src/review/skill-materialization.js.map +1 -0
- package/dist/src/review/source-binding.d.ts +183 -0
- package/dist/src/review/source-binding.js +708 -0
- package/dist/src/review/source-binding.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 +156 -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 +40 -0
- package/dist/src/tui/catalog-sources/screens.js.map +1 -0
- package/dist/src/tui/catalog-sources/session.d.ts +32 -0
- package/dist/src/tui/catalog-sources/session.js +300 -0
- package/dist/src/tui/catalog-sources/session.js.map +1 -0
- package/dist/src/tui/catalog-sources/types.d.ts +54 -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/catalog-store-task.d.ts +16 -0
- package/dist/src/tui/catalog-store-task.js +19 -0
- package/dist/src/tui/catalog-store-task.js.map +1 -0
- package/dist/src/tui/clipboard.d.ts +13 -0
- package/dist/src/tui/clipboard.js +95 -0
- package/dist/src/tui/clipboard.js.map +1 -0
- package/dist/src/tui/components.d.ts +177 -0
- package/dist/src/tui/components.js +297 -7
- package/dist/src/tui/components.js.map +1 -1
- package/dist/src/tui/config-array-draft.d.ts +29 -0
- package/dist/src/tui/config-array-draft.js +48 -0
- package/dist/src/tui/config-array-draft.js.map +1 -0
- package/dist/src/tui/config-leaf-editor.d.ts +16 -0
- package/dist/src/tui/config-leaf-editor.js +206 -0
- package/dist/src/tui/config-leaf-editor.js.map +1 -0
- package/dist/src/tui/config-value-presentation.d.ts +20 -0
- package/dist/src/tui/config-value-presentation.js +104 -0
- package/dist/src/tui/config-value-presentation.js.map +1 -0
- package/dist/src/tui/console-app-v4.d.ts +14 -4
- package/dist/src/tui/console-app-v4.js +9659 -1558
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/content-item-card.d.ts +13 -0
- package/dist/src/tui/content-item-card.js +51 -0
- package/dist/src/tui/content-item-card.js.map +1 -0
- package/dist/src/tui/controller-runtime.d.ts +13 -1
- package/dist/src/tui/controller-runtime.js +3323 -349
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +643 -40
- package/dist/src/tui/controller.js +3756 -705
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/dependency-graph-view.d.ts +39 -0
- package/dist/src/tui/dependency-graph-view.js +121 -0
- package/dist/src/tui/dependency-graph-view.js.map +1 -0
- package/dist/src/tui/dependency-graph.d.ts +81 -0
- package/dist/src/tui/dependency-graph.js +452 -0
- package/dist/src/tui/dependency-graph.js.map +1 -0
- package/dist/src/tui/diagnostic-projection.d.ts +23 -0
- package/dist/src/tui/diagnostic-projection.js +567 -0
- package/dist/src/tui/diagnostic-projection.js.map +1 -0
- package/dist/src/tui/diagnostics.d.ts +31 -0
- package/dist/src/tui/diagnostics.js +83 -0
- package/dist/src/tui/diagnostics.js.map +1 -0
- package/dist/src/tui/entity-cards.d.ts +55 -0
- package/dist/src/tui/entity-cards.js +220 -0
- package/dist/src/tui/entity-cards.js.map +1 -0
- package/dist/src/tui/glossary.d.ts +23 -0
- package/dist/src/tui/glossary.js +42 -0
- package/dist/src/tui/glossary.js.map +1 -0
- package/dist/src/tui/index.d.ts +11 -4
- package/dist/src/tui/index.js +8 -2
- package/dist/src/tui/index.js.map +1 -1
- package/dist/src/tui/input-display.d.ts +9 -0
- package/dist/src/tui/input-display.js +58 -0
- package/dist/src/tui/input-display.js.map +1 -0
- package/dist/src/tui/keys.d.ts +44 -0
- package/dist/src/tui/keys.js +43 -15
- package/dist/src/tui/keys.js.map +1 -1
- package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
- package/dist/src/tui/lifecycle-action-view.js +36 -0
- package/dist/src/tui/lifecycle-action-view.js.map +1 -0
- package/dist/src/tui/model.d.ts +248 -27
- package/dist/src/tui/model.js +1662 -314
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
- package/dist/src/tui/operation-diagnostic-screens.js +71 -0
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
- package/dist/src/tui/operation-history.d.ts +81 -0
- package/dist/src/tui/operation-history.js +136 -0
- package/dist/src/tui/operation-history.js.map +1 -0
- package/dist/src/tui/operation-review-planner.d.ts +21 -0
- package/dist/src/tui/operation-review-planner.js +1295 -0
- package/dist/src/tui/operation-review-planner.js.map +1 -0
- package/dist/src/tui/plugin-content.d.ts +31 -0
- package/dist/src/tui/plugin-content.js +680 -0
- package/dist/src/tui/plugin-content.js.map +1 -0
- package/dist/src/tui/plugin-detail.d.ts +52 -0
- package/dist/src/tui/plugin-detail.js +165 -0
- package/dist/src/tui/plugin-detail.js.map +1 -0
- package/dist/src/tui/plugin-write-task.d.ts +69 -0
- package/dist/src/tui/plugin-write-task.js +286 -0
- package/dist/src/tui/plugin-write-task.js.map +1 -0
- package/dist/src/tui/project-inventory.d.ts +68 -0
- package/dist/src/tui/project-inventory.js +203 -0
- package/dist/src/tui/project-inventory.js.map +1 -0
- package/dist/src/tui/prompt.js +4 -15
- package/dist/src/tui/prompt.js.map +1 -1
- package/dist/src/tui/query-header.d.ts +30 -0
- package/dist/src/tui/query-header.js +40 -0
- package/dist/src/tui/query-header.js.map +1 -0
- package/dist/src/tui/reader.d.ts +37 -0
- package/dist/src/tui/reader.js +47 -0
- package/dist/src/tui/reader.js.map +1 -0
- package/dist/src/tui/router.d.ts +207 -14
- package/dist/src/tui/router.js +352 -29
- package/dist/src/tui/router.js.map +1 -1
- package/dist/src/tui/screen-registry.d.ts +701 -0
- package/dist/src/tui/screen-registry.js +230 -0
- package/dist/src/tui/screen-registry.js.map +1 -0
- package/dist/src/tui/session-console-app.d.ts +6 -0
- package/dist/src/tui/session-console-app.js +13 -0
- package/dist/src/tui/session-console-app.js.map +1 -0
- package/dist/src/tui/session-host.d.ts +45 -0
- package/dist/src/tui/session-host.js +209 -0
- package/dist/src/tui/session-host.js.map +1 -0
- package/dist/src/tui/source-detail-card.d.ts +29 -0
- package/dist/src/tui/source-detail-card.js +45 -0
- package/dist/src/tui/source-detail-card.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 +30 -10
- package/dist/src/tui/theme.js +30 -10
- package/dist/src/tui/theme.js.map +1 -1
- package/dist/src/tui/viewport.d.ts +21 -0
- package/dist/src/tui/viewport.js +52 -0
- package/dist/src/tui/viewport.js.map +1 -0
- package/dist/src/tui/views.js +31 -3
- package/dist/src/tui/views.js.map +1 -1
- package/dist/src/tui/wizard.js +37 -13
- package/dist/src/tui/wizard.js.map +1 -1
- package/dist/src/types.d.ts +244 -20
- package/dist/src/types.js +1 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.d.ts +7 -1
- package/dist/src/utils/agent-version.js +41 -8
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-plan.d.ts +5 -4
- package/dist/src/utils/artifact-plan.js +18 -7
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +17 -7
- package/dist/src/utils/artifact-renderer.js +214 -216
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +21 -0
- package/dist/src/utils/artifact-request.js +78 -0
- package/dist/src/utils/artifact-request.js.map +1 -0
- package/dist/src/utils/aw-home-mutation-lock.d.ts +1 -0
- package/dist/src/utils/aw-home-mutation-lock.js +32 -4
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
- package/dist/src/utils/bundle-integrity.d.ts +0 -1
- package/dist/src/utils/bundle-integrity.js +0 -25
- package/dist/src/utils/bundle-integrity.js.map +1 -1
- package/dist/src/utils/bundle-layout.js +22 -29
- package/dist/src/utils/bundle-layout.js.map +1 -1
- package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
- package/dist/src/utils/catalog-capability-projection.js +14 -0
- package/dist/src/utils/catalog-capability-projection.js.map +1 -0
- package/dist/src/utils/catalog-digests.d.ts +10 -0
- package/dist/src/utils/catalog-digests.js +50 -2
- package/dist/src/utils/catalog-digests.js.map +1 -1
- 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 +44 -0
- package/dist/src/utils/catalog-generation-resolver.js +273 -0
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -0
- package/dist/src/utils/catalog-generation-service.d.ts +172 -0
- package/dist/src/utils/catalog-generation-service.js +1271 -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 +58 -0
- package/dist/src/utils/catalog-generation-store.js +452 -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-v4.js → catalog-manifest-v7.js} +35 -43
- 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 +142 -0
- package/dist/src/utils/catalog-operation-context.js.map +1 -0
- package/dist/src/utils/catalog-public-error.d.ts +7 -3
- package/dist/src/utils/catalog-public-error.js +28 -8
- package/dist/src/utils/catalog-public-error.js.map +1 -1
- package/dist/src/utils/catalog-runtime-projection.d.ts +4 -7
- package/dist/src/utils/catalog-runtime-projection.js +7 -102
- package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
- package/dist/src/utils/catalog-snapshot.d.ts +5 -3
- package/dist/src/utils/catalog-snapshot.js +11 -3
- package/dist/src/utils/catalog-snapshot.js.map +1 -1
- package/dist/src/utils/catalog-source-identity.d.ts +1 -0
- package/dist/src/utils/catalog-source-identity.js +21 -2
- package/dist/src/utils/catalog-source-identity.js.map +1 -1
- package/dist/src/utils/catalog-source-impact.d.ts +21 -0
- package/dist/src/utils/catalog-source-impact.js +344 -0
- package/dist/src/utils/catalog-source-impact.js.map +1 -0
- package/dist/src/utils/catalog-source-references.d.ts +3 -2
- package/dist/src/utils/catalog-source-references.js +195 -347
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/catalog-sources.d.ts +15 -1
- package/dist/src/utils/catalog-sources.js +206 -27
- package/dist/src/utils/catalog-sources.js.map +1 -1
- package/dist/src/utils/codex-config.d.ts +2 -0
- package/dist/src/utils/codex-config.js +26 -5
- package/dist/src/utils/codex-config.js.map +1 -1
- package/dist/src/utils/codex-manager.d.ts +79 -0
- package/dist/src/utils/codex-manager.js +745 -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 +49 -0
- package/dist/src/utils/codex-native-observation.js +154 -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 +126 -0
- package/dist/src/utils/codex-reconciler.js +298 -0
- package/dist/src/utils/codex-reconciler.js.map +1 -0
- package/dist/src/utils/codex-shared-native.d.ts +43 -0
- package/dist/src/utils/codex-shared-native.js +81 -0
- package/dist/src/utils/codex-shared-native.js.map +1 -0
- package/dist/src/utils/codex-skill-staging.d.ts +2 -0
- package/dist/src/utils/codex-skill-staging.js.map +1 -1
- package/dist/src/utils/codex-surface-analysis.d.ts +46 -0
- package/dist/src/utils/codex-surface-analysis.js +247 -0
- package/dist/src/utils/codex-surface-analysis.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +4 -0
- package/dist/src/utils/dynamic-skill-tree.js +36 -6
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
- package/dist/src/utils/git-catalog-provider.d.ts +16 -0
- package/dist/src/utils/git-catalog-provider.js +169 -144
- package/dist/src/utils/git-catalog-provider.js.map +1 -1
- package/dist/src/utils/local-marketplace.d.ts +17 -1
- package/dist/src/utils/local-marketplace.js +301 -84
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/manifest.d.ts +1 -4
- package/dist/src/utils/manifest.js +1 -4
- package/dist/src/utils/manifest.js.map +1 -1
- package/dist/src/utils/multi-source-catalog.d.ts +3 -9
- package/dist/src/utils/multi-source-catalog.js +54 -110
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +55 -7
- package/dist/src/utils/native-cli.js +386 -57
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/orphan-marketplace-cleanup.js +0 -4
- package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
- package/dist/src/utils/ownership.d.ts +84 -20
- package/dist/src/utils/ownership.js +179 -222
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/path-catalog-provider.d.ts +1 -1
- package/dist/src/utils/path-catalog-provider.js +54 -65
- package/dist/src/utils/path-catalog-provider.js.map +1 -1
- package/dist/src/utils/paths.d.ts +0 -1
- package/dist/src/utils/paths.js +0 -1
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/plugin-config-impact.d.ts +33 -0
- package/dist/src/utils/plugin-config-impact.js +298 -0
- package/dist/src/utils/plugin-config-impact.js.map +1 -0
- package/dist/src/utils/plugin-config-write.d.ts +52 -27
- package/dist/src/utils/plugin-config-write.js +1000 -296
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +153 -93
- package/dist/src/utils/plugin-config.js +1163 -1017
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-intent-state.d.ts +49 -0
- package/dist/src/utils/plugin-intent-state.js +320 -0
- package/dist/src/utils/plugin-intent-state.js.map +1 -0
- package/dist/src/utils/plugin-scripts.d.ts +65 -125
- package/dist/src/utils/plugin-scripts.js +482 -524
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/process-tree.d.ts +2 -2
- package/dist/src/utils/process-tree.js +1 -1
- package/dist/src/utils/process-tree.js.map +1 -1
- package/dist/src/utils/project-boundary.d.ts +11 -13
- package/dist/src/utils/project-boundary.js +28 -34
- package/dist/src/utils/project-boundary.js.map +1 -1
- package/dist/src/utils/runtime-config.d.ts +20 -0
- package/dist/src/utils/runtime-config.js +75 -0
- package/dist/src/utils/runtime-config.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/safe-operation-diagnostic.d.ts +15 -0
- package/dist/src/utils/safe-operation-diagnostic.js +33 -0
- package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
- package/dist/src/utils/sensitive-content.d.ts +4 -0
- package/dist/src/utils/sensitive-content.js +36 -0
- package/dist/src/utils/sensitive-content.js.map +1 -0
- package/dist/src/utils/skill-validation.d.ts +1 -1
- package/dist/src/utils/skill-validation.js +1 -1
- package/dist/src/utils/skill-validation.js.map +1 -1
- package/dist/src/utils/state-paths.d.ts +1 -0
- package/dist/src/utils/state-paths.js +12 -2
- package/dist/src/utils/state-paths.js.map +1 -1
- package/dist/src/utils/target-eligibility.d.ts +8 -2
- package/dist/src/utils/target-eligibility.js +17 -8
- package/dist/src/utils/target-eligibility.js.map +1 -1
- package/dist/src/utils/windows-claude-shim.d.ts +9 -0
- package/dist/src/utils/windows-claude-shim.js +141 -0
- package/dist/src/utils/windows-claude-shim.js.map +1 -0
- package/dist/vitest.config.js +91 -10
- package/dist/vitest.config.js.map +1 -1
- package/package.json +22 -19
- package/dist/authoring/scripts/check-plugin-versions.mjs +0 -5
- package/dist/authoring/scripts/check-plugin-versions.mjs.map +0 -1
- package/dist/scripts/aw-skill-eval-engine.d.ts +0 -13
- package/dist/scripts/aw-skill-eval-engine.js +0 -31
- package/dist/scripts/aw-skill-eval-engine.js.map +0 -1
- package/dist/scripts/codex-eval-app-server.d.ts +0 -89
- package/dist/scripts/codex-eval-app-server.js +0 -1228
- package/dist/scripts/codex-eval-app-server.js.map +0 -1
- package/dist/scripts/codex-eval-isolation.d.ts +0 -61
- package/dist/scripts/codex-eval-isolation.js +0 -318
- package/dist/scripts/codex-eval-isolation.js.map +0 -1
- package/dist/scripts/codex-eval-process-management.d.ts +0 -8
- package/dist/scripts/codex-eval-process-management.js +0 -69
- package/dist/scripts/codex-eval-process-management.js.map +0 -1
- package/dist/scripts/codex-eval-process-tree.d.ts +0 -38
- package/dist/scripts/codex-eval-process-tree.js +0 -803
- package/dist/scripts/codex-eval-process-tree.js.map +0 -1
- package/dist/scripts/codex-eval-runtime-config.d.ts +0 -62
- package/dist/scripts/codex-eval-runtime-config.js +0 -843
- package/dist/scripts/codex-eval-runtime-config.js.map +0 -1
- package/dist/scripts/codex-trigger-eval.d.ts +0 -84
- package/dist/scripts/codex-trigger-eval.js +0 -968
- package/dist/scripts/codex-trigger-eval.js.map +0 -1
- package/dist/scripts/eval-plugin-skills-audited.d.ts +0 -6
- package/dist/scripts/eval-plugin-skills-audited.js +0 -261
- package/dist/scripts/eval-plugin-skills-audited.js.map +0 -1
- package/dist/scripts/eval-plugin-skills.d.ts +0 -45
- package/dist/scripts/eval-plugin-skills.js +0 -1586
- package/dist/scripts/eval-plugin-skills.js.map +0 -1
- package/dist/scripts/eval-run-layout.d.ts +0 -17
- package/dist/scripts/eval-run-layout.js +0 -26
- package/dist/scripts/eval-run-layout.js.map +0 -1
- package/dist/scripts/plugin-eval-contract.d.ts +0 -185
- package/dist/scripts/plugin-eval-contract.js +0 -695
- package/dist/scripts/plugin-eval-contract.js.map +0 -1
- package/dist/scripts/plugin-eval-materializer.d.ts +0 -13
- package/dist/scripts/plugin-eval-materializer.js +0 -421
- package/dist/scripts/plugin-eval-materializer.js.map +0 -1
- package/dist/scripts/skill-reporting.d.ts +0 -212
- package/dist/scripts/skill-reporting.js +0 -922
- package/dist/scripts/skill-reporting.js.map +0 -1
- package/dist/src/commands/status-v4.d.ts +0 -102
- package/dist/src/commands/status-v4.js +0 -844
- package/dist/src/commands/status-v4.js.map +0 -1
- package/dist/src/commands/status.d.ts +0 -93
- package/dist/src/commands/status.js +0 -442
- package/dist/src/commands/status.js.map +0 -1
- package/dist/src/utils/active-marketplace-runtime-lock.d.ts +0 -12
- package/dist/src/utils/active-marketplace-runtime-lock.js +0 -133
- package/dist/src/utils/active-marketplace-runtime-lock.js.map +0 -1
- package/dist/src/utils/catalog-manifest-v3.d.ts +0 -2
- package/dist/src/utils/catalog-manifest-v3.js +0 -3
- package/dist/src/utils/catalog-manifest-v3.js.map +0 -1
- package/dist/src/utils/catalog-manifest-v4.d.ts +0 -5
- package/dist/src/utils/catalog-manifest-v4.js.map +0 -1
- package/dist/src/utils/catalog-source-cache.d.ts +0 -61
- package/dist/src/utils/catalog-source-cache.js +0 -276
- package/dist/src/utils/catalog-source-cache.js.map +0 -1
- package/dist/src/utils/codex-project-surface.d.ts +0 -3
- package/dist/src/utils/codex-project-surface.js +0 -49
- package/dist/src/utils/codex-project-surface.js.map +0 -1
- package/dist/src/utils/lifecycle-active-store.d.ts +0 -175
- package/dist/src/utils/lifecycle-active-store.js +0 -1276
- package/dist/src/utils/lifecycle-active-store.js.map +0 -1
- package/dist/src/utils/plugin-authoring-capabilities.d.ts +0 -23
- package/dist/src/utils/plugin-authoring-capabilities.js +0 -37
- package/dist/src/utils/plugin-authoring-capabilities.js.map +0 -1
- package/dist/src/utils/plugin-authoring-capabilities.json +0 -92
- package/dist/src/utils/plugin-release.d.ts +0 -2
- package/dist/src/utils/plugin-release.js +0 -2
- package/dist/src/utils/plugin-release.js.map +0 -1
- package/dist/src/utils/skill-frontmatter-capabilities.d.ts +0 -201
- package/dist/src/utils/skill-frontmatter-capabilities.js +0 -5
- package/dist/src/utils/skill-frontmatter-capabilities.js.map +0 -1
- package/dist/src/utils/skill-frontmatter-capabilities.json +0 -200
- /package/dist/authoring/scripts/{check-plugin-versions.d.mts → remove-plugin.d.mts} +0 -0
|
@@ -1,374 +1,804 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
|
-
import { execFile } from 'node:child_process';
|
|
3
2
|
import os from 'node:os';
|
|
4
3
|
import path from 'node:path';
|
|
5
|
-
import { promisify } from 'node:util';
|
|
6
4
|
import fs from 'fs-extra';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
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;
|
|
28
40
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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}).`);
|
|
41
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.');
|
|
42
73
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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);
|
|
47
89
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
90
|
+
function displayFromPreparation(preparation) {
|
|
91
|
+
return {
|
|
92
|
+
catalogVersion: preparation.prepared.catalogVersion,
|
|
93
|
+
channel: preparation.prepared.channel,
|
|
94
|
+
pluginCount: preparation.prepared.pluginNames.length,
|
|
95
|
+
};
|
|
50
96
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
recordedVersion = assertStrictSemVer(legacy.catalogVersion, 'legacy attempted Catalog version');
|
|
60
|
-
}
|
|
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.');
|
|
61
105
|
}
|
|
62
|
-
|
|
63
|
-
|
|
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.');
|
|
64
112
|
}
|
|
65
|
-
const destination = attemptPath(workspaceRoot, recordedVersion);
|
|
66
|
-
await fs.ensureDir(path.dirname(destination));
|
|
67
|
-
if (await fs.pathExists(destination))
|
|
68
|
-
return;
|
|
69
|
-
await fs.rename(legacyPath, destination);
|
|
70
113
|
}
|
|
71
|
-
async function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
return result.stdout.trim();
|
|
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.');
|
|
80
121
|
}
|
|
81
|
-
|
|
82
|
-
|
|
122
|
+
else {
|
|
123
|
+
await publicationGit(repositoryRoot, [
|
|
124
|
+
'checkout', '--quiet', '--orphan', 'catalog-publication',
|
|
125
|
+
], env, 'publicationCommitFailed', 'Could not create the initial Catalog publication.');
|
|
83
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;
|
|
84
160
|
}
|
|
85
|
-
async function
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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.');
|
|
89
207
|
}
|
|
90
|
-
|
|
91
|
-
|
|
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.');
|
|
92
213
|
}
|
|
93
214
|
}
|
|
94
|
-
function
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
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
|
+
}
|
|
99
229
|
}
|
|
100
|
-
async function
|
|
101
|
-
await fs.ensureDir(path.dirname(filePath));
|
|
102
|
-
const temporary = path.join(path.dirname(filePath), `.${path.basename(filePath)}.${crypto.randomUUID()}.tmp`);
|
|
103
|
-
await fs.writeFile(temporary, `${JSON.stringify(value, null, 2)}\n`, { flag: 'wx', mode: 0o600 });
|
|
230
|
+
async function assertPathMissing(filePath) {
|
|
104
231
|
try {
|
|
105
|
-
await fs.
|
|
232
|
+
await fs.lstat(filePath);
|
|
106
233
|
}
|
|
107
234
|
catch (error) {
|
|
108
|
-
|
|
235
|
+
if (error.code === 'ENOENT')
|
|
236
|
+
return;
|
|
109
237
|
throw error;
|
|
110
238
|
}
|
|
239
|
+
throw new Error('Pending Catalog publication repository must not use alternate object stores.');
|
|
111
240
|
}
|
|
112
|
-
async function
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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.');
|
|
116
272
|
}
|
|
117
273
|
}
|
|
118
|
-
async function
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
await git(options.repoRoot, [
|
|
122
|
-
'archive', '--format=tar', `--output=${archivePath}`, options.sourceHead,
|
|
123
|
-
], options.env, 'Could not archive the committed source HEAD.');
|
|
124
|
-
const tarEnv = { ...options.env };
|
|
125
|
-
delete tarEnv.TAR_OPTIONS;
|
|
274
|
+
async function validatePersistentRepository(repositoryRoot, journal, env) {
|
|
275
|
+
const version = journal.display.catalogVersion;
|
|
276
|
+
let stats;
|
|
126
277
|
try {
|
|
127
|
-
|
|
128
|
-
env: tarEnv,
|
|
129
|
-
encoding: 'utf8',
|
|
130
|
-
maxBuffer: 16 * 1024 * 1024,
|
|
131
|
-
});
|
|
278
|
+
stats = await fs.lstat(repositoryRoot);
|
|
132
279
|
}
|
|
133
280
|
catch (error) {
|
|
134
|
-
throw new Error(
|
|
281
|
+
throw new Error(`Catalog ${version} pending publication repository is missing or damaged. Increase the Catalog version.`, { cause: error });
|
|
135
282
|
}
|
|
136
|
-
|
|
137
|
-
|
|
283
|
+
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
284
|
+
throw new Error(`Catalog ${version} pending publication repository is missing or damaged. Increase the Catalog version.`);
|
|
138
285
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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`);
|
|
143
305
|
try {
|
|
144
|
-
await
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
], {
|
|
150
|
-
cwd: workspace.workspaceRoot,
|
|
151
|
-
env,
|
|
152
|
-
encoding: 'utf8',
|
|
153
|
-
maxBuffer: 16 * 1024 * 1024,
|
|
154
|
-
});
|
|
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);
|
|
155
311
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (typeof error === 'object' && error !== null && 'stdout' in error && typeof error.stdout === 'string') {
|
|
159
|
-
try {
|
|
160
|
-
const result = JSON.parse(error.stdout);
|
|
161
|
-
details = (result.errors ?? [])
|
|
162
|
-
.map((entry) => typeof entry.message === 'string' ? entry.message : '')
|
|
163
|
-
.filter(Boolean)
|
|
164
|
-
.join('; ');
|
|
165
|
-
}
|
|
166
|
-
catch {
|
|
167
|
-
// Keep the public validator failure bounded to its plugin identity.
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
throw new Error(`Plugin ${plugin.manifest.name} failed public source validation before Catalog publication${details ? `: ${details}` : '.'}`);
|
|
312
|
+
finally {
|
|
313
|
+
await fs.remove(verificationRoot);
|
|
171
314
|
}
|
|
172
315
|
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
throw new Error(`Catalog ${version} pending publication repository is missing or damaged. Increase the Catalog version.`, { cause: error });
|
|
318
|
+
}
|
|
173
319
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
export async function runCatalogPublishCommand(options) {
|
|
183
|
-
if (options.json && !options.yes)
|
|
184
|
-
throw new Error('Catalog publish with --json requires --yes.');
|
|
185
|
-
if (!options.interactive && !options.yes)
|
|
186
|
-
throw new Error('Non-interactive Catalog publish requires --yes.');
|
|
187
|
-
const remote = options.remote ?? 'origin';
|
|
188
|
-
const branch = options.branch ?? 'catalog';
|
|
189
|
-
const env = sanitizedGitEnvironment(options.env);
|
|
190
|
-
const workspaceRoot = await fs.realpath(path.resolve(options.workspaceRoot));
|
|
191
|
-
const repoRoot = await git(workspaceRoot, ['rev-parse', '--show-toplevel'], env, 'Workspace must be inside a real Git worktree.');
|
|
192
|
-
const sourceHead = await git(repoRoot, ['rev-parse', '--verify', 'HEAD'], env, 'Workspace Git HEAD must be committed and not unborn.');
|
|
193
|
-
const status = await git(repoRoot, [
|
|
194
|
-
'status', '--porcelain=v1', '--untracked-files=all', '--ignore-submodules=none',
|
|
195
|
-
], env, 'Could not inspect the source worktree.');
|
|
196
|
-
if (status !== '')
|
|
197
|
-
throw new Error('Catalog publish requires the complete source Git worktree to be clean.');
|
|
198
|
-
const temporaryRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'aw-public-catalog-'));
|
|
199
|
-
let fetchUrl = '';
|
|
200
|
-
let pushUrl = '';
|
|
201
|
-
let safeFetchUrl = '';
|
|
202
|
-
let safePushUrl = '';
|
|
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');
|
|
203
326
|
try {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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.`);
|
|
209
336
|
}
|
|
210
|
-
|
|
211
|
-
await
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (!(await gitExit(repoRoot, ['check-ignore', '-q', markerPath], env))) {
|
|
219
|
-
throw new Error('Catalog publish state under .aw/publish must be ignored by Git. Add .aw/ to .gitignore.');
|
|
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;
|
|
220
345
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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;
|
|
225
362
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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.`);
|
|
244
408
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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.`);
|
|
253
520
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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,
|
|
260
530
|
});
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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.`);
|
|
267
623
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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.');
|
|
281
678
|
}
|
|
282
679
|
}
|
|
283
|
-
|
|
284
|
-
await
|
|
285
|
-
|
|
286
|
-
await git(repositoryRoot, ['checkout', '--quiet', '--orphan', 'catalog-publication'], env, 'Could not create the initial Catalog publication.');
|
|
287
|
-
await clearWorktree(repositoryRoot);
|
|
288
|
-
await fs.copy(prepared.outputRoot, repositoryRoot, { dereference: false });
|
|
289
|
-
await git(repositoryRoot, ['add', '--force', '--all'], env, 'Could not stage the Catalog publication tree.');
|
|
290
|
-
await git(repositoryRoot, [
|
|
291
|
-
'-c', 'user.name=AW Catalog Publisher',
|
|
292
|
-
'-c', 'user.email=catalog-publisher@agent-workflows.invalid',
|
|
293
|
-
'commit', '--quiet', '-m', `Catalog ${catalogVersion}`,
|
|
294
|
-
], env, 'Could not create the Catalog publication commit.');
|
|
295
|
-
const commit = await git(repositoryRoot, ['rev-parse', 'HEAD'], env, 'Could not resolve the Catalog publication commit.');
|
|
296
|
-
const parents = (await git(repositoryRoot, ['show', '-s', '--format=%P', commit], env, 'Could not verify the Catalog publication parent.')).split(/\s+/u).filter(Boolean);
|
|
297
|
-
if ((parent && (parents.length !== 1 || parents[0] !== parent)) || (!parent && parents.length !== 0)) {
|
|
298
|
-
throw new Error('Catalog publication commit has an invalid parent.');
|
|
299
|
-
}
|
|
300
|
-
const verificationRoot = path.join(temporaryRoot, 'verification');
|
|
301
|
-
await fs.ensureDir(verificationRoot);
|
|
302
|
-
await git(repositoryRoot, ['--work-tree', verificationRoot, 'checkout', '--quiet', commit, '--', '.'], env, 'Could not verify the Catalog publication commit tree.');
|
|
303
|
-
const committed = await validatePublishedCatalogSnapshot(verificationRoot);
|
|
304
|
-
if (committed.snapshotDigest !== prepared.snapshotDigest)
|
|
305
|
-
throw new Error('Catalog publication commit tree differs from the prepared snapshot.');
|
|
306
|
-
await git(repositoryRoot, [
|
|
307
|
-
'-c', 'user.name=AW Catalog Publisher',
|
|
308
|
-
'-c', 'user.email=catalog-publisher@agent-workflows.invalid',
|
|
309
|
-
'tag', '--annotate', tag, '--message', `Catalog ${catalogVersion}`,
|
|
310
|
-
], env, 'Could not create the annotated Catalog tag.');
|
|
311
|
-
const attemptedAt = new Date().toISOString();
|
|
312
|
-
const attempted = {
|
|
313
|
-
schemaVersion: 1,
|
|
314
|
-
state: 'attempted',
|
|
315
|
-
workspaceIdentity: digest(JSON.stringify({ repoRoot, workspaceRelative: path.relative(repoRoot, workspaceRoot) })),
|
|
316
|
-
catalogVersion,
|
|
317
|
-
sourceHead,
|
|
318
|
-
remote: { name: remote, identityDigest: remoteIdentityDigest },
|
|
319
|
-
branch,
|
|
320
|
-
tag,
|
|
321
|
-
preparedSnapshotDigest: prepared.snapshotDigest,
|
|
322
|
-
attemptedAt,
|
|
323
|
-
};
|
|
324
|
-
await writeJsonAtomic(markerPath, attempted);
|
|
325
|
-
const liveRefs = parseRemoteRefs(await git(repositoryRoot, [
|
|
326
|
-
'ls-remote', 'publish', branchRef, tagRef, `${tagRef}^{}`,
|
|
327
|
-
], env, 'Could not recheck the Catalog publication remote.'));
|
|
328
|
-
if ((liveRefs.get(branchRef) ?? null) !== parent || liveRefs.has(tagRef) || liveRefs.has(`${tagRef}^{}`)) {
|
|
329
|
-
throw new Error('Catalog remote changed during preparation. Increase the Catalog version before publishing again.');
|
|
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 });
|
|
330
683
|
}
|
|
331
684
|
try {
|
|
332
|
-
await
|
|
333
|
-
'push', '--atomic', 'publish', `${commit}:${branchRef}`, `${tagRef}:${tagRef}`,
|
|
334
|
-
], env, `Catalog atomic push failed or its result is uncertain. Do not retry ${catalogVersion}; increase the Catalog version.`);
|
|
685
|
+
state = await remoteRefState(repositoryPath, writeContext.pushUrl, writeContext.branchRef, tagRef, writeContext.env);
|
|
335
686
|
}
|
|
336
|
-
catch {
|
|
337
|
-
|
|
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 });
|
|
338
690
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if (publishedRefs.get(branchRef) !== commit || publishedRefs.get(`${tagRef}^{}`) !== commit) {
|
|
343
|
-
throw new Error(`Catalog publication result is uncertain. Do not retry ${catalogVersion}; run aw catalog version <higher>.`);
|
|
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.`);
|
|
344
694
|
}
|
|
345
|
-
await writeJsonAtomic(markerPath, { ...attempted, state: 'published', commit, publishedAt: new Date().toISOString() });
|
|
346
|
-
return {
|
|
347
|
-
command: 'catalog:publish',
|
|
348
|
-
ok: true,
|
|
349
|
-
catalogVersion,
|
|
350
|
-
channel: prepared.channel,
|
|
351
|
-
remote,
|
|
352
|
-
remoteUrl: safeFetchUrl,
|
|
353
|
-
fetchUrl: safeFetchUrl,
|
|
354
|
-
pushUrl: safePushUrl,
|
|
355
|
-
branch,
|
|
356
|
-
tag,
|
|
357
|
-
commit,
|
|
358
|
-
sourceHead,
|
|
359
|
-
pluginCount: prepared.pluginNames.length,
|
|
360
|
-
snapshotDigest: prepared.snapshotDigest,
|
|
361
|
-
};
|
|
362
695
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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.');
|
|
369
748
|
}
|
|
370
|
-
|
|
371
|
-
|
|
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
|
+
}
|
|
372
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;
|
|
373
803
|
}
|
|
374
804
|
//# sourceMappingURL=catalog-publish.js.map
|