@astryxdesign/cli 0.6.3-canary.ee13359 → 0.6.3-canary.eedc844

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.
Files changed (77) hide show
  1. package/README.md +3 -3
  2. package/api/build/_adapter.d.mts +50 -0
  3. package/api/build/_adapter.mjs +60 -0
  4. package/api/build/build.doc.mjs +13 -7
  5. package/api/build/build.test.mjs +184 -6
  6. package/api/build/build.type.d.mts +57 -2
  7. package/api/build/build.type.mjs +30 -7
  8. package/api/build/help/help.d.mts +4 -0
  9. package/api/build/help/help.mjs +24 -11
  10. package/api/build/kit/kit.d.mts +4 -1
  11. package/api/build/kit/kit.mjs +165 -49
  12. package/api/build/kit/rank.d.mts +44 -0
  13. package/api/build/kit/rank.mjs +432 -0
  14. package/api/build/kit/rank.test.mjs +196 -0
  15. package/api/docs/_adapter.d.mts +49 -7
  16. package/api/docs/_adapter.mjs +284 -33
  17. package/api/docs/docs.doc.mjs +4 -3
  18. package/api/docs/docs.type.d.mts +21 -5
  19. package/api/docs/docs.type.mjs +21 -5
  20. package/api/docs/integration-tree.test.mjs +9 -1
  21. package/api/docs/reference-blocks.test.mjs +406 -0
  22. package/api/doctor/doctor.mjs +5 -1
  23. package/api/integration/authoring-checks.mjs +56 -23
  24. package/api/integration/authoring-checks.test.mjs +8 -1
  25. package/api/integration/authoring-checks.type.d.mts +1 -3
  26. package/api/integration/authoring-checks.type.mjs +7 -4
  27. package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
  28. package/api/integration/integrationTemplateConflicts.doc.mjs +8 -6
  29. package/api/integration/template-conflict-compatibility.test.mjs +73 -0
  30. package/api/search/search.d.mts +33 -0
  31. package/api/search/search.mjs +134 -42
  32. package/api/template/table-floating-bulk-actions.test.mjs +66 -0
  33. package/api/template/template-integration.test.mjs +50 -0
  34. package/assets/docs/layout.doc.dense.mjs +2 -2
  35. package/assets/docs/layout.doc.mjs +1 -1
  36. package/assets/docs/working-with-ai.doc.mjs +3 -3
  37. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
  38. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
  39. package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
  40. package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
  41. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
  42. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
  43. package/authoring/doctypes/_schema.d.mts +72 -0
  44. package/authoring/doctypes/_schema.mjs +25 -1
  45. package/authoring/doctypes/load-contract.test.mjs +25 -0
  46. package/authoring/doctypes/reference/reference.doc.mjs +31 -4
  47. package/authoring/doctypes/reference/type.ts +20 -5
  48. package/clients/cli/commands/build.doc.mjs +11 -6
  49. package/clients/cli/commands/build.mjs +105 -70
  50. package/clients/cli/commands/build.text-fields.test.mjs +41 -0
  51. package/clients/cli/commands/docs.mjs +2 -2
  52. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  53. package/clients/cli/commands/doctor-integration.test.mjs +7 -0
  54. package/clients/cli/commands/doctor.mjs +39 -17
  55. package/foundation/agent-docs/agent-docs.d.mts +3 -2
  56. package/foundation/agent-docs/agent-docs.mjs +12 -9
  57. package/foundation/agent-docs/agent-docs.test.mjs +9 -0
  58. package/foundation/discovery/authoring-self-docs.d.mts +12 -0
  59. package/foundation/discovery/authoring-self-docs.mjs +20 -8
  60. package/foundation/discovery/authoring-self-docs.test.mjs +7 -2
  61. package/foundation/discovery/docs-discovery.d.mts +4 -1
  62. package/foundation/discovery/docs-discovery.mjs +40 -6
  63. package/foundation/discovery/docs-discovery.test.mjs +40 -0
  64. package/foundation/discovery/template-conflict-release.d.mts +13 -0
  65. package/foundation/discovery/template-conflict-release.mjs +40 -0
  66. package/foundation/discovery/template-conflict-release.test.mjs +40 -0
  67. package/foundation/doc-compiler/lenses.d.mts +5 -3
  68. package/foundation/doc-compiler/lenses.mjs +48 -3
  69. package/foundation/doc-compiler/links.d.mts +30 -3
  70. package/foundation/doc-compiler/links.mjs +46 -5
  71. package/foundation/doc-compiler/links.test.mjs +53 -0
  72. package/foundation/integrations/cli-requirement.test.mjs +17 -42
  73. package/foundation/response/response-types.doc.d.mts +5 -1
  74. package/foundation/response/response-types.doc.mjs +8 -4
  75. package/foundation/text/string-utils.d.mts +8 -0
  76. package/foundation/text/string-utils.mjs +18 -0
  77. package/package.json +9 -9
