@astryxdesign/cli 0.7.16 → 0.7.17-canary.g16fe6a8
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 +76 -86
- package/api/build/_adapter.d.mts +12 -0
- package/api/build/_adapter.mjs +51 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.type.d.mts +2 -2
- package/api/build/build.type.mjs +3 -3
- package/api/build/kit/kind.d.mts +2 -1
- package/api/build/kit/kind.mjs +199 -10
- package/api/build/kit/kit.mjs +6 -4
- package/api/build/kit/rank.d.mts +4 -2
- package/api/build/kit/rank.mjs +125 -24
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/build/kit/weights.d.mts +39 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +340 -43
- package/api/build/kit/word-model.d.mts +23 -0
- package/api/build/kit/word-model.mjs +46 -0
- package/api/build/kit/words.d.mts +48 -0
- package/api/build/kit/words.mjs +90 -1
- package/api/component/__fixtures__/resolutions/modules.txt +4 -5
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -6
- package/api/discover/_adapter.d.mts +1 -1
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +28 -2
- package/api/docs/_adapter.mjs +249 -10
- package/api/docs/docs.d.mts +3 -0
- package/api/docs/docs.doc.mjs +7 -1
- package/api/docs/docs.mjs +12 -0
- package/api/docs/docs.type.d.mts +5 -0
- package/api/docs/docs.type.mjs +2 -0
- package/api/docs/node/node.mjs +1 -1
- package/api/doctor/_adapter.d.mts +27 -5
- package/api/doctor/_adapter.mjs +83 -10
- package/api/doctor/built-checks.mjs +40 -14
- package/api/doctor/doctor.d.mts +4 -3
- package/api/doctor/doctor.mjs +14 -7
- package/api/doctor/theme-checks.mjs +121 -17
- package/api/icon/_records.mjs +2 -1
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/integration/_adapter.d.mts +44 -0
- package/api/integration/_adapter.mjs +77 -1
- package/api/integration/authoring-checks.mjs +6 -6
- package/api/integration/example-scope.d.mts +14 -0
- package/api/integration/example-scope.mjs +44 -0
- package/api/integration/example-scope.type.d.mts +29 -0
- package/api/integration/example-scope.type.mjs +25 -0
- package/api/integration/integrationExampleScope.doc.d.mts +11 -0
- package/api/integration/integrationExampleScope.doc.mjs +59 -0
- package/api/integration/validate-integration.mjs +19 -1
- package/api/integration/validate-integration.type.d.mts +9 -0
- package/api/integration/validate-integration.type.mjs +1 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.mjs +591 -195
- package/api/render/render.doc.mjs +11 -3
- package/api/render/render.type.d.mts +52 -0
- package/api/render/render.type.mjs +31 -1
- package/api/search/ORDERING.md +1 -1
- package/api/search/_adapter.d.mts +9 -0
- package/api/search/_adapter.mjs +85 -0
- package/api/search/_candidate-score.mjs +51 -32
- package/api/search/_fit-order.mjs +3 -3
- package/api/search/_gather-components.d.mts +3 -2
- package/api/search/_gather-components.mjs +12 -3
- package/api/search/_lexical.d.mts +5 -0
- package/api/search/_lexical.mjs +8 -2
- package/api/search/_result.d.mts +11 -9
- package/api/search/_result.mjs +4 -4
- package/api/search/_score.d.mts +6 -1
- package/api/search/_score.mjs +15 -3
- package/api/search/search-index.mjs +7 -1
- package/api/search/search.d.mts +1 -1
- package/api/theme/_adapter.mjs +12 -1
- package/api/theme/build/build.d.mts +132 -1
- package/api/theme/build/build.mjs +482 -157
- package/api/theme/build/core-interception.d.mts +10 -0
- package/api/theme/build/core-interception.mjs +10 -0
- package/api/theme/build/font-warning.d.mts +44 -5
- package/api/theme/build/font-warning.mjs +118 -10
- package/api/theme/build/icon-imports.mjs +51 -9
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +115 -4
- package/api/theme-edit/_adapter.mjs +997 -83
- package/api/theme-edit/_catalog.d.mts +20 -2
- package/api/theme-edit/_catalog.mjs +50 -10
- package/api/theme-edit/_check.d.mts +75 -24
- package/api/theme-edit/_check.mjs +2672 -422
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +54 -1
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +133 -15
- package/api/theme-edit/_context.d.mts +14 -3
- package/api/theme-edit/_context.mjs +225 -65
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +54 -4
- package/api/theme-edit/_edit.mjs +2966 -286
- package/api/theme-edit/_how-commands.d.mts +72 -1
- package/api/theme-edit/_how-commands.mjs +770 -9
- package/api/theme-edit/_how-question.d.mts +82 -5
- package/api/theme-edit/_how-question.mjs +6983 -701
- package/api/theme-edit/_how.d.mts +2 -1
- package/api/theme-edit/_how.mjs +237 -41
- package/api/theme-edit/_importers.d.mts +38 -0
- package/api/theme-edit/_importers.mjs +188 -0
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_name-rule.d.mts +11 -0
- package/api/theme-edit/_name-rule.mjs +12 -0
- package/api/theme-edit/_normal.d.mts +303 -0
- package/api/theme-edit/_normal.mjs +1517 -0
- package/api/theme-edit/_palette.d.mts +12 -0
- package/api/theme-edit/_palette.mjs +37 -4
- package/api/theme-edit/_part-words.d.mts +31 -0
- package/api/theme-edit/_part-words.mjs +126 -0
- package/api/theme-edit/_parts.d.mts +28 -2
- package/api/theme-edit/_parts.mjs +267 -31
- package/api/theme-edit/_preview-app.d.mts +7 -13
- package/api/theme-edit/_preview-app.mjs +814 -406
- package/api/theme-edit/_preview.d.mts +116 -16
- package/api/theme-edit/_preview.mjs +649 -152
- package/api/theme-edit/_project.d.mts +22 -1
- package/api/theme-edit/_project.mjs +83 -3
- package/api/theme-edit/_settings.d.mts +467 -42
- package/api/theme-edit/_settings.mjs +3527 -468
- package/api/theme-edit/_tables.d.mts +21 -0
- package/api/theme-edit/_tables.mjs +97 -3
- package/api/theme-edit/_vet.d.mts +31 -0
- package/api/theme-edit/_vet.mjs +114 -8
- package/api/theme-edit/theme-edit.type.d.mts +16 -2
- package/api/theme-edit/theme-edit.type.mjs +6 -3
- package/api/theme-edit/themeEditHow.doc.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
- package/api/theme-edit/themeEditNew.doc.mjs +7 -4
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
- package/api/upgrade/run/run.mjs +4 -3
- package/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/codemods/run-codemod.mjs +87 -7
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
- package/assets/component-list.generated.json +1 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -0
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/render-pages.doc.mjs +44 -3
- package/assets/docs/tree/share-a-page.doc.mjs +157 -0
- package/assets/docs/tree/single-component.doc.mjs +4 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/search-catalog.generated.json +2 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +5 -1
- package/assets/templates/pages/blank/template.doc.mjs +1 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
- package/assets/templates/pages/documentation/template.doc.mjs +4 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
- package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +24 -2
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
- package/assets/templates/pages/library/template.doc.mjs +4 -1
- package/assets/templates/pages/login/template.doc.mjs +2 -1
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/template.doc.mjs +2 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
- package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/template.doc.mjs +5 -4
- package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
- package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/assets/theme.template.ts +6 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +3 -3
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/component/categories.d.mts +37 -0
- package/authoring/doctypes/component/categories.mjs +54 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +9 -0
- package/authoring/example/example.doc.d.mts +12 -0
- package/authoring/example/example.doc.mjs +69 -0
- package/authoring/example/preview.d.mts +92 -0
- package/authoring/example/preview.mjs +994 -0
- package/authoring/example/type.ts +102 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +3 -1
- package/clients/cli/bin/astryx.mjs +6 -9
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.mjs +22 -3
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +32 -14
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +573 -119
- package/clients/cli/commands/experimental-render.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
- package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
- package/clients/cli/commands/search.doc.mjs +2 -1
- package/clients/cli/commands/search.mjs +6 -1
- package/clients/cli/commands/template.mjs +4 -2
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +718 -438
- package/clients/cli/commands/upgrade.mjs +42 -7
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/cli-error.mjs +2 -1
- package/clients/cli/lib/component-format.mjs +205 -98
- package/clients/cli/lib/hook-format.mjs +9 -19
- package/clients/cli/lib/json-shim.mjs +132 -24
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/theme-state.d.mts +13 -1
- package/foundation/config/theme-state.mjs +47 -7
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +56 -8
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/core-component-docs.d.mts +29 -0
- package/foundation/discovery/core-component-docs.mjs +83 -0
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/entry-name-files.d.mts +43 -0
- package/foundation/discovery/entry-name-files.mjs +264 -0
- package/foundation/discovery/hook-discovery.d.mts +8 -2
- package/foundation/discovery/hook-discovery.mjs +22 -8
- package/foundation/discovery/icon-definition-discovery.mjs +2 -1
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.mjs +2 -1
- package/foundation/discovery/integration-doc-files.mjs +2 -1
- package/foundation/discovery/package-exports.d.mts +10 -0
- package/foundation/discovery/package-exports.mjs +56 -3
- package/foundation/discovery/prop-drift.mjs +9 -9
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/stored-component-list.d.mts +43 -0
- package/foundation/discovery/stored-component-list.mjs +90 -0
- package/foundation/discovery/stored-search-catalog.d.mts +115 -0
- package/foundation/discovery/stored-search-catalog.mjs +297 -0
- package/foundation/discovery/stored-self-audit.d.mts +26 -10
- package/foundation/discovery/stored-self-audit.mjs +38 -18
- package/foundation/discovery/template-adapter.d.mts +53 -1
- package/foundation/discovery/template-adapter.mjs +176 -12
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +31 -4
- package/foundation/discovery/theme-imports.d.mts +14 -0
- package/foundation/discovery/theme-imports.mjs +43 -1
- package/foundation/discovery/theming-targets.d.mts +6 -5
- package/foundation/discovery/theming-targets.mjs +31 -47
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +22 -0
- package/foundation/doc-compiler/stored-docs.mjs +49 -0
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +38 -0
- package/foundation/fonts/font-stylesheet.mjs +141 -0
- package/foundation/fs/cache-eviction.d.mts +21 -0
- package/foundation/fs/cache-eviction.mjs +73 -0
- package/foundation/fs/exact-codec.d.mts +12 -2
- package/foundation/fs/exact-codec.mjs +23 -6
- package/foundation/fs/file-protection.mjs +4 -3
- package/foundation/fs/gather-cache.d.mts +62 -4
- package/foundation/fs/gather-cache.mjs +517 -91
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +60 -0
- package/foundation/fs/kept-tree.mjs +154 -0
- package/foundation/fs/listing-cache.d.mts +7 -0
- package/foundation/fs/listing-cache.mjs +10 -0
- package/foundation/fs/module-loader.d.mts +24 -2
- package/foundation/fs/module-loader.mjs +94 -21
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/fs/read-record.d.mts +9 -0
- package/foundation/fs/read-record.mjs +19 -11
- package/foundation/fs/stop-cleanup.d.mts +12 -0
- package/foundation/fs/stop-cleanup.mjs +66 -0
- package/foundation/identity/provider-identity.d.mts +6 -0
- package/foundation/identity/provider-identity.mjs +10 -1
- package/foundation/integrations/contribution-inventory.mjs +4 -3
- package/foundation/integrations/example-code.d.mts +63 -0
- package/foundation/integrations/example-code.mjs +416 -0
- package/foundation/integrations/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/validate-contributions.mjs +17 -45
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +39 -7
- package/foundation/render/embedded-imports.mjs +66 -27
- package/foundation/render/file-header.d.mts +66 -0
- package/foundation/render/file-header.mjs +118 -0
- package/foundation/render/host-answer.d.mts +18 -0
- package/foundation/render/host-answer.mjs +46 -0
- package/foundation/render/host-exit.d.mts +1 -0
- package/foundation/render/host-exit.mjs +6 -1
- package/foundation/render/html-reader.d.mts +55 -2
- package/foundation/render/html-reader.mjs +145 -26
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +121 -13
- package/foundation/render/picture-chrome.d.mts +4 -0
- package/foundation/render/picture-chrome.mjs +185 -0
- package/foundation/render/picture-playwright.d.mts +4 -0
- package/foundation/render/picture-playwright.mjs +34 -0
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +35 -3
- package/foundation/render/render-page.mjs +641 -96
- package/foundation/render/source-block.d.mts +85 -6
- package/foundation/render/source-block.mjs +211 -20
- package/foundation/render/ts-paths.d.mts +69 -6
- package/foundation/render/ts-paths.mjs +326 -40
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +12 -1
- package/foundation/response/error-codes.mjs +11 -1
- package/foundation/response/response-types.doc.mjs +2 -2
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/css-escape.d.mts +18 -0
- package/foundation/text/css-escape.mjs +35 -0
- package/foundation/text/string-utils.d.mts +3 -2
- package/foundation/text/string-utils.mjs +18 -4
- package/foundation/text/suggest-order.d.mts +9 -0
- package/foundation/text/suggest-order.mjs +15 -1
- package/foundation/xle/expand.mjs +2 -1
- package/host/index.mjs +8 -6
- package/package.json +7 -6
package/api/build/kit/kind.mjs
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
* not a page, and the system's own components say what a part is: an idea
|
|
9
9
|
* whose head noun is a word of a component's name or keywords, Core's or an
|
|
10
10
|
* integration's, asks for that part, unless the noun is a family word ("a data
|
|
11
|
-
* table") or the idea lists a page's worth of pieces.
|
|
11
|
+
* table") or the idea lists a page's worth of pieces. A component named with
|
|
12
|
+
* its listed contents ("a side panel with an owner, a status, and a history")
|
|
13
|
+
* is still one part, unless the component holds records: its category declares
|
|
14
|
+
* a page family (a list, a table). Words search drops as
|
|
12
15
|
* stopwords ("page", "screen", "app", "view") name no component, so "a calendar
|
|
13
16
|
* page" asks for a page and "a calendar" for a part. A part starts from the
|
|
14
17
|
* base template of the family the idea names ("an empty state for a settings
|
|
@@ -19,14 +22,20 @@
|
|
|
19
22
|
* existing table"), unless the idea asks for a new page ("a new dashboard like
|
|
20
23
|
* the existing dashboard", "clone the existing dashboard as a new page"). A
|
|
21
24
|
* bare "existing" phrase that names a page ("existing reports dashboard with a
|
|
22
|
-
* date filter") reads as the builder's own page.
|
|
25
|
+
* date filter") reads as the builder's own page. An idea that opens with "add"
|
|
26
|
+
* and says where the piece goes ("add a filter row above the table") puts it
|
|
27
|
+
* into a page the builder already has, so it is a change too, unless the piece
|
|
28
|
+
* is a page ("add a dashboard to the app") or it asks for a new page ("add a
|
|
29
|
+
* new dashboard").
|
|
23
30
|
*/
|
|
24
31
|
|
|
32
|
+
import {COMPONENT_CATEGORIES} from '../../../authoring/doctypes/component/categories.mjs';
|
|
25
33
|
import {stem} from '../../search/search.mjs';
|
|
26
34
|
import {
|
|
27
35
|
HEAD_END,
|
|
28
36
|
CONTAINER_PHRASE,
|
|
29
37
|
PHRASE_END,
|
|
38
|
+
PLACE_PHRASE,
|
|
30
39
|
terms,
|
|
31
40
|
containersOf,
|
|
32
41
|
familyWordsOf,
|
|
@@ -41,7 +50,7 @@ import {
|
|
|
41
50
|
/**
|
|
42
51
|
* How many listed pieces make an idea a page: a part is one thing with a detail
|
|
43
52
|
* or two ("a status pill with a tooltip"), while three pieces, two commas
|
|
44
|
-
* apart, describe a page.
|
|
53
|
+
* apart, describe a page, unless they are one component's contents.
|
|
45
54
|
*/
|
|
46
55
|
const PAGE_PIECES = 3;
|
|
47
56
|
|
|
@@ -51,6 +60,12 @@ const PAGE_PIECES = 3;
|
|
|
51
60
|
*/
|
|
52
61
|
const EXISTING = /\bexisting\b/i;
|
|
53
62
|
|
|
63
|
+
/**
|
|
64
|
+
* The word that opens an idea adding a piece to a page the builder already
|
|
65
|
+
* has (spec:AST-048/FR3, FR9), when the idea says where the piece goes.
|
|
66
|
+
*/
|
|
67
|
+
const ADDS = /^\s*add\b/i;
|
|
68
|
+
|
|
54
69
|
/**
|
|
55
70
|
* The word that marks an idea asking for a new page ("a new dashboard", "as a
|
|
56
71
|
* new page"), which is never a change to one the builder has.
|
|
@@ -60,7 +75,8 @@ const NEW = /\bnew\b/;
|
|
|
60
75
|
/**
|
|
61
76
|
* What an idea asks for (spec:AST-048/FR3): a whole `page`; a `part` of one,
|
|
62
77
|
* when its head noun names one of the system's components and it lists fewer
|
|
63
|
-
* than PAGE_PIECES pieces; or an `edit` of a
|
|
78
|
+
* than PAGE_PIECES pieces or only that component's contents; or an `edit` of a
|
|
79
|
+
* page the builder already has.
|
|
64
80
|
*
|
|
65
81
|
* @param {string} query
|
|
66
82
|
* @param {PageTemplate[]} pages
|
|
@@ -71,25 +87,198 @@ export function ideaKind(query, pages, components) {
|
|
|
71
87
|
const text = String(query);
|
|
72
88
|
const familyWords = familyWordsOf(pages);
|
|
73
89
|
if (changesExistingPage(text, familyWords, components)) return 'edit';
|
|
90
|
+
if (addsToPage(text, familyWords, pages, components)) return 'edit';
|
|
74
91
|
// The head's last word, page words included: "calendar" is the noun of "a
|
|
75
92
|
// calendar", "page" the noun of "a calendar page". An overlay frame names
|
|
76
93
|
// where the thing lives, not the thing: "drafts" is the noun of "drafts in
|
|
77
94
|
// a modal".
|
|
78
|
-
const
|
|
95
|
+
const rawHead = text.split(HEAD_END)[0] ?? '';
|
|
96
|
+
const head = rawHead.replace(CONTAINER_PHRASE, m =>
|
|
79
97
|
containersOf(m).size > 0 ? ' ' : m,
|
|
80
98
|
);
|
|
81
|
-
const
|
|
82
|
-
w => w.length >= 2,
|
|
83
|
-
);
|
|
84
|
-
const noun = stem(words[words.length - 1] ?? '');
|
|
99
|
+
const noun = lastNoun(head);
|
|
85
100
|
if (familyWords.has(noun)) return 'page';
|
|
101
|
+
const holdsRecords = (/** @type {string} */ word) =>
|
|
102
|
+
namedComponents(word, components).some(c => namesFamily(c, familyWords));
|
|
103
|
+
if (
|
|
104
|
+
describesOnePart(text, rawHead, noun, familyWords, components) &&
|
|
105
|
+
!holdsRecords(noun)
|
|
106
|
+
)
|
|
107
|
+
return 'part';
|
|
86
108
|
const pieces = (text.match(/,/g) ?? []).length + 1;
|
|
87
109
|
if (pieces >= PAGE_PIECES) return 'page';
|
|
88
|
-
|
|
110
|
+
const namesPart = (/** @type {string} */ word) =>
|
|
111
|
+
components.some(c => componentTerms(c).includes(word));
|
|
112
|
+
if (!namesPart(noun)) return 'page';
|
|
113
|
+
// A component that holds records, followed by "of", is a page of those
|
|
114
|
+
// records ("a list of jobs"), unless what follows names a component ("a list
|
|
115
|
+
// of buttons") or a page family ("a list of settings toggles").
|
|
116
|
+
if (!holdsRecords(noun) || !endsOnOf(text)) return 'part';
|
|
117
|
+
const phrase = madeOf(text);
|
|
118
|
+
return terms(phrase).some(t => familyWords.has(t)) ||
|
|
119
|
+
namesPart(lastNoun(phrase))
|
|
89
120
|
? 'part'
|
|
90
121
|
: 'page';
|
|
91
122
|
}
|
|
92
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Whether an idea describes one part and its contents: its head names a
|
|
126
|
+
* component by name and ends on a word ("a side panel with a, b and c"), not
|
|
127
|
+
* on a comma or a colon that starts a list of peers, and no word of the idea
|
|
128
|
+
* names a page family. Such an idea is a part however many pieces it lists.
|
|
129
|
+
* @param {string} text
|
|
130
|
+
* @param {string} head the idea's head, before any frame is removed
|
|
131
|
+
* @param {string} noun
|
|
132
|
+
* @param {Map<string, string>} familyWords
|
|
133
|
+
* @param {ComponentWords[]} components
|
|
134
|
+
* @returns {boolean}
|
|
135
|
+
*/
|
|
136
|
+
function describesOnePart(text, head, noun, familyWords, components) {
|
|
137
|
+
const end = text.slice(head.length).match(/^\s*([a-z]+)/i);
|
|
138
|
+
return (
|
|
139
|
+
end !== null &&
|
|
140
|
+
components.some(c => nameTerms(c).includes(noun)) &&
|
|
141
|
+
!terms(text).some(t => familyWords.has(t))
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The components a word names: the one whose whole name is the word
|
|
147
|
+
* ("button" names Button), else every component whose name holds it.
|
|
148
|
+
* @param {string} word
|
|
149
|
+
* @param {ComponentWords[]} components
|
|
150
|
+
* @returns {ComponentWords[]}
|
|
151
|
+
*/
|
|
152
|
+
function namedComponents(word, components) {
|
|
153
|
+
const whole = components.filter(c => {
|
|
154
|
+
const name = nameTerms(c);
|
|
155
|
+
return name.length === 1 && name[0] === word;
|
|
156
|
+
});
|
|
157
|
+
return whole.length > 0
|
|
158
|
+
? whole
|
|
159
|
+
: components.filter(c => nameTerms(c).includes(word));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Whether a component's doc files it under a category that declares a page
|
|
164
|
+
* family the project has ("Table & List" declares the table family): such a
|
|
165
|
+
* component holds the records a page of that family shows.
|
|
166
|
+
* @param {ComponentWords} component
|
|
167
|
+
* @param {Map<string, string>} familyWords
|
|
168
|
+
* @returns {boolean}
|
|
169
|
+
*/
|
|
170
|
+
function namesFamily(component, familyWords) {
|
|
171
|
+
const family = Object.hasOwn(COMPONENT_CATEGORIES, component.category ?? '')
|
|
172
|
+
? COMPONENT_CATEGORIES[component.category ?? ''].pageFamily
|
|
173
|
+
: undefined;
|
|
174
|
+
return family !== undefined && [...familyWords.values()].includes(family);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The stem of a phrase's last word.
|
|
179
|
+
* @param {string} phrase
|
|
180
|
+
* @returns {string}
|
|
181
|
+
*/
|
|
182
|
+
function lastNoun(phrase) {
|
|
183
|
+
const words = (phrase.toLowerCase().match(/[a-z0-9]+/g) ?? []).filter(
|
|
184
|
+
w => w.length >= 2,
|
|
185
|
+
);
|
|
186
|
+
return stem(words[words.length - 1] ?? '');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Whether an idea's head ends on "of" ("a list of jobs").
|
|
191
|
+
* @param {string} text
|
|
192
|
+
* @returns {boolean}
|
|
193
|
+
*/
|
|
194
|
+
function endsOnOf(text) {
|
|
195
|
+
return text.match(HEAD_END)?.[0].toLowerCase() === 'of';
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* What a head that ends on "of" is made of: the phrase after "of", up to the
|
|
200
|
+
* next head end, without an overlay frame.
|
|
201
|
+
* @param {string} text
|
|
202
|
+
* @returns {string}
|
|
203
|
+
*/
|
|
204
|
+
function madeOf(text) {
|
|
205
|
+
const end = text.match(HEAD_END);
|
|
206
|
+
const rest = text.slice((end?.index ?? 0) + (end?.[0].length ?? 0));
|
|
207
|
+
return (rest.split(HEAD_END)[0] ?? '').replace(CONTAINER_PHRASE, m =>
|
|
208
|
+
containersOf(m).size > 0 ? ' ' : m,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Whether an idea adds a piece to a page the builder already has: it opens
|
|
214
|
+
* with "add", says where the piece goes with a place phrase that names
|
|
215
|
+
* something build knows (a page family word, a page template by its whole
|
|
216
|
+
* name, or a component by the head word of its name:
|
|
217
|
+
* "above the table", "to the settings page"; not "to my project"), the
|
|
218
|
+
* piece's head names no page ("add a dashboard with a chart to my project"
|
|
219
|
+
* is a new page), and it asks for no new page.
|
|
220
|
+
* @param {string} text
|
|
221
|
+
* @param {Map<string, string>} familyWords
|
|
222
|
+
* @param {PageTemplate[]} pages
|
|
223
|
+
* @param {ComponentWords[]} components
|
|
224
|
+
* @returns {boolean}
|
|
225
|
+
*/
|
|
226
|
+
function addsToPage(text, familyWords, pages, components) {
|
|
227
|
+
if (!ADDS.test(text)) return false;
|
|
228
|
+
const place = text.match(PLACE_PHRASE);
|
|
229
|
+
if (!place || place.index === undefined) return false;
|
|
230
|
+
const piece = text.slice(0, place.index).split(HEAD_END)[0] ?? '';
|
|
231
|
+
const target =
|
|
232
|
+
text.slice(place.index + place[0].length).split(HEAD_END)[0] ?? '';
|
|
233
|
+
const named = new Set(terms(target));
|
|
234
|
+
const known = new Set([
|
|
235
|
+
...familyWords.keys(),
|
|
236
|
+
...components.map(c => nameTerms(c).at(-1) ?? ''),
|
|
237
|
+
]);
|
|
238
|
+
const namesTemplate = pages.some(page => {
|
|
239
|
+
const name = templateTerms(page);
|
|
240
|
+
return name.length > 0 && name.every(t => named.has(t));
|
|
241
|
+
});
|
|
242
|
+
return (
|
|
243
|
+
([...named].some(t => known.has(t)) || namesTemplate) &&
|
|
244
|
+
!namesPage(piece, familyWords, pages) &&
|
|
245
|
+
!asksNewPage(text.toLowerCase().split(PHRASE_END), familyWords)
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Whether a phrase names a page: it ends on a page family word ("add a
|
|
251
|
+
* dashboard"), on a word search drops, such as "page" ("add a settings
|
|
252
|
+
* page"), or on a page template's own name ("add a kanban board").
|
|
253
|
+
* @param {string} phrase
|
|
254
|
+
* @param {Map<string, string>} familyWords
|
|
255
|
+
* @param {PageTemplate[]} pages
|
|
256
|
+
* @returns {boolean}
|
|
257
|
+
*/
|
|
258
|
+
function namesPage(phrase, familyWords, pages) {
|
|
259
|
+
const words = phrase.toLowerCase().match(/[a-z0-9]+/g) ?? [];
|
|
260
|
+
const last = words[words.length - 1] ?? '';
|
|
261
|
+
if (familyWords.has(stem(last)) || terms(last).length === 0) return true;
|
|
262
|
+
const named = new Set(terms(phrase));
|
|
263
|
+
return pages.some(page => {
|
|
264
|
+
const name = templateTerms(page);
|
|
265
|
+
return (
|
|
266
|
+
name.length > 0 &&
|
|
267
|
+
name.includes(stem(last)) &&
|
|
268
|
+
name.every(t => named.has(t))
|
|
269
|
+
);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* The terms of a page template's own name: "kanban-board" is kanban, board.
|
|
275
|
+
* @param {PageTemplate} page
|
|
276
|
+
* @returns {string[]}
|
|
277
|
+
*/
|
|
278
|
+
function templateTerms(page) {
|
|
279
|
+
return terms(page.name.replace(/-/g, ' '));
|
|
280
|
+
}
|
|
281
|
+
|
|
93
282
|
/**
|
|
94
283
|
* Whether an idea changes a page or part the builder already has: "existing"
|
|
95
284
|
* in the same phrase as a word that names a family of page templates or one of
|
package/api/build/kit/kit.mjs
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file build.kit leaf — the page template to start from, and the kit around it.
|
|
5
5
|
*
|
|
6
|
-
* Every kit names a page template to START from
|
|
7
|
-
* (rank.mjs)
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Every kit names a page template to START from, else the app shell. The page
|
|
7
|
+
* ranker (rank.mjs) orders the page templates; for a whole page the word
|
|
8
|
+
* weights (weights.mjs) decide page or shell and the page-pick model chooses
|
|
9
|
+
* the page from that list (start.mjs). Search's own matches never choose the
|
|
10
|
+
* start, so one noisy signal — search matching "site" to a gallery's "side" —
|
|
11
|
+
* cannot choose the page. A
|
|
10
12
|
* template carries the page frame, the spacing, and the section rhythm; a page
|
|
11
13
|
* composed from components carries none of that, so the kit never recommends
|
|
12
14
|
* composing from scratch while a template exists. Next to the start it names
|
package/api/build/kit/rank.d.mts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Rank page templates against an idea, best first.
|
|
6
|
-
*
|
|
5
|
+
* Rank page templates against an idea, best first. An exact tie goes to a
|
|
6
|
+
* family's base template ahead of a variant; templates still tied are ordered
|
|
7
|
+
* by how strongly each one's own descriptor answers the idea, then by how
|
|
8
|
+
* typical of its family it is, then by name (`settleTies`).
|
|
7
9
|
*
|
|
8
10
|
* @param {string} query
|
|
9
11
|
* @param {PageTemplate[]} pages
|
package/api/build/kit/rank.mjs
CHANGED
|
@@ -23,14 +23,19 @@
|
|
|
23
23
|
* "board" picks the kanban board for a game board. Here every matched term
|
|
24
24
|
* counts, weighted by how rare it is among page templates (inverse document
|
|
25
25
|
* frequency), so the page that answers more of the idea — and its rarer words —
|
|
26
|
-
* wins. Structural signals sit on top
|
|
26
|
+
* wins. Structural signals sit on top. They order the ranker's list; for a
|
|
27
|
+
* whole page, the page-pick model in weights.mjs reads that list beside its
|
|
28
|
+
* own word tables and picks the start, so the start can differ from the
|
|
29
|
+
* ranker's first template:
|
|
27
30
|
*
|
|
28
31
|
* - The head noun. The words before the first "with", ":" or "," name what
|
|
29
32
|
* the page is ("audit dashboard: dense table with …"); a family word there
|
|
30
33
|
* outweighs the same word among the parts.
|
|
31
34
|
* - The container. In "draft history in a modal", the modal is the page's
|
|
32
|
-
* frame, and a template is its frame; container words count double
|
|
33
|
-
* container match is evidence enough to start from
|
|
35
|
+
* frame, and a template is its frame; container words count double. A
|
|
36
|
+
* container match is evidence enough to start from only when the frame holds
|
|
37
|
+
* a word of the template's own family ("settings in a modal"); a frame that
|
|
38
|
+
* holds a part ("saved drafts in a modal") is not. Only an overlay frame
|
|
34
39
|
* counts: "inside a data card" names a component the part lives in, and "in
|
|
35
40
|
* an existing dashboard" names the page being changed.
|
|
36
41
|
* - Phrase heads. In "side-by-side product response", "product" describes the
|
|
@@ -56,7 +61,12 @@ import {
|
|
|
56
61
|
normalized,
|
|
57
62
|
SYNONYMS_OF,
|
|
58
63
|
familyWordsOf,
|
|
64
|
+
keywordUnits,
|
|
65
|
+
keywordWordsFor,
|
|
66
|
+
framesOf,
|
|
59
67
|
} from './words.mjs';
|
|
68
|
+
import {namedOutright, tieReading} from './weights.mjs';
|
|
69
|
+
import {compareText} from '../../../foundation/text/compare-text.mjs';
|
|
60
70
|
|
|
61
71
|
/**
|
|
62
72
|
* @typedef {import('./words.mjs').PageTemplate} PageTemplate
|
|
@@ -126,8 +136,10 @@ const START_SCORE = 10;
|
|
|
126
136
|
const START_TERMS = 2;
|
|
127
137
|
|
|
128
138
|
/**
|
|
129
|
-
* Rank page templates against an idea, best first.
|
|
130
|
-
*
|
|
139
|
+
* Rank page templates against an idea, best first. An exact tie goes to a
|
|
140
|
+
* family's base template ahead of a variant; templates still tied are ordered
|
|
141
|
+
* by how strongly each one's own descriptor answers the idea, then by how
|
|
142
|
+
* typical of its family it is, then by name (`settleTies`).
|
|
131
143
|
*
|
|
132
144
|
* @param {string} query
|
|
133
145
|
* @param {PageTemplate[]} pages
|
|
@@ -136,14 +148,17 @@ const START_TERMS = 2;
|
|
|
136
148
|
export function rankPages(query, pages) {
|
|
137
149
|
const docs = pages.map(page => {
|
|
138
150
|
const [family = '', ...variantParts] = page.category.split(' - ');
|
|
151
|
+
const keywords = page.keywords ?? [];
|
|
152
|
+
const phrases = keywordUnits(keywords, terms).filter(u => u.includes(' '));
|
|
139
153
|
/** @type {Record<keyof typeof FIELD_WEIGHT, string>} */
|
|
140
154
|
const fields = {
|
|
141
155
|
id: page.name.replace(/-/g, ' '),
|
|
142
156
|
variant: variantParts.join(' - '),
|
|
143
157
|
family,
|
|
144
158
|
display: page.displayName,
|
|
145
|
-
//
|
|
146
|
-
|
|
159
|
+
// A one-word keyword is a term like any other. A longer one gives its
|
|
160
|
+
// words only to an idea that names the whole phrase (keywordWordsFor).
|
|
161
|
+
keywords: keywords.filter(k => terms(k).length === 1).join(', '),
|
|
147
162
|
description: page.description,
|
|
148
163
|
};
|
|
149
164
|
/** @type {Map<string, number>} */
|
|
@@ -158,7 +173,9 @@ export function rankPages(query, pages) {
|
|
|
158
173
|
page,
|
|
159
174
|
family: family.trim(),
|
|
160
175
|
bag,
|
|
161
|
-
|
|
176
|
+
phrases,
|
|
177
|
+
// Each keyword is its own phrase: a pair never spans two of them.
|
|
178
|
+
pairs: pairsOf([...Object.values(fields), keywords.join(', ')]),
|
|
162
179
|
};
|
|
163
180
|
});
|
|
164
181
|
|
|
@@ -169,27 +186,52 @@ export function rankPages(query, pages) {
|
|
|
169
186
|
for (const {bag} of docs)
|
|
170
187
|
for (const t of bag.keys()) df.set(t, (df.get(t) ?? 0) + 1);
|
|
171
188
|
const n = docs.length;
|
|
172
|
-
/**
|
|
173
|
-
|
|
174
|
-
|
|
189
|
+
/**
|
|
190
|
+
* @param {string} t
|
|
191
|
+
* @param {number} [own] 1 when the template scored carries `t` only through
|
|
192
|
+
* a phrase keyword the idea names, so it counts among the templates that
|
|
193
|
+
* carry `t`
|
|
194
|
+
*/
|
|
195
|
+
const idf = (t, own = 0) => {
|
|
196
|
+
const d = (df.get(t) ?? 0) + own;
|
|
175
197
|
return d ? Math.log(1 + (n - d + 0.5) / (d + 0.5)) : 0;
|
|
176
198
|
};
|
|
177
199
|
|
|
200
|
+
// How many templates of each family carry each term, for how typical of its
|
|
201
|
+
// family a template's descriptor is.
|
|
202
|
+
/** @type {Map<string, Map<string, number>>} */
|
|
203
|
+
const familyDf = new Map();
|
|
204
|
+
for (const {family, bag} of docs) {
|
|
205
|
+
const counts = familyDf.get(family) ?? new Map();
|
|
206
|
+
familyDf.set(family, counts);
|
|
207
|
+
for (const t of bag.keys()) counts.set(t, (counts.get(t) ?? 0) + 1);
|
|
208
|
+
}
|
|
209
|
+
|
|
178
210
|
const familyOfWord = familyWordsOf(pages);
|
|
179
211
|
/** @param {string[]} ts */
|
|
180
212
|
const familiesIn = ts =>
|
|
181
213
|
new Set(ts.filter(t => familyOfWord.has(t)).map(t => familyOfWord.get(t)));
|
|
182
214
|
|
|
183
|
-
const
|
|
215
|
+
const queryWords = terms(query);
|
|
216
|
+
const queryTerms = [...new Set(queryWords)];
|
|
184
217
|
const headFamilies = familiesIn(
|
|
185
218
|
terms(String(query).split(HEAD_END)[0] ?? ''),
|
|
186
219
|
);
|
|
187
220
|
const namedFamilies = familiesIn(queryTerms);
|
|
188
221
|
const modifiers = modifiersOf(query);
|
|
189
222
|
const containers = containersOf(query);
|
|
223
|
+
const frames = framesOf(query);
|
|
190
224
|
|
|
191
225
|
const ranked = docs
|
|
192
|
-
.map(({page, family, bag, pairs}) => {
|
|
226
|
+
.map(({page, family, bag, phrases, pairs}) => {
|
|
227
|
+
// The words of the phrase keywords this idea names count as keywords.
|
|
228
|
+
const phraseWords = new Set(keywordWordsFor(phrases, queryWords));
|
|
229
|
+
/** @param {string} t */
|
|
230
|
+
const weightOf = t =>
|
|
231
|
+
Math.max(
|
|
232
|
+
bag.get(t) ?? 0,
|
|
233
|
+
phraseWords.has(t) ? FIELD_WEIGHT.keywords : 0,
|
|
234
|
+
);
|
|
193
235
|
let score = 0;
|
|
194
236
|
let hits = 0;
|
|
195
237
|
let containerMatched = false;
|
|
@@ -202,7 +244,10 @@ export function rankPages(query, pages) {
|
|
|
202
244
|
const discounted =
|
|
203
245
|
modified !== undefined &&
|
|
204
246
|
![...modified].some(n => pairs.has(`${t} ${n}`));
|
|
205
|
-
const direct =
|
|
247
|
+
const direct =
|
|
248
|
+
idf(t, bag.has(t) ? 0 : Number(phraseWords.has(t))) *
|
|
249
|
+
weightOf(t) *
|
|
250
|
+
(discounted ? MODIFIER : 1);
|
|
206
251
|
let viaSynonym = 0;
|
|
207
252
|
for (const s of SYNONYMS_OF.get(t) ?? []) {
|
|
208
253
|
if (queryTerms.includes(s)) continue;
|
|
@@ -217,7 +262,12 @@ export function rankPages(query, pages) {
|
|
|
217
262
|
score += value;
|
|
218
263
|
hits++;
|
|
219
264
|
matched.add(t);
|
|
220
|
-
|
|
265
|
+
// A frame is start evidence only when it holds the template's
|
|
266
|
+
// family itself, not a part placed on some page.
|
|
267
|
+
if (
|
|
268
|
+
[...(frames.get(t) ?? [])].some(h => familyOfWord.get(h) === family)
|
|
269
|
+
)
|
|
270
|
+
containerMatched = true;
|
|
221
271
|
}
|
|
222
272
|
}
|
|
223
273
|
const familyNamed = namedFamilies.has(family);
|
|
@@ -226,8 +276,12 @@ export function rankPages(query, pages) {
|
|
|
226
276
|
else if (familyNamed) score += BODY_FAMILY;
|
|
227
277
|
const base = normalized(page.name) === normalized(family);
|
|
228
278
|
if (familyNamed && base) score += FAMILY_BASE;
|
|
279
|
+
const inFamily = familyDf.get(family);
|
|
280
|
+
let shared = 0;
|
|
281
|
+
for (const t of bag.keys()) shared += (inFamily?.get(t) ?? 1) - 1;
|
|
229
282
|
return {
|
|
230
283
|
name: page.name,
|
|
284
|
+
typical: bag.size ? shared / bag.size : 0,
|
|
231
285
|
score,
|
|
232
286
|
hits,
|
|
233
287
|
familyNamed,
|
|
@@ -238,18 +292,64 @@ export function rankPages(query, pages) {
|
|
|
238
292
|
matched,
|
|
239
293
|
};
|
|
240
294
|
})
|
|
241
|
-
.sort(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
295
|
+
.sort((a, b) => b.score - a.score || Number(b.base) - Number(a.base));
|
|
296
|
+
return baseFirst(settleTies(ranked, query, pages));
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Order each run of templates the ranker scores exactly the same (and that
|
|
301
|
+
* are all bases or all variants), whatever their families: first the one the
|
|
302
|
+
* idea names by its whole name (`namedOutright`), then by how strongly each
|
|
303
|
+
* one's own descriptor answers the idea (`tieReading`), then by how typical of
|
|
304
|
+
* its family it is, then by name. The catalog's order never decides, and
|
|
305
|
+
* neither does the host's locale.
|
|
306
|
+
* @param {RankedPage[]} ranked sorted by score, then base first
|
|
307
|
+
* @param {string} query
|
|
308
|
+
* @param {PageTemplate[]} pages
|
|
309
|
+
* @returns {RankedPage[]}
|
|
310
|
+
*/
|
|
311
|
+
function settleTies(ranked, query, pages) {
|
|
312
|
+
const out = [];
|
|
313
|
+
for (let i = 0; i < ranked.length;) {
|
|
314
|
+
let j = i + 1;
|
|
315
|
+
while (
|
|
316
|
+
j < ranked.length &&
|
|
317
|
+
ranked[j].score === ranked[i].score &&
|
|
318
|
+
ranked[j].base === ranked[i].base
|
|
319
|
+
)
|
|
320
|
+
j++;
|
|
321
|
+
const run = ranked.slice(i, j);
|
|
322
|
+
if (run.length > 1) {
|
|
323
|
+
const reading = tieReading(
|
|
324
|
+
run.map(r => r.name),
|
|
325
|
+
query,
|
|
326
|
+
pages,
|
|
327
|
+
);
|
|
328
|
+
const named = namedOutright(
|
|
329
|
+
run.map(r => r.name),
|
|
330
|
+
query,
|
|
331
|
+
pages,
|
|
332
|
+
);
|
|
333
|
+
const at = new Map(run.map((r, k) => [r, reading[k]]));
|
|
334
|
+
const outright = new Map(run.map((r, k) => [r, named[k]]));
|
|
335
|
+
run.sort(
|
|
336
|
+
(a, b) =>
|
|
337
|
+
Number(outright.get(b)) - Number(outright.get(a)) ||
|
|
338
|
+
Number(at.get(b)) - Number(at.get(a)) ||
|
|
339
|
+
b.typical - a.typical ||
|
|
340
|
+
compareText(a.name, b.name),
|
|
341
|
+
);
|
|
342
|
+
} else run.sort((a, b) => compareText(a.name, b.name));
|
|
343
|
+
out.push(...run);
|
|
344
|
+
i = j;
|
|
345
|
+
}
|
|
346
|
+
return out;
|
|
248
347
|
}
|
|
249
348
|
|
|
250
349
|
/**
|
|
251
350
|
* Put a named family's base template ahead of the variant that outranks it,
|
|
252
|
-
* unless the variant matched START_TERMS terms the base did not,
|
|
351
|
+
* unless the variant matched START_TERMS terms the base did not, the idea
|
|
352
|
+
* places the page in the variant's frame and not the base's, or the base
|
|
253
353
|
* cannot start on its own: too little score, or too few matched terms. The
|
|
254
354
|
* head names the exception: a family word in the idea's head is start
|
|
255
355
|
* evidence on its own — the same evidence pickStart accepts in place of a
|
|
@@ -272,8 +372,9 @@ function baseFirst(ranked) {
|
|
|
272
372
|
) {
|
|
273
373
|
return ranked;
|
|
274
374
|
}
|
|
375
|
+
// The frame is what a template is, and pickStart takes it as evidence.
|
|
275
376
|
const own = [...top.matched].filter(t => !base.matched.has(t)).length;
|
|
276
|
-
return own >= START_TERMS
|
|
377
|
+
return own >= START_TERMS || (top.containerMatched && !base.containerMatched)
|
|
277
378
|
? ranked
|
|
278
379
|
: [base, ...ranked.filter(r => r !== base)];
|
|
279
380
|
}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The template to start from:
|
|
6
|
-
*
|
|
5
|
+
* The template to start from: for a whole page, the ready page the word
|
|
6
|
+
* weights and the page-pick model choose (weighStart); for a part or an edit,
|
|
7
|
+
* the ranker's placement; else the first fallback shell the project can
|
|
7
8
|
* scaffold. Null only when the project has no page template to offer at all.
|
|
8
9
|
*
|
|
9
|
-
* `direct` means two independent signals agree: the
|
|
10
|
-
*
|
|
10
|
+
* `direct` means two independent signals agree: the start is also search's
|
|
11
|
+
* direct match. The ranker sees only ready templates, so a template
|
|
11
12
|
* still marked not ready is never the start; when search matched one directly
|
|
12
13
|
* the reason names it, so the reader knows why the kit starts elsewhere.
|
|
13
14
|
*
|
package/api/build/kit/start.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file The page template a kit starts from:
|
|
5
|
-
*
|
|
4
|
+
* @file The page template a kit starts from: for a whole page, the page the
|
|
5
|
+
* word weights and the page-pick model choose from the ranker's list; for a
|
|
6
|
+
* part or an edit, where the ranker's placement rules put it; else the app
|
|
7
|
+
* shell.
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
10
|
import {loadWeights} from '../_adapter.mjs';
|
|
@@ -113,12 +115,13 @@ function liftFromShell(ranked, kind, catalog, idea) {
|
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
/**
|
|
116
|
-
* The template to start from:
|
|
117
|
-
*
|
|
118
|
+
* The template to start from: for a whole page, the ready page the word
|
|
119
|
+
* weights and the page-pick model choose (weighStart); for a part or an edit,
|
|
120
|
+
* the ranker's placement; else the first fallback shell the project can
|
|
118
121
|
* scaffold. Null only when the project has no page template to offer at all.
|
|
119
122
|
*
|
|
120
|
-
* `direct` means two independent signals agree: the
|
|
121
|
-
*
|
|
123
|
+
* `direct` means two independent signals agree: the start is also search's
|
|
124
|
+
* direct match. The ranker sees only ready templates, so a template
|
|
122
125
|
* still marked not ready is never the start; when search matched one directly
|
|
123
126
|
* the reason names it, so the reader knows why the kit starts elsewhere.
|
|
124
127
|
*
|
|
@@ -149,8 +152,9 @@ export function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
|
|
|
149
152
|
: place[0].toUpperCase() + place.slice(1);
|
|
150
153
|
const proposed = pickStart(ranked, kind);
|
|
151
154
|
// The checked-in word weights (weights.mjs), blended with the ranker's
|
|
152
|
-
// scores, decide the start of a whole page
|
|
153
|
-
//
|
|
155
|
+
// scores, decide the start of a whole page, so it can differ from the
|
|
156
|
+
// ranker's own pick, its head-noun family included. A part or an edit starts
|
|
157
|
+
// where the ranker's placement rules put it (spec:AST-048/FR3).
|
|
154
158
|
const weighed =
|
|
155
159
|
kind === 'page'
|
|
156
160
|
? weighStart(idea, ranked, proposed, catalog, {
|