@lesliechan721/aw 0.1.0-beta.73 → 0.1.0-beta.74
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-runtime-config.mjs +65 -43
- package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -1
- package/dist/authoring/scripts/add-skill.mjs +5 -14
- package/dist/authoring/scripts/add-skill.mjs.map +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +4 -28
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +2 -2
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +0 -1
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
- package/dist/authoring/scripts/validate-plugin.mjs +234 -1422
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/scripts/aw-skill-eval-materializer.d.ts +2 -0
- package/dist/scripts/aw-skill-eval-materializer.js +19 -80
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/test-plugin-scripts.js +6 -8
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- package/dist/src/commands/aw-capabilities.d.ts +1 -1
- package/dist/src/commands/aw-capabilities.js +2 -2
- package/dist/src/commands/aw-capabilities.js.map +1 -1
- package/dist/src/commands/dependency-operation-plan.js +3 -3
- package/dist/src/commands/dependency-operation-plan.js.map +1 -1
- package/dist/src/commands/deployment-confirmation.d.ts +4 -0
- package/dist/src/commands/deployment-confirmation.js +20 -0
- package/dist/src/commands/deployment-confirmation.js.map +1 -0
- package/dist/src/commands/managed-commands.js +4 -2
- package/dist/src/commands/managed-commands.js.map +1 -1
- package/dist/src/commands/offline-cleanup-evidence.d.ts +3 -1
- package/dist/src/commands/offline-cleanup-evidence.js +9 -4
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +6 -0
- package/dist/src/commands/operation-plan.js +29 -2
- package/dist/src/commands/operation-plan.js.map +1 -1
- package/dist/src/commands/options.d.ts +6 -2
- package/dist/src/commands/options.js +5 -4
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +29 -41
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-config-confirmation.js +5 -5
- package/dist/src/commands/public-config-confirmation.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.d.ts +47 -0
- package/dist/src/commands/public-lifecycle-result.js +119 -4
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/commands/public-lifecycle.d.ts +1 -0
- package/dist/src/commands/public-lifecycle.js +15 -2
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/public-plugin-query.d.ts +1 -0
- package/dist/src/commands/public-plugin-query.js +28 -8
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +12 -11
- package/dist/src/commands/rebuild-command.js +529 -769
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +21 -43
- package/dist/src/commands/rebuild-integration.js +306 -3600
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +13 -0
- package/dist/src/commands/rebuild-operations.js +60 -15
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +59 -0
- package/dist/src/commands/rebuild-platform-integration.js +1200 -0
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
- package/dist/src/commands/review-inspection.js +41 -4
- package/dist/src/commands/review-inspection.js.map +1 -1
- package/dist/src/commands/review-preparation.d.ts +2 -0
- package/dist/src/commands/review-preparation.js +23 -60
- package/dist/src/commands/review-preparation.js.map +1 -1
- package/dist/src/commands/skill-eval.js +1 -0
- package/dist/src/commands/skill-eval.js.map +1 -1
- package/dist/src/commands/status-v6.d.ts +3 -1
- package/dist/src/commands/status-v6.js +24 -15
- package/dist/src/commands/status-v6.js.map +1 -1
- package/dist/src/commands/targets-command.d.ts +9 -0
- package/dist/src/commands/targets-command.js +57 -6
- package/dist/src/commands/targets-command.js.map +1 -1
- package/dist/src/commands/write-commands.js +43 -28
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/constants.d.ts +2 -2
- package/dist/src/constants.js +2 -2
- package/dist/src/constants.js.map +1 -1
- package/dist/src/generators/local-plugin.js +59 -248
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/index.js +40 -14
- package/dist/src/index.js.map +1 -1
- package/dist/src/output/command-receipt.d.ts +1 -1
- package/dist/src/output/command-receipt.js +3 -1
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/native-consent.d.ts +2 -0
- package/dist/src/output/native-consent.js +5 -0
- package/dist/src/output/native-consent.js.map +1 -0
- package/dist/src/output/public-result.js +60 -0
- package/dist/src/output/public-result.js.map +1 -1
- package/dist/src/output/rebuild-progress.js +5 -5
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/output/receipt-projection.js +19 -2
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/platforms/capabilities.d.ts +10 -0
- package/dist/src/platforms/capabilities.js +158 -0
- package/dist/src/platforms/capabilities.js.map +1 -0
- package/dist/src/platforms/contracts.d.ts +338 -0
- package/dist/src/platforms/contracts.js +2 -0
- package/dist/src/platforms/contracts.js.map +1 -0
- package/dist/src/platforms/cursor-workspace-hook.d.ts +22 -0
- package/dist/src/platforms/cursor-workspace-hook.js +185 -0
- package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
- package/dist/src/platforms/discovery.d.ts +74 -0
- package/dist/src/platforms/discovery.js +582 -0
- package/dist/src/platforms/discovery.js.map +1 -0
- package/dist/src/platforms/gemini-activation.d.ts +36 -0
- package/dist/src/platforms/gemini-activation.js +331 -0
- package/dist/src/platforms/gemini-activation.js.map +1 -0
- package/dist/src/platforms/gemini-consent.d.ts +8 -0
- package/dist/src/platforms/gemini-consent.js +79 -0
- package/dist/src/platforms/gemini-consent.js.map +1 -0
- package/dist/src/platforms/identity.d.ts +4 -0
- package/dist/src/platforms/identity.js +22 -0
- package/dist/src/platforms/identity.js.map +1 -0
- package/dist/src/platforms/inspection-grok.d.ts +4 -0
- package/dist/src/platforms/inspection-grok.js +173 -0
- package/dist/src/platforms/inspection-grok.js.map +1 -0
- package/dist/src/platforms/inspection-native.d.ts +6 -0
- package/dist/src/platforms/inspection-native.js +379 -0
- package/dist/src/platforms/inspection-native.js.map +1 -0
- package/dist/src/platforms/inspection-pi.d.ts +4 -0
- package/dist/src/platforms/inspection-pi.js +212 -0
- package/dist/src/platforms/inspection-pi.js.map +1 -0
- package/dist/src/platforms/inspection.d.ts +13 -0
- package/dist/src/platforms/inspection.js +189 -0
- package/dist/src/platforms/inspection.js.map +1 -0
- package/dist/src/platforms/layout.d.ts +21 -0
- package/dist/src/platforms/layout.js +239 -0
- package/dist/src/platforms/layout.js.map +1 -0
- package/dist/src/platforms/lifecycle-native-services.d.ts +3 -0
- package/dist/src/platforms/lifecycle-native-services.js +147 -0
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
- package/dist/src/platforms/lifecycle-native.d.ts +9 -0
- package/dist/src/platforms/lifecycle-native.js +252 -0
- package/dist/src/platforms/lifecycle-native.js.map +1 -0
- package/dist/src/platforms/lifecycle.d.ts +25 -0
- package/dist/src/platforms/lifecycle.js +452 -0
- package/dist/src/platforms/lifecycle.js.map +1 -0
- package/dist/src/platforms/managed-command-placement.d.ts +8 -0
- package/dist/src/platforms/managed-command-placement.js +79 -0
- package/dist/src/platforms/managed-command-placement.js.map +1 -0
- package/dist/src/platforms/projection-code-extension.d.ts +8 -0
- package/dist/src/platforms/projection-code-extension.js +121 -0
- package/dist/src/platforms/projection-code-extension.js.map +1 -0
- package/dist/src/platforms/projection-command-resources.d.ts +7 -0
- package/dist/src/platforms/projection-command-resources.js +74 -0
- package/dist/src/platforms/projection-command-resources.js.map +1 -0
- package/dist/src/platforms/projection-files.d.ts +27 -0
- package/dist/src/platforms/projection-files.js +111 -0
- package/dist/src/platforms/projection-files.js.map +1 -0
- package/dist/src/platforms/projection-marketplace.d.ts +19 -0
- package/dist/src/platforms/projection-marketplace.js +42 -0
- package/dist/src/platforms/projection-marketplace.js.map +1 -0
- package/dist/src/platforms/projection.d.ts +10 -0
- package/dist/src/platforms/projection.js +446 -0
- package/dist/src/platforms/projection.js.map +1 -0
- package/dist/src/platforms/registry.d.ts +4 -0
- package/dist/src/platforms/registry.js +30 -0
- package/dist/src/platforms/registry.js.map +1 -0
- package/dist/src/platforms/supplement-layout.d.ts +16 -0
- package/dist/src/platforms/supplement-layout.js +31 -0
- package/dist/src/platforms/supplement-layout.js.map +1 -0
- package/dist/src/portable/commands.d.ts +7 -5
- package/dist/src/portable/commands.js +6 -1
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/materializer.d.ts +8 -6
- package/dist/src/portable/materializer.js +47 -245
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery-layout.js +2 -15
- package/dist/src/portable/recovery-layout.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +10 -1
- package/dist/src/portable/recovery.js +34 -8
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/recovery/coordinator.d.ts +4 -7
- package/dist/src/recovery/coordinator.js +151 -119
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/demand.d.ts +1 -1
- package/dist/src/recovery/demand.js +10 -42
- package/dist/src/recovery/demand.js.map +1 -1
- package/dist/src/recovery/joint-coordinator.js +112 -52
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/joint-demand.d.ts +4 -22
- package/dist/src/recovery/joint-demand.js +43 -40
- package/dist/src/recovery/joint-demand.js.map +1 -1
- package/dist/src/recovery/receipt.d.ts +23 -8
- package/dist/src/recovery/retirement.d.ts +1 -1
- package/dist/src/recovery/retirement.js +122 -29
- package/dist/src/recovery/retirement.js.map +1 -1
- package/dist/src/recovery/status.d.ts +13 -6
- package/dist/src/recovery/status.js +479 -79
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/recovery/types.d.ts +3 -3
- package/dist/src/review/platform-profile.d.ts +3 -0
- package/dist/src/review/platform-profile.js +16 -0
- package/dist/src/review/platform-profile.js.map +1 -0
- package/dist/src/review/review-profile.d.ts +1 -0
- package/dist/src/review/review-profile.js +8 -2
- package/dist/src/review/review-profile.js.map +1 -1
- package/dist/src/review/review-selection.d.ts +2 -11
- package/dist/src/review/review-selection.js +97 -71
- package/dist/src/review/review-selection.js.map +1 -1
- package/dist/src/review/review-types.d.ts +3 -0
- package/dist/src/review/review-types.js.map +1 -1
- package/dist/src/review/skill-materialization.d.ts +44 -9
- package/dist/src/review/skill-materialization.js +112 -136
- package/dist/src/review/skill-materialization.js.map +1 -1
- package/dist/src/review/source-binding.d.ts +8 -5
- package/dist/src/review/source-binding.js +99 -41
- package/dist/src/review/source-binding.js.map +1 -1
- package/dist/src/tui/agent-management.js +112 -10
- package/dist/src/tui/agent-management.js.map +1 -1
- package/dist/src/tui/agent-settings.d.ts +3 -0
- package/dist/src/tui/agent-settings.js +10 -11
- package/dist/src/tui/agent-settings.js.map +1 -1
- package/dist/src/tui/console-app-v4.js +58 -20
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/content-item-card.js +2 -2
- package/dist/src/tui/content-item-card.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +198 -152
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +5 -9
- package/dist/src/tui/controller.js +40 -18
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/deployment-view.d.ts +10 -0
- package/dist/src/tui/deployment-view.js +91 -0
- package/dist/src/tui/deployment-view.js.map +1 -0
- package/dist/src/tui/glossary.js +4 -4
- package/dist/src/tui/glossary.js.map +1 -1
- package/dist/src/tui/model.d.ts +5 -0
- package/dist/src/tui/model.js +73 -12
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.js +2 -1
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
- package/dist/src/tui/operation-history.d.ts +5 -4
- package/dist/src/tui/operation-history.js.map +1 -1
- package/dist/src/tui/operation-review-planner.d.ts +7 -2
- package/dist/src/tui/operation-review-planner.js +97 -42
- package/dist/src/tui/operation-review-planner.js.map +1 -1
- package/dist/src/tui/plugin-content.d.ts +5 -3
- package/dist/src/tui/plugin-content.js +70 -508
- package/dist/src/tui/plugin-content.js.map +1 -1
- package/dist/src/tui/plugin-detail.d.ts +3 -2
- package/dist/src/tui/plugin-detail.js +33 -25
- package/dist/src/tui/plugin-detail.js.map +1 -1
- package/dist/src/tui/scoped-inventory.d.ts +10 -6
- package/dist/src/tui/scoped-inventory.js +34 -1
- package/dist/src/tui/scoped-inventory.js.map +1 -1
- package/dist/src/types.d.ts +4 -63
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.d.ts +10 -4
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-plan.d.ts +26 -2
- package/dist/src/utils/artifact-plan.js +113 -489
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +100 -93
- package/dist/src/utils/artifact-renderer.js +173 -346
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +21 -11
- package/dist/src/utils/artifact-request.js +56 -80
- package/dist/src/utils/artifact-request.js.map +1 -1
- package/dist/src/utils/bundle-layout.js +30 -146
- package/dist/src/utils/bundle-layout.js.map +1 -1
- package/dist/src/utils/catalog-digests.d.ts +2 -12
- package/dist/src/utils/catalog-digests.js +0 -39
- package/dist/src/utils/catalog-digests.js.map +1 -1
- package/dist/src/utils/catalog-source-references.d.ts +7 -0
- package/dist/src/utils/catalog-source-references.js +234 -19
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/codex-config-observation.d.ts +19 -0
- package/dist/src/utils/codex-config-observation.js +145 -0
- package/dist/src/utils/codex-config-observation.js.map +1 -0
- package/dist/src/utils/codex-executable-discovery.d.ts +2 -0
- package/dist/src/utils/codex-executable-discovery.js +47 -13
- package/dist/src/utils/codex-executable-discovery.js.map +1 -1
- package/dist/src/utils/codex-manager.js +1 -1
- package/dist/src/utils/codex-manager.js.map +1 -1
- package/dist/src/utils/codex-native-observation.d.ts +3 -0
- package/dist/src/utils/codex-native-observation.js +53 -0
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/codex-shared-native.d.ts +3 -1
- package/dist/src/utils/codex-shared-native.js +46 -5
- package/dist/src/utils/codex-shared-native.js.map +1 -1
- package/dist/src/utils/codex-skill-staging.d.ts +4 -3
- package/dist/src/utils/codex-skill-staging.js.map +1 -1
- package/dist/src/utils/codex-surface-analysis.d.ts +5 -2
- package/dist/src/utils/codex-surface-analysis.js +28 -57
- package/dist/src/utils/codex-surface-analysis.js.map +1 -1
- package/dist/src/utils/component-command-preparation.d.ts +34 -0
- package/dist/src/utils/component-command-preparation.js +228 -0
- package/dist/src/utils/component-command-preparation.js.map +1 -0
- package/dist/src/utils/component-resources.d.ts +43 -0
- package/dist/src/utils/component-resources.js +304 -0
- package/dist/src/utils/component-resources.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +17 -6
- package/dist/src/utils/dynamic-skill-tree.js +7 -3
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
- package/dist/src/utils/local-marketplace.d.ts +11 -44
- package/dist/src/utils/local-marketplace.js +11 -638
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/managed-command-evidence.d.ts +2 -2
- package/dist/src/utils/managed-command-evidence.js +5 -81
- package/dist/src/utils/managed-command-evidence.js.map +1 -1
- package/dist/src/utils/managed-command-materialization.d.ts +5 -2
- package/dist/src/utils/managed-command-materialization.js +35 -35
- package/dist/src/utils/managed-command-materialization.js.map +1 -1
- package/dist/src/utils/managed-command-preparation.d.ts +67 -0
- package/dist/src/utils/managed-command-preparation.js +146 -0
- package/dist/src/utils/managed-command-preparation.js.map +1 -0
- package/dist/src/utils/managed-command-review.d.ts +26 -0
- package/dist/src/utils/managed-command-review.js +68 -0
- package/dist/src/utils/managed-command-review.js.map +1 -0
- package/dist/src/utils/managed-command-store.js +26 -15
- package/dist/src/utils/managed-command-store.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +19 -0
- package/dist/src/utils/native-cli.js +45 -2
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/native-demand.d.ts +20 -1
- package/dist/src/utils/native-demand.js.map +1 -1
- package/dist/src/utils/native-tool-review.d.ts +3 -6
- package/dist/src/utils/native-tool-review.js +25 -11
- package/dist/src/utils/native-tool-review.js.map +1 -1
- package/dist/src/utils/ownership.d.ts +26 -3
- package/dist/src/utils/ownership.js +95 -9
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/paths.d.ts +1 -1
- package/dist/src/utils/paths.js +2 -0
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/platform-empty-state.d.ts +46 -0
- package/dist/src/utils/platform-empty-state.js +123 -0
- package/dist/src/utils/platform-empty-state.js.map +1 -0
- package/dist/src/utils/plugin-config-impact.d.ts +17 -11
- package/dist/src/utils/plugin-config-impact.js +46 -62
- package/dist/src/utils/plugin-config-impact.js.map +1 -1
- package/dist/src/utils/plugin-config-write.js +52 -53
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +0 -2
- package/dist/src/utils/plugin-config.js +0 -6
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-dependencies.d.ts +1 -1
- package/dist/src/utils/plugin-dependencies.js.map +1 -1
- package/dist/src/utils/runtime-config.d.ts +5 -7
- package/dist/src/utils/runtime-config.js +12 -25
- package/dist/src/utils/runtime-config.js.map +1 -1
- package/dist/src/utils/windows-npm-shim.js +19 -2
- package/dist/src/utils/windows-npm-shim.js.map +1 -1
- package/package.json +3 -3
- package/dist/src/utils/claude-native-render-receipt.d.ts +0 -14
- package/dist/src/utils/claude-native-render-receipt.js +0 -26
- package/dist/src/utils/claude-native-render-receipt.js.map +0 -1
- package/dist/src/utils/claude-skills-root.d.ts +0 -8
- package/dist/src/utils/claude-skills-root.js +0 -87
- package/dist/src/utils/claude-skills-root.js.map +0 -1
- package/dist/src/utils/codex-native-render-receipt.d.ts +0 -40
- package/dist/src/utils/codex-native-render-receipt.js +0 -205
- package/dist/src/utils/codex-native-render-receipt.js.map +0 -1
- package/dist/src/utils/slash-commands.d.ts +0 -1
- package/dist/src/utils/slash-commands.js +0 -2
- package/dist/src/utils/slash-commands.js.map +0 -1
|
@@ -1,505 +1,129 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { validatePortableSkillName } from './dynamic-skill-tree.js';
|
|
5
|
-
import { artifactDeclarationSurface, artifactRequestDeclarations, resolveArtifactRequest } from './artifact-request.js';
|
|
6
|
-
import { normalizeCommandDefinitions, normalizeCommandRelativeFile } from '@lesliechan721/aw-plugin-core/manifest';
|
|
7
|
-
const SUPPORTED_ARTIFACT_TARGETS = new Set([
|
|
8
|
-
'codex.developerInstructionsBlock',
|
|
9
|
-
'codex.agentRole',
|
|
10
|
-
'codex.skill',
|
|
11
|
-
'claude.skill',
|
|
12
|
-
'agent-skills.skill',
|
|
13
|
-
'aw.command-set',
|
|
14
|
-
'aw.command-package',
|
|
15
|
-
]);
|
|
16
|
-
const SUPPORTED_ARTIFACT_STATES = new Set(['present', 'disabled']);
|
|
17
|
-
const TARGET_ORDER = [
|
|
18
|
-
'codex.skill',
|
|
19
|
-
'claude.skill',
|
|
20
|
-
'agent-skills.skill',
|
|
21
|
-
'codex.developerInstructionsBlock',
|
|
22
|
-
'codex.agentRole',
|
|
23
|
-
];
|
|
24
|
-
const ARTIFACT_KIND_BY_TARGET = {
|
|
25
|
-
'codex.developerInstructionsBlock': 'instruction',
|
|
26
|
-
'codex.agentRole': 'codexRole',
|
|
27
|
-
'codex.skill': 'skill',
|
|
28
|
-
'claude.skill': 'skill',
|
|
29
|
-
'agent-skills.skill': 'skill',
|
|
30
|
-
'aw.command-set': 'commandSet',
|
|
31
|
-
'aw.command-package': 'commandPackage',
|
|
32
|
-
};
|
|
2
|
+
import { assertPlatformComponentPlan, normalizeCommandDefinitions, normalizeCommandRelativeFile, } from '@lesliechan721/aw-plugin-core/manifest';
|
|
3
|
+
import { resolveArtifactRequest } from './artifact-request.js';
|
|
33
4
|
function isRecord(value) {
|
|
34
5
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
35
6
|
}
|
|
36
|
-
function
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
return value;
|
|
49
|
-
}
|
|
50
|
-
function validateArtifactId(value, fieldName) {
|
|
51
|
-
if (!/^[A-Za-z][A-Za-z0-9_.-]*$/.test(value)) {
|
|
52
|
-
throw new Error(`Invalid ${fieldName}: expected a stable id using letters, numbers, ".", "_" or "-".`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function validateCodexRoleKey(value, fieldName) {
|
|
56
|
-
if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(value)) {
|
|
57
|
-
throw new Error(`Invalid ${fieldName}: expected a valid Codex role key.`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function validateCodexSkillKey(value, fieldName) {
|
|
61
|
-
if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(value)) {
|
|
62
|
-
throw new Error(`Invalid ${fieldName}: expected a valid Codex skill key.`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function stableStringify(value) {
|
|
66
|
-
if (Array.isArray(value)) {
|
|
67
|
-
return `[${value.map((entry) => stableStringify(entry)).join(',')}]`;
|
|
68
|
-
}
|
|
69
|
-
if (isRecord(value)) {
|
|
70
|
-
return `{${Object.keys(value)
|
|
71
|
-
.sort()
|
|
72
|
-
.map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`)
|
|
73
|
-
.join(',')}}`;
|
|
74
|
-
}
|
|
7
|
+
function keys(value, allowed, field) {
|
|
8
|
+
for (const key of Object.keys(value))
|
|
9
|
+
if (!allowed.includes(key))
|
|
10
|
+
throw new Error(`Invalid ${field}: unexpected field "${key}".`);
|
|
11
|
+
}
|
|
12
|
+
export function stableArtifactStringify(value) {
|
|
13
|
+
if (Array.isArray(value))
|
|
14
|
+
return `[${value.map(stableArtifactStringify).join(',')}]`;
|
|
15
|
+
if (isRecord(value))
|
|
16
|
+
return `{${Object.keys(value).filter((key) => value[key] !== undefined).sort()
|
|
17
|
+
.map((key) => `${JSON.stringify(key)}:${stableArtifactStringify(value[key])}`).join(',')}}`;
|
|
75
18
|
return JSON.stringify(value);
|
|
76
19
|
}
|
|
77
|
-
function
|
|
78
|
-
return `sha256:${crypto.createHash('sha256').update(
|
|
79
|
-
}
|
|
80
|
-
function resolvePlanObject(plan) {
|
|
81
|
-
if (!isRecord(plan)) {
|
|
82
|
-
throw new Error('Invalid artifact plan: expected a JSON object.');
|
|
83
|
-
}
|
|
84
|
-
assertAllowedObjectKeys(plan, 'artifact plan', ['version', 'artifacts']);
|
|
85
|
-
if (plan.version !== 2) {
|
|
86
|
-
throw new Error(`Invalid artifact plan version "${String(plan.version)}".`);
|
|
87
|
-
}
|
|
88
|
-
if (!Array.isArray(plan.artifacts)) {
|
|
89
|
-
throw new Error('Invalid artifact plan: "artifacts" must be an array.');
|
|
90
|
-
}
|
|
91
|
-
return plan;
|
|
92
|
-
}
|
|
93
|
-
function getDeclaredTargets(options) {
|
|
94
|
-
const output = new Map();
|
|
95
|
-
for (const [index, target] of artifactRequestDeclarations(options.manifest).entries()) {
|
|
96
|
-
if (target.platform) {
|
|
97
|
-
assertPlatformFieldSupported({
|
|
98
|
-
pluginName: options.manifest.name,
|
|
99
|
-
manifest: options.manifest,
|
|
100
|
-
fieldPath: `artifacts.targets[${index}].platform`,
|
|
101
|
-
requiredPlatform: target.platform,
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
if (artifactDeclarationSurface(target) !== options.platform || !target.scopes.includes(options.scope)) {
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
if (options.scope === 'project' &&
|
|
108
|
-
target.platform === 'codex' &&
|
|
109
|
-
targetRequiresCodexProjectConfig(target.target) &&
|
|
110
|
-
target.requiresCodexProjectConfig !== true) {
|
|
111
|
-
throw new Error(`Artifact "${target.id}" target "${target.target}" is missing requiresCodexProjectConfig for project scope.`);
|
|
112
|
-
}
|
|
113
|
-
output.set(`${target.id}:${target.target}`, target);
|
|
114
|
-
}
|
|
115
|
-
return output;
|
|
116
|
-
}
|
|
117
|
-
function normalizeRefreshKeys(options) {
|
|
118
|
-
if (!Array.isArray(options.value)) {
|
|
119
|
-
throw new Error(`Invalid ${options.fieldName}: expected an array.`);
|
|
120
|
-
}
|
|
121
|
-
const declaredKeys = options.declaration.refreshKeys;
|
|
122
|
-
const declaredKeySet = new Set(declaredKeys);
|
|
123
|
-
const seen = new Set();
|
|
124
|
-
for (const [index, key] of options.value.entries()) {
|
|
125
|
-
const refreshKey = ensureNonEmptyString(key, `${options.fieldName}[${index}]`);
|
|
126
|
-
if (!declaredKeySet.has(refreshKey)) {
|
|
127
|
-
throw new Error(`Invalid ${options.fieldName}[${index}]: "${refreshKey}" is not declared for artifact "${options.declaration.id}".`);
|
|
128
|
-
}
|
|
129
|
-
if (seen.has(refreshKey)) {
|
|
130
|
-
throw new Error(`Invalid ${options.fieldName}[${index}]: duplicate refresh key "${refreshKey}".`);
|
|
131
|
-
}
|
|
132
|
-
seen.add(refreshKey);
|
|
133
|
-
}
|
|
134
|
-
for (const refreshKey of declaredKeys) {
|
|
135
|
-
if (!seen.has(refreshKey)) {
|
|
136
|
-
throw new Error(`Invalid ${options.fieldName}: artifact "${options.declaration.id}" must preserve declared refresh key "${refreshKey}".`);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return declaredKeys.slice();
|
|
140
|
-
}
|
|
141
|
-
function validateDisabledReason(value, fieldName) {
|
|
142
|
-
if (value === undefined) {
|
|
143
|
-
return undefined;
|
|
144
|
-
}
|
|
145
|
-
return ensureNonEmptyString(value, fieldName);
|
|
146
|
-
}
|
|
147
|
-
function validateInstructionArtifactContent(value, fieldName) {
|
|
148
|
-
return ensureNonEmptyString(value, fieldName);
|
|
149
|
-
}
|
|
150
|
-
function validateRoleArtifactContent(value, fieldName, roleKey) {
|
|
151
|
-
if (!isRecord(value)) {
|
|
152
|
-
throw new Error(`Invalid ${fieldName}: expected an object.`);
|
|
153
|
-
}
|
|
154
|
-
assertAllowedObjectKeys(value, fieldName, ['registration', 'roleFile']);
|
|
155
|
-
const registrationValue = value.registration;
|
|
156
|
-
if (registrationValue !== undefined) {
|
|
157
|
-
if (!isRecord(registrationValue)) {
|
|
158
|
-
throw new Error(`Invalid ${fieldName}.registration: expected an object.`);
|
|
159
|
-
}
|
|
160
|
-
if (Object.hasOwn(registrationValue, 'config_file')) {
|
|
161
|
-
throw new Error(`Invalid ${fieldName}.registration.config_file: this field is reserved for AW-managed output.`);
|
|
162
|
-
}
|
|
163
|
-
assertAllowedObjectKeys(registrationValue, `${fieldName}.registration`, ['description']);
|
|
164
|
-
if (registrationValue.description !== undefined &&
|
|
165
|
-
(typeof registrationValue.description !== 'string' || registrationValue.description.trim() === '')) {
|
|
166
|
-
throw new Error(`Invalid ${fieldName}.registration.description: expected a non-empty string.`);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
const roleFileValue = value.roleFile;
|
|
170
|
-
if (!isRecord(roleFileValue)) {
|
|
171
|
-
throw new Error(`Invalid ${fieldName}.roleFile: expected an object.`);
|
|
172
|
-
}
|
|
173
|
-
assertAllowedObjectKeys(roleFileValue, `${fieldName}.roleFile`, [
|
|
174
|
-
'name',
|
|
175
|
-
'description',
|
|
176
|
-
'developer_instructions',
|
|
177
|
-
'model',
|
|
178
|
-
'model_reasoning_effort',
|
|
179
|
-
]);
|
|
180
|
-
const roleFileName = ensureNonEmptyString(roleFileValue.name, `${fieldName}.roleFile.name`);
|
|
181
|
-
validateCodexRoleKey(roleFileName, `${fieldName}.roleFile.name`);
|
|
182
|
-
if (roleFileName !== roleKey) {
|
|
183
|
-
throw new Error(`Invalid ${fieldName}.roleFile.name: expected "${roleKey}" to match the declared roleKey.`);
|
|
184
|
-
}
|
|
185
|
-
if (roleFileValue.description !== undefined &&
|
|
186
|
-
(typeof roleFileValue.description !== 'string' || roleFileValue.description.trim() === '')) {
|
|
187
|
-
throw new Error(`Invalid ${fieldName}.roleFile.description: expected a non-empty string.`);
|
|
188
|
-
}
|
|
189
|
-
ensureNonEmptyString(roleFileValue.developer_instructions, `${fieldName}.roleFile.developer_instructions`);
|
|
190
|
-
if (roleFileValue.model !== undefined &&
|
|
191
|
-
(typeof roleFileValue.model !== 'string' || roleFileValue.model.trim() === '')) {
|
|
192
|
-
throw new Error(`Invalid ${fieldName}.roleFile.model: expected a non-empty string.`);
|
|
193
|
-
}
|
|
194
|
-
if (roleFileValue.model_reasoning_effort !== undefined &&
|
|
195
|
-
(typeof roleFileValue.model_reasoning_effort !== 'string' ||
|
|
196
|
-
roleFileValue.model_reasoning_effort.trim() === '')) {
|
|
197
|
-
throw new Error(`Invalid ${fieldName}.roleFile.model_reasoning_effort: expected a non-empty string.`);
|
|
198
|
-
}
|
|
199
|
-
return value;
|
|
200
|
-
}
|
|
201
|
-
function validateSkillArtifactContent(value, fieldName) {
|
|
202
|
-
if (!isRecord(value)) {
|
|
203
|
-
throw new Error(`Invalid ${fieldName}: expected an object.`);
|
|
204
|
-
}
|
|
205
|
-
assertAllowedObjectKeys(value, fieldName, ['files']);
|
|
206
|
-
if (!isRecord(value.files)) {
|
|
207
|
-
throw new Error(`Invalid ${fieldName}.files: expected an object.`);
|
|
208
|
-
}
|
|
209
|
-
const files = {};
|
|
210
|
-
for (const [relativePath, content] of Object.entries(value.files)) {
|
|
211
|
-
if (relativePath.trim() === '' ||
|
|
212
|
-
relativePath.includes('\\') ||
|
|
213
|
-
relativePath.startsWith('/') ||
|
|
214
|
-
path.posix.normalize(relativePath) !== relativePath ||
|
|
215
|
-
relativePath.split('/').some((segment) => segment === '' || segment === '.' || segment === '..')) {
|
|
216
|
-
throw new Error(`Invalid ${fieldName}.files: "${relativePath}" must be a normalized POSIX path inside the skill root.`);
|
|
217
|
-
}
|
|
218
|
-
if (typeof content !== 'string') {
|
|
219
|
-
throw new Error(`Invalid ${fieldName}.files.${relativePath}: expected a string.`);
|
|
220
|
-
}
|
|
221
|
-
files[relativePath] = content;
|
|
222
|
-
}
|
|
223
|
-
const paths = Object.keys(files).sort();
|
|
224
|
-
for (const [index, relativePath] of paths.entries()) {
|
|
225
|
-
const conflictingPrefix = paths
|
|
226
|
-
.slice(0, index)
|
|
227
|
-
.find((candidate) => relativePath.startsWith(`${candidate}/`));
|
|
228
|
-
if (conflictingPrefix) {
|
|
229
|
-
throw new Error(`Invalid ${fieldName}.files: file path "${conflictingPrefix}" conflicts with "${relativePath}".`);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return {
|
|
233
|
-
files,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
function targetRequiresCodexProjectConfig(target) {
|
|
237
|
-
return target === 'codex.developerInstructionsBlock' || target === 'codex.agentRole';
|
|
238
|
-
}
|
|
239
|
-
function normalizeArtifact(options) {
|
|
240
|
-
const fieldName = `artifacts[${options.index}]`;
|
|
241
|
-
if (!isRecord(options.artifact)) {
|
|
242
|
-
throw new Error(`Invalid ${fieldName}: expected an object.`);
|
|
243
|
-
}
|
|
244
|
-
const id = ensureNonEmptyString(options.artifact.id, `${fieldName}.id`);
|
|
245
|
-
validateArtifactId(id, `${fieldName}.id`);
|
|
246
|
-
const target = ensureNonEmptyString(options.artifact.target, `${fieldName}.target`);
|
|
247
|
-
if (!SUPPORTED_ARTIFACT_TARGETS.has(target)) {
|
|
248
|
-
throw new Error(`Invalid ${fieldName}.target: unsupported target "${target}".`);
|
|
249
|
-
}
|
|
250
|
-
const declaration = options.declarationMap.get(`${id}:${target}`);
|
|
251
|
-
if (!declaration) {
|
|
252
|
-
throw new Error(`Invalid ${fieldName}: artifact "${id}" target "${target}" is not declared for this surface/scope.`);
|
|
253
|
-
}
|
|
254
|
-
if (target === 'aw.command-set' || target === 'aw.command-package') {
|
|
255
|
-
assertAllowedObjectKeys(options.artifact, fieldName, target === 'aw.command-set'
|
|
256
|
-
? ['id', 'target', 'kind', 'platform', 'state', 'refreshKeys', 'entries', 'disabledReason']
|
|
257
|
-
: ['id', 'target', 'kind', 'state', 'refreshKeys', 'files']);
|
|
258
|
-
if (options.artifact.kind !== (target === 'aw.command-set' ? 'commandSet' : 'commandPackage')) {
|
|
259
|
-
throw new Error(`Invalid ${fieldName}.kind: unexpected command target kind.`);
|
|
260
|
-
}
|
|
261
|
-
if (declaration.platform ? options.artifact.platform !== declaration.platform : Object.hasOwn(options.artifact, 'platform')) {
|
|
262
|
-
throw new Error(`Invalid ${fieldName}.platform: command target must preserve its declared surface.`);
|
|
263
|
-
}
|
|
264
|
-
const state = options.artifact.state;
|
|
265
|
-
if ((state !== 'present' && state !== 'disabled') || !declaration.states.includes(state)) {
|
|
266
|
-
throw new Error(`Invalid ${fieldName}.state: state is not declared.`);
|
|
267
|
-
}
|
|
268
|
-
const refreshKeys = normalizeRefreshKeys({ value: options.artifact.refreshKeys, fieldName: `${fieldName}.refreshKeys`, declaration });
|
|
269
|
-
let normalized;
|
|
270
|
-
if (target === 'aw.command-set') {
|
|
271
|
-
if (declaration.platform !== undefined && declaration.platform !== 'codex' && declaration.platform !== 'claude') {
|
|
272
|
-
throw new Error(`Invalid ${fieldName}.platform: managed commands require a Native platform.`);
|
|
273
|
-
}
|
|
274
|
-
const entries = normalizeCommandDefinitions(options.artifact.entries, `${fieldName}.entries`);
|
|
275
|
-
if (state === 'disabled' && entries.length !== 0)
|
|
276
|
-
throw new Error(`Invalid ${fieldName}.entries: disabled sets must be empty.`);
|
|
277
|
-
if (state === 'present' && Object.hasOwn(options.artifact, 'disabledReason'))
|
|
278
|
-
throw new Error(`Invalid ${fieldName}.disabledReason: only disabled sets may include this field.`);
|
|
279
|
-
const disabledReason = validateDisabledReason(options.artifact.disabledReason, `${fieldName}.disabledReason`);
|
|
280
|
-
normalized = { id, target, kind: 'commandSet', ...(declaration.platform ? { platform: declaration.platform } : {}), state, refreshKeys, entries, ...(disabledReason ? { disabledReason } : {}) };
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
if (state !== 'present')
|
|
284
|
-
throw new Error(`Invalid ${fieldName}.state: command packages must be present.`);
|
|
285
|
-
const content = validateSkillArtifactContent({ files: options.artifact.files }, fieldName);
|
|
286
|
-
for (const [file, text] of Object.entries(content?.files ?? {})) {
|
|
287
|
-
normalizeCommandRelativeFile(file, `${fieldName}.files`);
|
|
288
|
-
if (text.includes('\0') || Buffer.from(text, 'utf8').toString('utf8') !== text)
|
|
289
|
-
throw new Error(`Invalid ${fieldName}.files: generated configuration must be Unicode text without NUL.`);
|
|
290
|
-
}
|
|
291
|
-
normalized = { id, target, kind: 'commandPackage', state: 'present', refreshKeys, files: content?.files ?? {} };
|
|
292
|
-
}
|
|
293
|
-
return { ...normalized, declaration, logicalIdentity: `${options.pluginName}:${id}:${target}`, configDigest: createArtifactConfigDigest({ artifact: normalized, renderConfig: options.renderConfig, digestSalt: options.digestSalt }) };
|
|
294
|
-
}
|
|
295
|
-
assertAllowedObjectKeys(options.artifact, fieldName, target === 'codex.developerInstructionsBlock'
|
|
296
|
-
? ['id', 'platform', 'target', 'kind', 'state', 'refreshKeys', 'disabledReason', 'content']
|
|
297
|
-
: target === 'codex.agentRole'
|
|
298
|
-
? ['id', 'platform', 'target', 'kind', 'state', 'refreshKeys', 'disabledReason', 'roleKey', 'content']
|
|
299
|
-
: ['id', 'platform', ...(target === 'agent-skills.skill' ? ['distribution'] : []), 'target', 'kind', 'state', 'refreshKeys', 'disabledReason', 'skillKey', 'content']);
|
|
300
|
-
const surfaceField = 'platform';
|
|
301
|
-
const surface = ensureNonEmptyString(options.artifact.platform, `${fieldName}.platform`);
|
|
302
|
-
if (surface !== options.platform) {
|
|
303
|
-
throw new Error(`Invalid ${fieldName}.${surfaceField}: expected "${options.platform}" but received "${surface}".`);
|
|
304
|
-
}
|
|
305
|
-
const platform = surface;
|
|
306
|
-
const distribution = target === 'agent-skills.skill' ? 'agent-skills' : undefined;
|
|
307
|
-
if (distribution && options.artifact.distribution !== distribution) {
|
|
308
|
-
throw new Error(`Invalid ${fieldName}.distribution: expected "agent-skills".`);
|
|
309
|
-
}
|
|
310
|
-
const kind = ensureNonEmptyString(options.artifact.kind, `${fieldName}.kind`);
|
|
311
|
-
const expectedKind = declaration.kind ?? ARTIFACT_KIND_BY_TARGET[target];
|
|
312
|
-
if (kind !== expectedKind) {
|
|
313
|
-
throw new Error(`Invalid ${fieldName}.kind: expected "${expectedKind}" for target "${target}".`);
|
|
314
|
-
}
|
|
315
|
-
const state = ensureNonEmptyString(options.artifact.state, `${fieldName}.state`);
|
|
316
|
-
if (!SUPPORTED_ARTIFACT_STATES.has(state)) {
|
|
317
|
-
throw new Error(`Invalid ${fieldName}.state: unsupported state "${state}".`);
|
|
318
|
-
}
|
|
319
|
-
if (!declaration.states.includes(state)) {
|
|
320
|
-
throw new Error(`Invalid ${fieldName}.state: "${state}" is not declared for artifact "${id}".`);
|
|
321
|
-
}
|
|
322
|
-
const refreshKeys = normalizeRefreshKeys({
|
|
323
|
-
value: options.artifact.refreshKeys,
|
|
324
|
-
fieldName: `${fieldName}.refreshKeys`,
|
|
325
|
-
declaration,
|
|
326
|
-
});
|
|
327
|
-
const disabledReason = validateDisabledReason(options.artifact.disabledReason, `${fieldName}.disabledReason`);
|
|
328
|
-
const logicalIdentity = `${options.pluginName}:${id}:${target}`;
|
|
329
|
-
if (target === 'codex.developerInstructionsBlock') {
|
|
330
|
-
const content = state === 'present'
|
|
331
|
-
? validateInstructionArtifactContent(options.artifact.content, `${fieldName}.content`)
|
|
332
|
-
: undefined;
|
|
333
|
-
const normalized = {
|
|
334
|
-
id,
|
|
335
|
-
kind: 'instruction',
|
|
336
|
-
platform,
|
|
337
|
-
target,
|
|
338
|
-
state,
|
|
339
|
-
refreshKeys,
|
|
340
|
-
...(disabledReason === undefined ? {} : { disabledReason }),
|
|
341
|
-
...(content === undefined ? {} : { content }),
|
|
342
|
-
};
|
|
343
|
-
return {
|
|
344
|
-
...normalized,
|
|
345
|
-
declaration,
|
|
346
|
-
logicalIdentity,
|
|
347
|
-
configDigest: createArtifactConfigDigest({
|
|
348
|
-
artifact: normalized,
|
|
349
|
-
renderConfig: options.renderConfig,
|
|
350
|
-
digestSalt: options.digestSalt,
|
|
351
|
-
}),
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
if (target === 'codex.skill' || target === 'claude.skill' || target === 'agent-skills.skill') {
|
|
355
|
-
const skillKey = ensureNonEmptyString(options.artifact.skillKey, `${fieldName}.skillKey`);
|
|
356
|
-
if (target === 'agent-skills.skill')
|
|
357
|
-
validatePortableSkillName(skillKey, `${fieldName}.skillKey`);
|
|
358
|
-
else
|
|
359
|
-
validateCodexSkillKey(skillKey, `${fieldName}.skillKey`);
|
|
360
|
-
if (skillKey !== declaration.skillKey) {
|
|
361
|
-
throw new Error(`Invalid ${fieldName}.skillKey: expected "${declaration.skillKey}" from static metadata.`);
|
|
362
|
-
}
|
|
363
|
-
const content = state === 'present'
|
|
364
|
-
? validateSkillArtifactContent(options.artifact.content, `${fieldName}.content`)
|
|
365
|
-
: undefined;
|
|
366
|
-
const normalized = {
|
|
367
|
-
id,
|
|
368
|
-
kind: 'skill',
|
|
369
|
-
platform,
|
|
370
|
-
...(distribution ? { distribution } : {}),
|
|
371
|
-
target,
|
|
372
|
-
state,
|
|
373
|
-
skillKey,
|
|
374
|
-
refreshKeys,
|
|
375
|
-
...(disabledReason === undefined ? {} : { disabledReason }),
|
|
376
|
-
...(content === undefined ? {} : { content }),
|
|
377
|
-
};
|
|
378
|
-
return {
|
|
379
|
-
...normalized,
|
|
380
|
-
declaration,
|
|
381
|
-
logicalIdentity,
|
|
382
|
-
configDigest: createArtifactConfigDigest({
|
|
383
|
-
artifact: normalized,
|
|
384
|
-
renderConfig: options.renderConfig,
|
|
385
|
-
digestSalt: options.digestSalt,
|
|
386
|
-
}),
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
const roleKey = ensureNonEmptyString(options.artifact.roleKey, `${fieldName}.roleKey`);
|
|
390
|
-
validateCodexRoleKey(roleKey, `${fieldName}.roleKey`);
|
|
391
|
-
if (roleKey !== declaration.roleKey) {
|
|
392
|
-
throw new Error(`Invalid ${fieldName}.roleKey: expected "${declaration.roleKey}" from static metadata.`);
|
|
393
|
-
}
|
|
394
|
-
const content = state === 'present'
|
|
395
|
-
? validateRoleArtifactContent(options.artifact.content, `${fieldName}.content`, roleKey)
|
|
396
|
-
: undefined;
|
|
397
|
-
const normalized = {
|
|
398
|
-
id,
|
|
399
|
-
kind: 'codexRole',
|
|
400
|
-
platform,
|
|
401
|
-
target,
|
|
402
|
-
state,
|
|
403
|
-
roleKey,
|
|
404
|
-
refreshKeys,
|
|
405
|
-
...(disabledReason === undefined ? {} : { disabledReason }),
|
|
406
|
-
...(content === undefined ? {} : { content }),
|
|
407
|
-
};
|
|
408
|
-
return {
|
|
409
|
-
...normalized,
|
|
410
|
-
declaration,
|
|
411
|
-
logicalIdentity,
|
|
412
|
-
configDigest: createArtifactConfigDigest({
|
|
413
|
-
artifact: normalized,
|
|
414
|
-
renderConfig: options.renderConfig,
|
|
415
|
-
digestSalt: options.digestSalt,
|
|
416
|
-
}),
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
function artifactSortKey(artifact) {
|
|
420
|
-
const targetIndex = TARGET_ORDER.indexOf(artifact.target);
|
|
421
|
-
return [targetIndex === -1 ? TARGET_ORDER.length : targetIndex, artifact.id];
|
|
422
|
-
}
|
|
423
|
-
function resolveDigestSalt(options) {
|
|
424
|
-
return options.rendererDigest ??
|
|
425
|
-
options.manifestDigest ??
|
|
426
|
-
digestHex({
|
|
427
|
-
name: options.manifest.name,
|
|
428
|
-
version: options.manifest.version,
|
|
429
|
-
scripts: options.manifest.scripts?.artifacts?.render ?? null,
|
|
430
|
-
artifacts: options.manifest.artifacts?.targets ?? null,
|
|
431
|
-
});
|
|
20
|
+
export function artifactValueDigest(value) {
|
|
21
|
+
return `sha256:${crypto.createHash('sha256').update(stableArtifactStringify(value)).digest('hex')}`;
|
|
432
22
|
}
|
|
433
23
|
export function createArtifactConfigDigest(options) {
|
|
434
|
-
return
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
id: options.artifact.id,
|
|
440
|
-
refreshInputs: options.artifact.refreshKeys.map((key) => ({
|
|
441
|
-
key,
|
|
442
|
-
present: Object.hasOwn(options.renderConfig.values, key),
|
|
443
|
-
value: options.renderConfig.values[key],
|
|
444
|
-
source: options.renderConfig.sources[key],
|
|
445
|
-
issues: options.renderConfig.issues.filter((issue) => issue.key === key),
|
|
446
|
-
})),
|
|
447
|
-
});
|
|
24
|
+
return artifactValueDigest({ digestSalt: options.digestSalt, platform: options.artifact.platform,
|
|
25
|
+
distribution: options.artifact.distribution, target: options.artifact.target, id: options.artifact.id,
|
|
26
|
+
refreshInputs: options.artifact.refreshKeys.map((key) => ({ key,
|
|
27
|
+
present: Object.hasOwn(options.renderConfig.values, key), value: options.renderConfig.values[key],
|
|
28
|
+
source: options.renderConfig.sources[key], issues: options.renderConfig.issues.filter((issue) => issue.key === key) })) });
|
|
448
29
|
}
|
|
30
|
+
/** v2 is reserved for exact command requests. Five component kinds use v3 below. */
|
|
449
31
|
export function validateArtifactPlan(options) {
|
|
450
|
-
const
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
manifest: options.manifest,
|
|
458
|
-
platform: options.platform,
|
|
459
|
-
scope: options.scope,
|
|
460
|
-
requestedArtifactIds: options.requestedArtifactIds,
|
|
461
|
-
});
|
|
462
|
-
const requestedIds = new Set(request.requestedArtifactIds);
|
|
463
|
-
const declarationMap = new Map([...allDeclarations].filter(([, declaration]) => requestedIds.has(declaration.id)));
|
|
464
|
-
const parsedPlan = resolvePlanObject(options.plan);
|
|
465
|
-
const digestSalt = resolveDigestSalt({
|
|
466
|
-
manifest: options.manifest,
|
|
467
|
-
rendererDigest: options.rendererDigest,
|
|
468
|
-
manifestDigest: options.manifestDigest,
|
|
469
|
-
});
|
|
470
|
-
const artifacts = parsedPlan.artifacts.map((artifact, index) => normalizeArtifact({
|
|
471
|
-
artifact,
|
|
472
|
-
index,
|
|
473
|
-
platform: options.platform,
|
|
474
|
-
pluginName,
|
|
475
|
-
declarationMap,
|
|
476
|
-
renderConfig: options.renderConfig,
|
|
477
|
-
digestSalt,
|
|
478
|
-
}));
|
|
32
|
+
const request = resolveArtifactRequest(options);
|
|
33
|
+
const plan = options.plan;
|
|
34
|
+
if (!isRecord(plan))
|
|
35
|
+
throw new Error('Invalid command artifact plan: expected a JSON object.');
|
|
36
|
+
keys(plan, ['version', 'artifacts'], 'command artifact plan');
|
|
37
|
+
if (plan.version !== 2 || !Array.isArray(plan.artifacts))
|
|
38
|
+
throw new Error('Invalid command artifact plan: expected version 2 and artifacts array.');
|
|
479
39
|
const seen = new Set();
|
|
480
|
-
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
483
|
-
throw new Error(`Invalid
|
|
40
|
+
const artifacts = plan.artifacts.map((value, index) => {
|
|
41
|
+
const field = `artifacts[${index}]`;
|
|
42
|
+
if (!isRecord(value))
|
|
43
|
+
throw new Error(`Invalid ${field}: expected an object.`);
|
|
44
|
+
const declaration = request.declarations.find((entry) => entry.id === value.id);
|
|
45
|
+
if (!declaration || seen.has(declaration.id))
|
|
46
|
+
throw new Error(`Invalid ${field}: unexpected or duplicate command artifact ID.`);
|
|
47
|
+
seen.add(declaration.id);
|
|
48
|
+
const commandSet = declaration.target === 'aw.command-set';
|
|
49
|
+
keys(value, commandSet ? ['id', 'target', 'kind', 'platform', 'state', 'refreshKeys', 'entries', 'disabledReason']
|
|
50
|
+
: ['id', 'target', 'kind', 'state', 'refreshKeys', 'files'], field);
|
|
51
|
+
if (value.target !== declaration.target || value.kind !== declaration.kind)
|
|
52
|
+
throw new Error(`Invalid ${field}: target and kind must match the command request.`);
|
|
53
|
+
if (declaration.platform ? value.platform !== declaration.platform : Object.hasOwn(value, 'platform'))
|
|
54
|
+
throw new Error(`Invalid ${field}.platform: must match the command request.`);
|
|
55
|
+
if (!Array.isArray(value.refreshKeys) || value.refreshKeys.length !== declaration.refreshKeys.length
|
|
56
|
+
|| new Set(value.refreshKeys).size !== value.refreshKeys.length
|
|
57
|
+
|| declaration.refreshKeys.some((key) => !value.refreshKeys.includes(key)))
|
|
58
|
+
throw new Error(`Invalid ${field}.refreshKeys: must preserve declared keys.`);
|
|
59
|
+
if ((value.state !== 'present' && value.state !== 'disabled') || !declaration.states.includes(value.state))
|
|
60
|
+
throw new Error(`Invalid ${field}.state: state is not declared.`);
|
|
61
|
+
let artifact;
|
|
62
|
+
if (commandSet) {
|
|
63
|
+
const entries = normalizeCommandDefinitions(value.entries, `${field}.entries`);
|
|
64
|
+
if (value.state === 'disabled' && entries.length)
|
|
65
|
+
throw new Error(`Invalid ${field}.entries: disabled sets must be empty.`);
|
|
66
|
+
if (Object.hasOwn(value, 'disabledReason') && (value.state !== 'disabled' || typeof value.disabledReason !== 'string' || !value.disabledReason.trim()))
|
|
67
|
+
throw new Error(`Invalid ${field}.disabledReason.`);
|
|
68
|
+
artifact = { id: declaration.id, target: 'aw.command-set', kind: 'commandSet',
|
|
69
|
+
...(declaration.platform ? { platform: declaration.platform } : {}), state: value.state,
|
|
70
|
+
refreshKeys: [...declaration.refreshKeys], entries,
|
|
71
|
+
...(typeof value.disabledReason === 'string' ? { disabledReason: value.disabledReason } : {}) };
|
|
484
72
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
return leftTargetIndex - rightTargetIndex;
|
|
73
|
+
else {
|
|
74
|
+
if (value.state !== 'present' || !isRecord(value.files))
|
|
75
|
+
throw new Error(`Invalid ${field}: command packages require present state and files.`);
|
|
76
|
+
const files = Object.create(null);
|
|
77
|
+
for (const [file, text] of Object.entries(value.files)) {
|
|
78
|
+
normalizeCommandRelativeFile(file, `${field}.files`);
|
|
79
|
+
if (typeof text !== 'string' || text.includes('\0') || Buffer.from(text).toString('utf8') !== text)
|
|
80
|
+
throw new Error(`Invalid ${field}.files: expected Unicode text without NUL.`);
|
|
81
|
+
files[file] = text;
|
|
82
|
+
}
|
|
83
|
+
artifact = { id: declaration.id, target: 'aw.command-package', kind: 'commandPackage', state: 'present', refreshKeys: [...declaration.refreshKeys], files };
|
|
497
84
|
}
|
|
498
|
-
return
|
|
85
|
+
return { ...artifact, declaration, logicalIdentity: `${options.pluginName ?? options.manifest.name}:${declaration.id}:${declaration.target}`,
|
|
86
|
+
configDigest: createArtifactConfigDigest({ artifact, renderConfig: options.renderConfig,
|
|
87
|
+
digestSalt: options.rendererDigest ?? options.manifestDigest ?? artifactValueDigest(options.manifest) }) };
|
|
499
88
|
});
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
};
|
|
89
|
+
for (const id of request.requestedArtifactIds)
|
|
90
|
+
if (!seen.has(id))
|
|
91
|
+
throw new Error(`Invalid command artifact plan: missing requested artifact "${id}".`);
|
|
92
|
+
return { version: 2, artifacts };
|
|
93
|
+
}
|
|
94
|
+
export function validatePlatformComponentPlan(options) {
|
|
95
|
+
assertPlatformComponentPlan(options.plan, options);
|
|
96
|
+
return options.plan;
|
|
97
|
+
}
|
|
98
|
+
export function mergeExpectedComponentSets(sets) {
|
|
99
|
+
const expected = { components: [], omitted: [], unmet: [], sources: Object.create(null) };
|
|
100
|
+
const ids = new Set();
|
|
101
|
+
const names = new Set();
|
|
102
|
+
for (const set of sets) {
|
|
103
|
+
for (const entry of [...set.components, ...set.omitted, ...set.unmet]) {
|
|
104
|
+
if (ids.has(entry.id))
|
|
105
|
+
throw new Error(`componentIdentityConflict: duplicate component ID "${entry.id}".`);
|
|
106
|
+
ids.add(entry.id);
|
|
107
|
+
const source = set.sources[entry.id];
|
|
108
|
+
if (source !== 'static' && source !== 'dynamic')
|
|
109
|
+
throw new Error(`componentSourceInvalid: missing source for "${entry.id}".`);
|
|
110
|
+
expected.sources[entry.id] = source;
|
|
111
|
+
}
|
|
112
|
+
for (const component of set.components) {
|
|
113
|
+
const key = `${component.kind}:${component.name}`;
|
|
114
|
+
if (names.has(key))
|
|
115
|
+
throw new Error(`componentNameConflict: duplicate ${component.kind} name "${component.name}".`);
|
|
116
|
+
names.add(key);
|
|
117
|
+
}
|
|
118
|
+
expected.components.push(...set.components);
|
|
119
|
+
expected.omitted.push(...set.omitted);
|
|
120
|
+
expected.unmet.push(...set.unmet);
|
|
121
|
+
}
|
|
122
|
+
for (const gap of expected.unmet) {
|
|
123
|
+
if (gap.componentId && !expected.components.some((component) => component.id === gap.componentId && component.kind === 'instruction')) {
|
|
124
|
+
throw new Error(`componentGapInvalid: "${gap.id}" references an unavailable component.`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return expected;
|
|
504
128
|
}
|
|
505
129
|
//# sourceMappingURL=artifact-plan.js.map
|