@astryxdesign/cli 0.7.3-canary.641d08e → 0.7.3-canary.6e266c2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -63
- package/api/build/blocks/blocks.d.mts +6 -4
- package/api/build/blocks/blocks.mjs +103 -20
- package/api/build/blocks/blocks.test.mjs +126 -13
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/kit/answer.d.mts +5 -4
- package/api/build/kit/answer.mjs +114 -12
- package/api/build/kit/answer.test.mjs +73 -3
- package/api/build/kit/signals.d.mts +8 -0
- package/api/build/kit/signals.mjs +10 -0
- package/api/build/tree.test.mjs +19 -11
- package/api/component/_adapter.mjs +39 -5
- package/api/component/component-replacement.test.mjs +1 -0
- package/api/component/component.mjs +1 -1
- 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 +24 -10
- package/api/doctor/_adapter.mjs +28 -25
- package/api/doctor/doctor.d.mts +7 -4
- package/api/doctor/doctor.mjs +52 -14
- package/api/doctor/doctor.test.mjs +58 -0
- package/api/hook/hook.mjs +1 -1
- package/api/integration/validate-integration-fixes.test.mjs +6 -5
- package/api/integration/validate-integration-gaps.test.mjs +12 -1
- package/api/integration/validate-integration.d.mts +4 -0
- package/api/integration/validate-integration.mjs +48 -7
- package/api/integration/validate-integration.type.d.mts +36 -5
- package/api/integration/validate-integration.type.mjs +27 -6
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.d.mts +16 -0
- package/api/search/_adapter.mjs +39 -0
- package/api/search/_adapter.test.mjs +173 -0
- package/api/search/_entries.d.mts +11 -0
- package/api/search/_entries.mjs +35 -17
- package/api/search/_entries.test.mjs +48 -0
- package/api/search/search.mjs +6 -2
- package/api/template/template.mjs +5 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +4 -0
- package/assets/docs/use-integrations.doc.mjs +120 -0
- package/clients/cli/command-result-coverage.test.mjs +6 -5
- package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
- package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
- package/clients/cli/commands/component.test.mjs +6 -6
- package/clients/cli/commands/doctor-integration.test.mjs +49 -1
- package/clients/cli/commands/doctor.mjs +10 -0
- package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
- package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/manifest.mjs +67 -0
- package/clients/cli/commands/postinstall.doc.mjs +23 -0
- package/clients/cli/commands/postinstall.mjs +31 -0
- package/clients/cli/commands/setup-nudge.test.mjs +17 -0
- package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
- package/clients/cli/index.mjs +35 -93
- package/clients/cli/lib/component-format.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +12 -7
- package/clients/cli/lib/exit-codes.test.mjs +5 -0
- package/clients/cli/lib/manifest.test.mjs +12 -0
- package/clients/cli/lib/welcome-box.mjs +50 -0
- 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.mjs +16 -1
- package/foundation/agent-docs/computer-agent-text.test.mjs +23 -2
- package/foundation/discovery/runner-commands.mjs +1 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +21 -9
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +131 -0
- package/foundation/fs/read-record.test.mjs +77 -0
- package/foundation/integrations/cli-peer-version.d.mts +36 -0
- package/foundation/integrations/cli-peer-version.mjs +132 -0
- package/foundation/integrations/cli-peer-version.test.mjs +354 -0
- package/foundation/integrations/exports-subpaths.d.mts +57 -0
- package/foundation/integrations/exports-subpaths.mjs +113 -0
- package/foundation/integrations/public-imports.d.mts +118 -0
- package/foundation/integrations/public-imports.mjs +1769 -0
- package/foundation/integrations/public-imports.test.mjs +1793 -0
- 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/response/response-types.doc.mjs +1 -1
- 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
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The kit for a request. `blocks`
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* The kit for a request. `blocks` names the blocks to list, best first: a
|
|
6
|
+
* block build names itself keeps build's entry, another keeps search's own
|
|
7
|
+
* entry (its real score and reason), a name search did not return is
|
|
8
|
+
* dropped, and the kit never lists more blocks than build's own. Blocks of
|
|
9
|
+
* the same name from two packages are both kept.
|
|
9
10
|
*
|
|
10
11
|
* @param {import('./signals.mjs').KitSignals} signals
|
|
11
12
|
* @param {string[]} [blocks] block names; build's own when omitted
|
package/api/build/kit/answer.mjs
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* calls it with the block picker's list.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import {firstSentence} from '../../../foundation/text/string-utils.mjs';
|
|
13
14
|
import {FOUNDATION, FRAME} from './signals.mjs';
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -23,10 +24,11 @@ import {FOUNDATION, FRAME} from './signals.mjs';
|
|
|
23
24
|
const THIN_KIT = 3;
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
|
-
* The kit for a request. `blocks`
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* The kit for a request. `blocks` names the blocks to list, best first: a
|
|
28
|
+
* block build names itself keeps build's entry, another keeps search's own
|
|
29
|
+
* entry (its real score and reason), a name search did not return is
|
|
30
|
+
* dropped, and the kit never lists more blocks than build's own. Blocks of
|
|
31
|
+
* the same name from two packages are both kept.
|
|
30
32
|
*
|
|
31
33
|
* @param {import('./signals.mjs').KitSignals} signals
|
|
32
34
|
* @param {string[]} [blocks] block names; build's own when omitted
|
|
@@ -40,10 +42,22 @@ export function kitAnswer(signals, blocks = signals.kitBlocks) {
|
|
|
40
42
|
const own = new Map();
|
|
41
43
|
for (const b of signals.blocks)
|
|
42
44
|
own.set(b.name, [...(own.get(b.name) ?? []), b]);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
/** @type {Set<string>} */
|
|
46
|
+
const added = new Set();
|
|
47
|
+
const named = blocks
|
|
48
|
+
.flatMap(name => {
|
|
49
|
+
const entry = own.get(name)?.shift();
|
|
50
|
+
if (entry) return [entry];
|
|
51
|
+
// A block build does not name itself keeps search's own entry, once.
|
|
52
|
+
const found =
|
|
53
|
+
own.has(name) || added.has(name)
|
|
54
|
+
? undefined
|
|
55
|
+
: signals.searchedEntries.get(name);
|
|
56
|
+
if (!found) return [];
|
|
57
|
+
added.add(name);
|
|
58
|
+
return [found];
|
|
59
|
+
})
|
|
60
|
+
.slice(0, signals.blocks.length);
|
|
47
61
|
|
|
48
62
|
// What to try when the kit comes back thin. Keyword search over a design
|
|
49
63
|
// system misses in a predictable way — the reader's words and the package's
|
|
@@ -64,8 +78,8 @@ export function kitAnswer(signals, blocks = signals.kitBlocks) {
|
|
|
64
78
|
}
|
|
65
79
|
: undefined;
|
|
66
80
|
|
|
67
|
-
|
|
68
|
-
type: 'build.kit',
|
|
81
|
+
const answer = (/** @type {typeof named} */ list) => ({
|
|
82
|
+
type: /** @type {const} */ ('build.kit'),
|
|
69
83
|
data: {
|
|
70
84
|
query: signals.query,
|
|
71
85
|
// Distinguishes "search found nothing" from a weak-but-non-empty result
|
|
@@ -75,11 +89,99 @@ export function kitAnswer(signals, blocks = signals.kitBlocks) {
|
|
|
75
89
|
directMatch: signals.directMatch,
|
|
76
90
|
start: signals.start,
|
|
77
91
|
pages: signals.pages,
|
|
78
|
-
blocks:
|
|
92
|
+
blocks: list,
|
|
79
93
|
domain: signals.domain,
|
|
80
94
|
frame: FRAME,
|
|
81
95
|
foundation: FOUNDATION,
|
|
82
96
|
hint,
|
|
83
97
|
},
|
|
84
|
-
};
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// An added block must not make the answer longer than build's own, as JSON
|
|
101
|
+
// or as text: trim the added blocks' descriptions, never which blocks are
|
|
102
|
+
// listed.
|
|
103
|
+
const fitted = fitDescriptions(named, signals.blocks, {
|
|
104
|
+
json: list => bytes(answer(list)),
|
|
105
|
+
text: textSize,
|
|
106
|
+
});
|
|
107
|
+
return answer(fitted);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** @param {unknown} value */
|
|
111
|
+
const bytes = value => Buffer.byteLength(JSON.stringify(value));
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* What the blocks add to the text answer, which prints each block's name,
|
|
115
|
+
* package, and the first sentence of its description.
|
|
116
|
+
* @param {{name: string, package?: string, description?: string}[]} list
|
|
117
|
+
*/
|
|
118
|
+
const textSize = list =>
|
|
119
|
+
list.reduce(
|
|
120
|
+
(n, b) =>
|
|
121
|
+
n +
|
|
122
|
+
Buffer.byteLength(
|
|
123
|
+
`${b.name}${b.package ?? ''}${firstSentence(b.description ?? '')}`,
|
|
124
|
+
),
|
|
125
|
+
0,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
/** An added block keeps at least this much of its description. */
|
|
129
|
+
const MIN_DESCRIPTION = 24;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A description cut to about `keep` characters (never fewer than
|
|
133
|
+
* {@link MIN_DESCRIPTION}) at a word boundary, with an ellipsis. Never empty:
|
|
134
|
+
* a description already that short is kept whole.
|
|
135
|
+
* @param {string} description
|
|
136
|
+
* @param {number} keep
|
|
137
|
+
*/
|
|
138
|
+
function cutTo(description, keep) {
|
|
139
|
+
const room = Math.max(keep, MIN_DESCRIPTION);
|
|
140
|
+
if (description.length <= room) return description;
|
|
141
|
+
const cut = description.slice(0, room);
|
|
142
|
+
const at = cut.lastIndexOf(' ');
|
|
143
|
+
return `${(at > 0 ? cut.slice(0, at) : cut).trimEnd()}…`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The listed blocks with the added blocks' descriptions shortened until
|
|
148
|
+
* neither the JSON nor the text answer is longer than with build's own
|
|
149
|
+
* blocks, or every added description is as short as it may get. A
|
|
150
|
+
* description is never emptied, and build's own entries never change.
|
|
151
|
+
* @template {{name: string, package?: string, description?: string}} B
|
|
152
|
+
* @param {B[]} list
|
|
153
|
+
* @param {B[]} own build's own entries
|
|
154
|
+
* @param {{json: (list: B[]) => number, text: (list: B[]) => number}} size
|
|
155
|
+
* @returns {B[]}
|
|
156
|
+
*/
|
|
157
|
+
function fitDescriptions(list, own, size) {
|
|
158
|
+
const limit = {json: size.json(own), text: size.text(own)};
|
|
159
|
+
let out = list;
|
|
160
|
+
/** The bytes over each limit; 0 when within. */
|
|
161
|
+
const over = (/** @type {B[]} */ l) => ({
|
|
162
|
+
text: Math.max(0, size.text(l) - limit.text),
|
|
163
|
+
json: Math.max(0, size.json(l) - limit.json),
|
|
164
|
+
});
|
|
165
|
+
// The last added block first, each cut by what is still over and never
|
|
166
|
+
// below MIN_DESCRIPTION; when one is as short as it may get, the next one
|
|
167
|
+
// up is cut, and passes repeat while any cut still helps.
|
|
168
|
+
for (let changed = true; changed;) {
|
|
169
|
+
changed = false;
|
|
170
|
+
for (let k = out.length - 1; k >= 0; k--) {
|
|
171
|
+
const o = over(out);
|
|
172
|
+
if (o.text === 0 && o.json === 0) return out;
|
|
173
|
+
const b = out[k];
|
|
174
|
+
if (own.includes(b) || !b.description) continue;
|
|
175
|
+
const first = firstSentence(b.description);
|
|
176
|
+
const keep = Math.min(
|
|
177
|
+
o.text > 0 ? first.length - o.text - 1 : b.description.length,
|
|
178
|
+
o.json > 0 ? b.description.length - o.json - 1 : b.description.length,
|
|
179
|
+
);
|
|
180
|
+
const description = cutTo(b.description, keep);
|
|
181
|
+
if (description.length >= b.description.length) continue;
|
|
182
|
+
out = out.map((x, i) => (i === k ? {...x, description} : x));
|
|
183
|
+
changed = true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return out;
|
|
85
187
|
}
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
import {describe, it, expect} from 'vitest';
|
|
4
4
|
import {kitAnswer} from './answer.mjs';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @param {any[]} blocks
|
|
8
|
+
* @param {any[]} [searched] blocks search returned that build did not name
|
|
9
|
+
*/
|
|
10
|
+
const signals = (blocks, searched = []) =>
|
|
8
11
|
/** @type {any} */ ({
|
|
9
12
|
query: 'q',
|
|
10
13
|
matchCount: blocks.length,
|
|
@@ -14,6 +17,7 @@ const signals = blocks =>
|
|
|
14
17
|
blocks,
|
|
15
18
|
kitBlocks: blocks.map(b => b.name),
|
|
16
19
|
domain: [],
|
|
20
|
+
searchedEntries: new Map(searched.map(b => [b.name, b])),
|
|
17
21
|
});
|
|
18
22
|
|
|
19
23
|
describe('kitAnswer', () => {
|
|
@@ -31,8 +35,74 @@ describe('kitAnswer', () => {
|
|
|
31
35
|
expect(kit.data.blocks).toEqual([c, a, b]);
|
|
32
36
|
});
|
|
33
37
|
|
|
34
|
-
it('never lists a block build
|
|
38
|
+
it('never lists a block neither build nor search gave, or more than build gave', () => {
|
|
35
39
|
const kit = kitAnswer(signals([a, c]), ['Hero', 'Hero', 'Nav', 'Footer']);
|
|
36
40
|
expect(kit.data.blocks).toEqual([a, c]);
|
|
37
41
|
});
|
|
42
|
+
|
|
43
|
+
it('lists a block search returned with search’s own entry, within build’s count', () => {
|
|
44
|
+
const nav = {name: 'Nav', package: '@a/one', score: 60, reason: 'keyword'};
|
|
45
|
+
const kit = kitAnswer(signals([a, c], [nav]), [
|
|
46
|
+
'Nav',
|
|
47
|
+
'Nav',
|
|
48
|
+
'Hero',
|
|
49
|
+
'Footer',
|
|
50
|
+
]);
|
|
51
|
+
expect(kit.data.blocks).toEqual([nav, a]);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('trims an added block’s description so the answer is never longer than build’s own', () => {
|
|
55
|
+
const hero = {
|
|
56
|
+
...a,
|
|
57
|
+
description: 'A wide hero with a title and two buttons.',
|
|
58
|
+
};
|
|
59
|
+
const foot = {...c, description: 'A footer with links in three columns.'};
|
|
60
|
+
const nav = {
|
|
61
|
+
name: 'Nav',
|
|
62
|
+
package: '@a/one',
|
|
63
|
+
score: 60,
|
|
64
|
+
reason: 'keyword',
|
|
65
|
+
description: 'word '.repeat(200).trim(),
|
|
66
|
+
};
|
|
67
|
+
const own = kitAnswer(signals([hero, foot]));
|
|
68
|
+
const kit = kitAnswer(signals([hero, foot], [nav]), ['Nav', 'Hero']);
|
|
69
|
+
expect(kit.data.blocks.map(b => b.name)).toEqual(['Nav', 'Hero']);
|
|
70
|
+
expect(kit.data.blocks[1]).toEqual(hero);
|
|
71
|
+
expect(Buffer.byteLength(JSON.stringify(kit))).toBeLessThanOrEqual(
|
|
72
|
+
Buffer.byteLength(JSON.stringify(own)),
|
|
73
|
+
);
|
|
74
|
+
expect(kit.data.blocks[0].description).toMatch(/…$/);
|
|
75
|
+
});
|
|
76
|
+
it('trims an added block’s first sentence so the text answer is never longer either', () => {
|
|
77
|
+
const long = ' More words follow here. '.repeat(20);
|
|
78
|
+
const hero = {...a, description: `A hero.${long}`};
|
|
79
|
+
const foot = {...c, description: `A footer.${long}`};
|
|
80
|
+
const nav = {
|
|
81
|
+
name: 'Nav',
|
|
82
|
+
package: '@a/one',
|
|
83
|
+
score: 60,
|
|
84
|
+
reason: 'keyword',
|
|
85
|
+
description:
|
|
86
|
+
'A navigation bar with a logo, five links, a search box and a menu.',
|
|
87
|
+
};
|
|
88
|
+
const kit = kitAnswer(signals([hero, foot], [nav]), ['Nav', 'Hero']);
|
|
89
|
+
const d = kit.data.blocks[0].description;
|
|
90
|
+
expect(d).toMatch(/…$/);
|
|
91
|
+
expect(d.length).toBeLessThan(nav.description.length);
|
|
92
|
+
expect(nav.description.startsWith(d.slice(0, -1))).toBe(true);
|
|
93
|
+
expect(kit.data.blocks[1]).toEqual(hero);
|
|
94
|
+
});
|
|
95
|
+
it('never empties an added block’s description', () => {
|
|
96
|
+
const nav = {
|
|
97
|
+
name: 'Nav',
|
|
98
|
+
package: '@a/one',
|
|
99
|
+
score: 60,
|
|
100
|
+
reason: 'keyword',
|
|
101
|
+
description:
|
|
102
|
+
'A navigation bar with a logo, five links, a search box and a menu.',
|
|
103
|
+
};
|
|
104
|
+
const kit = kitAnswer(signals([a, c], [nav]), ['Nav', 'Hero']);
|
|
105
|
+
expect(kit.data.blocks[0].name).toBe('Nav');
|
|
106
|
+
expect(kit.data.blocks[0].description.length).toBeGreaterThan(0);
|
|
107
|
+
});
|
|
38
108
|
});
|
|
@@ -53,6 +53,14 @@ export type KitSignals = {
|
|
|
53
53
|
* every block search returned, in its order
|
|
54
54
|
*/
|
|
55
55
|
searched: BlockScore[];
|
|
56
|
+
/**
|
|
57
|
+
* search's entry for each of those blocks (the first of a name)
|
|
58
|
+
*/
|
|
59
|
+
searchedEntries: Map<string, SearchResultEntry>;
|
|
60
|
+
/**
|
|
61
|
+
* each of those blocks' display name and description, from the catalog
|
|
62
|
+
*/
|
|
63
|
+
blockText: Map<string, string>;
|
|
56
64
|
/**
|
|
57
65
|
* the blocks, named, searched or scaffoldable, whose package is not Core's
|
|
58
66
|
*/
|
|
@@ -100,6 +100,8 @@ const ALWAYS = new Set([...FRAME, ...FOUNDATION]);
|
|
|
100
100
|
* @property {SearchResultEntry[]} domain
|
|
101
101
|
* @property {string[]} kitBlocks the names of `blocks`
|
|
102
102
|
* @property {BlockScore[]} searched every block search returned, in its order
|
|
103
|
+
* @property {Map<string, SearchResultEntry>} searchedEntries search's entry for each of those blocks (the first of a name)
|
|
104
|
+
* @property {Map<string, string>} blockText each of those blocks' display name and description, from the catalog
|
|
103
105
|
* @property {string[]} foreign the blocks, named, searched or scaffoldable, whose package is not Core's
|
|
104
106
|
*/
|
|
105
107
|
|
|
@@ -273,6 +275,14 @@ export async function kitSignals(query, options = {}) {
|
|
|
273
275
|
domain: domainKept,
|
|
274
276
|
kitBlocks: blocksKept.map(r => r.name),
|
|
275
277
|
searched: searchedBlocks.map(blockScore),
|
|
278
|
+
searchedEntries: new Map(
|
|
279
|
+
[...searchedBlocks].reverse().map(r => [r.name, r]),
|
|
280
|
+
),
|
|
281
|
+
blockText: new Map(
|
|
282
|
+
templates.blocks
|
|
283
|
+
.filter(b => searchedBlocks.some(r => r.name === b.name))
|
|
284
|
+
.map(b => [b.name, `${b.displayName} ${b.description}`]),
|
|
285
|
+
),
|
|
276
286
|
foreign: [
|
|
277
287
|
...new Set(
|
|
278
288
|
[...blocksKept, ...searchedBlocks, ...templates.blocks]
|
package/api/build/tree.test.mjs
CHANGED
|
@@ -59,8 +59,8 @@ const PINNED = [
|
|
|
59
59
|
[
|
|
60
60
|
'analytics dashboard with a KPI row and a sortable table',
|
|
61
61
|
[
|
|
62
|
-
'
|
|
63
|
-
'
|
|
62
|
+
'TableSortableTable',
|
|
63
|
+
'TableRichCellTable',
|
|
64
64
|
'TableBulkActionsTable',
|
|
65
65
|
'TableGridDividersTable',
|
|
66
66
|
'TableRowExpansionTable',
|
|
@@ -83,17 +83,17 @@ const PINNED = [
|
|
|
83
83
|
'EmptyStateCompact',
|
|
84
84
|
'EmptyStateContainer',
|
|
85
85
|
'EmptyStateShowcase',
|
|
86
|
-
'
|
|
86
|
+
'BannerWithActionButton',
|
|
87
87
|
],
|
|
88
88
|
],
|
|
89
89
|
[
|
|
90
90
|
'login form with single sign-on buttons',
|
|
91
91
|
[
|
|
92
|
+
'DialogFormDialog',
|
|
92
93
|
'CardWithInnerLayout',
|
|
93
|
-
'BottomSheetMobileKeyboard',
|
|
94
94
|
'ButtonGroupBasic',
|
|
95
|
-
'
|
|
96
|
-
'
|
|
95
|
+
'ToggleButtonGroup',
|
|
96
|
+
'BannerWithActionButton',
|
|
97
97
|
],
|
|
98
98
|
],
|
|
99
99
|
[
|
|
@@ -108,7 +108,7 @@ const PINNED = [
|
|
|
108
108
|
],
|
|
109
109
|
[
|
|
110
110
|
'kanban board for sprint tasks with a filter bar',
|
|
111
|
-
['ToolbarTableFilter', '
|
|
111
|
+
['ToolbarTableFilter', 'PowerSearchFullFeatured'],
|
|
112
112
|
],
|
|
113
113
|
];
|
|
114
114
|
|
|
@@ -166,12 +166,20 @@ describe('build tree', () => {
|
|
|
166
166
|
expect(answer.data.start?.alternatives).toEqual(
|
|
167
167
|
own.data.start?.alternatives,
|
|
168
168
|
);
|
|
169
|
-
//
|
|
170
|
-
//
|
|
169
|
+
// Every block is build's own entry or one search returned, with its real
|
|
170
|
+
// score and reason; never more blocks than build's own.
|
|
171
171
|
expect(answer.data.blocks.length).toBe(own.data.blocks.length);
|
|
172
|
-
for (const b of answer.data.blocks)
|
|
173
|
-
expect(
|
|
172
|
+
for (const b of answer.data.blocks) {
|
|
173
|
+
expect(b.score).toBeGreaterThan(0);
|
|
174
|
+
expect(typeof b.reason).toBe('string');
|
|
175
|
+
const mine = own.data.blocks.find(o => o.name === b.name);
|
|
176
|
+
if (mine) expect(mine).toEqual(b);
|
|
177
|
+
}
|
|
174
178
|
expect(answer.data.blocks.map(b => b.name)).toEqual(blocks);
|
|
179
|
+
// Never longer than build's own answer for the same request.
|
|
180
|
+
expect(Buffer.byteLength(JSON.stringify(answer))).toBeLessThanOrEqual(
|
|
181
|
+
Buffer.byteLength(JSON.stringify(own)),
|
|
182
|
+
);
|
|
175
183
|
});
|
|
176
184
|
}
|
|
177
185
|
});
|
|
@@ -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})),
|
|
@@ -64,6 +64,7 @@ function writeIntegration(name, components, peers) {
|
|
|
64
64
|
type: 'component',
|
|
65
65
|
name: componentName,
|
|
66
66
|
displayName: componentName,
|
|
67
|
+
import: `${name}/components/${componentName}`,
|
|
67
68
|
...(replaces ? {replaces} : {}),
|
|
68
69
|
keywords: ['acme'],
|
|
69
70
|
usage: {description: `${componentName} for Acme apps.`},
|
|
@@ -293,7 +293,7 @@ async function componentRead(name, options = {}) {
|
|
|
293
293
|
const selectorList = Array.isArray(name) ? name : null;
|
|
294
294
|
const noName = selectorList == null && !name;
|
|
295
295
|
|
|
296
|
-
// Default detail level mirrors the CLI (see commands/component
|
|
296
|
+
// Default detail level mirrors the CLI (see commands/component.mjs):
|
|
297
297
|
// single-component views default to 'full', list-style views (--list,
|
|
298
298
|
// --category, or no name) default to 'brief' (scannable name lists).
|
|
299
299
|
// An explicit array remains a batch even when it is empty or a caller also
|
|
@@ -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);
|
|
@@ -108,13 +108,14 @@ export function outsideProject(cwd: string): boolean;
|
|
|
108
108
|
/**
|
|
109
109
|
* The commands that bring a project's own CLI and Core to one release, with
|
|
110
110
|
* the project's package manager: Core up to the CLI, then its codemods, when
|
|
111
|
-
* the CLI is newer; else the CLI to the Core's release.
|
|
111
|
+
* the CLI is newer; else the CLI to the Core's release. Null when no
|
|
112
|
+
* command fits (see `alignCliAndCore`).
|
|
112
113
|
* @param {string} cwd
|
|
113
114
|
* @param {string} cli
|
|
114
115
|
* @param {string} core
|
|
115
|
-
* @returns {string}
|
|
116
|
+
* @returns {string | null}
|
|
116
117
|
*/
|
|
117
|
-
export function alignCommand(cwd: string, cli: string, core: string): string;
|
|
118
|
+
export function alignCommand(cwd: string, cli: string, core: string): string | null;
|
|
118
119
|
/**
|
|
119
120
|
* The Core release the project at `cwd` names: installed, else locked, else
|
|
120
121
|
* declared; the version the daily hint and notice compare against (spec
|
|
@@ -131,19 +132,32 @@ export function projectCoreVersion(cwd: string): string | null;
|
|
|
131
132
|
export function projectHasOwnCli(cwd: string): boolean;
|
|
132
133
|
/**
|
|
133
134
|
* The command that adds the CLI at `version` with the project's package
|
|
134
|
-
* manager.
|
|
135
|
+
* manager, and the Core it matches: from a folder whose package.json declares
|
|
136
|
+
* no Astryx package, in the Astryx project above at that project's Core; null
|
|
137
|
+
* when there is none (see `cliInstallAdvice`).
|
|
135
138
|
* @param {string} cwd
|
|
136
139
|
* @param {string} version
|
|
137
|
-
* @returns {string}
|
|
140
|
+
* @returns {{command: string, core: string} | null}
|
|
138
141
|
*/
|
|
139
|
-
export function addCliCommandFor(cwd: string, version: string):
|
|
142
|
+
export function addCliCommandFor(cwd: string, version: string): {
|
|
143
|
+
command: string;
|
|
144
|
+
core: string;
|
|
145
|
+
} | null;
|
|
140
146
|
/**
|
|
141
|
-
* The command that adds a package
|
|
142
|
-
*
|
|
147
|
+
* The command that adds a package to the project of `cwd`; null in a folder
|
|
148
|
+
* that belongs to no project or whose package.json is not the project's (see
|
|
149
|
+
* `projectAddCommand`).
|
|
143
150
|
* @param {string} cwd
|
|
144
|
-
* @returns {(name: string) => string}
|
|
151
|
+
* @returns {((name: string) => string) | null}
|
|
152
|
+
*/
|
|
153
|
+
export function installCommandFor(cwd: string): ((name: string) => string) | null;
|
|
154
|
+
/**
|
|
155
|
+
* Whether `cwd` is inside a project whose package.json is not the project's,
|
|
156
|
+
* so advice points at the project's folder (see `installFolder`).
|
|
157
|
+
* @param {string} cwd
|
|
158
|
+
* @returns {boolean}
|
|
145
159
|
*/
|
|
146
|
-
export function
|
|
160
|
+
export function insideProjectElsewhere(cwd: string): boolean;
|
|
147
161
|
export { resolveRecordedTheme } from "../theme/theme.mjs";
|
|
148
162
|
export { collectUnloadedFonts } from "../theme/build/font-warning.mjs";
|
|
149
163
|
export const SOURCE_EXTENSIONS: Set<string>;
|