@reqvire-org/ads 0.3.53 → 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 +114 -94
- 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 +6 -6
- 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 +222 -79
- package/dist/boundaries.mjs +137 -40
- package/dist/brand-assets.mjs +219 -47
- package/dist/brands.mjs +86 -27
- package/dist/bun-compiler.mjs +34 -13
- 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 +66 -0
- package/dist/check.mjs +756 -196
- package/dist/cli.mjs +203 -100
- package/dist/color-values.mjs +21 -21
- package/dist/component-contrast.mjs +2 -2
- package/dist/config.mjs +308 -163
- package/dist/construction-styles.cjs +10 -0
- package/dist/contracts.d.mts +9 -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 +4 -2
- package/dist/foundation-views.mjs +238 -0
- package/dist/foundation.mjs +63 -39
- package/dist/generated-entries.mjs +198 -0
- package/dist/icons.mjs +80 -33
- package/dist/image-attributes.mjs +109 -36
- package/dist/image-size.mjs +1 -1
- package/dist/index.mjs +0 -2
- package/dist/init.mjs +128 -68
- package/dist/investigations.mjs +2 -2
- package/dist/layers.mjs +300 -127
- 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 +91 -26
- package/dist/mcp/context.mjs +17 -18
- package/dist/mcp/draft-discovery.mjs +44 -21
- package/dist/mcp/drafts.mjs +978 -343
- package/dist/mcp/execution-coordinator.mjs +417 -167
- package/dist/mcp/execution-results.mjs +7 -7
- package/dist/mcp/mutations.mjs +701 -219
- package/dist/mcp/preview-watch.mjs +465 -161
- package/dist/mcp/preview-widget.bundle.js +44 -50
- package/dist/mcp/prompts.mjs +6 -6
- package/dist/mcp/result-pages.mjs +1 -1
- package/dist/mcp/sandbox-host.mjs +1 -1
- package/dist/mcp/server.mjs +2436 -570
- package/dist/mcp/showcase-host.mjs +176 -39
- 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 +10 -0
- package/dist/project-documents.mjs +1 -1
- package/dist/public-api.mjs +70 -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 +768 -359
- package/dist/scenarios-vite.d.mts +1 -3
- package/dist/scenarios-vite.mjs +2 -81
- package/dist/scenarios.mjs +424 -159
- 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 +152 -144
- package/dist/skills/ads-designer/references/accessibility.md +14 -11
- package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
- package/dist/skills/ads-designer/references/behaviors.md +34 -30
- package/dist/skills/ads-designer/references/branding.md +98 -10
- package/dist/skills/ads-designer/references/captures.md +31 -31
- package/dist/skills/ads-designer/references/cli.md +21 -20
- package/dist/skills/ads-designer/references/contracts.md +63 -29
- package/dist/skills/ads-designer/references/design-data.md +49 -52
- package/dist/skills/ads-designer/references/drafts.md +71 -52
- package/dist/skills/ads-designer/references/evidence.md +1 -5
- package/dist/skills/ads-designer/references/guarded-editing.md +58 -51
- 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/performance.md +3 -2
- package/dist/skills/ads-designer/references/review.md +42 -38
- package/dist/skills/ads-designer/references/runtimes.md +33 -30
- package/dist/skills/ads-designer/references/scenarios.md +17 -19
- 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 -71
- package/dist/skills/ads-designer/references/workflows.md +19 -37
- package/dist/skills/ads-import/SKILL.md +43 -328
- package/dist/skills/ads-import/references/atomic-styles.md +4 -4
- package/dist/skills/ads-import/references/behaviors.md +34 -30
- package/dist/skills/ads-import/references/branding.md +5 -5
- package/dist/skills/ads-import/references/captures.md +31 -31
- package/dist/skills/ads-import/references/cli.md +21 -20
- package/dist/skills/ads-import/references/compatibility.md +1 -1
- package/dist/skills/ads-import/references/contracts.md +63 -29
- package/dist/skills/ads-import/references/design-data.md +49 -52
- package/dist/skills/ads-import/references/drafts.md +71 -52
- package/dist/skills/ads-import/references/evidence.md +1 -5
- package/dist/skills/ads-import/references/guarded-editing.md +58 -51
- 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 +42 -38
- package/dist/skills/ads-import/references/runtimes.md +33 -30
- package/dist/skills/ads-import/references/scenarios.md +17 -19
- package/dist/skills/ads-import/references/tokens.md +3 -3
- package/dist/skills/ads-import/references/validation.md +83 -71
- package/dist/skills/ads-import/references/workflows.md +19 -37
- 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 -346
- package/dist/skills/ads-port/references/atomic-styles.md +4 -4
- package/dist/skills/ads-port/references/behaviors.md +34 -30
- package/dist/skills/ads-port/references/captures.md +31 -31
- package/dist/skills/ads-port/references/cli.md +21 -20
- package/dist/skills/ads-port/references/contracts.md +63 -29
- package/dist/skills/ads-port/references/design-data.md +49 -52
- package/dist/skills/ads-port/references/drafts.md +71 -52
- package/dist/skills/ads-port/references/evidence.md +1 -5
- package/dist/skills/ads-port/references/guarded-editing.md +58 -51
- 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 +8 -7
- package/dist/skills/ads-port/references/review.md +42 -38
- package/dist/skills/ads-port/references/runtimes.md +33 -30
- package/dist/skills/ads-port/references/scenarios.md +17 -19
- package/dist/skills/ads-port/references/validation.md +83 -71
- package/dist/skills/ads-port/references/workflows.md +19 -37
- 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 +24 -19
- 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 +54 -52
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.exports.ts +1 -0
- 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/components/Content/Icon/Icon.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.exports.ts +1 -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/controllers/Palette/Palette.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/index.ts +5 -8
- 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/Search/SearchBar/SearchBar.ads.exports.ts +1 -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 -0
- 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 -0
- 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/styles.css +1 -0
- 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 +24 -19
- 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 +73 -27
- package/dist/task-cache.mjs +173 -72
- package/dist/task-worker.mjs +22 -11
- package/dist/test-boundaries.mjs +133 -60
- package/dist/themes-generated.mjs +1 -1
- package/dist/themes-watch.mjs +60 -19
- 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 +270 -89
- package/dist/units.mjs +215 -180
- package/dist/usage.mjs +138 -38
- package/dist/validation-checks.mjs +121 -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 +100 -89
- package/docs/ARCHITECTURE.md +353 -159
- package/docs/BEHAVIORS.md +33 -28
- package/docs/CACHING.md +55 -11
- package/docs/CHANGELOG.md +358 -17
- package/docs/COMPARISON.md +1 -1
- package/docs/CONTRACTS.md +22 -29
- package/docs/DESIGN-REFERENCES.md +40 -0
- package/docs/GUIDE.md +313 -292
- package/docs/MCP.md +261 -439
- 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 -424
- package/dist/contract-migration.mjs +0 -110
- package/dist/create.mjs +0 -48
- package/dist/lint-config.mjs +0 -48
- package/dist/mcp/draft-exports.mjs +0 -40
- package/dist/mcp/edit-preparation.mjs +0 -115
- 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 -88
- 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 -415
- 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 -411
- package/dist/skills/ads-break-ui/references/captures.md +0 -160
- package/dist/skills/ads-break-ui/references/contracts.md +0 -284
- package/dist/skills/ads-break-ui/references/design-data.md +0 -354
- package/dist/skills/ads-break-ui/references/drafts.md +0 -178
- package/dist/skills/ads-break-ui/references/evidence.md +0 -128
- package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -154
- 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 -96
- 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 -162
- package/dist/skills/ads-break-ui/references/verification.md +0 -58
- package/dist/skills/ads-break-ui/references/workflows.md +0 -83
- 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 -388
- 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 -411
- package/dist/skills/ads-motion/references/captures.md +0 -160
- package/dist/skills/ads-motion/references/contracts.md +0 -284
- package/dist/skills/ads-motion/references/design-data.md +0 -354
- package/dist/skills/ads-motion/references/drafts.md +0 -178
- package/dist/skills/ads-motion/references/evidence.md +0 -128
- package/dist/skills/ads-motion/references/guarded-editing.md +0 -154
- 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 -96
- 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 -162
- package/dist/skills/ads-motion/references/verification.md +0 -39
- package/dist/skills/ads-motion/references/workflows.md +0 -83
- package/dist/skills/ads-port/references/reporting.md +0 -101
- 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.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.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.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.tsx +0 -18
- package/dist/starters/react/design-system/review/index.ts +0 -5
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- 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
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { mapAsync } from "./analysis/queries.mjs";
|
|
1
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
3
|
import { isBuiltin } from "node:module";
|
|
3
4
|
import path from "node:path";
|
|
4
|
-
import ts from "
|
|
5
|
+
import ts from "./analysis/syntax.mjs";
|
|
5
6
|
import { isDevelopmentFile, isInside, sourceFiles } from "./config.mjs";
|
|
6
7
|
import { importResolver } from "./boundaries.mjs";
|
|
7
8
|
import { inspectUnits } from "./units.mjs";
|
|
8
9
|
|
|
9
|
-
const packageName = specifier => specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0];
|
|
10
|
+
const packageName = (specifier) => (specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0]);
|
|
10
11
|
|
|
11
12
|
/** Runtime imports only; development roles retain their existing policies. */
|
|
12
13
|
function imports(source) {
|
|
@@ -15,14 +16,30 @@ function imports(source) {
|
|
|
15
16
|
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier)) {
|
|
16
17
|
const bindings = ts.isImportDeclaration(node) ? node.importClause : node;
|
|
17
18
|
const named = ts.isImportDeclaration(node) ? bindings?.namedBindings : node.exportClause;
|
|
18
|
-
const typeOnly =
|
|
19
|
-
|
|
19
|
+
const typeOnly =
|
|
20
|
+
bindings?.isTypeOnly ||
|
|
21
|
+
(named &&
|
|
22
|
+
(ts.isNamedImports(named) || ts.isNamedExports(named)) &&
|
|
23
|
+
named.elements.length > 0 &&
|
|
24
|
+
!bindings?.name &&
|
|
25
|
+
named.elements.every((item) => item.isTypeOnly));
|
|
20
26
|
if (!typeOnly) result.push({ node, specifier: node.moduleSpecifier.text });
|
|
21
27
|
}
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
if (
|
|
29
|
+
ts.isCallExpression(node) &&
|
|
30
|
+
(node.expression.kind === ts.SyntaxKind.ImportKeyword || (ts.isIdentifier(node.expression) && node.expression.text === "require")) &&
|
|
31
|
+
node.arguments[0] &&
|
|
32
|
+
ts.isStringLiteralLike(node.arguments[0])
|
|
33
|
+
)
|
|
34
|
+
result.push({ node, specifier: node.arguments[0].text });
|
|
35
|
+
if (
|
|
36
|
+
ts.isImportEqualsDeclaration(node) &&
|
|
37
|
+
!node.isTypeOnly &&
|
|
38
|
+
ts.isExternalModuleReference(node.moduleReference) &&
|
|
39
|
+
node.moduleReference.expression &&
|
|
40
|
+
ts.isStringLiteralLike(node.moduleReference.expression)
|
|
41
|
+
)
|
|
42
|
+
result.push({ node, specifier: node.moduleReference.expression.text });
|
|
26
43
|
ts.forEachChild(node, visit);
|
|
27
44
|
}
|
|
28
45
|
visit(source);
|
|
@@ -35,59 +52,111 @@ function installedPackage(root, name) {
|
|
|
35
52
|
for (let directory = root; ; directory = path.dirname(directory)) {
|
|
36
53
|
const file = path.join(directory, "node_modules", name, "package.json");
|
|
37
54
|
if (existsSync(file)) {
|
|
38
|
-
try {
|
|
55
|
+
try {
|
|
56
|
+
const pkg = JSON.parse(readFileSync(file, "utf8"));
|
|
57
|
+
return { version: typeof pkg.version === "string" ? pkg.version : null };
|
|
58
|
+
} catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
39
61
|
}
|
|
40
62
|
if (path.dirname(directory) === directory) return null;
|
|
41
63
|
}
|
|
42
64
|
}
|
|
43
65
|
|
|
44
66
|
/** An explicit project allowlist, not certification of library internals. */
|
|
45
|
-
export function inspectBehaviorLibraries(options, program) {
|
|
67
|
+
export async function inspectBehaviorLibraries(options, program) {
|
|
46
68
|
const { root, dsRoot, config } = options;
|
|
47
|
-
const diagnostics = [],
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
69
|
+
const diagnostics = [],
|
|
70
|
+
inventory = await inspectUnits(options),
|
|
71
|
+
resolve = await importResolver(options);
|
|
72
|
+
const declared = config.behaviorLibraries ?? [],
|
|
73
|
+
allowed = new Set(declared);
|
|
74
|
+
const usage = new Map(),
|
|
75
|
+
edges = new Map();
|
|
76
|
+
const owner = (file) => inventory.owner(inventory.relative(path.relative(root, file)));
|
|
77
|
+
const runtime = (file) => isInside(dsRoot, file) && !isDevelopmentFile(file, options) && !/\.d\.[cm]?ts$/.test(file) && owner(file) !== "configuration";
|
|
78
|
+
const sources = program
|
|
79
|
+
? (await program.getSourceFiles()).filter((source) => runtime(source.fileName))
|
|
80
|
+
: await mapAsync(
|
|
81
|
+
sourceFiles(dsRoot).filter((file) => /\.[cm]?[jt]sx?$/.test(file) && runtime(file)),
|
|
82
|
+
async (file) => ts.createSourceFile(file, readFileSync(file, "utf8"), ts.ScriptTarget.Latest, true),
|
|
83
|
+
);
|
|
55
84
|
function report(file, node, rule, message, library) {
|
|
56
85
|
const location = node && file.getLineAndCharacterOfPosition(node.getStart(file));
|
|
57
|
-
diagnostics.push({
|
|
58
|
-
|
|
86
|
+
diagnostics.push({
|
|
87
|
+
file: typeof file === "string" ? file : path.relative(root, file.fileName).replaceAll("\\", "/"),
|
|
88
|
+
rule,
|
|
89
|
+
line: location ? location.line + 1 : 1,
|
|
90
|
+
column: location ? location.character + 1 : 1,
|
|
91
|
+
message,
|
|
92
|
+
library,
|
|
93
|
+
});
|
|
59
94
|
}
|
|
60
95
|
let pkg = {};
|
|
61
|
-
try {
|
|
62
|
-
|
|
63
|
-
|
|
96
|
+
try {
|
|
97
|
+
pkg = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8"));
|
|
98
|
+
} catch {
|
|
99
|
+
/* Missing dependencies are diagnosed below. */
|
|
100
|
+
}
|
|
101
|
+
const libraries = declared.map((name) => {
|
|
102
|
+
if (!Object.hasOwn(pkg.dependencies ?? {}, name))
|
|
103
|
+
report("ds.config.json", null, "behavior-library-dependency", `${name} is in behaviorLibraries but not package.json dependencies.`, name);
|
|
64
104
|
const installed = installedPackage(root, name);
|
|
65
|
-
if (!installed)
|
|
105
|
+
if (!installed)
|
|
106
|
+
report(
|
|
107
|
+
"ds.config.json",
|
|
108
|
+
null,
|
|
109
|
+
"behavior-library-missing",
|
|
110
|
+
`${name} is declared but not installed in this project. Install the project dependencies.`,
|
|
111
|
+
name,
|
|
112
|
+
);
|
|
66
113
|
return { name, version: installed?.version ?? null, units: [] };
|
|
67
114
|
});
|
|
68
115
|
for (const source of sources) {
|
|
69
|
-
const used = new Set(),
|
|
116
|
+
const used = new Set(),
|
|
117
|
+
local = new Set();
|
|
70
118
|
for (const { node, specifier } of imports(source)) {
|
|
71
119
|
const name = packageName(specifier);
|
|
72
|
-
if (name === config.framework || config.framework === "react" && name === "react-dom" || name.startsWith("@linaria/") || isBuiltin(specifier)) continue;
|
|
73
|
-
const targets = resolve(specifier, source.fileName);
|
|
120
|
+
if (name === config.framework || (config.framework === "react" && name === "react-dom") || name.startsWith("@linaria/") || isBuiltin(specifier)) continue;
|
|
121
|
+
const targets = await resolve(specifier, source.fileName);
|
|
74
122
|
for (const target of targets) if (runtime(target) && !target.split(path.sep).includes("node_modules")) local.add(target);
|
|
75
|
-
if (
|
|
76
|
-
|
|
123
|
+
if (
|
|
124
|
+
specifier.startsWith(".") ||
|
|
125
|
+
path.isAbsolute(specifier) ||
|
|
126
|
+
specifier === config.publicAlias ||
|
|
127
|
+
specifier.startsWith(config.publicAlias + "/") ||
|
|
128
|
+
targets.some((target) => isInside(root, target) && !target.split(path.sep).includes("node_modules") && existsSync(target))
|
|
129
|
+
)
|
|
130
|
+
continue;
|
|
77
131
|
used.add(name);
|
|
78
|
-
if (!allowed.has(name))
|
|
132
|
+
if (!allowed.has(name))
|
|
133
|
+
report(
|
|
134
|
+
source,
|
|
135
|
+
node,
|
|
136
|
+
"behavior-library-undeclared",
|
|
137
|
+
`Runtime import ${specifier} requires ${name} in ds.config.json behaviorLibraries and package.json dependencies.`,
|
|
138
|
+
name,
|
|
139
|
+
);
|
|
79
140
|
}
|
|
80
|
-
usage.set(source.fileName, used);
|
|
141
|
+
usage.set(source.fileName, used);
|
|
142
|
+
edges.set(source.fileName, local);
|
|
81
143
|
}
|
|
82
144
|
function librariesFor(file, seen = new Set()) {
|
|
83
145
|
if (seen.has(file)) return [];
|
|
84
146
|
seen.add(file);
|
|
85
|
-
return [...new Set([...(usage.get(file) ?? []), ...[...(edges.get(file) ?? [])].flatMap(target => librariesFor(target, seen))])].sort();
|
|
86
|
-
}
|
|
87
|
-
for (const source of sources) for (const name of librariesFor(source.fileName)) {
|
|
88
|
-
const library = libraries.find(item => item.name === name), unit = owner(source.fileName);
|
|
89
|
-
if (library && unit && !library.units.includes(unit)) library.units.push(unit);
|
|
147
|
+
return [...new Set([...(usage.get(file) ?? []), ...[...(edges.get(file) ?? [])].flatMap((target) => librariesFor(target, seen))])].sort();
|
|
90
148
|
}
|
|
149
|
+
for (const source of sources)
|
|
150
|
+
for (const name of librariesFor(source.fileName)) {
|
|
151
|
+
const library = libraries.find((item) => item.name === name),
|
|
152
|
+
unit = owner(source.fileName);
|
|
153
|
+
if (library && unit && !library.units.includes(unit)) library.units.push(unit);
|
|
154
|
+
}
|
|
91
155
|
for (const library of libraries) library.units.sort();
|
|
92
|
-
return {
|
|
156
|
+
return {
|
|
157
|
+
libraries,
|
|
158
|
+
diagnostics,
|
|
159
|
+
librariesFor,
|
|
160
|
+
undeclared: [...new Set(diagnostics.filter((item) => item.rule === "behavior-library-undeclared").map((item) => item.library))].sort(),
|
|
161
|
+
};
|
|
93
162
|
}
|
package/dist/behaviors.mjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { withProjectAnalysis } from "./analysis/standalone.mjs";
|
|
2
|
+
import { currentAnalysis } from "./analysis/context.mjs";
|
|
3
|
+
import { eachChild } from "./analysis/queries.mjs";
|
|
4
|
+
import { localValueDeclarations } from "./analysis/helpers.mjs";
|
|
5
|
+
import { existsSync, realpathSync, statSync } from "node:fs";
|
|
2
6
|
import path from "node:path";
|
|
3
|
-
import ts from "
|
|
7
|
+
import ts from "./analysis/syntax.mjs";
|
|
4
8
|
import { z } from "zod";
|
|
5
|
-
import {
|
|
9
|
+
import { isDevelopmentFile, isInside, sourceFiles, isReviewFile, isTestFile } from "./config.mjs";
|
|
6
10
|
import { importResolver, projectCompilerOptions } from "./boundaries.mjs";
|
|
7
11
|
import { inspectUnits } from "./units.mjs";
|
|
12
|
+
import { cachedProgram } from "./program-cache.mjs";
|
|
8
13
|
import { scenarioApi } from "./public-api.mjs";
|
|
9
14
|
import { inspectScenarios } from "./scenarios.mjs";
|
|
10
15
|
import { uiOperation } from "./ui-framework.mjs";
|
|
@@ -14,59 +19,105 @@ const id = z.string().regex(/^[a-zA-Z0-9][\w.-]{0,99}$/);
|
|
|
14
19
|
const reference = z.string().min(1).max(500);
|
|
15
20
|
const subject = z.union([
|
|
16
21
|
z.object({ api: reference }).strict(),
|
|
17
|
-
z.object({ source: reference, symbol: reference.optional(), role:z.enum(["controller","implementation"]).optional() }).strict(),
|
|
22
|
+
z.object({ source: reference, symbol: reference.optional(), role: z.enum(["controller", "implementation"]).optional() }).strict(),
|
|
18
23
|
]);
|
|
19
|
-
export const behaviorSchema = z
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}).strict()
|
|
24
|
+
export const behaviorSchema = z
|
|
25
|
+
.object({
|
|
26
|
+
schemaVersion: z.literal(1),
|
|
27
|
+
subjects: z.record(id, subject).refine((value) => Object.keys(value).length > 0 && Object.keys(value).length <= 100),
|
|
28
|
+
guarantees: z
|
|
29
|
+
.array(z.object({ id, description: z.string().min(1).max(2000), subjects: z.array(id).min(1).max(100), checks: z.array(id).min(1).max(100) }).strict())
|
|
30
|
+
.min(1)
|
|
31
|
+
.max(100),
|
|
32
|
+
checks: z
|
|
33
|
+
.record(id, z.object({ file: reference, case: id, scenario: reference.optional(), profile: id }).strict())
|
|
34
|
+
.refine((value) => Object.keys(value).length > 0 && Object.keys(value).length <= 100),
|
|
35
|
+
})
|
|
36
|
+
.strict();
|
|
25
37
|
|
|
26
38
|
/** Static contracts never execute project code or certify natural-language claims. */
|
|
27
|
-
export function inspectBehaviors(options, suppliedProgram, suppliedRegistry) {
|
|
39
|
+
export async function inspectBehaviors(options, suppliedProgram, suppliedRegistry) {
|
|
40
|
+
if (!currentAnalysis()?.provideProgram) return withProjectAnalysis(options.root, async () => inspectBehaviors(options, suppliedProgram, suppliedRegistry));
|
|
28
41
|
const { root, dsRoot, config } = options;
|
|
29
|
-
const inventory = inspectUnits(options);
|
|
30
|
-
const declarations = inspectUnitContracts(options);
|
|
31
|
-
const typed = declarations.contracts.filter(entry => entry.behavior);
|
|
32
|
-
const files =
|
|
42
|
+
const inventory = await inspectUnits(options);
|
|
43
|
+
const declarations = await inspectUnitContracts(options);
|
|
44
|
+
const typed = declarations.contracts.filter((entry) => entry.behavior);
|
|
45
|
+
const files = typed.map((entry) => path.resolve(root, entry.file));
|
|
33
46
|
if (!files.length) return { contracts: [], diagnostics: [] };
|
|
34
|
-
const program =
|
|
47
|
+
const program =
|
|
48
|
+
suppliedProgram ??
|
|
49
|
+
declarations.program ??
|
|
50
|
+
(await cachedProgram(
|
|
51
|
+
`behaviors:${root}`,
|
|
52
|
+
sourceFiles(dsRoot).filter((file) => /\.[cm]?[jt]sx?$/.test(file)),
|
|
53
|
+
{ ...(await projectCompilerOptions(options)), allowJs: true },
|
|
54
|
+
));
|
|
35
55
|
const checker = program.getTypeChecker();
|
|
36
|
-
const apis = new Map(scenarioApi(program, options).map(item => [item.name, item]));
|
|
37
|
-
const scenarios = (suppliedRegistry ?? inspectScenarios(options, program)).scenarios;
|
|
38
|
-
const diagnostics = [...declarations.diagnostics],
|
|
39
|
-
|
|
56
|
+
const apis = new Map((await scenarioApi(program, options)).map((item) => [item.name, item]));
|
|
57
|
+
const scenarios = (suppliedRegistry ?? (await inspectScenarios(options, program))).scenarios;
|
|
58
|
+
const diagnostics = [...declarations.diagnostics],
|
|
59
|
+
contracts = [],
|
|
60
|
+
owners = new Set();
|
|
61
|
+
const relative = (file) => path.relative(root, file).replaceAll("\\", "/");
|
|
40
62
|
for (const file of files) {
|
|
41
|
-
const report = message => diagnostics.push({ file: relative(file), rule: "behavior-contract", line: 1, column: 1, message });
|
|
63
|
+
const report = (message) => diagnostics.push({ file: relative(file), rule: "behavior-contract", line: 1, column: 1, message });
|
|
42
64
|
let value;
|
|
43
65
|
try {
|
|
44
66
|
if (statSync(file).size > 128 * 1024 || realpathSync(file) !== file) throw new Error("Behavior contracts must be regular files of at most 128 KiB.");
|
|
45
|
-
const parsed = behaviorSchema.safeParse(typed.find(entry => path.resolve(root, entry.file) === file)
|
|
46
|
-
if (!parsed.success)
|
|
67
|
+
const parsed = behaviorSchema.safeParse(typed.find((entry) => path.resolve(root, entry.file) === file).behavior);
|
|
68
|
+
if (!parsed.success)
|
|
69
|
+
throw new Error(
|
|
70
|
+
parsed.error.issues
|
|
71
|
+
.slice(0, 5)
|
|
72
|
+
.map((issue) => `${issue.path.join(".")}: ${issue.message}`)
|
|
73
|
+
.join("; "),
|
|
74
|
+
);
|
|
47
75
|
value = parsed.data;
|
|
48
|
-
} catch (error) {
|
|
76
|
+
} catch (error) {
|
|
77
|
+
report(error.message);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
49
80
|
const unit = inventory.owner(inventory.relative(relative(file)));
|
|
50
|
-
if (!["components", "patterns", "controllers", "review"].includes(unit?.split("/")[0])) {
|
|
51
|
-
|
|
81
|
+
if (!["components", "patterns", "controllers", "review"].includes(unit?.split("/")[0])) {
|
|
82
|
+
report("Behavior contracts belong to a component, pattern, controller or development review unit.");
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (owners.has(unit)) {
|
|
86
|
+
report(`Only one behavior contract may describe ${unit}.`);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
52
89
|
owners.add(unit);
|
|
53
90
|
function owned(target, field) {
|
|
54
|
-
if (path.isAbsolute(target) || target.includes("\\") || target.includes("\0")) {
|
|
91
|
+
if (path.isAbsolute(target) || target.includes("\\") || target.includes("\0")) {
|
|
92
|
+
report(`${field} must be an owner-local relative path.`);
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
55
95
|
const absolute = path.resolve(path.dirname(file), target);
|
|
56
|
-
if (
|
|
57
|
-
|
|
96
|
+
if (
|
|
97
|
+
!isInside(dsRoot, absolute) ||
|
|
98
|
+
inventory.owner(inventory.relative(relative(absolute))) !== unit ||
|
|
99
|
+
!existsSync(absolute) ||
|
|
100
|
+
!statSync(absolute).isFile() ||
|
|
101
|
+
realpathSync(absolute) !== absolute
|
|
102
|
+
) {
|
|
103
|
+
report(`${field} must resolve to a real file in ${unit}: ${target}`);
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
58
106
|
return absolute;
|
|
59
107
|
}
|
|
60
108
|
for (const [name, entry] of Object.entries(value.subjects)) {
|
|
61
109
|
if (entry.api) {
|
|
62
110
|
const api = apis.get(entry.api);
|
|
63
|
-
if (!api || inventory.owner(inventory.relative(relative(api.file))) !== unit)
|
|
111
|
+
if (!api || inventory.owner(inventory.relative(relative(api.file))) !== unit)
|
|
112
|
+
report(`Subject ${name} must resolve to a public API owned by ${unit}: ${entry.api}`);
|
|
64
113
|
} else {
|
|
65
114
|
const source = owned(entry.source, `Subject ${name}`);
|
|
66
|
-
if (source && isDevelopmentFile(source, options) && !isReviewFile(source, options))
|
|
115
|
+
if (source && isDevelopmentFile(source, options) && !isReviewFile(source, options))
|
|
116
|
+
report(`Subject ${name} must identify runtime implementation, not a fixture, scenario or check.`);
|
|
67
117
|
if (source && entry.symbol) {
|
|
68
|
-
const ast = program.getSourceFile(source);
|
|
69
|
-
if (!ast || !
|
|
118
|
+
const ast = await program.getSourceFile(source);
|
|
119
|
+
if (!ast || !(await localValueDeclarations(checker, ast, entry.symbol)).length)
|
|
120
|
+
report(`Subject ${name}: symbol ${entry.symbol} is not declared in ${entry.source}.`);
|
|
70
121
|
}
|
|
71
122
|
}
|
|
72
123
|
}
|
|
@@ -81,83 +132,175 @@ export function inspectBehaviors(options, suppliedProgram, suppliedRegistry) {
|
|
|
81
132
|
for (const [name, check] of Object.entries(value.checks)) {
|
|
82
133
|
const target = owned(check.file, `Check ${name}`);
|
|
83
134
|
if (target && !isTestFile(target)) report(`Check ${name} must use a development-only test/spec file, not a scenario, fixture or helper.`);
|
|
84
|
-
if (!Object.hasOwn(config.mcp.behaviorProfiles, check.profile))
|
|
85
|
-
|
|
135
|
+
if (!Object.hasOwn(config.mcp.behaviorProfiles, check.profile))
|
|
136
|
+
report(
|
|
137
|
+
`Check ${name} references unregistered profile ${check.profile}. Register its literal runner command in ds.config.json; checks cannot install packages or assume host globals.`,
|
|
138
|
+
);
|
|
139
|
+
if (check.scenario && !scenarios.some((scenario) => scenario.id === check.scenario))
|
|
140
|
+
report(`Check ${name} references unknown scenario ${check.scenario}.`);
|
|
86
141
|
const identity = JSON.stringify([check.file, check.case, check.profile]);
|
|
87
142
|
if (cases.has(identity)) report(`Duplicate execution identity for check ${name}. Use one check ID and reference it from several guarantees.`);
|
|
88
143
|
cases.add(identity);
|
|
89
144
|
}
|
|
90
|
-
const declaration=typed.find(entry=>entry.unit===unit);
|
|
91
|
-
for(const entry of [...Object.values(declaration?.bindings??{})
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
145
|
+
const declaration = typed.find((entry) => entry.unit === unit);
|
|
146
|
+
for (const entry of [...Object.values(declaration?.bindings ?? {}), ...(declaration?.declarativeParts ?? [])])
|
|
147
|
+
for (const name of entry.checks) {
|
|
148
|
+
const check = value.checks[name],
|
|
149
|
+
scenario = check && scenarios.find((scenario) => scenario.id === check.scenario);
|
|
150
|
+
const parent = entry.parentName ?? entry.scope.apiName;
|
|
151
|
+
const roots = entry.rootNames ?? [parent];
|
|
152
|
+
const nested = declaration?.declarativeParts?.some((part) => part.apiName === parent);
|
|
153
|
+
if (
|
|
154
|
+
!check ||
|
|
155
|
+
config.mcp.behaviorProfiles[check.profile]?.mode !== "browser" ||
|
|
156
|
+
!roots.some((root) => scenario?.covers.includes(root)) ||
|
|
157
|
+
(entry.parentName && (!scenario?.exercises?.includes(entry.apiName) || (nested && !scenario?.exercises?.includes(parent))))
|
|
158
|
+
)
|
|
159
|
+
report(
|
|
160
|
+
`Required contract check ${name} must use a browser profile and a scenario covering a rendering root (${roots.join(", ") || parent})${entry.parentName ? ` and exercising ${entry.apiName}${nested ? ` through ${parent}` : ""}` : ""}. Source registration does not establish rendered behavior.`,
|
|
161
|
+
);
|
|
162
|
+
if (!value.guarantees.some((guarantee) => guarantee.checks.includes(name)))
|
|
163
|
+
report(`Required contract check ${name} must back a named guarantee, not remain an unclaimed execution.`);
|
|
164
|
+
}
|
|
165
|
+
contracts.push({
|
|
166
|
+
...value,
|
|
167
|
+
unit,
|
|
168
|
+
file: relative(file),
|
|
169
|
+
demonstrations: Object.fromEntries(
|
|
170
|
+
Object.entries(value.subjects)
|
|
171
|
+
.filter(([, item]) => item.api)
|
|
172
|
+
.map(([name, item]) => [name, scenarios.filter((scenario) => scenario.exercises?.includes(item.api)).map((scenario) => scenario.id)]),
|
|
173
|
+
),
|
|
174
|
+
});
|
|
100
175
|
}
|
|
101
176
|
return { contracts, diagnostics };
|
|
102
177
|
}
|
|
103
178
|
|
|
104
179
|
/** Headless ownership applies to shared controllers and explicitly named private subjects. */
|
|
105
|
-
export function inspectControllers(options, program, report, contracts = []) {
|
|
180
|
+
export async function inspectControllers(options, program, report, contracts = []) {
|
|
106
181
|
const { root, dsRoot, config } = options;
|
|
107
|
-
const resolve = importResolver(options);
|
|
182
|
+
const resolve = await importResolver(options);
|
|
108
183
|
const privateFiles = new Map();
|
|
109
|
-
for (const contract of contracts)
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
184
|
+
for (const contract of contracts)
|
|
185
|
+
for (const subject of Object.values(contract.subjects).filter((item) => item.source && item.role !== "implementation")) {
|
|
186
|
+
const file = path.resolve(root, path.dirname(contract.file), subject.source);
|
|
187
|
+
if (!privateFiles.has(file)) privateFiles.set(file, new Set());
|
|
188
|
+
privateFiles.get(file).add(subject.symbol ?? null);
|
|
189
|
+
}
|
|
114
190
|
const checker = program.getTypeChecker();
|
|
115
|
-
for (const source of program.getSourceFiles()) {
|
|
191
|
+
for (const source of await program.getSourceFiles()) {
|
|
116
192
|
const file = source.fileName;
|
|
117
|
-
if (isDevelopmentFile(file, options) || !isInside(path.join(dsRoot, "controllers"), file) && !privateFiles.has(file)) continue;
|
|
193
|
+
if (isDevelopmentFile(file, options) || (!isInside(path.join(dsRoot, "controllers"), file) && !privateFiles.has(file))) continue;
|
|
118
194
|
const wholeFile = isInside(path.join(dsRoot, "controllers"), file) || privateFiles.get(file)?.has(null);
|
|
119
|
-
const subjects = wholeFile ? [] :
|
|
120
|
-
const headless = node =>
|
|
121
|
-
|
|
122
|
-
function
|
|
195
|
+
const subjects = wholeFile ? [] : (await Promise.all([...privateFiles.get(file)].map((name) => localValueDeclarations(checker, source, name)))).flat();
|
|
196
|
+
const headless = (node) =>
|
|
197
|
+
wholeFile || subjects.some((subject) => subject.getSourceFile() === source && node.pos >= subject.pos && node.end <= subject.end);
|
|
198
|
+
function emit(node, rule, message) {
|
|
199
|
+
const p = source.getLineAndCharacterOfPosition(node.getStart());
|
|
200
|
+
report(
|
|
201
|
+
file,
|
|
202
|
+
rule,
|
|
203
|
+
message +
|
|
204
|
+
(rule === "controller-skin" && !isInside(path.join(dsRoot, "controllers"), file)
|
|
205
|
+
? ' An intentional visual behavior subject can declare role: "implementation"; controller subjects remain headless.'
|
|
206
|
+
: ""),
|
|
207
|
+
p.line + 1,
|
|
208
|
+
p.character + 1,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
async function visit(node) {
|
|
123
212
|
let specifier;
|
|
124
|
-
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier))
|
|
125
|
-
|
|
213
|
+
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier))
|
|
214
|
+
specifier = node.moduleSpecifier.text;
|
|
215
|
+
if (
|
|
216
|
+
ts.isCallExpression(node) &&
|
|
217
|
+
(node.expression.kind === ts.SyntaxKind.ImportKeyword || (ts.isIdentifier(node.expression) && node.expression.text === "require")) &&
|
|
218
|
+
node.arguments[0] &&
|
|
219
|
+
ts.isStringLiteralLike(node.arguments[0])
|
|
220
|
+
)
|
|
221
|
+
specifier = node.arguments[0].text;
|
|
126
222
|
if (specifier) {
|
|
127
|
-
const typeOnly =
|
|
223
|
+
const typeOnly =
|
|
224
|
+
(ts.isImportDeclaration(node) &&
|
|
225
|
+
(node.importClause?.isTypeOnly ||
|
|
226
|
+
(node.importClause?.namedBindings &&
|
|
227
|
+
ts.isNamedImports(node.importClause.namedBindings) &&
|
|
228
|
+
!node.importClause.name &&
|
|
229
|
+
node.importClause.namedBindings.elements.every((item) => item.isTypeOnly)))) ||
|
|
230
|
+
(ts.isExportDeclaration(node) && node.isTypeOnly);
|
|
128
231
|
if (!typeOnly) {
|
|
129
|
-
if (wholeFile && /^(?:@linaria\/|.*\.css(?:[?#].*)?$)/.test(specifier))
|
|
232
|
+
if (wholeFile && /^(?:@linaria\/|.*\.css(?:[?#].*)?$)/.test(specifier))
|
|
233
|
+
emit(node, "controller-skin", "Controllers own behavior and measurements. Put CSS/Linaria skins in the consuming component or pattern.");
|
|
130
234
|
const framework = /^(?:react|react-dom)(?:\/|$)/.test(specifier) ? "react" : /^preact(?:\/|$)/.test(specifier) ? "preact" : null;
|
|
131
|
-
if (framework && config.framework !== framework)
|
|
132
|
-
|
|
133
|
-
|
|
235
|
+
if (framework && config.framework !== framework)
|
|
236
|
+
emit(
|
|
237
|
+
node,
|
|
238
|
+
"controller-framework",
|
|
239
|
+
`Controller imports ${framework}, but ds.config.json selects ${config.framework ?? "no framework"}. Use the configured framework or plain TypeScript/browser APIs; MCP hosts do not supply another runtime.`,
|
|
240
|
+
);
|
|
241
|
+
const targets = await resolve(specifier, file);
|
|
242
|
+
const local =
|
|
243
|
+
specifier.startsWith(".") ||
|
|
244
|
+
specifier === config.publicAlias ||
|
|
245
|
+
targets.some((target) => isInside(root, target) && !target.includes(`${path.sep}node_modules${path.sep}`) && existsSync(target));
|
|
134
246
|
if (local) {
|
|
135
|
-
if (targets.some(target => !existsSync(target)))
|
|
247
|
+
if (targets.some((target) => !existsSync(target)))
|
|
248
|
+
emit(
|
|
249
|
+
node,
|
|
250
|
+
"controller-dependency",
|
|
251
|
+
`Unresolved controller dependency ${specifier}. Declare real project dependencies and local modules; do not assume MCP host globals.`,
|
|
252
|
+
);
|
|
136
253
|
if (isInside(path.join(dsRoot, "controllers"), file)) {
|
|
137
|
-
const targetsInUi = targets.some(target => ["components", "patterns"].some(kind => isInside(path.join(dsRoot, kind), target)));
|
|
138
|
-
if (targetsInUi)
|
|
254
|
+
const targetsInUi = targets.some((target) => ["components", "patterns"].some((kind) => isInside(path.join(dsRoot, kind), target)));
|
|
255
|
+
if (targetsInUi)
|
|
256
|
+
emit(
|
|
257
|
+
node,
|
|
258
|
+
"controller-dependency",
|
|
259
|
+
"Shared controllers cannot import component/pattern runtime implementations. Pass behavior adapters or callbacks from the consumer; type-only imports are allowed.",
|
|
260
|
+
);
|
|
139
261
|
if (specifier === config.publicAlias) {
|
|
140
|
-
for (const item of node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
262
|
+
for (const item of node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings)
|
|
263
|
+
? node.importClause.namedBindings.elements
|
|
264
|
+
: []) {
|
|
265
|
+
let symbol = await checker.getSymbolAtLocation(item.name);
|
|
266
|
+
if (symbol?.flags & ts.SymbolFlags.Alias) symbol = await checker.getAliasedSymbol(symbol);
|
|
267
|
+
if (
|
|
268
|
+
symbol?.declarations?.some((declaration) =>
|
|
269
|
+
["components", "patterns"].some((kind) => isInside(path.join(dsRoot, kind), declaration.getSourceFile().fileName)),
|
|
270
|
+
)
|
|
271
|
+
)
|
|
272
|
+
emit(item, "controller-dependency", "Shared controllers consume behavior helpers, not styled component/pattern implementations.");
|
|
144
273
|
}
|
|
145
|
-
if (!node.importClause?.namedBindings || ts.isNamespaceImport(node.importClause.namedBindings))
|
|
274
|
+
if (!node.importClause?.namedBindings || ts.isNamespaceImport(node.importClause.namedBindings))
|
|
275
|
+
emit(node, "controller-dependency", "Use explicit behavior imports in shared controllers so dependency ownership can be checked.");
|
|
146
276
|
}
|
|
147
277
|
}
|
|
148
278
|
}
|
|
149
279
|
}
|
|
150
280
|
}
|
|
151
|
-
if (
|
|
152
|
-
|
|
281
|
+
if (
|
|
282
|
+
headless(node) &&
|
|
283
|
+
(((ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) && ts.isIdentifier(node.tagName) && /^[a-z]/.test(node.tagName.text)) ||
|
|
284
|
+
(ts.isCallExpression(node) &&
|
|
285
|
+
(await uiOperation(node.expression, checker)) === "createElement" &&
|
|
286
|
+
node.arguments[0] &&
|
|
287
|
+
ts.isStringLiteralLike(node.arguments[0])))
|
|
288
|
+
)
|
|
289
|
+
emit(node, "controller-skin", "Visual DOM markup belongs in components/patterns. Controllers may use framework hooks and context providers.");
|
|
153
290
|
if (!wholeFile && headless(node) && (ts.isTaggedTemplateExpression(node) || ts.isCallExpression(node))) {
|
|
154
291
|
let base = ts.isTaggedTemplateExpression(node) ? node.tag : node.expression;
|
|
155
292
|
while (ts.isPropertyAccessExpression(base) || ts.isCallExpression(base)) base = base.expression;
|
|
156
|
-
if (
|
|
157
|
-
|
|
293
|
+
if (
|
|
294
|
+
(await checker.getSymbolAtLocation(base))?.declarations?.some(
|
|
295
|
+
(declaration) =>
|
|
296
|
+
(ts.isImportSpecifier(declaration) && declaration.parent.parent.parent.moduleSpecifier.text.startsWith("@linaria/")) ||
|
|
297
|
+
(ts.isNamespaceImport(declaration) && declaration.parent.parent.moduleSpecifier.text.startsWith("@linaria/")),
|
|
298
|
+
)
|
|
299
|
+
)
|
|
300
|
+
emit(node, "controller-skin", "Keep Linaria styling outside the declared private controller subject, in its visual consumer.");
|
|
158
301
|
}
|
|
159
|
-
|
|
302
|
+
await eachChild(node, visit);
|
|
160
303
|
}
|
|
161
|
-
visit(source);
|
|
304
|
+
await visit(source);
|
|
162
305
|
}
|
|
163
306
|
}
|