@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
|
@@ -1,221 +1,238 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Unit tests for build's block picker on small hand-written weights:
|
|
5
|
-
* blocks
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* @file Unit tests for build's block picker on small hand-written weights: it
|
|
5
|
+
* lists as many blocks as build's own, from the block catalog, each once; a
|
|
6
|
+
* block search did not return gets the picker's own entry with a real score
|
|
7
|
+
* and reason; a block the request writes out by its exact name keeps its slot,
|
|
8
|
+
* as does a block an integration ships; a block the weights were never fitted
|
|
9
|
+
* with is still ranked from its own docs; and ties keep build's order.
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
import {describe, expect, it} from 'vitest';
|
|
12
|
-
import {pickBlocks} from './blocks.mjs';
|
|
13
|
+
import {pickBlocks, stemOf, termsOf, wordsOf} from './blocks.mjs';
|
|
14
|
+
|
|
15
|
+
/** Two dims, each byte a weight offset by 128: "chart" words on the first, "table" words on the second. */
|
|
16
|
+
const MATRIX = 'goCBgICCgIGAgICAgoA=';
|
|
13
17
|
|
|
14
18
|
/** @type {import('./blocks.mjs').BlockPickerWeights} */
|
|
15
|
-
const
|
|
16
|
-
vocab:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const WEIGHTS = {
|
|
20
|
+
vocab: ['chart', 'sale', 'table', 'row', 'toggle', 'switch', 'sale_chart'],
|
|
21
|
+
idf: [1024, 1024, 1024, 1024, 2048, 2048, 1024],
|
|
22
|
+
dims: 2,
|
|
23
|
+
request: MATRIX,
|
|
24
|
+
requestScale: 1,
|
|
25
|
+
doc: MATRIX,
|
|
26
|
+
docScale: 1,
|
|
27
|
+
lexical: 2,
|
|
28
|
+
known: ['ChartBar', 'TableBasic', 'CardStat', 'ListPlain'],
|
|
29
|
+
theta: {
|
|
30
|
+
g: 1,
|
|
31
|
+
grank: 0,
|
|
32
|
+
gmargin: 0,
|
|
33
|
+
seen: 0,
|
|
34
|
+
lex: 1,
|
|
35
|
+
sscore: 0,
|
|
36
|
+
scov: 0,
|
|
37
|
+
srank: 0,
|
|
38
|
+
inkit: 0,
|
|
39
|
+
kitpos: 0,
|
|
40
|
+
mention: 0,
|
|
41
|
+
show: 0,
|
|
24
42
|
},
|
|
25
|
-
theta: [0.5, 0.25, 0.5, 0.4, 1.5],
|
|
26
43
|
};
|
|
44
|
+
|
|
45
|
+
/** @type {import('./blocks.mjs').CatalogBlock[]} */
|
|
46
|
+
const CATALOG = [
|
|
47
|
+
{
|
|
48
|
+
name: 'ChartBar',
|
|
49
|
+
package: '@astryxdesign/core',
|
|
50
|
+
displayName: 'Chart — Bar',
|
|
51
|
+
description: 'A bar chart of sales by month.',
|
|
52
|
+
command: 'astryx template ChartBar --type block',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'TableBasic',
|
|
56
|
+
package: '@astryxdesign/core',
|
|
57
|
+
displayName: 'Table — Basic',
|
|
58
|
+
description: 'A table of rows.',
|
|
59
|
+
command: 'astryx template TableBasic --type block',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'CardStat',
|
|
63
|
+
package: '@astryxdesign/core',
|
|
64
|
+
displayName: 'Card — Stat',
|
|
65
|
+
description: 'A card with one number.',
|
|
66
|
+
command: 'astryx template CardStat --type block',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'ListPlain',
|
|
70
|
+
package: '@astryxdesign/core',
|
|
71
|
+
displayName: 'List — Plain',
|
|
72
|
+
description: 'A plain list.',
|
|
73
|
+
command: 'astryx template ListPlain --type block',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'SwitchToggle',
|
|
77
|
+
package: '@astryxdesign/core',
|
|
78
|
+
displayName: 'Switch — Toggle',
|
|
79
|
+
description: 'A toggle switch.',
|
|
80
|
+
command: 'astryx template SwitchToggle --type block',
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
/** @type {import('./blocks.mjs').CatalogComponent[]} */
|
|
85
|
+
const COMPONENTS = [
|
|
86
|
+
{name: 'Chart', keywords: ['graph']},
|
|
87
|
+
{name: 'Table', keywords: ['grid']},
|
|
88
|
+
{name: 'Card'},
|
|
89
|
+
{name: 'List'},
|
|
90
|
+
{name: 'Switch', keywords: ['toggle']},
|
|
91
|
+
];
|
|
92
|
+
|
|
27
93
|
/** @type {[string, number, number, number][]} */
|
|
28
94
|
const SEARCHED = [
|
|
29
95
|
['TableBasic', 96, 1, 3],
|
|
30
96
|
['ListPlain', 64, 1, 3],
|
|
31
|
-
['ChartBar', 50, 1, 3],
|
|
32
97
|
['CardStat', 40, 1, 3],
|
|
33
98
|
];
|
|
34
99
|
|
|
35
|
-
/**
|
|
36
|
-
* Two blocks, no words, and a theta that prefers a block build did not name:
|
|
37
|
-
* a block search returned wins the slot whenever the word check lets it in.
|
|
38
|
-
* @type {import('./blocks.mjs').BlockPickerWeights}
|
|
39
|
-
*/
|
|
40
|
-
const TIES_ALL = {
|
|
41
|
-
vocab: {},
|
|
42
|
-
classes: ['ListPlain', 'CardStat'],
|
|
43
|
-
bias: [0, 0],
|
|
44
|
-
words: {},
|
|
45
|
-
theta: [0, 0, -1, 0, 0],
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/** @type {import('./blocks.mjs').BlockPickerWeights} */
|
|
49
|
-
const TIES = {
|
|
50
|
-
vocab: {alpha: 1024},
|
|
51
|
-
classes: ['X', 'Y', 'Z'],
|
|
52
|
-
bias: [0, 0, 0],
|
|
53
|
-
words: {},
|
|
54
|
-
theta: [0, 0, 0, 0, 1],
|
|
55
|
-
};
|
|
56
|
-
|
|
57
100
|
/**
|
|
58
101
|
* @param {string[]} kitBlocks
|
|
59
102
|
* @param {string[]} [foreign]
|
|
60
103
|
*/
|
|
61
|
-
const signals = (kitBlocks, foreign = []
|
|
104
|
+
const signals = (kitBlocks, foreign = []) => ({
|
|
62
105
|
kitBlocks,
|
|
63
|
-
searched,
|
|
106
|
+
searched: SEARCHED,
|
|
64
107
|
foreign,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
['CardStat', 'Stat card A card with one number.'],
|
|
68
|
-
['ListPlain', 'Plain list A list of rows.'],
|
|
69
|
-
['TableBasic', 'Basic table A table of rows.'],
|
|
70
|
-
]),
|
|
108
|
+
catalog: CATALOG,
|
|
109
|
+
components: COMPONENTS,
|
|
71
110
|
});
|
|
72
111
|
|
|
73
112
|
describe('pickBlocks', () => {
|
|
74
|
-
it('
|
|
113
|
+
it('lists as many blocks as build’s own, from the catalog, each once', () => {
|
|
75
114
|
const own = ['TableBasic', 'ListPlain', 'CardStat'];
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
expect(
|
|
79
|
-
for (const b of
|
|
80
|
-
expect(new Set(picks).size).toBe(picks.length);
|
|
115
|
+
const {names} = pickBlocks('sales chart', signals(own), WEIGHTS);
|
|
116
|
+
expect(names).toHaveLength(own.length);
|
|
117
|
+
expect(new Set(names).size).toBe(names.length);
|
|
118
|
+
for (const b of names) expect(CATALOG.some(c => c.name === b)).toBe(true);
|
|
81
119
|
});
|
|
82
120
|
|
|
83
|
-
it('
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
121
|
+
it('puts the block that means what the request asks first, even one search did not return', () => {
|
|
122
|
+
const own = ['TableBasic', 'ListPlain'];
|
|
123
|
+
const {names, entries} = pickBlocks('sales chart', signals(own), WEIGHTS);
|
|
124
|
+
expect(names[0]).toBe('ChartBar');
|
|
125
|
+
const entry = entries.get('ChartBar');
|
|
126
|
+
expect(entry?.score).toBeGreaterThan(0);
|
|
127
|
+
expect(entry?.reason).toMatch(/chart|sales/);
|
|
128
|
+
expect(entry?.description).toBe('A bar chart of sales by month.');
|
|
129
|
+
// Blocks search returned keep search's entry: the picker adds none.
|
|
130
|
+
for (const b of names)
|
|
131
|
+
if (SEARCHED.some(s => s[0] === b)) expect(entries.has(b)).toBe(false);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('keeps a block the request writes out by its exact name in its slot', () => {
|
|
135
|
+
const own = ['ListPlain', 'TableBasic'];
|
|
136
|
+
const {names} = pickBlocks(
|
|
137
|
+
'sales chart beside a ListPlain',
|
|
138
|
+
signals(own),
|
|
139
|
+
WEIGHTS,
|
|
88
140
|
);
|
|
89
|
-
expect(
|
|
90
|
-
expect(picks).toHaveLength(2);
|
|
141
|
+
expect(names[0]).toBe('ListPlain');
|
|
91
142
|
});
|
|
92
143
|
|
|
93
|
-
it('
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
'
|
|
100
|
-
|
|
101
|
-
|
|
144
|
+
it('keeps a block with a long name in its slot when the request writes it out', () => {
|
|
145
|
+
const long = {
|
|
146
|
+
name: 'ListPlainWithSixWordName',
|
|
147
|
+
package: '@astryxdesign/core',
|
|
148
|
+
displayName: 'List — Plain with a long name',
|
|
149
|
+
description: 'A plain list.',
|
|
150
|
+
command: 'astryx template ListPlainWithSixWordName --type block',
|
|
151
|
+
};
|
|
152
|
+
const s = {
|
|
153
|
+
...signals(['ListPlainWithSixWordName', 'TableBasic']),
|
|
154
|
+
catalog: [...CATALOG, long],
|
|
155
|
+
};
|
|
156
|
+
const {names} = pickBlocks(
|
|
157
|
+
'sales chart starting from ListPlainWithSixWordName',
|
|
158
|
+
s,
|
|
159
|
+
WEIGHTS,
|
|
102
160
|
);
|
|
103
|
-
expect(
|
|
104
|
-
expect(picks).not.toContain('CardStat');
|
|
105
|
-
expect([...picks].sort()).toEqual(['ListPlain', 'TableBasic']);
|
|
161
|
+
expect(names[0]).toBe('ListPlainWithSixWordName');
|
|
106
162
|
});
|
|
107
163
|
|
|
108
|
-
it('
|
|
109
|
-
const own = ['
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
'sales chart with two calendars',
|
|
113
|
-
'sales chart, calendar basic',
|
|
114
|
-
]) {
|
|
115
|
-
expect(pickBlocks(request, signals(own), WORDS)[1]).toBe('CalendarBasic');
|
|
116
|
-
}
|
|
164
|
+
it('does not pin a block for its component’s word alone', () => {
|
|
165
|
+
const own = ['ListPlain', 'TableBasic'];
|
|
166
|
+
const {names} = pickBlocks('sales chart list', signals(own), WEIGHTS);
|
|
167
|
+
expect(names[0]).toBe('ChartBar');
|
|
117
168
|
});
|
|
118
169
|
|
|
119
|
-
it('keeps a block
|
|
120
|
-
const own = ['
|
|
121
|
-
const
|
|
122
|
-
'sales chart
|
|
170
|
+
it('keeps a block an integration ships in its slot', () => {
|
|
171
|
+
const own = ['ListPlain', 'TableBasic'];
|
|
172
|
+
const {names} = pickBlocks(
|
|
173
|
+
'sales chart',
|
|
123
174
|
signals(own, ['ListPlain']),
|
|
124
|
-
|
|
175
|
+
WEIGHTS,
|
|
125
176
|
);
|
|
126
|
-
expect(
|
|
127
|
-
expect(picks[3]).toBe('ListPlain');
|
|
128
|
-
expect(picks).toHaveLength(own.length);
|
|
177
|
+
expect(names[0]).toBe('ListPlain');
|
|
129
178
|
});
|
|
130
179
|
|
|
131
|
-
it('
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
180
|
+
it('ranks a block the weights were never fitted with from its own docs', () => {
|
|
181
|
+
expect(WEIGHTS.known).not.toContain('SwitchToggle');
|
|
182
|
+
const own = ['TableBasic', 'ListPlain'];
|
|
183
|
+
const {names, entries} = pickBlocks('toggle switch', signals(own), WEIGHTS);
|
|
184
|
+
expect(names[0]).toBe('SwitchToggle');
|
|
185
|
+
expect(entries.get('SwitchToggle')?.reason).toMatch(/toggle|switch/);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('keeps build’s order when nothing in the request is known', () => {
|
|
189
|
+
const own = ['ListPlain', 'TableBasic', 'CardStat'];
|
|
190
|
+
const {names} = pickBlocks('zzz qqq', signals(own), WEIGHTS);
|
|
191
|
+
expect(names).toEqual(own);
|
|
140
192
|
});
|
|
141
193
|
|
|
142
194
|
it('returns nothing when build names no block, and does not change its input', () => {
|
|
143
|
-
|
|
195
|
+
const s = signals([]);
|
|
196
|
+
const before = JSON.stringify(s);
|
|
197
|
+
expect(pickBlocks('sales chart', s, WEIGHTS)).toEqual({
|
|
198
|
+
names: [],
|
|
199
|
+
entries: new Map(),
|
|
200
|
+
});
|
|
144
201
|
const own = ['TableBasic', 'ListPlain'];
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
202
|
+
const s2 = signals(own);
|
|
203
|
+
const before2 = JSON.stringify(s2);
|
|
204
|
+
pickBlocks('sales chart', s2, WEIGHTS);
|
|
205
|
+
expect(JSON.stringify(s)).toBe(before);
|
|
206
|
+
expect(JSON.stringify(s2)).toBe(before2);
|
|
148
207
|
});
|
|
208
|
+
});
|
|
149
209
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
['categories', 'category'],
|
|
158
|
-
]) {
|
|
159
|
-
const sig = {
|
|
160
|
-
kitBlocks: ['ListPlain'],
|
|
161
|
-
searched: /** @type {[string, number, number, number][]} */ ([
|
|
162
|
-
['ListPlain', 96, 1, 3],
|
|
163
|
-
['CardStat', 90, 1, 3],
|
|
164
|
-
]),
|
|
165
|
-
foreign: [],
|
|
166
|
-
blockText: new Map([['CardStat', `Stat card. A ${blockWord} panel.`]]),
|
|
167
|
-
};
|
|
168
|
-
expect(pickBlocks(`one ${word} view`, sig, TIES_ALL)).toEqual([
|
|
169
|
-
'CardStat',
|
|
170
|
-
]);
|
|
171
|
-
}
|
|
172
|
-
const none = {
|
|
173
|
-
kitBlocks: ['ListPlain'],
|
|
174
|
-
searched: /** @type {[string, number, number, number][]} */ ([
|
|
175
|
-
['ListPlain', 96, 1, 3],
|
|
176
|
-
['CardStat', 90, 1, 3],
|
|
177
|
-
]),
|
|
178
|
-
foreign: [],
|
|
179
|
-
blockText: new Map([['CardStat', 'Stat card. A setting panel.']]),
|
|
180
|
-
};
|
|
181
|
-
expect(pickBlocks('one widget view', none, TIES_ALL)).toEqual([
|
|
182
|
-
'ListPlain',
|
|
183
|
-
]);
|
|
210
|
+
describe('the picker’s words', () => {
|
|
211
|
+
it('stems plurals and verb endings of longer words only', () => {
|
|
212
|
+
expect(stemOf('tables')).toBe('table');
|
|
213
|
+
expect(stemOf('classes')).toBe('class');
|
|
214
|
+
expect(stemOf('entries')).toBe('entry');
|
|
215
|
+
expect(stemOf('class')).toBe('class');
|
|
216
|
+
expect(stemOf('rows')).toBe('rows');
|
|
184
217
|
});
|
|
185
218
|
|
|
186
|
-
it('
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
219
|
+
it('splits identifiers into words', () => {
|
|
220
|
+
expect(wordsOf('SideNavNestedItems')).toEqual([
|
|
221
|
+
'side',
|
|
222
|
+
'nav',
|
|
223
|
+
'nested',
|
|
224
|
+
'items',
|
|
190
225
|
]);
|
|
191
|
-
|
|
192
|
-
kitBlocks: ['TableBasic', 'ListPlain'],
|
|
193
|
-
searched,
|
|
194
|
-
foreign: [],
|
|
195
|
-
blockText: new Map([['CardStat', 'Stat card Each card under a header.']]),
|
|
196
|
-
};
|
|
197
|
-
const picks = pickBlocks('each row under which', sig, WORDS);
|
|
198
|
-
expect(picks).not.toContain('CardStat');
|
|
226
|
+
expect(wordsOf('KPICard')).toEqual(['kpi', 'card']);
|
|
199
227
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
[
|
|
210
|
-
'CardStat',
|
|
211
|
-
'Shows which one is done. Each, every, any, some, all, both, either, neither, few, many, much, several, such, that, who, whom, whose.',
|
|
212
|
-
],
|
|
213
|
-
]),
|
|
214
|
-
};
|
|
215
|
-
for (const w of 'which that who whom whose each every any some all both either neither few many much several such'.split(
|
|
216
|
-
' ',
|
|
217
|
-
))
|
|
218
|
-
expect(pickBlocks(`a ${w} b`, sig, TIES_ALL)).toEqual(['ListPlain']);
|
|
219
|
-
expect(pickBlocks('each, which', sig, TIES_ALL)).toEqual(['ListPlain']);
|
|
228
|
+
|
|
229
|
+
it('reads content words and their adjacent pairs, never a function word', () => {
|
|
230
|
+
expect(termsOf('the sales charts for a team')).toEqual([
|
|
231
|
+
'sale',
|
|
232
|
+
'chart',
|
|
233
|
+
'team',
|
|
234
|
+
'sale_chart',
|
|
235
|
+
'chart_team',
|
|
236
|
+
]);
|
|
220
237
|
});
|
|
221
238
|
});
|