@astryxdesign/cli 0.6.5-vanilla-poc.6e25cfc → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +84 -0
- package/README.md +1 -34
- package/api/build/_adapter.d.mts +14 -0
- package/api/build/_adapter.mjs +58 -1
- package/api/build/build.test.mjs +74 -1
- package/api/build/kit/kit.mjs +39 -7
- package/api/build/kit/rank.d.mts +8 -0
- package/api/build/kit/rank.mjs +14 -0
- package/api/build/kit/weights.d.mts +82 -0
- package/api/build/kit/weights.json +1 -0
- package/api/build/kit/weights.mjs +305 -0
- package/api/build/kit/weights.test.mjs +190 -0
- package/api/component/_adapter.d.mts +1 -51
- package/api/component/_adapter.mjs +3 -110
- package/api/component/component.d.mts +1 -9
- package/api/component/component.doc.mjs +7 -52
- package/api/component/component.mjs +3 -276
- package/api/component/component.type.d.mts +1 -28
- package/api/component/component.type.mjs +1 -20
- package/api/docs/docs.d.mts +6 -0
- package/api/docs/docs.depth.test.mjs +132 -0
- package/api/docs/docs.doc.mjs +31 -2
- package/api/docs/docs.mjs +44 -1
- package/api/docs/docs.type.d.mts +38 -1
- package/api/docs/docs.type.mjs +18 -1
- package/api/docs/node/node.d.mts +28 -3
- package/api/docs/node/node.mjs +146 -23
- package/api/hook/list/list.d.mts +1 -1
- package/api/index.d.mts +0 -8
- package/api/index.mjs +0 -8
- package/api/integration/add-theme.mjs +93 -3
- package/api/integration/add-theme.test.mjs +100 -0
- package/api/integration/integrationAddTheme.doc.mjs +1 -1
- package/api/search/search.d.mts +8 -1
- package/api/search/search.doc.mjs +3 -3
- package/api/search/search.mjs +58 -73
- package/api/search/search.test.mjs +122 -21
- package/api/search/search.type.d.mts +0 -10
- package/api/search/search.type.mjs +0 -1
- package/api/template/cdn/cdn.test.mjs +2 -50
- package/api/template/template.d.mts +0 -6
- package/api/template/template.doc.mjs +4 -56
- package/api/template/template.mjs +0 -82
- package/api/template/template.type.d.mts +0 -12
- package/api/template/template.type.mjs +0 -7
- package/assets/cdn.template.html +5 -19
- package/assets/docs/tokens.doc.mjs +3 -3
- package/assets/docs/tree/add-a-theme.doc.mjs +4 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +4 -4
- package/clients/cli/commands/component/index.mjs +9 -66
- package/clients/cli/commands/component.doc.mjs +4 -26
- package/clients/cli/commands/docs.depth.test.mjs +219 -0
- package/clients/cli/commands/docs.doc.mjs +15 -2
- package/clients/cli/commands/docs.mjs +222 -5
- package/clients/cli/commands/integration-add.doc.mjs +1 -1
- package/clients/cli/commands/search.doc.mjs +2 -3
- package/clients/cli/commands/search.mjs +11 -8
- package/clients/cli/commands/search.test.mjs +35 -40
- package/clients/cli/commands/template.doc.mjs +3 -31
- package/clients/cli/commands/template.mjs +2 -37
- package/foundation/discovery/theme-discovery.d.mts +6 -0
- package/foundation/discovery/theme-discovery.mjs +9 -0
- package/foundation/response/response-types.doc.mjs +0 -38
- package/package.json +5 -9
- package/api/_vanilla-assets.d.mts +0 -10
- package/api/_vanilla-assets.mjs +0 -59
- package/api/component/html/html.d.mts +0 -12
- package/api/component/html/html.doc.d.mts +0 -5
- package/api/component/html/html.doc.mjs +0 -66
- package/api/component/html/html.mjs +0 -25
- package/api/component/html/html.test.mjs +0 -61
- package/api/component/html/html.type.d.mts +0 -23
- package/api/component/html/html.type.mjs +0 -27
- package/api/component/web-components/web-components.d.mts +0 -12
- package/api/component/web-components/web-components.doc.d.mts +0 -5
- package/api/component/web-components/web-components.doc.mjs +0 -70
- package/api/component/web-components/web-components.mjs +0 -32
- package/api/component/web-components/web-components.test.mjs +0 -50
- package/api/component/web-components/web-components.type.d.mts +0 -23
- package/api/component/web-components/web-components.type.mjs +0 -27
- package/api/template/_adapter.d.mts +0 -38
- package/api/template/_adapter.mjs +0 -90
- package/api/template/html/html.d.mts +0 -17
- package/api/template/html/html.doc.d.mts +0 -5
- package/api/template/html/html.doc.mjs +0 -72
- package/api/template/html/html.mjs +0 -61
- package/api/template/html/html.test.mjs +0 -71
- package/api/template/html/html.type.d.mts +0 -26
- package/api/template/html/html.type.mjs +0 -28
- package/api/template/web-components/web-components.d.mts +0 -13
- package/api/template/web-components/web-components.doc.d.mts +0 -5
- package/api/template/web-components/web-components.doc.mjs +0 -69
- package/api/template/web-components/web-components.mjs +0 -51
- package/api/template/web-components/web-components.test.mjs +0 -73
- package/api/template/web-components/web-components.type.d.mts +0 -26
- package/api/template/web-components/web-components.type.mjs +0 -28
- package/assets/generated/core-component-docs.json +0 -1
- package/assets/vanilla/elements-markup/Avatar.html +0 -27
- package/assets/vanilla/elements-markup/Badge.html +0 -16
- package/assets/vanilla/elements-markup/Banner.html +0 -32
- package/assets/vanilla/elements-markup/Breadcrumbs.html +0 -23
- package/assets/vanilla/elements-markup/Button.html +0 -37
- package/assets/vanilla/elements-markup/Card.html +0 -24
- package/assets/vanilla/elements-markup/CheckboxInput.html +0 -28
- package/assets/vanilla/elements-markup/Collapsible.html +0 -26
- package/assets/vanilla/elements-markup/DateInput.html +0 -28
- package/assets/vanilla/elements-markup/Dialog.html +0 -33
- package/assets/vanilla/elements-markup/Divider.html +0 -20
- package/assets/vanilla/elements-markup/DropdownMenu.html +0 -26
- package/assets/vanilla/elements-markup/EmptyState.html +0 -27
- package/assets/vanilla/elements-markup/Heading.html +0 -18
- package/assets/vanilla/elements-markup/HoverCard.html +0 -39
- package/assets/vanilla/elements-markup/Layout.html +0 -28
- package/assets/vanilla/elements-markup/Lightbox.html +0 -33
- package/assets/vanilla/elements-markup/Link.html +0 -23
- package/assets/vanilla/elements-markup/NumberInput.html +0 -34
- package/assets/vanilla/elements-markup/ProgressBar.html +0 -47
- package/assets/vanilla/elements-markup/RadioList.html +0 -28
- package/assets/vanilla/elements-markup/Selector.html +0 -34
- package/assets/vanilla/elements-markup/SideNav.html +0 -32
- package/assets/vanilla/elements-markup/Skeleton.html +0 -18
- package/assets/vanilla/elements-markup/Slider.html +0 -31
- package/assets/vanilla/elements-markup/Stack.html +0 -33
- package/assets/vanilla/elements-markup/StatusDot.html +0 -19
- package/assets/vanilla/elements-markup/Switch.html +0 -28
- package/assets/vanilla/elements-markup/Tab.html +0 -18
- package/assets/vanilla/elements-markup/TabList.html +0 -31
- package/assets/vanilla/elements-markup/Table.html +0 -31
- package/assets/vanilla/elements-markup/Text.html +0 -24
- package/assets/vanilla/elements-markup/TextArea.html +0 -32
- package/assets/vanilla/elements-markup/TextInput.html +0 -92
- package/assets/vanilla/elements-markup/Theme.html +0 -16
- package/assets/vanilla/elements-markup/TimeInput.html +0 -29
- package/assets/vanilla/elements-markup/Toast.html +0 -22
- package/assets/vanilla/elements-markup/Tooltip.html +0 -30
- package/assets/vanilla/elements-markup/TopNav.html +0 -85
- package/assets/vanilla/elements-markup/Typeahead.html +0 -31
- package/assets/vanilla/elements-templates/dashboard.html +0 -167
- package/assets/vanilla/elements-templates/detail-page.html +0 -145
- package/assets/vanilla/elements-templates/form-two-column.html +0 -135
- package/assets/vanilla/elements-templates/kanban-board.html +0 -141
- package/assets/vanilla/elements-templates/login.html +0 -100
- package/assets/vanilla/elements-templates/product-detail.html +0 -128
- package/assets/vanilla/elements-templates/settings.html +0 -130
- package/assets/vanilla/elements-templates/shell-side-nav.html +0 -160
- package/assets/vanilla/elements-templates/table-filter.html +0 -154
- package/assets/vanilla/markup/Avatar.html +0 -24
- package/assets/vanilla/markup/Badge.html +0 -12
- package/assets/vanilla/markup/Banner.html +0 -49
- package/assets/vanilla/markup/Breadcrumbs.html +0 -38
- package/assets/vanilla/markup/Button.html +0 -37
- package/assets/vanilla/markup/Card.html +0 -16
- package/assets/vanilla/markup/CheckboxInput.html +0 -45
- package/assets/vanilla/markup/Collapsible.html +0 -9
- package/assets/vanilla/markup/DateInput.html +0 -42
- package/assets/vanilla/markup/Dialog.html +0 -45
- package/assets/vanilla/markup/Divider.html +0 -9
- package/assets/vanilla/markup/DropdownMenu.html +0 -30
- package/assets/vanilla/markup/EmptyState.html +0 -41
- package/assets/vanilla/markup/Heading.html +0 -9
- package/assets/vanilla/markup/HoverCard.html +0 -85
- package/assets/vanilla/markup/Layout.html +0 -35
- package/assets/vanilla/markup/Lightbox.html +0 -107
- package/assets/vanilla/markup/Link.html +0 -6
- package/assets/vanilla/markup/NumberInput.html +0 -55
- package/assets/vanilla/markup/ProgressBar.html +0 -101
- package/assets/vanilla/markup/RadioList.html +0 -90
- package/assets/vanilla/markup/Selector.html +0 -92
- package/assets/vanilla/markup/SideNav.html +0 -82
- package/assets/vanilla/markup/Skeleton.html +0 -26
- package/assets/vanilla/markup/Slider.html +0 -65
- package/assets/vanilla/markup/Stack.html +0 -13
- package/assets/vanilla/markup/StatusDot.html +0 -22
- package/assets/vanilla/markup/Switch.html +0 -47
- package/assets/vanilla/markup/TabList.html +0 -56
- package/assets/vanilla/markup/Table.html +0 -75
- package/assets/vanilla/markup/Text.html +0 -9
- package/assets/vanilla/markup/TextArea.html +0 -37
- package/assets/vanilla/markup/TextInput.html +0 -80
- package/assets/vanilla/markup/Theme.html +0 -48
- package/assets/vanilla/markup/TimeInput.html +0 -43
- package/assets/vanilla/markup/Toast.html +0 -42
- package/assets/vanilla/markup/Tooltip.html +0 -18
- package/assets/vanilla/markup/TopNav.html +0 -81
- package/assets/vanilla/markup/Typeahead.html +0 -60
- package/assets/vanilla/templates/dashboard.html +0 -462
- package/assets/vanilla/templates/detail-page.html +0 -536
- package/assets/vanilla/templates/form-two-column.html +0 -438
- package/assets/vanilla/templates/kanban-board.html +0 -443
- package/assets/vanilla/templates/login.html +0 -199
- package/assets/vanilla/templates/product-detail.html +0 -335
- package/assets/vanilla/templates/settings.html +0 -374
- package/assets/vanilla/templates/shell-side-nav.html +0 -440
- package/assets/vanilla/templates/table-filter.html +0 -514
- package/clients/cli/commands/vanilla-html.test.mjs +0 -245
- package/foundation/discovery/bundled-component-docs.d.mts +0 -39
- package/foundation/discovery/bundled-component-docs.mjs +0 -92
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
1
|
# @xds/cli
|
|
2
2
|
|
|
3
|
+
# 0.6.6
|
|
4
|
+
|
|
5
|
+
#### New Features
|
|
6
|
+
|
|
7
|
+
- Add a shared `upload` icon, and use it for FileInput's upload affordance instead of the directional `arrowUp`
|
|
8
|
+
Themes draw `upload` through `icons.upload`, separately from `arrowUp`, so sort arrows and every other `arrowUp` use stay unchanged. Every bundled theme and theme template draws `upload` in its own icon style. FileInput keeps its icon size, placement, color, and accessibility in both modes; a theme with no `upload` artwork shows the default upload-into-tray glyph there.
|
|
9
|
+
|
|
10
|
+
A complete `IconRegistry` may still omit `upload` in this release. The next minor makes it required, so add an `upload` entry to any registry you type as `IconRegistry`.
|
|
11
|
+
|
|
12
|
+
- Templates declare their `keywords`, and `build` tells a part of a page from a page by the components the project can use (#6805)
|
|
13
|
+
- `build` chooses where to start with a checked-in table of word weights blended with the page ranker
|
|
14
|
+
- `astryx docs <route> --depth <levels>` reads as far down the docs tree as you ask, from one doc to everything below it.
|
|
15
|
+
`--depth 0` reads only the namespace you name, `--depth 1` adds the docs right below it (what a read without `--depth` shows), and `--depth all` goes to the bottom. With `--depth`, `--detail` sets how much of each doc below shows: `brief` (the default) is one line each, named by where it sits so you can open it, `compact` adds its sections, and `full` prints it whole. So `astryx docs cli --depth all` is a map of every CLI doc, and `astryx docs cli/integrations --depth all --detail full` prints the integration guides as one read. Where a read stops, a namespace says how many docs sit below it. `--json` returns the same tree as `docs.node`: each child carries its own `slots` while the read goes deeper, `childCount` where it stops, and its text at `compact` or `full`. `docs()` takes the same `depth` and `detail` options. Reads without `--depth` are unchanged.
|
|
16
|
+
- Point at `discover` where people look for things to add
|
|
17
|
+
Nothing an agent reads named `discover`, so agents asked to find a theme searched the package registry instead. The agent block `astryx init` writes now lists `discover <words>` (integrations you could add, and the ones you have), `theme list` ends with `More themes in packages you could add: astryx discover theme`, and a text search ends with `More in packages you could add: astryx discover <query>` (except `--type hook`, since no integration adds hooks). JSON output is unchanged.
|
|
18
|
+
- `integration add theme --from <base>` forks an existing theme as the starting point instead of a blank scaffold. The new theme copies the base's source files — renamed and rewritten for the new slug — with no link back. Use `--from` when you want to change a lot; for a small change that stays linked, use `extends` in `defineTheme`.
|
|
19
|
+
|
|
20
|
+
#### Fixes
|
|
21
|
+
|
|
22
|
+
- Say when a command did nothing: `upgrade` reports `sourcePathFound`, the integration checks report `validated`.
|
|
23
|
+
Two commands could legitimately do nothing and produce an envelope identical to a clean success. Both now carry the fact in a field of their own response instead of only in human text.
|
|
24
|
+
|
|
25
|
+
`astryx upgrade` defaults `--path` to `./src`. A project laid out as `app/` (or a typo) skipped every code codemod and still reported exit 0, `filesChanged: 0`, `errors: []` and "Upgrade complete". The only warning was a log line `--json` suppresses by design. `upgrade.run` now carries `sourcePathFound`, and the human completion line names the directory it did not find.
|
|
26
|
+
|
|
27
|
+
`astryx doctor integration validate|components|docs|templates` returned `{name: null, version: null, issues: []}` and exit 0 when no integration manifest was found — the same shape as a validated, healthy integration. All four envelopes now carry `validated`, false only when nothing was inspected.
|
|
28
|
+
|
|
29
|
+
- `astryx manifest --json` now takes each command's examples from its CommandDoc and its response types from the API function it wraps, so no example differs from the documented one and `upgrade` lists `upgrade.registry`, which `upgrade --registry --json` already emits.
|
|
30
|
+
- `astryx template <name> <path>` and `astryx layout expand` now say when they replaced Astryx demo media. The `template.copy` and `layout.expand` receipts carry `demoMediaReplaced`, the number of demo image and video references that became placeholders (one per reference, however many fixture paths its URL carries), and the text output names the file to update (when `layout expand` prints the code instead, the same line follows it as a comment, so the output is still valid TSX). Nothing about the copy itself changed.
|
|
31
|
+
- `astryx template <name>` and `template()` now return the same source that `astryx template <name> <path>` writes, and say how many Astryx demo media references they replaced. Demo images and videos that only Astryx's own previews serve are replaced the same way in both, so code copied from the printed source no longer points at media your project doesn't have. `template.show` gains `demoMediaReplaced` (0 when the template carried none); in text mode the count is stated on stderr so the printed source stays exact.
|
|
32
|
+
- A write that fails reports ERR_WRITE_FAILED instead of a raw Node errno.
|
|
33
|
+
`astryx template` into an unwritable directory returned `{"error": "EACCES: permission denied, open '/home/you/project/readonly/x.tsx'", "code": "ERR_UNKNOWN"}`, and `swizzle` returned the `mkdir` equivalent. Two things were wrong: ERR_WRITE_FAILED is already in the frozen error registry for exactly this case, and the message carried an absolute host path where every other Astryx message names its target relative to the project.
|
|
34
|
+
|
|
35
|
+
Both now throw ERR_WRITE_FAILED with the errno kept (it is the part that says what to fix) and the target named relative to the project. Nothing is left half-written: a `swizzle` that fails part-way removes the files it already copied and puts back any it replaced before it reports the error, and the message names any file it could not restore.
|
|
36
|
+
|
|
37
|
+
- When `discover --available` runs without a discover source, the CLI now
|
|
38
|
+
explains what discover sources are and where to find Astryx packages on npm, instead of the misleading message that told users to add package names they had no way to find. The base `discover` with no integrations also gains a pointer to npm and the integrations docs.
|
|
39
|
+
- A package with a namespace doc or a placed guide needs `@astryxdesign/cli` 0.6.4, not 0.7.0.
|
|
40
|
+
Published 0.6.4 reads an integration's docs tree: it lists the namespace and reads each guide placed in it. 0.6.3 rejects a namespace doc and hides every doc topic the package ships. `integration add doc --parent` wrote `"@astryxdesign/cli": ">=0.7.0"`, a range no released CLI satisfies, and `integration verify` failed a docs-tree package whose CLI peer started at 0.6.4. `integration add doc --parent` now writes `">=0.6.4"`, marked optional, and `integration verify` accepts it. A template that sets `replaces` or `keywords` still needs `">=0.7.0"`.
|
|
41
|
+
- `gap-report` fails when a listed integration cannot load, instead of reporting a clean result.
|
|
42
|
+
An integration whose `astryx.integration` module throws on import or fails validation was left out of the handler set. With no other handler, the report fell through to the built-in GitHub fallback for Core: the command exited 0 with `consent_required`, printed nothing on stderr, and offered `--confirm-public` to file on Core's public tracker a report the integration might have been meant to receive.
|
|
43
|
+
|
|
44
|
+
The unloadable integration now records a failed delivery in its config position, with the load error and the fix in its message. Like any handler, it turns the fallback off, so the report never goes to another package's tracker. The command exits 1, and a failed or partial report now prints each failed delivery on stderr as well as in the receipt.
|
|
45
|
+
|
|
46
|
+
- `astryx integration add theme <name> --from <base>` now adds the packages the copied theme files import to `dependencies`.
|
|
47
|
+
A fork of a bundled theme such as `neutral` copies its `icons.tsx`, which imports `lucide-react`, but the package did not declare it. So `astryx theme build` on the fork failed with "Cannot find module 'lucide-react'", and an app that installed the package hit the same error. `--from` now adds each package the copied files import, at the range the bundled themes use. It leaves out Core and React, which every Astryx app already has, and anything the package already declares.
|
|
48
|
+
- `astryx integration pack` without `--check` now points only at `astryx integration verify`.
|
|
49
|
+
It used to say "Pass --check to verify the integration tarball, or run `astryx integration verify`", which sent people to the deprecated spelling. It now says that `integration pack` is now `integration verify`, and that `npm pack` builds the tarball. The error code and exit code are unchanged, and `integration pack --check` still runs the same check as before.
|
|
50
|
+
- Search: differentiate all-word matches by total quality; index themes
|
|
51
|
+
Within the all-words tier, every candidate whose strongest token hit was a keyword scored the same (e.g. 157), regardless of how the other query words matched. A doc matching both words by keyword outranked nothing, and `search "how to use a theme"` put API reference docs above the consumer theme guide.
|
|
52
|
+
|
|
53
|
+
The bonus now uses the sum of ALL token scores instead of just the strongest, so a candidate matching every word by keyword outranks one matching keyword + prose. The `theme` doc also gains consumer-facing keywords so it surfaces for questions like "how to use a theme" and "how to apply a theme".
|
|
54
|
+
|
|
55
|
+
Themes are now a search domain: bundled and integration-provided themes appear in results with their slug, displayName, package, and the `astryx theme add` command. `--type theme` filters to them. Like `--type doc`, it works outside an app, where an open search now covers the docs and themes. Search help, the manifest, and the API reference list the new domain and its result fields.
|
|
56
|
+
|
|
57
|
+
- Search ranks a theme's description as prose, not as keywords
|
|
58
|
+
A word a theme shares with your query only through its description, such as `minimal`, `focus` or `content`, now ranks the theme like any other description instead of like a declared keyword, so it no longer lands above the components, hooks and docs that declare that word. A theme still comes first for its own slug or display name: `astryx search neutral` finds the Neutral theme first.
|
|
59
|
+
- A package that ships a theme or a doc section `id` needs `@astryxdesign/cli` 0.6.4, not 0.7.0.
|
|
60
|
+
Published 0.6.4 reads typed theme descriptors and section ids; 0.6.3 rejects both and hides the package's themes or doc topics. The 0.6.5 notes said a stable CLI before 0.7.0 rejects them, so `integration add theme` wrote `"@astryxdesign/cli": ">=0.7.0"`, a range no released CLI satisfies, and `integration verify` failed a theme or section-id package whose CLI peer started at 0.6.4. `integration add theme` now writes `">=0.6.4"`, marked optional, and `integration verify` accepts it for themes and section ids. A template that sets `replaces` or `keywords` still needs `">=0.7.0"`.
|
|
61
|
+
- `theme build` resolves real icon imports from the selected theme instead of matching comment or string contents. Generated modules preserve named, aliased, default, and namespace registry imports, plus inherited icons with child overrides. Normal builds and `--check` reject unsupported inline registries with `ERR_THEME_INVALID` before generating or writing output. Move such a registry into its own module and import it into the theme file.
|
|
62
|
+
- `astryx theme build` in an app uses the app's installed `@astryxdesign/core`, and says to install Core when there is none.
|
|
63
|
+
Run one-off with `npx @astryxdesign/cli`, it failed with "Build @astryxdesign/core first (e.g. `pnpm -F @astryxdesign/core build`)" even when the app had Core installed, because it looked for Core only next to the CLI. It now generates with the Core the project installed, the same Core the app's `<Theme>` runs on. In an app without Core, the error now says to install it (`npm install @astryxdesign/core`). The build command stays only for the Astryx repository itself. The error code (`ERR_CORE_NOT_FOUND`) is unchanged.
|
|
64
|
+
|
|
65
|
+
#### Other Changes
|
|
66
|
+
|
|
67
|
+
- `TemplateDoc` gains an optional `keywords` list: the ideas, domains, and other names a builder might use for what the template serves. `parseTemplate` validates it, discovery carries it from every template source, `astryx search` matches it as it matches a template's description, and `astryx build` ranks page templates on it. Each Core page template's closing list of ideas moved out of its `description` into `keywords`, so descriptions describe the layout.
|
|
68
|
+
- `build` starts a part of a page where it lives (`spec:AST-048` FR3), and the project's own components say what a part is: an idea whose head noun is a word of a component's name or keywords, Core's or an integration's, asks for a part, unless the noun names a family of page templates or the idea lists three or more pieces. A part starts from the base template of the family the idea names, else from the app shell; a change to an existing page or part (an idea whose "existing" names a page family or a component, such as "the existing table", and that does not ask for a new page) starts from the app shell. The start's reason says which case applies and why.
|
|
69
|
+
- A family's base template leads its family unless a variant matches two terms of its own; a base that cannot start on its own never displaces the variant that leads.
|
|
70
|
+
|
|
71
|
+
Integration templates that set `keywords` need `@astryxdesign/cli` 0.7.0 or later. The template metadata object is strict, so a stable CLI before 0.7.0 rejects the field, drops that template, and hides the package's doc topics; only `template --list` and `search` print a warning. `integration verify` fails a package whose template sets `keywords` until it declares `@astryxdesign/cli >=0.7.0`, as it does for `replaces`.
|
|
72
|
+
|
|
73
|
+
- `api/build/kit/weights.mjs` scores each candidate start (the app shell and every ready page template) from the idea's stemmed words using the tables in `weights.json`, and blends those scores with the ranker's own. The blend decides the start of every whole page; a part or an edit starts where it did before, and the ranker's pick of a template the tables do not list stands. Without a weights file the ranker's pick stands. The response's shape is unchanged.
|
|
74
|
+
|
|
75
|
+
#### Contributors
|
|
76
|
+
|
|
77
|
+
Thanks to everyone who contributed to this release:
|
|
78
|
+
|
|
79
|
+
- @AstryxBot
|
|
80
|
+
- @cixzhang
|
|
81
|
+
- @jiunshinn
|
|
82
|
+
- @josephfarina
|
|
83
|
+
- @rubyycheung
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
3
87
|
# 0.6.5
|
|
4
88
|
|
|
5
89
|
#### New Features
|
package/README.md
CHANGED
|
@@ -15,31 +15,6 @@ npx @astryxdesign/cli template --list
|
|
|
15
15
|
|
|
16
16
|
Once it's a project dependency (`npm install -D @astryxdesign/cli`), drop the scope and use the shorter `astryx` — e.g. `npx astryx component Button` or `pnpm exec astryx component Button`. Bare `astryx` resolves to an unrelated npm package until the CLI is installed, so prefer the scoped form above for first-run/one-off use.
|
|
17
17
|
|
|
18
|
-
## Install the preview CLI
|
|
19
|
-
|
|
20
|
-
Install the self-contained vanilla HTML preview from its immutable commit:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install -g https://cdn.jsdelivr.net/gh/facebook/astryx@9bd9b20ef7dd4c91d72e7e0d0bbe03b48750dccb/packages/vanilla/dist/cli/astryx-cli-vanilla.tgz
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
The preview package is `@astryxdesign/cli@0.6.5-vanilla.3eb9597f5`; it is not published to npm.
|
|
27
|
-
|
|
28
|
-
## Choosing a framework
|
|
29
|
-
|
|
30
|
-
`component` and `template` default to the React catalog. Use `--framework html`
|
|
31
|
-
for the no-build vanilla markup, or `--framework web-components` for the
|
|
32
|
-
custom-element markup. Both alternatives support named reads and `--list`:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
astryx component Button --framework html
|
|
36
|
-
astryx component Button --framework web-components
|
|
37
|
-
astryx template dashboard --framework html
|
|
38
|
-
astryx template dashboard --framework web-components
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`--html` remains a deprecated alias for `--framework html`.
|
|
42
|
-
|
|
43
18
|
## Reading the CLI's own docs
|
|
44
19
|
|
|
45
20
|
The CLI documents itself, so these commands print what the installed version does:
|
|
@@ -118,7 +93,7 @@ Options:
|
|
|
118
93
|
| `layout` | Generate XDS layouts from compressed expressions (XLE/XLO) |
|
|
119
94
|
| `search` | Search components, hooks, docs, templates, and themes in one ranked list |
|
|
120
95
|
| `swizzle` | Copy component source for customization |
|
|
121
|
-
| `template` | List, show,
|
|
96
|
+
| `template` | List, show, or scaffold page and block templates |
|
|
122
97
|
| `theme` | Create and build themes: add a shipped one, compile to CSS, or list what a theme can override |
|
|
123
98
|
| `upgrade` | Update your code after upgrading Astryx, and refresh ShadCN-copied components |
|
|
124
99
|
|
|
@@ -456,10 +431,6 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
456
431
|
| `component.detail.source` | One component's source file, as {component, source}. |
|
|
457
432
|
| `component.detail.showcase` | One component's showcase example, as {component, aspectRatio, source}. |
|
|
458
433
|
| `component.detail.blocks` | One component's example blocks, as {component, showcase, examples, related} of BlockEntry. |
|
|
459
|
-
| `component.html.list` | The sorted packages/vanilla/markup files as {name, file}. |
|
|
460
|
-
| `component.html` | One vanilla component markup file as {component, file, source}, preserving docs and variant comments verbatim. |
|
|
461
|
-
| `component.web-components.list` | The sorted packages/vanilla/elements-markup files as {name, file}. |
|
|
462
|
-
| `component.web-components` | One vanilla web-component markup file as {component, file, source}, preserving generated docs and variant comments verbatim. |
|
|
463
434
|
| `docs.list` | All reference-doc topics as DocsListEntry[] ({topic, description, package, replaces?}), in read order; meta.namespaces lists the docs tree's top-level namespaces, and meta.notLoaded each package whose docs did not load. |
|
|
464
435
|
| `docs.detail` | One topic's full ReferenceDoc (the JSON read of a topic, --full, --dense, or a topic with one section), with token-ref blocks inlined, plus links ({up, previous, next}: the commands that open the level it sits in and its neighbors there). |
|
|
465
436
|
| `docs.index` | One topic's section index, the text read of a topic with more than one section (and --index): the topic's name, title, and description, plus sections, each {id, title, summary} (pass the id as the section argument; summary is the section's one-line summary), and links ({up, previous, next}: the commands that open the level it sits in and its neighbors there). |
|
|
@@ -484,10 +455,6 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
484
455
|
| `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. |
|
|
485
456
|
| `template.copy` | A scaffold receipt: template id, output directory, written file name, file count, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media). |
|
|
486
457
|
| `template.cdn` | A write receipt for the no-build-step CDN starter page: the path (relative to cwd), the Astryx version every CDN URL was pinned to, whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |
|
|
487
|
-
| `template.html.list` | The sorted packages/vanilla/templates files as {id, file}. |
|
|
488
|
-
| `template.html` | One vanilla standalone page as {template, file, cdnRef, cdnBase, source}, with every CDN placeholder substituted. |
|
|
489
|
-
| `template.web-components.list` | The sorted packages/vanilla/elements-templates files as {id, file}. |
|
|
490
|
-
| `template.web-components` | One vanilla web-component page as {template, file, cdnRef, cdnBase, source}, with every CDN placeholder substituted. |
|
|
491
458
|
| `hook.list` | The hook catalog grouped by category: `detail` (the level: names \| compact \| full) and `components`, the grouped map of hook names, brief entries, or a full HookDoc per entry. |
|
|
492
459
|
| `hook.detail` | One hook's full authored HookDoc. |
|
|
493
460
|
| `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). |
|
package/api/build/_adapter.d.mts
CHANGED
|
@@ -40,6 +40,20 @@ export function loadPageTemplates(cwd: string): Promise<PageTemplate[]>;
|
|
|
40
40
|
* @returns {Promise<ComponentWords[]>}
|
|
41
41
|
*/
|
|
42
42
|
export function loadComponents(cwd: string): Promise<ComponentWords[]>;
|
|
43
|
+
/**
|
|
44
|
+
* The matcher weights checked in beside the kit (`kit/weights.json`), read
|
|
45
|
+
* once; null when the file is absent or unreadable.
|
|
46
|
+
* @returns {import('./kit/weights.mjs').WeightsFile | null}
|
|
47
|
+
*/
|
|
48
|
+
export function loadWeights(): import("./kit/weights.mjs").WeightsFile | null;
|
|
49
|
+
/**
|
|
50
|
+
* Whether a parsed weights file has the shape the kit reads: every row has a
|
|
51
|
+
* weight per candidate, every bias a number per candidate, and three blend
|
|
52
|
+
* numbers per member (the tables plus the ranker) and one for the shell.
|
|
53
|
+
* @param {any} file
|
|
54
|
+
* @returns {file is import('./kit/weights.mjs').WeightsFile}
|
|
55
|
+
*/
|
|
56
|
+
export function isWeightsFile(file: any): file is import("./kit/weights.mjs").WeightsFile;
|
|
43
57
|
/**
|
|
44
58
|
* A page template the kit can recommend starting from.
|
|
45
59
|
*/
|
package/api/build/_adapter.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file The build subject's environment access: the page templates a project
|
|
5
|
-
* can scaffold,
|
|
5
|
+
* can scaffold, the components it can use, and the checked-in matcher weights.
|
|
6
6
|
*
|
|
7
7
|
* @input Template and component discovery for `cwd` — the CLI's own templates
|
|
8
8
|
* and Core's components, plus any that the project's configured integrations
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* from the template subject's, components from search's.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import fs from 'node:fs';
|
|
20
|
+
|
|
19
21
|
import {discoverTemplates} from '../template/template.mjs';
|
|
20
22
|
import {componentKeywords} from '../search/search.mjs';
|
|
21
23
|
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
@@ -89,3 +91,58 @@ export async function loadComponents(cwd) {
|
|
|
89
91
|
return [];
|
|
90
92
|
}
|
|
91
93
|
}
|
|
94
|
+
|
|
95
|
+
/** @type {import('./kit/weights.mjs').WeightsFile | null | undefined} */
|
|
96
|
+
let weights;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The matcher weights checked in beside the kit (`kit/weights.json`), read
|
|
100
|
+
* once; null when the file is absent or unreadable.
|
|
101
|
+
* @returns {import('./kit/weights.mjs').WeightsFile | null}
|
|
102
|
+
*/
|
|
103
|
+
export function loadWeights() {
|
|
104
|
+
if (weights === undefined) {
|
|
105
|
+
try {
|
|
106
|
+
const file = JSON.parse(
|
|
107
|
+
fs.readFileSync(new URL('./kit/weights.json', import.meta.url), 'utf8'),
|
|
108
|
+
);
|
|
109
|
+
weights = isWeightsFile(file) ? file : null;
|
|
110
|
+
} catch {
|
|
111
|
+
weights = null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return weights ?? null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Whether a parsed weights file has the shape the kit reads: every row has a
|
|
119
|
+
* weight per candidate, every bias a number per candidate, and three blend
|
|
120
|
+
* numbers per member (the tables plus the ranker) and one for the shell.
|
|
121
|
+
* @param {any} file
|
|
122
|
+
* @returns {file is import('./kit/weights.mjs').WeightsFile}
|
|
123
|
+
*/
|
|
124
|
+
export function isWeightsFile(file) {
|
|
125
|
+
const n = Array.isArray(file?.candidates) ? file.candidates.length : 0;
|
|
126
|
+
return (
|
|
127
|
+
n > 0 &&
|
|
128
|
+
Array.isArray(file.tables) &&
|
|
129
|
+
file.tables.length > 0 &&
|
|
130
|
+
file.tables.every(
|
|
131
|
+
(/** @type {any} */ t) =>
|
|
132
|
+
Array.isArray(t?.words) &&
|
|
133
|
+
Array.isArray(t.rows) &&
|
|
134
|
+
t.rows.length === t.words.length &&
|
|
135
|
+
t.rows.every(
|
|
136
|
+
(/** @type {any} */ r) => typeof r === 'string' && r.length === n,
|
|
137
|
+
) &&
|
|
138
|
+
Array.isArray(t.bias) &&
|
|
139
|
+
t.bias.length === n &&
|
|
140
|
+
t.bias.every((/** @type {any} */ b) => Number.isFinite(b)) &&
|
|
141
|
+
Number.isFinite(t.clip) &&
|
|
142
|
+
Number.isFinite(t.step),
|
|
143
|
+
) &&
|
|
144
|
+
Array.isArray(file.blend) &&
|
|
145
|
+
file.blend.length === 3 * (file.tables.length + 1) + 1 &&
|
|
146
|
+
file.blend.every((/** @type {any} */ x) => Number.isFinite(x))
|
|
147
|
+
);
|
|
148
|
+
}
|
package/api/build/build.test.mjs
CHANGED
|
@@ -269,7 +269,7 @@ describe('build kit — a thin kit says what to try next', () => {
|
|
|
269
269
|
// A skeleton is a 35-line excerpt: a reader who studies it and composes
|
|
270
270
|
// the rest loses the spacing the template exists to carry. A loose match
|
|
271
271
|
// is still the best start there is, so `start` scaffolds it.
|
|
272
|
-
const r = await build('
|
|
272
|
+
const r = await build('weekly business review with targets', {cwd: REPO});
|
|
273
273
|
expect(r.type).toBe('build.kit');
|
|
274
274
|
if (r.type !== 'build.kit') return;
|
|
275
275
|
expect(r.data.directMatch).toBe(false);
|
|
@@ -477,6 +477,79 @@ describe('build kit — every page starts from a template', () => {
|
|
|
477
477
|
expect(r.data.pages.map(p => p.name)).not.toContain('side-gallery');
|
|
478
478
|
});
|
|
479
479
|
|
|
480
|
+
it('names a direct match the start does not use, and calls the start direct only when it is', async () => {
|
|
481
|
+
for (const idea of ['a login form', 'a docs site for our API', 'contact form']) {
|
|
482
|
+
const r = await build(idea, {cwd: REPO});
|
|
483
|
+
if (r.type !== 'build.kit') throw new Error(r.type);
|
|
484
|
+
expect(r.data.directMatch).toBe(true);
|
|
485
|
+
const match = r.data.pages[0].name;
|
|
486
|
+
if (r.data.start?.name === match) {
|
|
487
|
+
expect(r.data.start?.basis).toBe('direct');
|
|
488
|
+
} else {
|
|
489
|
+
expect(['closest', 'fallback']).toContain(r.data.start?.basis);
|
|
490
|
+
expect(r.data.start?.reason).toContain(`\`${match}\``);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
it('keeps a template search matched directly rather than the app shell', async () => {
|
|
496
|
+
for (const [idea, name] of [
|
|
497
|
+
['a login screen', 'login'],
|
|
498
|
+
['a checkout wizard', 'checkout-wizard'],
|
|
499
|
+
]) {
|
|
500
|
+
const r = await build(idea, {cwd: REPO});
|
|
501
|
+
if (r.type !== 'build.kit') throw new Error(r.type);
|
|
502
|
+
expect(r.data.directMatch).toBe(true);
|
|
503
|
+
expect(r.data.start?.name).toBe(name);
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it('lets the weights choose another template over a direct match', async () => {
|
|
508
|
+
const r = await build('a login form', {cwd: REPO});
|
|
509
|
+
if (r.type !== 'build.kit') throw new Error(r.type);
|
|
510
|
+
expect(r.data.directMatch).toBe(true);
|
|
511
|
+
const match = r.data.pages[0].name;
|
|
512
|
+
expect(r.data.start?.name).not.toBe('shell-top-nav');
|
|
513
|
+
expect(r.data.start?.name).not.toBe(match);
|
|
514
|
+
expect(r.data.start?.reason).toContain(`\`${match}\``);
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
it('starts a part that names no page from the app shell', async () => {
|
|
518
|
+
for (const idea of ['a kanban card', 'a date range picker']) {
|
|
519
|
+
const r = await build(idea, {cwd: REPO});
|
|
520
|
+
if (r.type !== 'build.kit') throw new Error(r.type);
|
|
521
|
+
expect(r.data.start).toMatchObject({name: 'shell-top-nav', basis: 'fallback'});
|
|
522
|
+
expect(r.data.start?.reason).toMatch(/part of a page/);
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it('does not keep a loose match over the app shell', async () => {
|
|
527
|
+
// Search matches no template directly, so the ranker's closest page does
|
|
528
|
+
// not override the shell the weights choose.
|
|
529
|
+
const r = await build('quarterly business review', {cwd: REPO});
|
|
530
|
+
if (r.type !== 'build.kit') throw new Error(r.type);
|
|
531
|
+
expect(r.data.directMatch).toBe(false);
|
|
532
|
+
expect(r.data.start).toMatchObject({name: 'shell-top-nav', basis: 'fallback'});
|
|
533
|
+
expect(r.data.start?.reason).toMatch(/closest/);
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
it('starts a new page with no matching template from the app shell', async () => {
|
|
537
|
+
const r = await build('a new page', {cwd: REPO});
|
|
538
|
+
if (r.type !== 'build.kit') throw new Error(r.type);
|
|
539
|
+
expect(r.data.start?.name).toBe('shell-top-nav');
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
it('starts a page the words describe from its template', async () => {
|
|
543
|
+
for (const [idea, name] of [
|
|
544
|
+
['a weekly report of sales by region', 'dashboard-scorecard'],
|
|
545
|
+
['a pricing page with three plans and a comparison table', 'table-page'],
|
|
546
|
+
]) {
|
|
547
|
+
const r = await build(idea, {cwd: REPO});
|
|
548
|
+
if (r.type !== 'build.kit') throw new Error(r.type);
|
|
549
|
+
expect(r.data.start?.name).toBe(name);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
|
|
480
553
|
it('starts a component in a container from a template with that frame', async () => {
|
|
481
554
|
// "in a modal": the modal is the frame, so the dialog template leads
|
|
482
555
|
// instead of the app shell.
|
package/api/build/kit/kit.mjs
CHANGED
|
@@ -32,8 +32,15 @@ import {findCoreDir} from '../../../foundation/fs/paths.mjs';
|
|
|
32
32
|
import {AstryxError} from '../../error.mjs';
|
|
33
33
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
34
34
|
import {getResultCoverage} from '../../search/coverage.mjs';
|
|
35
|
-
import {loadComponents, loadPageTemplates} from '../_adapter.mjs';
|
|
36
|
-
import {
|
|
35
|
+
import {loadComponents, loadPageTemplates, loadWeights} from '../_adapter.mjs';
|
|
36
|
+
import {
|
|
37
|
+
asksForNewPage,
|
|
38
|
+
ideaKind,
|
|
39
|
+
pickAlternatives,
|
|
40
|
+
pickStart,
|
|
41
|
+
rankPages,
|
|
42
|
+
} from './rank.mjs';
|
|
43
|
+
import {weighStart} from './weights.mjs';
|
|
37
44
|
|
|
38
45
|
/** A page at/above this score is a confident direct match. */
|
|
39
46
|
const PAGE_DIRECT = 95;
|
|
@@ -151,9 +158,10 @@ function placement(kind, inPage) {
|
|
|
151
158
|
* @param {SearchResultEntry[]} pages
|
|
152
159
|
* @param {boolean} directMatch
|
|
153
160
|
* @param {PageTemplate[]} catalog
|
|
161
|
+
* @param {string} idea
|
|
154
162
|
* @returns {Omit<BuildStart, 'alternatives'> | null}
|
|
155
163
|
*/
|
|
156
|
-
function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
164
|
+
function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
|
|
157
165
|
const direct = directMatch ? pages[0].name : null;
|
|
158
166
|
const unready =
|
|
159
167
|
direct && !catalog.some(t => t.name === direct) ? direct : null;
|
|
@@ -170,7 +178,27 @@ function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
|
170
178
|
direct && direct !== startName
|
|
171
179
|
? `Search matched \`${direct}\` by name, but ${place}`
|
|
172
180
|
: place[0].toUpperCase() + place.slice(1);
|
|
173
|
-
const
|
|
181
|
+
const proposed = pickStart(ranked, kind);
|
|
182
|
+
// The checked-in word weights (weights.mjs), blended with the ranker's
|
|
183
|
+
// scores, decide the start of a whole page. A part or an edit starts where
|
|
184
|
+
// the ranker's placement rules put it (spec:AST-048/FR3).
|
|
185
|
+
const weighed =
|
|
186
|
+
kind === 'page'
|
|
187
|
+
? weighStart(idea, ranked, proposed, catalog, {
|
|
188
|
+
weights: loadWeights(),
|
|
189
|
+
newPage: asksForNewPage(idea, catalog),
|
|
190
|
+
})
|
|
191
|
+
: undefined;
|
|
192
|
+
// A shell start keeps the shell the ranker named, if any, and never replaces
|
|
193
|
+
// the template the ranker chose for a page search matched directly.
|
|
194
|
+
const pick =
|
|
195
|
+
weighed === undefined
|
|
196
|
+
? proposed
|
|
197
|
+
: weighed === null
|
|
198
|
+
? proposed?.family === 'Shell' || (proposed && direct && !unready)
|
|
199
|
+
? proposed
|
|
200
|
+
: null
|
|
201
|
+
: (ranked.find(r => r.name === weighed) ?? proposed);
|
|
174
202
|
const closest = pick && catalog.find(t => t.name === pick.name);
|
|
175
203
|
if (pick && closest) {
|
|
176
204
|
const agrees = closest.name === direct;
|
|
@@ -194,7 +222,9 @@ function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
|
194
222
|
if (shell) {
|
|
195
223
|
// The shell can also be the ranker's best guess without the evidence to
|
|
196
224
|
// lead ("horizontal site navigation"); say so rather than "no match".
|
|
197
|
-
const nearest =
|
|
225
|
+
const nearest =
|
|
226
|
+
(ranked[0]?.name === shell.name && ranked[0].hits > 0) ||
|
|
227
|
+
(weighed === null && !!proposed && proposed.family !== 'Shell');
|
|
198
228
|
const place = placement(kind, false);
|
|
199
229
|
return {
|
|
200
230
|
...asTemplate(shell),
|
|
@@ -204,7 +234,9 @@ function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
|
204
234
|
: place
|
|
205
235
|
? placed(place, shell.name)
|
|
206
236
|
: direct
|
|
207
|
-
?
|
|
237
|
+
? weighed === null
|
|
238
|
+
? `Search matched \`${direct}\` by name, but the app shell is the closer start.`
|
|
239
|
+
: `Search matched \`${direct}\` by name, but too little of the idea fits it, so start from the app shell.`
|
|
208
240
|
: nearest
|
|
209
241
|
? 'No template is a clear match; the app shell is the closest.'
|
|
210
242
|
: loose
|
|
@@ -346,7 +378,7 @@ export async function buildKit(query, options = {}) {
|
|
|
346
378
|
)
|
|
347
379
|
: 'page';
|
|
348
380
|
const chosen = wantsPages
|
|
349
|
-
? chooseStart(ranked, kind, matchedPages, directMatch, catalog)
|
|
381
|
+
? chooseStart(ranked, kind, matchedPages, directMatch, catalog, query)
|
|
350
382
|
: null;
|
|
351
383
|
// Name the ranker's next two templates beside the start: the reader judges
|
|
352
384
|
// meaning better than keywords do, and an acceptable template is in these
|
package/api/build/kit/rank.d.mts
CHANGED
|
@@ -21,6 +21,14 @@ export function rankPages(query: string, pages: PageTemplate[]): RankedPage[];
|
|
|
21
21
|
* @returns {IdeaKind}
|
|
22
22
|
*/
|
|
23
23
|
export function ideaKind(query: string, pages: PageTemplate[], components: ComponentWords[]): IdeaKind;
|
|
24
|
+
/**
|
|
25
|
+
* Whether an idea asks for a new page (see `asksNewPage`), from the idea and
|
|
26
|
+
* the project's page templates.
|
|
27
|
+
* @param {string} query
|
|
28
|
+
* @param {PageTemplate[]} pages
|
|
29
|
+
* @returns {boolean}
|
|
30
|
+
*/
|
|
31
|
+
export function asksForNewPage(query: string, pages: PageTemplate[]): boolean;
|
|
24
32
|
/**
|
|
25
33
|
* The next closest templates after the start, best first: the ones a reader
|
|
26
34
|
* should check the idea against when the start's shape is wrong. Each matched
|
package/api/build/kit/rank.mjs
CHANGED
|
@@ -543,6 +543,20 @@ function asksNewPage(phrases, familyWords) {
|
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
545
|
|
|
546
|
+
/**
|
|
547
|
+
* Whether an idea asks for a new page (see `asksNewPage`), from the idea and
|
|
548
|
+
* the project's page templates.
|
|
549
|
+
* @param {string} query
|
|
550
|
+
* @param {PageTemplate[]} pages
|
|
551
|
+
* @returns {boolean}
|
|
552
|
+
*/
|
|
553
|
+
export function asksForNewPage(query, pages) {
|
|
554
|
+
return asksNewPage(
|
|
555
|
+
String(query).toLowerCase().split(PHRASE_END),
|
|
556
|
+
familyWordsOf(pages),
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
|
|
546
560
|
/**
|
|
547
561
|
* The words of a component's name: "DateRangeInput" is date, range, input.
|
|
548
562
|
* @param {ComponentWords} component
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The Porter stem of a lowercase word.
|
|
6
|
+
* @param {string} word
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
export function stem(word: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Lowercase words of an idea that can carry weight: letters only, two or more.
|
|
12
|
+
* @param {string} idea
|
|
13
|
+
* @returns {string[]}
|
|
14
|
+
*/
|
|
15
|
+
export function weightWords(idea: string): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Where an idea starts, by the blended weights.
|
|
18
|
+
* @param {string} idea
|
|
19
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked the ranker's output for the idea
|
|
20
|
+
* @param {import('./rank.mjs').RankedPage | null} pick the ranker's own start
|
|
21
|
+
* @param {{name: string}[]} catalog the project's ready page templates
|
|
22
|
+
* @param {{weights?: WeightsFile | null, newPage?: boolean}} [options]
|
|
23
|
+
* `newPage`: the idea asks for a new page (rank.mjs `asksForNewPage`)
|
|
24
|
+
* @returns {string | null | undefined} a template id, null for the app shell,
|
|
25
|
+
* undefined without weights
|
|
26
|
+
*/
|
|
27
|
+
export function weighStart(idea: string, ranked: import("./rank.mjs").RankedPage[], pick: import("./rank.mjs").RankedPage | null, catalog: {
|
|
28
|
+
name: string;
|
|
29
|
+
}[], { weights, newPage }?: {
|
|
30
|
+
weights?: WeightsFile | null;
|
|
31
|
+
newPage?: boolean;
|
|
32
|
+
}): string | null | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* @file Word weights for `build`'s START (spec:AST-048): a checked-in table of
|
|
35
|
+
* per-template word weights, blended with the page ranker's own scores, picks
|
|
36
|
+
* the template an idea starts from.
|
|
37
|
+
*
|
|
38
|
+
* @input An idea, the ranker's output for it (`rankPages`, `pickStart`), the
|
|
39
|
+
* project's ready page templates, and the weights (`weights.json` beside this
|
|
40
|
+
* file, read by the adapter): the candidates (the app shell as `SHELL`, then page template ids), one or more
|
|
41
|
+
* word tables (stemmed words, a bias per candidate, and one row of weights
|
|
42
|
+
* per word, a character per candidate) and the blend numbers.
|
|
43
|
+
* @output `weighStart(idea, ranked, pick, catalog)`: the template id to start
|
|
44
|
+
* from, null for the app shell, or undefined when no table is available, in
|
|
45
|
+
* which case the ranker's own pick stands.
|
|
46
|
+
* @position Beside rank.mjs (api/build/kit/); kit.mjs calls it for every
|
|
47
|
+
* whole page (a part or an edit follows the ranker's placement rules). The
|
|
48
|
+
* ranker's pick of a template the tables do not list stands, so a new
|
|
49
|
+
* template can start a build.
|
|
50
|
+
*/
|
|
51
|
+
/** The app shell, as one candidate. */
|
|
52
|
+
export const SHELL: "SHELL";
|
|
53
|
+
export type WeightTable = {
|
|
54
|
+
/**
|
|
55
|
+
* stemmed words
|
|
56
|
+
*/
|
|
57
|
+
words: string[];
|
|
58
|
+
/**
|
|
59
|
+
* one per candidate
|
|
60
|
+
*/
|
|
61
|
+
bias: number[];
|
|
62
|
+
clip: number;
|
|
63
|
+
step: number;
|
|
64
|
+
/**
|
|
65
|
+
* one per word: a character per candidate,
|
|
66
|
+
* weight = (charCode - 97) * step - clip
|
|
67
|
+
*/
|
|
68
|
+
rows: string[];
|
|
69
|
+
};
|
|
70
|
+
export type WeightsFile = {
|
|
71
|
+
version: number;
|
|
72
|
+
/**
|
|
73
|
+
* `SHELL`, then page template ids
|
|
74
|
+
*/
|
|
75
|
+
candidates: string[];
|
|
76
|
+
tables: WeightTable[];
|
|
77
|
+
/**
|
|
78
|
+
* three numbers per member (the tables, in order,
|
|
79
|
+
* with the ranker second), then one for `SHELL`
|
|
80
|
+
*/
|
|
81
|
+
blend: number[];
|
|
82
|
+
};
|