@astryxdesign/cli 0.6.5 → 0.6.6-canary.1eb16a0
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/CHANGELOG.md +87 -0
- package/README.md +58 -55
- package/api/build/_adapter.d.mts +55 -2
- package/api/build/_adapter.mjs +100 -10
- package/api/build/build.doc.mjs +2 -2
- package/api/build/build.test.mjs +111 -2
- package/api/build/build.type.d.mts +8 -0
- package/api/build/build.type.mjs +2 -0
- package/api/build/kit/kit.mjs +99 -22
- package/api/build/kit/rank.d.mts +32 -8
- package/api/build/kit/rank.mjs +291 -97
- package/api/build/kit/rank.test.mjs +231 -48
- package/api/build/kit/weights.d.mts +82 -0
- package/api/build/kit/weights.json +1 -0
- package/api/build/kit/weights.mjs +305 -0
- package/api/build/kit/weights.test.mjs +190 -0
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +603 -0
- package/api/component/component.mjs +49 -15
- package/api/component/component.test.mjs +32 -0
- package/api/component/component.type.d.mts +33 -3
- package/api/component/component.type.mjs +10 -3
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +5 -2
- package/api/component/detail/detail.mjs +5 -1
- package/api/component/detail/props/props.d.mts +2 -1
- package/api/component/detail/props/props.mjs +3 -2
- package/api/component/detail/showcase/showcase.d.mts +3 -1
- package/api/component/detail/showcase/showcase.mjs +3 -1
- package/api/component/detail/source/source.d.mts +3 -2
- package/api/component/detail/source/source.mjs +7 -3
- package/api/component/list/list.mjs +128 -10
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +25 -0
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.mjs +7 -1
- package/api/docs/docOverlays.test.mjs +10 -6
- package/api/docs/docs.d.mts +6 -0
- package/api/docs/docs.depth.test.mjs +134 -0
- package/api/docs/docs.doc.mjs +31 -2
- package/api/docs/docs.mjs +46 -1
- package/api/docs/docs.test.mjs +279 -0
- package/api/docs/docs.type.d.mts +81 -4
- package/api/docs/docs.type.mjs +41 -4
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/integration-tree.test.mjs +572 -0
- package/api/docs/integrationDocs.test.mjs +337 -0
- package/api/docs/node/node.d.mts +28 -3
- package/api/docs/node/node.mjs +149 -23
- package/api/doctor/_adapter.d.mts +50 -0
- package/api/doctor/_adapter.mjs +190 -0
- package/api/doctor/doctor.d.mts +0 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +8 -123
- package/api/doctor/theme-checks.d.mts +24 -0
- package/api/doctor/theme-checks.mjs +1231 -0
- package/api/doctor/theme-checks.test.mjs +667 -0
- package/api/error.d.mts +22 -0
- package/api/error.mjs +42 -0
- package/api/gap-report/gap-report.d.mts +3 -1
- package/api/gap-report/gap-report.mjs +27 -3
- package/api/gap-report/gap-report.test.mjs +106 -0
- package/api/hook/_adapter.d.mts +1 -0
- package/api/hook/_adapter.mjs +3 -0
- package/api/hook/detail/detail.mjs +2 -2
- package/api/hook/detail/params/params.mjs +2 -2
- package/api/hook/hook.type.d.mts +12 -0
- package/api/hook/hook.type.mjs +3 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/hook/list/list.mjs +8 -8
- package/api/index.d.mts +1 -1
- package/api/index.mjs +4 -0
- package/api/init/run/run.d.mts +3 -5
- package/api/init/run/run.mjs +10 -11
- package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
- package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
- package/api/integration/add-contribution.d.mts +2 -1
- package/api/integration/add-contribution.mjs +7 -3
- package/api/integration/add-contribution.test.mjs +3 -3
- package/api/integration/add-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +354 -28
- package/api/integration/add-theme.test.mjs +380 -16
- package/api/integration/authoring-checks.mjs +31 -8
- package/api/integration/authoring-checks.type.d.mts +8 -0
- package/api/integration/authoring-checks.type.mjs +7 -3
- package/api/integration/integration-authoring.type.d.mts +4 -1
- package/api/integration/integration-authoring.type.mjs +6 -1
- package/api/integration/integrationAdd.doc.mjs +6 -0
- package/api/integration/integrationAddTheme.doc.mjs +10 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
- package/api/integration/pack-check.component-replaces.test.mjs +126 -0
- package/api/integration/pack-check.d.mts +10 -0
- package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
- package/api/integration/pack-check.mjs +495 -4
- package/api/integration/pack-check.test.mjs +619 -10
- package/api/integration/validate-integration.d.mts +4 -2
- package/api/integration/validate-integration.mjs +7 -2
- package/api/integration/validate-integration.test.mjs +55 -0
- package/api/integration/validate-integration.type.d.mts +5 -0
- package/api/integration/validate-integration.type.mjs +5 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/layout/expand/expand.mjs +12 -7
- package/api/layout/expand/expand.receipt.test.mjs +74 -0
- package/api/layout/layout.type.d.mts +1 -0
- package/api/layout/layout.type.mjs +1 -0
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search.d.mts +39 -8
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +248 -66
- package/api/search/search.test.mjs +829 -0
- package/api/search/search.type.d.mts +6 -6
- package/api/search/search.type.mjs +5 -5
- package/api/swizzle/_adapter.d.mts +10 -0
- package/api/swizzle/_adapter.mjs +23 -0
- package/api/swizzle/copy/copy.d.mts +5 -6
- package/api/swizzle/copy/copy.mjs +95 -13
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.doc.mjs +4 -0
- package/api/swizzle/swizzle.test.mjs +55 -5
- package/api/swizzle/swizzle.type.d.mts +8 -0
- package/api/swizzle/swizzle.type.mjs +2 -0
- package/api/template/copy/copy.mjs +15 -8
- package/api/template/copy/copy.receipt.test.mjs +77 -0
- package/api/template/show/show.mjs +17 -4
- package/api/template/show/show.test.mjs +76 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template-integration.test.mjs +14 -0
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +6 -2
- package/api/template/template.mjs +2 -0
- package/api/template/template.type.d.mts +14 -0
- package/api/template/template.type.mjs +5 -0
- package/api/theme/_adapter.d.mts +106 -6
- package/api/theme/_adapter.mjs +687 -18
- package/api/theme/add/add.binary.test.mjs +76 -3
- package/api/theme/add/add.d.mts +5 -9
- package/api/theme/add/add.mjs +87 -64
- package/api/theme/add/add.rollback.test.mjs +9 -9
- package/api/theme/add/add.staging.test.mjs +9 -9
- package/api/theme/add/add.test.mjs +461 -55
- package/api/theme/add/add.types.test.mjs +151 -0
- package/api/theme/build/build.d.mts +50 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.icon-lineage.test.mjs +117 -0
- package/api/theme/build/build.icon-preservation.test.mjs +639 -0
- package/api/theme/build/build.mjs +463 -155
- package/api/theme/build/build.project-core.test.mjs +165 -0
- package/api/theme/build/build.test.mjs +220 -1
- package/api/theme/build/icon-imports.d.mts +47 -0
- package/api/theme/build/icon-imports.mjs +691 -0
- package/api/theme/eject/eject.binary.test.mjs +90 -0
- package/api/theme/eject/eject.d.mts +17 -0
- package/api/theme/eject/eject.mjs +65 -0
- package/api/theme/eject/eject.rollback.test.mjs +158 -0
- package/api/theme/eject/eject.staging.test.mjs +83 -0
- package/api/theme/eject/eject.test.mjs +160 -0
- package/api/theme/integration-themes.test.mjs +30 -6
- package/api/theme/list/list.d.mts +10 -0
- package/api/theme/list/list.mjs +75 -7
- package/api/theme/list/list.test.mjs +155 -4
- package/api/theme/remove/remove.d.mts +12 -0
- package/api/theme/remove/remove.mjs +15 -0
- package/api/theme/remove/remove.test.mjs +94 -0
- package/api/theme/template/template.mjs +3 -4
- package/api/theme/theme.d.mts +5 -2
- package/api/theme/theme.mjs +13 -8
- package/api/theme/theme.type.d.mts +106 -2
- package/api/theme/theme.type.mjs +54 -5
- package/api/theme/themeAdd.doc.d.mts +1 -3
- package/api/theme/themeAdd.doc.mjs +35 -22
- package/api/theme/themeBuild.doc.d.mts +4 -1
- package/api/theme/themeBuild.doc.mjs +15 -4
- package/api/theme/themeEject.doc.d.mts +8 -0
- package/api/theme/themeEject.doc.mjs +89 -0
- package/api/theme/themeListAvailable.doc.mjs +4 -4
- package/api/theme/themeListCopySources.doc.d.mts +8 -0
- package/api/theme/themeListCopySources.doc.mjs +60 -0
- package/api/theme/themeRemove.doc.d.mts +6 -0
- package/api/theme/themeRemove.doc.mjs +50 -0
- package/api/theme/themeTemplate.doc.mjs +4 -3
- package/api/theme/themeUse.doc.d.mts +6 -0
- package/api/theme/themeUse.doc.mjs +47 -0
- package/api/theme/use/use.d.mts +12 -0
- package/api/theme/use/use.mjs +15 -0
- package/api/theme/use/use.test.mjs +98 -0
- package/api/upgrade/_adapter.d.mts +1 -0
- package/api/upgrade/_adapter.mjs +3 -0
- package/api/upgrade/list/list.mjs +9 -3
- package/api/upgrade/run/run.mjs +20 -3
- package/api/upgrade/run/run.test.mjs +45 -1
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.type.d.mts +5 -0
- package/api/upgrade/upgrade.type.mjs +2 -0
- package/assets/codemods/integration-discovery.mjs +1 -1
- package/assets/codemods/integration-discovery.test.mjs +64 -0
- package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/next/index.mjs +14 -1
- package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/author-a-theme.doc.mjs +161 -0
- package/assets/docs/getting-started.doc.mjs +59 -15
- package/assets/docs/icons.doc.mjs +1 -0
- package/assets/docs/principles.doc.dense.mjs +2 -2
- package/assets/docs/principles.doc.mjs +2 -2
- package/assets/docs/principles.doc.zh.mjs +2 -2
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/styling.doc.mjs +2 -2
- package/assets/docs/theme.doc.dense.mjs +10 -198
- package/assets/docs/theme.doc.mjs +13 -770
- package/assets/docs/theme.doc.zh.mjs +31 -12
- package/assets/docs/tokens.doc.mjs +4 -4
- package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
- package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +6 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
- package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +32 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/responsive.doc.mjs +102 -0
- package/assets/docs/tree/scaffold.doc.mjs +145 -0
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/side-panels.doc.mjs +82 -0
- package/assets/docs/tree/structure.doc.mjs +144 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +11 -7
- package/assets/docs/use-a-theme.doc.mjs +209 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
- package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
- package/assets/templates/pages/blank/template.doc.mjs +3 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
- package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
- package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
- package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
- package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
- package/assets/templates/pages/documentation/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
- package/assets/templates/pages/editor/template.doc.mjs +9 -1
- package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
- package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
- package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
- package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
- package/assets/templates/pages/ide/template.doc.mjs +9 -1
- package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
- package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
- package/assets/templates/pages/library/template.doc.mjs +15 -1
- package/assets/templates/pages/login/template.doc.mjs +10 -1
- package/assets/templates/pages/login-card/template.doc.mjs +11 -1
- package/assets/templates/pages/login-split/template.doc.mjs +10 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
- package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
- package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/settings/template.doc.mjs +3 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/table/template.doc.mjs +11 -1
- package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
- package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
- package/assets/templates/pages/table-comparison/page.tsx +1449 -0
- package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
- package/assets/templates/pages/table-filter/template.doc.mjs +21 -1
- package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
- package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
- package/assets/templates/pages/table-page/template.doc.mjs +20 -1
- package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
- package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
- package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
- package/assets/templates/themes/butter/icons.tsx +2 -0
- package/assets/templates/themes/chocolate/icons.tsx +2 -0
- package/assets/templates/themes/gothic/icons.tsx +2 -0
- package/assets/templates/themes/matcha/icons.tsx +2 -0
- package/assets/templates/themes/neutral/icons.tsx +2 -0
- package/assets/templates/themes/stone/icons.tsx +2 -0
- package/assets/templates/themes/y2k/icons.tsx +2 -0
- package/authoring/doctypes/command/command.doc.mjs +5 -0
- package/authoring/doctypes/command/type.ts +2 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -4
- package/authoring/doctypes/template/parse.d.mts +2 -0
- package/authoring/doctypes/template/parse.mjs +1 -0
- package/authoring/doctypes/template/parse.test.mjs +21 -0
- package/authoring/doctypes/template/template.doc.mjs +6 -0
- package/authoring/doctypes/template/type.ts +11 -0
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.mjs +279 -30
- package/clients/cli/commands/build.mjs +7 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +88 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/discover.mjs +29 -1
- package/clients/cli/commands/discover.no-source.test.mjs +75 -0
- package/clients/cli/commands/docs.depth.test.mjs +219 -0
- package/clients/cli/commands/docs.doc.mjs +15 -2
- package/clients/cli/commands/docs.mjs +273 -16
- package/clients/cli/commands/docs.test.mjs +382 -0
- package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +4 -4
- package/clients/cli/commands/doctor.test.mjs +9 -51
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/gap-report.mjs +12 -0
- package/clients/cli/commands/gap-report.test.mjs +63 -0
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/import-hint-correctness.test.mjs +5 -5
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-add.doc.mjs +10 -0
- package/clients/cli/commands/integration-authoring.test.mjs +12 -2
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/integration.mjs +3 -1
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +4 -1
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
- package/clients/cli/commands/layout.mjs +61 -4
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.doc.mjs +5 -4
- package/clients/cli/commands/search.mjs +30 -6
- package/clients/cli/commands/search.test.mjs +63 -17
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
- package/clients/cli/commands/template.mjs +70 -6
- package/clients/cli/commands/template.show-media.test.mjs +62 -0
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +132 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
- package/clients/cli/commands/theme-remove.doc.mjs +22 -0
- package/clients/cli/commands/theme-template.doc.mjs +4 -3
- package/clients/cli/commands/theme-use.doc.mjs +22 -0
- package/clients/cli/commands/theme.doc.mjs +21 -16
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/commands/write-failure.test.mjs +175 -0
- package/clients/cli/index.mjs +4 -1
- package/clients/cli/lib/component-format.mjs +19 -2
- package/clients/cli/lib/manifest.mjs +44 -165
- package/clients/cli/lib/manifest.test.mjs +98 -7
- package/clients/cli/lib/resolve-theme.mjs +80 -78
- package/clients/cli/lib/resolve-theme.test.mjs +523 -27
- package/foundation/agent-docs/agent-docs.mjs +31 -28
- package/foundation/agent-docs/agent-docs.test.mjs +1163 -0
- package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
- package/foundation/config/project.d.mts +20 -5
- package/foundation/config/project.mjs +43 -6
- package/foundation/config/theme-private-vars.d.mts +12 -0
- package/foundation/config/theme-private-vars.mjs +107 -0
- package/foundation/config/theme-private-vars.test.mjs +55 -0
- package/foundation/config/theme-state.d.mts +145 -0
- package/foundation/config/theme-state.mjs +417 -0
- package/foundation/config/theme-state.test.mjs +182 -0
- package/foundation/discovery/component-discovery.d.mts +5 -2
- package/foundation/discovery/component-discovery.mjs +12 -6
- package/foundation/discovery/component-replacement.d.mts +91 -0
- package/foundation/discovery/component-replacement.mjs +417 -0
- package/foundation/discovery/component-replacement.test.mjs +480 -0
- package/foundation/discovery/docs-output-budget.d.mts +6 -2
- package/foundation/discovery/docs-output-budget.mjs +2 -1
- package/foundation/discovery/docs-section-key.d.mts +4 -2
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/module-exports.d.mts +10 -0
- package/foundation/discovery/module-exports.mjs +146 -0
- package/foundation/discovery/package-exports.d.mts +29 -0
- package/foundation/discovery/package-exports.mjs +200 -0
- package/foundation/discovery/template-adapter.d.mts +14 -0
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
- package/foundation/discovery/template-adapter.mjs +21 -1
- package/foundation/discovery/theme-discovery.d.mts +78 -5
- package/foundation/discovery/theme-discovery.mjs +143 -18
- package/foundation/discovery/theme-discovery.test.mjs +9 -3
- package/foundation/discovery/theme-imports.d.mts +15 -0
- package/foundation/discovery/theme-imports.mjs +217 -0
- package/foundation/discovery/theme-imports.test.mjs +173 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +18 -8
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/tree.test.mjs +649 -0
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +79 -13
- package/foundation/integrations/cli-requirement.mjs +115 -22
- package/foundation/integrations/cli-requirement.test.mjs +205 -8
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- package/foundation/response/base.d.ts +9 -3
- package/foundation/response/json.d.mts +7 -4
- package/foundation/response/json.mjs +10 -6
- package/foundation/response/response-types.doc.d.mts +5 -5
- package/foundation/response/response-types.doc.mjs +50 -35
- package/foundation/response/response.doc.mjs +18 -4
- package/foundation/text/copyright-header.mjs +1 -1
- package/foundation/text/copyright-header.test.mjs +1 -1
- package/package.json +9 -9
- package/assets/docs/layout.doc.dense.mjs +0 -388
- package/assets/docs/layout.doc.mjs +0 -550
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Word weights for `build`'s START (spec:AST-048): a checked-in table of
|
|
5
|
+
* per-template word weights, blended with the page ranker's own scores, picks
|
|
6
|
+
* the template an idea starts from.
|
|
7
|
+
*
|
|
8
|
+
* @input An idea, the ranker's output for it (`rankPages`, `pickStart`), the
|
|
9
|
+
* project's ready page templates, and the weights (`weights.json` beside this
|
|
10
|
+
* file, read by the adapter): the candidates (the app shell as `SHELL`, then page template ids), one or more
|
|
11
|
+
* word tables (stemmed words, a bias per candidate, and one row of weights
|
|
12
|
+
* per word, a character per candidate) and the blend numbers.
|
|
13
|
+
* @output `weighStart(idea, ranked, pick, catalog)`: the template id to start
|
|
14
|
+
* from, null for the app shell, or undefined when no table is available, in
|
|
15
|
+
* which case the ranker's own pick stands.
|
|
16
|
+
* @position Beside rank.mjs (api/build/kit/); kit.mjs calls it for every
|
|
17
|
+
* whole page (a part or an edit follows the ranker's placement rules). The
|
|
18
|
+
* ranker's pick of a template the tables do not list stands, so a new
|
|
19
|
+
* template can start a build.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** The app shell, as one candidate. */
|
|
23
|
+
export const SHELL = 'SHELL';
|
|
24
|
+
const SHELL_FAMILY = 'Shell';
|
|
25
|
+
|
|
26
|
+
// The Porter (1980) stemmer.
|
|
27
|
+
/** @type {Record<string, string>} */
|
|
28
|
+
const STEP2 = {
|
|
29
|
+
ational: 'ate',
|
|
30
|
+
tional: 'tion',
|
|
31
|
+
enci: 'ence',
|
|
32
|
+
anci: 'ance',
|
|
33
|
+
izer: 'ize',
|
|
34
|
+
bli: 'ble',
|
|
35
|
+
alli: 'al',
|
|
36
|
+
entli: 'ent',
|
|
37
|
+
eli: 'e',
|
|
38
|
+
ousli: 'ous',
|
|
39
|
+
ization: 'ize',
|
|
40
|
+
ation: 'ate',
|
|
41
|
+
ator: 'ate',
|
|
42
|
+
alism: 'al',
|
|
43
|
+
iveness: 'ive',
|
|
44
|
+
fulness: 'ful',
|
|
45
|
+
ousness: 'ous',
|
|
46
|
+
aliti: 'al',
|
|
47
|
+
iviti: 'ive',
|
|
48
|
+
biliti: 'ble',
|
|
49
|
+
logi: 'log',
|
|
50
|
+
};
|
|
51
|
+
/** @type {Record<string, string>} */
|
|
52
|
+
const STEP3 = {
|
|
53
|
+
icate: 'ic',
|
|
54
|
+
ative: '',
|
|
55
|
+
alize: 'al',
|
|
56
|
+
iciti: 'ic',
|
|
57
|
+
ical: 'ic',
|
|
58
|
+
ful: '',
|
|
59
|
+
ness: '',
|
|
60
|
+
};
|
|
61
|
+
const CONS = '[^aeiou][^aeiouy]*';
|
|
62
|
+
const VOW = '[aeiouy][aeiou]*';
|
|
63
|
+
const MGR0 = new RegExp(`^(${CONS})?${VOW}${CONS}`);
|
|
64
|
+
const MEQ1 = new RegExp(`^(${CONS})?${VOW}${CONS}(${VOW})?$`);
|
|
65
|
+
const MGR1 = new RegExp(`^(${CONS})?${VOW}${CONS}${VOW}${CONS}`);
|
|
66
|
+
const HAS_VOWEL = new RegExp(`^(${CONS})?[aeiouy]`);
|
|
67
|
+
const CVC = new RegExp(`^${CONS}[aeiouy][^aeiouwxy]$`);
|
|
68
|
+
const stems = new Map();
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The Porter stem of a lowercase word.
|
|
72
|
+
* @param {string} word
|
|
73
|
+
* @returns {string}
|
|
74
|
+
*/
|
|
75
|
+
export function stem(word) {
|
|
76
|
+
const cached = stems.get(word);
|
|
77
|
+
if (cached !== undefined) return cached;
|
|
78
|
+
let w = word;
|
|
79
|
+
if (w.length < 3 || /\d/.test(w)) {
|
|
80
|
+
stems.set(word, w);
|
|
81
|
+
return w;
|
|
82
|
+
}
|
|
83
|
+
const leadingY = w[0] === 'y';
|
|
84
|
+
if (leadingY) w = 'Y' + w.slice(1);
|
|
85
|
+
let m;
|
|
86
|
+
if ((m = /^(.+?)(ss|i)es$/.exec(w))) w = m[1] + m[2];
|
|
87
|
+
else if ((m = /^(.+?)([^s])s$/.exec(w))) w = m[1] + m[2];
|
|
88
|
+
if ((m = /^(.+?)eed$/.exec(w))) {
|
|
89
|
+
if (MGR0.test(m[1])) w = w.slice(0, -1);
|
|
90
|
+
} else if ((m = /^(.+?)(ed|ing)$/.exec(w)) && HAS_VOWEL.test(m[1])) {
|
|
91
|
+
w = m[1];
|
|
92
|
+
if (/(at|bl|iz)$/.test(w)) w += 'e';
|
|
93
|
+
else if (/([^aeiouylsz])\1$/.test(w)) w = w.slice(0, -1);
|
|
94
|
+
else if (CVC.test(w)) w += 'e';
|
|
95
|
+
}
|
|
96
|
+
if ((m = /^(.+?)y$/.exec(w)) && HAS_VOWEL.test(m[1])) w = m[1] + 'i';
|
|
97
|
+
if (
|
|
98
|
+
(m =
|
|
99
|
+
/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/.exec(
|
|
100
|
+
w,
|
|
101
|
+
)) &&
|
|
102
|
+
MGR0.test(m[1])
|
|
103
|
+
) {
|
|
104
|
+
w = m[1] + STEP2[m[2]];
|
|
105
|
+
}
|
|
106
|
+
if (
|
|
107
|
+
(m = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/.exec(w)) &&
|
|
108
|
+
MGR0.test(m[1])
|
|
109
|
+
) {
|
|
110
|
+
w = m[1] + STEP3[m[2]];
|
|
111
|
+
}
|
|
112
|
+
if (
|
|
113
|
+
(m =
|
|
114
|
+
/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/.exec(
|
|
115
|
+
w,
|
|
116
|
+
))
|
|
117
|
+
) {
|
|
118
|
+
if (MGR1.test(m[1])) w = m[1];
|
|
119
|
+
} else if ((m = /^(.+?)(s|t)(ion)$/.exec(w)) && MGR1.test(m[1] + m[2])) {
|
|
120
|
+
w = m[1] + m[2];
|
|
121
|
+
}
|
|
122
|
+
if (
|
|
123
|
+
(m = /^(.+?)e$/.exec(w)) &&
|
|
124
|
+
(MGR1.test(m[1]) || (MEQ1.test(m[1]) && !CVC.test(m[1])))
|
|
125
|
+
) {
|
|
126
|
+
w = m[1];
|
|
127
|
+
}
|
|
128
|
+
if (/ll$/.test(w) && MGR1.test(w)) w = w.slice(0, -1);
|
|
129
|
+
if (leadingY) w = 'y' + w.slice(1);
|
|
130
|
+
stems.set(word, w);
|
|
131
|
+
return w;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Lowercase words of an idea that can carry weight: letters only, two or more.
|
|
136
|
+
* @param {string} idea
|
|
137
|
+
* @returns {string[]}
|
|
138
|
+
*/
|
|
139
|
+
export function weightWords(idea) {
|
|
140
|
+
return String(idea ?? '')
|
|
141
|
+
.toLowerCase()
|
|
142
|
+
.split(/[^a-z0-9]+/)
|
|
143
|
+
.filter(w => w.length >= 2 && !/\d/.test(w));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @typedef {object} WeightTable
|
|
148
|
+
* @property {string[]} words stemmed words
|
|
149
|
+
* @property {number[]} bias one per candidate
|
|
150
|
+
* @property {number} clip
|
|
151
|
+
* @property {number} step
|
|
152
|
+
* @property {string[]} rows one per word: a character per candidate,
|
|
153
|
+
* weight = (charCode - 97) * step - clip
|
|
154
|
+
*
|
|
155
|
+
* @typedef {object} WeightsFile
|
|
156
|
+
* @property {number} version
|
|
157
|
+
* @property {string[]} candidates `SHELL`, then page template ids
|
|
158
|
+
* @property {WeightTable[]} tables
|
|
159
|
+
* @property {number[]} blend three numbers per member (the tables, in order,
|
|
160
|
+
* with the ranker second), then one for `SHELL`
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* A table's score for every candidate.
|
|
165
|
+
* @param {WeightTable} table
|
|
166
|
+
* @param {Map<string, number>} index word -> row
|
|
167
|
+
* @param {Set<string>} words the idea's stemmed words
|
|
168
|
+
* @param {number} n candidates
|
|
169
|
+
*/
|
|
170
|
+
function tableScores(table, index, words, n) {
|
|
171
|
+
const out = Float64Array.from(table.bias.slice(0, n));
|
|
172
|
+
for (const w of words) {
|
|
173
|
+
const i = index.get(w);
|
|
174
|
+
if (i === undefined) continue;
|
|
175
|
+
const row = table.rows[i];
|
|
176
|
+
for (let c = 0; c < n; c++) {
|
|
177
|
+
out[c] += (row.charCodeAt(c) - 97) * table.step - table.clip;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return out;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** @param {number} x */
|
|
184
|
+
const round4 = x => Math.round(x * 1e4) / 1e4;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The ranker's scores as a blend member: every non-shell template's rank
|
|
188
|
+
* score, the ranker's own start lifted above the rest, and the app shell above
|
|
189
|
+
* them all when the ranker would start from it.
|
|
190
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
191
|
+
* @param {import('./rank.mjs').RankedPage | null} pick
|
|
192
|
+
*/
|
|
193
|
+
function rankerScores(ranked, pick) {
|
|
194
|
+
/** @type {Map<string, number>} */
|
|
195
|
+
const out = new Map();
|
|
196
|
+
for (const r of ranked)
|
|
197
|
+
if (r.family !== SHELL_FAMILY) out.set(r.name, r.score);
|
|
198
|
+
const top = Math.max(0, ...out.values());
|
|
199
|
+
const pageStart = pick && pick.family !== SHELL_FAMILY ? pick.name : null;
|
|
200
|
+
out.set(SHELL, pageStart ? -1 : top + 1);
|
|
201
|
+
if (pageStart) out.set(pageStart, top + 2);
|
|
202
|
+
return out;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Per-candidate features of one member's scores: z-score, 1/(rank+1), is-top.
|
|
207
|
+
* @param {(number | undefined)[]} v a score per candidate (undefined: none)
|
|
208
|
+
*/
|
|
209
|
+
function memberFeatures(v) {
|
|
210
|
+
const finite = /** @type {number[]} */ (v.filter(x => x !== undefined));
|
|
211
|
+
const mean = finite.reduce((a, b) => a + b, 0) / Math.max(1, finite.length);
|
|
212
|
+
const sd =
|
|
213
|
+
Math.sqrt(
|
|
214
|
+
finite.reduce((a, b) => a + (b - mean) ** 2, 0) /
|
|
215
|
+
Math.max(1, finite.length),
|
|
216
|
+
) || 1;
|
|
217
|
+
const val = v.map(x => (x === undefined ? -1e9 : x));
|
|
218
|
+
const order = [...val.keys()].sort((a, b) => val[b] - val[a]);
|
|
219
|
+
const rank = new Array(v.length);
|
|
220
|
+
order.forEach((ci, r) => (rank[ci] = r));
|
|
221
|
+
return v.map((x, i) => [
|
|
222
|
+
x === undefined ? -4 : Math.max(-4, Math.min(4, (x - mean) / sd)),
|
|
223
|
+
1 / (rank[i] + 1),
|
|
224
|
+
rank[i] === 0 ? 1 : 0,
|
|
225
|
+
]);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Where an idea starts, by the blended weights.
|
|
230
|
+
* @param {string} idea
|
|
231
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked the ranker's output for the idea
|
|
232
|
+
* @param {import('./rank.mjs').RankedPage | null} pick the ranker's own start
|
|
233
|
+
* @param {{name: string}[]} catalog the project's ready page templates
|
|
234
|
+
* @param {{weights?: WeightsFile | null, newPage?: boolean}} [options]
|
|
235
|
+
* `newPage`: the idea asks for a new page (rank.mjs `asksForNewPage`)
|
|
236
|
+
* @returns {string | null | undefined} a template id, null for the app shell,
|
|
237
|
+
* undefined without weights
|
|
238
|
+
*/
|
|
239
|
+
export function weighStart(
|
|
240
|
+
idea,
|
|
241
|
+
ranked,
|
|
242
|
+
pick,
|
|
243
|
+
catalog,
|
|
244
|
+
{weights = null, newPage = false} = {},
|
|
245
|
+
) {
|
|
246
|
+
if (!weights) return undefined;
|
|
247
|
+
const ready = new Set(catalog.map(t => t.name));
|
|
248
|
+
const shellIds = new Set(
|
|
249
|
+
ranked.filter(r => r.family === SHELL_FAMILY).map(r => r.name),
|
|
250
|
+
);
|
|
251
|
+
// Candidates: the app shell and every ready, non-shell template, the
|
|
252
|
+
// table's first, then any the table does not list.
|
|
253
|
+
const listed = weights.candidates.filter(c => c === SHELL || ready.has(c));
|
|
254
|
+
const extra = catalog
|
|
255
|
+
.map(t => t.name)
|
|
256
|
+
.filter(n => !shellIds.has(n) && !weights.candidates.includes(n));
|
|
257
|
+
const cands = [...listed, ...extra];
|
|
258
|
+
const position = new Map(weights.candidates.map((c, i) => [c, i]));
|
|
259
|
+
const words = new Set(weightWords(idea).map(stem));
|
|
260
|
+
/** @type {(number | undefined)[][]} */
|
|
261
|
+
const members = weights.tables.map(table => {
|
|
262
|
+
const index = new Map(table.words.map((w, i) => [w, i]));
|
|
263
|
+
const s = tableScores(table, index, words, weights.candidates.length);
|
|
264
|
+
return cands.map(c => {
|
|
265
|
+
const i = position.get(c);
|
|
266
|
+
return i === undefined ? undefined : round4(s[i]);
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
const fromRanker = rankerScores(ranked, pick);
|
|
270
|
+
const rankerMember = cands.map(c => {
|
|
271
|
+
const x = fromRanker.get(c);
|
|
272
|
+
return x === undefined ? undefined : round4(x);
|
|
273
|
+
});
|
|
274
|
+
// The ranker is the blend's second member, after the first table.
|
|
275
|
+
members.splice(1, 0, rankerMember);
|
|
276
|
+
const feats = members.map(memberFeatures);
|
|
277
|
+
const scores = cands.map((c, i) => {
|
|
278
|
+
let s = 0;
|
|
279
|
+
let j = 0;
|
|
280
|
+
for (const f of feats) for (const x of f[i]) s += x * weights.blend[j++];
|
|
281
|
+
return s + (c === SHELL ? 1 : 0) * weights.blend[j];
|
|
282
|
+
});
|
|
283
|
+
/** @param {(c: string) => boolean} ok */
|
|
284
|
+
const best = ok => {
|
|
285
|
+
let at = -1;
|
|
286
|
+
for (let c = 0; c < cands.length; c++) {
|
|
287
|
+
if (ok(cands[c]) && (at < 0 || scores[c] > scores[at])) at = c;
|
|
288
|
+
}
|
|
289
|
+
return at < 0 ? null : cands[at];
|
|
290
|
+
};
|
|
291
|
+
const kept =
|
|
292
|
+
pick && pick.family !== SHELL_FAMILY && cands.includes(pick.name)
|
|
293
|
+
? pick.name
|
|
294
|
+
: null;
|
|
295
|
+
// The tables cannot judge a template they do not list, and a template the
|
|
296
|
+
// ranker placed by its frame stays (spec:AST-048/FR3): the ranker's pick
|
|
297
|
+
// stands for both.
|
|
298
|
+
if (kept && (!position.has(kept) || pick?.containerMatched)) return kept;
|
|
299
|
+
const top = best(() => true);
|
|
300
|
+
if (top !== SHELL) return top;
|
|
301
|
+
// An idea that asks for a new page keeps the ranker's template rather than
|
|
302
|
+
// the shell.
|
|
303
|
+
if (newPage && kept) return kept;
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {describe, expect, it} from 'vitest';
|
|
4
|
+
|
|
5
|
+
import {isWeightsFile} from '../_adapter.mjs';
|
|
6
|
+
import {SHELL, stem, weighStart, weightWords} from './weights.mjs';
|
|
7
|
+
|
|
8
|
+
// A made-up table for tests only: three page templates and the app shell.
|
|
9
|
+
const CANDIDATES = [SHELL, 'board', 'charts', 'grid'];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {Record<string, number[]>} weights per word, one value per candidate
|
|
13
|
+
* @param {number[]} [bias]
|
|
14
|
+
* @param {number} [step]
|
|
15
|
+
* @param {number} [clip]
|
|
16
|
+
*/
|
|
17
|
+
function table(weights, bias = [0, 0, 0, 0], step = 0.5, clip = 4) {
|
|
18
|
+
return {
|
|
19
|
+
words: Object.keys(weights),
|
|
20
|
+
bias,
|
|
21
|
+
clip,
|
|
22
|
+
step,
|
|
23
|
+
rows: Object.values(weights).map(ws =>
|
|
24
|
+
ws
|
|
25
|
+
.map(w => String.fromCharCode(97 + Math.round((w + clip) / step)))
|
|
26
|
+
.join(''),
|
|
27
|
+
),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const WEIGHTS = {
|
|
32
|
+
version: 1,
|
|
33
|
+
candidates: CANDIDATES,
|
|
34
|
+
tables: [
|
|
35
|
+
table({
|
|
36
|
+
[stem('kanban')]: [0, 3, 0, 0],
|
|
37
|
+
[stem('existing')]: [3, 0, 0, 0],
|
|
38
|
+
[stem('charts')]: [0, 0, 2, 0],
|
|
39
|
+
}),
|
|
40
|
+
table({[stem('cards')]: [0, 0, 0, 1]}, [0, 0, 0, 0], 1, 4),
|
|
41
|
+
],
|
|
42
|
+
// three numbers per member (table 1, the ranker, table 2), then one for SHELL
|
|
43
|
+
blend: [1, 0, 0, 0.5, 0, 0, 0.2, 0, 0, 0],
|
|
44
|
+
};
|
|
45
|
+
const CATALOG = [
|
|
46
|
+
{name: 'board'},
|
|
47
|
+
{name: 'charts'},
|
|
48
|
+
{name: 'grid'},
|
|
49
|
+
{name: 'top-nav'},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {string} name
|
|
54
|
+
* @param {number} score
|
|
55
|
+
* @param {string} family
|
|
56
|
+
*/
|
|
57
|
+
const page = (name, score, family) => ({
|
|
58
|
+
name,
|
|
59
|
+
score,
|
|
60
|
+
hits: 1,
|
|
61
|
+
family,
|
|
62
|
+
base: true,
|
|
63
|
+
familyNamed: false,
|
|
64
|
+
containerMatched: false,
|
|
65
|
+
matched: new Set(),
|
|
66
|
+
});
|
|
67
|
+
/** A ranker output that prefers `charts`. */
|
|
68
|
+
const RANKED = [
|
|
69
|
+
page('charts', 3, 'Charts'),
|
|
70
|
+
page('grid', 1, 'Grid'),
|
|
71
|
+
page('board', 0.5, 'Board'),
|
|
72
|
+
page('top-nav', 0, 'Shell'),
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
describe('weighStart', () => {
|
|
76
|
+
it('lets the word weights outvote the ranker', () => {
|
|
77
|
+
const start = weighStart(
|
|
78
|
+
'a kanban for launches',
|
|
79
|
+
RANKED,
|
|
80
|
+
RANKED[0],
|
|
81
|
+
CATALOG,
|
|
82
|
+
{
|
|
83
|
+
weights: WEIGHTS,
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
expect(start).toBe('board');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('keeps the ranker when the words carry no weight', () => {
|
|
90
|
+
const start = weighStart('something else', RANKED, RANKED[0], CATALOG, {
|
|
91
|
+
weights: WEIGHTS,
|
|
92
|
+
});
|
|
93
|
+
expect(start).toBe('charts');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('returns null for the app shell', () => {
|
|
97
|
+
const start = weighStart('tweak the existing page', RANKED, null, CATALOG, {
|
|
98
|
+
weights: WEIGHTS,
|
|
99
|
+
});
|
|
100
|
+
expect(start).toBeNull();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('returns undefined without weights, so the ranker decides', () => {
|
|
104
|
+
const start = weighStart('a kanban', RANKED, RANKED[0], CATALOG, {
|
|
105
|
+
weights: null,
|
|
106
|
+
});
|
|
107
|
+
expect(start).toBeUndefined();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('never starts from a template the project does not have', () => {
|
|
111
|
+
const catalog = CATALOG.filter(t => t.name !== 'board');
|
|
112
|
+
const ranked = RANKED.filter(r => r.name !== 'board');
|
|
113
|
+
const start = weighStart('a kanban', ranked, ranked[0], catalog, {
|
|
114
|
+
weights: WEIGHTS,
|
|
115
|
+
});
|
|
116
|
+
expect(start).not.toBe('board');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("keeps the ranker's pick of a template the tables do not list", () => {
|
|
120
|
+
const catalog = [...CATALOG, {name: 'fresh'}];
|
|
121
|
+
const ranked = [page('fresh', 9, 'Fresh'), ...RANKED];
|
|
122
|
+
const start = weighStart('a kanban', ranked, ranked[0], catalog, {
|
|
123
|
+
weights: WEIGHTS,
|
|
124
|
+
});
|
|
125
|
+
expect(start).toBe('fresh');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("keeps the ranker's template for an idea that asks for a new page", () => {
|
|
129
|
+
const start = weighStart('the existing page', RANKED, RANKED[0], CATALOG, {
|
|
130
|
+
weights: WEIGHTS,
|
|
131
|
+
newPage: true,
|
|
132
|
+
});
|
|
133
|
+
expect(start).toBe('charts');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('starts a new page from the shell when the ranker has no template', () => {
|
|
137
|
+
const start = weighStart('the existing page', RANKED, null, CATALOG, {
|
|
138
|
+
weights: WEIGHTS,
|
|
139
|
+
newPage: true,
|
|
140
|
+
});
|
|
141
|
+
expect(start).toBeNull();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('keeps a template the ranker placed by its frame', () => {
|
|
145
|
+
const framed = {...RANKED[1], containerMatched: true};
|
|
146
|
+
for (const idea of ['the existing page', 'a kanban']) {
|
|
147
|
+
const start = weighStart(idea, RANKED, framed, CATALOG, {
|
|
148
|
+
weights: WEIGHTS,
|
|
149
|
+
});
|
|
150
|
+
expect(start).toBe('grid');
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('is deterministic', () => {
|
|
155
|
+
const run = () =>
|
|
156
|
+
weighStart('kanban charts cards', RANKED, RANKED[0], CATALOG, {
|
|
157
|
+
weights: WEIGHTS,
|
|
158
|
+
});
|
|
159
|
+
expect(run()).toBe(run());
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe('weightWords', () => {
|
|
164
|
+
it('keeps letter words of two or more characters', () => {
|
|
165
|
+
expect(weightWords('A 3-col Dashboard, v2 KPIs!')).toEqual([
|
|
166
|
+
'col',
|
|
167
|
+
'dashboard',
|
|
168
|
+
'kpis',
|
|
169
|
+
]);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
describe('isWeightsFile', () => {
|
|
174
|
+
it('accepts a well-formed file', () => {
|
|
175
|
+
expect(isWeightsFile(WEIGHTS)).toBe(true);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('rejects a file whose rows, bias or blend do not fit the candidates', () => {
|
|
179
|
+
const [first, second] = WEIGHTS.tables;
|
|
180
|
+
expect(isWeightsFile({...WEIGHTS, blend: [1, 2, 3]})).toBe(false);
|
|
181
|
+
expect(
|
|
182
|
+
isWeightsFile({...WEIGHTS, tables: [{...first, rows: ['ab']}, second]}),
|
|
183
|
+
).toBe(false);
|
|
184
|
+
expect(
|
|
185
|
+
isWeightsFile({...WEIGHTS, tables: [{...first, bias: [0]}, second]}),
|
|
186
|
+
).toBe(false);
|
|
187
|
+
expect(isWeightsFile({version: 1})).toBe(false);
|
|
188
|
+
expect(isWeightsFile(null)).toBe(false);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
@@ -68,6 +68,25 @@ export function requireCoreDir(cwd: string): string;
|
|
|
68
68
|
* @returns {Promise<import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]>}
|
|
69
69
|
*/
|
|
70
70
|
export function loadIntegrationsSafely(cwd: string): Promise<import("../../foundation/integrations/integrations.mjs").LoadedIntegration[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Every component replacement the loaded integrations declare
|
|
73
|
+
* (spec:AST-035 FR10–FR15): the active one for each replaced Core component,
|
|
74
|
+
* and the findings Doctor reports. With no Core directory, only the opt-in
|
|
75
|
+
* and value findings are computed.
|
|
76
|
+
* @param {string|null} coreDir
|
|
77
|
+
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
78
|
+
* @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ComponentReplacements>}
|
|
79
|
+
*/
|
|
80
|
+
export function loadComponentReplacements(coreDir: string | null, loadedIntegrations: import("../../foundation/integrations/integrations.mjs").LoadedIntegration[]): Promise<import("../../foundation/discovery/component-replacement.mjs").ComponentReplacements>;
|
|
81
|
+
/**
|
|
82
|
+
* The integration component that answers to the Core component name
|
|
83
|
+
* `dirName` for unqualified lookup, or undefined when none replaces it.
|
|
84
|
+
* @param {string} coreDir
|
|
85
|
+
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
86
|
+
* @param {string} dirName
|
|
87
|
+
* @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ActiveComponentReplacement | undefined>}
|
|
88
|
+
*/
|
|
89
|
+
export function resolveComponentReplacement(coreDir: string, loadedIntegrations: import("../../foundation/integrations/integrations.mjs").LoadedIntegration[], dirName: string): Promise<import("../../foundation/discovery/component-replacement.mjs").ActiveComponentReplacement | undefined>;
|
|
71
90
|
/**
|
|
72
91
|
* Read the exact installed version available to a package-qualified component
|
|
73
92
|
* selector. Legacy docs packages do not expose a reliable version here, so a
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
} from '../../foundation/discovery/component-discovery.mjs';
|
|
39
39
|
import {Project} from '../../foundation/config/project.mjs';
|
|
40
40
|
import {loadComponentDoc as loadValidatedComponentDoc} from '../../foundation/discovery/component-loader.mjs';
|
|
41
|
+
import {resolveComponentReplacements} from '../../foundation/discovery/component-replacement.mjs';
|
|
41
42
|
import {searchComponents} from '../../foundation/text/string-utils.mjs';
|
|
42
43
|
import {AstryxError} from '../error.mjs';
|
|
43
44
|
|
|
@@ -138,6 +139,38 @@ export async function loadIntegrationsSafely(cwd) {
|
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Every component replacement the loaded integrations declare
|
|
144
|
+
* (spec:AST-035 FR10–FR15): the active one for each replaced Core component,
|
|
145
|
+
* and the findings Doctor reports. With no Core directory, only the opt-in
|
|
146
|
+
* and value findings are computed.
|
|
147
|
+
* @param {string|null} coreDir
|
|
148
|
+
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
149
|
+
* @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ComponentReplacements>}
|
|
150
|
+
*/
|
|
151
|
+
export function loadComponentReplacements(coreDir, loadedIntegrations) {
|
|
152
|
+
return resolveComponentReplacements(coreDir, loadedIntegrations);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The integration component that answers to the Core component name
|
|
157
|
+
* `dirName` for unqualified lookup, or undefined when none replaces it.
|
|
158
|
+
* @param {string} coreDir
|
|
159
|
+
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
160
|
+
* @param {string} dirName
|
|
161
|
+
* @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ActiveComponentReplacement | undefined>}
|
|
162
|
+
*/
|
|
163
|
+
export async function resolveComponentReplacement(
|
|
164
|
+
coreDir,
|
|
165
|
+
loadedIntegrations,
|
|
166
|
+
dirName,
|
|
167
|
+
) {
|
|
168
|
+
if (loadedIntegrations.length === 0) return undefined;
|
|
169
|
+
return (
|
|
170
|
+
await resolveComponentReplacements(coreDir, loadedIntegrations)
|
|
171
|
+
).forTarget(dirName);
|
|
172
|
+
}
|
|
173
|
+
|
|
141
174
|
/**
|
|
142
175
|
* Resolve a loaded integration by package name.
|
|
143
176
|
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|