@astryxdesign/cli 0.7.3-canary.ca48bb7 → 0.7.3-canary.cac3d8d
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.mjs +37 -25
- package/api/build/blocks/blocks.d.mts +68 -20
- package/api/build/blocks/blocks.mjs +472 -196
- package/api/build/blocks/blocks.test.mjs +185 -168
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/answer.d.mts +4 -1
- package/api/build/kit/answer.mjs +11 -3
- package/api/build/kit/signals.d.mts +11 -0
- package/api/build/kit/signals.mjs +8 -7
- package/api/build/kit/weights.d.mts +8 -22
- package/api/build/kit/weights.mjs +87 -8
- package/api/build/kit/weights.test.mjs +96 -0
- package/api/build/tree.mjs +2 -1
- package/api/build/tree.test.mjs +27 -27
- package/api/component/_adapter.mjs +39 -5
- package/api/discover/_adapter.d.mts +1 -2
- package/api/discover/_adapter.mjs +6 -8
- package/api/discover/discover.mjs +0 -1
- package/api/docs/_adapter.mjs +4 -0
- package/api/doctor/_adapter.d.mts +33 -13
- package/api/doctor/_adapter.mjs +55 -25
- package/api/doctor/doctor.d.mts +23 -5
- package/api/doctor/doctor.mjs +81 -16
- package/api/doctor/doctor.test.mjs +58 -0
- package/api/search/_gather-templates.d.mts +0 -1
- package/api/search/_gather-templates.mjs +25 -0
- package/api/search/search.integration-block.test.mjs +100 -0
- package/api/template/template.mjs +5 -1
- package/assets/docs/tree/ci-and-containers.doc.mjs +13 -0
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/outside-project.test.mjs +99 -0
- package/clients/cli/commands/setup-nudge.test.mjs +17 -0
- package/clients/cli/index.mjs +25 -8
- package/foundation/agent-docs/agent-doc-state.d.mts +12 -0
- package/foundation/agent-docs/agent-doc-state.mjs +24 -2
- package/foundation/agent-docs/agent-docs.mjs +5 -5
- package/foundation/agent-docs/computer-agent-text.d.mts +39 -2
- package/foundation/agent-docs/computer-agent-text.mjs +135 -8
- package/foundation/agent-docs/computer-agent-text.test.mjs +99 -2
- package/foundation/integrations/public-imports.mjs +1 -1
- package/foundation/release/cache.test.mjs +24 -21
- package/foundation/release/global-state.d.mts +8 -4
- package/foundation/release/global-state.mjs +4 -2
- package/foundation/release/notices.d.mts +62 -8
- package/foundation/release/notices.mjs +136 -25
- package/foundation/release/notices.test.mjs +21 -0
- package/foundation/text/string-utils.d.mts +2 -1
- package/foundation/text/string-utils.mjs +16 -5
- package/foundation/text/suggest-order.d.mts +72 -0
- package/foundation/text/suggest-order.mjs +363 -0
- package/foundation/text/suggest-order.test.mjs +259 -0
- package/package.json +9 -9
package/api/build/build.type.mjs
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
* @property {boolean} data.directMatch True when the top page template is a confident direct match.
|
|
78
78
|
* @property {BuildStart | null} data.start The page template to start from: the ranker's pick, 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
|
-
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.blocks Drop-in block patterns covering parts of the idea (≤5).
|
|
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.
|
|
82
82
|
* @property {string[]} data.frame Always-on page-shell component names. Every page template already uses them.
|
|
83
83
|
* @property {string[]} data.foundation Always-on layout/typography/action component names. Every page template already uses them.
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @param {import('./signals.mjs').KitSignals} signals
|
|
12
12
|
* @param {string[]} [blocks] block names; build's own when omitted
|
|
13
|
+
* @param {Map<string, import('../../search/search.type.mjs').SearchResultEntry>} [picked]
|
|
14
|
+
* the block picker's own entry (its real score and reason) for each named
|
|
15
|
+
* block search did not return
|
|
13
16
|
* @returns {import('../build.type.mjs').BuildKitResponse}
|
|
14
17
|
*/
|
|
15
|
-
export function kitAnswer(signals: import("./signals.mjs").KitSignals, blocks?: string[]): import("../build.type.mjs").BuildKitResponse;
|
|
18
|
+
export function kitAnswer(signals: import("./signals.mjs").KitSignals, blocks?: string[], picked?: Map<string, import("../../search/search.type.mjs").SearchResultEntry>): import("../build.type.mjs").BuildKitResponse;
|
package/api/build/kit/answer.mjs
CHANGED
|
@@ -32,9 +32,16 @@ const THIN_KIT = 3;
|
|
|
32
32
|
*
|
|
33
33
|
* @param {import('./signals.mjs').KitSignals} signals
|
|
34
34
|
* @param {string[]} [blocks] block names; build's own when omitted
|
|
35
|
+
* @param {Map<string, import('../../search/search.type.mjs').SearchResultEntry>} [picked]
|
|
36
|
+
* the block picker's own entry (its real score and reason) for each named
|
|
37
|
+
* block search did not return
|
|
35
38
|
* @returns {import('../build.type.mjs').BuildKitResponse}
|
|
36
39
|
*/
|
|
37
|
-
export function kitAnswer(
|
|
40
|
+
export function kitAnswer(
|
|
41
|
+
signals,
|
|
42
|
+
blocks = signals.kitBlocks,
|
|
43
|
+
picked = new Map(),
|
|
44
|
+
) {
|
|
38
45
|
// Entries by name, in build's order: two packages can ship a block with the
|
|
39
46
|
// same name, and each name in `blocks` takes the next entry of that name, so
|
|
40
47
|
// both stay listed.
|
|
@@ -48,11 +55,12 @@ export function kitAnswer(signals, blocks = signals.kitBlocks) {
|
|
|
48
55
|
.flatMap(name => {
|
|
49
56
|
const entry = own.get(name)?.shift();
|
|
50
57
|
if (entry) return [entry];
|
|
51
|
-
// A block build does not name itself keeps search's own entry, once
|
|
58
|
+
// A block build does not name itself keeps search's own entry, once;
|
|
59
|
+
// one search did not return keeps the picker's entry.
|
|
52
60
|
const found =
|
|
53
61
|
own.has(name) || added.has(name)
|
|
54
62
|
? undefined
|
|
55
|
-
: signals.searchedEntries.get(name);
|
|
63
|
+
: (signals.searchedEntries.get(name) ?? picked.get(name));
|
|
56
64
|
if (!found) return [];
|
|
57
65
|
added.add(name);
|
|
58
66
|
return [found];
|
|
@@ -65,4 +65,15 @@ export type KitSignals = {
|
|
|
65
65
|
* the blocks, named, searched or scaffoldable, whose package is not Core's
|
|
66
66
|
*/
|
|
67
67
|
foreign: string[];
|
|
68
|
+
/**
|
|
69
|
+
* every block the project can scaffold
|
|
70
|
+
*/
|
|
71
|
+
catalog: import("../_adapter.mjs").BlockTemplate[];
|
|
72
|
+
/**
|
|
73
|
+
* every component, with its keywords
|
|
74
|
+
*/
|
|
75
|
+
components: {
|
|
76
|
+
name: string;
|
|
77
|
+
keywords?: string[];
|
|
78
|
+
}[];
|
|
68
79
|
};
|
|
@@ -103,6 +103,8 @@ const ALWAYS = new Set([...FRAME, ...FOUNDATION]);
|
|
|
103
103
|
* @property {Map<string, SearchResultEntry>} searchedEntries search's entry for each of those blocks (the first of a name)
|
|
104
104
|
* @property {Map<string, string>} blockText each of those blocks' display name and description, from the catalog
|
|
105
105
|
* @property {string[]} foreign the blocks, named, searched or scaffoldable, whose package is not Core's
|
|
106
|
+
* @property {import('../_adapter.mjs').BlockTemplate[]} catalog every block the project can scaffold
|
|
107
|
+
* @property {{name: string, keywords?: string[]}[]} components every component, with its keywords
|
|
106
108
|
*/
|
|
107
109
|
|
|
108
110
|
/**
|
|
@@ -232,13 +234,10 @@ export async function kitSignals(query, options = {}) {
|
|
|
232
234
|
// A part of a page starts where it lives (spec:AST-048/FR3); the project's
|
|
233
235
|
// own components say what a part is. The search above already gathered them
|
|
234
236
|
// unless it was narrowed to templates.
|
|
235
|
-
const
|
|
236
|
-
?
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
searchedComponents(result) ?? (await loadComponents(cwd)),
|
|
240
|
-
)
|
|
241
|
-
: 'page';
|
|
237
|
+
const components = wantsPages
|
|
238
|
+
? (searchedComponents(result) ?? (await loadComponents(cwd)))
|
|
239
|
+
: [];
|
|
240
|
+
const kind = wantsPages ? ideaKind(query, catalog, components) : 'page';
|
|
242
241
|
const chosen = wantsPages
|
|
243
242
|
? chooseStart(ranked, kind, matchedPages, directMatch, catalog, query)
|
|
244
243
|
: null;
|
|
@@ -283,6 +282,8 @@ export async function kitSignals(query, options = {}) {
|
|
|
283
282
|
.filter(b => searchedBlocks.some(r => r.name === b.name))
|
|
284
283
|
.map(b => [b.name, `${b.displayName} ${b.description}`]),
|
|
285
284
|
),
|
|
285
|
+
catalog: templates.blocks,
|
|
286
|
+
components,
|
|
286
287
|
foreign: [
|
|
287
288
|
...new Set(
|
|
288
289
|
[...blocksKept, ...searchedBlocks, ...templates.blocks]
|
|
@@ -18,36 +18,16 @@ export function weightWords(idea: string): string[];
|
|
|
18
18
|
* @param {string} idea
|
|
19
19
|
* @param {import('./rank.mjs').RankedPage[]} ranked the ranker's output for the idea
|
|
20
20
|
* @param {import('./rank.mjs').RankedPage | null} pick the ranker's own start
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {DescribedTemplate[]} catalog the project's ready page templates
|
|
22
22
|
* @param {{weights?: WeightsFile | null, newPage?: boolean}} [options]
|
|
23
23
|
* `newPage`: the idea asks for a new page (rank.mjs `asksForNewPage`)
|
|
24
24
|
* @returns {string | null | undefined} a template id, null for the app shell,
|
|
25
25
|
* undefined without weights
|
|
26
26
|
*/
|
|
27
|
-
export function weighStart(idea: string, ranked: import("./rank.mjs").RankedPage[], pick: import("./rank.mjs").RankedPage | null, catalog: {
|
|
28
|
-
name: string;
|
|
29
|
-
}[], { weights, newPage }?: {
|
|
27
|
+
export function weighStart(idea: string, ranked: import("./rank.mjs").RankedPage[], pick: import("./rank.mjs").RankedPage | null, catalog: DescribedTemplate[], { weights, newPage }?: {
|
|
30
28
|
weights?: WeightsFile | null;
|
|
31
29
|
newPage?: boolean;
|
|
32
30
|
}): string | null | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* @file Word weights for `build`'s START (spec:AST-048): a checked-in table of
|
|
35
|
-
* per-template word weights, blended with the page ranker's own scores, picks
|
|
36
|
-
* the template an idea starts from.
|
|
37
|
-
*
|
|
38
|
-
* @input An idea, the ranker's output for it (`rankPages`, `pickStart`), the
|
|
39
|
-
* project's ready page templates, and the weights (`weights.json` beside this
|
|
40
|
-
* file, read by the adapter): the candidates (the app shell as `SHELL`, then page template ids), one or more
|
|
41
|
-
* word tables (stemmed words, a bias per candidate, and one row of weights
|
|
42
|
-
* per word, a character per candidate) and the blend numbers.
|
|
43
|
-
* @output `weighStart(idea, ranked, pick, catalog)`: the template id to start
|
|
44
|
-
* from, null for the app shell, or undefined when no table is available, in
|
|
45
|
-
* which case the ranker's own pick stands.
|
|
46
|
-
* @position Beside rank.mjs (api/build/kit/); kit.mjs calls it for every
|
|
47
|
-
* whole page (a part or an edit follows the ranker's placement rules). The
|
|
48
|
-
* ranker's pick of a template the tables do not list stands, so a new
|
|
49
|
-
* template can start a build.
|
|
50
|
-
*/
|
|
51
31
|
/** The app shell, as one candidate. */
|
|
52
32
|
export const SHELL: "SHELL";
|
|
53
33
|
export type WeightTable = {
|
|
@@ -80,3 +60,9 @@ export type WeightsFile = {
|
|
|
80
60
|
*/
|
|
81
61
|
blend: number[];
|
|
82
62
|
};
|
|
63
|
+
export type DescribedTemplate = {
|
|
64
|
+
name: string;
|
|
65
|
+
displayName?: string | undefined;
|
|
66
|
+
category?: string | undefined;
|
|
67
|
+
keywords?: string[] | undefined;
|
|
68
|
+
};
|
|
@@ -14,11 +14,13 @@
|
|
|
14
14
|
* from, null for the app shell, or undefined when no table is available, in
|
|
15
15
|
* which case the ranker's own pick stands.
|
|
16
16
|
* @position Beside rank.mjs (api/build/kit/); kit.mjs calls it for every
|
|
17
|
-
* whole page (a part or an edit follows the ranker's placement rules).
|
|
18
|
-
*
|
|
19
|
-
* template can start a build.
|
|
17
|
+
* whole page (a part or an edit follows the ranker's placement rules). A
|
|
18
|
+
* template the tables do not list competes on its own descriptor's words
|
|
19
|
+
* (`ownWords`), so a new template can start a build.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
import {STOPWORDS} from '../../search/search.mjs';
|
|
23
|
+
|
|
22
24
|
/** The app shell, as one candidate. */
|
|
23
25
|
export const SHELL = 'SHELL';
|
|
24
26
|
const SHELL_FAMILY = 'Shell';
|
|
@@ -225,12 +227,65 @@ function memberFeatures(v) {
|
|
|
225
227
|
]);
|
|
226
228
|
}
|
|
227
229
|
|
|
230
|
+
/**
|
|
231
|
+
* @typedef {object} DescribedTemplate
|
|
232
|
+
* @property {string} name
|
|
233
|
+
* @property {string} [displayName]
|
|
234
|
+
* @property {string} [category]
|
|
235
|
+
* @property {string[]} [keywords]
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* How many of the idea's stemmed words a template's own descriptor names: its
|
|
240
|
+
* display name, its category, and its keywords, less search's stopwords.
|
|
241
|
+
* @param {string} name
|
|
242
|
+
* @param {DescribedTemplate[]} catalog
|
|
243
|
+
* @param {Set<string>} words the idea's stemmed words, less search's stopwords
|
|
244
|
+
*/
|
|
245
|
+
function ownWords(name, catalog, words) {
|
|
246
|
+
const t = catalog.find(c => c.name === name);
|
|
247
|
+
if (!t) return 0;
|
|
248
|
+
// Search's stopwords are no evidence: "to" in a "to-do list" keyword must
|
|
249
|
+
// not answer the "to" of "rows to track orders".
|
|
250
|
+
const own = new Set(
|
|
251
|
+
weightWords(
|
|
252
|
+
[t.displayName ?? '', t.category ?? '', ...(t.keywords ?? [])].join(' '),
|
|
253
|
+
)
|
|
254
|
+
.filter(w => !STOPWORDS.has(w))
|
|
255
|
+
.map(stem),
|
|
256
|
+
);
|
|
257
|
+
let n = 0;
|
|
258
|
+
for (const w of words) if (own.has(w)) n++;
|
|
259
|
+
return n;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** How many fewer own words a template whose family the idea names first may
|
|
263
|
+
* name than the listed template it competes with, and still start. */
|
|
264
|
+
const FAMILY_SLACK = 2;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Where the idea first names a template's family, the part of its category
|
|
268
|
+
* before ` - ` ("Dashboard" in "Dashboard - Analytics"): the index of that
|
|
269
|
+
* word among the idea's stemmed words, or Infinity when it does not.
|
|
270
|
+
* @param {string} name
|
|
271
|
+
* @param {DescribedTemplate[]} catalog
|
|
272
|
+
* @param {string[]} order the idea's stemmed words, in order
|
|
273
|
+
*/
|
|
274
|
+
function familyAt(name, catalog, order) {
|
|
275
|
+
const t = catalog.find(c => c.name === name);
|
|
276
|
+
const family = weightWords(String(t?.category ?? '').split(' - ')[0]).map(
|
|
277
|
+
stem,
|
|
278
|
+
);
|
|
279
|
+
const at = family.length ? order.findIndex(w => family.includes(w)) : -1;
|
|
280
|
+
return at < 0 ? Infinity : at;
|
|
281
|
+
}
|
|
282
|
+
|
|
228
283
|
/**
|
|
229
284
|
* Where an idea starts, by the blended weights.
|
|
230
285
|
* @param {string} idea
|
|
231
286
|
* @param {import('./rank.mjs').RankedPage[]} ranked the ranker's output for the idea
|
|
232
287
|
* @param {import('./rank.mjs').RankedPage | null} pick the ranker's own start
|
|
233
|
-
* @param {
|
|
288
|
+
* @param {DescribedTemplate[]} catalog the project's ready page templates
|
|
234
289
|
* @param {{weights?: WeightsFile | null, newPage?: boolean}} [options]
|
|
235
290
|
* `newPage`: the idea asks for a new page (rank.mjs `asksForNewPage`)
|
|
236
291
|
* @returns {string | null | undefined} a template id, null for the app shell,
|
|
@@ -292,10 +347,34 @@ export function weighStart(
|
|
|
292
347
|
pick && pick.family !== SHELL_FAMILY && cands.includes(pick.name)
|
|
293
348
|
? pick.name
|
|
294
349
|
: null;
|
|
295
|
-
//
|
|
296
|
-
|
|
297
|
-
//
|
|
298
|
-
|
|
350
|
+
// A template the ranker placed by its frame stays (spec:AST-048/FR3).
|
|
351
|
+
if (kept && pick?.containerMatched) return kept;
|
|
352
|
+
// The tables cannot judge a template they do not list (an integration's
|
|
353
|
+
// template, or one added since they were fit), so its own descriptor
|
|
354
|
+
// decides: the ranker's pick stands when the idea names as many words of its
|
|
355
|
+
// display name, category and keywords as of the tables' first listed
|
|
356
|
+
// template's, or names its family first and nearly as many; otherwise that
|
|
357
|
+
// listed template starts. Nothing learned about the template is involved,
|
|
358
|
+
// so a new template competes on its own words.
|
|
359
|
+
if (kept && !position.has(kept)) {
|
|
360
|
+
const listed = best(c => c !== SHELL && position.has(c));
|
|
361
|
+
if (!listed) return kept;
|
|
362
|
+
// The idea's own words, less search's stopwords: "basically" must not
|
|
363
|
+
// answer the "Basic" of a category.
|
|
364
|
+
const content = weightWords(idea).filter(w => !STOPWORDS.has(w));
|
|
365
|
+
const said = new Set(content.map(stem));
|
|
366
|
+
const mine = ownWords(kept, catalog, said);
|
|
367
|
+
const theirs = ownWords(listed, catalog, said);
|
|
368
|
+
if (mine >= theirs) return kept;
|
|
369
|
+
// An idea that names the template's family before the listed one's
|
|
370
|
+
// ("a dashboard with a data table") is that family's page, unless it
|
|
371
|
+
// names far more of the listed template's words.
|
|
372
|
+
const order = content.map(stem);
|
|
373
|
+
return familyAt(kept, catalog, order) < familyAt(listed, catalog, order) &&
|
|
374
|
+
mine >= theirs - FAMILY_SLACK
|
|
375
|
+
? kept
|
|
376
|
+
: listed;
|
|
377
|
+
}
|
|
299
378
|
const top = best(() => true);
|
|
300
379
|
if (top !== SHELL) return top;
|
|
301
380
|
// An idea that asks for a new page keeps the ranker's template rather than
|
|
@@ -125,6 +125,102 @@ describe('weighStart', () => {
|
|
|
125
125
|
expect(start).toBe('fresh');
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
+
describe('a template the tables do not list (cold start)', () => {
|
|
129
|
+
// A made-up family the tables have never seen, described only by its own
|
|
130
|
+
// descriptor, next to listed templates with descriptors of their own.
|
|
131
|
+
const catalog = [
|
|
132
|
+
{name: 'board', displayName: 'Kanban Board', keywords: ['kanban']},
|
|
133
|
+
{name: 'charts', displayName: 'Charts', category: 'Charts - Overview'},
|
|
134
|
+
{name: 'grid', displayName: 'Grid'},
|
|
135
|
+
{
|
|
136
|
+
name: 'gauge-fleet',
|
|
137
|
+
displayName: 'Fleet Gauges',
|
|
138
|
+
category: 'Gauges - Fleet',
|
|
139
|
+
keywords: ['gauges', 'fleet', 'meters'],
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
it('starts from it when the idea names its own words', () => {
|
|
144
|
+
const ranked = [page('gauge-fleet', 9, 'Gauges'), ...RANKED];
|
|
145
|
+
const start = weighStart(
|
|
146
|
+
'fleet gauges with meters per kanban lane',
|
|
147
|
+
ranked,
|
|
148
|
+
ranked[0],
|
|
149
|
+
catalog,
|
|
150
|
+
{weights: WEIGHTS},
|
|
151
|
+
);
|
|
152
|
+
expect(start).toBe('gauge-fleet');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('starts from it when the idea names its family first', () => {
|
|
156
|
+
const ranked = [page('gauge-fleet', 9, 'Gauges'), ...RANKED];
|
|
157
|
+
const start = weighStart(
|
|
158
|
+
'gauges page with a kanban board',
|
|
159
|
+
ranked,
|
|
160
|
+
ranked[0],
|
|
161
|
+
catalog,
|
|
162
|
+
{weights: WEIGHTS},
|
|
163
|
+
);
|
|
164
|
+
expect(start).toBe('gauge-fleet');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("never counts a stopword from another template's keywords", () => {
|
|
168
|
+
// "side" in grid's "side by side" keyword is one of search's stopwords;
|
|
169
|
+
// it must not answer the idea's "sides", which is not.
|
|
170
|
+
const own = [
|
|
171
|
+
{name: 'board'},
|
|
172
|
+
{name: 'charts'},
|
|
173
|
+
{
|
|
174
|
+
name: 'grid',
|
|
175
|
+
displayName: 'Grid',
|
|
176
|
+
keywords: ['side by side', 'orders'],
|
|
177
|
+
},
|
|
178
|
+
{name: 'fold', displayName: 'Folding Rows'},
|
|
179
|
+
];
|
|
180
|
+
const ranked = [page('fold', 9, 'Fold'), ...RANKED];
|
|
181
|
+
const start = weighStart(
|
|
182
|
+
'rows on two sides with orders on cards',
|
|
183
|
+
ranked,
|
|
184
|
+
ranked[0],
|
|
185
|
+
own,
|
|
186
|
+
{weights: WEIGHTS},
|
|
187
|
+
);
|
|
188
|
+
expect(start).toBe('fold');
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("never counts a stopword from the idea's words", () => {
|
|
192
|
+
// "basically" is one of search's stopwords and stems to "basic", the
|
|
193
|
+
// word of grid's category; it must not tip the count to grid.
|
|
194
|
+
const own = [
|
|
195
|
+
{name: 'board'},
|
|
196
|
+
{name: 'charts'},
|
|
197
|
+
{name: 'grid', displayName: 'Grid', category: 'Grid - Basic'},
|
|
198
|
+
{name: 'fold', displayName: 'Folding Rows'},
|
|
199
|
+
];
|
|
200
|
+
const ranked = [page('fold', 9, 'Fold'), ...RANKED];
|
|
201
|
+
const start = weighStart(
|
|
202
|
+
'basically a grid of rows on cards',
|
|
203
|
+
ranked,
|
|
204
|
+
ranked[0],
|
|
205
|
+
own,
|
|
206
|
+
{weights: WEIGHTS},
|
|
207
|
+
);
|
|
208
|
+
expect(start).toBe('fold');
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('yields to the listed template whose own words the idea names more', () => {
|
|
212
|
+
const ranked = [page('gauge-fleet', 9, 'Gauges'), ...RANKED];
|
|
213
|
+
const start = weighStart(
|
|
214
|
+
'a kanban board with a fleet column',
|
|
215
|
+
ranked,
|
|
216
|
+
ranked[0],
|
|
217
|
+
catalog,
|
|
218
|
+
{weights: WEIGHTS},
|
|
219
|
+
);
|
|
220
|
+
expect(start).toBe('board');
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
128
224
|
it("keeps the ranker's template for an idea that asks for a new page", () => {
|
|
129
225
|
const start = weighStart('the existing page', RANKED, RANKED[0], CATALOG, {
|
|
130
226
|
weights: WEIGHTS,
|
package/api/build/tree.mjs
CHANGED
|
@@ -35,7 +35,8 @@ const main = defineSearcher({
|
|
|
35
35
|
run: async (request, ctx) => {
|
|
36
36
|
const signals = await kitSignals(request.query, request.options);
|
|
37
37
|
if (!ctx.blocks) return kitAnswer(signals);
|
|
38
|
-
|
|
38
|
+
const picked = pickBlocks(request.query, signals, ctx.blocks);
|
|
39
|
+
return kitAnswer(signals, picked.names, picked.entries);
|
|
39
40
|
},
|
|
40
41
|
});
|
|
41
42
|
|
package/api/build/tree.test.mjs
CHANGED
|
@@ -60,55 +60,55 @@ const PINNED = [
|
|
|
60
60
|
'analytics dashboard with a KPI row and a sortable table',
|
|
61
61
|
[
|
|
62
62
|
'TableSortableTable',
|
|
63
|
-
'TableRichCellTable',
|
|
64
|
-
'TableBulkActionsTable',
|
|
65
63
|
'TableGridDividersTable',
|
|
66
|
-
'
|
|
64
|
+
'TableShowcase',
|
|
65
|
+
'TableGroupedRowsTable',
|
|
66
|
+
'TableStripedTable',
|
|
67
67
|
],
|
|
68
68
|
],
|
|
69
69
|
[
|
|
70
70
|
'settings page with notification toggles and a save bar',
|
|
71
71
|
[
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
72
|
+
'SwitchShowcase',
|
|
73
|
+
'SwitchSettingsPanel',
|
|
74
|
+
'ToggleButtonShowcase',
|
|
75
|
+
'ToggleButtonStates',
|
|
76
|
+
'SwitchWithDescription',
|
|
77
77
|
],
|
|
78
78
|
],
|
|
79
79
|
[
|
|
80
80
|
'empty state for a question bank with an import button',
|
|
81
81
|
[
|
|
82
|
-
'EmptyStateActions',
|
|
83
|
-
'EmptyStateCompact',
|
|
84
82
|
'EmptyStateContainer',
|
|
85
83
|
'EmptyStateShowcase',
|
|
86
|
-
'
|
|
84
|
+
'EmptyStateCompact',
|
|
85
|
+
'EmptyStateActions',
|
|
86
|
+
'CommandPaletteEmptyShowcase',
|
|
87
87
|
],
|
|
88
88
|
],
|
|
89
89
|
[
|
|
90
90
|
'login form with single sign-on buttons',
|
|
91
91
|
[
|
|
92
|
-
'
|
|
92
|
+
'ButtonWithIcon',
|
|
93
93
|
'CardWithInnerLayout',
|
|
94
|
-
'
|
|
95
|
-
'
|
|
96
|
-
'
|
|
94
|
+
'ButtonVariants',
|
|
95
|
+
'FormLayoutShowcase',
|
|
96
|
+
'FormLayoutMixedControls',
|
|
97
97
|
],
|
|
98
98
|
],
|
|
99
99
|
[
|
|
100
100
|
'calendar for booking appointments',
|
|
101
101
|
[
|
|
102
|
-
'CalendarRangeWithValue',
|
|
103
102
|
'CalendarSingle',
|
|
104
|
-
'CalendarTwoMonths',
|
|
105
|
-
'CalendarConstraints',
|
|
106
103
|
'CalendarShowcase',
|
|
104
|
+
'CalendarConstraints',
|
|
105
|
+
'CalendarRangeWithValue',
|
|
106
|
+
'CalendarTwoMonths',
|
|
107
107
|
],
|
|
108
108
|
],
|
|
109
109
|
[
|
|
110
110
|
'kanban board for sprint tasks with a filter bar',
|
|
111
|
-
['ToolbarTableFilter', '
|
|
111
|
+
['ToolbarTableFilter', 'PowerSearchShowcase'],
|
|
112
112
|
],
|
|
113
113
|
];
|
|
114
114
|
|
|
@@ -125,16 +125,15 @@ afterAll(() => {
|
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
describe('build tree', () => {
|
|
128
|
-
it('keeps
|
|
129
|
-
const phrase = 'calendar for booking appointments';
|
|
128
|
+
it('keeps a block the request names by its exact name in build’s slot', async () => {
|
|
129
|
+
const phrase = 'calendar for booking appointments with CalendarTwoMonths';
|
|
130
130
|
const answer = await build(phrase, {cwd: REPO});
|
|
131
131
|
const own = await withListingCache(() => buildKit(phrase, {cwd: REPO}));
|
|
132
132
|
if (answer?.type !== 'build.kit' || own.type !== 'build.kit')
|
|
133
133
|
throw new Error('expected a kit');
|
|
134
|
-
own.data.blocks.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
});
|
|
134
|
+
const k = own.data.blocks.findIndex(b => b.name === 'CalendarTwoMonths');
|
|
135
|
+
expect(k).toBeGreaterThanOrEqual(0);
|
|
136
|
+
expect(answer.data.blocks[k].name).toBe('CalendarTwoMonths');
|
|
138
137
|
});
|
|
139
138
|
|
|
140
139
|
it('runs with the network and subprocesses blocked', async () => {
|
|
@@ -166,8 +165,9 @@ describe('build tree', () => {
|
|
|
166
165
|
expect(answer.data.start?.alternatives).toEqual(
|
|
167
166
|
own.data.start?.alternatives,
|
|
168
167
|
);
|
|
169
|
-
// Every block is build's own entry
|
|
170
|
-
// score and reason; never more blocks than
|
|
168
|
+
// Every block is build's own entry, one search returned, or the picker's
|
|
169
|
+
// own, each with its real score and reason; never more blocks than
|
|
170
|
+
// build's own.
|
|
171
171
|
expect(answer.data.blocks.length).toBe(own.data.blocks.length);
|
|
172
172
|
for (const b of answer.data.blocks) {
|
|
173
173
|
expect(b.score).toBeGreaterThan(0);
|
|
@@ -44,6 +44,10 @@ import {Project} from '../../foundation/config/project.mjs';
|
|
|
44
44
|
import {loadComponentDoc as loadValidatedComponentDoc} from '../../foundation/discovery/component-loader.mjs';
|
|
45
45
|
import {resolveComponentReplacements} from '../../foundation/discovery/component-replacement.mjs';
|
|
46
46
|
import {searchComponents} from '../../foundation/text/string-utils.mjs';
|
|
47
|
+
import {
|
|
48
|
+
rankComponentSuggestions,
|
|
49
|
+
synonymMatches,
|
|
50
|
+
} from '../../foundation/text/suggest-order.mjs';
|
|
47
51
|
import {AstryxError, coreDirOrThrow} from '../error.mjs';
|
|
48
52
|
import {
|
|
49
53
|
componentLinkProvider,
|
|
@@ -51,6 +55,28 @@ import {
|
|
|
51
55
|
loadDocsCatalog,
|
|
52
56
|
} from '../docs/_adapter.mjs';
|
|
53
57
|
|
|
58
|
+
/** @type {Record<string, {synonyms?: string[]}> | undefined} */
|
|
59
|
+
let cards;
|
|
60
|
+
/**
|
|
61
|
+
* Search's component cards (each component's other names), read once.
|
|
62
|
+
* @returns {Record<string, {synonyms?: string[]}>}
|
|
63
|
+
*/
|
|
64
|
+
function searchCards() {
|
|
65
|
+
if (!cards) {
|
|
66
|
+
try {
|
|
67
|
+
cards = JSON.parse(
|
|
68
|
+
fs.readFileSync(
|
|
69
|
+
new URL('../search/_cards.json', import.meta.url),
|
|
70
|
+
'utf8',
|
|
71
|
+
),
|
|
72
|
+
);
|
|
73
|
+
} catch {
|
|
74
|
+
cards = {};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return /** @type {Record<string, {synonyms?: string[]}>} */ (cards);
|
|
78
|
+
}
|
|
79
|
+
|
|
54
80
|
export {CORE_PACKAGE, unscopedComponentOwners};
|
|
55
81
|
|
|
56
82
|
/**
|
|
@@ -463,12 +489,20 @@ export async function resolveUnscopedDoc(dirName, {coreDir, cwd, name}) {
|
|
|
463
489
|
resolvedOwnerPackage = CORE_PACKAGE;
|
|
464
490
|
resolvedSourcePath = findComponentSource(coreDir, resolvedName);
|
|
465
491
|
} else {
|
|
492
|
+
// How many to suggest: the near-top results, at most five and at
|
|
493
|
+
// least two. Which ones, and in what order, is the suggestion
|
|
494
|
+
// ranking's call.
|
|
466
495
|
const threshold = Math.max(topScore - 20, 1);
|
|
467
|
-
const
|
|
468
|
-
.filter(r => r.score >= threshold)
|
|
469
|
-
.
|
|
470
|
-
|
|
471
|
-
|
|
496
|
+
const count = Math.max(
|
|
497
|
+
results.filter(r => r.score >= threshold).slice(0, 5).length,
|
|
498
|
+
Math.min(2, results.length),
|
|
499
|
+
);
|
|
500
|
+
const candidates = rankComponentSuggestions(
|
|
501
|
+
dirName,
|
|
502
|
+
results,
|
|
503
|
+
Object.values(components).flat(),
|
|
504
|
+
synonymMatches(dirName, searchCards()),
|
|
505
|
+
).slice(0, count);
|
|
472
506
|
throw new AstryxError(
|
|
473
507
|
`No component named "${name}"`,
|
|
474
508
|
candidates.map(c => ({name: c.name, reason: c.reason})),
|
|
@@ -43,12 +43,11 @@ export function hasSources(project: Project | undefined): boolean;
|
|
|
43
43
|
* @param {Project | undefined} project
|
|
44
44
|
* @param {Array<{name: string}>} installed
|
|
45
45
|
* @param {Set<string>} declared
|
|
46
|
-
* @param {(name: string, version?: string) => string} add
|
|
47
46
|
* @returns {Promise<import('./discover.type.mjs').DiscoverAvailableEntry[]>}
|
|
48
47
|
*/
|
|
49
48
|
export function computerAvailableEntries(project: Project | undefined, installed: Array<{
|
|
50
49
|
name: string;
|
|
51
|
-
}>, declared: Set<string
|
|
50
|
+
}>, declared: Set<string>): Promise<import("./discover.type.mjs").DiscoverAvailableEntry[]>;
|
|
52
51
|
/**
|
|
53
52
|
* Package names the project's package.json declares in any dependency field.
|
|
54
53
|
* @param {Project | undefined} project
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
availableComputerIntegrations,
|
|
26
26
|
} from '../../foundation/config/project.mjs';
|
|
27
27
|
import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
|
|
28
|
+
import {projectAddCommand} from '../../foundation/release/notices.mjs';
|
|
28
29
|
import {hostedRun} from '../../foundation/runtime/package-root.mjs';
|
|
29
30
|
import {
|
|
30
31
|
scanAllPackages,
|
|
@@ -274,17 +275,14 @@ const COMPUTER_SOURCE = 'installed for this computer';
|
|
|
274
275
|
* @param {Project | undefined} project
|
|
275
276
|
* @param {Array<{name: string}>} installed
|
|
276
277
|
* @param {Set<string>} declared
|
|
277
|
-
* @param {(name: string, version?: string) => string} add
|
|
278
278
|
* @returns {Promise<import('./discover.type.mjs').DiscoverAvailableEntry[]>}
|
|
279
279
|
*/
|
|
280
|
-
export async function computerAvailableEntries(
|
|
281
|
-
project,
|
|
282
|
-
installed,
|
|
283
|
-
declared,
|
|
284
|
-
add,
|
|
285
|
-
) {
|
|
280
|
+
export async function computerAvailableEntries(project, installed, declared) {
|
|
286
281
|
const cwd = project?.cwd ?? process.cwd();
|
|
287
282
|
if (isOutsideProject(cwd)) return [];
|
|
283
|
+
// The same command doctor names: in the project spec:AST-040 FR9 defines,
|
|
284
|
+
// and none where FR9 finds no project.
|
|
285
|
+
const add = projectAddCommand(cwd);
|
|
288
286
|
const have = new Set([...installed.map(pkg => pkg.name), ...declared]);
|
|
289
287
|
return (await availableComputerIntegrations(cwd, have)).map(c => ({
|
|
290
288
|
name: c.name,
|
|
@@ -292,7 +290,7 @@ export async function computerAvailableEntries(
|
|
|
292
290
|
...(c.version ? {version: c.version} : {}),
|
|
293
291
|
...(c.description ? {description: c.description} : {}),
|
|
294
292
|
source: COMPUTER_SOURCE,
|
|
295
|
-
install: add(c.name),
|
|
293
|
+
...(add ? {install: add(c.name)} : {}),
|
|
296
294
|
}));
|
|
297
295
|
}
|
|
298
296
|
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -71,6 +71,7 @@ import {
|
|
|
71
71
|
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
72
72
|
import {AstryxError} from '../error.mjs';
|
|
73
73
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
74
|
+
import {orderRouteSuggestions} from '../../foundation/text/suggest-order.mjs';
|
|
74
75
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
75
76
|
|
|
76
77
|
export {OVERLAY_LANGUAGES, overlayLanguages};
|
|
@@ -1622,6 +1623,9 @@ export async function unknownTopicError(topic, catalog) {
|
|
|
1622
1623
|
...catalog.names().map(name => ({name, reason: 'available topic'})),
|
|
1623
1624
|
];
|
|
1624
1625
|
}
|
|
1626
|
+
if (typeof topic === 'string') {
|
|
1627
|
+
suggestions = orderRouteSuggestions(topic, suggestions);
|
|
1628
|
+
}
|
|
1625
1629
|
// A route that moved names where it went, ahead of the usual suggestions
|
|
1626
1630
|
// (spec:AST-046 FR9, FR6).
|
|
1627
1631
|
const moved = movedRoute(topic, tree);
|