@astryxdesign/cli 0.6.5-canary.24fe2cd → 0.6.5-canary.2ad3b83
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 +13 -14
- package/api/build/_adapter.d.mts +2 -36
- package/api/build/_adapter.mjs +10 -41
- package/api/build/build.doc.mjs +2 -2
- package/api/build/build.test.mjs +2 -38
- package/api/build/kit/kit.mjs +21 -65
- package/api/build/kit/rank.d.mts +8 -24
- package/api/build/kit/rank.mjs +97 -277
- package/api/build/kit/rank.test.mjs +48 -231
- package/api/error.d.mts +0 -22
- package/api/error.mjs +0 -42
- package/api/integration/add-contribution.d.mts +1 -2
- package/api/integration/add-contribution.mjs +3 -7
- package/api/integration/add-contribution.test.mjs +3 -3
- package/api/integration/add-theme.mjs +22 -243
- package/api/integration/add-theme.test.mjs +0 -213
- package/api/integration/authoring-checks.mjs +7 -10
- package/api/integration/authoring-checks.type.d.mts +0 -8
- package/api/integration/authoring-checks.type.mjs +3 -7
- package/api/integration/integration-authoring.type.d.mts +1 -4
- package/api/integration/integration-authoring.type.mjs +1 -6
- package/api/integration/integrationAdd.doc.mjs +0 -6
- package/api/integration/integrationAddTheme.doc.mjs +0 -10
- package/api/integration/integrationComponentConflicts.doc.mjs +1 -1
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +2 -11
- package/api/integration/pack-check.test.mjs +1 -38
- package/api/integration/validate-integration.d.mts +2 -4
- package/api/integration/validate-integration.mjs +2 -7
- package/api/integration/validate-integration.test.mjs +0 -55
- package/api/integration/validate-integration.type.d.mts +0 -5
- package/api/integration/validate-integration.type.mjs +1 -5
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/layout/expand/expand.mjs +7 -12
- package/api/layout/layout.type.d.mts +0 -1
- package/api/layout/layout.type.mjs +0 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search.d.mts +0 -24
- package/api/search/search.mjs +1 -71
- package/api/swizzle/copy/copy.mjs +3 -66
- package/api/swizzle/swizzle.doc.mjs +0 -4
- package/api/template/copy/copy.mjs +8 -14
- package/api/template/show/show.mjs +4 -15
- package/api/template/template-integration.test.mjs +0 -14
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +2 -6
- package/api/template/template.mjs +0 -1
- package/api/template/template.type.d.mts +0 -2
- package/api/template/template.type.mjs +0 -2
- package/api/theme/build/build.d.mts +0 -24
- package/api/theme/build/build.mjs +8 -235
- package/api/upgrade/run/run.mjs +3 -20
- package/api/upgrade/run/run.test.mjs +1 -45
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.type.d.mts +0 -1
- package/api/upgrade/upgrade.type.mjs +0 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -13
- package/assets/docs/tree/troubleshooting.doc.mjs +3 -7
- package/assets/docs/tree/versioning.doc.mjs +6 -6
- package/assets/templates/pages/ai-chat/template.doc.mjs +1 -16
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +1 -9
- package/assets/templates/pages/blank/template.doc.mjs +1 -3
- package/assets/templates/pages/canvas-editor/template.doc.mjs +1 -9
- package/assets/templates/pages/centered-hero/template.doc.mjs +1 -3
- package/assets/templates/pages/checkout-wizard/template.doc.mjs +0 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -3
- package/assets/templates/pages/contact-form/template.doc.mjs +1 -16
- package/assets/templates/pages/dashboard/template.doc.mjs +1 -15
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +1 -23
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +1 -10
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +1 -9
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +1 -10
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +1 -17
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +1 -2
- package/assets/templates/pages/detail-page/template.doc.mjs +0 -8
- package/assets/templates/pages/documentation/template.doc.mjs +1 -10
- package/assets/templates/pages/documentation-design/template.doc.mjs +1 -10
- package/assets/templates/pages/documentation-technical/template.doc.mjs +1 -10
- package/assets/templates/pages/editor/template.doc.mjs +1 -9
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -3
- package/assets/templates/pages/form-two-column/template.doc.mjs +1 -17
- package/assets/templates/pages/form-wizard/template.doc.mjs +1 -14
- package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +0 -1
- package/assets/templates/pages/gallery-hero/template.doc.mjs +1 -10
- package/assets/templates/pages/ide/template.doc.mjs +1 -9
- package/assets/templates/pages/incident-console/template.doc.mjs +1 -10
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -11
- package/assets/templates/pages/library/template.doc.mjs +1 -15
- package/assets/templates/pages/login/template.doc.mjs +1 -10
- package/assets/templates/pages/login-card/template.doc.mjs +1 -11
- package/assets/templates/pages/login-split/template.doc.mjs +1 -10
- package/assets/templates/pages/login-sso/template.doc.mjs +1 -10
- package/assets/templates/pages/messaging-shell/template.doc.mjs +1 -11
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +1 -10
- package/assets/templates/pages/payment-form/template.doc.mjs +1 -3
- package/assets/templates/pages/product-detail/template.doc.mjs +1 -9
- package/assets/templates/pages/product-gallery/template.doc.mjs +1 -10
- package/assets/templates/pages/settings/template.doc.mjs +1 -3
- package/assets/templates/pages/settings-dialog/template.doc.mjs +1 -9
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +1 -9
- package/assets/templates/pages/shell-nav/template.doc.mjs +1 -10
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +1 -14
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +1 -11
- package/assets/templates/pages/side-gallery/template.doc.mjs +1 -3
- package/assets/templates/pages/table/template.doc.mjs +1 -11
- package/assets/templates/pages/table-filter/template.doc.mjs +1 -21
- package/assets/templates/pages/table-grouped/template.doc.mjs +1 -15
- package/assets/templates/pages/table-inbox/template.doc.mjs +6 -18
- package/assets/templates/pages/table-page/template.doc.mjs +1 -20
- package/assets/templates/pages/table-tree/template.doc.mjs +1 -14
- package/assets/templates/pages/theme-showcase/template.doc.mjs +1 -10
- package/assets/templates/pages/work-item-detail/template.doc.mjs +0 -10
- package/authoring/doctypes/template/parse.d.mts +0 -2
- package/authoring/doctypes/template/parse.mjs +0 -1
- package/authoring/doctypes/template/parse.test.mjs +0 -21
- package/authoring/doctypes/template/template.doc.mjs +0 -6
- package/authoring/doctypes/template/type.ts +0 -10
- package/clients/cli/commands/doctor.mjs +4 -4
- package/clients/cli/commands/integration-add.doc.mjs +0 -10
- package/clients/cli/commands/integration-authoring.test.mjs +2 -12
- package/clients/cli/commands/integration.mjs +1 -3
- package/clients/cli/commands/layout-expand.doc.mjs +1 -3
- package/clients/cli/commands/layout.mjs +0 -16
- package/clients/cli/commands/template.mjs +5 -19
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -14
- package/clients/cli/lib/manifest.mjs +165 -44
- package/clients/cli/lib/manifest.test.mjs +7 -98
- package/foundation/discovery/template-adapter.d.mts +0 -14
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +1 -37
- package/foundation/discovery/template-adapter.mjs +1 -21
- package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
- package/foundation/integrations/cli-requirement.d.mts +11 -23
- package/foundation/integrations/cli-requirement.mjs +18 -40
- package/foundation/integrations/cli-requirement.test.mjs +15 -66
- package/foundation/response/response-types.doc.d.mts +5 -5
- package/foundation/response/response-types.doc.mjs +13 -13
- package/package.json +9 -9
- package/api/docs/docs.test.mjs +0 -279
- package/api/docs/integration-tree.test.mjs +0 -572
- package/api/docs/integrationDocs.test.mjs +0 -336
- package/api/layout/expand/expand.receipt.test.mjs +0 -74
- package/api/search/search.test.mjs +0 -710
- package/api/template/copy/copy.receipt.test.mjs +0 -77
- package/api/template/show/show.test.mjs +0 -76
- package/api/theme/build/build.project-core.test.mjs +0 -165
- package/clients/cli/commands/docs.test.mjs +0 -383
- package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
- package/clients/cli/commands/template.copy-receipt.test.mjs +0 -60
- package/clients/cli/commands/template.show-media.test.mjs +0 -62
- package/clients/cli/commands/write-failure.test.mjs +0 -175
- package/foundation/agent-docs/agent-docs.test.mjs +0 -1160
- package/foundation/doc-compiler/tree.test.mjs +0 -649
package/README.md
CHANGED
|
@@ -303,12 +303,11 @@ Shape:
|
|
|
303
303
|
```
|
|
304
304
|
|
|
305
305
|
The manifest is **derived from Commander metadata** (commands, arguments, options)
|
|
306
|
-
so it can't drift from the real command definitions. The facts Commander
|
|
307
|
-
track
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
command is added without describing it.
|
|
306
|
+
so it can't drift from the real command definitions. The two facts Commander
|
|
307
|
+
doesn't track (`--json` support and emitted response types) are layered on from
|
|
308
|
+
the `JSON_SUPPORTED` allowlist and a small declarative `RESPONSE_TYPES` map in
|
|
309
|
+
`src/lib/manifest.mjs`, guarded by a drift test (`manifest.test.mjs`) so adding a
|
|
310
|
+
command without describing it fails CI.
|
|
312
311
|
|
|
313
312
|
**Backwards-compat:** the bare `astryx --json` envelope keeps `type: "help"` and its
|
|
314
313
|
original shallow fields (`name`, `version`, `commands` as a `string[]` of names,
|
|
@@ -451,9 +450,9 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
451
450
|
| `gap-report.categories` | The fixed gap category values and human-readable labels. |
|
|
452
451
|
| `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
452
|
| `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
|
-
| `template.show` | The resolved template's source
|
|
453
|
+
| `template.show` | The resolved template's raw source plus its description, kind, and the component names it composes. |
|
|
455
454
|
| `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
|
|
455
|
+
| `template.copy` | A scaffold receipt: template id, output directory, written file name, and file count. |
|
|
457
456
|
| `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
457
|
| `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
458
|
| `hook.detail` | One hook's full authored HookDoc. |
|
|
@@ -469,18 +468,18 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
469
468
|
| `upgrade.list` | Every available codemod, oldest→newest, as {name, title, version, optional}; returned for --list without running anything. |
|
|
470
469
|
| `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
470
|
| `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
|
-
| `upgrade.run` | The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary,
|
|
471
|
+
| `upgrade.run` | The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, and (apply mode) filesChanged, transformsApplied, and per-codemod errors. |
|
|
473
472
|
| `manifest` | The CLI capability manifest: name, version, apiVersion, description, globalOptions, commands (each name, description, arguments, options, json, aliases?, responseTypes?, examples?, exitCodes? as [{code, when}], subcommands?), jsonSupported, and the flat responseTypes index. |
|
|
474
473
|
| `help` | Help, in one of two shapes. A bare `astryx --json` returns the root manifest: name, version, commands (the command names), jsonSupported, and manifest (the full payload `astryx manifest --json` returns). `--help --json` on any command, or `astryx help [command] --json`, returns that command's help: command, description, usage, options (each flags, description, and defaultValue and choices when set), and subcommands (each name and description). data.manifest marks the first shape; data.usage marks the second. |
|
|
475
474
|
| `version` | The CLI version, for `astryx --version --json`: {version}. |
|
|
476
475
|
| `doctor` | The health-check report: `checks` (each with id, label, status: pass \| warn \| fail \| info, a message, and an optional fix, always present on warn and fail) plus a `summary` of counts per status. |
|
|
477
476
|
| `integration.add` | A contribution-writer receipt: kind, name, optional root {path, created}, integration-manifest path, every affected project-relative path, written, and dryRun. |
|
|
478
477
|
| `integration.pack-check` | The packed-package check: name, version, packable, tarball {filename, fileCount, size, unpackedSize} or null, inventory {manifest, roots [{kind, path, expectedFiles, missingFiles, complete}], expectedFiles, packedFiles}, contributions {local, packed}, each null or {themes [{slug, exportName}], components, templates [{id, type, name}], codemods [{version, id}], docs, agentDocsAppend}, and issues [{code, severity, message}]. |
|
|
479
|
-
| `integration.validate` | The validation result:
|
|
480
|
-
| `integration.template-conflicts` |
|
|
481
|
-
| `integration.component-conflicts` |
|
|
482
|
-
| `integration.doc-conflicts` |
|
|
483
|
-
| `layout.expand` | The expansion: parsed form, generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, written (the output path, or null when nothing was written)
|
|
478
|
+
| `integration.validate` | The validation result: the package name and version (both null when no local manifest is found) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning \| error, message}. |
|
|
479
|
+
| `integration.template-conflicts` | The integration identity, structural issues, and non-blocking Core template-id conflicts as {id, severity: warning, integrationPackage, integrationType, integrationName, coreMatches, message, command}. |
|
|
480
|
+
| `integration.component-conflicts` | The integration identity, structural issues, and non-blocking conflicts where an integration component name is also owned by Core; each conflict includes the exact package-qualified command. |
|
|
481
|
+
| `integration.doc-conflicts` | The integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` \| `error`) and `relationship` (`replaces` \| `extends` \| `accidental`). |
|
|
482
|
+
| `layout.expand` | The expansion: parsed form, generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, and written (the output path, or null when nothing was written). |
|
|
484
483
|
| `layout.check` | The validation result: a valid flag, the detected form, errors (each with line/col, message, formatted text, and suggestions), warnings, and the expression re-printed in both canonical surfaces (compact and outline). |
|
|
485
484
|
| `layout.grammar` | The XLE/XLO grammar cheatsheet: a text field with the full reference plus an aliases map (short name → canonical component) generated from this install's registry. |
|
|
486
485
|
|
package/api/build/_adapter.d.mts
CHANGED
|
@@ -7,15 +7,8 @@
|
|
|
7
7
|
* @property {string} name The template's own id, as search reports it.
|
|
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
|
-
* @property {string} description What the page is and
|
|
10
|
+
* @property {string} description What the page is: its layout and the ideas it serves.
|
|
11
11
|
* @property {string} category The template's own `Family - Variant` label; empty when it declares none.
|
|
12
|
-
* @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* A component the project can use, as the ranker reads it.
|
|
16
|
-
* @typedef {object} ComponentWords
|
|
17
|
-
* @property {string} name The component's name, e.g. `DateRangeInput`.
|
|
18
|
-
* @property {string[]} keywords The keywords its own doc declares.
|
|
19
12
|
*/
|
|
20
13
|
/**
|
|
21
14
|
* Every ready page template the project can scaffold, in discovery order. This
|
|
@@ -30,16 +23,6 @@
|
|
|
30
23
|
* @returns {Promise<PageTemplate[]>}
|
|
31
24
|
*/
|
|
32
25
|
export function loadPageTemplates(cwd: string): Promise<PageTemplate[]>;
|
|
33
|
-
/**
|
|
34
|
-
* The components the project can use, Core's and its integrations', each with
|
|
35
|
-
* the keywords its own doc declares: what the ranker reads to tell a part of a
|
|
36
|
-
* page from a page. Search's own discovery, so both agree on what exists; empty
|
|
37
|
-
* when Core cannot be found.
|
|
38
|
-
*
|
|
39
|
-
* @param {string} cwd
|
|
40
|
-
* @returns {Promise<ComponentWords[]>}
|
|
41
|
-
*/
|
|
42
|
-
export function loadComponents(cwd: string): Promise<ComponentWords[]>;
|
|
43
26
|
/**
|
|
44
27
|
* A page template the kit can recommend starting from.
|
|
45
28
|
*/
|
|
@@ -57,28 +40,11 @@ export type PageTemplate = {
|
|
|
57
40
|
*/
|
|
58
41
|
displayName: string;
|
|
59
42
|
/**
|
|
60
|
-
* What the page is and
|
|
43
|
+
* What the page is: its layout and the ideas it serves.
|
|
61
44
|
*/
|
|
62
45
|
description: string;
|
|
63
46
|
/**
|
|
64
47
|
* The template's own `Family - Variant` label; empty when it declares none.
|
|
65
48
|
*/
|
|
66
49
|
category: string;
|
|
67
|
-
/**
|
|
68
|
-
* The ideas the page serves, as its own descriptor names them; empty when it declares none.
|
|
69
|
-
*/
|
|
70
|
-
keywords: string[];
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* A component the project can use, as the ranker reads it.
|
|
74
|
-
*/
|
|
75
|
-
export type ComponentWords = {
|
|
76
|
-
/**
|
|
77
|
-
* The component's name, e.g. `DateRangeInput`.
|
|
78
|
-
*/
|
|
79
|
-
name: string;
|
|
80
|
-
/**
|
|
81
|
-
* The keywords its own doc declares.
|
|
82
|
-
*/
|
|
83
|
-
keywords: string[];
|
|
84
50
|
};
|
package/api/build/_adapter.mjs
CHANGED
|
@@ -2,23 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file The build subject's environment access: the page templates a project
|
|
5
|
-
* can scaffold
|
|
5
|
+
* can scaffold.
|
|
6
6
|
*
|
|
7
|
-
* @input Template
|
|
8
|
-
*
|
|
9
|
-
* contribute.
|
|
7
|
+
* @input Template discovery for `cwd` — the CLI's own templates plus any that
|
|
8
|
+
* the project's configured integrations contribute.
|
|
10
9
|
* @output Ready page templates as `{name, displayName, description, category,
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @position Beside build.mjs (api/build/). The kit leaf reads templates
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* command}`, where `command` is the `astryx template` command that selects
|
|
11
|
+
* exactly that template.
|
|
12
|
+
* @position Beside build.mjs (api/build/). The kit leaf reads templates only
|
|
13
|
+
* through here, because a subject's `_adapter.mjs` is its only environment
|
|
14
|
+
* access. Search keeps its own discovery; this adds none of its own, it
|
|
15
|
+
* reuses the template subject's.
|
|
17
16
|
*/
|
|
18
17
|
|
|
19
18
|
import {discoverTemplates} from '../template/template.mjs';
|
|
20
|
-
import {componentKeywords} from '../search/search.mjs';
|
|
21
|
-
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
22
19
|
|
|
23
20
|
/**
|
|
24
21
|
* A page template the kit can recommend starting from.
|
|
@@ -26,16 +23,8 @@ import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
|
26
23
|
* @property {string} name The template's own id, as search reports it.
|
|
27
24
|
* @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
25
|
* @property {string} displayName Human-facing name.
|
|
29
|
-
* @property {string} description What the page is and
|
|
26
|
+
* @property {string} description What the page is: its layout and the ideas it serves.
|
|
30
27
|
* @property {string} category The template's own `Family - Variant` label; empty when it declares none.
|
|
31
|
-
* @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* A component the project can use, as the ranker reads it.
|
|
36
|
-
* @typedef {object} ComponentWords
|
|
37
|
-
* @property {string} name The component's name, e.g. `DateRangeInput`.
|
|
38
|
-
* @property {string[]} keywords The keywords its own doc declares.
|
|
39
28
|
*/
|
|
40
29
|
|
|
41
30
|
/**
|
|
@@ -64,28 +53,8 @@ export async function loadPageTemplates(cwd) {
|
|
|
64
53
|
displayName: t.displayName || t.name,
|
|
65
54
|
description: t.description || '',
|
|
66
55
|
category: t.category || '',
|
|
67
|
-
keywords: t.keywords ?? [],
|
|
68
56
|
// The id `template()` resolves back to this entry: an active replacement
|
|
69
57
|
// owns the Core id it names, so that id selects it, not its own.
|
|
70
58
|
command: `astryx template ${t.replaces ?? t.dirName} --type page`,
|
|
71
59
|
}));
|
|
72
60
|
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* The components the project can use, Core's and its integrations', each with
|
|
76
|
-
* the keywords its own doc declares: what the ranker reads to tell a part of a
|
|
77
|
-
* page from a page. Search's own discovery, so both agree on what exists; empty
|
|
78
|
-
* when Core cannot be found.
|
|
79
|
-
*
|
|
80
|
-
* @param {string} cwd
|
|
81
|
-
* @returns {Promise<ComponentWords[]>}
|
|
82
|
-
*/
|
|
83
|
-
export async function loadComponents(cwd) {
|
|
84
|
-
const coreDir = findCoreDir(cwd);
|
|
85
|
-
if (!coreDir) return [];
|
|
86
|
-
try {
|
|
87
|
-
return await componentKeywords(coreDir, cwd);
|
|
88
|
-
} catch {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
}
|
package/api/build/build.doc.mjs
CHANGED
|
@@ -19,8 +19,8 @@ export const doc = {
|
|
|
19
19
|
'The "build a page" entry point. Called with no query it returns the ' +
|
|
20
20
|
'how-to-build-a-page playbook as data: the workflow steps with their ' +
|
|
21
21
|
'commands, the on-system rules, and related lookups. Called with a query it names the page template to ' +
|
|
22
|
-
'START from (always one: the page template a ranker built for long descriptions puts first
|
|
23
|
-
'
|
|
22
|
+
'START from (always one: the page template a ranker built for long descriptions puts first, else the app ' +
|
|
23
|
+
'shell) and the next two templates, ' +
|
|
24
24
|
'and the unified search grouped around it: the other close page templates, drop-in blocks, and ' +
|
|
25
25
|
'idea-specific components/hooks, plus the always-on frame + foundation. A template carries the page ' +
|
|
26
26
|
'frame and spacing, so the kit never recommends composing a page from components.',
|
package/api/build/build.test.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import {describe, it, expect, vi} from 'vitest';
|
|
|
8
8
|
import * as path from 'node:path';
|
|
9
9
|
import {fileURLToPath} from 'node:url';
|
|
10
10
|
import {build} from './build.mjs';
|
|
11
|
-
import {search
|
|
11
|
+
import {search} from '../search/search.mjs';
|
|
12
12
|
|
|
13
13
|
// api/build/ -> up 3 = packages/cli, up 4 = repo root (has packages/core).
|
|
14
14
|
const REPO = path.resolve(
|
|
@@ -152,16 +152,6 @@ describe('build API', () => {
|
|
|
152
152
|
});
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
describe('build kit — reuses the components its search gathered', () => {
|
|
156
|
-
it('keeps them beside the search response, out of its JSON', async () => {
|
|
157
|
-
const all = await search('date picker', {cwd: REPO});
|
|
158
|
-
expect(searchedComponents(all)?.map(c => c.name)).toContain('DateRangeInput');
|
|
159
|
-
expect(JSON.stringify(all)).not.toContain('"keywords"');
|
|
160
|
-
const pagesOnly = await search('date picker', {cwd: REPO, type: 'template'});
|
|
161
|
-
expect(searchedComponents(pagesOnly)).toBeNull();
|
|
162
|
-
}, 60_000);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
155
|
describe('build kit — coverage gates the pages group', () => {
|
|
166
156
|
it('does not call a one-word coincidence a direct match', async () => {
|
|
167
157
|
// A page's keywords include every component its source renders, so any
|
|
@@ -269,7 +259,7 @@ describe('build kit — a thin kit says what to try next', () => {
|
|
|
269
259
|
// A skeleton is a 35-line excerpt: a reader who studies it and composes
|
|
270
260
|
// the rest loses the spacing the template exists to carry. A loose match
|
|
271
261
|
// is still the best start there is, so `start` scaffolds it.
|
|
272
|
-
const r = await build('
|
|
262
|
+
const r = await build('executive summary', {cwd: REPO});
|
|
273
263
|
expect(r.type).toBe('build.kit');
|
|
274
264
|
if (r.type !== 'build.kit') return;
|
|
275
265
|
expect(r.data.directMatch).toBe(false);
|
|
@@ -367,35 +357,9 @@ describe('build kit — every page starts from a template', () => {
|
|
|
367
357
|
const placed = await build('an empty state for a settings page', {cwd: REPO});
|
|
368
358
|
if (placed.type !== 'build.kit') throw new Error(placed.type);
|
|
369
359
|
expect(placed.data.start).toMatchObject({name: 'settings', basis: 'closest'});
|
|
370
|
-
expect(placed.data.start?.reason).toMatch(/part of a page, so it starts from the page it names/);
|
|
371
360
|
const loose = await build('a date range picker', {cwd: REPO});
|
|
372
361
|
if (loose.type !== 'build.kit') throw new Error(loose.type);
|
|
373
362
|
expect(loose.data.start).toMatchObject({name: 'shell-top-nav', basis: 'fallback'});
|
|
374
|
-
expect(loose.data.start?.reason).toMatch(/part of a page and names no page, so it starts from the app shell/);
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
it('starts a change to an existing page from the app shell', async () => {
|
|
378
|
-
// The page is the builder's to keep; no template scaffolds it.
|
|
379
|
-
const r = await build('add a sort toggle to the existing reports dashboard', {cwd: REPO});
|
|
380
|
-
if (r.type !== 'build.kit') throw new Error(r.type);
|
|
381
|
-
expect(r.data.start).toMatchObject({name: 'shell-top-nav', basis: 'fallback'});
|
|
382
|
-
expect(r.data.start?.reason).toMatch(/changes a page you already have, so keep it/);
|
|
383
|
-
expect(r.data.start?.reason).not.toMatch(/too little of the idea fits/);
|
|
384
|
-
// A direct match the response reports is still named.
|
|
385
|
-
if (r.data.directMatch) expect(r.data.start?.reason).toContain(`\`${r.data.pages[0].name}\``);
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
it('does not call a new page that mentions something existing a change', async () => {
|
|
389
|
-
for (const idea of [
|
|
390
|
-
'a new dashboard inspired by the existing one',
|
|
391
|
-
'a new dashboard based on the existing dashboard',
|
|
392
|
-
'clone the existing dashboard as a new page',
|
|
393
|
-
]) {
|
|
394
|
-
const r = await build(idea, {cwd: REPO});
|
|
395
|
-
if (r.type !== 'build.kit') throw new Error(r.type);
|
|
396
|
-
expect(r.data.start?.name).toBe('dashboard');
|
|
397
|
-
expect(r.data.start?.reason).not.toMatch(/already have/);
|
|
398
|
-
}
|
|
399
363
|
});
|
|
400
364
|
|
|
401
365
|
it('names a direct match the ranker outweighed in the reason', async () => {
|
package/api/build/kit/kit.mjs
CHANGED
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
* the invocation stays the renderer's job.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
import {search
|
|
30
|
+
import {search} from '../../search/search.mjs';
|
|
31
31
|
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 {
|
|
36
|
-
import {
|
|
35
|
+
import {loadPageTemplates} from '../_adapter.mjs';
|
|
36
|
+
import {pickAlternatives, pickStart, rankPages} from './rank.mjs';
|
|
37
37
|
|
|
38
38
|
/** A page at/above this score is a confident direct match. */
|
|
39
39
|
const PAGE_DIRECT = 95;
|
|
@@ -118,24 +118,6 @@ const asTemplate = t => ({
|
|
|
118
118
|
command: `${t.command} <path>`,
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
-
/**
|
|
122
|
-
* Why a part of a page, or a change to a page the builder already has, starts
|
|
123
|
-
* where it does (spec:AST-048/FR3, FR9): the rest of the start's reason, or
|
|
124
|
-
* null for a whole page.
|
|
125
|
-
* @param {import('./rank.mjs').IdeaKind} kind
|
|
126
|
-
* @param {boolean} inPage whether the start is the page the idea names
|
|
127
|
-
* @returns {string | null}
|
|
128
|
-
*/
|
|
129
|
-
function placement(kind, inPage) {
|
|
130
|
-
if (kind === 'edit')
|
|
131
|
-
return 'the idea changes a page you already have, so keep it and add blocks to it; a new page starts from the app shell.';
|
|
132
|
-
if (kind === 'part')
|
|
133
|
-
return inPage
|
|
134
|
-
? 'the idea is a part of a page, so it starts from the page it names.'
|
|
135
|
-
: 'the idea is a part of a page and names no page, so it starts from the app shell.';
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
121
|
/**
|
|
140
122
|
* The template to start from: the ready page the ranker puts first when it
|
|
141
123
|
* has the evidence to lead, else the first fallback shell the project can
|
|
@@ -147,13 +129,12 @@ function placement(kind, inPage) {
|
|
|
147
129
|
* the reason names it, so the reader knows why the kit starts elsewhere.
|
|
148
130
|
*
|
|
149
131
|
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
150
|
-
* @param {import('./rank.mjs').IdeaKind} kind
|
|
151
132
|
* @param {SearchResultEntry[]} pages
|
|
152
133
|
* @param {boolean} directMatch
|
|
153
134
|
* @param {PageTemplate[]} catalog
|
|
154
135
|
* @returns {Omit<BuildStart, 'alternatives'> | null}
|
|
155
136
|
*/
|
|
156
|
-
function chooseStart(ranked,
|
|
137
|
+
function chooseStart(ranked, pages, directMatch, catalog) {
|
|
157
138
|
const direct = directMatch ? pages[0].name : null;
|
|
158
139
|
const unready =
|
|
159
140
|
direct && !catalog.some(t => t.name === direct) ? direct : null;
|
|
@@ -161,32 +142,20 @@ function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
|
161
142
|
// match the ranker outweighed is named, and so are the loose page matches
|
|
162
143
|
// search listed when the kit falls back to the shell.
|
|
163
144
|
const loose = pages.map(p => `\`${p.name}\``).join(', ');
|
|
164
|
-
|
|
165
|
-
* A part's or an edit's reason, naming a direct match that is not the start.
|
|
166
|
-
* @param {string} place
|
|
167
|
-
* @param {string} startName
|
|
168
|
-
*/
|
|
169
|
-
const placed = (place, startName) =>
|
|
170
|
-
direct && direct !== startName
|
|
171
|
-
? `Search matched \`${direct}\` by name, but ${place}`
|
|
172
|
-
: place[0].toUpperCase() + place.slice(1);
|
|
173
|
-
const pick = pickStart(ranked, kind);
|
|
145
|
+
const pick = pickStart(ranked);
|
|
174
146
|
const closest = pick && catalog.find(t => t.name === pick.name);
|
|
175
|
-
if (
|
|
147
|
+
if (closest) {
|
|
176
148
|
const agrees = closest.name === direct;
|
|
177
|
-
const place = placement(kind, pick.base && pick.familyNamed);
|
|
178
149
|
return {
|
|
179
150
|
...asTemplate(closest),
|
|
180
151
|
basis: agrees ? 'direct' : 'closest',
|
|
181
|
-
reason:
|
|
182
|
-
?
|
|
183
|
-
:
|
|
184
|
-
?
|
|
185
|
-
:
|
|
186
|
-
?
|
|
187
|
-
:
|
|
188
|
-
? `Search matched \`${direct}\` by name, but this template fits more of the idea.`
|
|
189
|
-
: 'The closest template; none is exactly this page.',
|
|
152
|
+
reason: agrees
|
|
153
|
+
? 'Matches the idea.'
|
|
154
|
+
: unready
|
|
155
|
+
? `\`${unready}\` matches but is not ready yet; this is the closest ready template.`
|
|
156
|
+
: direct
|
|
157
|
+
? `Search matched \`${direct}\` by name, but this template fits more of the idea.`
|
|
158
|
+
: 'The closest template; none is exactly this page.',
|
|
190
159
|
};
|
|
191
160
|
}
|
|
192
161
|
for (const id of FALLBACK_STARTS) {
|
|
@@ -195,21 +164,18 @@ function chooseStart(ranked, kind, pages, directMatch, catalog) {
|
|
|
195
164
|
// The shell can also be the ranker's best guess without the evidence to
|
|
196
165
|
// lead ("horizontal site navigation"); say so rather than "no match".
|
|
197
166
|
const nearest = ranked[0]?.name === shell.name && ranked[0].hits > 0;
|
|
198
|
-
const place = placement(kind, false);
|
|
199
167
|
return {
|
|
200
168
|
...asTemplate(shell),
|
|
201
169
|
basis: 'fallback',
|
|
202
170
|
reason: unready
|
|
203
171
|
? `\`${unready}\` matches but is not ready yet, so start from the app shell.`
|
|
204
|
-
:
|
|
205
|
-
?
|
|
206
|
-
:
|
|
207
|
-
?
|
|
208
|
-
:
|
|
209
|
-
?
|
|
210
|
-
:
|
|
211
|
-
? `Search matched ${loose} only loosely, so start from the app shell.`
|
|
212
|
-
: 'No template matched, so start from the app shell.',
|
|
172
|
+
: direct
|
|
173
|
+
? `Search matched \`${direct}\` by name, but too little of the idea fits it, so start from the app shell.`
|
|
174
|
+
: nearest
|
|
175
|
+
? 'No template is a clear match; the app shell is the closest.'
|
|
176
|
+
: loose
|
|
177
|
+
? `Search matched ${loose} only loosely, so start from the app shell.`
|
|
178
|
+
: 'No template matched, so start from the app shell.',
|
|
213
179
|
};
|
|
214
180
|
}
|
|
215
181
|
}
|
|
@@ -335,18 +301,8 @@ export async function buildKit(query, options = {}) {
|
|
|
335
301
|
const wantsPages = !type || type === 'template';
|
|
336
302
|
const catalog = wantsPages ? await loadPageTemplates(cwd) : [];
|
|
337
303
|
const ranked = wantsPages ? rankPages(query, catalog) : [];
|
|
338
|
-
// A part of a page starts where it lives (spec:AST-048/FR3); the project's
|
|
339
|
-
// own components say what a part is. The search above already gathered them
|
|
340
|
-
// unless it was narrowed to templates.
|
|
341
|
-
const kind = wantsPages
|
|
342
|
-
? ideaKind(
|
|
343
|
-
query,
|
|
344
|
-
catalog,
|
|
345
|
-
searchedComponents(result) ?? (await loadComponents(cwd)),
|
|
346
|
-
)
|
|
347
|
-
: 'page';
|
|
348
304
|
const chosen = wantsPages
|
|
349
|
-
? chooseStart(ranked,
|
|
305
|
+
? chooseStart(ranked, matchedPages, directMatch, catalog)
|
|
350
306
|
: null;
|
|
351
307
|
// Name the ranker's next two templates beside the start: the reader judges
|
|
352
308
|
// meaning better than keywords do, and an acceptable template is in these
|
package/api/build/kit/rank.d.mts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import('../_adapter.mjs').PageTemplate} PageTemplate
|
|
6
|
+
* @typedef {{name: string, score: number, hits: number, familyNamed: boolean, containerMatched: boolean}} RankedPage
|
|
7
|
+
*/
|
|
4
8
|
/**
|
|
5
9
|
* Rank page templates against an idea, best first. Ties go to the template
|
|
6
10
|
* with the shorter id (the family's broader page), then by name.
|
|
@@ -10,17 +14,6 @@
|
|
|
10
14
|
* @returns {RankedPage[]}
|
|
11
15
|
*/
|
|
12
16
|
export function rankPages(query: string, pages: PageTemplate[]): RankedPage[];
|
|
13
|
-
/**
|
|
14
|
-
* What an idea asks for (spec:AST-048/FR3): a whole `page`; a `part` of one,
|
|
15
|
-
* when its head noun names one of the system's components and it lists fewer
|
|
16
|
-
* than PAGE_PIECES pieces; or an `edit` of a page the builder already has.
|
|
17
|
-
*
|
|
18
|
-
* @param {string} query
|
|
19
|
-
* @param {PageTemplate[]} pages
|
|
20
|
-
* @param {ComponentWords[]} components
|
|
21
|
-
* @returns {IdeaKind}
|
|
22
|
-
*/
|
|
23
|
-
export function ideaKind(query: string, pages: PageTemplate[], components: ComponentWords[]): IdeaKind;
|
|
24
17
|
/**
|
|
25
18
|
* The next closest templates after the start, best first: the ones a reader
|
|
26
19
|
* should check the idea against when the start's shape is wrong. Each matched
|
|
@@ -33,28 +26,19 @@ export function ideaKind(query: string, pages: PageTemplate[], components: Compo
|
|
|
33
26
|
*/
|
|
34
27
|
export function pickAlternatives(ranked: RankedPage[], startName: string, count?: number): RankedPage[];
|
|
35
28
|
/**
|
|
36
|
-
* The template to start from, or null
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* the idea places it in, else from the app shell (spec:AST-048/FR3); an edit of
|
|
40
|
-
* a page the builder already has starts from the app shell (FR9). Either way,
|
|
41
|
-
* the app shell is the shell template the idea describes when one leads.
|
|
29
|
+
* The template to start from, or null when the best one has too little
|
|
30
|
+
* evidence to lead and the page should start from the app shell. Evidence is
|
|
31
|
+
* two matched terms, the idea naming the template's family, or its container.
|
|
42
32
|
*
|
|
43
33
|
* @param {RankedPage[]} ranked
|
|
44
|
-
* @param {IdeaKind} [kind]
|
|
45
34
|
* @returns {RankedPage | null}
|
|
46
35
|
*/
|
|
47
|
-
export function pickStart(ranked: RankedPage[]
|
|
36
|
+
export function pickStart(ranked: RankedPage[]): RankedPage | null;
|
|
48
37
|
export type PageTemplate = import("../_adapter.mjs").PageTemplate;
|
|
49
|
-
export type ComponentWords = import("../_adapter.mjs").ComponentWords;
|
|
50
38
|
export type RankedPage = {
|
|
51
39
|
name: string;
|
|
52
40
|
score: number;
|
|
53
41
|
hits: number;
|
|
54
42
|
familyNamed: boolean;
|
|
55
43
|
containerMatched: boolean;
|
|
56
|
-
family: string;
|
|
57
|
-
base: boolean;
|
|
58
|
-
matched: Set<string>;
|
|
59
44
|
};
|
|
60
|
-
export type IdeaKind = "page" | "part" | "edit";
|