@astryxdesign/cli 0.6.5-canary.f261d2f → 0.6.5-canary.f2f43e1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -55
- package/api/build/_adapter.d.mts +19 -0
- package/api/build/_adapter.mjs +60 -1
- package/api/build/build.test.mjs +74 -1
- package/api/build/build.type.d.mts +8 -0
- package/api/build/build.type.mjs +2 -0
- package/api/build/kit/kit.mjs +40 -7
- package/api/build/kit/rank.d.mts +8 -0
- package/api/build/kit/rank.mjs +14 -0
- 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 +1 -1
- 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/integrationDocs.test.mjs +6 -5
- 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-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +352 -27
- package/api/integration/add-theme.test.mjs +379 -15
- 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 +483 -1
- package/api/integration/pack-check.test.mjs +568 -8
- 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 +15 -8
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +179 -67
- package/api/search/search.test.mjs +128 -9
- 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.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.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/checks.doc.mjs +5 -4
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- 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/side-panels.doc.mjs +82 -0
- package/assets/docs/tree/structure.doc.mjs +144 -0
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +4 -0
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +4 -1
- package/assets/docs/use-a-theme.doc.mjs +97 -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/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/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/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 +2 -3
- 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 +35 -32
- 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 +13 -0
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
- package/foundation/discovery/template-adapter.mjs +16 -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/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/tree.test.mjs +2 -2
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +22 -0
- package/foundation/integrations/cli-requirement.mjs +31 -0
- package/foundation/integrations/cli-requirement.test.mjs +70 -0
- 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/build/kit/kit.mjs
CHANGED
|
@@ -32,8 +32,15 @@ import {findCoreDir} from '../../../foundation/fs/paths.mjs';
|
|
|
32
32
|
import {AstryxError} from '../../error.mjs';
|
|
33
33
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
34
34
|
import {getResultCoverage} from '../../search/coverage.mjs';
|
|
35
|
-
import {loadComponents, loadPageTemplates} from '../_adapter.mjs';
|
|
36
|
-
import {
|
|
35
|
+
import {loadComponents, loadPageTemplates, loadWeights} from '../_adapter.mjs';
|
|
36
|
+
import {
|
|
37
|
+
asksForNewPage,
|
|
38
|
+
ideaKind,
|
|
39
|
+
pickAlternatives,
|
|
40
|
+
pickStart,
|
|
41
|
+
rankPages,
|
|
42
|
+
} from './rank.mjs';
|
|
43
|
+
import {weighStart} from './weights.mjs';
|
|
37
44
|
|
|
38
45
|
/** A page at/above this score is a confident direct match. */
|
|
39
46
|
const PAGE_DIRECT = 95;
|
|
@@ -113,6 +120,7 @@ const ALWAYS = new Set([...FRAME, ...FOUNDATION]);
|
|
|
113
120
|
*/
|
|
114
121
|
const asTemplate = t => ({
|
|
115
122
|
name: t.name,
|
|
123
|
+
package: t.package,
|
|
116
124
|
displayName: t.displayName,
|
|
117
125
|
description: t.description,
|
|
118
126
|
command: `${t.command} <path>`,
|
|
@@ -151,9 +159,10 @@ function placement(kind, inPage) {
|
|
|
151
159
|
* @param {SearchResultEntry[]} pages
|
|
152
160
|
* @param {boolean} directMatch
|
|
153
161
|
* @param {PageTemplate[]} catalog
|
|
162
|
+
* @param {string} idea
|
|
154
163
|
* @returns {Omit<BuildStart, 'alternatives'> | null}
|
|
155
164
|
*/
|
|
156
|
-
function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
165
|
+
function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
|
|
157
166
|
const direct = directMatch ? pages[0].name : null;
|
|
158
167
|
const unready =
|
|
159
168
|
direct && !catalog.some(t => t.name === direct) ? direct : null;
|
|
@@ -170,7 +179,27 @@ function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
|
170
179
|
direct && direct !== startName
|
|
171
180
|
? `Search matched \`${direct}\` by name, but ${place}`
|
|
172
181
|
: place[0].toUpperCase() + place.slice(1);
|
|
173
|
-
const
|
|
182
|
+
const proposed = pickStart(ranked, kind);
|
|
183
|
+
// The checked-in word weights (weights.mjs), blended with the ranker's
|
|
184
|
+
// scores, decide the start of a whole page. A part or an edit starts where
|
|
185
|
+
// the ranker's placement rules put it (spec:AST-048/FR3).
|
|
186
|
+
const weighed =
|
|
187
|
+
kind === 'page'
|
|
188
|
+
? weighStart(idea, ranked, proposed, catalog, {
|
|
189
|
+
weights: loadWeights(),
|
|
190
|
+
newPage: asksForNewPage(idea, catalog),
|
|
191
|
+
})
|
|
192
|
+
: undefined;
|
|
193
|
+
// A shell start keeps the shell the ranker named, if any, and never replaces
|
|
194
|
+
// the template the ranker chose for a page search matched directly.
|
|
195
|
+
const pick =
|
|
196
|
+
weighed === undefined
|
|
197
|
+
? proposed
|
|
198
|
+
: weighed === null
|
|
199
|
+
? proposed?.family === 'Shell' || (proposed && direct && !unready)
|
|
200
|
+
? proposed
|
|
201
|
+
: null
|
|
202
|
+
: (ranked.find(r => r.name === weighed) ?? proposed);
|
|
174
203
|
const closest = pick && catalog.find(t => t.name === pick.name);
|
|
175
204
|
if (pick && closest) {
|
|
176
205
|
const agrees = closest.name === direct;
|
|
@@ -194,7 +223,9 @@ function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
|
194
223
|
if (shell) {
|
|
195
224
|
// The shell can also be the ranker's best guess without the evidence to
|
|
196
225
|
// lead ("horizontal site navigation"); say so rather than "no match".
|
|
197
|
-
const nearest =
|
|
226
|
+
const nearest =
|
|
227
|
+
(ranked[0]?.name === shell.name && ranked[0].hits > 0) ||
|
|
228
|
+
(weighed === null && !!proposed && proposed.family !== 'Shell');
|
|
198
229
|
const place = placement(kind, false);
|
|
199
230
|
return {
|
|
200
231
|
...asTemplate(shell),
|
|
@@ -204,7 +235,9 @@ function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
|
204
235
|
: place
|
|
205
236
|
? placed(place, shell.name)
|
|
206
237
|
: direct
|
|
207
|
-
?
|
|
238
|
+
? weighed === null
|
|
239
|
+
? `Search matched \`${direct}\` by name, but the app shell is the closer start.`
|
|
240
|
+
: `Search matched \`${direct}\` by name, but too little of the idea fits it, so start from the app shell.`
|
|
208
241
|
: nearest
|
|
209
242
|
? 'No template is a clear match; the app shell is the closest.'
|
|
210
243
|
: loose
|
|
@@ -346,7 +379,7 @@ export async function buildKit(query, options = {}) {
|
|
|
346
379
|
)
|
|
347
380
|
: 'page';
|
|
348
381
|
const chosen = wantsPages
|
|
349
|
-
? chooseStart(ranked, kind, matchedPages, directMatch, catalog)
|
|
382
|
+
? chooseStart(ranked, kind, matchedPages, directMatch, catalog, query)
|
|
350
383
|
: null;
|
|
351
384
|
// Name the ranker's next two templates beside the start: the reader judges
|
|
352
385
|
// meaning better than keywords do, and an acceptable template is in these
|
package/api/build/kit/rank.d.mts
CHANGED
|
@@ -21,6 +21,14 @@ export function rankPages(query: string, pages: PageTemplate[]): RankedPage[];
|
|
|
21
21
|
* @returns {IdeaKind}
|
|
22
22
|
*/
|
|
23
23
|
export function ideaKind(query: string, pages: PageTemplate[], components: ComponentWords[]): IdeaKind;
|
|
24
|
+
/**
|
|
25
|
+
* Whether an idea asks for a new page (see `asksNewPage`), from the idea and
|
|
26
|
+
* the project's page templates.
|
|
27
|
+
* @param {string} query
|
|
28
|
+
* @param {PageTemplate[]} pages
|
|
29
|
+
* @returns {boolean}
|
|
30
|
+
*/
|
|
31
|
+
export function asksForNewPage(query: string, pages: PageTemplate[]): boolean;
|
|
24
32
|
/**
|
|
25
33
|
* The next closest templates after the start, best first: the ones a reader
|
|
26
34
|
* should check the idea against when the start's shape is wrong. Each matched
|
package/api/build/kit/rank.mjs
CHANGED
|
@@ -543,6 +543,20 @@ function asksNewPage(phrases, familyWords) {
|
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
545
|
|
|
546
|
+
/**
|
|
547
|
+
* Whether an idea asks for a new page (see `asksNewPage`), from the idea and
|
|
548
|
+
* the project's page templates.
|
|
549
|
+
* @param {string} query
|
|
550
|
+
* @param {PageTemplate[]} pages
|
|
551
|
+
* @returns {boolean}
|
|
552
|
+
*/
|
|
553
|
+
export function asksForNewPage(query, pages) {
|
|
554
|
+
return asksNewPage(
|
|
555
|
+
String(query).toLowerCase().split(PHRASE_END),
|
|
556
|
+
familyWordsOf(pages),
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
|
|
546
560
|
/**
|
|
547
561
|
* The words of a component's name: "DateRangeInput" is date, range, input.
|
|
548
562
|
* @param {ComponentWords} component
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The Porter stem of a lowercase word.
|
|
6
|
+
* @param {string} word
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
export function stem(word: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Lowercase words of an idea that can carry weight: letters only, two or more.
|
|
12
|
+
* @param {string} idea
|
|
13
|
+
* @returns {string[]}
|
|
14
|
+
*/
|
|
15
|
+
export function weightWords(idea: string): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Where an idea starts, by the blended weights.
|
|
18
|
+
* @param {string} idea
|
|
19
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked the ranker's output for the idea
|
|
20
|
+
* @param {import('./rank.mjs').RankedPage | null} pick the ranker's own start
|
|
21
|
+
* @param {{name: string}[]} catalog the project's ready page templates
|
|
22
|
+
* @param {{weights?: WeightsFile | null, newPage?: boolean}} [options]
|
|
23
|
+
* `newPage`: the idea asks for a new page (rank.mjs `asksForNewPage`)
|
|
24
|
+
* @returns {string | null | undefined} a template id, null for the app shell,
|
|
25
|
+
* undefined without weights
|
|
26
|
+
*/
|
|
27
|
+
export function weighStart(idea: string, ranked: import("./rank.mjs").RankedPage[], pick: import("./rank.mjs").RankedPage | null, catalog: {
|
|
28
|
+
name: string;
|
|
29
|
+
}[], { weights, newPage }?: {
|
|
30
|
+
weights?: WeightsFile | null;
|
|
31
|
+
newPage?: boolean;
|
|
32
|
+
}): string | null | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* @file Word weights for `build`'s START (spec:AST-048): a checked-in table of
|
|
35
|
+
* per-template word weights, blended with the page ranker's own scores, picks
|
|
36
|
+
* the template an idea starts from.
|
|
37
|
+
*
|
|
38
|
+
* @input An idea, the ranker's output for it (`rankPages`, `pickStart`), the
|
|
39
|
+
* project's ready page templates, and the weights (`weights.json` beside this
|
|
40
|
+
* file, read by the adapter): the candidates (the app shell as `SHELL`, then page template ids), one or more
|
|
41
|
+
* word tables (stemmed words, a bias per candidate, and one row of weights
|
|
42
|
+
* per word, a character per candidate) and the blend numbers.
|
|
43
|
+
* @output `weighStart(idea, ranked, pick, catalog)`: the template id to start
|
|
44
|
+
* from, null for the app shell, or undefined when no table is available, in
|
|
45
|
+
* which case the ranker's own pick stands.
|
|
46
|
+
* @position Beside rank.mjs (api/build/kit/); kit.mjs calls it for every
|
|
47
|
+
* whole page (a part or an edit follows the ranker's placement rules). The
|
|
48
|
+
* ranker's pick of a template the tables do not list stands, so a new
|
|
49
|
+
* template can start a build.
|
|
50
|
+
*/
|
|
51
|
+
/** The app shell, as one candidate. */
|
|
52
|
+
export const SHELL: "SHELL";
|
|
53
|
+
export type WeightTable = {
|
|
54
|
+
/**
|
|
55
|
+
* stemmed words
|
|
56
|
+
*/
|
|
57
|
+
words: string[];
|
|
58
|
+
/**
|
|
59
|
+
* one per candidate
|
|
60
|
+
*/
|
|
61
|
+
bias: number[];
|
|
62
|
+
clip: number;
|
|
63
|
+
step: number;
|
|
64
|
+
/**
|
|
65
|
+
* one per word: a character per candidate,
|
|
66
|
+
* weight = (charCode - 97) * step - clip
|
|
67
|
+
*/
|
|
68
|
+
rows: string[];
|
|
69
|
+
};
|
|
70
|
+
export type WeightsFile = {
|
|
71
|
+
version: number;
|
|
72
|
+
/**
|
|
73
|
+
* `SHELL`, then page template ids
|
|
74
|
+
*/
|
|
75
|
+
candidates: string[];
|
|
76
|
+
tables: WeightTable[];
|
|
77
|
+
/**
|
|
78
|
+
* three numbers per member (the tables, in order,
|
|
79
|
+
* with the ranker second), then one for `SHELL`
|
|
80
|
+
*/
|
|
81
|
+
blend: number[];
|
|
82
|
+
};
|