@@ -0,0 +1,73 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Final-0.6.x compatibility coverage for integration-template conflicts.
5
+ * @input A future replacement declaration plus an ordinary released conflict.
6
+ * @output Proof that 0.6.x omits replacement-specific public fields.
7
+ * @position Regression fixture for the stable conflict response boundary.
8
+ */
9
+
10
+ import {afterEach, beforeEach, describe, expect, it} from 'vitest';
11
+ import * as fs from 'node:fs';
12
+ import * as path from 'node:path';
13
+ import {discoverCoreTemplates} from '../../foundation/discovery/template-adapter.mjs';
14
+ import {integrationTemplateConflicts} from './authoring-checks.mjs';
15
+
16
+ let tmpDir;
17
+
18
+ function writeTemplate(pkgDir, id, type, replaces) {
19
+ const stem = path.join(pkgDir, 'templates', id);
20
+ fs.mkdirSync(path.dirname(stem), {recursive: true});
21
+ fs.writeFileSync(
22
+ `${stem}.doc.mjs`,
23
+ `export default {type: ${JSON.stringify(type)}, name: ${JSON.stringify(id)}, description: 'fixture'${replaces == null ? '' : `, replaces: ${JSON.stringify(replaces)}`}};\n`,
24
+ );
25
+ fs.writeFileSync(
26
+ `${stem}.tsx`,
27
+ `export default function Fixture() { return ${JSON.stringify(id)}; }\n`,
28
+ );
29
+ }
30
+
31
+ beforeEach(() => {
32
+ tmpDir = fs.mkdtempSync(
33
+ path.join(process.cwd(), '.astryx-template-conflict-compat-'),
34
+ );
35
+ });
36
+
37
+ afterEach(() => {
38
+ fs.rmSync(tmpDir, {recursive: true, force: true});
39
+ });
40
+
41
+ describe('integration-template conflict compatibility on 0.6.x', () => {
42
+ it('preserves the released warning-only conflict shape', async () => {
43
+ const corePages = (await discoverCoreTemplates()).filter(
44
+ candidate => candidate.type === 'page',
45
+ );
46
+ const target = corePages[0];
47
+ const accidental = corePages[1];
48
+ expect(target).toBeDefined();
49
+ expect(accidental).toBeDefined();
50
+
51
+ fs.writeFileSync(
52
+ path.join(tmpDir, 'package.json'),
53
+ JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
54
+ );
55
+ fs.writeFileSync(
56
+ path.join(tmpDir, 'astryx.integration.mjs'),
57
+ `export default {templates: './templates'};\n`,
58
+ );
59
+ writeTemplate(tmpDir, 'acme-future-shell', target.type, target.dirName);
60
+ writeTemplate(tmpDir, accidental.dirName, accidental.type);
61
+
62
+ const report = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
63
+
64
+ expect(report.data.issues).toEqual([]);
65
+ expect(report.data.conflicts).toHaveLength(1);
66
+ expect(report.data.conflicts[0]).toMatchObject({
67
+ id: accidental.dirName,
68
+ severity: 'warning',
69
+ });
70
+ expect(report.data.conflicts[0]).not.toHaveProperty('relationship');
71
+ expect(report.data.conflicts[0]).not.toHaveProperty('replaces');
72
+ });
73
+ });
@@ -9,6 +9,13 @@
9
9
  * @returns {string}
10
10
  */
11
11
  export function stem(w: string): string;
12
+ /**
13
+ * Whether two lowercase words are the same word, up to plural and stem form.
14
+ * @param {string} a
15
+ * @param {string} b
16
+ * @returns {boolean}
17
+ */
18
+ export function sameWord(a: string, b: string): boolean;
12
19
  /**
13
20
  * Split a query into meaningful content tokens (lowercased, stopwords + very
14
21
  * short words removed). Empty for single-word queries (callers fall back to
@@ -47,6 +54,7 @@ export function scoreQuery(term: string, tokens: string[], candidate: Candidate)
47
54
  * @param {string} [candidate.description]
48
55
  * @param {string[]} [candidate.prose] - Extra free-text blobs (doc section text, best practices).
49
56
  * @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
57
+ * @param {{fuzzy?: boolean}} [opts] - `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false.
50
58
  * @returns {{score: number, reason: string} | null}
51
59
  */
