@astryxdesign/cli 0.6.5-canary.b8e30f3 → 0.6.5-canary.bd969de
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 +45 -43
- package/api/build/_adapter.d.mts +19 -0
- package/api/build/_adapter.mjs +60 -1
- package/api/build/build.test.mjs +74 -1
- package/api/build/build.type.d.mts +8 -0
- package/api/build/build.type.mjs +2 -0
- package/api/build/kit/kit.mjs +40 -7
- package/api/build/kit/rank.d.mts +8 -0
- package/api/build/kit/rank.mjs +14 -0
- package/api/build/kit/weights.d.mts +82 -0
- package/api/build/kit/weights.json +1 -0
- package/api/build/kit/weights.mjs +305 -0
- package/api/build/kit/weights.test.mjs +190 -0
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +603 -0
- package/api/component/component.mjs +49 -15
- package/api/component/component.type.d.mts +33 -3
- package/api/component/component.type.mjs +10 -3
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +5 -2
- package/api/component/detail/detail.mjs +5 -1
- package/api/component/detail/props/props.d.mts +2 -1
- package/api/component/detail/props/props.mjs +3 -2
- package/api/component/detail/showcase/showcase.d.mts +3 -1
- package/api/component/detail/showcase/showcase.mjs +3 -1
- package/api/component/detail/source/source.d.mts +3 -2
- package/api/component/detail/source/source.mjs +7 -3
- package/api/component/list/list.mjs +128 -10
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +25 -0
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.mjs +7 -1
- package/api/docs/docs.d.mts +6 -0
- package/api/docs/docs.depth.test.mjs +134 -0
- package/api/docs/docs.doc.mjs +31 -2
- package/api/docs/docs.mjs +46 -1
- package/api/docs/docs.test.mjs +1 -1
- package/api/docs/docs.type.d.mts +81 -4
- package/api/docs/docs.type.mjs +41 -4
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/node/node.d.mts +28 -3
- package/api/docs/node/node.mjs +149 -23
- package/api/doctor/_adapter.d.mts +43 -0
- package/api/doctor/_adapter.mjs +142 -0
- package/api/doctor/doctor.d.mts +0 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +6 -123
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +1117 -0
- package/api/doctor/theme-checks.test.mjs +483 -0
- package/api/gap-report/gap-report.d.mts +3 -1
- package/api/gap-report/gap-report.mjs +27 -3
- package/api/gap-report/gap-report.test.mjs +106 -0
- package/api/hook/_adapter.d.mts +1 -0
- package/api/hook/_adapter.mjs +3 -0
- package/api/hook/detail/detail.mjs +2 -2
- package/api/hook/detail/params/params.mjs +2 -2
- package/api/hook/hook.type.d.mts +12 -0
- package/api/hook/hook.type.mjs +3 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/hook/list/list.mjs +8 -8
- package/api/index.d.mts +1 -1
- package/api/index.mjs +4 -0
- package/api/init/run/run.d.mts +3 -5
- package/api/init/run/run.mjs +10 -11
- package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
- package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
- package/api/integration/add-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +109 -5
- package/api/integration/add-theme.test.mjs +166 -15
- package/api/integration/authoring-checks.mjs +21 -1
- package/api/integration/integrationAddTheme.doc.mjs +1 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- package/api/integration/pack-check.component-replaces.test.mjs +126 -0
- package/api/integration/pack-check.d.mts +10 -0
- package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
- package/api/integration/pack-check.mjs +483 -1
- package/api/integration/pack-check.test.mjs +568 -8
- package/api/search/search.d.mts +15 -8
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +179 -67
- package/api/search/search.test.mjs +123 -8
- package/api/search/search.type.d.mts +6 -6
- package/api/search/search.type.mjs +5 -5
- package/api/swizzle/_adapter.d.mts +10 -0
- package/api/swizzle/_adapter.mjs +23 -0
- package/api/swizzle/copy/copy.mjs +22 -2
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.type.d.mts +8 -0
- package/api/swizzle/swizzle.type.mjs +2 -0
- package/api/template/copy/copy.mjs +2 -1
- package/api/template/show/show.mjs +2 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.d.mts +1 -1
- package/api/template/template.mjs +1 -0
- package/api/template/template.type.d.mts +12 -0
- package/api/template/template.type.mjs +3 -0
- package/api/theme/_adapter.d.mts +106 -6
- package/api/theme/_adapter.mjs +679 -18
- package/api/theme/add/add.binary.test.mjs +76 -3
- package/api/theme/add/add.d.mts +5 -9
- package/api/theme/add/add.mjs +87 -64
- package/api/theme/add/add.rollback.test.mjs +9 -9
- package/api/theme/add/add.staging.test.mjs +9 -9
- package/api/theme/add/add.test.mjs +461 -55
- package/api/theme/add/add.types.test.mjs +151 -0
- package/api/theme/build/build.d.mts +26 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.mjs +82 -78
- package/api/theme/build/build.test.mjs +30 -0
- package/api/theme/eject/eject.binary.test.mjs +90 -0
- package/api/theme/eject/eject.d.mts +17 -0
- package/api/theme/eject/eject.mjs +65 -0
- package/api/theme/eject/eject.rollback.test.mjs +158 -0
- package/api/theme/eject/eject.staging.test.mjs +83 -0
- package/api/theme/eject/eject.test.mjs +160 -0
- package/api/theme/integration-themes.test.mjs +30 -6
- package/api/theme/list/list.d.mts +10 -0
- package/api/theme/list/list.mjs +75 -7
- package/api/theme/list/list.test.mjs +155 -4
- package/api/theme/remove/remove.d.mts +12 -0
- package/api/theme/remove/remove.mjs +15 -0
- package/api/theme/remove/remove.test.mjs +94 -0
- package/api/theme/template/template.mjs +3 -4
- package/api/theme/theme.d.mts +5 -2
- package/api/theme/theme.mjs +13 -8
- package/api/theme/theme.type.d.mts +101 -2
- package/api/theme/theme.type.mjs +52 -5
- package/api/theme/themeAdd.doc.d.mts +1 -3
- package/api/theme/themeAdd.doc.mjs +35 -22
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeEject.doc.d.mts +8 -0
- package/api/theme/themeEject.doc.mjs +89 -0
- package/api/theme/themeListAvailable.doc.mjs +4 -4
- package/api/theme/themeListCopySources.doc.d.mts +8 -0
- package/api/theme/themeListCopySources.doc.mjs +60 -0
- package/api/theme/themeRemove.doc.d.mts +6 -0
- package/api/theme/themeRemove.doc.mjs +50 -0
- package/api/theme/themeTemplate.doc.mjs +4 -3
- package/api/theme/themeUse.doc.d.mts +6 -0
- package/api/theme/themeUse.doc.mjs +47 -0
- package/api/theme/use/use.d.mts +12 -0
- package/api/theme/use/use.mjs +15 -0
- package/api/theme/use/use.test.mjs +98 -0
- package/api/upgrade/_adapter.d.mts +1 -0
- package/api/upgrade/_adapter.mjs +3 -0
- package/api/upgrade/list/list.mjs +9 -3
- package/api/upgrade/upgrade.type.d.mts +4 -0
- package/api/upgrade/upgrade.type.mjs +1 -0
- package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/next/index.mjs +14 -1
- package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/getting-started.doc.mjs +58 -14
- package/assets/docs/principles.doc.dense.mjs +2 -2
- package/assets/docs/principles.doc.mjs +2 -2
- package/assets/docs/principles.doc.zh.mjs +2 -2
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +23 -4
- package/assets/docs/theme.doc.mjs +77 -67
- package/assets/docs/theme.doc.zh.mjs +158 -12
- package/assets/docs/tokens.doc.mjs +3 -3
- package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
- package/assets/docs/tree/checks.doc.mjs +5 -4
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/fonts-and-assets.doc.mjs +24 -19
- package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +32 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/responsive.doc.mjs +102 -0
- package/assets/docs/tree/scaffold.doc.mjs +145 -0
- package/assets/docs/tree/side-panels.doc.mjs +82 -0
- package/assets/docs/tree/structure.doc.mjs +144 -0
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +4 -0
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +4 -1
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -4
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.mjs +274 -29
- package/clients/cli/commands/build.mjs +7 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +88 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/discover.mjs +29 -1
- package/clients/cli/commands/discover.no-source.test.mjs +75 -0
- package/clients/cli/commands/docs.depth.test.mjs +219 -0
- package/clients/cli/commands/docs.doc.mjs +15 -2
- package/clients/cli/commands/docs.mjs +273 -16
- package/clients/cli/commands/docs.test.mjs +2 -2
- package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +9 -51
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/gap-report.mjs +12 -0
- package/clients/cli/commands/gap-report.test.mjs +63 -0
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-add.doc.mjs +1 -1
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.doc.mjs +5 -4
- package/clients/cli/commands/search.mjs +30 -6
- package/clients/cli/commands/search.test.mjs +60 -16
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/template.mjs +8 -4
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +129 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
- package/clients/cli/commands/theme-remove.doc.mjs +22 -0
- package/clients/cli/commands/theme-template.doc.mjs +4 -3
- package/clients/cli/commands/theme-use.doc.mjs +22 -0
- package/clients/cli/commands/theme.doc.mjs +21 -16
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/index.mjs +4 -1
- package/clients/cli/lib/component-format.mjs +19 -2
- package/clients/cli/lib/resolve-theme.mjs +80 -78
- package/clients/cli/lib/resolve-theme.test.mjs +523 -27
- package/foundation/agent-docs/agent-docs.mjs +3 -2
- package/foundation/agent-docs/agent-docs.test.mjs +8 -0
- package/foundation/agent-docs/app-theme-workflow.test.mjs +16 -0
- package/foundation/config/project.d.mts +20 -5
- package/foundation/config/project.mjs +43 -6
- package/foundation/config/theme-private-vars.d.mts +12 -0
- package/foundation/config/theme-private-vars.mjs +107 -0
- package/foundation/config/theme-private-vars.test.mjs +55 -0
- package/foundation/config/theme-state.d.mts +145 -0
- package/foundation/config/theme-state.mjs +417 -0
- package/foundation/config/theme-state.test.mjs +182 -0
- package/foundation/discovery/component-discovery.d.mts +5 -2
- package/foundation/discovery/component-discovery.mjs +12 -6
- package/foundation/discovery/component-replacement.d.mts +91 -0
- package/foundation/discovery/component-replacement.mjs +417 -0
- package/foundation/discovery/component-replacement.test.mjs +480 -0
- package/foundation/discovery/docs-output-budget.d.mts +6 -2
- package/foundation/discovery/docs-output-budget.mjs +2 -1
- package/foundation/discovery/docs-section-key.d.mts +4 -2
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/module-exports.d.mts +10 -0
- package/foundation/discovery/module-exports.mjs +146 -0
- package/foundation/discovery/package-exports.d.mts +29 -0
- package/foundation/discovery/package-exports.mjs +200 -0
- package/foundation/discovery/theme-discovery.d.mts +78 -5
- package/foundation/discovery/theme-discovery.mjs +143 -18
- package/foundation/discovery/theme-discovery.test.mjs +9 -3
- package/foundation/discovery/theme-imports.d.mts +15 -0
- package/foundation/discovery/theme-imports.mjs +217 -0
- package/foundation/discovery/theme-imports.test.mjs +173 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +15 -5
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/tree.test.mjs +2 -2
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +22 -0
- package/foundation/integrations/cli-requirement.mjs +31 -0
- package/foundation/integrations/cli-requirement.test.mjs +70 -0
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- package/foundation/response/base.d.ts +9 -3
- package/foundation/response/json.d.mts +7 -4
- package/foundation/response/json.mjs +10 -6
- package/foundation/response/response-types.doc.mjs +38 -23
- package/foundation/response/response.doc.mjs +18 -4
- package/foundation/text/copyright-header.mjs +1 -1
- package/foundation/text/copyright-header.test.mjs +1 -1
- package/package.json +9 -9
- package/assets/docs/layout.doc.dense.mjs +0 -388
- package/assets/docs/layout.doc.mjs +0 -550
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ Results for "button" (20 of 239):
|
|
|
69
69
|
|
|
70
70
|
Options:
|
|
71
71
|
|
|
72
|
-
- `--type <component|hook|doc|template>`: restrict to a single domain
|
|
72
|
+
- `--type <component|hook|doc|template|theme>`: restrict to a single domain (`doc` and `theme` work outside an app too)
|
|
73
73
|
- `--limit <n>`: cap the number of results (default 20)
|
|
74
74
|
- `--verbose`: also print each result's match score and reason
|
|
75
75
|
- `--json`: typed `{ apiVersion, type: 'search', data: { query, matchCount, results } }` envelope — `matchCount` is how many candidates matched in total, `results` the slice `--limit` allowed
|
|
@@ -78,24 +78,24 @@ Options:
|
|
|
78
78
|
|
|
79
79
|
<!-- BEGIN GENERATED: commands -->
|
|
80
80
|
|
|
81
|
-
| Command | Description
|
|
82
|
-
| ------------- |
|
|
83
|
-
| `blog` | Read the Astryx blog from the published feed
|
|
84
|
-
| `build` | Build a page: the template to start from, or the workflow playbook (no query)
|
|
85
|
-
| `component` | List components or print component docs
|
|
86
|
-
| `discover` | Browse and search integrations: the ones you have and the ones you could add
|
|
87
|
-
| `docs` | Print reference docs
|
|
88
|
-
| `doctor` | Diagnose Astryx projects and integration packages
|
|
89
|
-
| `gap-report` | Report a missing component or feature to the package that owns it
|
|
90
|
-
| `hook` | List hooks or print hook docs
|
|
91
|
-
| `init` | Initialize the design system in your project
|
|
92
|
-
| `integration` | Author and verify an Astryx integration package
|
|
93
|
-
| `layout` | Generate XDS layouts from compressed expressions (XLE/XLO)
|
|
94
|
-
| `search` | Search components, hooks, docs, and
|
|
95
|
-
| `swizzle` | Copy component source for customization
|
|
96
|
-
| `template` | List, show, or scaffold page and block templates
|
|
97
|
-
| `theme` |
|
|
98
|
-
| `upgrade` | Update your code after upgrading Astryx, and refresh ShadCN-copied components
|
|
81
|
+
| Command | Description |
|
|
82
|
+
| ------------- | ----------------------------------------------------------------------------- |
|
|
83
|
+
| `blog` | Read the Astryx blog from the published feed |
|
|
84
|
+
| `build` | Build a page: the template to start from, or the workflow playbook (no query) |
|
|
85
|
+
| `component` | List components or print component docs |
|
|
86
|
+
| `discover` | Browse and search integrations: the ones you have and the ones you could add |
|
|
87
|
+
| `docs` | Print reference docs |
|
|
88
|
+
| `doctor` | Diagnose Astryx projects and integration packages |
|
|
89
|
+
| `gap-report` | Report a missing component or feature to the package that owns it |
|
|
90
|
+
| `hook` | List hooks or print hook docs |
|
|
91
|
+
| `init` | Initialize the design system in your project |
|
|
92
|
+
| `integration` | Author and verify an Astryx integration package |
|
|
93
|
+
| `layout` | Generate XDS layouts from compressed expressions (XLE/XLO) |
|
|
94
|
+
| `search` | Search components, hooks, docs, templates, and themes in one ranked list |
|
|
95
|
+
| `swizzle` | Copy component source for customization |
|
|
96
|
+
| `template` | List, show, or scaffold page and block templates |
|
|
97
|
+
| `theme` | Add, switch, build, and author themes |
|
|
98
|
+
| `upgrade` | Update your code after upgrading Astryx, and refresh ShadCN-copied components |
|
|
99
99
|
|
|
100
100
|
<!-- END GENERATED: commands -->
|
|
101
101
|
<!-- Generated by scripts/generate-cli-readme.mjs from `astryx manifest`. Run `pnpm -F @astryxdesign/cli readme`. -->
|
|
@@ -104,7 +104,7 @@ Options:
|
|
|
104
104
|
|
|
105
105
|
`--json` works with every command listed in `jsonSupported` (`astryx manifest --json`), which is every command except the bare groups such as `astryx theme`. The other four change only the reads named here; other commands ignore them:
|
|
106
106
|
|
|
107
|
-
- `--json`: Output as typed JSON envelope: `{ apiVersion, type, data, meta? }` (errors: `{ apiVersion, error, code, suggestions? }`)
|
|
107
|
+
- `--json`: Output as typed JSON envelope: `{ apiVersion, type, package?, data, meta? }` (errors: `{ apiVersion, error, code, suggestions? }`)
|
|
108
108
|
- `--detail <level>`: Detail level for `component`, `hook`, and docs tree reads (such as `astryx docs cli/commands/build`), increasing in size: `brief` (names only, default for lists) < `compact` (names + 1-line descriptions) < `full` (full docs per entry). Single-item views default to `full`.
|
|
109
109
|
- `--zh`: Simplified Chinese for component reads and for docs topics that have a translation (English otherwise)
|
|
110
110
|
- `--dense`: Token-efficient dense text for `astryx component <Name>` and `astryx docs <topic>`
|
|
@@ -424,18 +424,18 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
424
424
|
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
425
425
|
| `init.run` | The install receipt: the `mode` (`default` \| `features`), the features run, agent-doc files written, any soft `docsError`, whether theme guidance was emitted, the template outcome (`workflow` \| `created` \| `skipped`) plus its path, and whether the next-steps were emitted. |
|
|
426
426
|
| `init.remove` | Confirmation that the managed agent-docs block was removed (`data.removed: true`) — returned when --remove-agents is set. |
|
|
427
|
-
| `component.list` | The component catalog grouped by component group (each component's group field): `detail` (the level: names \| compact \| full) and `components`, the grouped map of names entries ({name, package, and optional canonical import for integrations}), brief entries, or a full ComponentDoc per entry.
|
|
427
|
+
| `component.list` | The component catalog grouped by component group (each component's group field): `detail` (the level: names \| compact \| full) and `components`, the grouped map of names entries ({name, package, and optional canonical import for integrations}), brief entries ({name, package, description, import}), or a full ComponentDoc per entry with its package. |
|
|
428
428
|
| `component.batch` | The component specialization of the shared `BatchResponse` and `BatchRow` types. An explicit programmatic selector array, or two or more CLI selectors, returns one ordered receipt: `count` plus `results`, one row per selector including duplicates. Every row carries `selector` and `status` (found \| not_found \| ambiguous \| error). A found row carries `result`, the same {type, data} response as one selector. An ambiguous row carries `code`, `error`, and `candidates` ({package, component, kind, installed}). Other failed rows carry `code`, `error`, and optional `suggestions` ({name, reason}). |
|
|
429
|
-
| `component.detail` | One component's authored ComponentDoc plus ownership fields (package, the owner; import, the specifier; sourceAvailable, whether source exists) and parentDoc (present when the component is documented inside another component's doc, naming that doc).
|
|
430
|
-
| `component.detail.props` | Just one component's props table (ComponentPropDoc[]).
|
|
431
|
-
| `component.detail.source` | One component's source file, as {component, source}.
|
|
432
|
-
| `component.detail.showcase` | One component's showcase example, as {component, aspectRatio, source}.
|
|
433
|
-
| `component.detail.blocks` | One component's example blocks, as {component, showcase, examples, related} of BlockEntry.
|
|
429
|
+
| `component.detail` | One component's authored ComponentDoc plus ownership fields (package, the owner; import, the specifier; sourceAvailable, whether source exists) and parentDoc (present when the component is documented inside another component's doc, naming that doc). The envelope's package names the same owner. |
|
|
430
|
+
| `component.detail.props` | Just one component's props table (ComponentPropDoc[]). The envelope's package names the npm package that owns the component. |
|
|
431
|
+
| `component.detail.source` | One component's source file, as {component, source}. The envelope's package names the npm package that owns the component. |
|
|
432
|
+
| `component.detail.showcase` | One component's showcase example, as {component, aspectRatio, source}. The envelope's package names the npm package that owns the component. |
|
|
433
|
+
| `component.detail.blocks` | One component's example blocks, as {component, showcase, examples, related} of BlockEntry ({name, package, displayName, description, isShowcase, category}); each block names the package that owns it, and the envelope's package names the component's owner. |
|
|
434
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. |
|
|
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).
|
|
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).
|
|
437
|
-
| `docs.detail.section` | One ReferenceSection of a topic, found by key or title, with token-ref blocks inlined, plus links ({up, previous, next}: the commands that open its topic index and the sections before and after it).
|
|
438
|
-
| `docs.node` | One node of the docs tree, read by its route: its id, kind, package, title, summary, and breadcrumb, plus a namespace's slots with their children (one level down) or a typed doc's content, and links ({up, previous, next, related}: the commands that open its parent, its neighbors, and the docs it names).
|
|
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 and each section naming the package that wrote it, plus links ({up, previous, next}: the commands that open the level it sits in and its neighbors there). |
|
|
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, package, summary} (pass the id as the section argument; package is the npm package that wrote the section; 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). |
|
|
437
|
+
| `docs.detail.section` | One ReferenceSection of a topic, found by key or title, with token-ref blocks inlined, plus links ({up, previous, next}: the commands that open its topic index and the sections before and after it). The envelope's package names the npm package that wrote the section. |
|
|
438
|
+
| `docs.node` | One node of the docs tree, read by its route: its id, kind, package, title, summary, and breadcrumb, plus a namespace's slots with their children (one level down, each naming its package) or a typed doc's content, and links ({up, previous, next, related}: the commands that open its parent, its neighbors, and the docs it names). |
|
|
439
439
|
| `blog.list` | The feed URL plus every post parsed from the RSS feed, each with slug, title, description, date, type, authors, link, and plaintext URL. |
|
|
440
440
|
| `blog.detail` | One post's metadata plus the feed URL and the post's full plaintext body. |
|
|
441
441
|
| `discover.list` | The integrations the project loads (name, category, components, version, a list per other kind they add, and latest when a source knows it); with a discover source, meta.available lists what the project could add and meta.sources reports each source; when empty it carries meta.configured to tell "nothing configured" from "nothing discovered". |
|
|
@@ -443,30 +443,32 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
443
443
|
| `discover.detail.doc` | The validated ComponentDoc for one installed component, for an @scope/name/Component query. |
|
|
444
444
|
| `discover.item` | One item that is not an installed component, for an @scope/name/<item> query: its kind, name, package, version, and whether the project has the package. |
|
|
445
445
|
| `discover.search` | The echoed query plus every matching item and package across all packages, each with its kind and whether the project has it, even when only one matches; total is set when --limit cut the list. |
|
|
446
|
-
| `search` | The echoed query, `matchCount` (total matches, before `limit`), and results, a ranked SearchResultEntry[] bounded by `limit`: each {domain, name, score, reason, description, command}, plus import (components, hooks), title, parent (the command that opens the level above),
|
|
446
|
+
| `search` | The echoed query, `matchCount` (total matches, before `limit`), and results, a ranked SearchResultEntry[] bounded by `limit`: each {domain, name, package, score, reason, description, command} (package is the npm package that owns the result), plus import (components, hooks), title, parent (the command that opens the level above), and, for a hit on one section, section (docs), or displayName and kind (templates). |
|
|
447
447
|
| `build.help` | The how-to-build-a-page playbook, emitted when no query is given: `playbook: true`, a title, the ordered steps (title, commands, optional returns), the on-system rules, and related lookups. Commands are bare subcommands for the caller to render with its own invocation. |
|
|
448
|
-
| `build.kit` | The template to start from and its kit: query, hasResults, matchCount (never a cap), directMatch, start {name, command, basis, reason, alternatives, ...}, pages (search's closest templates), blocks and domain as SearchResultEntry[], frame
|
|
449
|
-
| `swizzle.list` | The names of swizzlable components discoverable from cwd's @astryxdesign/core.
|
|
450
|
-
| `swizzle.copy` | An eject receipt: component name, owning package, output directory, files-copied count, the written file names, whether any file uses StyleX, and, when the owner has an issues URL, feedback ({issuesUrl, ghCommand?}): where to report the gap that led to swizzling.
|
|
448
|
+
| `build.kit` | The template to start from and its kit: query, hasResults, matchCount (never a cap), directMatch, start {name, package, command, basis, reason, alternatives, ...} (the start and each alternative name the package that owns the template), pages (search's closest templates), blocks and domain as SearchResultEntry[] (each naming its package), frame and foundation (Core component names), and hint {reason, commands} when thin. |
|
|
449
|
+
| `swizzle.list` | The names of swizzlable components discoverable from cwd's @astryxdesign/core. The envelope's package is @astryxdesign/core. |
|
|
450
|
+
| `swizzle.copy` | An eject receipt: component name, owning package, output directory, files-copied count, the written file names, whether any file uses StyleX, and, when the owner has an issues URL, feedback ({issuesUrl, ghCommand?}): where to report the gap that led to swizzling. The envelope's package names the same owning package. |
|
|
451
451
|
| `gap-report.categories` | The fixed gap category values and human-readable labels. |
|
|
452
452
|
| `gap-report.file` | An aggregate receipt: overall status, the selected package, issuesUrl (or null), deliveries in handler order, each {handlerType: project \| integration \| fallback, handler, audience, status, url, message}, and filedCount/routedOnlyCount totals. |
|
|
453
453
|
| `template.list` | The effective discovered TemplateListEntry[] for pages and blocks. A winning replacement entry includes optional `replaces`, naming the Core id omitted from the default list. |
|
|
454
454
|
| `template.show` | The resolved template's source, exactly as a copy writes it, plus its description, kind, the component names it composes, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media). |
|
|
455
|
-
| `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes.
|
|
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).
|
|
455
|
+
| `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. The envelope's package names the npm package that owns the template. |
|
|
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). The envelope's package names the npm package that owns the template. |
|
|
457
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. |
|
|
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.
|
|
459
|
-
| `hook.detail` | One hook's full authored HookDoc.
|
|
460
|
-
| `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]).
|
|
461
|
-
| `theme.build` | A theme build receipt: name, tokenCount and componentCount (override counts), sizeKB, the written outputs {css, js, dts, and variantsDts when applicable}, warnings (defects to fix), and notices (advisories about a correct theme, such as a named font it does not load).
|
|
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. The envelope's package is @astryxdesign/core, the only package that ships hooks. |
|
|
459
|
+
| `hook.detail` | One hook's full authored HookDoc. The envelope's package is @astryxdesign/core. |
|
|
460
|
+
| `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). The envelope's package is @astryxdesign/core. |
|
|
461
|
+
| `theme.build` | A theme build receipt: name, tokenCount and componentCount (override counts), sizeKB, the written outputs {css, cssDts, js, dts, and variantsDts when applicable}, warnings (defects to fix), and notices (advisories about a correct theme, such as a named font it does not load). |
|
|
462
462
|
| `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}), and the full list of checked paths. Writes nothing. |
|
|
463
463
|
| `theme.build.batch` | Several themes built in one invocation: `count` plus one {file, receipt} per theme in argument order, where receipt is that theme's theme.build (or theme.build.check) envelope, or null when it produced no CSS. |
|
|
464
|
-
| `theme.list` | Every bundled
|
|
465
|
-
| `theme.add` |
|
|
464
|
+
| `theme.list` | Every bundled, installed package, and local theme as a ThemeListEntry[]. Each entry has slug, displayName, description, maintained, owner package or local root, source, added, and default fields. Optional meta.unmigratedCopies names earlier descriptor-less copies, their missing descriptor, and the upgrade command; those copies are not data entries. |
|
|
465
|
+
| `theme.add` | The released source-copy receipt: slug, displayName, maintained flag, owner package, outputDir, source entry, exportName, and files. Its additive meta.deprecations entry names DEP-0005 and the source-fork/import replacements. |
|
|
466
|
+
| `theme.app` | The app theme record after add, remove, or use. It includes every added theme and its built imports, the default slug, generated module path, and the command change. |
|
|
467
|
+
| `theme.eject` | A local source-fork receipt with the resolved slug, displayName, source theme maintained flag, source-selector package, outputDir, source entry, exportName, and every file written, including the descriptor. The written local descriptor always uses maintained: false. |
|
|
466
468
|
| `theme.template` | A write receipt for the annotated theme template: the path (relative to cwd), whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |
|
|
467
469
|
| `theme.targets` | The whole themeable surface: the echoed filter, componentCount, and targets, one per theming target — {key, className, component, props, states, deprecatedFor?}, where props and states are its legal override keys and deprecatedFor names the canonical replacement key. |
|
|
468
470
|
| `theme.palette.generate` | An author-reviewable OKLCH palette candidate, its reproducibility receipt, summary counts, and optional candidate/receipt file-write result. |
|
|
469
|
-
| `upgrade.list` | Every available codemod, oldest→newest, as {name, title, version, optional}; returned for --list without running anything.
|
|
471
|
+
| `upgrade.list` | Every available codemod, oldest→newest, as {name, package, title, version, optional}; returned for --list without running anything. |
|
|
470
472
|
| `upgrade.registry` | The copied-composition receipt for --registry: applied, ok, the counts (found, current, wouldUpdate, updated, wouldMerge, merged, wouldRefreshReceipt, receiptsRefreshed, conflicts, missing, invalid, failed), and items. |
|
|
471
473
|
| `upgrade.status` | A short-circuit outcome with no codemods run (up_to_date, no_codemods, or config_fixable), each carrying the agent-docs summary. |
|
|
472
474
|
| `upgrade.run` | The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, sourcePathFound (false when the resolved source directory does not exist, so no source file was read), and (apply mode) filesChanged, transformsApplied, and per-codemod errors. |
|
package/api/build/_adapter.d.mts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @property {string} command `astryx template <id> --type page`, the command that selects exactly this template: an integration replacement is selected by the Core id it replaces, and `--type page` keeps a block with the same id from making it ambiguous. Search prints template commands the same way.
|
|
9
9
|
* @property {string} displayName Human-facing name.
|
|
10
10
|
* @property {string} description What the page is and how it is laid out.
|
|
11
|
+
* @property {string} package The npm package that owns this template.
|
|
11
12
|
* @property {string} category The template's own `Family - Variant` label; empty when it declares none.
|
|
12
13
|
* @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
|
|
13
14
|
*/
|
|
@@ -40,6 +41,20 @@ export function loadPageTemplates(cwd: string): Promise<PageTemplate[]>;
|
|
|
40
41
|
* @returns {Promise<ComponentWords[]>}
|
|
41
42
|
*/
|
|
42
43
|
export function loadComponents(cwd: string): Promise<ComponentWords[]>;
|
|
44
|
+
/**
|
|
45
|
+
* The matcher weights checked in beside the kit (`kit/weights.json`), read
|
|
46
|
+
* once; null when the file is absent or unreadable.
|
|
47
|
+
* @returns {import('./kit/weights.mjs').WeightsFile | null}
|
|
48
|
+
*/
|
|
49
|
+
export function loadWeights(): import("./kit/weights.mjs").WeightsFile | null;
|
|
50
|
+
/**
|
|
51
|
+
* Whether a parsed weights file has the shape the kit reads: every row has a
|
|
52
|
+
* weight per candidate, every bias a number per candidate, and three blend
|
|
53
|
+
* numbers per member (the tables plus the ranker) and one for the shell.
|
|
54
|
+
* @param {any} file
|
|
55
|
+
* @returns {file is import('./kit/weights.mjs').WeightsFile}
|
|
56
|
+
*/
|
|
57
|
+
export function isWeightsFile(file: any): file is import("./kit/weights.mjs").WeightsFile;
|
|
43
58
|
/**
|
|
44
59
|
* A page template the kit can recommend starting from.
|
|
45
60
|
*/
|
|
@@ -60,6 +75,10 @@ export type PageTemplate = {
|
|
|
60
75
|
* What the page is and how it is laid out.
|
|
61
76
|
*/
|
|
62
77
|
description: string;
|
|
78
|
+
/**
|
|
79
|
+
* The npm package that owns this template.
|
|
80
|
+
*/
|
|
81
|
+
package: string;
|
|
63
82
|
/**
|
|
64
83
|
* The template's own `Family - Variant` label; empty when it declares none.
|
|
65
84
|
*/
|
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';
|
|
@@ -27,6 +29,7 @@ import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
|
27
29
|
* @property {string} command `astryx template <id> --type page`, the command that selects exactly this template: an integration replacement is selected by the Core id it replaces, and `--type page` keeps a block with the same id from making it ambiguous. Search prints template commands the same way.
|
|
28
30
|
* @property {string} displayName Human-facing name.
|
|
29
31
|
* @property {string} description What the page is and how it is laid out.
|
|
32
|
+
* @property {string} package The npm package that owns this template.
|
|
30
33
|
* @property {string} category The template's own `Family - Variant` label; empty when it declares none.
|
|
31
34
|
* @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
|
|
32
35
|
*/
|
|
@@ -63,6 +66,7 @@ export async function loadPageTemplates(cwd) {
|
|
|
63
66
|
name: t.dirName,
|
|
64
67
|
displayName: t.displayName || t.name,
|
|
65
68
|
description: t.description || '',
|
|
69
|
+
package: t.package ?? '@astryxdesign/core',
|
|
66
70
|
category: t.category || '',
|
|
67
71
|
keywords: t.keywords ?? [],
|
|
68
72
|
// The id `template()` resolves back to this entry: an active replacement
|
|
@@ -89,3 +93,58 @@ export async function loadComponents(cwd) {
|
|
|
89
93
|
return [];
|
|
90
94
|
}
|
|
91
95
|
}
|
|
96
|
+
|
|
97
|
+
/** @type {import('./kit/weights.mjs').WeightsFile | null | undefined} */
|
|
98
|
+
let weights;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The matcher weights checked in beside the kit (`kit/weights.json`), read
|
|
102
|
+
* once; null when the file is absent or unreadable.
|
|
103
|
+
* @returns {import('./kit/weights.mjs').WeightsFile | null}
|
|
104
|
+
*/
|
|
105
|
+
export function loadWeights() {
|
|
106
|
+
if (weights === undefined) {
|
|
107
|
+
try {
|
|
108
|
+
const file = JSON.parse(
|
|
109
|
+
fs.readFileSync(new URL('./kit/weights.json', import.meta.url), 'utf8'),
|
|
110
|
+
);
|
|
111
|
+
weights = isWeightsFile(file) ? file : null;
|
|
112
|
+
} catch {
|
|
113
|
+
weights = null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return weights ?? null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Whether a parsed weights file has the shape the kit reads: every row has a
|
|
121
|
+
* weight per candidate, every bias a number per candidate, and three blend
|
|
122
|
+
* numbers per member (the tables plus the ranker) and one for the shell.
|
|
123
|
+
* @param {any} file
|
|
124
|
+
* @returns {file is import('./kit/weights.mjs').WeightsFile}
|
|
125
|
+
*/
|
|
126
|
+
export function isWeightsFile(file) {
|
|
127
|
+
const n = Array.isArray(file?.candidates) ? file.candidates.length : 0;
|
|
128
|
+
return (
|
|
129
|
+
n > 0 &&
|
|
130
|
+
Array.isArray(file.tables) &&
|
|
131
|
+
file.tables.length > 0 &&
|
|
132
|
+
file.tables.every(
|
|
133
|
+
(/** @type {any} */ t) =>
|
|
134
|
+
Array.isArray(t?.words) &&
|
|
135
|
+
Array.isArray(t.rows) &&
|
|
136
|
+
t.rows.length === t.words.length &&
|
|
137
|
+
t.rows.every(
|
|
138
|
+
(/** @type {any} */ r) => typeof r === 'string' && r.length === n,
|
|
139
|
+
) &&
|
|
140
|
+
Array.isArray(t.bias) &&
|
|
141
|
+
t.bias.length === n &&
|
|
142
|
+
t.bias.every((/** @type {any} */ b) => Number.isFinite(b)) &&
|
|
143
|
+
Number.isFinite(t.clip) &&
|
|
144
|
+
Number.isFinite(t.step),
|
|
145
|
+
) &&
|
|
146
|
+
Array.isArray(file.blend) &&
|
|
147
|
+
file.blend.length === 3 * (file.tables.length + 1) + 1 &&
|
|
148
|
+
file.blend.every((/** @type {any} */ x) => Number.isFinite(x))
|
|
149
|
+
);
|
|
150
|
+
}
|
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.
|
|
@@ -60,6 +60,10 @@ export type BuildStart = {
|
|
|
60
60
|
* What the page is: its layout and the ideas it serves.
|
|
61
61
|
*/
|
|
62
62
|
description: string;
|
|
63
|
+
/**
|
|
64
|
+
* The npm package that owns this template.
|
|
65
|
+
*/
|
|
66
|
+
package: string;
|
|
63
67
|
/**
|
|
64
68
|
* 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.
|
|
65
69
|
*/
|
|
@@ -93,6 +97,10 @@ export type BuildAlternative = {
|
|
|
93
97
|
* What the page is: its layout and the ideas it serves.
|
|
94
98
|
*/
|
|
95
99
|
description: string;
|
|
100
|
+
/**
|
|
101
|
+
* The npm package that owns this template.
|
|
102
|
+
*/
|
|
103
|
+
package: string;
|
|
96
104
|
/**
|
|
97
105
|
* The scaffold command, in the same form as the start's.
|
|
98
106
|
*/
|
package/api/build/build.type.mjs
CHANGED
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
* @property {string} name Template id, as `astryx template <name>` takes it.
|
|
43
43
|
* @property {string} displayName Human-facing template name.
|
|
44
44
|
* @property {string} description What the page is: its layout and the ideas it serves.
|
|
45
|
+
* @property {string} package The npm package that owns this template.
|
|
45
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.
|
|
46
47
|
* @property {'direct' | 'closest' | 'fallback'} basis Why this template. The page ranker picks every start: 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. `direct` when its pick is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when no template has the evidence to lead and the page starts from the app shell.
|
|
47
48
|
* @property {string} reason One sentence saying the same as `basis`, for a reader.
|
|
@@ -55,6 +56,7 @@
|
|
|
55
56
|
* @property {string} name Template id, as `astryx template <name>` takes it.
|
|
56
57
|
* @property {string} displayName Human-facing template name.
|
|
57
58
|
* @property {string} description What the page is: its layout and the ideas it serves.
|
|
59
|
+
* @property {string} package The npm package that owns this template.
|
|
58
60
|
* @property {string} command The scaffold command, in the same form as the start's.
|
|
59
61
|
*/
|
|
60
62
|
|
package/api/build/kit/kit.mjs
CHANGED
|
@@ -32,8 +32,15 @@ import {findCoreDir} from '../../../foundation/fs/paths.mjs';
|
|
|
32
32
|
import {AstryxError} from '../../error.mjs';
|
|
33
33
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
34
34
|
import {getResultCoverage} from '../../search/coverage.mjs';
|
|
35
|
-
import {loadComponents, loadPageTemplates} from '../_adapter.mjs';
|
|
36
|
-
import {
|
|
35
|
+
import {loadComponents, loadPageTemplates, loadWeights} from '../_adapter.mjs';
|
|
36
|
+
import {
|
|
37
|
+
asksForNewPage,
|
|
38
|
+
ideaKind,
|
|
39
|
+
pickAlternatives,
|
|
40
|
+
pickStart,
|
|
41
|
+
rankPages,
|
|
42
|
+
} from './rank.mjs';
|
|
43
|
+
import {weighStart} from './weights.mjs';
|
|
37
44
|
|
|
38
45
|
/** A page at/above this score is a confident direct match. */
|
|
39
46
|
const PAGE_DIRECT = 95;
|
|
@@ -113,6 +120,7 @@ const ALWAYS = new Set([...FRAME, ...FOUNDATION]);
|
|
|
113
120
|
*/
|
|
114
121
|
const asTemplate = t => ({
|
|
115
122
|
name: t.name,
|
|
123
|
+
package: t.package,
|
|
116
124
|
displayName: t.displayName,
|
|
117
125
|
description: t.description,
|
|
118
126
|
command: `${t.command} <path>`,
|
|
@@ -151,9 +159,10 @@ function placement(kind, inPage) {
|
|
|
151
159
|
* @param {SearchResultEntry[]} pages
|
|
152
160
|
* @param {boolean} directMatch
|
|
153
161
|
* @param {PageTemplate[]} catalog
|
|
162
|
+
* @param {string} idea
|
|
154
163
|
* @returns {Omit<BuildStart, 'alternatives'> | null}
|
|
155
164
|
*/
|
|
156
|
-
function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
165
|
+
function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
|
|
157
166
|
const direct = directMatch ? pages[0].name : null;
|
|
158
167
|
const unready =
|
|
159
168
|
direct && !catalog.some(t => t.name === direct) ? direct : null;
|
|
@@ -170,7 +179,27 @@ function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
|
170
179
|
direct && direct !== startName
|
|
171
180
|
? `Search matched \`${direct}\` by name, but ${place}`
|
|
172
181
|
: place[0].toUpperCase() + place.slice(1);
|
|
173
|
-
const
|
|
182
|
+
const proposed = pickStart(ranked, kind);
|
|
183
|
+
// The checked-in word weights (weights.mjs), blended with the ranker's
|
|
184
|
+
// scores, decide the start of a whole page. A part or an edit starts where
|
|
185
|
+
// the ranker's placement rules put it (spec:AST-048/FR3).
|
|
186
|
+
const weighed =
|
|
187
|
+
kind === 'page'
|
|
188
|
+
? weighStart(idea, ranked, proposed, catalog, {
|
|
189
|
+
weights: loadWeights(),
|
|
190
|
+
newPage: asksForNewPage(idea, catalog),
|
|
191
|
+
})
|
|
192
|
+
: undefined;
|
|
193
|
+
// A shell start keeps the shell the ranker named, if any, and never replaces
|
|
194
|
+
// the template the ranker chose for a page search matched directly.
|
|
195
|
+
const pick =
|
|
196
|
+
weighed === undefined
|
|
197
|
+
? proposed
|
|
198
|
+
: weighed === null
|
|
199
|
+
? proposed?.family === 'Shell' || (proposed && direct && !unready)
|
|
200
|
+
? proposed
|
|
201
|
+
: null
|
|
202
|
+
: (ranked.find(r => r.name === weighed) ?? proposed);
|
|
174
203
|
const closest = pick && catalog.find(t => t.name === pick.name);
|
|
175
204
|
if (pick && closest) {
|
|
176
205
|
const agrees = closest.name === direct;
|
|
@@ -194,7 +223,9 @@ function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
|
194
223
|
if (shell) {
|
|
195
224
|
// The shell can also be the ranker's best guess without the evidence to
|
|
196
225
|
// lead ("horizontal site navigation"); say so rather than "no match".
|
|
197
|
-
const nearest =
|
|
226
|
+
const nearest =
|
|
227
|
+
(ranked[0]?.name === shell.name && ranked[0].hits > 0) ||
|
|
228
|
+
(weighed === null && !!proposed && proposed.family !== 'Shell');
|
|
198
229
|
const place = placement(kind, false);
|
|
199
230
|
return {
|
|
200
231
|
...asTemplate(shell),
|
|
@@ -204,7 +235,9 @@ function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
|
204
235
|
: place
|
|
205
236
|
? placed(place, shell.name)
|
|
206
237
|
: direct
|
|
207
|
-
?
|
|
238
|
+
? weighed === null
|
|
239
|
+
? `Search matched \`${direct}\` by name, but the app shell is the closer start.`
|
|
240
|
+
: `Search matched \`${direct}\` by name, but too little of the idea fits it, so start from the app shell.`
|
|
208
241
|
: nearest
|
|
209
242
|
? 'No template is a clear match; the app shell is the closest.'
|
|
210
243
|
: loose
|
|
@@ -346,7 +379,7 @@ export async function buildKit(query, options = {}) {
|
|
|
346
379
|
)
|
|
347
380
|
: 'page';
|
|
348
381
|
const chosen = wantsPages
|
|
349
|
-
? chooseStart(ranked, kind, matchedPages, directMatch, catalog)
|
|
382
|
+
? chooseStart(ranked, kind, matchedPages, directMatch, catalog, query)
|
|
350
383
|
: null;
|
|
351
384
|
// Name the ranker's next two templates beside the start: the reader judges
|
|
352
385
|
// meaning better than keywords do, and an acceptable template is in these
|
package/api/build/kit/rank.d.mts
CHANGED
|
@@ -21,6 +21,14 @@ export function rankPages(query: string, pages: PageTemplate[]): RankedPage[];
|
|
|
21
21
|
* @returns {IdeaKind}
|
|
22
22
|
*/
|
|
23
23
|
export function ideaKind(query: string, pages: PageTemplate[], components: ComponentWords[]): IdeaKind;
|
|
24
|
+
/**
|
|
25
|
+
* Whether an idea asks for a new page (see `asksNewPage`), from the idea and
|
|
26
|
+
* the project's page templates.
|
|
27
|
+
* @param {string} query
|
|
28
|
+
* @param {PageTemplate[]} pages
|
|
29
|
+
* @returns {boolean}
|
|
30
|
+
*/
|
|
31
|
+
export function asksForNewPage(query: string, pages: PageTemplate[]): boolean;
|
|
24
32
|
/**
|
|
25
33
|
* The next closest templates after the start, best first: the ones a reader
|
|
26
34
|
* should check the idea against when the start's shape is wrong. Each matched
|
package/api/build/kit/rank.mjs
CHANGED
|
@@ -543,6 +543,20 @@ function asksNewPage(phrases, familyWords) {
|
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
545
|
|
|
546
|
+
/**
|
|
547
|
+
* Whether an idea asks for a new page (see `asksNewPage`), from the idea and
|
|
548
|
+
* the project's page templates.
|
|
549
|
+
* @param {string} query
|
|
550
|
+
* @param {PageTemplate[]} pages
|
|
551
|
+
* @returns {boolean}
|
|
552
|
+
*/
|
|
553
|
+
export function asksForNewPage(query, pages) {
|
|
554
|
+
return asksNewPage(
|
|
555
|
+
String(query).toLowerCase().split(PHRASE_END),
|
|
556
|
+
familyWordsOf(pages),
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
|
|
546
560
|
/**
|
|
547
561
|
* The words of a component's name: "DateRangeInput" is date, range, input.
|
|
548
562
|
* @param {ComponentWords} component
|