@astryxdesign/cli 0.6.5 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -0
- package/README.md +16 -15
- package/api/build/_adapter.d.mts +50 -2
- package/api/build/_adapter.mjs +98 -10
- package/api/build/build.doc.mjs +2 -2
- package/api/build/build.test.mjs +111 -2
- package/api/build/kit/kit.mjs +98 -22
- package/api/build/kit/rank.d.mts +32 -8
- package/api/build/kit/rank.mjs +291 -97
- package/api/build/kit/rank.test.mjs +231 -48
- 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/docs/docs.d.mts +6 -0
- package/api/docs/docs.depth.test.mjs +132 -0
- package/api/docs/docs.doc.mjs +31 -2
- package/api/docs/docs.mjs +44 -1
- package/api/docs/docs.test.mjs +279 -0
- package/api/docs/docs.type.d.mts +38 -1
- package/api/docs/docs.type.mjs +18 -1
- package/api/docs/integration-tree.test.mjs +572 -0
- package/api/docs/integrationDocs.test.mjs +336 -0
- package/api/docs/node/node.d.mts +28 -3
- package/api/docs/node/node.mjs +146 -23
- package/api/error.d.mts +22 -0
- package/api/error.mjs +42 -0
- package/api/gap-report/gap-report.d.mts +3 -1
- package/api/gap-report/gap-report.mjs +12 -2
- package/api/gap-report/gap-report.test.mjs +106 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/integration/add-contribution.d.mts +2 -1
- package/api/integration/add-contribution.mjs +7 -3
- package/api/integration/add-contribution.test.mjs +3 -3
- package/api/integration/add-theme.mjs +338 -26
- package/api/integration/add-theme.test.mjs +314 -1
- package/api/integration/authoring-checks.mjs +10 -7
- package/api/integration/authoring-checks.type.d.mts +8 -0
- package/api/integration/authoring-checks.type.mjs +7 -3
- package/api/integration/integration-authoring.type.d.mts +4 -1
- package/api/integration/integration-authoring.type.mjs +6 -1
- package/api/integration/integrationAdd.doc.mjs +6 -0
- package/api/integration/integrationAddTheme.doc.mjs +10 -0
- 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 +12 -3
- package/api/integration/pack-check.test.mjs +52 -3
- package/api/integration/validate-integration.d.mts +4 -2
- package/api/integration/validate-integration.mjs +7 -2
- package/api/integration/validate-integration.test.mjs +55 -0
- package/api/integration/validate-integration.type.d.mts +5 -0
- package/api/integration/validate-integration.type.mjs +5 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/layout/expand/expand.mjs +12 -7
- package/api/layout/expand/expand.receipt.test.mjs +74 -0
- package/api/layout/layout.type.d.mts +1 -0
- package/api/layout/layout.type.mjs +1 -0
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search.d.mts +36 -5
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +194 -54
- package/api/search/search.test.mjs +825 -0
- package/api/search/search.type.d.mts +5 -5
- package/api/search/search.type.mjs +5 -5
- package/api/swizzle/copy/copy.mjs +66 -3
- package/api/swizzle/swizzle.doc.mjs +4 -0
- package/api/template/copy/copy.mjs +14 -8
- package/api/template/copy/copy.receipt.test.mjs +77 -0
- package/api/template/show/show.mjs +15 -4
- package/api/template/show/show.test.mjs +76 -0
- package/api/template/template-integration.test.mjs +14 -0
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +6 -2
- package/api/template/template.mjs +1 -0
- package/api/template/template.type.d.mts +2 -0
- package/api/template/template.type.mjs +2 -0
- package/api/theme/build/build.d.mts +24 -0
- package/api/theme/build/build.icon-lineage.test.mjs +117 -0
- package/api/theme/build/build.icon-preservation.test.mjs +639 -0
- package/api/theme/build/build.mjs +381 -77
- package/api/theme/build/build.project-core.test.mjs +165 -0
- package/api/theme/build/build.test.mjs +190 -1
- package/api/theme/build/icon-imports.d.mts +47 -0
- package/api/theme/build/icon-imports.mjs +691 -0
- package/api/theme/themeBuild.doc.d.mts +4 -1
- package/api/theme/themeBuild.doc.mjs +14 -3
- package/api/upgrade/run/run.mjs +20 -3
- package/api/upgrade/run/run.test.mjs +45 -1
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.type.d.mts +1 -0
- package/api/upgrade/upgrade.type.mjs +1 -0
- package/assets/docs/icons.doc.mjs +1 -0
- package/assets/docs/theme.doc.mjs +3 -2
- package/assets/docs/tokens.doc.mjs +3 -3
- package/assets/docs/tree/add-a-theme.doc.mjs +4 -0
- package/assets/docs/tree/add-a-topic.doc.mjs +1 -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/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +9 -5
- package/assets/docs/tree/versioning.doc.mjs +7 -6
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
- package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
- package/assets/templates/pages/blank/template.doc.mjs +3 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
- package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
- package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
- package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
- package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
- package/assets/templates/pages/documentation/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
- package/assets/templates/pages/editor/template.doc.mjs +9 -1
- package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
- package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
- package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
- package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
- package/assets/templates/pages/ide/template.doc.mjs +9 -1
- package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
- package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
- package/assets/templates/pages/library/template.doc.mjs +15 -1
- package/assets/templates/pages/login/template.doc.mjs +10 -1
- package/assets/templates/pages/login-card/template.doc.mjs +11 -1
- package/assets/templates/pages/login-split/template.doc.mjs +10 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
- package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
- package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/settings/template.doc.mjs +3 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/table/template.doc.mjs +11 -1
- package/assets/templates/pages/table-filter/template.doc.mjs +21 -1
- package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
- package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
- package/assets/templates/pages/table-page/template.doc.mjs +20 -1
- package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
- package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
- package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
- package/assets/templates/themes/butter/icons.tsx +2 -0
- package/assets/templates/themes/chocolate/icons.tsx +2 -0
- package/assets/templates/themes/gothic/icons.tsx +2 -0
- package/assets/templates/themes/matcha/icons.tsx +2 -0
- package/assets/templates/themes/neutral/icons.tsx +2 -0
- package/assets/templates/themes/stone/icons.tsx +2 -0
- package/assets/templates/themes/y2k/icons.tsx +2 -0
- package/authoring/doctypes/template/parse.d.mts +2 -0
- package/authoring/doctypes/template/parse.mjs +1 -0
- package/authoring/doctypes/template/parse.test.mjs +21 -0
- package/authoring/doctypes/template/template.doc.mjs +6 -0
- package/authoring/doctypes/template/type.ts +10 -0
- package/clients/cli/commands/build-theme.mjs +8 -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 +222 -5
- package/clients/cli/commands/docs.test.mjs +383 -0
- package/clients/cli/commands/doctor.mjs +4 -4
- package/clients/cli/commands/gap-report.mjs +12 -0
- package/clients/cli/commands/gap-report.test.mjs +63 -0
- package/clients/cli/commands/integration-add.doc.mjs +10 -0
- package/clients/cli/commands/integration-authoring.test.mjs +12 -2
- package/clients/cli/commands/integration.mjs +3 -1
- package/clients/cli/commands/layout-expand.doc.mjs +3 -1
- package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
- package/clients/cli/commands/layout.mjs +16 -0
- 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/template.copy-receipt.test.mjs +60 -0
- package/clients/cli/commands/template.mjs +19 -5
- package/clients/cli/commands/template.show-media.test.mjs +62 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +41 -0
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
- package/clients/cli/commands/write-failure.test.mjs +175 -0
- package/clients/cli/lib/manifest.mjs +44 -165
- package/clients/cli/lib/manifest.test.mjs +98 -7
- package/foundation/agent-docs/agent-docs.mjs +2 -1
- package/foundation/agent-docs/agent-docs.test.mjs +1168 -0
- package/foundation/discovery/template-adapter.d.mts +14 -0
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
- package/foundation/discovery/template-adapter.mjs +21 -1
- package/foundation/discovery/theme-discovery.d.mts +6 -0
- package/foundation/discovery/theme-discovery.mjs +9 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +3 -3
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/tree.test.mjs +649 -0
- package/foundation/integrations/cli-requirement.d.mts +57 -13
- package/foundation/integrations/cli-requirement.mjs +84 -22
- package/foundation/integrations/cli-requirement.test.mjs +135 -8
- package/foundation/response/response-types.doc.d.mts +5 -5
- package/foundation/response/response-types.doc.mjs +13 -13
- package/package.json +1 -1
package/api/build/kit/kit.mjs
CHANGED
|
@@ -27,13 +27,20 @@
|
|
|
27
27
|
* the invocation stays the renderer's job.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
import {search} from '../../search/search.mjs';
|
|
30
|
+
import {search, searchedComponents} 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 {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;
|
|
@@ -118,6 +125,24 @@ const asTemplate = t => ({
|
|
|
118
125
|
command: `${t.command} <path>`,
|
|
119
126
|
});
|
|
120
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Why a part of a page, or a change to a page the builder already has, starts
|
|
130
|
+
* where it does (spec:AST-048/FR3, FR9): the rest of the start's reason, or
|
|
131
|
+
* null for a whole page.
|
|
132
|
+
* @param {import('./rank.mjs').IdeaKind} kind
|
|
133
|
+
* @param {boolean} inPage whether the start is the page the idea names
|
|
134
|
+
* @returns {string | null}
|
|
135
|
+
*/
|
|
136
|
+
function placement(kind, inPage) {
|
|
137
|
+
if (kind === 'edit')
|
|
138
|
+
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.';
|
|
139
|
+
if (kind === 'part')
|
|
140
|
+
return inPage
|
|
141
|
+
? 'the idea is a part of a page, so it starts from the page it names.'
|
|
142
|
+
: 'the idea is a part of a page and names no page, so it starts from the app shell.';
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
121
146
|
/**
|
|
122
147
|
* The template to start from: the ready page the ranker puts first when it
|
|
123
148
|
* has the evidence to lead, else the first fallback shell the project can
|
|
@@ -129,12 +154,14 @@ const asTemplate = t => ({
|
|
|
129
154
|
* the reason names it, so the reader knows why the kit starts elsewhere.
|
|
130
155
|
*
|
|
131
156
|
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
157
|
+
* @param {import('./rank.mjs').IdeaKind} kind
|
|
132
158
|
* @param {SearchResultEntry[]} pages
|
|
133
159
|
* @param {boolean} directMatch
|
|
134
160
|
* @param {PageTemplate[]} catalog
|
|
161
|
+
* @param {string} idea
|
|
135
162
|
* @returns {Omit<BuildStart, 'alternatives'> | null}
|
|
136
163
|
*/
|
|
137
|
-
function chooseStart(ranked, pages, directMatch, catalog) {
|
|
164
|
+
function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
|
|
138
165
|
const direct = directMatch ? pages[0].name : null;
|
|
139
166
|
const unready =
|
|
140
167
|
direct && !catalog.some(t => t.name === direct) ? direct : null;
|
|
@@ -142,20 +169,52 @@ function chooseStart(ranked, pages, directMatch, catalog) {
|
|
|
142
169
|
// match the ranker outweighed is named, and so are the loose page matches
|
|
143
170
|
// search listed when the kit falls back to the shell.
|
|
144
171
|
const loose = pages.map(p => `\`${p.name}\``).join(', ');
|
|
145
|
-
|
|
172
|
+
/**
|
|
173
|
+
* A part's or an edit's reason, naming a direct match that is not the start.
|
|
174
|
+
* @param {string} place
|
|
175
|
+
* @param {string} startName
|
|
176
|
+
*/
|
|
177
|
+
const placed = (place, startName) =>
|
|
178
|
+
direct && direct !== startName
|
|
179
|
+
? `Search matched \`${direct}\` by name, but ${place}`
|
|
180
|
+
: place[0].toUpperCase() + place.slice(1);
|
|
181
|
+
const proposed = pickStart(ranked, kind);
|
|
182
|
+
// The checked-in word weights (weights.mjs), blended with the ranker's
|
|
183
|
+
// scores, decide the start of a whole page. A part or an edit starts where
|
|
184
|
+
// the ranker's placement rules put it (spec:AST-048/FR3).
|
|
185
|
+
const weighed =
|
|
186
|
+
kind === 'page'
|
|
187
|
+
? weighStart(idea, ranked, proposed, catalog, {
|
|
188
|
+
weights: loadWeights(),
|
|
189
|
+
newPage: asksForNewPage(idea, catalog),
|
|
190
|
+
})
|
|
191
|
+
: undefined;
|
|
192
|
+
// A shell start keeps the shell the ranker named, if any, and never replaces
|
|
193
|
+
// the template the ranker chose for a page search matched directly.
|
|
194
|
+
const pick =
|
|
195
|
+
weighed === undefined
|
|
196
|
+
? proposed
|
|
197
|
+
: weighed === null
|
|
198
|
+
? proposed?.family === 'Shell' || (proposed && direct && !unready)
|
|
199
|
+
? proposed
|
|
200
|
+
: null
|
|
201
|
+
: (ranked.find(r => r.name === weighed) ?? proposed);
|
|
146
202
|
const closest = pick && catalog.find(t => t.name === pick.name);
|
|
147
|
-
if (closest) {
|
|
203
|
+
if (pick && closest) {
|
|
148
204
|
const agrees = closest.name === direct;
|
|
205
|
+
const place = placement(kind, pick.base && pick.familyNamed);
|
|
149
206
|
return {
|
|
150
207
|
...asTemplate(closest),
|
|
151
208
|
basis: agrees ? 'direct' : 'closest',
|
|
152
|
-
reason:
|
|
153
|
-
?
|
|
154
|
-
:
|
|
155
|
-
?
|
|
156
|
-
:
|
|
157
|
-
?
|
|
158
|
-
:
|
|
209
|
+
reason: unready
|
|
210
|
+
? `\`${unready}\` matches but is not ready yet; this is the closest ready template.`
|
|
211
|
+
: place
|
|
212
|
+
? placed(place, closest.name)
|
|
213
|
+
: agrees
|
|
214
|
+
? 'Matches the idea.'
|
|
215
|
+
: direct
|
|
216
|
+
? `Search matched \`${direct}\` by name, but this template fits more of the idea.`
|
|
217
|
+
: 'The closest template; none is exactly this page.',
|
|
159
218
|
};
|
|
160
219
|
}
|
|
161
220
|
for (const id of FALLBACK_STARTS) {
|
|
@@ -163,19 +222,26 @@ function chooseStart(ranked, pages, directMatch, catalog) {
|
|
|
163
222
|
if (shell) {
|
|
164
223
|
// The shell can also be the ranker's best guess without the evidence to
|
|
165
224
|
// lead ("horizontal site navigation"); say so rather than "no match".
|
|
166
|
-
const nearest =
|
|
225
|
+
const nearest =
|
|
226
|
+
(ranked[0]?.name === shell.name && ranked[0].hits > 0) ||
|
|
227
|
+
(weighed === null && !!proposed && proposed.family !== 'Shell');
|
|
228
|
+
const place = placement(kind, false);
|
|
167
229
|
return {
|
|
168
230
|
...asTemplate(shell),
|
|
169
231
|
basis: 'fallback',
|
|
170
232
|
reason: unready
|
|
171
233
|
? `\`${unready}\` matches but is not ready yet, so start from the app shell.`
|
|
172
|
-
:
|
|
173
|
-
?
|
|
174
|
-
:
|
|
175
|
-
?
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
234
|
+
: place
|
|
235
|
+
? placed(place, shell.name)
|
|
236
|
+
: direct
|
|
237
|
+
? weighed === null
|
|
238
|
+
? `Search matched \`${direct}\` by name, but the app shell is the closer start.`
|
|
239
|
+
: `Search matched \`${direct}\` by name, but too little of the idea fits it, so start from the app shell.`
|
|
240
|
+
: nearest
|
|
241
|
+
? 'No template is a clear match; the app shell is the closest.'
|
|
242
|
+
: loose
|
|
243
|
+
? `Search matched ${loose} only loosely, so start from the app shell.`
|
|
244
|
+
: 'No template matched, so start from the app shell.',
|
|
179
245
|
};
|
|
180
246
|
}
|
|
181
247
|
}
|
|
@@ -301,8 +367,18 @@ export async function buildKit(query, options = {}) {
|
|
|
301
367
|
const wantsPages = !type || type === 'template';
|
|
302
368
|
const catalog = wantsPages ? await loadPageTemplates(cwd) : [];
|
|
303
369
|
const ranked = wantsPages ? rankPages(query, catalog) : [];
|
|
370
|
+
// A part of a page starts where it lives (spec:AST-048/FR3); the project's
|
|
371
|
+
// own components say what a part is. The search above already gathered them
|
|
372
|
+
// unless it was narrowed to templates.
|
|
373
|
+
const kind = wantsPages
|
|
374
|
+
? ideaKind(
|
|
375
|
+
query,
|
|
376
|
+
catalog,
|
|
377
|
+
searchedComponents(result) ?? (await loadComponents(cwd)),
|
|
378
|
+
)
|
|
379
|
+
: 'page';
|
|
304
380
|
const chosen = wantsPages
|
|
305
|
-
? chooseStart(ranked, matchedPages, directMatch, catalog)
|
|
381
|
+
? chooseStart(ranked, kind, matchedPages, directMatch, catalog, query)
|
|
306
382
|
: null;
|
|
307
383
|
// Name the ranker's next two templates beside the start: the reader judges
|
|
308
384
|
// meaning better than keywords do, and an acceptable template is in these
|
package/api/build/kit/rank.d.mts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
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
|
-
*/
|
|
8
4
|
/**
|
|
9
5
|
* Rank page templates against an idea, best first. Ties go to the template
|
|
10
6
|
* with the shorter id (the family's broader page), then by name.
|
|
@@ -14,6 +10,25 @@
|
|
|
14
10
|
* @returns {RankedPage[]}
|
|
15
11
|
*/
|
|
16
12
|
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
|
+
/**
|
|
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;
|
|
17
32
|
/**
|
|
18
33
|
* The next closest templates after the start, best first: the ones a reader
|
|
19
34
|
* should check the idea against when the start's shape is wrong. Each matched
|
|
@@ -26,19 +41,28 @@ export function rankPages(query: string, pages: PageTemplate[]): RankedPage[];
|
|
|
26
41
|
*/
|
|
27
42
|
export function pickAlternatives(ranked: RankedPage[], startName: string, count?: number): RankedPage[];
|
|
28
43
|
/**
|
|
29
|
-
* The template to start from, or null
|
|
30
|
-
* evidence to lead
|
|
31
|
-
*
|
|
44
|
+
* The template to start from, or null for the kit's neutral app shell. A page
|
|
45
|
+
* needs evidence to lead: two matched terms, the idea naming the template's
|
|
46
|
+
* family, or its container. A part starts from the base template of the family
|
|
47
|
+
* the idea places it in, else from the app shell (spec:AST-048/FR3); an edit of
|
|
48
|
+
* a page the builder already has starts from the app shell (FR9). Either way,
|
|
49
|
+
* the app shell is the shell template the idea describes when one leads.
|
|
32
50
|
*
|
|
33
51
|
* @param {RankedPage[]} ranked
|
|
52
|
+
* @param {IdeaKind} [kind]
|
|
34
53
|
* @returns {RankedPage | null}
|
|
35
54
|
*/
|
|
36
|
-
export function pickStart(ranked: RankedPage[]): RankedPage | null;
|
|
55
|
+
export function pickStart(ranked: RankedPage[], kind?: IdeaKind): RankedPage | null;
|
|
37
56
|
export type PageTemplate = import("../_adapter.mjs").PageTemplate;
|
|
57
|
+
export type ComponentWords = import("../_adapter.mjs").ComponentWords;
|
|
38
58
|
export type RankedPage = {
|
|
39
59
|
name: string;
|
|
40
60
|
score: number;
|
|
41
61
|
hits: number;
|
|
42
62
|
familyNamed: boolean;
|
|
43
63
|
containerMatched: boolean;
|
|
64
|
+
family: string;
|
|
65
|
+
base: boolean;
|
|
66
|
+
matched: Set<string>;
|
|
44
67
|
};
|
|
68
|
+
export type IdeaKind = "page" | "part" | "edit";
|