52
60
  export function scoreCandidate(term: string, { name, keywords, weakKeywords, description, prose, guidance, }: {
@@ -56,6 +64,8 @@ export function scoreCandidate(term: string, { name, keywords, weakKeywords, des
56
64
  description?: string | undefined;
57
65
  prose?: string[] | undefined;
58
66
  guidance?: string[] | undefined;
67
+ }, { fuzzy }?: {
68
+ fuzzy?: boolean;
59
69
  }): {
60
70
  score: number;
61
71
  reason: string;
@@ -75,8 +85,31 @@ export function search(query: string, options?: {
75
85
  type?: "component" | "hook" | "template" | "doc" | undefined;
76
86
  limit?: number | undefined;
77
87
  }): Promise<import("./search.type.mjs").SearchResponse>;
88
+ export namespace SYNONYMS {
89
+ let dashboard: string[];
90
+ let login: string[];
91
+ let signup: string[];
92
+ let payment: string[];
93
+ let pricing: string[];
94
+ let chat: string[];
95
+ let settings: string[];
96
+ let calendar: string[];
97
+ let table: string[];
98
+ let gallery: string[];
99
+ let hero: string[];
100
+ let form: string[];
101
+ let profile: string[];
102
+ let documentation: string[];
103
+ let navigation: string[];
104
+ }
78
105
  /** Valid domain filters for `--type`. */
79
106
  export const SEARCH_DOMAINS: string[];
107
+ /**
108
+ * Filler words stripped from multi-word queries so natural-language phrasing
109
+ * ("a page where you can see business stats") ranks on its content words.
110
+ * Exported for `build`, whose page ranker strips the same words.
111
+ */
112
+ export const STOPWORDS: Set<string>;
80
113
  /**
81
114
  * A search candidate gathered from one content domain. Extra underscore-
82
115
  * prefixed fields carry domain-specific payload used only by {@link toResult}.
@@ -17,21 +17,31 @@
17
17
  * component fuzzy resolver in lib/string-utils.mjs:
18
18
  *
19
19
  * 100 exact name match
20
+ * 95 name is the term's plural or stem form ("buttons" -> Button)
20
21
  * 90 exact keyword match
21
- * 80 name Levenshtein distance 1
22
- * 70 keyword substring / distance 1
23
- * 60 name substring (>=4 chars, >=50% coverage)
22
+ * 88 keyword is the term's plural or stem form
23
+ * 80 name Levenshtein distance 1 (one-word lookups, words of 5+ letters)
24
+ * 70 keyword word prefix / distance 1 (distance: one-word lookups, 5+ letters)
25
+ * 60 name word prefix (>=4 chars, >=50% coverage)
24
26
  * 60 exact weak-keyword match
25
27
  * 50 description / prose mentions the term
26
28
  * 45 usage guidance mentions the term
27
- * 40 name Levenshtein distance 2
28
- * 40 weak-keyword substring
29
- * 30 keyword Levenshtein distance 2
30
- * 20 name Levenshtein distance 3
29
+ * 40 name Levenshtein distance 2 (one-word lookups, 8+ letters)
30
+ * 40 weak-keyword word prefix
31
+ * 30 keyword Levenshtein distance 2 (one-word lookups, 8+ letters)
32
+ * 20 name Levenshtein distance 3 (one-word lookups, 11+ letters)
31
33
  *
32
34
  * Name + keyword signals always outweigh description/prose, so an exact match
33
35
  * sorts above an incidental mention.
34
36
  *
37
+ * A term matches inside a name or keyword only at the start of one of its
38
+ * words: "dash" finds "dashboard" and "input" finds "TextInput", but "file"
39
+ * does not find "profile". Edit distance is typo tolerance, so it applies only
40
+ * to a one-word lookup, where a typo is the likely explanation, and only to
41
+ * words long enough that one edit rarely makes another real word. In a
42
+ * sentence, a near miss is usually a different word: "site" is not "side",
43
+ * "cable" is not "table".
44
+ *
35
45
  * Description and guidance are separate tiers on purpose. A component's own
36
46
  * one-line description saying "notification" is a claim about what it IS; the
37
47
  * same word inside another component's best-practice advice is a passing
@@ -115,9 +125,10 @@ import {setResultCoverage} from './coverage.mjs';
115
125
  * Synonym / intent map: product-language terms an agent is likely to type,
116
126
  * expanded to the catalog's vocabulary so oblique queries still rank. Keys and
117
127
  * values are matched bidirectionally (typing any value also pulls in the key
118
- * and its siblings). Lowercase, single words or short phrases.
128
+ * and its siblings). Lowercase, single words or short phrases. Exported for
129
+ * `build`, whose page ranker expands a query with the same vocabulary.
119
130
  */
120
- const SYNONYMS = {
131
+ export const SYNONYMS = {
121
132
  dashboard: [
122
133
  'overview',
123
134
  'analytics',
@@ -189,14 +200,90 @@ export function stem(w) {
189
200
  return s;
190
201
  }
191
202
 
203
+ /**
204
+ * The forms of a word that count as the same word: itself, its stem, and its
205
+ * singular when it ends in a plural suffix — so "tables" is "table",
206
+ * "statuses" is "status", and "filtering" is "filter".
207
+ * @param {string} w - Lowercase word.
208
+ * @returns {Set<string>}
209
+ */
210
+ function wordForms(w) {
211
+ const forms = new Set([w, stem(w)]);
212
+ if (w.length > 3 && w.endsWith('s')) forms.add(w.slice(0, -1));
213
+ if (w.length > 4 && w.endsWith('es')) forms.add(w.slice(0, -2));
214
+ if (w.length > 4 && w.endsWith('ies')) forms.add(w.slice(0, -3) + 'y');
215
+ return forms;
216
+ }
217
+
218
+ /**
219
+ * Whether two lowercase words are the same word, up to plural and stem form.
220
+ * @param {string} a
221
+ * @param {string} b
222
+ * @returns {boolean}
223
+ */
224
+ export function sameWord(a, b) {
225
+ if (a === b) return true;
226
+ const forms = wordForms(a);
227
+ for (const f of wordForms(b)) if (forms.has(f)) return true;
228
+ return false;
229
+ }
230
+
231
+ /**
232
+ * The lowercase words of a name or keyword: split at non-alphanumerics and at
233
+ * camelCase boundaries, so "TextInput" is ["text", "input"] and
234
+ * "Dashboard - Analytics" is ["dashboard", "analytics"].
235
+ * @param {string} text
236
+ * @returns {string[]}
237
+ */
238
+ function wordsOf(text) {
239
+ return String(text)
240
+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
241
+ .replace(/([A-Z])([A-Z][a-z])/g, '$1 $2')
242
+ .toLowerCase()
243
+ .split(/[^a-z0-9]+/)
244
+ .filter(Boolean);
245
+ }
246
+
247
+ /**
248
+ * Whether a term is found inside a name or keyword: it is one of its words, or
249
+ * the start of one (a truncation), and covers at least half of the whole
250
+ * string. Four letters minimum, so a short term never matches by accident.
251
+ * @param {string} term - Lowercase term.
252
+ * @param {string} text - The name or keyword as authored.
253
+ * @returns {boolean}
254
+ */
255
+ function startsAWordOf(term, text) {
256
+ if (term.length < 4) return false;
257
+ if (term.length / String(text).length < 0.5) return false;
258
+ return wordsOf(text).some(w => w.startsWith(term) || sameWord(term, w));
259
+ }
260
+
261
+ /**
262
+ * The fewest letters both words need before an edit distance counts as a
263
+ * typo, by distance. Below them, one edit usually makes a different word.
264
+ */
265
+ const TYPO_MIN_LENGTH = {1: 5, 2: 8, 3: 11};
266
+
267
+ /**
268
+ * @param {string} a
269
+ * @param {string} b
270
+ * @param {number} dist
271
+ */
272
+ const isTypo = (a, b, dist) =>
273
+ dist > 0 &&
274
+ dist <= 3 &&
275
+ Math.min(a.length, b.length) >=
276
+ TYPO_MIN_LENGTH[/** @type {1 | 2 | 3} */ (dist)];
277
+
192
278
  /** Valid domain filters for `--type`. */
193
279
  export const SEARCH_DOMAINS = ['component', 'hook', 'doc', 'template'];
194
280
 
195
281
  /**
196
282
  * Filler words stripped from multi-word queries so natural-language phrasing
197
283
  * ("a page where you can see business stats") ranks on its content words.
284
+ * Exported for `build`, whose page ranker strips the same words.
198
285
  */
199
- const STOPWORDS = new Set([
286
+ export const STOPWORDS = new Set([
200
287
  'a',
201
288
  'an',
202
289
  'the',
@@ -308,14 +395,15 @@ const MIN_TOKEN_SCORE = 50;
308
395
  * (synonym hits are discounted so a direct hit always wins).
309
396
  * @param {string} tok
310
397
  * @param {Candidate} candidate
398
+ * @param {{fuzzy?: boolean}} [opts]
311
399
  * @returns {{score: number, reason: string} | null}
312
400
  */
313
- function bestForToken(tok, candidate) {
314
- let best = scoreCandidate(tok, candidate);
401
+ function bestForToken(tok, candidate, opts = {}) {
402
+ let best = scoreCandidate(tok, candidate, opts);
315
403
  const syns = SYNONYM_INDEX.get(tok);
316
404
  if (syns) {
317
405
  for (const s of syns) {
318
- const h = scoreCandidate(s, candidate);
406
+ const h = scoreCandidate(s, candidate, opts);
319
407
  if (h) {
320
408
  const score = Math.round(h.score * 0.85);
321
409
  if (!best || score > best.score)
@@ -345,14 +433,17 @@ export function scoreQuery(term, tokens, candidate) {
345
433
  matched: total,
346
434
  total,
347
435
  });
348
- const full = scoreCandidate(term, candidate);
436
+ // Typo tolerance is for one-word lookups. In a multi-word query a near miss
437
+ // is usually a different word, not a typo.
438
+ const fuzzy = tokens.length <= 1;
439
+ const full = scoreCandidate(term, candidate, {fuzzy});
349
440
 
350
441
  // 0–1 content tokens: keep whole-phrase fuzzy matching (typo tolerance for
351
442
  // single words), but if stopwords left exactly one DIFFERENT token (e.g.
352
443
  // "pricing page" → "pricing"), score that token too and take the stronger.
353
444
  if (tokens.length <= 1) {
354
445
  const single =
355
- tokens.length === 1 ? bestForToken(tokens[0], candidate) : null;
446
+ tokens.length === 1 ? bestForToken(tokens[0], candidate, {fuzzy}) : null;
356
447
  if (full && (!single || full.score >= single.score)) return asFull(full);
357
448
  return single ? asFull(single) : null;
358
449
  }
@@ -379,7 +470,7 @@ export function scoreQuery(term, tokens, candidate) {
379
470
  /** @type {string[]} */
380
471
  const hitTerms = [];
381
472
  for (const tok of tokens) {
382
- const h = bestForToken(tok, candidate);
473
+ const h = bestForToken(tok, candidate, {fuzzy});
383
474
  if (h && h.score >= MIN_TOKEN_SCORE) {
384
475
  if (h.score > strongest) strongest = h.score;
385
476
  matched++;
@@ -432,6 +523,7 @@ export function scoreQuery(term, tokens, candidate) {
432
523
  * @param {string} [candidate.description]
433
524
  * @param {string[]} [candidate.prose] - Extra free-text blobs (doc section text, best practices).
434
525
  * @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
526
+ * @param {{fuzzy?: boolean}} [opts] - `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false.
435
527
  * @returns {{score: number, reason: string} | null}
436
528
  */
437
529
  export function scoreCandidate(
@@ -444,6 +536,7 @@ export function scoreCandidate(
444
536
  prose = [],
445
537
  guidance = [],
446
538
  },
539
+ {fuzzy = true} = {},
447
540
  ) {
448
541
  let best = 0;
449
542
  let reason = '';
@@ -464,20 +557,20 @@ export function scoreCandidate(
464
557
  if (nameLower === term) {
465
558
  consider(100, 'exact name');
466
559
  } else {
467
- // Substring (both directions), min 4 chars, >=50% coverage.
468
- const shorter = term.length < nameLower.length ? term : nameLower;
469
- const longer = term.length < nameLower.length ? nameLower : term;
470
- if (
471
- shorter.length >= 4 &&
472
- longer.includes(shorter) &&
473
- shorter.length / longer.length >= 0.5
474
- ) {
475
- consider(60, `name contains "${shorter}"`);
560
+ if (sameWord(term, nameLower)) consider(95, `name "${name}"`);
561
+ // The term is a word of the name, or starts one: "input" in TextInput.
562
+ else if (startsAWordOf(term, name)) {
563
+ consider(60, `name contains "${term}"`);
564
+ }
565
+ if (fuzzy) {
566
+ const dist = levenshteinDistance(term, nameLower);
567
+ if (isTypo(term, nameLower, dist)) {
568
+ consider(
569
+ dist === 1 ? 80 : dist === 2 ? 40 : 20,
570
+ `similar name (distance ${dist})`,
571
+ );
572
+ }
476
573
  }
477
- const dist = levenshteinDistance(term, nameLower);
478
- if (dist === 1) consider(80, `similar name (distance ${dist})`);
479
- else if (dist === 2) consider(40, `similar name (distance ${dist})`);
480
- else if (dist === 3) consider(20, `similar name (distance ${dist})`);
481
574
  }
482
575
 
483
576
  // ── Keyword signals ─────────────────────────────────────────────
@@ -487,14 +580,17 @@ export function scoreCandidate(
487
580
  consider(90, `keyword "${kw}"`);
488
581
  continue;
489
582
  }
490
- const s = term.length < kwLower.length ? term : kwLower;
491
- const l = term.length < kwLower.length ? kwLower : term;
492
- if (s.length >= 4 && l.includes(s) && s.length / l.length >= 0.5) {
493
- consider(70, `keyword "${kw}"`);
583
+ if (sameWord(term, kwLower)) {
584
+ consider(88, `keyword "${kw}"`);
585
+ continue;
586
+ }
587
+ if (startsAWordOf(term, kw)) consider(70, `keyword "${kw}"`);
588
+ if (fuzzy) {
589
+ const dist = levenshteinDistance(term, kwLower);
590
+ if (isTypo(term, kwLower, dist) && dist <= 2) {
591
+ consider(dist === 1 ? 70 : 30, `keyword "${kw}" (distance ${dist})`);
592
+ }
494
593
  }
495
- const dist = levenshteinDistance(term, kwLower);
496
- if (dist === 1) consider(70, `keyword "${kw}" (distance ${dist})`);
497
- else if (dist === 2) consider(30, `keyword "${kw}" (distance ${dist})`);
498
594
  }
499
595
 
500
596
  // ── Weak keyword signals (derived, not authored) ─────────────────
@@ -504,15 +600,11 @@ export function scoreCandidate(
504
600
  // No Levenshtein tier — fuzzy matching a derived signal is pure noise.
505
601
  for (const kw of weakKeywords) {
506
602
  const kwLower = String(kw).toLowerCase();
507
- if (kwLower === term) {
603
+ if (kwLower === term || sameWord(term, kwLower)) {
508
604
  consider(60, `renders ${kw}`);
509
605
  continue;
510
606
  }
511
- const s = term.length < kwLower.length ? term : kwLower;
512
- const l = term.length < kwLower.length ? kwLower : term;
513
- if (s.length >= 4 && l.includes(s) && s.length / l.length >= 0.5) {
514
- consider(40, `renders ${kw}`);
515
- }
607
+ if (startsAWordOf(term, kw)) consider(40, `renders ${kw}`);
516
608
  }
517
609
 
518
610
  // ── Prose / description / guidance signals (stem-tolerant whole word) ──
@@ -0,0 +1,66 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Regression coverage for the floating bulk-actions Table block.
5
+ * @input The shipped TableFloatingBulkActionsTable source.
6
+ * @output Assertions for width, logical scrolling, local stacking, and shared toolbar geometry.
7
+ * @position Template contract test for the website example layout.
8
+ */
9
+
10
+ import fs from 'node:fs';
11
+ import path from 'node:path';
12
+ import {fileURLToPath} from 'node:url';
13
+ import {describe, expect, it} from 'vitest';
14
+
15
+ const sourcePath = path.resolve(
16
+ path.dirname(fileURLToPath(import.meta.url)),
17
+ '../../assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx',
18
+ );
19
+ const source = fs.readFileSync(sourcePath, 'utf8');
20
+ const pageStyles = source.match(/page:\s*\{([\s\S]*?)\n\s{2}\},/)?.[1];
21
+ const tableRegionStyles = source.match(
22
+ /tableRegion:\s*\{([\s\S]*?)\n\s{2}\},/,
23
+ )?.[1];
24
+ const toolbarStyles = source.match(/toolbar:\s*\{([\s\S]*?)\n\s{2}\},/)?.[1];
25
+ const columns = source.match(
26
+ /const columns:[\s\S]*?=\s*\[([\s\S]*?)\n\];/,
27
+ )?.[1];
28
+
29
+ describe('Table floating bulk-actions template', () => {
30
+ it('caps the demo height without capping its width', () => {
31
+ expect(pageStyles).toContain('maxBlockSize: 640');
32
+ expect(pageStyles).not.toContain('maxWidth');
33
+ expect(pageStyles).not.toContain('marginInline');
34
+ });
35
+
36
+ it('uses the shared logical-axis scroll behavior', () => {
37
+ expect(source).toContain(
38
+ "import {ScrollableArea} from '@astryxdesign/core/ScrollableArea'",
39
+ );
40
+ expect(source).toMatch(
41
+ /<ScrollableArea[\s\S]*?axis="block"[\s\S]*?label="Bulk actions example"[\s\S]*?overscroll="contain"/,
42
+ );
43
+ expect(source).not.toContain('role="region"');
44
+ expect(source).not.toContain('tabIndex={0}');
45
+ expect(source).not.toContain('aria-label="Metrics"');
46
+ expect(pageStyles).not.toContain('overflowY');
47
+ expect(pageStyles).not.toContain('overscrollBehavior');
48
+ });
49
+
50
+ it('keeps the floating toolbar inside an isolated local stacking context', () => {
51
+ expect(pageStyles).toContain("isolation: 'isolate'");
52
+ expect(toolbarStyles).toContain('zIndex: 1');
53
+ expect(toolbarStyles).not.toContain('zIndex: 20');
54
+ });
55
+
56
+ it('shares one reserved-space variable across the placement geometry', () => {
57
+ expect(tableRegionStyles).toContain("'--table-bulk-actions-space'");
58
+ expect(source.match(/var\(--table-bulk-actions-space\)/g)).toHaveLength(4);
59
+ });
60
+
61
+ it('keeps the email column compact enough to avoid horizontal overflow', () => {
62
+ expect(columns).toContain(
63
+ "{key: 'email', header: 'Email', width: proportional(1)}",
64
+ );
65
+ });
66
+ });
@@ -1271,3 +1271,53 @@ describe('integration template discovery', () => {
1271
1271
  expect(fs.existsSync(path.join(tmpDir, 'dest', 'hero.tsx'))).toBe(true);
1272
1272
  });
1273
1273
  });
1274
+
1275
+ describe('build names a start its command selects', () => {
1276
+ it('scaffolds an integration replacement through the Core id it replaces', async () => {
1277
+ const pkgDir = installWidgets(tmpDir);
1278
+ writeTemplate(pkgDir, 'acme-app-shell', {
1279
+ kind: 'page',
1280
+ body: "export default {type: 'page', name: 'Acme App Shell', category: 'Shell - Acme Sidebar', description: 'Acme application frame with a left sidebar navigation. Shell, frame, or sidebar navigation.'};\n",
1281
+ });
1282
+ declareReplaces(pkgDir, {'acme-app-shell': 'shell-side-nav'});
1283
+
1284
+ const kit = await build('acme application frame with sidebar navigation', {
1285
+ cwd: tmpDir,
1286
+ });
1287
+ expect(kit.type).toBe('build.kit');
1288
+ if (kit.type !== 'build.kit') throw new Error('expected build.kit');
1289
+ expect(kit.data.start).toMatchObject({
1290
+ name: 'acme-app-shell',
1291
+ command: 'astryx template shell-side-nav --type page <path>',
1292
+ });
1293
+ const selected = await template('shell-side-nav', {
1294
+ type: 'page',
1295
+ show: true,
1296
+ cwd: tmpDir,
1297
+ });
1298
+ expect(selected.data.template).toBe('acme-app-shell');
1299
+ });
1300
+
1301
+ it('keeps the start command unambiguous when a block shares the id', async () => {
1302
+ const pkgDir = installWidgets(tmpDir);
1303
+ writeTemplate(pkgDir, 'contact-form', {kind: 'block'});
1304
+
1305
+ const kit = await build('contact form', {cwd: tmpDir});
1306
+ expect(kit.type).toBe('build.kit');
1307
+ if (kit.type !== 'build.kit') throw new Error('expected build.kit');
1308
+ expect(kit.data.start).toMatchObject({
1309
+ name: 'contact-form',
1310
+ command: 'astryx template contact-form --type page <path>',
1311
+ });
1312
+ const selected = await template('contact-form', {
1313
+ type: 'page',
1314
+ show: true,
1315
+ cwd: tmpDir,
1316
+ });
1317
+ expect(selected.data.template).toBe('contact-form');
1318
+ // The bare id is ambiguous here, which is why the command carries --type.
1319
+ await expect(
1320
+ template('contact-form', {show: true, cwd: tmpDir}),
1321
+ ).rejects.toMatchObject({code: 'ERR_AMBIGUOUS_TEMPLATE'});
1322
+ });
1323
+ });
@@ -25,7 +25,7 @@ export const docsDense = {
25
25
  },
26
26
  {
27
27
  type: 'prose',
28
- text: 'decides layout, not component APIs. npx astryx build "<idea>" = closest template for your app type. npx astryx component <Name> = props.',
28
+ text: 'decides layout, not component APIs. npx astryx build "<idea>" = the template to start from for your app type. npx astryx component <Name> = props.',
29
29
  },
30
30
  ],
31
31
  },
@@ -71,7 +71,7 @@ export const docsDense = {
71
71
  null,
72
72
  {
73
73
  type: 'prose',
74
- text: 'verify: you can state the reason in one sentence, and it still holds if the nav doubles. npx astryx build "<idea>" names the closest template, --skeleton shows the pairing wired up.',
74
+ text: 'verify: you can state the reason in one sentence, and it still holds if the nav doubles. npx astryx build "<idea>" names the template to start from; scaffold it and the pairing is wired up.',
75
75
  },
76
76
  // Best practices
77
77
  null,
@@ -106,7 +106,7 @@ export const docs = {
106
106
  },
107
107
  {
108
108
  type: 'prose',
109
- text: 'Verify: you can state the reason in one sentence, and the choice still holds if the nav doubles in size. `npx astryx build "<idea>"` names the closest template, and its `--skeleton` shows the pairing already wired up.',
109
+ text: 'Verify: you can state the reason in one sentence, and the choice still holds if the nav doubles in size. `npx astryx build "<idea>"` names the template to start from; scaffold it and the pairing is already wired up.',
110
110
  },
111
111
 
112
112
  {type: 'heading', level: 3, text: 'Best practices'},
@@ -66,14 +66,14 @@ npx @astryxdesign/cli init --features agents --agent muse # AGENTS.md (Muse
66
66
  type: 'list',
67
67
  style: 'ordered',
68
68
  items: [
69
- '`astryx template --list`: find a related page pattern to use as reference',
70
- '`astryx template <name> --skeleton`: study the layout structure',
69
+ '`astryx build "<idea>"`: get the page template to start from (always one: the closest match, or the app shell), two other templates, and the blocks and components for the parts it lacks',
70
+ '`astryx template <name> <path>`: scaffold that template into the project, keep its frame and spacing, and replace its content',
71
71
  '`astryx component <Name>`: read props and examples for every component used',
72
72
  ],
73
73
  },
74
74
  {
75
75
  type: 'prose',
76
- text: "It also includes rules that prevent common mistakes (no raw divs, no style={{}}, use tokens not magic values), a CLI quick reference, and package-labeled integration guidance when a configured manifest declares `agentDocs`. After setup, you shouldn't need to manually correct your AI on these conventions; the agent docs handle it at the system level.",
76
+ text: "It also includes rules that prevent common mistakes (start every page from a template, no raw divs, no style={{}}, use tokens not magic values), a CLI quick reference, and package-labeled integration guidance when a configured manifest declares `agentDocs`. After setup, you shouldn't need to manually correct your AI on these conventions; the agent docs handle it at the system level.",
77
77
  },
78
78
  ],
79
79
  },
@@ -10,5 +10,5 @@ export const doc = {
10
10
  'A "select all" toggle at the top of a checkbox list that switches to an indeterminate dash when only some items are checked, useful for bulk actions like exporting documents or assigning permissions where users often want everything at once.',
11
11
  isReady: true,
12
12
  aspectRatio: 16 / 9,
13
- componentsUsed: ['CheckboxList', 'Divider'],
13
+ componentsUsed: ['CheckboxList'],
14
14
  };
@@ -4,7 +4,6 @@
4
4
 
5
5
  import {useState} from 'react';
6
6
  import {CheckboxList, CheckboxListItem} from '@astryxdesign/core/CheckboxList';
7
- import {Divider} from '@astryxdesign/core/Divider';
8
7
 
9
8
  const DOCUMENTS = [
10
9
  {id: 'transactions', label: 'Transaction history'},
@@ -27,7 +26,7 @@ export default function CheckboxListSelectAllPattern() {
27
26
  : ('indeterminate' as const);
28
27
 
29
28
  return (
30
- <CheckboxList label="Include in export">
29
+ <CheckboxList label="Include in export" hasDividers>
31
30
  <CheckboxListItem
32
31
  label="Select all"
33
32
  isChecked={selectAllState}
@@ -35,7 +34,6 @@ export default function CheckboxListSelectAllPattern() {
35
34
  setSelected(checked ? [...ALL_IDS] : []);
36
35
  }}
37
36
  />
38
- <Divider />
39
37
  {DOCUMENTS.map(doc => (
40
38
  <CheckboxListItem
41
39
  key={doc.id}
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'useTableSelection',
7
+ name: 'Table: Bulk Actions',
8
+ displayName: 'Table: Bulk Actions',
9
+ description:
10
+ 'Controlled row selection with the reusable TableSelectionToolbar rendered in flow above the table. Product actions occupy the logical start; synchronized selection count and complete clear action occupy the logical end.',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: ['Table', 'TableSelectionToolbar', 'Button'],
14
+ };