@astryxdesign/cli 0.6.5 → 0.6.6-canary.13d926e
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 +43 -0
- package/api/doctor/_adapter.mjs +142 -0
- package/api/doctor/doctor.d.mts +0 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +6 -123
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +1117 -0
- package/api/doctor/theme-checks.test.mjs +526 -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 +10 -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
package/api/search/search.mjs
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* outputs. The CLI command handler is a thin wrapper around this function.
|
|
8
8
|
*
|
|
9
9
|
* `search(query)` is the single "I'm looking for X" entry point across ALL
|
|
10
|
-
* content domains — components, hooks, docs topics,
|
|
11
|
-
*
|
|
12
|
-
* (`component --list`, `hook --list`, `docs`, `template --list`)
|
|
13
|
-
* scanning; this collapses them into one ranked, typed result set.
|
|
10
|
+
* content domains — components, hooks, docs topics, templates (page + block),
|
|
11
|
+
* and themes. Finding the right thing otherwise takes separate list calls
|
|
12
|
+
* (`component --list`, `hook --list`, `docs`, `template --list`, `theme list`)
|
|
13
|
+
* plus manual scanning; this collapses them into one ranked, typed result set.
|
|
14
14
|
*
|
|
15
15
|
* Scoring is keyword + fuzzy ranking (NOT semantic / embeddings — that is a
|
|
16
16
|
* deliberate future follow-up). It reuses the same signal weighting as the
|
|
@@ -80,15 +80,20 @@ import {
|
|
|
80
80
|
findComponentReadme,
|
|
81
81
|
resolveImportPath,
|
|
82
82
|
resolveIntegrationImportPath,
|
|
83
|
+
CORE_PACKAGE,
|
|
83
84
|
} from '../../foundation/discovery/component-discovery.mjs';
|
|
84
85
|
import {
|
|
85
86
|
discoverHooks,
|
|
86
87
|
findHookDoc,
|
|
87
88
|
} from '../../foundation/discovery/hook-discovery.mjs';
|
|
88
|
-
import {
|
|
89
|
+
import {
|
|
90
|
+
loadComponentReplacements,
|
|
91
|
+
loadIntegrationsSafely,
|
|
92
|
+
} from '../component/_adapter.mjs';
|
|
89
93
|
import {levenshteinDistance} from '../../foundation/text/string-utils.mjs';
|
|
90
94
|
import {discoverTemplates, extractComponents} from '../template/template.mjs';
|
|
91
95
|
import {templateLookupIds} from '../../foundation/discovery/template-adapter.mjs';
|
|
96
|
+
import {listAvailableThemes} from '../theme/_adapter.mjs';
|
|
92
97
|
import {
|
|
93
98
|
guideEntry,
|
|
94
99
|
loadDocsCatalog,
|
|
@@ -110,8 +115,10 @@ import {setResultCoverage} from './coverage.mjs';
|
|
|
110
115
|
* A search candidate gathered from one content domain. Extra underscore-
|
|
111
116
|
* prefixed fields carry domain-specific payload used only by {@link toResult}.
|
|
112
117
|
* @typedef {object} Candidate
|
|
113
|
-
* @property {'component'|'hook'|'doc'|'template'} domain
|
|
118
|
+
* @property {'component'|'hook'|'doc'|'template'|'theme'} domain
|
|
114
119
|
* @property {string} name
|
|
120
|
+
* @property {string[]} [aliases] - Other names the candidate answers to, scored
|
|
121
|
+
* with the same name signals: a theme's display name.
|
|
115
122
|
* @property {string[]} [keywords]
|
|
116
123
|
* @property {string[]} [weakKeywords]
|
|
117
124
|
* @property {string} [description]
|
|
@@ -127,9 +134,9 @@ import {setResultCoverage} from './coverage.mjs';
|
|
|
127
134
|
* @property {string} [_command] - The command that reads exactly this doc part.
|
|
128
135
|
* @property {string} [_parent] - The command that opens the level above a doc
|
|
129
136
|
* part: its topic's section list, or the docs-tree namespace it sits in.
|
|
130
|
-
* @property {string} [_package] - The npm package that
|
|
131
|
-
*
|
|
132
|
-
*
|
|
137
|
+
* @property {string} [_package] - The npm package that owns the candidate:
|
|
138
|
+
* Core's package for its components, hooks, and templates, the integration's
|
|
139
|
+
* for what it contributed, and for a doc part the package that wrote it.
|
|
133
140
|
* @property {string} [_displayName]
|
|
134
141
|
* @property {'page'|'block'} [_kind]
|
|
135
142
|
* @property {string} [_resultName]
|
|
@@ -291,7 +298,13 @@ const isTypo = (a, b, dist) =>
|
|
|
291
298
|
TYPO_MIN_LENGTH[/** @type {1 | 2 | 3} */ (dist)];
|
|
292
299
|
|
|
293
300
|
/** Valid domain filters for `--type`. */
|
|
294
|
-
export const SEARCH_DOMAINS = ['component', 'hook', 'doc', 'template'];
|
|
301
|
+
export const SEARCH_DOMAINS = ['component', 'hook', 'doc', 'template', 'theme'];
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* The domains a search reads without @astryxdesign/core. An open search outside
|
|
305
|
+
* an app covers these alone.
|
|
306
|
+
*/
|
|
307
|
+
const CORELESS_DOMAINS = ['doc', 'theme'];
|
|
295
308
|
|
|
296
309
|
/**
|
|
297
310
|
* Filler words stripped from multi-word queries so natural-language phrasing
|
|
@@ -618,6 +631,7 @@ export function scoreQuery(term, tokens, candidate) {
|
|
|
618
631
|
// strong hits, then reward coverage so candidates matching more terms win.
|
|
619
632
|
let strongest = 0;
|
|
620
633
|
let matched = 0;
|
|
634
|
+
let tokenSum = 0;
|
|
621
635
|
/** @type {string[]} */
|
|
622
636
|
const hitTerms = [];
|
|
623
637
|
for (const tok of tokens) {
|
|
@@ -626,6 +640,7 @@ export function scoreQuery(term, tokens, candidate) {
|
|
|
626
640
|
if (h.score > strongest) strongest = h.score;
|
|
627
641
|
matched++;
|
|
628
642
|
hitTerms.push(tok);
|
|
643
|
+
tokenSum += h.score;
|
|
629
644
|
}
|
|
630
645
|
}
|
|
631
646
|
// The reverse of the title tier, a step lower: the query holds a whole title
|
|
@@ -650,14 +665,25 @@ export function scoreQuery(term, tokens, candidate) {
|
|
|
650
665
|
// (50 + bonus + coverage = 77) lost to thirty docs that each match
|
|
651
666
|
// `integration` alone, by name or in a code tick (98-108). The reader asked for
|
|
652
667
|
// both; a candidate that has both comes first, ordered among its peers by
|
|
653
|
-
// how strong its
|
|
668
|
+
// how strong its matches are. It needs one keyword-strength hit:
|
|
654
669
|
// every word mentioned in prose, or rendered by a page, is breadth, and
|
|
655
670
|
// stays on the token sum below an exact hit on one word.
|
|
671
|
+
//
|
|
672
|
+
// The TOTAL quality of matches orders candidates within this tier, not
|
|
673
|
+
// just the strongest single hit. A doc matching both words by keyword
|
|
674
|
+
// (90 + 90 = 180) outranks one matching keyword + prose (90 + 50 = 140).
|
|
675
|
+
// Before this, every all-word match whose strongest hit was a keyword (90)
|
|
676
|
+
// scored 157, burying the better match among dozens of ties.
|
|
656
677
|
if (matched === tokens.length && strongest >= STRONG_TOKEN_SCORE) {
|
|
657
678
|
return {
|
|
658
679
|
score:
|
|
659
680
|
FULL_COVERAGE_SCORE +
|
|
660
|
-
Math.
|
|
681
|
+
Math.min(
|
|
682
|
+
Math.floor(
|
|
683
|
+
(tokenSum - matched * MIN_TOKEN_SCORE) / (matched * 5),
|
|
684
|
+
),
|
|
685
|
+
8,
|
|
686
|
+
),
|
|
661
687
|
reason,
|
|
662
688
|
matched,
|
|
663
689
|
total,
|
|
@@ -697,6 +723,7 @@ export function scoreQuery(term, tokens, candidate) {
|
|
|
697
723
|
* @param {string} term - Lowercased search term.
|
|
698
724
|
* @param {object} candidate
|
|
699
725
|
* @param {string} candidate.name - Primary identifier (component/hook name, topic, template name).
|
|
726
|
+
* @param {string[]} [candidate.aliases] - Other names, scored like the name (a theme's display name).
|
|
700
727
|
* @param {string} [candidate.domain] - A component, hook, or template name
|
|
701
728
|
* also matches typed as words: `command palette` is CommandPalette.
|
|
702
729
|
* @param {string[]} [candidate.keywords] - Authored intent (componentsUsed, category words).
|
|
@@ -711,6 +738,7 @@ export function scoreCandidate(
|
|
|
711
738
|
term,
|
|
712
739
|
{
|
|
713
740
|
name,
|
|
741
|
+
aliases = [],
|
|
714
742
|
domain,
|
|
715
743
|
keywords = [],
|
|
716
744
|
weakKeywords = [],
|
|
@@ -733,40 +761,44 @@ export function scoreCandidate(
|
|
|
733
761
|
}
|
|
734
762
|
};
|
|
735
763
|
|
|
736
|
-
const nameLower = name.toLowerCase();
|
|
737
|
-
// A placed guide's name is its route, and the route's last segment is its
|
|
738
|
-
// name too, as a flat topic's is: `codemods` is cli/integrations/codemods.
|
|
739
|
-
const leafLower = nameLower.slice(nameLower.lastIndexOf('/') + 1);
|
|
740
|
-
|
|
741
764
|
// ── Name signals ────────────────────────────────────────────────
|
|
742
|
-
//
|
|
743
|
-
//
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
//
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
);
|
|
765
|
+
// An alias is a name too: a theme answers to its display name as well as
|
|
766
|
+
// its slug.
|
|
767
|
+
for (const candidateName of [name, ...aliases.filter(Boolean)]) {
|
|
768
|
+
const nameLower = candidateName.toLowerCase();
|
|
769
|
+
// A placed guide's name is its route, and the route's last segment is its
|
|
770
|
+
// name too, as a flat topic's is: `codemods` is cli/integrations/codemods.
|
|
771
|
+
const leafLower = nameLower.slice(nameLower.lastIndexOf('/') + 1);
|
|
772
|
+
|
|
773
|
+
// A plural of the name is the name: `integration` is the `integrations`
|
|
774
|
+
// guides, `tab` the `tabs` doc.
|
|
775
|
+
// A component, hook, or template name typed as words is its name:
|
|
776
|
+
// `command palette` is CommandPalette. A doc's name is a route or key,
|
|
777
|
+
// matched as written.
|
|
778
|
+
const spelled =
|
|
779
|
+
domain !== 'doc' &&
|
|
780
|
+
!/[\s_-]/.test(nameLower) &&
|
|
781
|
+
nameLower === term.replace(/\s+/g, '');
|
|
782
|
+
if (nameLower === term || leafLower === term || spelled) {
|
|
783
|
+
consider(100, 'exact name');
|
|
784
|
+
} else if (pluralOf(nameLower, term) || pluralOf(term, nameLower)) {
|
|
785
|
+
// One point under the exact spelling, so the doc named `tokens` still
|
|
786
|
+
// outranks the Token component for `tokens`.
|
|
787
|
+
consider(99, 'plural of the name');
|
|
788
|
+
} else {
|
|
789
|
+
if (sameWord(term, nameLower)) consider(95, `name "${candidateName}"`);
|
|
790
|
+
// The term is a word of the name, or starts one: "input" in TextInput.
|
|
791
|
+
else if (startsAWordOf(term, candidateName)) {
|
|
792
|
+
consider(60, `name contains "${term}"`);
|
|
793
|
+
}
|
|
794
|
+
if (fuzzy) {
|
|
795
|
+
const dist = levenshteinDistance(term, nameLower);
|
|
796
|
+
if (isTypo(term, nameLower, dist)) {
|
|
797
|
+
consider(
|
|
798
|
+
dist === 1 ? 80 : dist === 2 ? 40 : 20,
|
|
799
|
+
`similar name (distance ${dist})`,
|
|
800
|
+
);
|
|
801
|
+
}
|
|
770
802
|
}
|
|
771
803
|
}
|
|
772
804
|
}
|
|
@@ -939,6 +971,7 @@ async function gatherCoreComponents(coreDir) {
|
|
|
939
971
|
keywords,
|
|
940
972
|
description,
|
|
941
973
|
guidance,
|
|
974
|
+
_package: CORE_PACKAGE,
|
|
942
975
|
_import: resolveImportPath(coreDir, comp),
|
|
943
976
|
});
|
|
944
977
|
}
|
|
@@ -952,11 +985,10 @@ async function gatherCoreComponents(coreDir) {
|
|
|
952
985
|
* this, an integration component is invisible to `search`/`build` even
|
|
953
986
|
* though `component --list`/`component <Name>` already resolve it — the two
|
|
954
987
|
* discovery paths silently disagreed.
|
|
955
|
-
* @param {
|
|
988
|
+
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
956
989
|
* @returns {Promise<Candidate[]>}
|
|
957
990
|
*/
|
|
958
|
-
async function gatherIntegrationComponents(
|
|
959
|
-
const loadedIntegrations = await loadIntegrationsSafely(cwd);
|
|
991
|
+
async function gatherIntegrationComponents(loadedIntegrations) {
|
|
960
992
|
/** @type {Candidate[]} */
|
|
961
993
|
const candidates = [];
|
|
962
994
|
for (const integration of loadedIntegrations) {
|
|
@@ -969,6 +1001,7 @@ async function gatherIntegrationComponents(cwd) {
|
|
|
969
1001
|
keywords: doc && Array.isArray(doc.keywords) ? doc.keywords : [],
|
|
970
1002
|
description: doc ? doc.usage?.description || doc.description || '' : '',
|
|
971
1003
|
guidance: guidanceFrom(doc),
|
|
1004
|
+
_package: rec.package ?? integration.name,
|
|
972
1005
|
// Exactly what `component` reports: a doc may state its own specifier
|
|
973
1006
|
// (one entry point exporting several components), and only when it
|
|
974
1007
|
// does not do we resolve the subpath against the owning package's
|
|
@@ -1000,11 +1033,105 @@ async function gatherIntegrationComponents(cwd) {
|
|
|
1000
1033
|
* @returns {Promise<Candidate[]>}
|
|
1001
1034
|
*/
|
|
1002
1035
|
async function gatherComponents(coreDir, cwd) {
|
|
1003
|
-
const
|
|
1036
|
+
const loadedIntegrations = await loadIntegrationsSafely(cwd);
|
|
1037
|
+
const [core, integrations, replacements] = await Promise.all([
|
|
1004
1038
|
gatherCoreComponents(coreDir),
|
|
1005
|
-
gatherIntegrationComponents(
|
|
1039
|
+
gatherIntegrationComponents(loadedIntegrations),
|
|
1040
|
+
loadComponentReplacements(coreDir, loadedIntegrations),
|
|
1006
1041
|
]);
|
|
1007
|
-
|
|
1042
|
+
// An active replacement answers to the Core name it replaces, so a search
|
|
1043
|
+
// for that name finds the replacement and not the Core original
|
|
1044
|
+
// (spec:AST-035 FR11).
|
|
1045
|
+
/** @type {Map<string, string>} */
|
|
1046
|
+
const targetOf = new Map(
|
|
1047
|
+
replacements.active.map(active => [
|
|
1048
|
+
`${active.package}\0${active.name}`,
|
|
1049
|
+
active.target,
|
|
1050
|
+
]),
|
|
1051
|
+
);
|
|
1052
|
+
return [
|
|
1053
|
+
...core.filter(candidate => !replacements.forTarget(candidate.name)),
|
|
1054
|
+
...integrations.map(candidate => {
|
|
1055
|
+
const target = targetOf.get(`${candidate._package}\0${candidate.name}`);
|
|
1056
|
+
if (target != null) {
|
|
1057
|
+
return {...candidate, aliases: [...(candidate.aliases ?? []), target]};
|
|
1058
|
+
}
|
|
1059
|
+
// Another package's component named after a replaced Core component is
|
|
1060
|
+
// shadowed for the bare name (FR14): its command names its package.
|
|
1061
|
+
const shadowedBy = replacements.forTarget(candidate.name);
|
|
1062
|
+
return shadowedBy && shadowedBy.package !== candidate._package
|
|
1063
|
+
? {
|
|
1064
|
+
...candidate,
|
|
1065
|
+
_command: `astryx component ${candidate.name} --package ${candidate._package}`,
|
|
1066
|
+
}
|
|
1067
|
+
: candidate;
|
|
1068
|
+
}),
|
|
1069
|
+
];
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* The components each search response was scored against, by response:
|
|
1074
|
+
* `build` reads them to tell a part of a page from a page without gathering
|
|
1075
|
+
* them again. Module-private, so they never enter search's JSON.
|
|
1076
|
+
* @type {WeakMap<object, {name: string, keywords: string[]}[]>}
|
|
1077
|
+
*/
|
|
1078
|
+
const searchedComponentsOf = new WeakMap();
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* The components (name and keywords) a search response was scored against, or
|
|
1082
|
+
* null when that search was narrowed away from components.
|
|
1083
|
+
* @param {object} response
|
|
1084
|
+
* @returns {{name: string, keywords: string[]}[] | null}
|
|
1085
|
+
*/
|
|
1086
|
+
export function searchedComponents(response) {
|
|
1087
|
+
return searchedComponentsOf.get(response) ?? null;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* Every component the project can use, Core's and its integrations', with the
|
|
1092
|
+
* keywords its own doc declares: the discovery and doc reads search's own
|
|
1093
|
+
* candidates use, without the import paths and prose a result carries. `build`
|
|
1094
|
+
* reads it to tell a part of a page from a page when its search was narrowed
|
|
1095
|
+
* away from components.
|
|
1096
|
+
* @param {string} coreDir
|
|
1097
|
+
* @param {string} cwd
|
|
1098
|
+
* @returns {Promise<{name: string, keywords: string[]}[]>}
|
|
1099
|
+
*/
|
|
1100
|
+
export async function componentKeywords(coreDir, cwd) {
|
|
1101
|
+
/** @param {any} doc */
|
|
1102
|
+
const keywordsOf = doc => (Array.isArray(doc?.keywords) ? doc.keywords : []);
|
|
1103
|
+
const core = Object.values(discoverComponents(coreDir))
|
|
1104
|
+
.flat()
|
|
1105
|
+
.map(async name => {
|
|
1106
|
+
const readme = findComponentReadme(coreDir, name);
|
|
1107
|
+
const doc =
|
|
1108
|
+
readme && readme.endsWith('.doc.mjs')
|
|
1109
|
+
? await loadModuleDoc(readme)
|
|
1110
|
+
: null;
|
|
1111
|
+
return {name, keywords: keywordsOf(doc)};
|
|
1112
|
+
});
|
|
1113
|
+
const loadedIntegrations = await loadIntegrationsSafely(cwd);
|
|
1114
|
+
const replacements = await loadComponentReplacements(
|
|
1115
|
+
coreDir,
|
|
1116
|
+
loadedIntegrations,
|
|
1117
|
+
);
|
|
1118
|
+
const integrations = loadedIntegrations.map(
|
|
1119
|
+
async integration => {
|
|
1120
|
+
const {components} = await discoverValidIntegrationComponents(integration);
|
|
1121
|
+
return Promise.all(
|
|
1122
|
+
components.map(async rec => ({
|
|
1123
|
+
name: rec.name,
|
|
1124
|
+
keywords: keywordsOf(await loadModuleDoc(rec.docPath)),
|
|
1125
|
+
})),
|
|
1126
|
+
);
|
|
1127
|
+
},
|
|
1128
|
+
);
|
|
1129
|
+
return [
|
|
1130
|
+
...(await Promise.all(core)).filter(
|
|
1131
|
+
component => !replacements.forTarget(component.name),
|
|
1132
|
+
),
|
|
1133
|
+
...(await Promise.all(integrations)).flat(),
|
|
1134
|
+
];
|
|
1008
1135
|
}
|
|
1009
1136
|
|
|
1010
1137
|
/**
|
|
@@ -1037,6 +1164,7 @@ async function gatherHooks(coreDir) {
|
|
|
1037
1164
|
name: hookName,
|
|
1038
1165
|
keywords,
|
|
1039
1166
|
description,
|
|
1167
|
+
_package: CORE_PACKAGE,
|
|
1040
1168
|
_import: importPath,
|
|
1041
1169
|
});
|
|
1042
1170
|
}
|
|
@@ -1393,7 +1521,12 @@ async function gatherTemplates(cwd) {
|
|
|
1393
1521
|
keywords,
|
|
1394
1522
|
weakKeywords,
|
|
1395
1523
|
description: t.description || '',
|
|
1524
|
+
// A template's own keywords name the many ideas it serves, so they score
|
|
1525
|
+
// as its prose does, not as a name: one of them matching one word of a
|
|
1526
|
+
// short idea is not a direct match.
|
|
1527
|
+
prose: t.keywords ?? [],
|
|
1396
1528
|
_displayName: t.name,
|
|
1529
|
+
_package: t.package ?? CORE_PACKAGE,
|
|
1397
1530
|
_kind: t.type, // 'page' | 'block'
|
|
1398
1531
|
_resultName: t.dirName,
|
|
1399
1532
|
_commandName: commandName,
|
|
@@ -1401,6 +1534,36 @@ async function gatherTemplates(cwd) {
|
|
|
1401
1534
|
});
|
|
1402
1535
|
}
|
|
1403
1536
|
|
|
1537
|
+
/**
|
|
1538
|
+
* Build theme candidates from bundled and integration-provided themes. Without
|
|
1539
|
+
* this, an integration's themes are invisible to `search` even though
|
|
1540
|
+
* `theme list` and `discover` already resolve them.
|
|
1541
|
+
*
|
|
1542
|
+
* A theme's slug and display name are its names, and its description is prose
|
|
1543
|
+
* (`spec:AST-050/FR14`). A theme declares no keywords, so a word it shares with
|
|
1544
|
+
* the query only through its description is a description mention: read as a
|
|
1545
|
+
* keyword, every word of the description would outrank the components and docs
|
|
1546
|
+
* that declare that word.
|
|
1547
|
+
* @param {string} cwd
|
|
1548
|
+
* @returns {Promise<Candidate[]>}
|
|
1549
|
+
*/
|
|
1550
|
+
async function gatherThemes(cwd) {
|
|
1551
|
+
let themes;
|
|
1552
|
+
try {
|
|
1553
|
+
themes = await listAvailableThemes(cwd);
|
|
1554
|
+
} catch {
|
|
1555
|
+
return [];
|
|
1556
|
+
}
|
|
1557
|
+
return themes.map(t => ({
|
|
1558
|
+
domain: 'theme',
|
|
1559
|
+
name: t.slug,
|
|
1560
|
+
aliases: t.displayName ? [t.displayName] : [],
|
|
1561
|
+
description: t.description || '',
|
|
1562
|
+
_displayName: t.displayName,
|
|
1563
|
+
_package: t.package,
|
|
1564
|
+
}));
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1404
1567
|
/**
|
|
1405
1568
|
* Map a scored candidate to its public, actionable result shape. Each result
|
|
1406
1569
|
* carries enough to act on it: the domain, name, a one-line description, and
|
|
@@ -1416,6 +1579,7 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
|
|
|
1416
1579
|
const base = {
|
|
1417
1580
|
domain: c.domain,
|
|
1418
1581
|
name: c._resultName ?? c.name,
|
|
1582
|
+
package: c._package,
|
|
1419
1583
|
score,
|
|
1420
1584
|
reason,
|
|
1421
1585
|
description: c.description || '',
|
|
@@ -1426,7 +1590,7 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
|
|
|
1426
1590
|
result = {
|
|
1427
1591
|
...base,
|
|
1428
1592
|
import: c._import,
|
|
1429
|
-
command: `astryx component ${c.name}`,
|
|
1593
|
+
command: c._command ?? `astryx component ${c.name}`,
|
|
1430
1594
|
};
|
|
1431
1595
|
break;
|
|
1432
1596
|
case 'hook':
|
|
@@ -1446,7 +1610,6 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
|
|
|
1446
1610
|
title: c._title,
|
|
1447
1611
|
command: c._command ?? `astryx docs ${c.name}`,
|
|
1448
1612
|
...(c._parent ? {parent: c._parent} : {}),
|
|
1449
|
-
...(c._package ? {package: c._package} : {}),
|
|
1450
1613
|
};
|
|
1451
1614
|
break;
|
|
1452
1615
|
case 'template':
|
|
@@ -1457,6 +1620,13 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
|
|
|
1457
1620
|
command: `astryx template ${c._commandName ?? c.name} --type ${c._kind}`,
|
|
1458
1621
|
};
|
|
1459
1622
|
break;
|
|
1623
|
+
case 'theme':
|
|
1624
|
+
result = {
|
|
1625
|
+
...base,
|
|
1626
|
+
displayName: c._displayName,
|
|
1627
|
+
command: `astryx theme add --import ${c.name}`,
|
|
1628
|
+
};
|
|
1629
|
+
break;
|
|
1460
1630
|
default:
|
|
1461
1631
|
result = base;
|
|
1462
1632
|
}
|
|
@@ -1464,12 +1634,12 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
|
|
|
1464
1634
|
}
|
|
1465
1635
|
|
|
1466
1636
|
/**
|
|
1467
|
-
* Unified ranked search across components, hooks, docs, and
|
|
1637
|
+
* Unified ranked search across components, hooks, docs, templates, and themes.
|
|
1468
1638
|
*
|
|
1469
1639
|
* @param {string} query - Free-text search term.
|
|
1470
1640
|
* @param {object} [options]
|
|
1471
1641
|
* @param {string} [options.cwd]
|
|
1472
|
-
* @param {'component'|'hook'|'doc'|'template'} [options.type] - Restrict to one domain.
|
|
1642
|
+
* @param {'component'|'hook'|'doc'|'template'|'theme'} [options.type] - Restrict to one domain.
|
|
1473
1643
|
* @param {number} [options.limit] - Max results (default 20).
|
|
1474
1644
|
* @returns {Promise<import('./search.type.mjs').SearchResponse>}
|
|
1475
1645
|
*/
|
|
@@ -1506,12 +1676,14 @@ export async function search(query, options = {}) {
|
|
|
1506
1676
|
const term = String(query).trim().toLowerCase();
|
|
1507
1677
|
const tokens = tokenizeQuery(term);
|
|
1508
1678
|
|
|
1509
|
-
// `astryx docs` reads docs without @astryxdesign/core,
|
|
1510
|
-
//
|
|
1511
|
-
//
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1679
|
+
// `astryx docs` reads docs without @astryxdesign/core, and `astryx theme
|
|
1680
|
+
// list` reads themes without it (bundled themes need no project), so a
|
|
1681
|
+
// search of either must too. Every other domain reads core: asked for by
|
|
1682
|
+
// name, it is an error without core; an open search then covers the docs
|
|
1683
|
+
// and themes alone.
|
|
1684
|
+
const needsCore = !type || !CORELESS_DOMAINS.includes(type);
|
|
1685
|
+
const coreDir = needsCore ? findCoreDir(cwd) : null;
|
|
1686
|
+
if (type && needsCore && !coreDir) {
|
|
1515
1687
|
throw new AstryxError(
|
|
1516
1688
|
'Could not find @astryxdesign/core package',
|
|
1517
1689
|
undefined,
|
|
@@ -1521,17 +1693,19 @@ export async function search(query, options = {}) {
|
|
|
1521
1693
|
|
|
1522
1694
|
// Gather candidates from each requested domain in parallel.
|
|
1523
1695
|
/** @param {string} d */
|
|
1524
|
-
const wants = d =>
|
|
1525
|
-
|
|
1696
|
+
const wants = d =>
|
|
1697
|
+
(!type && (coreDir != null || CORELESS_DOMAINS.includes(d))) || type === d;
|
|
1698
|
+
const [components, hooks, docTopics, templates, themes] = await Promise.all([
|
|
1526
1699
|
wants('component')
|
|
1527
1700
|
? gatherComponents(/** @type {string} */ (coreDir), cwd)
|
|
1528
1701
|
: [],
|
|
1529
1702
|
wants('hook') ? gatherHooks(/** @type {string} */ (coreDir)) : [],
|
|
1530
1703
|
wants('doc') ? gatherDocs(cwd) : [],
|
|
1531
1704
|
wants('template') ? gatherTemplates(cwd) : [],
|
|
1705
|
+
wants('theme') ? gatherThemes(cwd) : [],
|
|
1532
1706
|
]);
|
|
1533
1707
|
|
|
1534
|
-
const all = [...components, ...hooks, ...docTopics, ...templates];
|
|
1708
|
+
const all = [...components, ...hooks, ...docTopics, ...templates, ...themes];
|
|
1535
1709
|
|
|
1536
1710
|
// Score every candidate on its own merits. The consumer groups results by
|
|
1537
1711
|
// role (page / block / component) and takes the top of each, so there's no
|
|
@@ -1548,7 +1722,7 @@ export async function search(query, options = {}) {
|
|
|
1548
1722
|
|
|
1549
1723
|
// Sort by score desc, then domain (stable order), then name.
|
|
1550
1724
|
/** @type {Record<string, number>} */
|
|
1551
|
-
const domainOrder = {component: 0, hook: 1, doc: 2, template: 3};
|
|
1725
|
+
const domainOrder = {component: 0, hook: 1, doc: 2, template: 3, theme: 4};
|
|
1552
1726
|
scored.sort(
|
|
1553
1727
|
(a, b) =>
|
|
1554
1728
|
b.score - a.score ||
|
|
@@ -1563,7 +1737,8 @@ export async function search(query, options = {}) {
|
|
|
1563
1737
|
// 57 things and one matching exactly 20 would be indistinguishable.
|
|
1564
1738
|
const limited = scored.slice(0, limit);
|
|
1565
1739
|
|
|
1566
|
-
|
|
1740
|
+
/** @type {import('./search.type.mjs').SearchResponse} */
|
|
1741
|
+
const response = {
|
|
1567
1742
|
type: 'search',
|
|
1568
1743
|
data: {
|
|
1569
1744
|
query: String(query).trim(),
|
|
@@ -1574,4 +1749,11 @@ export async function search(query, options = {}) {
|
|
|
1574
1749
|
),
|
|
1575
1750
|
},
|
|
1576
1751
|
};
|
|
1752
|
+
if (wants('component')) {
|
|
1753
|
+
searchedComponentsOf.set(
|
|
1754
|
+
response,
|
|
1755
|
+
components.map(c => ({name: c.name, keywords: c.keywords ?? []})),
|
|
1756
|
+
);
|
|
1757
|
+
}
|
|
1758
|
+
return response;
|
|
1577
1759
|
}
|