@astryxdesign/cli 0.7.16 → 0.7.17-canary.g0135e03
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 +26 -2
- package/api/docs/_adapter.mjs +219 -6
- 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 +122 -1
- package/api/theme/build/build.mjs +412 -84
- 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 +23 -3
- package/api/theme/build/font-warning.mjs +54 -5
- package/api/theme/build/icon-imports.mjs +25 -2
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +103 -3
- package/api/theme-edit/_adapter.mjs +961 -82
- package/api/theme-edit/_catalog.mjs +19 -4
- package/api/theme-edit/_check.d.mts +63 -24
- package/api/theme-edit/_check.mjs +2467 -362
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +49 -1
- package/api/theme-edit/_compiler.mjs +89 -6
- package/api/theme-edit/_context.d.mts +3 -3
- package/api/theme-edit/_context.mjs +165 -54
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +31 -4
- package/api/theme-edit/_edit.mjs +2433 -204
- package/api/theme-edit/_how-commands.d.mts +72 -1
- package/api/theme-edit/_how-commands.mjs +759 -9
- package/api/theme-edit/_how-question.d.mts +82 -5
- package/api/theme-edit/_how-question.mjs +6473 -553
- package/api/theme-edit/_how.d.mts +2 -1
- package/api/theme-edit/_how.mjs +237 -41
- 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 +292 -0
- package/api/theme-edit/_normal.mjs +1454 -0
- package/api/theme-edit/_palette.mjs +10 -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 +18 -1
- package/api/theme-edit/_parts.mjs +246 -23
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +776 -187
- package/api/theme-edit/_preview.d.mts +100 -14
- package/api/theme-edit/_preview.mjs +582 -139
- package/api/theme-edit/_project.d.mts +4 -0
- package/api/theme-edit/_project.mjs +3 -1
- package/api/theme-edit/_settings.d.mts +417 -42
- package/api/theme-edit/_settings.mjs +3262 -424
- package/api/theme-edit/_tables.d.mts +15 -0
- package/api/theme-edit/_tables.mjs +63 -1
- package/api/theme-edit/_vet.d.mts +20 -0
- package/api/theme-edit/_vet.mjs +47 -2
- package/api/theme-edit/theme-edit.type.d.mts +10 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -1
- 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/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 +358 -63
- 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 +1 -1
- 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 +317 -47
- 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 +92 -21
- 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/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.mjs +3 -2
- 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 +31 -0
- package/foundation/fonts/font-stylesheet.mjs +115 -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 +512 -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/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/_adapter.d.mts
CHANGED
|
@@ -12,12 +12,15 @@
|
|
|
12
12
|
* @property {string} category The template's own `Family - Variant` label; empty when it declares none.
|
|
13
13
|
* @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
|
|
14
14
|
* @property {string} filePath Absolute path to the template source file on disk.
|
|
15
|
+
* @property {string[]} components The components its page composes, read from its source on first use; empty when the source cannot be read.
|
|
15
16
|
*/
|
|
16
17
|
/**
|
|
17
18
|
* A component the project can use, as the ranker reads it.
|
|
18
19
|
* @typedef {object} ComponentWords
|
|
19
20
|
* @property {string} name The component's name, e.g. `DateRangeInput`.
|
|
20
21
|
* @property {string[]} keywords The keywords its own doc declares.
|
|
22
|
+
* @property {string} [category] The category its own doc files it under,
|
|
23
|
+
* e.g. `Table & List`.
|
|
21
24
|
*/
|
|
22
25
|
/**
|
|
23
26
|
* Every ready page template the project can scaffold, in discovery order. This
|
|
@@ -158,6 +161,10 @@ export type PageTemplate = {
|
|
|
158
161
|
* Absolute path to the template source file on disk.
|
|
159
162
|
*/
|
|
160
163
|
filePath: string;
|
|
164
|
+
/**
|
|
165
|
+
* The components its page composes, read from its source on first use; empty when the source cannot be read.
|
|
166
|
+
*/
|
|
167
|
+
components: string[];
|
|
161
168
|
};
|
|
162
169
|
/**
|
|
163
170
|
* A component the project can use, as the ranker reads it.
|
|
@@ -171,6 +178,11 @@ export type ComponentWords = {
|
|
|
171
178
|
* The keywords its own doc declares.
|
|
172
179
|
*/
|
|
173
180
|
keywords: string[];
|
|
181
|
+
/**
|
|
182
|
+
* The category its own doc files it under,
|
|
183
|
+
* e.g. `Table & List`.
|
|
184
|
+
*/
|
|
185
|
+
category?: string | undefined;
|
|
174
186
|
};
|
|
175
187
|
/**
|
|
176
188
|
* A block the kit can name, as search names a block result.
|
package/api/build/_adapter.mjs
CHANGED
|
@@ -28,6 +28,8 @@ import {componentKeywords} from '../search/search.mjs';
|
|
|
28
28
|
import {findCoreDir, requireCoreDir} from '../../foundation/fs/paths.mjs';
|
|
29
29
|
import {persistedDerived} from '../../foundation/fs/gather-cache.mjs';
|
|
30
30
|
import {analyzeTemplateNeeds} from '../../foundation/discovery/template-needs.mjs';
|
|
31
|
+
import {extractComponents} from '../../foundation/discovery/template-adapter.mjs';
|
|
32
|
+
import {isWordModel} from './kit/word-model.mjs';
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* Runs one build with a single directory listing per path: the kit resolves
|
|
@@ -47,6 +49,7 @@ export {withListingCache} from '../../foundation/fs/listing-cache.mjs';
|
|
|
47
49
|
* @property {string} category The template's own `Family - Variant` label; empty when it declares none.
|
|
48
50
|
* @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
|
|
49
51
|
* @property {string} filePath Absolute path to the template source file on disk.
|
|
52
|
+
* @property {string[]} components The components its page composes, read from its source on first use; empty when the source cannot be read.
|
|
50
53
|
*/
|
|
51
54
|
|
|
52
55
|
/**
|
|
@@ -54,6 +57,8 @@ export {withListingCache} from '../../foundation/fs/listing-cache.mjs';
|
|
|
54
57
|
* @typedef {object} ComponentWords
|
|
55
58
|
* @property {string} name The component's name, e.g. `DateRangeInput`.
|
|
56
59
|
* @property {string[]} keywords The keywords its own doc declares.
|
|
60
|
+
* @property {string} [category] The category its own doc files it under,
|
|
61
|
+
* e.g. `Table & List`.
|
|
57
62
|
*/
|
|
58
63
|
|
|
59
64
|
/**
|
|
@@ -99,18 +104,23 @@ export async function loadTemplates(cwd) {
|
|
|
99
104
|
}
|
|
100
105
|
const pages = templates
|
|
101
106
|
.filter(t => t.type === 'page' && t.isReady !== false)
|
|
102
|
-
.map(t =>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
.map(t =>
|
|
108
|
+
withComponents(
|
|
109
|
+
{
|
|
110
|
+
name: t.dirName,
|
|
111
|
+
displayName: t.displayName || t.name,
|
|
112
|
+
description: t.description || '',
|
|
113
|
+
package: t.package ?? '@astryxdesign/core',
|
|
114
|
+
category: t.category || '',
|
|
115
|
+
keywords: t.keywords ?? [],
|
|
116
|
+
filePath: t.filePath,
|
|
117
|
+
// The id `template()` resolves back to this entry: an active
|
|
118
|
+
// replacement owns the Core id it names, so that id selects it.
|
|
119
|
+
command: `astryx template ${t.replaces ?? t.dirName} --type page`,
|
|
120
|
+
},
|
|
121
|
+
t.filePath,
|
|
122
|
+
),
|
|
123
|
+
);
|
|
114
124
|
const blocks = templates
|
|
115
125
|
.filter(t => t.type === 'block')
|
|
116
126
|
.map(t => ({
|
|
@@ -261,28 +271,7 @@ export function loadBlockPicker() {
|
|
|
261
271
|
*/
|
|
262
272
|
export function isWeightsFile(file) {
|
|
263
273
|
const n = Array.isArray(file?.candidates) ? file.candidates.length : 0;
|
|
264
|
-
return (
|
|
265
|
-
n > 0 &&
|
|
266
|
-
Array.isArray(file.tables) &&
|
|
267
|
-
file.tables.length > 0 &&
|
|
268
|
-
file.tables.every(
|
|
269
|
-
(/** @type {any} */ t) =>
|
|
270
|
-
Array.isArray(t?.words) &&
|
|
271
|
-
Array.isArray(t.rows) &&
|
|
272
|
-
t.rows.length === t.words.length &&
|
|
273
|
-
t.rows.every(
|
|
274
|
-
(/** @type {any} */ r) => typeof r === 'string' && r.length === n,
|
|
275
|
-
) &&
|
|
276
|
-
Array.isArray(t.bias) &&
|
|
277
|
-
t.bias.length === n &&
|
|
278
|
-
t.bias.every((/** @type {any} */ b) => Number.isFinite(b)) &&
|
|
279
|
-
Number.isFinite(t.clip) &&
|
|
280
|
-
Number.isFinite(t.step),
|
|
281
|
-
) &&
|
|
282
|
-
Array.isArray(file.blend) &&
|
|
283
|
-
file.blend.length === 3 * (file.tables.length + 1) + 1 &&
|
|
284
|
-
file.blend.every((/** @type {any} */ x) => Number.isFinite(x))
|
|
285
|
-
);
|
|
274
|
+
return isWordModel(file, n);
|
|
286
275
|
}
|
|
287
276
|
|
|
288
277
|
/** The ranking coefficients the picker reads. */
|
|
@@ -362,3 +351,31 @@ export function templateSetupNotes(template, cwd) {
|
|
|
362
351
|
export function requireBuildCoreDir(cwd) {
|
|
363
352
|
return requireCoreDir(cwd);
|
|
364
353
|
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Adds a lazy, non-enumerable `components` getter to a page entry: the page's
|
|
357
|
+
* source is read and parsed only when a caller reads it, once, so loading the
|
|
358
|
+
* catalog stays cheap and the entry's own fields are unchanged.
|
|
359
|
+
* @template {object} T
|
|
360
|
+
* @param {T} entry
|
|
361
|
+
* @param {string | undefined} filePath
|
|
362
|
+
* @returns {T & {readonly components: string[]}}
|
|
363
|
+
*/
|
|
364
|
+
function withComponents(entry, filePath) {
|
|
365
|
+
/** @type {string[] | undefined} */
|
|
366
|
+
let components;
|
|
367
|
+
return /** @type {T & {readonly components: string[]}} */ (
|
|
368
|
+
Object.defineProperty(entry, 'components', {
|
|
369
|
+
get() {
|
|
370
|
+
if (components === undefined) {
|
|
371
|
+
try {
|
|
372
|
+
components = filePath ? extractComponents(filePath) : [];
|
|
373
|
+
} catch {
|
|
374
|
+
components = [];
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return components;
|
|
378
|
+
},
|
|
379
|
+
})
|
|
380
|
+
);
|
|
381
|
+
}
|
|
@@ -47,17 +47,19 @@ export function requestSideOf(request: string, weights: BlockPickerWeights): {
|
|
|
47
47
|
/**
|
|
48
48
|
* The picker's match of a request to a docs text: their projections' dot
|
|
49
49
|
* product plus the lexical weight times their plain overlap (the cosine of
|
|
50
|
-
* their word vectors).
|
|
51
|
-
*
|
|
52
|
-
*
|
|
50
|
+
* their word vectors). The vectors are keyed by vocabulary index (search's
|
|
51
|
+
* fit) or by word (the block picker's overlap, which also counts single
|
|
52
|
+
* words outside the vocabulary).
|
|
53
|
+
* @param {{vector: Map<number | string, number>, projected: Float64Array}} request
|
|
54
|
+
* @param {{vector: Map<number | string, number>, projected: Float64Array}} doc
|
|
53
55
|
* @param {BlockPickerWeights} weights
|
|
54
56
|
* @returns {{match: number, overlap: number}}
|
|
55
57
|
*/
|
|
56
58
|
export function matchOf(request: {
|
|
57
|
-
vector: Map<number, number>;
|
|
59
|
+
vector: Map<number | string, number>;
|
|
58
60
|
projected: Float64Array;
|
|
59
61
|
}, doc: {
|
|
60
|
-
vector: Map<number, number>;
|
|
62
|
+
vector: Map<number | string, number>;
|
|
61
63
|
projected: Float64Array;
|
|
62
64
|
}, weights: BlockPickerWeights): {
|
|
63
65
|
match: number;
|
|
@@ -27,7 +27,11 @@
|
|
|
27
27
|
* request's vector through the request matrix, against the docs' vector
|
|
28
28
|
* through the doc matrix, plus the lexical weight times their plain overlap
|
|
29
29
|
* (cosine), so a block the weights were never fitted with, such as a new one,
|
|
30
|
-
* is scored from its docs the same way. The
|
|
30
|
+
* is scored from its docs the same way. The plain overlap also counts single
|
|
31
|
+
* words outside the vocabulary the matrices were fitted with (such a word
|
|
32
|
+
* weighs as much as the vocabulary's rarest word), so a newer block's own
|
|
33
|
+
* words still tie it to a request that uses them. The
|
|
34
|
+
* candidates are the best matches,
|
|
31
35
|
* build's own blocks, search's first results, and the best plain overlaps.
|
|
32
36
|
* Each candidate's final score adds the ranking coefficients times: its match
|
|
33
37
|
* relative to the best, its place among the matches, its lead over the
|
|
@@ -197,10 +201,42 @@ function vectorOf(terms, d) {
|
|
|
197
201
|
return v;
|
|
198
202
|
}
|
|
199
203
|
|
|
204
|
+
/**
|
|
205
|
+
* A text's sparse unit vector over its words, for the plain overlap:
|
|
206
|
+
* (1 + ln count) x idf. A single word outside the vocabulary weighs as much
|
|
207
|
+
* as the vocabulary's rarest word (no fitted text used it often enough to
|
|
208
|
+
* keep). It counts only when `known` has it: a request word no block's docs
|
|
209
|
+
* use cannot tie the request to any block. A word pair counts only when the
|
|
210
|
+
* vocabulary has it.
|
|
211
|
+
* @param {string[]} terms
|
|
212
|
+
* @param {{index: Map<string, number>, idf: Float64Array, rarest: number}} d
|
|
213
|
+
* @param {Set<string>} [known] the words outside the vocabulary that count; all when absent
|
|
214
|
+
* @returns {Map<string, number>}
|
|
215
|
+
*/
|
|
216
|
+
function wordVectorOf(terms, d, known) {
|
|
217
|
+
/** @type {Map<string, number>} */
|
|
218
|
+
const counts = new Map();
|
|
219
|
+
for (const t of terms) counts.set(t, (counts.get(t) ?? 0) + 1);
|
|
220
|
+
/** @type {Map<string, number>} */
|
|
221
|
+
const v = new Map();
|
|
222
|
+
let sq = 0;
|
|
223
|
+
for (const [t, c] of counts) {
|
|
224
|
+
const i = d.index.get(t);
|
|
225
|
+
if (i === undefined && (t.includes('_') || (known && !known.has(t))))
|
|
226
|
+
continue;
|
|
227
|
+
const x = (1 + Math.log(c)) * (i === undefined ? d.rarest : d.idf[i]);
|
|
228
|
+
v.set(t, x);
|
|
229
|
+
sq += x * x;
|
|
230
|
+
}
|
|
231
|
+
const norm = Math.sqrt(sq) || 1;
|
|
232
|
+
for (const [t, x] of v) v.set(t, x / norm);
|
|
233
|
+
return v;
|
|
234
|
+
}
|
|
235
|
+
|
|
200
236
|
/**
|
|
201
237
|
* The vocabulary index and idf, read once per weights object, and each matrix
|
|
202
238
|
* row decoded when a side first uses it.
|
|
203
|
-
* @type {WeakMap<BlockPickerWeights, {index: Map<string, number>, idf: Float64Array, rows: Map<string, Int8Array>}>}
|
|
239
|
+
* @type {WeakMap<BlockPickerWeights, {index: Map<string, number>, idf: Float64Array, rarest: number, rows: Map<string, Int8Array>}>}
|
|
204
240
|
*/
|
|
205
241
|
const vocabularies = new WeakMap();
|
|
206
242
|
|
|
@@ -208,9 +244,11 @@ const vocabularies = new WeakMap();
|
|
|
208
244
|
function vocabularyOf(weights) {
|
|
209
245
|
let v = vocabularies.get(weights);
|
|
210
246
|
if (!v) {
|
|
247
|
+
const idf = Float64Array.from(weights.idf, x => x / 1024);
|
|
211
248
|
v = {
|
|
212
249
|
index: new Map(weights.vocab.map((w, i) => [w, i])),
|
|
213
|
-
idf
|
|
250
|
+
idf,
|
|
251
|
+
rarest: idf.reduce((a, x) => Math.max(a, x), 0),
|
|
214
252
|
rows: new Map(),
|
|
215
253
|
};
|
|
216
254
|
vocabularies.set(weights, v);
|
|
@@ -292,9 +330,11 @@ export function requestSideOf(request, weights) {
|
|
|
292
330
|
/**
|
|
293
331
|
* The picker's match of a request to a docs text: their projections' dot
|
|
294
332
|
* product plus the lexical weight times their plain overlap (the cosine of
|
|
295
|
-
* their word vectors).
|
|
296
|
-
*
|
|
297
|
-
*
|
|
333
|
+
* their word vectors). The vectors are keyed by vocabulary index (search's
|
|
334
|
+
* fit) or by word (the block picker's overlap, which also counts single
|
|
335
|
+
* words outside the vocabulary).
|
|
336
|
+
* @param {{vector: Map<number | string, number>, projected: Float64Array}} request
|
|
337
|
+
* @param {{vector: Map<number | string, number>, projected: Float64Array}} doc
|
|
298
338
|
* @param {BlockPickerWeights} weights
|
|
299
339
|
* @returns {{match: number, overlap: number}}
|
|
300
340
|
*/
|
|
@@ -325,7 +365,7 @@ function componentOf(block, componentNames) {
|
|
|
325
365
|
/**
|
|
326
366
|
* The catalog, read once per weights and catalog contents: each block's
|
|
327
367
|
* component, docs vector and projection, and each component's name phrases.
|
|
328
|
-
* @type {WeakMap<BlockPickerWeights, {key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>, phrases: Map<string, [string[], number][]>}>}
|
|
368
|
+
* @type {WeakMap<BlockPickerWeights, {key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array, words: Map<string, number>}>, phrases: Map<string, [string[], number][]>}>}
|
|
329
369
|
*/
|
|
330
370
|
const catalogs = new WeakMap();
|
|
331
371
|
|
|
@@ -357,19 +397,41 @@ function readCatalog(catalog, components, weights, keep) {
|
|
|
357
397
|
return read;
|
|
358
398
|
}
|
|
359
399
|
|
|
400
|
+
/**
|
|
401
|
+
* Every word the catalog's block docs use, per read catalog.
|
|
402
|
+
* @type {WeakMap<object, Set<string>>}
|
|
403
|
+
*/
|
|
404
|
+
const docWords = new WeakMap();
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* @param {{blocks: Map<string, {words: Map<string, number>}>}} cat
|
|
408
|
+
* @returns {Set<string>}
|
|
409
|
+
*/
|
|
410
|
+
function docWordsOf(cat) {
|
|
411
|
+
let words = docWords.get(cat);
|
|
412
|
+
if (!words) {
|
|
413
|
+
words = new Set();
|
|
414
|
+
for (const b of cat.blocks.values())
|
|
415
|
+
for (const t of b.words.keys()) words.add(t);
|
|
416
|
+
docWords.set(cat, words);
|
|
417
|
+
}
|
|
418
|
+
return words;
|
|
419
|
+
}
|
|
420
|
+
|
|
360
421
|
/**
|
|
361
422
|
* readCatalog's value, worked out.
|
|
362
423
|
* @param {string} key
|
|
363
424
|
* @param {CatalogBlock[]} catalog
|
|
364
425
|
* @param {CatalogComponent[]} components
|
|
365
426
|
* @param {BlockPickerWeights} weights
|
|
366
|
-
* @returns {{key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>, phrases: Map<string, [string[], number][]>}}
|
|
427
|
+
* @returns {{key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array, words: Map<string, number>}>, phrases: Map<string, [string[], number][]>}}
|
|
367
428
|
*/
|
|
368
429
|
function computeCatalog(key, catalog, components, weights) {
|
|
369
430
|
const names = components.map(c => c.name).sort((a, b) => b.length - a.length);
|
|
370
431
|
const keywords = new Map(components.map(c => [c.name, c.keywords ?? []]));
|
|
371
|
-
/** @type {Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>} */
|
|
432
|
+
/** @type {Map<string, {component: string, vector: Map<number, number>, projected: Float64Array, words: Map<string, number>}>} */
|
|
372
433
|
const blocks = new Map();
|
|
434
|
+
const vocabulary = vocabularyOf(weights);
|
|
373
435
|
for (const b of catalog) {
|
|
374
436
|
if (blocks.has(b.name)) continue;
|
|
375
437
|
const component = componentOf(b, names);
|
|
@@ -380,7 +442,11 @@ function computeCatalog(key, catalog, components, weights) {
|
|
|
380
442
|
wordsOf(component).join(' '),
|
|
381
443
|
(keywords.get(component) ?? []).join(' '),
|
|
382
444
|
].join(' ');
|
|
383
|
-
blocks.set(b.name, {
|
|
445
|
+
blocks.set(b.name, {
|
|
446
|
+
component,
|
|
447
|
+
...docSideOf(text, weights),
|
|
448
|
+
words: wordVectorOf(termsOf(text), vocabulary),
|
|
449
|
+
});
|
|
384
450
|
}
|
|
385
451
|
// A component is named by its own words, or by a keyword at most three
|
|
386
452
|
// components share (weighted by how few share it).
|
|
@@ -412,7 +478,8 @@ function computeCatalog(key, catalog, components, weights) {
|
|
|
412
478
|
const CATALOG_CODEC = {
|
|
413
479
|
/**
|
|
414
480
|
* What decode can get wrong in a read-back catalog: its key, each block's
|
|
415
|
-
* component, and projections of one width with finite
|
|
481
|
+
* component and word vector, and projections of one width with finite
|
|
482
|
+
* numbers.
|
|
416
483
|
* @param {any} read
|
|
417
484
|
*/
|
|
418
485
|
valid: read => {
|
|
@@ -422,6 +489,7 @@ const CATALOG_CODEC = {
|
|
|
422
489
|
return blocks.every(
|
|
423
490
|
(/** @type {any} */ b) =>
|
|
424
491
|
typeof b.component === 'string' &&
|
|
492
|
+
b.words instanceof Map &&
|
|
425
493
|
b.projected.length > 0 &&
|
|
426
494
|
b.projected.length === width &&
|
|
427
495
|
[...b.projected].every(Number.isFinite),
|
|
@@ -435,6 +503,7 @@ const CATALOG_CODEC = {
|
|
|
435
503
|
b.component,
|
|
436
504
|
[...b.vector],
|
|
437
505
|
[...b.projected],
|
|
506
|
+
[...b.words],
|
|
438
507
|
]),
|
|
439
508
|
phrases: [...read.phrases],
|
|
440
509
|
}),
|
|
@@ -447,11 +516,12 @@ const CATALOG_CODEC = {
|
|
|
447
516
|
blocks: new Map(
|
|
448
517
|
stored.blocks.map(
|
|
449
518
|
(
|
|
450
|
-
/** @type {[string, string, [number, number][], number[]]} */ [
|
|
519
|
+
/** @type {[string, string, [number, number][], number[], [string, number][]]} */ [
|
|
451
520
|
name,
|
|
452
521
|
component,
|
|
453
522
|
vector,
|
|
454
523
|
projected,
|
|
524
|
+
words,
|
|
455
525
|
],
|
|
456
526
|
) => [
|
|
457
527
|
name,
|
|
@@ -459,6 +529,7 @@ const CATALOG_CODEC = {
|
|
|
459
529
|
component,
|
|
460
530
|
vector: new Map(vector),
|
|
461
531
|
projected: Float64Array.from(projected),
|
|
532
|
+
words: new Map(words),
|
|
462
533
|
},
|
|
463
534
|
],
|
|
464
535
|
),
|
|
@@ -540,10 +611,22 @@ export function pickBlocks(request, signals, weights, keep) {
|
|
|
540
611
|
if (own.length === 0) return {names: [], entries};
|
|
541
612
|
const cat = readCatalog(signals.catalog, signals.components, weights, keep);
|
|
542
613
|
const side = requestSideOf(request, weights);
|
|
614
|
+
const words = wordVectorOf(
|
|
615
|
+
termsOf(request),
|
|
616
|
+
vocabularyOf(weights),
|
|
617
|
+
docWordsOf(cat),
|
|
618
|
+
);
|
|
543
619
|
/** @type {Map<string, {match: number, overlap: number}>} */
|
|
544
620
|
const scored = new Map();
|
|
545
621
|
for (const [name, b] of cat.blocks)
|
|
546
|
-
scored.set(
|
|
622
|
+
scored.set(
|
|
623
|
+
name,
|
|
624
|
+
matchOf(
|
|
625
|
+
{vector: words, projected: side.projected},
|
|
626
|
+
{vector: b.words, projected: b.projected},
|
|
627
|
+
weights,
|
|
628
|
+
),
|
|
629
|
+
);
|
|
547
630
|
const get = (/** @type {string} */ b) =>
|
|
548
631
|
scored.get(b) ?? {match: -Infinity, overlap: 0};
|
|
549
632
|
const ranked = [...scored.keys()].sort((a, b) => get(b).match - get(a).match);
|
|
@@ -593,8 +676,8 @@ export function pickBlocks(request, signals, weights, keep) {
|
|
|
593
676
|
});
|
|
594
677
|
final.sort((a, b) => b.score - a.score || a.pos - b.pos);
|
|
595
678
|
const foreign = new Set(signals.foreign);
|
|
596
|
-
const
|
|
597
|
-
const keeps = own.map(b => foreign.has(b) || writesName(
|
|
679
|
+
const requestWords = wordsOf(request);
|
|
680
|
+
const keeps = own.map(b => foreign.has(b) || writesName(requestWords, b));
|
|
598
681
|
const kept = new Set(own.filter((_, k) => keeps[k]));
|
|
599
682
|
const order = [
|
|
600
683
|
...final.map(x => x.b).filter(b => !kept.has(b) && !foreign.has(b)),
|
|
@@ -626,7 +709,7 @@ export function pickBlocks(request, signals, weights, keep) {
|
|
|
626
709
|
name,
|
|
627
710
|
package: block.package ?? '',
|
|
628
711
|
score: Math.max(1, Math.round(100 * Math.exp(x.score - max))),
|
|
629
|
-
reason: reasonFor(request, side, cat.blocks.get(name), weights),
|
|
712
|
+
reason: reasonFor(request, side, words, cat.blocks.get(name), weights),
|
|
630
713
|
description: block.description ?? '',
|
|
631
714
|
displayName: block.displayName,
|
|
632
715
|
kind: 'block',
|
|
@@ -640,10 +723,11 @@ export function pickBlocks(request, signals, weights, keep) {
|
|
|
640
723
|
* Why a block fits: the request words that tie it to its docs most.
|
|
641
724
|
* @param {string} request
|
|
642
725
|
* @param {{vector: Map<number, number>, projected: Float64Array}} side the request's side
|
|
643
|
-
* @param {
|
|
726
|
+
* @param {Map<string, number>} words the request's word vector for the plain overlap
|
|
727
|
+
* @param {{projected: Float64Array, words: Map<string, number>} | undefined} block
|
|
644
728
|
* @param {BlockPickerWeights} weights
|
|
645
729
|
*/
|
|
646
|
-
function reasonFor(request, side, block, weights) {
|
|
730
|
+
function reasonFor(request, side, words, block, weights) {
|
|
647
731
|
if (!block) return 'fits by meaning';
|
|
648
732
|
const raw =
|
|
649
733
|
String(request)
|
|
@@ -653,17 +737,20 @@ function reasonFor(request, side, block, weights) {
|
|
|
653
737
|
const wordOf = new Map();
|
|
654
738
|
for (const w of raw)
|
|
655
739
|
if (!STOP.has(w) && !wordOf.has(stemOf(w))) wordOf.set(stemOf(w), w);
|
|
740
|
+
const {index} = vocabularyOf(weights);
|
|
656
741
|
/** @type {[string, number][]} */
|
|
657
742
|
const parts = [];
|
|
658
|
-
for (const [
|
|
659
|
-
const term = weights.vocab[i];
|
|
743
|
+
for (const [term, x] of words) {
|
|
660
744
|
if (term.includes('_')) continue;
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
745
|
+
let s = weights.lexical * x * (block.words.get(term) ?? 0);
|
|
746
|
+
const i = index.get(term);
|
|
747
|
+
const v = i === undefined ? undefined : side.vector.get(i);
|
|
748
|
+
if (i !== undefined && v !== undefined) {
|
|
749
|
+
const row = rowOf(weights, 'request', i);
|
|
750
|
+
let dot = 0;
|
|
751
|
+
for (let k = 0; k < weights.dims; k++) dot += row[k] * block.projected[k];
|
|
752
|
+
s += v * dot * weights.requestScale;
|
|
753
|
+
}
|
|
667
754
|
if (s > 0) parts.push([wordOf.get(term) ?? term, s]);
|
|
668
755
|
}
|
|
669
756
|
parts.sort((a, b) => b[1] - a[1]);
|
package/api/build/build.doc.mjs
CHANGED
|
@@ -19,8 +19,9 @@ export const doc = {
|
|
|
19
19
|
'The "build a page" entry point. Called with no query it returns the ' +
|
|
20
20
|
'how-to-build-a-page playbook as data: the workflow steps with their ' +
|
|
21
21
|
'commands, the on-system rules, and related lookups. Called with a query it names the page template to ' +
|
|
22
|
-
|
|
23
|
-
'of a page, the page it names; else the app shell
|
|
22
|
+
"START from (always one: for a whole page, the template its page-pick model chooses from the page ranker's list and its own word tables, or the app shell when its word weights call the shell; for a part " +
|
|
23
|
+
'of a page, the page it names; else the app shell, unless the idea reads as a whole page, which starts ' +
|
|
24
|
+
'from the closest page template) and the next two templates, ' +
|
|
24
25
|
'and the unified search grouped around it: the other close page templates, drop-in blocks, and ' +
|
|
25
26
|
'idea-specific components/hooks, plus the always-on frame + foundation. A template carries the page ' +
|
|
26
27
|
'frame and spacing, so the kit never recommends composing a page from components.',
|
|
@@ -64,7 +65,7 @@ export const doc = {
|
|
|
64
65
|
{
|
|
65
66
|
type: 'build.kit',
|
|
66
67
|
description:
|
|
67
|
-
|
|
68
|
+
'The page template to start from and the kit around it: the echoed query, hasResults/matchCount/directMatch fields, `start` (the template to scaffold, the `template <id> --type page <path>` command that selects it, whether the start is also search\'s direct match, the closest page, or the fallback app shell, the next two `alternatives` in the order the start is chosen from, and optional `notes` — setup notes naming what the template needs that the project lacks, such as missing packages or a missing StyleX compiler), search\'s closest page templates (≤3), drop-in block patterns (≤5), idea-specific components/hooks (≤6), and the always-on frame + foundation component-name arrays. Carries `hint` only when the kit came back thin — what to try instead, so a caller does not read a near-empty kit as "the package has nothing".',
|
|
68
69
|
},
|
|
69
70
|
],
|
|
70
71
|
throws: [
|
|
@@ -69,7 +69,7 @@ export type BuildStart = {
|
|
|
69
69
|
*/
|
|
70
70
|
command: string;
|
|
71
71
|
/**
|
|
72
|
-
* Why this template. The page ranker
|
|
72
|
+
* Why this template. The page ranker orders the page templates: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. For a part or an edit, the start is where the ranker's placement rules put it; for a whole page, checked-in word weights decide page or app shell and a page-pick model chooses the page from the ranker's list and its own word tables, so the start can differ from the ranker's first template. `direct` when the start is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when the page starts from the app shell.
|
|
73
73
|
*/
|
|
74
74
|
basis: "direct" | "closest" | "fallback";
|
|
75
75
|
/**
|
|
@@ -77,7 +77,7 @@ export type BuildStart = {
|
|
|
77
77
|
*/
|
|
78
78
|
reason: string;
|
|
79
79
|
/**
|
|
80
|
-
* The
|
|
80
|
+
* The next closest page templates (≤2), for when the start's layout is wrong: for a whole page in the page-pick model's order, else in the ranker's.
|
|
81
81
|
*/
|
|
82
82
|
alternatives: BuildAlternative[];
|
|
83
83
|
/**
|
package/api/build/build.type.mjs
CHANGED
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
* @property {string} description What the page is: its layout and the ideas it serves.
|
|
45
45
|
* @property {string} package The npm package that owns this template.
|
|
46
46
|
* @property {string} command The scaffold command that selects exactly this template, `astryx template <id> --type page <path>`: `<id>` is the Core id an integration replacement stands in for, else the template's own id, `<path>` is a placeholder for the file or folder to write the template to, and the `astryx` prefix is for the caller to replace with its own invocation.
|
|
47
|
-
* @property {'direct' | 'closest' | 'fallback'} basis Why this template. The page ranker
|
|
47
|
+
* @property {'direct' | 'closest' | 'fallback'} basis Why this template. The page ranker orders the page templates: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. For a part or an edit, the start is where the ranker's placement rules put it; for a whole page, checked-in word weights decide page or app shell and a page-pick model chooses the page from the ranker's list and its own word tables, so the start can differ from the ranker's first template. `direct` when the start is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when the page starts from the app shell.
|
|
48
48
|
* @property {string} reason One sentence saying the same as `basis`, for a reader.
|
|
49
|
-
* @property {BuildAlternative[]} alternatives The
|
|
49
|
+
* @property {BuildAlternative[]} alternatives The next closest page templates (≤2), for when the start's layout is wrong: for a whole page in the page-pick model's order, else in the ranker's.
|
|
50
50
|
* @property {string[]} [notes] Setup notes: what the template needs that the project lacks (missing packages, missing StyleX compiler). Present only when the start template imports packages the project does not have or needs a StyleX compiler the project has not configured.
|
|
51
51
|
*/
|
|
52
52
|
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
* @property {boolean} data.hasResults False when search returned nothing. The kit still names a template in `start`.
|
|
76
76
|
* @property {number} data.matchCount Total ranked search matches for the query — counted before the search `limit`, the kit's score floors, and its per-group caps, so it is never a cap read back.
|
|
77
77
|
* @property {boolean} data.directMatch True when the top page template is a confident direct match.
|
|
78
|
-
* @property {BuildStart | null} data.start The page template to start from
|
|
78
|
+
* @property {BuildStart | null} data.start The page template to start from (see `BuildStart.basis`), else the app shell. Null only when the kit is narrowed to components or hooks (`type`), or when the project has no page template to offer.
|
|
79
79
|
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.pages Closest page templates by search (≤3). Each entry's `command` carries `--skeleton` when `directMatch` is false, so it previews the layout; `start.command` is the scaffold.
|
|
80
80
|
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.blocks Drop-in block patterns covering parts of the idea (≤5), best first. A block search returned keeps search's score and reason; any other block carries the block picker's relative score (100 for its best candidate, never below 1) and reason, so the two kinds of score are not comparable.
|
|
81
81
|
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.domain Idea-specific components/hooks (≤6), excluding frame/foundation.
|
package/api/build/kit/kind.d.mts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* What an idea asks for (spec:AST-048/FR3): a whole `page`; a `part` of one,
|
|
6
6
|
* when its head noun names one of the system's components and it lists fewer
|
|
7
|
-
* than PAGE_PIECES pieces; or an `edit` of a
|
|
7
|
+
* than PAGE_PIECES pieces or only that component's contents; or an `edit` of a
|
|
8
|
+
* page the builder already has.
|
|
8
9
|
*
|
|
9
10
|
* @param {string} query
|
|
10
11
|
* @param {PageTemplate[]} pages
|