@astryxdesign/cli 0.7.4-canary.4fc0c4a → 0.7.4-canary.720bb10
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/search/ORDERING.md +1 -1
- package/api/search/_order.d.mts +1 -1
- package/api/search/_order.mjs +75 -6
- package/api/search/search.tie-order.test.mjs +39 -0
- package/assets/templates/blocks/components/CommandPaletteItem/CommandPaletteItemShowcase.doc.mjs +3 -2
- package/assets/templates/blocks/components/Item/ItemWithMetadata.doc.mjs +1 -1
- package/assets/templates/blocks/components/MetadataListItem/MetadataListItemBasic.doc.mjs +1 -1
- package/assets/templates/blocks/components/SegmentedControlItem/SegmentedControlItemBasic.doc.mjs +1 -1
- package/assets/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.doc.mjs +1 -1
- package/package.json +9 -9
package/api/search/ORDERING.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## Rule
|
|
6
6
|
|
|
7
|
-
`spec:AST-083` owns search's result order; this file describes the data that implements it. Inside one score band, a searcher's static weights decide the order. Matches with the same score move together as one block,
|
|
7
|
+
`spec:AST-083` owns search's result order; this file describes the data that implements it. Inside one score band, a searcher's static weights decide the order. Matches with the same score move together as one block, placed by the learned position of the block's first match: moving each one on its own breaks search's existing rules for tied matches. Inside a block, the lexical ranker's order holds, except below the first result: there a block of one domain puts a part of the first result first (its name words start with the first result's; at most two parts lead across an answer), then the match whose matched words are rarer in the catalog. Matches never cross bands or kinds. There is no model runtime: every number is a plain static value read at load time.
|
|
8
8
|
|
|
9
9
|
## Files
|
|
10
10
|
|
package/api/search/_order.d.mts
CHANGED
|
@@ -23,10 +23,10 @@ export function orderMatches(table: EntryTable, order: number[], lexical: import
|
|
|
23
23
|
*/
|
|
24
24
|
export function integrationTies(items: Item[]): Item[];
|
|
25
25
|
export function bandOf(score: number): number;
|
|
26
|
+
export type EntryTable = import("./_entries.mjs").EntryTable;
|
|
26
27
|
export type Item = {
|
|
27
28
|
res: any;
|
|
28
29
|
i: number;
|
|
29
30
|
band: number;
|
|
30
31
|
learned: number;
|
|
31
32
|
};
|
|
32
|
-
export type EntryTable = import("./_entries.mjs").EntryTable;
|
package/api/search/_order.mjs
CHANGED
|
@@ -9,14 +9,15 @@
|
|
|
9
9
|
* and a synonym name match can score under 55, so inside a band a weaker match
|
|
10
10
|
* can lead a stronger one when the weights favor it. Inside such a
|
|
11
11
|
* run the learned order places the matches, with these exceptions: matches
|
|
12
|
-
* that scored the same
|
|
13
|
-
* query
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* that scored the same move as one block; an entry the query names leads; in a
|
|
13
|
+
* query of one or two words, the matches on every word keep their lexical
|
|
14
|
+
* order; and an integration's matches that scored the same keep theirs.
|
|
15
|
+
* Below the first result, a block of one domain is ordered by fit (tiesByFit): a part of the first result, then rarer matched
|
|
16
|
+
* words, then the lexical order.
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
import {entryOf} from './_entries.mjs';
|
|
19
|
-
import {words} from './_query-words.mjs';
|
|
20
|
+
import {fold, nameWords, words} from './_query-words.mjs';
|
|
20
21
|
import {searchedComponentsOf} from './_result.mjs';
|
|
21
22
|
|
|
22
23
|
/** @typedef {import('./_entries.mjs').EntryTable} EntryTable */
|
|
@@ -104,9 +105,12 @@ export function orderMatches(table, order, lexical, query, limit) {
|
|
|
104
105
|
ranked = keepLexical(ranked, it => (it.res.score ?? 0) >= FULL_COVERAGE);
|
|
105
106
|
}
|
|
106
107
|
ranked = integrationTies(ranked);
|
|
108
|
+
// Each whole tie is ordered by fit before the limit, so every limit shows
|
|
109
|
+
// the top of one answer.
|
|
110
|
+
const shown = tiesByFit(ranked, table, blockOf).slice(0, limit);
|
|
107
111
|
const response = {
|
|
108
112
|
...lexical,
|
|
109
|
-
data: {...lexical.data, results:
|
|
113
|
+
data: {...lexical.data, results: shown.map(it => it.res)},
|
|
110
114
|
};
|
|
111
115
|
const searched = searchedComponentsOf.get(lexical);
|
|
112
116
|
if (searched) searchedComponentsOf.set(response, searched);
|
|
@@ -117,6 +121,71 @@ export function orderMatches(table, order, lexical, query, limit) {
|
|
|
117
121
|
* @typedef {{res: any, i: number, band: number, learned: number}} Item
|
|
118
122
|
*/
|
|
119
123
|
|
|
124
|
+
/** How many parts of the first result lead their ties, across an answer. */
|
|
125
|
+
const PARTS_FIRST = 2;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Below the first result, matches the lexical ranker scored the same keep
|
|
129
|
+
* their block but are no longer in name order inside it: a part or sibling of
|
|
130
|
+
* the first result leads (TableRow after Table), then the match whose matched
|
|
131
|
+
* words are rarer in the catalog, so a match on a common word alone sits
|
|
132
|
+
* below one on the query's telling words. Nothing crosses a block.
|
|
133
|
+
* @param {Item[]} ranked
|
|
134
|
+
* @param {EntryTable} table
|
|
135
|
+
* @param {(item: Item) => string} blockOf
|
|
136
|
+
* @returns {Item[]}
|
|
137
|
+
*/
|
|
138
|
+
function tiesByFit(ranked, table, blockOf) {
|
|
139
|
+
if (ranked.length < 3) return ranked;
|
|
140
|
+
const first = nameWords(String(ranked[0].res.name ?? '')).map(fold);
|
|
141
|
+
const idf = table.fields.desc.idf;
|
|
142
|
+
const rarest = Math.max(0, ...idf.values());
|
|
143
|
+
/** @param {Item} it */
|
|
144
|
+
const related = it => {
|
|
145
|
+
// A part's name words start with the first result's whole name words:
|
|
146
|
+
// TableRow is a part of Table, Table is no part of Tab.
|
|
147
|
+
const name = nameWords(String(it.res.name ?? '')).map(fold);
|
|
148
|
+
return (
|
|
149
|
+
(first.length > 0 &&
|
|
150
|
+
name.length > first.length &&
|
|
151
|
+
first.every((w, n) => name[n] === w)) ||
|
|
152
|
+
/^member of /.test(it.res.reason ?? '')
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
/** @param {Item} it */
|
|
156
|
+
const rarity = it => {
|
|
157
|
+
const m = /^matches \d+\/\d+ terms: (.*)$/.exec(it.res.reason ?? '');
|
|
158
|
+
if (!m) return 0;
|
|
159
|
+
let sum = 0;
|
|
160
|
+
// A matched term counts by its alphanumeric parts (`three-dot`), and a
|
|
161
|
+
// part the catalog never uses is as rare as a word can be.
|
|
162
|
+
for (const t of m[1].split(', '))
|
|
163
|
+
for (const part of words(t)) sum += idf.get(fold(part)) ?? rarest;
|
|
164
|
+
return sum;
|
|
165
|
+
};
|
|
166
|
+
const out = [ranked[0]];
|
|
167
|
+
let parts = 0;
|
|
168
|
+
for (let i = 1; i < ranked.length;) {
|
|
169
|
+
let j = i;
|
|
170
|
+
const at = (/** @type {Item} */ it) => `${blockOf(it)}:${it.res.domain}`;
|
|
171
|
+
while (j < ranked.length && at(ranked[j]) === at(ranked[i])) j++;
|
|
172
|
+
const run = ranked.slice(i, j);
|
|
173
|
+
if (run.length > 1) {
|
|
174
|
+
const keyed = run.map((it, n) => {
|
|
175
|
+
// At most PARTS_FIRST parts lead, across the answer, so a family
|
|
176
|
+
// with many parts does not crowd out what else the query matched.
|
|
177
|
+
const r = parts < PARTS_FIRST && related(it);
|
|
178
|
+
if (r) parts++;
|
|
179
|
+
return {it, n, r, f: rarity(it)};
|
|
180
|
+
});
|
|
181
|
+
keyed.sort((a, b) => Number(b.r) - Number(a.r) || b.f - a.f || a.n - b.n);
|
|
182
|
+
out.push(...keyed.map(k => k.it));
|
|
183
|
+
} else out.push(...run);
|
|
184
|
+
i = j;
|
|
185
|
+
}
|
|
186
|
+
return out;
|
|
187
|
+
}
|
|
188
|
+
|
|
120
189
|
/**
|
|
121
190
|
* The matches `pick` selects keep the places they hold, filled in lexical
|
|
122
191
|
* order.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Below the first result, matches the lexical ranker scored the same
|
|
5
|
+
* are ordered by fit, not by name: a part of the first result leads its tie,
|
|
6
|
+
* then the match on the query's rarer words. Scores, reasons and the set of
|
|
7
|
+
* results stay the lexical ranker's (see _order.test.mjs).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {describe, expect, it} from 'vitest';
|
|
11
|
+
import {search} from './search.mjs';
|
|
12
|
+
|
|
13
|
+
describe('ties below the first result', () => {
|
|
14
|
+
it('a part of the first result leads its tie', async () => {
|
|
15
|
+
const results = (await search('progress bar with percent')).data.results;
|
|
16
|
+
expect(results[0]).toMatchObject({name: 'ProgressBar'});
|
|
17
|
+
expect(results[1]?.name).toMatch(/^ProgressBar./);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('shows the top of one answer at every limit', async () => {
|
|
21
|
+
const query = 'progress bar with percent';
|
|
22
|
+
const all = (await search(query)).data.results.map(r => r.name);
|
|
23
|
+
const three = (await search(query, {limit: 3})).data.results.map(
|
|
24
|
+
r => r.name,
|
|
25
|
+
);
|
|
26
|
+
expect(three).toEqual(all.slice(0, 3));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('reads a punctuated query word by its parts', async () => {
|
|
30
|
+
const results = (await search('three-dot menu with actions')).data.results;
|
|
31
|
+
expect(results.slice(0, 3).map(r => r.name)).toContain('MoreMenu');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('lets few parts lead, so a big family keeps the rest in view', async () => {
|
|
35
|
+
const results = (await search('chat')).data.results.map(r => r.name);
|
|
36
|
+
expect(results).toContain('ai-chat');
|
|
37
|
+
expect(results).toContain('ai-chat-landing');
|
|
38
|
+
});
|
|
39
|
+
});
|
package/assets/templates/blocks/components/CommandPaletteItem/CommandPaletteItemShowcase.doc.mjs
CHANGED
|
@@ -6,9 +6,10 @@ export const doc = {
|
|
|
6
6
|
exampleFor: 'CommandPaletteItem',
|
|
7
7
|
name: 'CommandPaletteItem',
|
|
8
8
|
displayName: 'Command Palette Item',
|
|
9
|
-
description:
|
|
9
|
+
description:
|
|
10
|
+
'An inline command palette whose items pair each command label with its keyboard shortcut through renderItem.',
|
|
10
11
|
isReady: true,
|
|
11
12
|
isShowcase: true,
|
|
12
13
|
aspectRatio: 4 / 3,
|
|
13
|
-
componentsUsed: ['CommandPalette', 'CommandPaletteItem', '
|
|
14
|
+
componentsUsed: ['CommandPalette', 'CommandPaletteItem', 'Kbd', 'Text'],
|
|
14
15
|
};
|
|
@@ -7,7 +7,7 @@ export const doc = {
|
|
|
7
7
|
name: 'Item — Metadata',
|
|
8
8
|
displayName: 'Item — Metadata',
|
|
9
9
|
description:
|
|
10
|
-
'
|
|
10
|
+
'Status rows with an icon, a title, a short description, and end-aligned metadata such as a timestamp or a status badge, here build, memory, and sync events. Use the endContent slot for counts, status, timestamps, and other secondary row information.',
|
|
11
11
|
isReady: true,
|
|
12
12
|
aspectRatio: 16 / 9,
|
|
13
13
|
componentsUsed: ['Item', 'Badge', 'Icon', 'Text', 'Layout'],
|
|
@@ -7,7 +7,7 @@ export const doc = {
|
|
|
7
7
|
name: 'MetadataListItem — Basic',
|
|
8
8
|
displayName: 'MetadataListItem — Basic',
|
|
9
9
|
description:
|
|
10
|
-
'
|
|
10
|
+
'A titled section of label and value rows for one record, here a deployment\'s environment, health status badge, version, and last deploy date. Values take plain text or a component such as a Badge.',
|
|
11
11
|
isReady: true,
|
|
12
12
|
aspectRatio: 16 / 9,
|
|
13
13
|
componentsUsed: ['MetadataList', 'MetadataListItem', 'Badge'],
|
package/assets/templates/blocks/components/SegmentedControlItem/SegmentedControlItemBasic.doc.mjs
CHANGED
|
@@ -7,7 +7,7 @@ export const doc = {
|
|
|
7
7
|
name: 'SegmentedControlItem — Basic',
|
|
8
8
|
displayName: 'SegmentedControlItem — Basic',
|
|
9
9
|
description:
|
|
10
|
-
'
|
|
10
|
+
'A row of label-only options that switches between a few views, here Board, List, and Timeline. Each item declares a value; the parent control holds the selected value and change handler.',
|
|
11
11
|
isReady: true,
|
|
12
12
|
aspectRatio: 16 / 9,
|
|
13
13
|
componentsUsed: ['SegmentedControl', 'SegmentedControlItem'],
|
package/assets/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.doc.mjs
CHANGED
|
@@ -7,7 +7,7 @@ export const doc = {
|
|
|
7
7
|
name: 'VisuallyHidden — Supplementary Context',
|
|
8
8
|
displayName: 'VisuallyHidden — Supplementary Context',
|
|
9
9
|
description:
|
|
10
|
-
'
|
|
10
|
+
'Stat cards whose trend arrows get screen-reader-only text, so a change like +12% is read as an increase from last month. Use to make terse visual data accessible.',
|
|
11
11
|
isReady: true,
|
|
12
12
|
aspectRatio: 4 / 3,
|
|
13
13
|
componentsUsed: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.4-canary.
|
|
3
|
+
"version": "0.7.4-canary.720bb10",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -106,10 +106,10 @@
|
|
|
106
106
|
"zod": "^4.4.3"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
|
-
"@astryxdesign/charts": "0.7.4-canary.
|
|
110
|
-
"@astryxdesign/core": "0.7.4-canary.
|
|
111
|
-
"@astryxdesign/lab": "0.7.4-canary.
|
|
112
|
-
"@astryxdesign/theme-neutral": "0.7.4-canary.
|
|
109
|
+
"@astryxdesign/charts": "0.7.4-canary.720bb10",
|
|
110
|
+
"@astryxdesign/core": "0.7.4-canary.720bb10",
|
|
111
|
+
"@astryxdesign/lab": "0.7.4-canary.720bb10",
|
|
112
|
+
"@astryxdesign/theme-neutral": "0.7.4-canary.720bb10"
|
|
113
113
|
},
|
|
114
114
|
"peerDependenciesMeta": {
|
|
115
115
|
"@astryxdesign/charts": {
|
|
@@ -126,10 +126,10 @@
|
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": {
|
|
129
|
-
"@astryxdesign/charts": "0.7.4-canary.
|
|
130
|
-
"@astryxdesign/core": "0.7.4-canary.
|
|
131
|
-
"@astryxdesign/lab": "0.7.4-canary.
|
|
132
|
-
"@astryxdesign/theme-neutral": "0.7.4-canary.
|
|
129
|
+
"@astryxdesign/charts": "0.7.4-canary.720bb10",
|
|
130
|
+
"@astryxdesign/core": "0.7.4-canary.720bb10",
|
|
131
|
+
"@astryxdesign/lab": "0.7.4-canary.720bb10",
|
|
132
|
+
"@astryxdesign/theme-neutral": "0.7.4-canary.720bb10",
|
|
133
133
|
"@heroicons/react": "^2.2.0",
|
|
134
134
|
"@stylexjs/stylex": "^0.19.0",
|
|
135
135
|
"@types/babel__core": "^7.20.5",
|