@astryxdesign/cli 0.7.17-canary.gcfcba64 → 0.7.17-canary.geeb3d7c
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/api/build/_adapter.d.mts +7 -0
- package/api/build/_adapter.mjs +2 -0
- package/api/build/build.doc.mjs +2 -2
- package/api/build/build.type.d.mts +2 -2
- package/api/build/build.type.mjs +3 -3
- package/api/build/kit/kind.d.mts +2 -1
- package/api/build/kit/kind.mjs +116 -9
- package/api/build/kit/kit.mjs +6 -4
- package/api/build/kit/rank.mjs +10 -4
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/component/list/list.mjs +2 -1
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.mjs +2 -1
- package/api/doctor/_adapter.mjs +6 -4
- package/api/doctor/built-checks.mjs +2 -1
- package/api/icon/_records.mjs +2 -1
- package/api/integration/authoring-checks.mjs +6 -6
- package/api/integration/validate-integration.mjs +2 -1
- package/api/render/_adapter.mjs +90 -17
- package/api/render/render.doc.mjs +1 -1
- package/api/render/render.type.d.mts +23 -1
- package/api/render/render.type.mjs +12 -1
- package/api/search/_gather-components.d.mts +3 -2
- package/api/search/_gather-components.mjs +12 -3
- package/api/search/_lexical.d.mts +5 -0
- package/api/search/_lexical.mjs +8 -2
- package/api/search/_result.d.mts +6 -4
- package/api/search/_result.mjs +4 -4
- package/api/search/search-index.mjs +7 -1
- package/api/theme/_adapter.mjs +2 -1
- package/api/theme/build/build.d.mts +13 -0
- package/api/theme/build/build.mjs +60 -28
- package/api/theme/build/font-warning.d.mts +8 -0
- package/api/theme/build/font-warning.mjs +19 -0
- package/api/theme-edit/_adapter.d.mts +7 -0
- package/api/theme-edit/_adapter.mjs +95 -97
- package/api/theme-edit/_check.mjs +414 -97
- package/api/theme-edit/_color.d.mts +1 -0
- package/api/theme-edit/_color.mjs +8 -0
- package/api/theme-edit/_edit.mjs +533 -200
- package/api/theme-edit/_how-commands.mjs +62 -11
- package/api/theme-edit/_how-question.d.mts +15 -2
- package/api/theme-edit/_how-question.mjs +390 -85
- package/api/theme-edit/_how.mjs +31 -5
- package/api/theme-edit/_normal.d.mts +74 -8
- package/api/theme-edit/_normal.mjs +425 -45
- package/api/theme-edit/_playwright-picture.d.mts +4 -0
- package/api/theme-edit/_playwright-picture.mjs +34 -0
- package/api/theme-edit/_preview-app.mjs +194 -62
- package/api/theme-edit/_preview.d.mts +6 -1
- package/api/theme-edit/_preview.mjs +115 -50
- package/api/theme-edit/_settings.d.mts +72 -6
- package/api/theme-edit/_settings.mjs +493 -33
- package/api/theme-edit/_tables.mjs +12 -0
- package/api/theme-edit/_vet.d.mts +18 -0
- package/api/theme-edit/_vet.mjs +32 -0
- package/api/theme-edit/themeEditHow.doc.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
- package/api/upgrade/run/run.mjs +4 -3
- package/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/tree/render-pages.doc.mjs +2 -2
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
- package/assets/templates/components.generated.json +1 -1
- package/assets/theme.template.ts +6 -0
- package/authoring/doctypes/component/categories.d.mts +37 -0
- package/authoring/doctypes/component/categories.mjs +54 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.mjs +2 -1
- package/clients/cli/commands/experimental/render.mjs +10 -0
- package/clients/cli/commands/experimental/theme.mjs +80 -2
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/theme.mjs +30 -1
- package/clients/cli/lib/cli-error.mjs +2 -1
- package/clients/cli/lib/json-shim.mjs +77 -21
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/discovery/component-discovery.mjs +5 -4
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/hook-discovery.mjs +2 -1
- package/foundation/discovery/icon-definition-discovery.mjs +2 -1
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.mjs +2 -1
- package/foundation/discovery/integration-doc-files.mjs +2 -1
- package/foundation/discovery/prop-drift.mjs +9 -9
- package/foundation/discovery/template-adapter.mjs +3 -2
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +3 -2
- package/foundation/discovery/theming-targets.mjs +3 -2
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +31 -0
- package/foundation/fonts/font-stylesheet.mjs +115 -0
- package/foundation/fs/file-protection.mjs +4 -3
- package/foundation/fs/gather-cache.mjs +3 -4
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/integrations/contribution-inventory.mjs +4 -3
- package/foundation/integrations/public-imports.mjs +2 -1
- package/foundation/render/embedded-files.mjs +17 -4
- package/foundation/render/embedded-imports.d.mts +25 -3
- package/foundation/render/embedded-imports.mjs +42 -6
- package/foundation/render/file-header.d.mts +2 -2
- package/foundation/render/file-header.mjs +1 -1
- package/foundation/render/markup-edits.d.mts +1 -1
- package/foundation/render/markup-edits.mjs +1 -1
- package/foundation/render/page-worker.mjs +38 -0
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.mjs +38 -17
- package/foundation/render/source-block.d.mts +6 -2
- package/foundation/render/source-block.mjs +31 -9
- package/foundation/render/ts-paths.d.mts +21 -5
- package/foundation/render/ts-paths.mjs +56 -15
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/string-utils.mjs +2 -1
- package/foundation/text/suggest-order.mjs +2 -1
- package/foundation/xle/expand.mjs +2 -1
- package/package.json +6 -6
package/api/build/_adapter.d.mts
CHANGED
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
* @typedef {object} ComponentWords
|
|
20
20
|
* @property {string} name The component's name, e.g. `DateRangeInput`.
|
|
21
21
|
* @property {string[]} keywords The keywords its own doc declares.
|
|
22
|
+
* @property {string} [category] The category its own doc files it under,
|
|
23
|
+
* e.g. `Table & List`.
|
|
22
24
|
*/
|
|
23
25
|
/**
|
|
24
26
|
* Every ready page template the project can scaffold, in discovery order. This
|
|
@@ -176,6 +178,11 @@ export type ComponentWords = {
|
|
|
176
178
|
* The keywords its own doc declares.
|
|
177
179
|
*/
|
|
178
180
|
keywords: string[];
|
|
181
|
+
/**
|
|
182
|
+
* The category its own doc files it under,
|
|
183
|
+
* e.g. `Table & List`.
|
|
184
|
+
*/
|
|
185
|
+
category?: string | undefined;
|
|
179
186
|
};
|
|
180
187
|
/**
|
|
181
188
|
* A block the kit can name, as search names a block result.
|
package/api/build/_adapter.mjs
CHANGED
|
@@ -57,6 +57,8 @@ export {withListingCache} from '../../foundation/fs/listing-cache.mjs';
|
|
|
57
57
|
* @typedef {object} ComponentWords
|
|
58
58
|
* @property {string} name The component's name, e.g. `DateRangeInput`.
|
|
59
59
|
* @property {string[]} keywords The keywords its own doc declares.
|
|
60
|
+
* @property {string} [category] The category its own doc files it under,
|
|
61
|
+
* e.g. `Table & List`.
|
|
60
62
|
*/
|
|
61
63
|
|
|
62
64
|
/**
|
package/api/build/build.doc.mjs
CHANGED
|
@@ -19,7 +19,7 @@ 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
|
-
|
|
22
|
+
"START from (always one: for a whole page, the template its page-pick model chooses from the page ranker's list and its own word tables, or the app shell when its word weights call the shell; for a part " +
|
|
23
23
|
'of a page, the page it names; else the app shell, unless the idea reads as a whole page, which starts ' +
|
|
24
24
|
'from the closest page template) and the next two templates, ' +
|
|
25
25
|
'and the unified search grouped around it: the other close page templates, drop-in blocks, and ' +
|
|
@@ -65,7 +65,7 @@ export const doc = {
|
|
|
65
65
|
{
|
|
66
66
|
type: 'build.kit',
|
|
67
67
|
description:
|
|
68
|
-
|
|
68
|
+
'The page template to start from and the kit around it: the echoed query, hasResults/matchCount/directMatch fields, `start` (the template to scaffold, the `template <id> --type page <path>` command that selects it, whether the start is also search\'s direct match, the closest page, or the fallback app shell, the next two `alternatives` in the order the start is chosen from, and optional `notes` — setup notes naming what the template needs that the project lacks, such as missing packages or a missing StyleX compiler), search\'s closest page templates (≤3), drop-in block patterns (≤5), idea-specific components/hooks (≤6), and the always-on frame + foundation component-name arrays. Carries `hint` only when the kit came back thin — what to try instead, so a caller does not read a near-empty kit as "the package has nothing".',
|
|
69
69
|
},
|
|
70
70
|
],
|
|
71
71
|
throws: [
|
|
@@ -69,7 +69,7 @@ export type BuildStart = {
|
|
|
69
69
|
*/
|
|
70
70
|
command: string;
|
|
71
71
|
/**
|
|
72
|
-
* Why this template. The page ranker
|
|
72
|
+
* Why this template. The page ranker orders the page templates: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. For a part or an edit, the start is where the ranker's placement rules put it; for a whole page, checked-in word weights decide page or app shell and a page-pick model chooses the page from the ranker's list and its own word tables, so the start can differ from the ranker's first template. `direct` when the start is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when the page starts from the app shell.
|
|
73
73
|
*/
|
|
74
74
|
basis: "direct" | "closest" | "fallback";
|
|
75
75
|
/**
|
|
@@ -77,7 +77,7 @@ export type BuildStart = {
|
|
|
77
77
|
*/
|
|
78
78
|
reason: string;
|
|
79
79
|
/**
|
|
80
|
-
* The
|
|
80
|
+
* The next closest page templates (≤2), for when the start's layout is wrong: for a whole page in the page-pick model's order, else in the ranker's.
|
|
81
81
|
*/
|
|
82
82
|
alternatives: BuildAlternative[];
|
|
83
83
|
/**
|
package/api/build/build.type.mjs
CHANGED
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
* @property {string} description What the page is: its layout and the ideas it serves.
|
|
45
45
|
* @property {string} package The npm package that owns this template.
|
|
46
46
|
* @property {string} command The scaffold command that selects exactly this template, `astryx template <id> --type page <path>`: `<id>` is the Core id an integration replacement stands in for, else the template's own id, `<path>` is a placeholder for the file or folder to write the template to, and the `astryx` prefix is for the caller to replace with its own invocation.
|
|
47
|
-
* @property {'direct' | 'closest' | 'fallback'} basis Why this template. The page ranker
|
|
47
|
+
* @property {'direct' | 'closest' | 'fallback'} basis Why this template. The page ranker orders the page templates: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. For a part or an edit, the start is where the ranker's placement rules put it; for a whole page, checked-in word weights decide page or app shell and a page-pick model chooses the page from the ranker's list and its own word tables, so the start can differ from the ranker's first template. `direct` when the start is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when the page starts from the app shell.
|
|
48
48
|
* @property {string} reason One sentence saying the same as `basis`, for a reader.
|
|
49
|
-
* @property {BuildAlternative[]} alternatives The
|
|
49
|
+
* @property {BuildAlternative[]} alternatives The next closest page templates (≤2), for when the start's layout is wrong: for a whole page in the page-pick model's order, else in the ranker's.
|
|
50
50
|
* @property {string[]} [notes] Setup notes: what the template needs that the project lacks (missing packages, missing StyleX compiler). Present only when the start template imports packages the project does not have or needs a StyleX compiler the project has not configured.
|
|
51
51
|
*/
|
|
52
52
|
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
* @property {boolean} data.hasResults False when search returned nothing. The kit still names a template in `start`.
|
|
76
76
|
* @property {number} data.matchCount Total ranked search matches for the query — counted before the search `limit`, the kit's score floors, and its per-group caps, so it is never a cap read back.
|
|
77
77
|
* @property {boolean} data.directMatch True when the top page template is a confident direct match.
|
|
78
|
-
* @property {BuildStart | null} data.start The page template to start from
|
|
78
|
+
* @property {BuildStart | null} data.start The page template to start from (see `BuildStart.basis`), else the app shell. Null only when the kit is narrowed to components or hooks (`type`), or when the project has no page template to offer.
|
|
79
79
|
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.pages Closest page templates by search (≤3). Each entry's `command` carries `--skeleton` when `directMatch` is false, so it previews the layout; `start.command` is the scaffold.
|
|
80
80
|
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.blocks Drop-in block patterns covering parts of the idea (≤5), best first. A block search returned keeps search's score and reason; any other block carries the block picker's relative score (100 for its best candidate, never below 1) and reason, so the two kinds of score are not comparable.
|
|
81
81
|
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.domain Idea-specific components/hooks (≤6), excluding frame/foundation.
|
package/api/build/kit/kind.d.mts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* What an idea asks for (spec:AST-048/FR3): a whole `page`; a `part` of one,
|
|
6
6
|
* when its head noun names one of the system's components and it lists fewer
|
|
7
|
-
* than PAGE_PIECES pieces; or an `edit` of a
|
|
7
|
+
* than PAGE_PIECES pieces or only that component's contents; or an `edit` of a
|
|
8
|
+
* page the builder already has.
|
|
8
9
|
*
|
|
9
10
|
* @param {string} query
|
|
10
11
|
* @param {PageTemplate[]} pages
|
package/api/build/kit/kind.mjs
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
* not a page, and the system's own components say what a part is: an idea
|
|
9
9
|
* whose head noun is a word of a component's name or keywords, Core's or an
|
|
10
10
|
* integration's, asks for that part, unless the noun is a family word ("a data
|
|
11
|
-
* table") or the idea lists a page's worth of pieces.
|
|
11
|
+
* table") or the idea lists a page's worth of pieces. A component named with
|
|
12
|
+
* its listed contents ("a side panel with an owner, a status, and a history")
|
|
13
|
+
* is still one part, unless the component holds records: its category declares
|
|
14
|
+
* a page family (a list, a table). Words search drops as
|
|
12
15
|
* stopwords ("page", "screen", "app", "view") name no component, so "a calendar
|
|
13
16
|
* page" asks for a page and "a calendar" for a part. A part starts from the
|
|
14
17
|
* base template of the family the idea names ("an empty state for a settings
|
|
@@ -26,6 +29,7 @@
|
|
|
26
29
|
* new dashboard").
|
|
27
30
|
*/
|
|
28
31
|
|
|
32
|
+
import {COMPONENT_CATEGORIES} from '../../../authoring/doctypes/component/categories.mjs';
|
|
29
33
|
import {stem} from '../../search/search.mjs';
|
|
30
34
|
import {
|
|
31
35
|
HEAD_END,
|
|
@@ -46,7 +50,7 @@ import {
|
|
|
46
50
|
/**
|
|
47
51
|
* How many listed pieces make an idea a page: a part is one thing with a detail
|
|
48
52
|
* or two ("a status pill with a tooltip"), while three pieces, two commas
|
|
49
|
-
* apart, describe a page.
|
|
53
|
+
* apart, describe a page, unless they are one component's contents.
|
|
50
54
|
*/
|
|
51
55
|
const PAGE_PIECES = 3;
|
|
52
56
|
|
|
@@ -71,7 +75,8 @@ const NEW = /\bnew\b/;
|
|
|
71
75
|
/**
|
|
72
76
|
* What an idea asks for (spec:AST-048/FR3): a whole `page`; a `part` of one,
|
|
73
77
|
* when its head noun names one of the system's components and it lists fewer
|
|
74
|
-
* than PAGE_PIECES pieces; or an `edit` of a
|
|
78
|
+
* than PAGE_PIECES pieces or only that component's contents; or an `edit` of a
|
|
79
|
+
* page the builder already has.
|
|
75
80
|
*
|
|
76
81
|
* @param {string} query
|
|
77
82
|
* @param {PageTemplate[]} pages
|
|
@@ -87,21 +92,123 @@ export function ideaKind(query, pages, components) {
|
|
|
87
92
|
// calendar", "page" the noun of "a calendar page". An overlay frame names
|
|
88
93
|
// where the thing lives, not the thing: "drafts" is the noun of "drafts in
|
|
89
94
|
// a modal".
|
|
90
|
-
const
|
|
95
|
+
const rawHead = text.split(HEAD_END)[0] ?? '';
|
|
96
|
+
const head = rawHead.replace(CONTAINER_PHRASE, m =>
|
|
91
97
|
containersOf(m).size > 0 ? ' ' : m,
|
|
92
98
|
);
|
|
93
|
-
const
|
|
94
|
-
w => w.length >= 2,
|
|
95
|
-
);
|
|
96
|
-
const noun = stem(words[words.length - 1] ?? '');
|
|
99
|
+
const noun = lastNoun(head);
|
|
97
100
|
if (familyWords.has(noun)) return 'page';
|
|
101
|
+
const holdsRecords = (/** @type {string} */ word) =>
|
|
102
|
+
namedComponents(word, components).some(c => namesFamily(c, familyWords));
|
|
103
|
+
if (
|
|
104
|
+
describesOnePart(text, rawHead, noun, familyWords, components) &&
|
|
105
|
+
!holdsRecords(noun)
|
|
106
|
+
)
|
|
107
|
+
return 'part';
|
|
98
108
|
const pieces = (text.match(/,/g) ?? []).length + 1;
|
|
99
109
|
if (pieces >= PAGE_PIECES) return 'page';
|
|
100
|
-
|
|
110
|
+
const namesPart = (/** @type {string} */ word) =>
|
|
111
|
+
components.some(c => componentTerms(c).includes(word));
|
|
112
|
+
if (!namesPart(noun)) return 'page';
|
|
113
|
+
// A component that holds records, followed by "of", is a page of those
|
|
114
|
+
// records ("a list of jobs"), unless what follows names a component ("a list
|
|
115
|
+
// of buttons") or a page family ("a list of settings toggles").
|
|
116
|
+
if (!holdsRecords(noun) || !endsOnOf(text)) return 'part';
|
|
117
|
+
const phrase = madeOf(text);
|
|
118
|
+
return terms(phrase).some(t => familyWords.has(t)) ||
|
|
119
|
+
namesPart(lastNoun(phrase))
|
|
101
120
|
? 'part'
|
|
102
121
|
: 'page';
|
|
103
122
|
}
|
|
104
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Whether an idea describes one part and its contents: its head names a
|
|
126
|
+
* component by name and ends on a word ("a side panel with a, b and c"), not
|
|
127
|
+
* on a comma or a colon that starts a list of peers, and no word of the idea
|
|
128
|
+
* names a page family. Such an idea is a part however many pieces it lists.
|
|
129
|
+
* @param {string} text
|
|
130
|
+
* @param {string} head the idea's head, before any frame is removed
|
|
131
|
+
* @param {string} noun
|
|
132
|
+
* @param {Map<string, string>} familyWords
|
|
133
|
+
* @param {ComponentWords[]} components
|
|
134
|
+
* @returns {boolean}
|
|
135
|
+
*/
|
|
136
|
+
function describesOnePart(text, head, noun, familyWords, components) {
|
|
137
|
+
const end = text.slice(head.length).match(/^\s*([a-z]+)/i);
|
|
138
|
+
return (
|
|
139
|
+
end !== null &&
|
|
140
|
+
components.some(c => nameTerms(c).includes(noun)) &&
|
|
141
|
+
!terms(text).some(t => familyWords.has(t))
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The components a word names: the one whose whole name is the word
|
|
147
|
+
* ("button" names Button), else every component whose name holds it.
|
|
148
|
+
* @param {string} word
|
|
149
|
+
* @param {ComponentWords[]} components
|
|
150
|
+
* @returns {ComponentWords[]}
|
|
151
|
+
*/
|
|
152
|
+
function namedComponents(word, components) {
|
|
153
|
+
const whole = components.filter(c => {
|
|
154
|
+
const name = nameTerms(c);
|
|
155
|
+
return name.length === 1 && name[0] === word;
|
|
156
|
+
});
|
|
157
|
+
return whole.length > 0
|
|
158
|
+
? whole
|
|
159
|
+
: components.filter(c => nameTerms(c).includes(word));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Whether a component's doc files it under a category that declares a page
|
|
164
|
+
* family the project has ("Table & List" declares the table family): such a
|
|
165
|
+
* component holds the records a page of that family shows.
|
|
166
|
+
* @param {ComponentWords} component
|
|
167
|
+
* @param {Map<string, string>} familyWords
|
|
168
|
+
* @returns {boolean}
|
|
169
|
+
*/
|
|
170
|
+
function namesFamily(component, familyWords) {
|
|
171
|
+
const family = Object.hasOwn(COMPONENT_CATEGORIES, component.category ?? '')
|
|
172
|
+
? COMPONENT_CATEGORIES[component.category ?? ''].pageFamily
|
|
173
|
+
: undefined;
|
|
174
|
+
return family !== undefined && [...familyWords.values()].includes(family);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The stem of a phrase's last word.
|
|
179
|
+
* @param {string} phrase
|
|
180
|
+
* @returns {string}
|
|
181
|
+
*/
|
|
182
|
+
function lastNoun(phrase) {
|
|
183
|
+
const words = (phrase.toLowerCase().match(/[a-z0-9]+/g) ?? []).filter(
|
|
184
|
+
w => w.length >= 2,
|
|
185
|
+
);
|
|
186
|
+
return stem(words[words.length - 1] ?? '');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Whether an idea's head ends on "of" ("a list of jobs").
|
|
191
|
+
* @param {string} text
|
|
192
|
+
* @returns {boolean}
|
|
193
|
+
*/
|
|
194
|
+
function endsOnOf(text) {
|
|
195
|
+
return text.match(HEAD_END)?.[0].toLowerCase() === 'of';
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* What a head that ends on "of" is made of: the phrase after "of", up to the
|
|
200
|
+
* next head end, without an overlay frame.
|
|
201
|
+
* @param {string} text
|
|
202
|
+
* @returns {string}
|
|
203
|
+
*/
|
|
204
|
+
function madeOf(text) {
|
|
205
|
+
const end = text.match(HEAD_END);
|
|
206
|
+
const rest = text.slice((end?.index ?? 0) + (end?.[0].length ?? 0));
|
|
207
|
+
return (rest.split(HEAD_END)[0] ?? '').replace(CONTAINER_PHRASE, m =>
|
|
208
|
+
containersOf(m).size > 0 ? ' ' : m,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
105
212
|
/**
|
|
106
213
|
* Whether an idea adds a piece to a page the builder already has: it opens
|
|
107
214
|
* with "add", says where the piece goes with a place phrase that names
|
package/api/build/kit/kit.mjs
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file build.kit leaf — the page template to start from, and the kit around it.
|
|
5
5
|
*
|
|
6
|
-
* Every kit names a page template to START from
|
|
7
|
-
* (rank.mjs)
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Every kit names a page template to START from, else the app shell. The page
|
|
7
|
+
* ranker (rank.mjs) orders the page templates; for a whole page the word
|
|
8
|
+
* weights (weights.mjs) decide page or shell and the page-pick model chooses
|
|
9
|
+
* the page from that list (start.mjs). Search's own matches never choose the
|
|
10
|
+
* start, so one noisy signal — search matching "site" to a gallery's "side" —
|
|
11
|
+
* cannot choose the page. A
|
|
10
12
|
* template carries the page frame, the spacing, and the section rhythm; a page
|
|
11
13
|
* composed from components carries none of that, so the kit never recommends
|
|
12
14
|
* composing from scratch while a template exists. Next to the start it names
|
package/api/build/kit/rank.mjs
CHANGED
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
* "board" picks the kanban board for a game board. Here every matched term
|
|
24
24
|
* counts, weighted by how rare it is among page templates (inverse document
|
|
25
25
|
* frequency), so the page that answers more of the idea — and its rarer words —
|
|
26
|
-
* wins. Structural signals sit on top
|
|
26
|
+
* wins. Structural signals sit on top. They order the ranker's list; for a
|
|
27
|
+
* whole page, the page-pick model in weights.mjs reads that list beside its
|
|
28
|
+
* own word tables and picks the start, so the start can differ from the
|
|
29
|
+
* ranker's first template:
|
|
27
30
|
*
|
|
28
31
|
* - The head noun. The words before the first "with", ":" or "," name what
|
|
29
32
|
* the page is ("audit dashboard: dense table with …"); a family word there
|
|
@@ -62,6 +65,7 @@ import {
|
|
|
62
65
|
keywordWordsFor,
|
|
63
66
|
framesOf,
|
|
64
67
|
} from './words.mjs';
|
|
68
|
+
import {compareText} from '../../../foundation/text/compare-text.mjs';
|
|
65
69
|
|
|
66
70
|
/**
|
|
67
71
|
* @typedef {import('./words.mjs').PageTemplate} PageTemplate
|
|
@@ -289,14 +293,15 @@ export function rankPages(query, pages) {
|
|
|
289
293
|
(a, b) =>
|
|
290
294
|
b.score - a.score ||
|
|
291
295
|
a.name.split('-').length - b.name.split('-').length ||
|
|
292
|
-
a.name
|
|
296
|
+
compareText(a.name, b.name),
|
|
293
297
|
);
|
|
294
298
|
return baseFirst(ranked);
|
|
295
299
|
}
|
|
296
300
|
|
|
297
301
|
/**
|
|
298
302
|
* Put a named family's base template ahead of the variant that outranks it,
|
|
299
|
-
* unless the variant matched START_TERMS terms the base did not,
|
|
303
|
+
* unless the variant matched START_TERMS terms the base did not, the idea
|
|
304
|
+
* places the page in the variant's frame and not the base's, or the base
|
|
300
305
|
* cannot start on its own: too little score, or too few matched terms. The
|
|
301
306
|
* head names the exception: a family word in the idea's head is start
|
|
302
307
|
* evidence on its own — the same evidence pickStart accepts in place of a
|
|
@@ -319,8 +324,9 @@ function baseFirst(ranked) {
|
|
|
319
324
|
) {
|
|
320
325
|
return ranked;
|
|
321
326
|
}
|
|
327
|
+
// The frame is what a template is, and pickStart takes it as evidence.
|
|
322
328
|
const own = [...top.matched].filter(t => !base.matched.has(t)).length;
|
|
323
|
-
return own >= START_TERMS
|
|
329
|
+
return own >= START_TERMS || (top.containerMatched && !base.containerMatched)
|
|
324
330
|
? ranked
|
|
325
331
|
: [base, ...ranked.filter(r => r !== base)];
|
|
326
332
|
}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The template to start from:
|
|
6
|
-
*
|
|
5
|
+
* The template to start from: for a whole page, the ready page the word
|
|
6
|
+
* weights and the page-pick model choose (weighStart); for a part or an edit,
|
|
7
|
+
* the ranker's placement; else the first fallback shell the project can
|
|
7
8
|
* scaffold. Null only when the project has no page template to offer at all.
|
|
8
9
|
*
|
|
9
|
-
* `direct` means two independent signals agree: the
|
|
10
|
-
*
|
|
10
|
+
* `direct` means two independent signals agree: the start is also search's
|
|
11
|
+
* direct match. The ranker sees only ready templates, so a template
|
|
11
12
|
* still marked not ready is never the start; when search matched one directly
|
|
12
13
|
* the reason names it, so the reader knows why the kit starts elsewhere.
|
|
13
14
|
*
|
package/api/build/kit/start.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file The page template a kit starts from:
|
|
5
|
-
*
|
|
4
|
+
* @file The page template a kit starts from: for a whole page, the page the
|
|
5
|
+
* word weights and the page-pick model choose from the ranker's list; for a
|
|
6
|
+
* part or an edit, where the ranker's placement rules put it; else the app
|
|
7
|
+
* shell.
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
10
|
import {loadWeights} from '../_adapter.mjs';
|
|
@@ -113,12 +115,13 @@ function liftFromShell(ranked, kind, catalog, idea) {
|
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
/**
|
|
116
|
-
* The template to start from:
|
|
117
|
-
*
|
|
118
|
+
* The template to start from: for a whole page, the ready page the word
|
|
119
|
+
* weights and the page-pick model choose (weighStart); for a part or an edit,
|
|
120
|
+
* the ranker's placement; else the first fallback shell the project can
|
|
118
121
|
* scaffold. Null only when the project has no page template to offer at all.
|
|
119
122
|
*
|
|
120
|
-
* `direct` means two independent signals agree: the
|
|
121
|
-
*
|
|
123
|
+
* `direct` means two independent signals agree: the start is also search's
|
|
124
|
+
* direct match. The ranker sees only ready templates, so a template
|
|
122
125
|
* still marked not ready is never the start; when search matched one directly
|
|
123
126
|
* the reason names it, so the reader knows why the kit starts elsewhere.
|
|
124
127
|
*
|
|
@@ -149,8 +152,9 @@ export function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
|
|
|
149
152
|
: place[0].toUpperCase() + place.slice(1);
|
|
150
153
|
const proposed = pickStart(ranked, kind);
|
|
151
154
|
// The checked-in word weights (weights.mjs), blended with the ranker's
|
|
152
|
-
// scores, decide the start of a whole page
|
|
153
|
-
//
|
|
155
|
+
// scores, decide the start of a whole page, so it can differ from the
|
|
156
|
+
// ranker's own pick, its head-noun family included. A part or an edit starts
|
|
157
|
+
// where the ranker's placement rules put it (spec:AST-048/FR3).
|
|
154
158
|
const weighed =
|
|
155
159
|
kind === 'page'
|
|
156
160
|
? weighStart(idea, ranked, proposed, catalog, {
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
loadIntegrationsSafely,
|
|
34
34
|
withOwnership,
|
|
35
35
|
} from '../_adapter.mjs';
|
|
36
|
+
import {compareText} from '../../../foundation/text/compare-text.mjs';
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* @typedef {import('../component.type.mjs').ComponentListResponse} ComponentListResponse
|
|
@@ -470,7 +471,7 @@ async function componentListNow(coreDir, {cwd, category, detail, zh, dense, lang
|
|
|
470
471
|
});
|
|
471
472
|
}
|
|
472
473
|
for (const [key, members] of byGroup) {
|
|
473
|
-
members.sort((a, b) => a.name
|
|
474
|
+
members.sort((a, b) => compareText(a.name, b.name));
|
|
474
475
|
listData[key] = members;
|
|
475
476
|
}
|
|
476
477
|
}
|
|
@@ -24,6 +24,7 @@ import {levenshteinDistance} from '../../../foundation/text/string-utils.mjs';
|
|
|
24
24
|
import {AstryxError} from '../../error.mjs';
|
|
25
25
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
26
26
|
import {DISCOVER_KINDS} from '../../../authoring/discover/parse.mjs';
|
|
27
|
+
import {compareText} from '../../../foundation/text/compare-text.mjs';
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* @typedef {import('../_package-scanner.mjs').ScannedPackage} ScannedPackage
|
|
@@ -131,8 +132,8 @@ export async function search(packages, query, opts) {
|
|
|
131
132
|
a.score - b.score ||
|
|
132
133
|
Number(b.item.installed) - Number(a.item.installed) ||
|
|
133
134
|
KIND_ORDER.indexOf(a.item.kind) - KIND_ORDER.indexOf(b.item.kind) ||
|
|
134
|
-
a.item.package
|
|
135
|
-
a.item.name
|
|
135
|
+
compareText(a.item.package, b.item.package) ||
|
|
136
|
+
compareText(a.item.name, b.item.name),
|
|
136
137
|
);
|
|
137
138
|
|
|
138
139
|
if (ranked.length > 0) {
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -97,6 +97,7 @@ import {
|
|
|
97
97
|
orderRouteSuggestions,
|
|
98
98
|
} from '../../foundation/text/suggest-order.mjs';
|
|
99
99
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
100
|
+
import {compareText} from '../../foundation/text/compare-text.mjs';
|
|
100
101
|
|
|
101
102
|
export {OVERLAY_LANGUAGES, overlayLanguages};
|
|
102
103
|
|
|
@@ -2293,6 +2294,6 @@ export async function integrationDocTypes(integration, cwd) {
|
|
|
2293
2294
|
unchecked: [
|
|
2294
2295
|
...report.unchecked,
|
|
2295
2296
|
...unread.map(entry => ({doc: rel(entry.path), reason: entry.reason})),
|
|
2296
|
-
].sort((a, b) => a.doc
|
|
2297
|
+
].sort((a, b) => compareText(a.doc, b.doc)),
|
|
2297
2298
|
};
|
|
2298
2299
|
}
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -70,6 +70,7 @@ import {
|
|
|
70
70
|
findProjectCoreDir,
|
|
71
71
|
findInstalledPackage,
|
|
72
72
|
} from '../../foundation/fs/paths.mjs';
|
|
73
|
+
import {compareText} from '../../foundation/text/compare-text.mjs';
|
|
73
74
|
export {
|
|
74
75
|
isLocalThemeOwner,
|
|
75
76
|
planThemeAppWrite,
|
|
@@ -131,8 +132,9 @@ export function keptFileCheck(
|
|
|
131
132
|
check,
|
|
132
133
|
codec = CHECK_CODEC,
|
|
133
134
|
) {
|
|
134
|
-
// Only a recorded run (
|
|
135
|
-
// hosted run names its commands its own way, so it
|
|
135
|
+
// Only a recorded run (`doctor` from the bin, with or without `--built`)
|
|
136
|
+
// reads or keeps one: a hosted run names its commands its own way, so it
|
|
137
|
+
// always checks.
|
|
136
138
|
if (!recordedRun()) return check();
|
|
137
139
|
return persistedGather(
|
|
138
140
|
// With the command name the checks print commands with.
|
|
@@ -282,7 +284,7 @@ export function findIconPlaceholders(projectDir) {
|
|
|
282
284
|
uses: uses.length,
|
|
283
285
|
});
|
|
284
286
|
}
|
|
285
|
-
return found.sort((a, b) => a.file
|
|
287
|
+
return found.sort((a, b) => compareText(a.file, b.file));
|
|
286
288
|
}
|
|
287
289
|
|
|
288
290
|
/** @param {string} projectDir */
|
|
@@ -796,7 +798,7 @@ export function readBuiltPath(target, {fileLimit = BUILT_FILE_LIMIT} = {}) {
|
|
|
796
798
|
} catch {
|
|
797
799
|
continue;
|
|
798
800
|
}
|
|
799
|
-
entries.sort((a, b) => a.name
|
|
801
|
+
entries.sort((a, b) => compareText(a.name, b.name));
|
|
800
802
|
for (const entry of entries) {
|
|
801
803
|
const full = path.join(dir, entry.name);
|
|
802
804
|
if (entry.isDirectory()) {
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
} from './_adapter.mjs';
|
|
32
32
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
33
33
|
import {babelParse as parseModule} from '../../foundation/runtime/lazy-dependencies.mjs';
|
|
34
|
+
import {compareText} from '../../foundation/text/compare-text.mjs';
|
|
34
35
|
|
|
35
36
|
/** Source files, read for imports and JSX. */
|
|
36
37
|
const SOURCE_EXT = new Set(['.tsx', '.jsx', '.ts', '.js', '.mjs', '.cjs']);
|
|
@@ -716,7 +717,7 @@ export function scanBuilt(target, packages, {fileLimit} = {}) {
|
|
|
716
717
|
}
|
|
717
718
|
}
|
|
718
719
|
scan.packages = [...imported].sort();
|
|
719
|
-
scan.findings.sort((a, b) => a.file
|
|
720
|
+
scan.findings.sort((a, b) => compareText(a.file, b.file) || a.line - b.line);
|
|
720
721
|
return scan;
|
|
721
722
|
}
|
|
722
723
|
|
package/api/icon/_records.mjs
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import {AstryxError} from '../error.mjs';
|
|
15
15
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
16
16
|
import {levenshteinDistance} from '../../foundation/text/string-utils.mjs';
|
|
17
|
+
import {compareText} from '../../foundation/text/compare-text.mjs';
|
|
17
18
|
export {
|
|
18
19
|
answeringMatches,
|
|
19
20
|
iconRecord,
|
|
@@ -115,7 +116,7 @@ export function oneNamedSet(sets, withdrawn, selector) {
|
|
|
115
116
|
export function closest(wanted, candidates, reason, max = 5) {
|
|
116
117
|
return [...new Set(candidates)]
|
|
117
118
|
.map(name => ({name, distance: levenshteinDistance(wanted, name)}))
|
|
118
|
-
.sort((a, b) => a.distance - b.distance || a.name
|
|
119
|
+
.sort((a, b) => a.distance - b.distance || compareText(a.name, b.name))
|
|
119
120
|
.slice(0, max)
|
|
120
121
|
.map(({name}) => ({name, reason}));
|
|
121
122
|
}
|
|
@@ -58,6 +58,7 @@ import {
|
|
|
58
58
|
import {rootProblem} from '../../foundation/integrations/validate-contributions.mjs';
|
|
59
59
|
import {normalizeProviderId} from '../../foundation/identity/provider-identity.mjs';
|
|
60
60
|
import {shellArg} from '../../foundation/text/shell-arg.mjs';
|
|
61
|
+
import {compareText} from '../../foundation/text/compare-text.mjs';
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
64
|
* The provider ID a package without a name is checked under: a valid bare
|
|
@@ -215,7 +216,7 @@ async function templateConflicts(pkg, options) {
|
|
|
215
216
|
}
|
|
216
217
|
for (const matches of coreById.values()) {
|
|
217
218
|
matches.sort((a, b) =>
|
|
218
|
-
`${a.type}:${a.name}
|
|
219
|
+
compareText(`${a.type}:${a.name}`, `${b.type}:${b.name}`),
|
|
219
220
|
);
|
|
220
221
|
}
|
|
221
222
|
|
|
@@ -279,7 +280,8 @@ async function templateConflicts(pkg, options) {
|
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
282
|
conflicts.sort((a, b) =>
|
|
282
|
-
|
|
283
|
+
compareText(
|
|
284
|
+
`${a.id}:${'relationship' in a ? a.relationship : ''}`,
|
|
283
285
|
`${b.id}:${'relationship' in b ? b.relationship : ''}`,
|
|
284
286
|
),
|
|
285
287
|
);
|
|
@@ -388,7 +390,7 @@ async function componentConflicts(pkg, options) {
|
|
|
388
390
|
'If you keep it, always select it with --package.',
|
|
389
391
|
command: `${run} component ${shellArg(component.name)} --package ${shellArg(name)}`,
|
|
390
392
|
}))
|
|
391
|
-
.sort((a, b) => a.name
|
|
393
|
+
.sort((a, b) => compareText(a.name, b.name));
|
|
392
394
|
|
|
393
395
|
return {
|
|
394
396
|
type: 'integration.component-conflicts',
|
|
@@ -561,9 +563,7 @@ async function docConflicts(pkg, options) {
|
|
|
561
563
|
}
|
|
562
564
|
}
|
|
563
565
|
findings.sort((a, b) =>
|
|
564
|
-
`${a.topic}:${a.relationship}
|
|
565
|
-
`${b.topic}:${b.relationship}`,
|
|
566
|
-
),
|
|
566
|
+
compareText(`${a.topic}:${a.relationship}`, `${b.topic}:${b.relationship}`),
|
|
567
567
|
);
|
|
568
568
|
|
|
569
569
|
// The same graph checks `astryx doctor` runs in a project: the namespaces
|
|
@@ -90,6 +90,7 @@ import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
|
90
90
|
import {cliPeerVersionProblem} from '../../foundation/integrations/cli-peer-version.mjs';
|
|
91
91
|
import {publicImportIssues} from '../../foundation/integrations/public-imports.mjs';
|
|
92
92
|
import {runChoice} from '../../foundation/release/run-context.mjs';
|
|
93
|
+
import {compareText} from '../../foundation/text/compare-text.mjs';
|
|
93
94
|
|
|
94
95
|
/** The running CLI is outside the package's `@astryxdesign/cli` peer range. */
|
|
95
96
|
const CLI_PEER_VERSION = 'cli_peer_version';
|
|
@@ -255,7 +256,7 @@ async function findUnreachableContributionIssues(
|
|
|
255
256
|
try {
|
|
256
257
|
entries = fs
|
|
257
258
|
.readdirSync(dir, {withFileTypes: true})
|
|
258
|
-
.sort((a, b) => a.name
|
|
259
|
+
.sort((a, b) => compareText(a.name, b.name));
|
|
259
260
|
} catch (err) {
|
|
260
261
|
// One folder the user running astryx cannot read must not end the whole
|
|
261
262
|
// validation: name it and keep checking the rest of the package.
|