@reqvire-org/ads 0.4.0 → 0.4.2
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/README.md +105 -86
- package/dist/a11y.mjs +108 -29
- package/dist/analysis/compiler-options.mjs +13 -0
- package/dist/analysis/context.mjs +46 -0
- package/dist/analysis/file-tree.mjs +52 -0
- package/dist/analysis/helpers.mjs +140 -0
- package/dist/analysis/impact.mjs +20 -0
- package/dist/analysis/inputs.mjs +15 -0
- package/dist/analysis/native-adapter.mjs +180 -0
- package/dist/analysis/native-project.mjs +323 -0
- package/dist/analysis/queries.mjs +133 -0
- package/dist/analysis/service.mjs +146 -0
- package/dist/analysis/standalone.mjs +57 -0
- package/dist/analysis/syntax.mjs +164 -0
- package/dist/analysis/worker.mjs +182 -0
- package/dist/assets.mjs +5 -5
- package/dist/atomic-composition.mjs +191 -70
- package/dist/atomic-trace.mjs +120 -50
- package/dist/behavior-libraries.mjs +106 -37
- package/dist/behaviors.mjs +219 -77
- package/dist/boundaries.mjs +135 -38
- package/dist/brand-assets.mjs +219 -47
- package/dist/brands.mjs +86 -27
- package/dist/bun-compiler.mjs +28 -14
- package/dist/bun-worker.mjs +7 -5
- package/dist/capture/worker.mjs +15 -4
- package/dist/capture-store.mjs +4 -2
- package/dist/capture.mjs +17 -14
- package/dist/check-service.mjs +40 -57
- package/dist/check.mjs +749 -188
- package/dist/cli.mjs +200 -99
- package/dist/color-values.mjs +21 -21
- package/dist/component-contrast.mjs +2 -2
- package/dist/config.mjs +303 -135
- package/dist/construction-styles.cjs +10 -0
- package/dist/control-padding.mjs +45 -25
- package/dist/css-values.mjs +3 -2
- package/dist/declarative-flow.mjs +209 -109
- package/dist/design-values.mjs +136 -51
- package/dist/development-runtime.mjs +4 -6
- package/dist/draft-boundary.mjs +11 -6
- package/dist/evidence.mjs +1 -1
- package/dist/finding-rules.mjs +7 -5
- package/dist/font-rules.mjs +2 -2
- package/dist/fonts-generated.mjs +2 -2
- package/dist/foundation-views.mjs +238 -0
- package/dist/foundation.mjs +63 -39
- package/dist/generated-entries.mjs +101 -34
- package/dist/icons.mjs +79 -32
- package/dist/image-attributes.mjs +109 -36
- package/dist/image-size.mjs +1 -1
- package/dist/index.mjs +0 -2
- package/dist/init.mjs +122 -41
- package/dist/investigations.mjs +2 -2
- package/dist/layers.mjs +298 -129
- package/dist/layout-widths.mjs +180 -85
- package/dist/linaria/preserve-values.cjs +7 -0
- package/dist/linaria/spatial-inputs.cjs +56 -0
- package/dist/lockup-composition.mjs +44 -0
- package/dist/lockup-model.cjs +64 -0
- package/dist/mcp/THIRD_PARTY_NOTICES.md +51 -1
- package/dist/mcp/apps.mjs +4 -30
- package/dist/mcp/behavior-pages.mjs +72 -24
- package/dist/mcp/build-status.mjs +257 -64
- package/dist/mcp/catalog.mjs +90 -26
- package/dist/mcp/context.mjs +17 -18
- package/dist/mcp/draft-discovery.mjs +44 -21
- package/dist/mcp/drafts.mjs +901 -281
- package/dist/mcp/execution-coordinator.mjs +417 -167
- package/dist/mcp/execution-results.mjs +7 -7
- package/dist/mcp/mutations.mjs +670 -234
- package/dist/mcp/preview-watch.mjs +448 -170
- package/dist/mcp/preview-widget.bundle.js +44 -50
- package/dist/mcp/prompts.mjs +5 -5
- package/dist/mcp/result-pages.mjs +1 -1
- package/dist/mcp/sandbox-host.mjs +1 -1
- package/dist/mcp/server.mjs +2402 -577
- package/dist/mcp/showcase-host.mjs +165 -41
- package/dist/mcp/skills.mjs +1 -1
- package/dist/mcp/text-diff.mjs +29 -10
- package/dist/paint-contracts.mjs +174 -81
- package/dist/palette-generated.mjs +2 -2
- package/dist/preview-bun.mjs +493 -187
- package/dist/preview-failure.mjs +1 -1
- package/dist/preview-files.mjs +13 -13
- package/dist/preview-imports.mjs +104 -55
- package/dist/preview-inputs.mjs +2 -2
- package/dist/preview-requests.mjs +24 -0
- package/dist/preview-resources.mjs +288 -147
- package/dist/preview-scope.mjs +5 -4
- package/dist/program-cache.mjs +8 -34
- package/dist/project-documents.mjs +1 -1
- package/dist/public-api.mjs +69 -31
- package/dist/public-props.mjs +39 -22
- package/dist/{browser-audit → render-audit}/axe-run.mjs +3 -3
- package/dist/{browser-audit → render-audit}/image-shape.mjs +2 -2
- package/dist/{browser-audit → render-audit}/layout-overflow.mjs +86 -23
- package/dist/{browser-audit → render-audit}/non-text-contrast.mjs +86 -27
- package/dist/{browser-audit → render-audit}/render-states.mjs +208 -52
- package/dist/{browser-audit → render-audit}/worker.mjs +86 -30
- package/dist/render-audit.mjs +828 -0
- package/dist/render-color-probe.mjs +96 -42
- package/dist/resource-limits.mjs +229 -97
- package/dist/runtime-contracts.mjs +467 -185
- package/dist/scenario-groups.mjs +22 -10
- package/dist/scenario-inspector.mjs +6 -43
- package/dist/scenario-program.mjs +8 -25
- package/dist/scenario-registry.mjs +72 -30
- package/dist/scenario-selectors.mjs +161 -64
- package/dist/scenario-slots.mjs +149 -56
- package/dist/scenario-trace.mjs +215 -109
- package/dist/scenarios-compiler.mjs +719 -378
- package/dist/scenarios-vite.d.mts +1 -3
- package/dist/scenarios-vite.mjs +2 -81
- package/dist/scenarios.mjs +421 -157
- package/dist/selector-match.mjs +2 -2
- package/dist/showcase/client.bundle.js +57 -56
- package/dist/showcase/draft-navigation.js +18 -0
- package/dist/showcase/favicon.ico +0 -0
- package/dist/showcase/favicon.svg +1 -0
- package/dist/showcase/foundation-view.css +55 -0
- package/dist/showcase/foundation-view.mjs +252 -0
- package/dist/showcase/guide-controls.ads.review.mjs +32 -0
- package/dist/showcase/icons.js +1 -145
- package/dist/showcase/index.html +3 -31
- package/dist/showcase/preview-frame.ads.review.css +46 -0
- package/dist/showcase/preview-frame.ads.review.d.mts +11 -0
- package/dist/showcase/preview-frame.ads.review.mjs +22 -0
- package/dist/showcase/preview-state.js +0 -9
- package/dist/showcase/refresh-scheduler.js +23 -0
- package/dist/showcase/style.css +5 -47
- package/dist/showcase/ui/ui.css +1353 -0
- package/dist/showcase/ui/ui.js +1062 -0
- package/dist/showcase-coverage.mjs +58 -37
- package/dist/skills/README.md +24 -23
- package/dist/skills/ads-designer/README.md +8 -2
- package/dist/skills/ads-designer/SKILL.md +130 -119
- package/dist/skills/ads-designer/references/accessibility.md +12 -13
- package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
- package/dist/skills/ads-designer/references/behaviors.md +30 -27
- package/dist/skills/ads-designer/references/branding.md +98 -10
- package/dist/skills/ads-designer/references/captures.md +25 -0
- package/dist/skills/ads-designer/references/cli.md +21 -24
- package/dist/skills/ads-designer/references/contracts.md +7 -6
- package/dist/skills/ads-designer/references/design-data.md +49 -52
- package/dist/skills/ads-designer/references/drafts.md +20 -17
- package/dist/skills/ads-designer/references/evidence.md +1 -5
- package/dist/skills/ads-designer/references/guarded-editing.md +14 -18
- package/dist/skills/ads-designer/references/layers.md +1 -1
- package/dist/skills/ads-designer/references/layout.md +347 -0
- package/dist/skills/ads-designer/references/mobile.md +2 -1
- package/dist/skills/{ads-motion/references/performance.md → ads-designer/references/motion-performance.md} +5 -1
- package/dist/skills/{ads-motion/references/build.md → ads-designer/references/motion.md} +73 -5
- package/dist/skills/ads-designer/references/review.md +37 -34
- package/dist/skills/ads-designer/references/runtimes.md +33 -30
- package/dist/skills/ads-designer/references/scenarios.md +16 -18
- package/dist/skills/{ads-break-ui/references/catalog.md → ads-designer/references/stress-catalog.md} +3 -1
- package/dist/skills/ads-designer/references/stress-test.md +68 -0
- package/dist/skills/ads-designer/references/validation.md +83 -75
- package/dist/skills/ads-designer/references/workflows.md +8 -33
- package/dist/skills/ads-import/SKILL.md +43 -325
- package/dist/skills/ads-import/references/atomic-styles.md +4 -4
- package/dist/skills/ads-import/references/behaviors.md +30 -27
- package/dist/skills/ads-import/references/branding.md +5 -5
- package/dist/skills/ads-import/references/captures.md +25 -0
- package/dist/skills/ads-import/references/cli.md +21 -24
- package/dist/skills/ads-import/references/compatibility.md +1 -1
- package/dist/skills/ads-import/references/contracts.md +7 -6
- package/dist/skills/ads-import/references/design-data.md +49 -52
- package/dist/skills/ads-import/references/drafts.md +20 -17
- package/dist/skills/ads-import/references/evidence.md +1 -5
- package/dist/skills/ads-import/references/guarded-editing.md +14 -18
- package/dist/skills/ads-import/references/implementation.md +2 -1
- package/dist/skills/ads-import/references/layers.md +1 -1
- package/dist/skills/ads-import/references/layout.md +347 -0
- package/dist/skills/ads-import/references/review.md +37 -34
- package/dist/skills/ads-import/references/runtimes.md +33 -30
- package/dist/skills/ads-import/references/scenarios.md +16 -18
- package/dist/skills/ads-import/references/tokens.md +3 -3
- package/dist/skills/ads-import/references/validation.md +83 -75
- package/dist/skills/ads-import/references/workflows.md +8 -33
- package/dist/skills/ads-migrate/SKILL.md +56 -0
- package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +602 -0
- package/dist/skills/ads-port/SKILL.md +54 -343
- package/dist/skills/ads-port/references/atomic-styles.md +4 -4
- package/dist/skills/ads-port/references/behaviors.md +30 -27
- package/dist/skills/ads-port/references/captures.md +25 -0
- package/dist/skills/ads-port/references/cli.md +21 -24
- package/dist/skills/ads-port/references/contracts.md +7 -6
- package/dist/skills/ads-port/references/design-data.md +49 -52
- package/dist/skills/ads-port/references/drafts.md +20 -17
- package/dist/skills/ads-port/references/evidence.md +1 -5
- package/dist/skills/ads-port/references/guarded-editing.md +14 -18
- package/dist/skills/ads-port/references/layers.md +1 -1
- package/dist/skills/ads-port/references/layout.md +347 -0
- package/dist/skills/ads-port/references/lint-and-docs.md +8 -11
- package/dist/skills/ads-port/references/native-implementation.md +2 -1
- package/dist/skills/ads-port/references/review.md +37 -34
- package/dist/skills/ads-port/references/runtimes.md +33 -30
- package/dist/skills/ads-port/references/scenarios.md +16 -18
- package/dist/skills/ads-port/references/validation.md +83 -75
- package/dist/skills/ads-port/references/workflows.md +8 -33
- package/dist/source-symbols.mjs +1 -8
- package/dist/source-values.mjs +266 -128
- package/dist/spatial-composition.mjs +322 -0
- package/dist/spatial-contexts.cjs +56 -0
- package/dist/spatial-css.cjs +351 -0
- package/dist/spatial-inputs.cjs +80 -0
- package/dist/spatial-metadata.mjs +18 -0
- package/dist/spatial-model.cjs +322 -0
- package/dist/spatial.mjs +21 -0
- package/dist/stage-timing.cjs +20 -0
- package/dist/starters/preact/design-system/patterns/Conversation/Conversation.tsx +105 -0
- package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +275 -0
- package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
- package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
- package/dist/starters/preact/design-system/showcase/mcp/main.ads.mount.tsx +8 -0
- package/dist/starters/preact/ds.config.json +25 -6
- package/dist/starters/preact/package.json +4 -8
- package/dist/starters/preact/tsconfig.json +4 -5
- package/dist/starters/preact/vite.config.ts +3 -3
- package/dist/starters/react/ADS.md +42 -47
- package/dist/starters/react/README.md +47 -49
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +18 -2
- package/dist/starters/react/design-system/components/Actions/IconButton/README.md +3 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/README.md +5 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +13 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +22 -0
- package/dist/starters/react/design-system/index.ts +2 -1
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +7 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +15 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +105 -0
- package/dist/starters/react/design-system/patterns/Conversation/README.md +9 -0
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +5 -0
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +21 -0
- package/dist/starters/react/design-system/patterns/Shell/README.md +43 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +5 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +21 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +274 -0
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -1
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
- package/dist/starters/react/design-system/review/index.ads.review.ts +4 -0
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +6 -0
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -1
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
- package/dist/starters/react/design-system/showcase/mcp/{main.tsx → main.ads.mount.tsx} +4 -2
- package/dist/starters/react/design-system/tokens/catalog.ads.json +1221 -0
- package/dist/starters/react/design-system/tokens/colors.css +1 -1
- package/dist/starters/react/design-system/tokens/spacing.css +22 -32
- package/dist/starters/react/design-system/tokens/spatial.ads.json +70 -0
- package/dist/starters/react/design-system/tokens/themes.generated.ts +1 -1
- package/dist/starters/react/ds.config.json +25 -6
- package/dist/starters/react/package.json +2 -6
- package/dist/starters/react/tsconfig.json +2 -3
- package/dist/starters/react/vite.config.ts +3 -3
- package/dist/style-boundaries.mjs +70 -25
- package/dist/task-cache.mjs +173 -72
- package/dist/task-worker.mjs +22 -11
- package/dist/test-boundaries.mjs +132 -59
- package/dist/themes-generated.mjs +1 -1
- package/dist/themes-watch.mjs +57 -22
- package/dist/themes.mjs +176 -73
- package/dist/token-export.mjs +39 -14
- package/dist/token-policy.mjs +6 -3
- package/dist/token-quality.mjs +6 -6
- package/dist/token-samples.mjs +16 -5
- package/dist/tokens.mjs +71 -26
- package/dist/ui-framework.mjs +16 -14
- package/dist/unit-contracts.mjs +251 -104
- package/dist/units.mjs +208 -98
- package/dist/usage.mjs +138 -38
- package/dist/validation-checks.mjs +115 -38
- package/dist/validation-inputs.mjs +187 -78
- package/dist/validation.mjs +268 -102
- package/dist/verification/browser.mjs +27 -5
- package/dist/verification.mjs +711 -187
- package/docs/ADS.md +90 -79
- package/docs/ARCHITECTURE.md +294 -136
- package/docs/BEHAVIORS.md +29 -25
- package/docs/CACHING.md +52 -17
- package/docs/CHANGELOG.md +309 -17
- package/docs/CONTRACTS.md +12 -4
- package/docs/DESIGN-REFERENCES.md +40 -0
- package/docs/GUIDE.md +270 -258
- package/docs/MCP.md +181 -324
- package/docs/SPATIAL-CHECKS.md +69 -0
- package/docs/benchmarks/README.md +39 -0
- package/package.json +42 -34
- package/dist/browser-audit.mjs +0 -429
- package/dist/create.mjs +0 -48
- package/dist/lint-config.mjs +0 -50
- package/dist/mcp/project-widget.bundle.js +0 -114
- package/dist/mcp/reports.mjs +0 -101
- package/dist/mcp/widget.bundle.js +0 -147
- package/dist/oxlint.mjs +0 -89
- package/dist/preview-builder.mjs +0 -133
- package/dist/preview-workers.mjs +0 -184
- package/dist/showcase.mjs +0 -77
- package/dist/skills/ads-break-ui/LICENSE.upstream +0 -21
- package/dist/skills/ads-break-ui/README.md +0 -16
- package/dist/skills/ads-break-ui/SKILL.md +0 -412
- package/dist/skills/ads-break-ui/agents/openai.yaml +0 -4
- package/dist/skills/ads-break-ui/references/atomic-styles.md +0 -293
- package/dist/skills/ads-break-ui/references/behaviors.md +0 -412
- package/dist/skills/ads-break-ui/references/captures.md +0 -135
- package/dist/skills/ads-break-ui/references/contracts.md +0 -317
- package/dist/skills/ads-break-ui/references/design-data.md +0 -354
- package/dist/skills/ads-break-ui/references/drafts.md +0 -194
- package/dist/skills/ads-break-ui/references/evidence.md +0 -128
- package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -165
- package/dist/skills/ads-break-ui/references/layers.md +0 -145
- package/dist/skills/ads-break-ui/references/reporting.md +0 -101
- package/dist/skills/ads-break-ui/references/review.md +0 -97
- package/dist/skills/ads-break-ui/references/runtimes.md +0 -203
- package/dist/skills/ads-break-ui/references/scenarios.md +0 -246
- package/dist/skills/ads-break-ui/references/validation.md +0 -166
- package/dist/skills/ads-break-ui/references/verification.md +0 -58
- package/dist/skills/ads-break-ui/references/workflows.md +0 -90
- package/dist/skills/ads-designer/references/reporting.md +0 -101
- package/dist/skills/ads-import/references/reporting.md +0 -101
- package/dist/skills/ads-motion/LICENSE.upstream +0 -21
- package/dist/skills/ads-motion/README.md +0 -22
- package/dist/skills/ads-motion/SKILL.md +0 -385
- package/dist/skills/ads-motion/agents/openai.yaml +0 -4
- package/dist/skills/ads-motion/references/atomic-styles.md +0 -293
- package/dist/skills/ads-motion/references/audit.md +0 -44
- package/dist/skills/ads-motion/references/behaviors.md +0 -412
- package/dist/skills/ads-motion/references/captures.md +0 -135
- package/dist/skills/ads-motion/references/contracts.md +0 -317
- package/dist/skills/ads-motion/references/design-data.md +0 -354
- package/dist/skills/ads-motion/references/drafts.md +0 -194
- package/dist/skills/ads-motion/references/evidence.md +0 -128
- package/dist/skills/ads-motion/references/guarded-editing.md +0 -165
- package/dist/skills/ads-motion/references/layers.md +0 -145
- package/dist/skills/ads-motion/references/motion-review.md +0 -35
- package/dist/skills/ads-motion/references/reporting.md +0 -101
- package/dist/skills/ads-motion/references/review.md +0 -97
- package/dist/skills/ads-motion/references/runtimes.md +0 -203
- package/dist/skills/ads-motion/references/scenarios.md +0 -246
- package/dist/skills/ads-motion/references/validation.md +0 -166
- package/dist/skills/ads-motion/references/verification.md +0 -39
- package/dist/skills/ads-motion/references/workflows.md +0 -90
- package/dist/skills/ads-port/references/reporting.md +0 -101
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +0 -76
- package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.tsx +0 -29
- package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +0 -137
- package/dist/starters/preact/design-system/showcase/mcp/main.tsx +0 -6
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +0 -12
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +0 -17
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +0 -75
- package/dist/starters/react/design-system/components/Layout/Grid/README.md +0 -21
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +0 -112
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.tsx +0 -29
- package/dist/starters/react/design-system/review/grid-cell/GridCell.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +0 -18
- package/dist/starters/react/design-system/review/index.ts +0 -6
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +0 -137
- package/dist/starters/react/design-system/showcase/mcp/index.html +0 -1
- package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +0 -124
- package/dist/starters/react/design-system/tokens/Color.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +0 -39
- package/dist/starters/react/design-system/tokens/Layout.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +0 -18
- package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +0 -30
- package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +0 -37
- package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +0 -29
- package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +0 -4
- package/dist/starters/react/package-lock.json +0 -4707
- package/dist/token-fixtures.mjs +0 -30
- package/docs/benchmarks/bun-previews.md +0 -91
- package/docs/benchmarks/preview-memory.md +0 -147
- package/docs/benchmarks/turbo-poc.md +0 -284
- package/docs/plans/execution-coordination.md +0 -57
- /package/dist/{browser-audit → render-audit}/first-render.mjs +0 -0
- /package/dist/{browser-audit → render-audit}/layout-shift.mjs +0 -0
package/dist/mcp/mutations.mjs
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
|
+
import { mapAsync } from "../analysis/queries.mjs";
|
|
1
2
|
import { trackExecutionWorkspace } from "./execution-context.mjs";
|
|
2
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
cpSync,
|
|
6
|
+
existsSync,
|
|
7
|
+
lstatSync,
|
|
8
|
+
mkdirSync,
|
|
9
|
+
mkdtempSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
readdirSync,
|
|
12
|
+
realpathSync,
|
|
13
|
+
renameSync,
|
|
14
|
+
rmSync,
|
|
15
|
+
symlinkSync,
|
|
16
|
+
writeFileSync,
|
|
17
|
+
} from "node:fs";
|
|
4
18
|
import path from "node:path";
|
|
5
19
|
import { hasProjectConfig } from "../project-boundary.mjs";
|
|
6
|
-
import ts from "
|
|
20
|
+
import ts from "../analysis/syntax.mjs";
|
|
7
21
|
import { isInside, loadConfig } from "../config.mjs";
|
|
8
|
-
import {
|
|
22
|
+
import { createVerificationController } from "../verification.mjs";
|
|
23
|
+
|
|
9
24
|
import { generateBrandAssets } from "../brand-assets.mjs";
|
|
10
25
|
import { applyFilePatch, parseUnifiedPatch } from "./patch.mjs";
|
|
11
|
-
import { createCaptureController
|
|
26
|
+
import { createCaptureController } from "../capture.mjs";
|
|
12
27
|
import { previewSourceRevision } from "../preview-inputs.mjs";
|
|
13
|
-
|
|
28
|
+
|
|
14
29
|
import { checkUnitCandidate, checkUnitFiles, inspectUnits, validateUnitId } from "../units.mjs";
|
|
15
30
|
import { acceptance, failure as evidenceFailure } from "../evidence.mjs";
|
|
16
31
|
import { checkCandidate, checkCommand, projectChecks as checks } from "../validation-checks.mjs";
|
|
@@ -19,41 +34,69 @@ import { validationInputFiles } from "../validation-inputs.mjs";
|
|
|
19
34
|
import { mutationLimits } from "./mutation-limits.mjs";
|
|
20
35
|
import { writeThemesCss } from "../themes-generated.mjs";
|
|
21
36
|
import { generatedEntries } from "../generated-entries.mjs";
|
|
22
|
-
|
|
37
|
+
|
|
38
|
+
import { analyze, registerAnalysisRevision, releaseAnalysisRevision, promoteAnalysisRevision } from "../analysis/service.mjs";
|
|
39
|
+
import { isAnalysisSource } from "../analysis/inputs.mjs";
|
|
23
40
|
|
|
24
41
|
export { mutationLimits } from "./mutation-limits.mjs";
|
|
25
|
-
const digest = bytes => `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
|
|
42
|
+
const digest = (bytes) => `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
|
|
26
43
|
const ignored = new Set([".git", ".ds", "node_modules", ".vite", "coverage", ".playwright-cli", "test-results", "output"]);
|
|
27
|
-
const textFile = file => /\.(?:[cm]?[jt]sx?|css|html|jsonc?|md|txt|svg)$/.test(file);
|
|
28
|
-
const setupDotfile = file => /^\.(?:oxlintrc|linariarc|babelrc)(?:\.json)?$/.test(file);
|
|
44
|
+
const textFile = (file) => /\.(?:[cm]?[jt]sx?|css|html|jsonc?|md|txt|svg)$/.test(file);
|
|
45
|
+
const setupDotfile = (file) => /^\.(?:oxlintrc|linariarc|babelrc)(?:\.json)?$/.test(file);
|
|
29
46
|
|
|
30
|
-
function fail(rule, message, file, boundary
|
|
31
|
-
|
|
47
|
+
function fail(rule, message, file, boundary) {
|
|
48
|
+
if (boundary === undefined) boundary = evidenceFailure("architecture", "mutation-policy", rule);
|
|
49
|
+
return Object.assign(new Error(message), { diagnostic: { rule, message, failure: boundary, ...(file ? { file } : {}) } });
|
|
32
50
|
}
|
|
33
51
|
|
|
34
52
|
function address(options, file) {
|
|
35
|
-
if (
|
|
53
|
+
if (
|
|
54
|
+
typeof file !== "string" ||
|
|
55
|
+
!file ||
|
|
56
|
+
file.includes("\\") ||
|
|
57
|
+
file.includes("\0") ||
|
|
58
|
+
file.split("/").some((part) => !part || part === "." || part === "..") ||
|
|
59
|
+
path.isAbsolute(file)
|
|
60
|
+
)
|
|
61
|
+
throw fail("mutation-path", "Use a canonical project-relative ADS file path.", file);
|
|
36
62
|
const target = path.resolve(options.root, file);
|
|
37
63
|
if (!isInside(options.root, target) || target === options.root) throw fail("mutation-path", "Mutation paths must stay inside the project.", file);
|
|
38
64
|
for (let current = options.root; ; ) {
|
|
39
65
|
const relative = path.relative(current, target).split(path.sep);
|
|
40
|
-
if (
|
|
66
|
+
if (
|
|
67
|
+
relative.some(
|
|
68
|
+
(part) =>
|
|
69
|
+
ignored.has(part) ||
|
|
70
|
+
(part.startsWith(".") && !setupDotfile(part) && !(part === ".gitkeep" && path.basename(target) === part && isInside(options.dsRoot, target))),
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
throw fail("mutation-path", "Hidden, dependency and generated paths are not editable.", file);
|
|
41
74
|
current = path.join(current, relative[0]);
|
|
42
75
|
const stat = lstatSync(current, { throwIfNoEntry: false });
|
|
43
|
-
if (stat?.isSymbolicLink() || stat && current !== target && !stat.isDirectory() || stat && current === target && (!stat.isFile() || stat.nlink !== 1))
|
|
76
|
+
if (stat?.isSymbolicLink() || (stat && current !== target && !stat.isDirectory()) || (stat && current === target && (!stat.isFile() || stat.nlink !== 1)))
|
|
77
|
+
throw fail("mutation-path", "Mutation paths must contain ordinary directories and unlinked regular files.", file);
|
|
44
78
|
if (current === target) break;
|
|
45
79
|
}
|
|
46
|
-
if (options.config.assets.generatedPaths.some(entry => isInside(path.resolve(options.root, entry), target)))
|
|
47
|
-
|
|
80
|
+
if (options.config.assets.generatedPaths.some((entry) => isInside(path.resolve(options.root, entry), target)))
|
|
81
|
+
throw fail("mutation-path", "Generated output is not editable.", file);
|
|
82
|
+
if (options.config.assets.generatedFiles.some((entry) => target === path.resolve(options.dsRoot, "assets", entry)))
|
|
83
|
+
throw fail("mutation-path", "Generated brand files are outputs; edit their source instead.", file);
|
|
48
84
|
return target;
|
|
49
85
|
}
|
|
50
86
|
|
|
51
87
|
export function readPatchFile(options, file) {
|
|
52
|
-
if (typeof file !== "string" || file.includes("\\") || file.includes("\0") || !/^\.ds\/patches\/[^/]+\.(?:patch|diff)$/.test(file))
|
|
88
|
+
if (typeof file !== "string" || file.includes("\\") || file.includes("\0") || !/^\.ds\/patches\/[^/]+\.(?:patch|diff)$/.test(file))
|
|
89
|
+
throw fail("mutation-patch", "Patch files must be regular .patch/.diff files in .ds/patches/.");
|
|
53
90
|
const target = path.join(options.root, file);
|
|
54
91
|
for (const current of [path.join(options.root, ".ds"), path.dirname(target), target]) {
|
|
55
92
|
const stat = lstatSync(current, { throwIfNoEntry: false });
|
|
56
|
-
if (
|
|
93
|
+
if (
|
|
94
|
+
!stat ||
|
|
95
|
+
stat.isSymbolicLink() ||
|
|
96
|
+
(current !== target && !stat.isDirectory()) ||
|
|
97
|
+
(current === target && (!stat.isFile() || stat.nlink !== 1 || stat.size > mutationLimits.patchFileBytes))
|
|
98
|
+
)
|
|
99
|
+
throw fail("mutation-patch", "Patch files must be real files no larger than 16 MiB.");
|
|
57
100
|
}
|
|
58
101
|
const bytes = readFileSync(target);
|
|
59
102
|
if (bytes.includes(0) || !Buffer.from(bytes.toString("utf8")).equals(bytes)) throw fail("mutation-patch", "Patch files must contain UTF-8 Git diff text.");
|
|
@@ -69,61 +112,92 @@ function read(options, file) {
|
|
|
69
112
|
return { path: file, exists: true, digest: digest(bytes), bytes: bytes.length, binary, content: binary ? bytes : bytes.toString("utf8") };
|
|
70
113
|
}
|
|
71
114
|
|
|
72
|
-
function validateContent(change, unit) {
|
|
115
|
+
async function validateContent(change, unit) {
|
|
73
116
|
if (change.content === null) return;
|
|
74
117
|
const bytes = Buffer.from(change.content);
|
|
75
118
|
if (bytes.length > mutationLimits.fileBytes) throw fail("mutation-content", "The patched file exceeds 16 MiB.", change.path);
|
|
76
|
-
if ((unit === "documentation" || textFile(change.path)) && (bytes.includes(0) || !Buffer.from(bytes.toString("utf8")).equals(bytes)))
|
|
119
|
+
if ((unit === "documentation" || textFile(change.path)) && (bytes.includes(0) || !Buffer.from(bytes.toString("utf8")).equals(bytes)))
|
|
120
|
+
throw fail("mutation-content", "Text source and documentation must contain valid UTF-8 without NUL bytes.", change.path);
|
|
77
121
|
if (/\.jsonc?$/.test(change.path)) {
|
|
78
|
-
const content=bytes.toString("utf8");
|
|
79
|
-
if (unit === "configuration" && !["package.json","ds.config.json"].includes(path.basename(change.path))) {
|
|
80
|
-
if (ts.parseConfigFileTextToJson(change.path,content).error)
|
|
81
|
-
|
|
122
|
+
const content = bytes.toString("utf8");
|
|
123
|
+
if (unit === "configuration" && !["package.json", "ds.config.json"].includes(path.basename(change.path))) {
|
|
124
|
+
if ((await ts.parseConfigFileTextToJson(change.path, content)).error)
|
|
125
|
+
throw fail("mutation-syntax", "Configuration must contain valid JSON/JSONC.", change.path);
|
|
126
|
+
} else {
|
|
127
|
+
try {
|
|
128
|
+
JSON.parse(content);
|
|
129
|
+
} catch {
|
|
130
|
+
throw fail("mutation-syntax", "JSON source and configuration must be valid JSON.", change.path);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
82
133
|
}
|
|
83
|
-
if (unit !== "configuration" && /\b(?:oxlint|eslint)-(?:disable|enable)|\bbiome-ignore|@ts-(?:ignore|nocheck|expect-error)/.test(bytes.toString("utf8")))
|
|
134
|
+
if (unit !== "configuration" && /\b(?:oxlint|eslint)-(?:disable|enable)|\bbiome-ignore|@ts-(?:ignore|nocheck|expect-error)/.test(bytes.toString("utf8")))
|
|
135
|
+
throw fail(
|
|
136
|
+
"mutation-policy",
|
|
137
|
+
"Configure reviewed lint/typecheck exceptions through the configuration unit instead of source suppression directives.",
|
|
138
|
+
change.path,
|
|
139
|
+
);
|
|
84
140
|
}
|
|
85
141
|
|
|
86
|
-
function candidateInputs(options,extraFiles=[]) {
|
|
87
|
-
try {
|
|
88
|
-
|
|
142
|
+
async function candidateInputs(options, extraFiles = [], onFile) {
|
|
143
|
+
try {
|
|
144
|
+
return await validationInputFiles(options, extraFiles, { maxFiles: mutationLimits.snapshotFiles, maxBytes: mutationLimits.snapshotBytes, onFile });
|
|
145
|
+
} catch (error) {
|
|
146
|
+
if (error.code === "ADS_INPUT_LIMIT") throw fail("mutation-snapshot", error.message);
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
89
149
|
}
|
|
90
|
-
function copyInputs(options, destination, extraFiles, {baseline=new Map(),changed=new Set(),budget={bytes:0,files:0}}={}) {
|
|
91
|
-
|
|
150
|
+
async function copyInputs(options, destination, extraFiles, { baseline = new Map(), changed = new Set(), budget = { bytes: 0, files: 0 }, contents } = {}) {
|
|
151
|
+
const buffers = new Map();
|
|
152
|
+
const inputs = await candidateInputs(options, extraFiles, (file, content) => buffers.set(file, content));
|
|
153
|
+
for (const [relative, value] of Object.entries(inputs)) {
|
|
92
154
|
if (baseline.has(relative)) continue;
|
|
93
|
-
if (relative==="installed-dependencies" || value===null) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
155
|
+
if (relative === "installed-dependencies" || value === null) {
|
|
156
|
+
baseline.set(relative, value);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const file = path.resolve(options.root, relative),
|
|
160
|
+
stat = lstatSync(file);
|
|
161
|
+
if (budget.files + 1 > mutationLimits.snapshotFiles || budget.bytes + stat.size > mutationLimits.snapshotBytes)
|
|
162
|
+
throw fail("mutation-snapshot", "Relevant inputs exceed the bounded validation snapshot limit.");
|
|
163
|
+
const content = buffers.get(relative);
|
|
164
|
+
budget.bytes += content.length;
|
|
165
|
+
budget.files++;
|
|
166
|
+
if (budget.bytes > mutationLimits.snapshotBytes) throw fail("mutation-snapshot", "Relevant inputs exceed the bounded validation snapshot limit.");
|
|
167
|
+
baseline.set(relative, digest(content));
|
|
168
|
+
if (contents && isAnalysisSource(relative)) contents.set(relative, content.toString("utf8"));
|
|
99
169
|
if (!changed.has(relative)) {
|
|
100
|
-
const target=path.join(destination,relative);
|
|
101
|
-
|
|
170
|
+
const target = path.join(destination, relative);
|
|
171
|
+
mkdirSync(path.dirname(target), { recursive: true });
|
|
172
|
+
writeFileSync(target, content, { mode: stat.mode });
|
|
102
173
|
}
|
|
103
174
|
}
|
|
104
175
|
return baseline;
|
|
105
176
|
}
|
|
106
177
|
|
|
107
|
-
function snapshot(options) {
|
|
178
|
+
async function snapshot(options) {
|
|
108
179
|
// Scan the entire *candidate* to detect checking commands that rewrite source,
|
|
109
180
|
// including files outside the input graph. Live projects are never copied here.
|
|
110
|
-
candidateInputs(options);
|
|
181
|
+
await candidateInputs(options);
|
|
111
182
|
const entries = [];
|
|
112
183
|
let bytes = 0;
|
|
113
|
-
const generated = options.config.assets.generatedPaths.map(file => path.resolve(options.root, file));
|
|
184
|
+
const generated = options.config.assets.generatedPaths.map((file) => path.resolve(options.root, file));
|
|
114
185
|
function walk(folder) {
|
|
115
186
|
for (const entry of readdirSync(folder, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
116
187
|
if (ignored.has(entry.name)) continue;
|
|
117
188
|
const file = path.join(folder, entry.name);
|
|
118
189
|
const relative = path.relative(options.root, file);
|
|
119
|
-
if (generated.some(base => isInside(base, file))) continue;
|
|
190
|
+
if (generated.some((base) => isInside(base, file))) continue;
|
|
120
191
|
if (entry.isSymbolicLink()) continue;
|
|
121
|
-
if (entry.isDirectory()) {
|
|
122
|
-
|
|
123
|
-
|
|
192
|
+
if (entry.isDirectory()) {
|
|
193
|
+
if (!hasProjectConfig(file)) walk(file);
|
|
194
|
+
} else if (entry.isFile()) {
|
|
195
|
+
if (bytes + lstatSync(file).size > mutationLimits.snapshotBytes || entries.length >= mutationLimits.snapshotFiles)
|
|
196
|
+
throw fail("mutation-snapshot", "Project source exceeds the bounded validation snapshot limit.");
|
|
124
197
|
const content = readFileSync(file);
|
|
125
198
|
bytes += content.length;
|
|
126
|
-
if (bytes > mutationLimits.snapshotBytes || entries.length >= mutationLimits.snapshotFiles)
|
|
199
|
+
if (bytes > mutationLimits.snapshotBytes || entries.length >= mutationLimits.snapshotFiles)
|
|
200
|
+
throw fail("mutation-snapshot", "Project source exceeds the bounded validation snapshot limit.");
|
|
127
201
|
entries.push([relative, digest(content)]);
|
|
128
202
|
}
|
|
129
203
|
}
|
|
@@ -135,15 +209,39 @@ function snapshot(options) {
|
|
|
135
209
|
return JSON.stringify(entries);
|
|
136
210
|
}
|
|
137
211
|
|
|
138
|
-
|
|
139
212
|
function mutationEvidence(result, candidateRevision) {
|
|
140
|
-
const diagnostics=(result.diagnostics??[]).map(diagnostic=>({
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
213
|
+
const diagnostics = (result.diagnostics ?? []).map((diagnostic) => ({
|
|
214
|
+
...diagnostic,
|
|
215
|
+
failure: diagnostic.failure ?? evidenceFailure("architecture", "mutation-policy", diagnostic.rule),
|
|
216
|
+
}));
|
|
217
|
+
const failed = diagnostics[0];
|
|
218
|
+
const accepted = acceptance(
|
|
219
|
+
"candidate-validation",
|
|
220
|
+
result.ok,
|
|
221
|
+
(result.checks ?? []).filter((check) => check.passed && !check.skipped).map((check) => check.name ?? [check.command, ...(check.args ?? [])].join(" ")),
|
|
222
|
+
["unregistered-checks", "unselected-behavior-checks", "post-application-preview-freshness", "visual-parity", "accessibility-audit"],
|
|
223
|
+
);
|
|
224
|
+
return {
|
|
225
|
+
...result,
|
|
226
|
+
...(result.diagnostics ? { diagnostics } : {}),
|
|
227
|
+
acceptance: accepted,
|
|
228
|
+
investigation: {
|
|
229
|
+
target: "candidate",
|
|
230
|
+
candidateRevision: candidateRevision ?? null,
|
|
231
|
+
...(failed
|
|
232
|
+
? {
|
|
233
|
+
failure: failed.failure,
|
|
234
|
+
failingStep: failed.failure.phase,
|
|
235
|
+
source: failed.file ? { file: failed.file, line: failed.line, column: failed.column } : null,
|
|
236
|
+
...(failed.command ? { command: failed.command, args: failed.args, exitCode: failed.exitCode, output: failed.output } : {}),
|
|
237
|
+
message: failed.message,
|
|
238
|
+
}
|
|
239
|
+
: {}),
|
|
240
|
+
acceptance: accepted,
|
|
241
|
+
},
|
|
242
|
+
};
|
|
144
243
|
}
|
|
145
244
|
|
|
146
|
-
|
|
147
245
|
export function createMutationController(directory, { captures = createCaptureController(directory), previewWork } = {}) {
|
|
148
246
|
// A passing dry run's audit holds for accepting the same candidate: remembered by its revision and selection.
|
|
149
247
|
const audits = new Map();
|
|
@@ -155,58 +253,149 @@ export function createMutationController(directory, { captures = createCaptureCo
|
|
|
155
253
|
return {
|
|
156
254
|
status() {
|
|
157
255
|
const options = loadConfig(root);
|
|
158
|
-
let commands = [],
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
256
|
+
let commands = [],
|
|
257
|
+
diagnostics = [];
|
|
258
|
+
try {
|
|
259
|
+
commands = checks(options).map((check) => [check.command, ...check.args].join(" "));
|
|
260
|
+
} catch (error) {
|
|
261
|
+
diagnostics = [error.diagnostic ?? { rule: "mutation-check", message: error.message }];
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
enabled: true,
|
|
265
|
+
scope: "one-ds-unit",
|
|
266
|
+
format: "git-unified-diff",
|
|
267
|
+
route: "draft",
|
|
268
|
+
drafts: {
|
|
269
|
+
create: "ads_create_draft",
|
|
270
|
+
edit: "ads_update_draft",
|
|
271
|
+
review: "ads_show_draft",
|
|
272
|
+
accept: "ads_accept",
|
|
273
|
+
maxUnits: mutationLimits.units,
|
|
274
|
+
finalCandidateChecks: true,
|
|
275
|
+
},
|
|
276
|
+
dsDir: options.config.dsDir,
|
|
277
|
+
limits: mutationLimits,
|
|
278
|
+
checks: ["ads check", ...commands, ...(options.config.framework ? ["managed production previews"] : [])],
|
|
279
|
+
diagnostics,
|
|
280
|
+
busy,
|
|
281
|
+
...(progress ? { progress } : {}),
|
|
282
|
+
lastResult,
|
|
283
|
+
};
|
|
284
|
+
},
|
|
285
|
+
cancel() {
|
|
286
|
+
active?.abort();
|
|
162
287
|
},
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
288
|
+
async units() {
|
|
289
|
+
return (await inspectUnits(loadConfig(root))).units;
|
|
290
|
+
},
|
|
291
|
+
async read(file, { offset = 0, limit = mutationLimits.readChars } = {}) {
|
|
292
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(limit) || limit < 1 || limit > mutationLimits.readChars)
|
|
293
|
+
throw fail("mutation-range", "Use a non-negative character offset and a limit between 1 and 12000.", file);
|
|
294
|
+
const options = loadConfig(root),
|
|
295
|
+
source = read(options, file);
|
|
296
|
+
const inventory = await inspectUnits(options),
|
|
297
|
+
unit = inventory.owner(inventory.relative(file));
|
|
298
|
+
if (!unit && inventory.relative(file) !== inventory.publicEntry && inventory.relative(file) !== inventory.reviewEntry)
|
|
299
|
+
throw fail("mutation-unit", "This file is outside the project's ADS and registered configuration/extension units.", file);
|
|
170
300
|
if (!source.exists) return { ...source, offset: 0, nextOffset: null, totalChars: 0, startLine: 1 };
|
|
171
|
-
if (source.binary)
|
|
301
|
+
if (source.binary)
|
|
302
|
+
return {
|
|
303
|
+
...source,
|
|
304
|
+
unit,
|
|
305
|
+
content: null,
|
|
306
|
+
note: "Binary asset: inspect its metadata or preview; edit using a Git binary patch, optionally through patchFile.",
|
|
307
|
+
};
|
|
172
308
|
if (offset > source.content.length) throw fail("mutation-range", "Read offset exceeds the current file length.", file);
|
|
173
|
-
const content = source.content.slice(offset, offset + limit),
|
|
174
|
-
|
|
175
|
-
|
|
309
|
+
const content = source.content.slice(offset, offset + limit),
|
|
310
|
+
end = offset + content.length;
|
|
311
|
+
return {
|
|
312
|
+
...source,
|
|
313
|
+
unit,
|
|
314
|
+
content,
|
|
315
|
+
offset,
|
|
316
|
+
nextOffset: end < source.content.length ? end : null,
|
|
317
|
+
totalChars: source.content.length,
|
|
318
|
+
startLine: source.content.slice(0, offset).split("\n").length,
|
|
319
|
+
};
|
|
176
320
|
},
|
|
177
|
-
async apply(
|
|
178
|
-
|
|
321
|
+
async apply(
|
|
322
|
+
{ unit, patch, patchFile, files, patches, checkRoot, previewHost: reviewedHost, dryRun = false },
|
|
323
|
+
signal,
|
|
324
|
+
notifyProgress,
|
|
325
|
+
{ beforeApply } = {},
|
|
326
|
+
) {
|
|
327
|
+
if (busy)
|
|
328
|
+
return mutationEvidence({
|
|
329
|
+
ok: false,
|
|
330
|
+
applied: false,
|
|
331
|
+
diagnostics: [
|
|
332
|
+
{
|
|
333
|
+
rule: "mutation-busy",
|
|
334
|
+
message: "Another mutation is validating; retry after it finishes.",
|
|
335
|
+
failure: evidenceFailure("runner", "mutation-execution", "ADS_MUTATION_BUSY"),
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
});
|
|
179
339
|
busy = true;
|
|
180
340
|
active = new AbortController();
|
|
181
341
|
signal = signal ? AbortSignal.any([signal, active.signal]) : active.signal;
|
|
182
342
|
let temporary, candidateRevision, releasePreview, releasePublication, previewHost;
|
|
183
|
-
|
|
343
|
+
const analysisRoots = new Set(),
|
|
344
|
+
analysisFiles = new Map();
|
|
345
|
+
let boundary = evidenceFailure("runner", "mutation-execution", "ADS_MUTATION_EXCEPTION", { certainty: "unclassified" });
|
|
184
346
|
const verified = [];
|
|
185
347
|
try {
|
|
186
348
|
const options = loadConfig(root);
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
349
|
+
if (
|
|
350
|
+
patches !== undefined &&
|
|
351
|
+
(unit !== undefined ||
|
|
352
|
+
patch !== undefined ||
|
|
353
|
+
patchFile !== undefined ||
|
|
354
|
+
!Array.isArray(patches) ||
|
|
355
|
+
patches.length < 2 ||
|
|
356
|
+
patches.length > mutationLimits.units)
|
|
357
|
+
)
|
|
358
|
+
throw fail("mutation-batch", `A transaction requires 2–${mutationLimits.units} distinct owner patches, without a top-level unit/patch.`);
|
|
359
|
+
const groups = patches ?? [{ unit, patch, patchFile, ...(files ? { files } : {}) }];
|
|
360
|
+
if (new Set(groups.map((group) => group.unit)).size !== groups.length)
|
|
361
|
+
throw fail("mutation-batch", "Use one patch per distinct unit in a transaction.");
|
|
192
362
|
let patchBytes = 0;
|
|
193
|
-
const plans = groups.map(group => {
|
|
363
|
+
const plans = groups.map((group) => {
|
|
194
364
|
validateUnitId(group.unit);
|
|
195
365
|
// A draft hands over its proposed files as they are; no diff round trip.
|
|
196
366
|
if (group.files !== undefined) {
|
|
197
|
-
if (
|
|
198
|
-
|
|
367
|
+
if (
|
|
368
|
+
group.patch !== undefined ||
|
|
369
|
+
group.patchFile !== undefined ||
|
|
370
|
+
!Array.isArray(group.files) ||
|
|
371
|
+
!group.files.length ||
|
|
372
|
+
group.files.length > mutationLimits.files
|
|
373
|
+
)
|
|
374
|
+
throw fail("mutation-batch", "Provide an owner's proposed files, or one patch, not both.");
|
|
375
|
+
return { unit: group.unit, entries: group.files.map((file) => ({ path: file.path, direct: true, content: file.content })) };
|
|
199
376
|
}
|
|
200
|
-
if ((typeof group.patch === "string") === (typeof group.patchFile === "string"))
|
|
201
|
-
|
|
377
|
+
if ((typeof group.patch === "string") === (typeof group.patchFile === "string"))
|
|
378
|
+
throw fail("mutation-patch", "Provide exactly one of patch or patchFile for each owner.");
|
|
379
|
+
const value = group.patchFile === undefined ? group.patch : readPatchFile(options, group.patchFile);
|
|
202
380
|
const maxPatch = group.patchFile === undefined ? mutationLimits.patchBytes : mutationLimits.patchFileBytes;
|
|
203
381
|
patchBytes += Buffer.byteLength(value ?? "");
|
|
204
|
-
if (
|
|
205
|
-
|
|
382
|
+
if (
|
|
383
|
+
typeof value !== "string" ||
|
|
384
|
+
value.includes("\0") ||
|
|
385
|
+
Buffer.from(value).toString("utf8") !== value ||
|
|
386
|
+
Buffer.byteLength(value) > maxPatch ||
|
|
387
|
+
patchBytes > mutationLimits.patchFileBytes
|
|
388
|
+
)
|
|
389
|
+
throw fail("mutation-patch", "Patch exceeds its UTF-8 Git diff size limit.");
|
|
390
|
+
return { unit: group.unit, entries: parseUnifiedPatch(value, mutationLimits.files) };
|
|
206
391
|
});
|
|
207
|
-
const units = groups.map(group => group.unit),
|
|
208
|
-
|
|
209
|
-
|
|
392
|
+
const units = groups.map((group) => group.unit),
|
|
393
|
+
configuration = units.includes("configuration"),
|
|
394
|
+
assets = units.some((unit) => unit.startsWith("assets"));
|
|
395
|
+
for (const plan of plans) for (const entry of plan.entries) address(options, entry.path);
|
|
396
|
+
const changes = [],
|
|
397
|
+
originals = [],
|
|
398
|
+
byPath = new Map();
|
|
210
399
|
const cache = path.join(root, ".ds");
|
|
211
400
|
mkdirSync(cache, { recursive: true });
|
|
212
401
|
if (realpathSync(cache) !== path.join(realpathSync(root), ".ds")) throw fail("mutation-path", "The .ds directory cannot resolve through a symlink.");
|
|
@@ -214,248 +403,495 @@ export function createMutationController(directory, { captures = createCaptureCo
|
|
|
214
403
|
trackExecutionWorkspace(temporary);
|
|
215
404
|
const candidate = path.join(temporary, "project");
|
|
216
405
|
mkdirSync(candidate);
|
|
217
|
-
const patchPaths=plans.flatMap(plan=>plan.entries.map(entry=>entry.path));
|
|
218
|
-
const copyBudget={bytes:0,files:0};
|
|
219
|
-
const copiedInputs=copyInputs(options,candidate,patchPaths,{budget:copyBudget});
|
|
406
|
+
const patchPaths = plans.flatMap((plan) => plan.entries.map((entry) => entry.path));
|
|
407
|
+
const copyBudget = { bytes: 0, files: 0 };
|
|
408
|
+
const copiedInputs = await copyInputs(options, candidate, patchPaths, { budget: copyBudget, contents: analysisFiles });
|
|
409
|
+
const registerAnalysis = async (viewRoot = candidate) => {
|
|
410
|
+
await registerAnalysisRevision(
|
|
411
|
+
root,
|
|
412
|
+
viewRoot,
|
|
413
|
+
analysisFiles,
|
|
414
|
+
changes
|
|
415
|
+
.filter((change) => isAnalysisSource(change.path))
|
|
416
|
+
.map((change) => [change.path, change.content === null ? null : Buffer.from(change.content).toString("utf8")]),
|
|
417
|
+
copiedInputs.get("installed-dependencies") ?? "",
|
|
418
|
+
signal,
|
|
419
|
+
);
|
|
420
|
+
analysisRoots.add(viewRoot);
|
|
421
|
+
};
|
|
220
422
|
const dependencies = path.join(root, "node_modules");
|
|
221
423
|
if (!existsSync(dependencies)) throw fail("mutation-check", "Install project dependencies before using guarded mutations.");
|
|
222
424
|
symlinkSync(realpathSync(dependencies), path.join(candidate, "node_modules"), process.platform === "win32" ? "junction" : "dir");
|
|
223
425
|
// The tooling repository's own scripts run dist/cli.mjs. Preserve that
|
|
224
426
|
// already-built runtime without treating generated output as source.
|
|
225
427
|
if (existsSync(path.join(root, "dist")) && !existsSync(path.join(candidate, "dist"))) {
|
|
226
|
-
let count = 0,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
428
|
+
let count = 0,
|
|
429
|
+
bytes = 0;
|
|
430
|
+
cpSync(path.join(root, "dist"), path.join(candidate, "dist"), {
|
|
431
|
+
recursive: true,
|
|
432
|
+
filter(file) {
|
|
433
|
+
const stat = lstatSync(file);
|
|
434
|
+
if (stat.isSymbolicLink()) throw fail("mutation-snapshot", "Generated runtime copies cannot contain symlinks.");
|
|
435
|
+
if (stat.isFile()) {
|
|
436
|
+
bytes += stat.size;
|
|
437
|
+
++count;
|
|
438
|
+
}
|
|
439
|
+
if (count > mutationLimits.snapshotFiles || bytes > mutationLimits.snapshotBytes)
|
|
440
|
+
throw fail("mutation-snapshot", "Generated runtime exceeds the validation snapshot limit.");
|
|
441
|
+
return true;
|
|
442
|
+
},
|
|
443
|
+
});
|
|
234
444
|
}
|
|
235
|
-
const entries = plans.flatMap(plan => plan.entries);
|
|
236
|
-
if (entries.some(entry => entry.binary)) {
|
|
237
|
-
const formats = new Set(entries.filter(entry=>entry.binary).map(entry=>entry.objectFormat));
|
|
445
|
+
const entries = plans.flatMap((plan) => plan.entries);
|
|
446
|
+
if (entries.some((entry) => entry.binary)) {
|
|
447
|
+
const formats = new Set(entries.filter((entry) => entry.binary).map((entry) => entry.objectFormat));
|
|
238
448
|
if (formats.size !== 1) throw fail("mutation-patch", "Binary blocks in one Git diff must use the same object format.");
|
|
239
449
|
await checkCommand("git", ["init", "--quiet", `--object-format=${[...formats][0]}`, candidate], root, signal);
|
|
240
450
|
}
|
|
241
451
|
for (const plan of plans) {
|
|
242
|
-
const current = loadConfig(candidate),
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
452
|
+
const current = loadConfig(candidate),
|
|
453
|
+
selected = await mapAsync(plan.entries, async (entry) => {
|
|
454
|
+
address(options, entry.path);
|
|
455
|
+
const before = read(current, entry.path);
|
|
456
|
+
if (!entry.binary && !entry.direct && before.binary) throw fail("mutation-patch", "Binary assets require a git diff --binary patch.", entry.path);
|
|
457
|
+
const change = {
|
|
458
|
+
path: entry.path,
|
|
459
|
+
originalContent: before.content,
|
|
460
|
+
content: entry.direct
|
|
461
|
+
? entry.content
|
|
462
|
+
: entry.binary
|
|
463
|
+
? entry.operation === "delete"
|
|
464
|
+
? null
|
|
465
|
+
: (before.content ?? Buffer.alloc(0))
|
|
466
|
+
: applyFilePatch(entry, before.content),
|
|
467
|
+
...(entry.binary ? { binaryPatch: entry.patch } : {}),
|
|
468
|
+
};
|
|
469
|
+
if (!entry.binary) await validateContent(change, plan.unit);
|
|
470
|
+
if (!byPath.has(entry.path)) {
|
|
471
|
+
const original = read(options, entry.path);
|
|
472
|
+
// The candidate copy and live inputs must agree before any changes.
|
|
473
|
+
if (original.digest !== before.digest)
|
|
474
|
+
throw fail("mutation-conflict", "Source changed while preparing validation; regenerate the patch.", entry.path);
|
|
475
|
+
originals.push({ ...original, mode: original.exists ? lstatSync(address(options, entry.path)).mode : undefined });
|
|
476
|
+
byPath.set(entry.path, changes.length);
|
|
477
|
+
changes.push({ ...change, expectedDigest: original.digest });
|
|
478
|
+
if (changes.length > mutationLimits.files)
|
|
479
|
+
throw fail("mutation-batch", `A transaction may change at most ${mutationLimits.files} distinct files.`);
|
|
480
|
+
}
|
|
481
|
+
return change;
|
|
482
|
+
});
|
|
483
|
+
const inventory = await checkUnitFiles(current, plan.unit, selected, await inspectUnits(current), true);
|
|
260
484
|
for (const change of selected) {
|
|
261
|
-
const file = path.join(candidate,change.path);
|
|
485
|
+
const file = path.join(candidate, change.path);
|
|
262
486
|
if (change.binaryPatch) {
|
|
263
|
-
for (const match of change.binaryPatch.matchAll(/^(?:literal|delta) (\d+)$/gm))
|
|
264
|
-
|
|
487
|
+
for (const match of change.binaryPatch.matchAll(/^(?:literal|delta) (\d+)$/gm))
|
|
488
|
+
if (Number(match[1]) > mutationLimits.fileBytes) throw fail("mutation-content", "Binary patch blocks exceed 16 MiB.", change.path);
|
|
489
|
+
await checkCommand("git", ["apply", "--binary", "--whitespace=nowarn", "-"], candidate, signal, change.binaryPatch);
|
|
265
490
|
change.content = existsSync(file) ? readFileSync(file) : null;
|
|
266
|
-
validateContent(change,plan.unit);
|
|
491
|
+
await validateContent(change, plan.unit);
|
|
267
492
|
} else if (change.content === null) rmSync(file);
|
|
268
|
-
else {
|
|
493
|
+
else {
|
|
494
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
495
|
+
writeFileSync(file, change.content);
|
|
496
|
+
}
|
|
269
497
|
changes[byPath.get(change.path)].content = change.content;
|
|
270
498
|
}
|
|
271
|
-
checkUnitCandidate(loadConfig(candidate),plan.unit,selected,inventory);
|
|
499
|
+
await checkUnitCandidate(loadConfig(candidate), plan.unit, selected, inventory);
|
|
272
500
|
}
|
|
273
501
|
// ADS removes an empty .gitkeep itself once accepted source is added beneath it.
|
|
274
|
-
for (const change of changes.filter(item => item.originalContent === null && item.content !== null)) {
|
|
275
|
-
for (
|
|
276
|
-
|
|
502
|
+
for (const change of changes.filter((item) => item.originalContent === null && item.content !== null)) {
|
|
503
|
+
for (
|
|
504
|
+
let directory = path.posix.dirname(change.path);
|
|
505
|
+
directory !== "." && isInside(options.dsRoot, path.join(root, directory)) && path.join(root, directory) !== options.dsRoot;
|
|
506
|
+
directory = path.posix.dirname(directory)
|
|
507
|
+
) {
|
|
508
|
+
const marker = `${directory}/.gitkeep`,
|
|
509
|
+
live = read(options, marker);
|
|
277
510
|
if (!live.exists || live.content !== "" || byPath.has(marker)) continue;
|
|
278
|
-
originals.push({...live,mode:lstatSync(address(options,marker)).mode});
|
|
279
|
-
byPath.set(marker,changes.length);
|
|
280
|
-
changes.push({path:marker,originalContent:"",content:null,expectedDigest:live.digest});
|
|
511
|
+
originals.push({ ...live, mode: lstatSync(address(options, marker)).mode });
|
|
512
|
+
byPath.set(marker, changes.length);
|
|
513
|
+
changes.push({ path: marker, originalContent: "", content: null, expectedDigest: live.digest });
|
|
281
514
|
// The live placeholder is part of the baseline the publication fences against.
|
|
282
|
-
copiedInputs.set(marker,digest(Buffer.from("")));
|
|
283
|
-
rmSync(path.join(candidate,marker),{force:true});
|
|
515
|
+
copiedInputs.set(marker, digest(Buffer.from("")));
|
|
516
|
+
rmSync(path.join(candidate, marker), { force: true });
|
|
284
517
|
}
|
|
285
518
|
}
|
|
519
|
+
const candidateOptions = loadConfig(candidate);
|
|
520
|
+
// A proposed configuration may add roots or explicit inputs. Preserve
|
|
521
|
+
// already patched files while bringing those additional live inputs in.
|
|
522
|
+
const proposedInputs = Object.keys(await validationInputFiles(candidateOptions));
|
|
523
|
+
await copyInputs(
|
|
524
|
+
{
|
|
525
|
+
root,
|
|
526
|
+
config: candidateOptions.config,
|
|
527
|
+
dsRoot: path.resolve(root, candidateOptions.config.dsDir),
|
|
528
|
+
sourceRoot: path.resolve(root, candidateOptions.config.sourceDir),
|
|
529
|
+
},
|
|
530
|
+
candidate,
|
|
531
|
+
[...patchPaths, ...proposedInputs],
|
|
532
|
+
{ baseline: copiedInputs, changed: new Set(changes.map((change) => change.path)), budget: copyBudget, contents: analysisFiles },
|
|
533
|
+
);
|
|
286
534
|
// Token sheet and theme/brand config changes carry the regenerated theme sheet with them,
|
|
287
535
|
// and exports file or token sheet changes carry the regenerated entries (barrels, styles entry).
|
|
288
536
|
{
|
|
289
537
|
const generatedOptions = loadConfig(candidate);
|
|
538
|
+
await registerAnalysis();
|
|
290
539
|
// Theme files first: the public barrel publishes the generated font preloads when they exist.
|
|
291
|
-
const themes = writeThemesCss(generatedOptions,
|
|
292
|
-
const barrels = generatedEntries(generatedOptions);
|
|
293
|
-
for (const barrel of barrels) {
|
|
540
|
+
const themes = writeThemesCss(generatedOptions, await analyze(candidate, "tokens", [], signal)).files;
|
|
541
|
+
const barrels = await generatedEntries(generatedOptions);
|
|
542
|
+
for (const barrel of barrels) {
|
|
543
|
+
mkdirSync(path.dirname(barrel.file), { recursive: true });
|
|
544
|
+
writeFileSync(barrel.file, barrel.text);
|
|
545
|
+
}
|
|
294
546
|
for (const generated of [...themes, ...barrels]) {
|
|
295
|
-
const relative = path.relative(candidate, generated.file).replaceAll("\\", "/"),
|
|
547
|
+
const relative = path.relative(candidate, generated.file).replaceAll("\\", "/"),
|
|
548
|
+
current = generated.text !== undefined && read(options, relative);
|
|
296
549
|
if (current && current.content !== generated.text) {
|
|
297
550
|
if (!byPath.has(relative)) {
|
|
298
|
-
originals.push({...current,mode:current.exists ? lstatSync(address(options,relative)).mode : undefined});
|
|
299
|
-
byPath.set(relative,changes.length);
|
|
300
|
-
changes.push({path:relative,originalContent:current.content,content:generated.text,expectedDigest:current.digest});
|
|
551
|
+
originals.push({ ...current, mode: current.exists ? lstatSync(address(options, relative)).mode : undefined });
|
|
552
|
+
byPath.set(relative, changes.length);
|
|
553
|
+
changes.push({ path: relative, originalContent: current.content, content: generated.text, expectedDigest: current.digest });
|
|
301
554
|
} else changes[byPath.get(relative)].content = generated.text;
|
|
302
555
|
}
|
|
303
556
|
}
|
|
304
557
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const proposedInputs = Object.keys(validationInputFiles(candidateOptions));
|
|
309
|
-
copyInputs({root,config:candidateOptions.config,dsRoot:path.resolve(root,candidateOptions.config.dsDir),sourceRoot:path.resolve(root,candidateOptions.config.sourceDir)},candidate,[...patchPaths,...proposedInputs],{baseline:copiedInputs,changed:new Set(changes.map(change=>change.path)),budget:copyBudget});
|
|
310
|
-
const inputPaths = [...new Set([...changes.map(change=>change.path),...Object.keys(validationInputFiles(candidateOptions))])];
|
|
311
|
-
const scopedInputs = () => {
|
|
558
|
+
await registerAnalysis();
|
|
559
|
+
const inputPaths = [...new Set([...changes.map((change) => change.path), ...Object.keys(await validationInputFiles(candidateOptions))])];
|
|
560
|
+
const scopedInputs = async () => {
|
|
312
561
|
const files = {};
|
|
313
|
-
for (const original of [options,candidateOptions]) {
|
|
314
|
-
const rebased = {
|
|
315
|
-
|
|
562
|
+
for (const original of [options, candidateOptions]) {
|
|
563
|
+
const rebased = {
|
|
564
|
+
root,
|
|
565
|
+
config: original.config,
|
|
566
|
+
dsRoot: path.resolve(root, original.config.dsDir),
|
|
567
|
+
sourceRoot: path.resolve(root, original.config.sourceDir),
|
|
568
|
+
};
|
|
569
|
+
Object.assign(files, await validationInputFiles(rebased, inputPaths));
|
|
316
570
|
}
|
|
317
|
-
return Object.fromEntries(Object.entries(files).sort(([a],[b])=>a.localeCompare(b)));
|
|
571
|
+
return Object.fromEntries(Object.entries(files).sort(([a], [b]) => a.localeCompare(b)));
|
|
318
572
|
};
|
|
319
|
-
const currentInputs = scopedInputs();
|
|
320
|
-
const before = JSON.stringify(Object.fromEntries(Object.keys(currentInputs).map(file=>[file,copiedInputs.get(file)??null])));
|
|
321
|
-
if (JSON.stringify(currentInputs) !== before)
|
|
573
|
+
const currentInputs = await scopedInputs();
|
|
574
|
+
const before = JSON.stringify(Object.fromEntries(Object.keys(currentInputs).map((file) => [file, copiedInputs.get(file) ?? null])));
|
|
575
|
+
if (JSON.stringify(currentInputs) !== before)
|
|
576
|
+
throw fail("mutation-conflict", "Relevant inputs changed while preparing validation; regenerate the patch.");
|
|
322
577
|
const extraChecks = checks(candidateOptions);
|
|
323
|
-
const expected = snapshot(candidateOptions);
|
|
324
|
-
candidateRevision=digest(Buffer.from(expected));
|
|
578
|
+
const expected = await snapshot(candidateOptions);
|
|
579
|
+
candidateRevision = digest(Buffer.from(expected));
|
|
325
580
|
if (previewWork) releasePreview = await previewWork.acquire(signal);
|
|
326
581
|
// A reviewed draft's workspace holds exactly this candidate's inputs at a stable path, so
|
|
327
582
|
// its warm check (and a remembered report from a dry run) applies; otherwise check the copy.
|
|
328
583
|
// Compared over the project's own inputs plus the changed files.
|
|
329
|
-
const compared = [...new Set([...Object.keys(validationInputFiles(options)), ...changes.map(change => change.path)])];
|
|
330
|
-
const pick = (digests) => JSON.stringify(compared.map(file => [file, digests[file] ?? null]));
|
|
331
|
-
const sameInputs =
|
|
584
|
+
const compared = [...new Set([...Object.keys(await validationInputFiles(options)), ...changes.map((change) => change.path)])];
|
|
585
|
+
const pick = (digests) => JSON.stringify(compared.map((file) => [file, digests[file] ?? null]));
|
|
586
|
+
const sameInputs =
|
|
587
|
+
checkRoot &&
|
|
588
|
+
existsSync(checkRoot) &&
|
|
589
|
+
pick(await validationInputFiles(loadConfig(checkRoot), compared)) === pick(await validationInputFiles(candidateOptions, compared));
|
|
332
590
|
// Browser checks of a reviewed draft render its workspace through the project's own host and
|
|
333
591
|
// compiler; only a candidate without one gets a preview host of its own.
|
|
334
|
-
const reviewRoot = sameInputs ? checkRoot : candidate,
|
|
592
|
+
const reviewRoot = sameInputs ? checkRoot : candidate,
|
|
593
|
+
sharedHost = sameInputs ? reviewedHost : undefined;
|
|
594
|
+
if (reviewRoot !== candidate) await registerAnalysis(reviewRoot);
|
|
335
595
|
const result = await checkCandidate(reviewRoot, signal, root);
|
|
336
|
-
verified.push({name:"ads check",passed:result.ok,cache:result.cache});
|
|
337
|
-
if (!result.ok)
|
|
596
|
+
verified.push({ name: "ads check", passed: result.ok, cache: result.cache });
|
|
597
|
+
if (!result.ok)
|
|
598
|
+
return (lastResult = mutationEvidence(
|
|
599
|
+
{ ok: false, applied: false, diagnostics: result.diagnostics, total: result.diagnostics.length, checks: verified },
|
|
600
|
+
candidateRevision,
|
|
601
|
+
));
|
|
338
602
|
if (assets || configuration) {
|
|
339
|
-
boundary=evidenceFailure("build","brand-assets","ADS_ASSET_BUILD");
|
|
603
|
+
boundary = evidenceFailure("build", "brand-assets", "ADS_ASSET_BUILD");
|
|
340
604
|
const brand = await generateBrandAssets(candidate);
|
|
341
605
|
verified.push({ name: "brand assets", passed: true, skipped: !!brand.skipped });
|
|
342
606
|
}
|
|
343
|
-
for (const [index,check] of extraChecks.entries()) {
|
|
344
|
-
progress={stage:"project-checks",completed:index,total:extraChecks.length,message
|
|
345
|
-
|
|
607
|
+
for (const [index, check] of extraChecks.entries()) {
|
|
608
|
+
progress = { stage: "project-checks", completed: index, total: extraChecks.length, message: `Checking ${check.command} ${check.args.join(" ")}` };
|
|
609
|
+
notifyProgress?.(progress);
|
|
610
|
+
verified.push(
|
|
611
|
+
await checkCommand(
|
|
612
|
+
check.command,
|
|
613
|
+
check.args,
|
|
614
|
+
candidate,
|
|
615
|
+
signal,
|
|
616
|
+
undefined,
|
|
617
|
+
{ category: "build", phase: `project-check:${check.args.at(-1)}` },
|
|
618
|
+
candidateOptions.config.mcp.mutationCheckTimeoutMs,
|
|
619
|
+
),
|
|
620
|
+
);
|
|
346
621
|
}
|
|
347
|
-
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
// candidate host that compiles only the selected scenarios.
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
622
|
+
// Acceptance checks the draft's owners themselves: their own behavior tests (acceptance.behavior)
|
|
623
|
+
// and their own scenarios' render audit (acceptance.audit). What the change reaches beyond them is
|
|
624
|
+
// ads_validate's to check. The audit reuses the candidate preview host built for browser behavior
|
|
625
|
+
// checks; on its own it starts a candidate host that compiles only the selected scenarios.
|
|
626
|
+
const behaviorUnits = candidateOptions.config.acceptance.behavior
|
|
627
|
+
? (await analyze(candidate, "behavior", [], signal)).contracts.map((contract) => contract.unit).filter((unit) => units.includes(unit))
|
|
628
|
+
: [];
|
|
629
|
+
const audit = candidateOptions.config.acceptance.audit ? await import("../render-audit.mjs") : null;
|
|
630
|
+
const auditSelection =
|
|
631
|
+
audit && (await analyze(candidate, "audit-selection", [changes.map((change) => change.path), { mode: "owners", owners: units }], signal));
|
|
632
|
+
// Previews are built only when a browser behavior check renders them.
|
|
633
|
+
if ((await analyze(candidate, "needs-browser", [behaviorUnits], signal)) && candidateOptions.config.framework) {
|
|
634
|
+
boundary = evidenceFailure("build", "preview-build", "ADS_PREVIEW_BUILD");
|
|
635
|
+
progress = { stage: "preview-build", message: "Building all candidate previews" };
|
|
636
|
+
notifyProgress?.(progress);
|
|
637
|
+
if (sharedHost) await sharedHost.buildAll(signal, { timeoutMs: candidateOptions.config.mcp.mutationCheckTimeoutMs });
|
|
357
638
|
else {
|
|
358
639
|
const { startAdsMcp } = await import("./server.mjs");
|
|
359
|
-
previewHost = await startAdsMcp(candidate, { stdio:false });
|
|
360
|
-
await previewHost.buildAll(signal, {timeoutMs:candidateOptions.config.mcp.mutationCheckTimeoutMs});
|
|
640
|
+
previewHost = await startAdsMcp(candidate, { stdio: false });
|
|
641
|
+
await previewHost.buildAll(signal, { timeoutMs: candidateOptions.config.mcp.mutationCheckTimeoutMs });
|
|
361
642
|
// Browser checks consume this immutable production graph. Keep its
|
|
362
643
|
// resources hosted, release its compiler, and leave Explorer live.
|
|
363
644
|
await previewHost.parkCompiler();
|
|
364
645
|
}
|
|
365
|
-
verified.push({ name:"managed production previews", passed:true });
|
|
646
|
+
verified.push({ name: "managed production previews", passed: true });
|
|
366
647
|
}
|
|
367
|
-
boundary=evidenceFailure("runner","behavior-verification","ADS_BEHAVIOR_SETUP");
|
|
648
|
+
boundary = evidenceFailure("runner", "behavior-verification", "ADS_BEHAVIOR_SETUP");
|
|
368
649
|
if (behaviorUnits.length) {
|
|
369
|
-
const verification = createVerificationController(reviewRoot, {
|
|
650
|
+
const verification = createVerificationController(reviewRoot, {
|
|
651
|
+
reportRoot: root,
|
|
652
|
+
previewHost: previewHost ?? sharedHost,
|
|
653
|
+
onProgress: (value) => {
|
|
654
|
+
progress = { stage: "behavior", ...value };
|
|
655
|
+
notifyProgress?.(progress);
|
|
656
|
+
},
|
|
657
|
+
});
|
|
370
658
|
let evidence;
|
|
371
|
-
try {
|
|
372
|
-
|
|
373
|
-
|
|
659
|
+
try {
|
|
660
|
+
evidence = await verification.run({ units: behaviorUnits, persist: false }, signal);
|
|
661
|
+
} finally {
|
|
662
|
+
await verification.close();
|
|
663
|
+
}
|
|
664
|
+
if (!evidence.ok)
|
|
665
|
+
return (lastResult = mutationEvidence(
|
|
666
|
+
{
|
|
667
|
+
ok: false,
|
|
668
|
+
applied: false,
|
|
669
|
+
diagnostics: [
|
|
670
|
+
...evidence.results
|
|
671
|
+
.filter((item) => item.status !== "passed")
|
|
672
|
+
.map((item) => ({ rule: "behavior-check", failure: item.failure, message: `${item.unit}#${item.check}: ${item.status}. ${item.message}` })),
|
|
673
|
+
...evidence.diagnostics,
|
|
674
|
+
],
|
|
675
|
+
checks: verified,
|
|
676
|
+
behavior: evidence,
|
|
677
|
+
},
|
|
678
|
+
candidateRevision,
|
|
679
|
+
));
|
|
374
680
|
verified.push({ name: "registered behavior checks", passed: true, results: evidence.results });
|
|
375
|
-
}
|
|
376
|
-
|
|
681
|
+
} else
|
|
682
|
+
verified.push({
|
|
683
|
+
name: "registered behavior checks",
|
|
684
|
+
skipped: true,
|
|
685
|
+
reason: candidateOptions.config.acceptance.behavior
|
|
686
|
+
? "The draft's owners register no behavior checks."
|
|
687
|
+
: "Turned off by acceptance.behavior: false.",
|
|
688
|
+
});
|
|
377
689
|
if (auditSelection) {
|
|
378
|
-
boundary=evidenceFailure("runner","
|
|
379
|
-
const selection = {
|
|
380
|
-
|
|
690
|
+
boundary = evidenceFailure("runner", "render-audit", "ADS_AUDIT_FAILED");
|
|
691
|
+
const selection = {
|
|
692
|
+
selection: auditSelection.mode,
|
|
693
|
+
...(auditSelection.reason ? { selectionReason: auditSelection.reason } : {}),
|
|
694
|
+
auditedScenarios: auditSelection.scenarios,
|
|
695
|
+
};
|
|
696
|
+
if (!auditSelection.scenarios.length)
|
|
697
|
+
verified.push({ name: "render-audit", skipped: true, reason: "No affected UI scenarios.", scenarios: 0, ...selection });
|
|
381
698
|
else {
|
|
382
|
-
progress={stage:"
|
|
383
|
-
|
|
699
|
+
progress = { stage: "render-audit", message: `Accessibility audit of ${auditSelection.scenarios.length} candidate scenarios` };
|
|
700
|
+
notifyProgress?.(progress);
|
|
701
|
+
const auditKey = `${candidateRevision}:${JSON.stringify(auditSelection.scenarios)}`,
|
|
702
|
+
remembered = audits.get(auditKey);
|
|
384
703
|
if (remembered) {
|
|
385
704
|
verified.push({ ...remembered.check, remembered: true });
|
|
386
|
-
if (!remembered.check.passed)
|
|
705
|
+
if (!remembered.check.passed)
|
|
706
|
+
return (lastResult = mutationEvidence(
|
|
707
|
+
{ ok: false, applied: false, diagnostics: remembered.diagnostics, total: remembered.diagnostics.length, checks: verified },
|
|
708
|
+
candidateRevision,
|
|
709
|
+
));
|
|
387
710
|
} else {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
711
|
+
let result;
|
|
712
|
+
try {
|
|
713
|
+
result = await audit.runRenderAudit(reviewRoot, {
|
|
714
|
+
scenarios: auditSelection.scenarios,
|
|
715
|
+
previewHost: previewHost ?? sharedHost,
|
|
716
|
+
signal,
|
|
717
|
+
onProgress: (value) => {
|
|
718
|
+
progress = value;
|
|
719
|
+
notifyProgress?.(value);
|
|
720
|
+
},
|
|
721
|
+
});
|
|
722
|
+
} catch (error) {
|
|
723
|
+
if (signal.aborted) throw error;
|
|
724
|
+
verified.push({ name: "render-audit", passed: false, ...selection });
|
|
725
|
+
return (lastResult = mutationEvidence(
|
|
726
|
+
{
|
|
727
|
+
ok: false,
|
|
728
|
+
applied: false,
|
|
729
|
+
diagnostics: [
|
|
730
|
+
{ rule: "render-audit", message: error.message, failure: evidenceFailure("runner", "render-audit", error.code ?? "ADS_AUDIT_FAILED") },
|
|
731
|
+
],
|
|
732
|
+
checks: verified,
|
|
733
|
+
},
|
|
734
|
+
candidateRevision,
|
|
735
|
+
));
|
|
736
|
+
}
|
|
737
|
+
const { routed, check } = audit.auditCheck(result, selection);
|
|
738
|
+
audits.set(auditKey, {
|
|
739
|
+
check,
|
|
740
|
+
diagnostics: routed.diagnostics.map((item) => ({ ...item, failure: evidenceFailure("assertion", "render-audit", item.rule) })),
|
|
741
|
+
});
|
|
742
|
+
while (audits.size > 16) audits.delete(audits.keys().next().value);
|
|
743
|
+
verified.push(check);
|
|
744
|
+
if (!check.passed)
|
|
745
|
+
return (lastResult = mutationEvidence(
|
|
746
|
+
{
|
|
747
|
+
ok: false,
|
|
748
|
+
applied: false,
|
|
749
|
+
diagnostics: routed.diagnostics.map((item) => ({ ...item, failure: evidenceFailure("assertion", "render-audit", item.rule) })),
|
|
750
|
+
total: routed.diagnostics.length,
|
|
751
|
+
checks: verified,
|
|
752
|
+
...(routed.advisories.length ? { advisories: routed.advisories, advisoryCount: routed.advisories.length } : {}),
|
|
753
|
+
},
|
|
754
|
+
candidateRevision,
|
|
755
|
+
));
|
|
400
756
|
}
|
|
401
757
|
}
|
|
402
758
|
}
|
|
403
|
-
let screenshots;
|
|
404
|
-
if (screenshot) {
|
|
405
|
-
boundary=evidenceFailure("runner","capture","ADS_CAPTURE_FAILED");
|
|
406
|
-
progress = { stage: "capture", total: selections.length, completed: 0, active: [], profile: "screenshots", elapsedMs: 0 };
|
|
407
|
-
notifyProgress?.(progress);
|
|
408
|
-
const proposal = digest(Buffer.from(JSON.stringify(changes.map(change => [change.path, change.content === null ? null : digest(Buffer.from(change.content))]))));
|
|
409
|
-
screenshots = await captures.run({ captures: selections, candidateRoot: candidate, proposal, publish: false }, signal, value => { progress = value; notifyProgress?.(value); });
|
|
410
|
-
}
|
|
411
759
|
let preparedPreview;
|
|
412
|
-
if(!dryRun){
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
captures.store.commit(screenshots.records);
|
|
419
|
-
const selected = new Set(screenshots.records.map(record => record.key));
|
|
420
|
-
screenshots = { ok: true, captures: captures.store.list(inspectScenarios(loadConfig(root)).scenarios, screenshots.baseRevision).captures.filter(record => selected.has(record.key)) };
|
|
760
|
+
if (!dryRun) {
|
|
761
|
+
try {
|
|
762
|
+
preparedPreview = await preparePreviewCache(candidateOptions, loadConfig(root));
|
|
763
|
+
} catch {
|
|
764
|
+
/* A missing cache falls back to background compilation. */
|
|
765
|
+
}
|
|
421
766
|
}
|
|
767
|
+
if (signal?.aborted)
|
|
768
|
+
throw fail(
|
|
769
|
+
"mutation-cancelled",
|
|
770
|
+
"Mutation cancelled before application.",
|
|
771
|
+
undefined,
|
|
772
|
+
evidenceFailure("runner", "mutation-execution", "ADS_CANCELLED"),
|
|
773
|
+
);
|
|
774
|
+
if ((await snapshot(candidateOptions)) !== expected)
|
|
775
|
+
throw fail("mutation-check", "A validation command changed source files. Use checks without source-writing side effects.");
|
|
776
|
+
if (JSON.stringify(await scopedInputs()) !== before)
|
|
777
|
+
throw fail(
|
|
778
|
+
"mutation-conflict",
|
|
779
|
+
"ADS, consuming UI or declared validation inputs changed during validation; no changes were applied. Read current source and retry.",
|
|
780
|
+
);
|
|
781
|
+
for (const change of changes) address(options, change.path);
|
|
422
782
|
if (!dryRun) {
|
|
423
|
-
beforeApply?.();
|
|
783
|
+
await beforeApply?.();
|
|
424
784
|
if (preparedPreview) releasePublication = holdLivePreview(root);
|
|
425
785
|
const written = [];
|
|
426
786
|
const directories = [];
|
|
427
|
-
function mkdir(directory) {
|
|
787
|
+
function mkdir(directory) {
|
|
788
|
+
if (!existsSync(directory)) {
|
|
789
|
+
mkdir(path.dirname(directory));
|
|
790
|
+
mkdirSync(directory);
|
|
791
|
+
directories.push(directory);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
428
794
|
function replace(file, content, mode) {
|
|
429
795
|
mkdir(path.dirname(file));
|
|
430
796
|
const staged = path.join(path.dirname(file), `.ads-edit-${randomUUID()}`);
|
|
431
|
-
try {
|
|
432
|
-
|
|
797
|
+
try {
|
|
798
|
+
writeFileSync(staged, content, { mode });
|
|
799
|
+
renameSync(staged, file);
|
|
800
|
+
} finally {
|
|
801
|
+
rmSync(staged, { force: true });
|
|
802
|
+
}
|
|
433
803
|
}
|
|
434
804
|
try {
|
|
435
805
|
changes.forEach((change, index) => {
|
|
436
806
|
const file = address(options, change.path);
|
|
437
|
-
if (change.content === null) rmSync(file);
|
|
807
|
+
if (change.content === null) rmSync(file);
|
|
808
|
+
else replace(file, change.content, originals[index].mode);
|
|
438
809
|
written.push(index);
|
|
439
810
|
});
|
|
440
811
|
} catch (error) {
|
|
441
812
|
for (const index of written.reverse()) {
|
|
442
|
-
const original = originals[index],
|
|
443
|
-
|
|
813
|
+
const original = originals[index],
|
|
814
|
+
file = path.join(root, original.path);
|
|
815
|
+
if (original.exists) replace(file, original.content, original.mode);
|
|
816
|
+
else rmSync(file, { force: true });
|
|
444
817
|
}
|
|
445
818
|
for (const directory of directories.reverse()) if (!readdirSync(directory).length) rmSync(directory, { recursive: true });
|
|
446
819
|
throw error;
|
|
447
820
|
}
|
|
448
821
|
}
|
|
449
822
|
const warnings = [];
|
|
450
|
-
if (!dryRun && (assets || configuration)) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
823
|
+
if (!dryRun && (assets || configuration)) {
|
|
824
|
+
try {
|
|
825
|
+
await generateBrandAssets(root);
|
|
826
|
+
} catch (error) {
|
|
827
|
+
warnings.push({ rule: "mutation-assets", message: `Source was applied; generated brand output needs recovery: ${error.message}` });
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
if (!dryRun && captures.store.fingerprint()) {
|
|
831
|
+
try {
|
|
832
|
+
captures.store.promote(await previewSourceRevision(loadConfig(root)), (await analyze(root, "registry")).scenarios);
|
|
833
|
+
} catch (error) {
|
|
834
|
+
warnings.push({ rule: "mutation-capture", message: `Source was applied; capture promotion needs recovery: ${error.message}` });
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
if (!dryRun && preparedPreview) {
|
|
838
|
+
try {
|
|
839
|
+
await preparedPreview();
|
|
840
|
+
} catch (error) {
|
|
841
|
+
warnings.push({ rule: "mutation-preview-cache", message: `Source was applied; preview warming will rebuild instead: ${error.message}` });
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
if (!dryRun && analysisRoots.has(candidate)) {
|
|
845
|
+
try {
|
|
846
|
+
await promoteAnalysisRevision(candidate, root);
|
|
847
|
+
} catch {
|
|
848
|
+
await releaseAnalysisRevision(candidate).catch(() => {});
|
|
849
|
+
}
|
|
850
|
+
analysisRoots.delete(candidate);
|
|
851
|
+
}
|
|
852
|
+
return (lastResult = mutationEvidence(
|
|
853
|
+
{
|
|
854
|
+
ok: true,
|
|
855
|
+
...(patches ? { units, transaction: true } : { unit }),
|
|
856
|
+
applied: !dryRun,
|
|
857
|
+
changes: changes.map((change) => ({
|
|
858
|
+
path: change.path,
|
|
859
|
+
operation: change.content === null ? "delete" : change.expectedDigest === null ? "create" : "update",
|
|
860
|
+
digest: change.content === null ? null : digest(Buffer.from(change.content)),
|
|
861
|
+
})),
|
|
862
|
+
checks: verified,
|
|
863
|
+
...(result.advisories?.length ? { advisories: result.advisories, advisoryCount: result.advisories.length } : {}),
|
|
864
|
+
...(warnings.length ? { warnings } : {}),
|
|
865
|
+
preview: "Source validation passed. Inspect the managed preview build and rendered scenario after applying; validation is not visual verification.",
|
|
866
|
+
},
|
|
867
|
+
candidateRevision,
|
|
868
|
+
));
|
|
456
869
|
} catch (error) {
|
|
457
|
-
return lastResult = mutationEvidence(
|
|
458
|
-
|
|
870
|
+
return (lastResult = mutationEvidence(
|
|
871
|
+
{
|
|
872
|
+
ok: false,
|
|
873
|
+
applied: false,
|
|
874
|
+
diagnostics: [error.diagnostic ?? { rule: "mutation-error", message: error.message, failure: error.failure ?? boundary }],
|
|
875
|
+
checks: verified,
|
|
876
|
+
},
|
|
877
|
+
candidateRevision,
|
|
878
|
+
));
|
|
879
|
+
} finally {
|
|
880
|
+
for (const analysisRoot of analysisRoots) await releaseAnalysisRevision(analysisRoot).catch(() => {});
|
|
881
|
+
releasePublication?.();
|
|
882
|
+
try {
|
|
883
|
+
await previewHost?.close();
|
|
884
|
+
} finally {
|
|
885
|
+
try {
|
|
886
|
+
if (temporary) rmSync(temporary, { recursive: true, force: true });
|
|
887
|
+
} finally {
|
|
888
|
+
releasePreview?.();
|
|
889
|
+
busy = false;
|
|
890
|
+
active = undefined;
|
|
891
|
+
progress = undefined;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
459
895
|
},
|
|
460
896
|
};
|
|
461
897
|
}
|