@astryxdesign/cli 0.7.14-canary.g3825554 → 0.7.14-canary.g7deca33

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.
@@ -800,10 +800,11 @@ export function answerHow(ctx, question) {
800
800
  !(/\bwhite\b/.test(text) && !whiteText)
801
801
  )
802
802
  intents = intents.filter(g => g !== 'background');
803
- // "border color" is the border's color, not a fill; a color word for
804
- // something else ("white with a gray border") still is one.
803
+ // "border color" or "a gray border" is the border's color, not a fill; a
804
+ // color word for anything else ("a dark card with a border", "the card
805
+ // color and its border", "colored buttons") is the fill's.
805
806
  const looseColor = new RegExp(
806
- `\\b(${COLOR_WORDS.join('|')})\\b(?!\\s+(border|outline|stroke|edge|text|labels?)s?\\b)`,
807
+ `(?<!\\b(border|outline|stroke|edge)\\s)\\b(${[...COLOR_WORDS, 'dark', 'light', 'colou?r(ed)?'].join('|')})\\b(?!\\s+(border|outline|stroke|edge|text|labels?)s?\\b)`,
807
808
  ).test(text);
808
809
  if (
809
810
  intents.includes('border') &&
@@ -321,9 +321,18 @@ async function change(sub, slug, thing, value, options) {
321
321
  `the ${s.thing} color is no longer generated, and the tokens it fed go back to the base theme's values`,
322
322
  );
323
323
  if (s.thing === 'neutral' && sub === 'set') {
324
- const page = base.light['--color-background-body'];
324
+ // Only the theme's own modes; a dark theme gets no white-page offer.
325
+ const modes = modesOf(data);
326
+ const pages = modes
327
+ .map(m => [m, base[m]['--color-background-body']])
328
+ .filter(([, v]) => v)
329
+ .map(([m, v]) => `${v} in ${m}`);
325
330
  notes.push(
326
- `the page background stays the base theme's${page ? ` (${page} in light${base.dark['--color-background-body'] ? `, ${base.dark['--color-background-body']} in dark` : ''})` : ''}; for a white or off-white page: ${P} set ${slug} --color-background-body "#ffffff"${data.mode === 'both' ? ' --mode light' : ''}`,
331
+ `the page background stays the base theme's${pages.length ? ` (${pages.join(', ')})` : ''}${
332
+ modes.includes('light')
333
+ ? `; for a white or off-white page: ${P} set ${slug} --color-background-body "#ffffff"${modes.length > 1 ? ' --mode light' : ''}`
334
+ : `; for another page color: ${P} set ${slug} --color-background-body "<color>"`
335
+ }`,
327
336
  );
328
337
  }
329
338
  if (s.thing === 'vibrancy') {
@@ -500,12 +509,30 @@ function partValues(ctx, data, res, mode) {
500
509
  const listed = `${parts.slice(0, 4).join(', ')}${parts.length > 4 ? `, and ${parts.length - 4} more` : ''}`;
501
510
  if (s.thing === 'corners') {
502
511
  const px = cornerPx(s.value);
503
- const token = FAMILIES[s.on ?? '']
504
- ? s.on === 'containers'
505
- ? '--radius-container'
506
- : '--radius-element'
507
- : '--radius-element';
508
- return `${describe(s)} -> border-radius ${px >= 9999 ? 'fully round' : `${px}px`} on ${listed} (whole theme: ${token} ${res[mode][token] ?? 'unset'})`;
512
+ // The radius token each part's resting corners read, as the whole-
513
+ // theme value they would have without this setting.
514
+ // A part the census saw closed (a menu, a popover) has no recorded
515
+ // radius: like every Core surface, it reads the container radius.
516
+ /** @type {Map<string, string[]>} */
517
+ const byToken = new Map();
518
+ for (const t of parts) {
519
+ const reads = ctx.C.partReads(t, 'corners').filter(x =>
520
+ x.props.includes('border-radius'),
521
+ );
522
+ const token =
523
+ (reads.find(x => x.when.includes('')) ?? reads[0])?.token ??
524
+ (['containers', 'menus'].includes(familyOf(t) ?? '')
525
+ ? '--radius-container'
526
+ : '--radius-element');
527
+ byToken.set(token, [...(byToken.get(token) ?? []), t]);
528
+ }
529
+ const whole = [...byToken]
530
+ .map(
531
+ ([token, ts]) =>
532
+ `${token} ${res[mode][token] ?? 'unset'}${byToken.size > 1 ? ` for ${ts.join(', ')}` : ''}`,
533
+ )
534
+ .join('; ');
535
+ return `${describe(s)} -> border-radius ${px >= 9999 ? 'fully round' : `${px}px`} on ${listed} (whole theme: ${whole})`;
509
536
  }
510
537
  const f = SPACING.find(([n]) => n === s.value)?.[1] ?? 1;
511
538
  return `${describe(s)} -> spacing x${f} inside ${listed} (whole theme: --spacing-4 ${res[mode]['--spacing-4'] ?? 'unset'})`;
@@ -541,6 +541,45 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
541
541
  };
542
542
  };
543
543
 
544
+ /**
545
+ * The dark shade nearest the seed's own shade (a lighter one on a tie)
546
+ * where text on it reads at 4.5:1 and it stands out from the dark
547
+ * surfaces at 3:1; null when no shade does both.
548
+ * @param {string} onToken @param {string} id @param {number} seedStop
549
+ */
550
+ const nearestDarkFill = (onToken, id, seedStop) => {
551
+ const page = surfaces('dark', id);
552
+ const order = [...stops]
553
+ .filter(s => s > 0 && s < 100)
554
+ .sort((a, b) => Math.abs(a - seedStop) - Math.abs(b - seedStop) || b - a);
555
+ for (const stop of order) {
556
+ const fill = ref(id, 'dark', stop).color;
557
+ if (Math.min(...page.map(([, bg]) => contrast(fill, bg))) < NON_TEXT)
558
+ continue;
559
+ const best = ON_FILL.dark
560
+ .map(on => ({on, r: contrast(ref(id, 'dark', on).color, fill)}))
561
+ .reduce((a, b) => (b.r > a.r + 0.01 ? b : a));
562
+ if (best.r < TEXT) continue;
563
+ if (has(onToken))
564
+ checks.push({
565
+ token: onToken,
566
+ mode: 'dark',
567
+ stop: best.on,
568
+ preferred: ON_FILL.dark[0],
569
+ against: `the fill (shade ${stop})`,
570
+ ratio: round(best.r),
571
+ needs: TEXT,
572
+ pass: true,
573
+ });
574
+ return {
575
+ fill: ref(id, 'dark', stop),
576
+ on: ref(id, 'dark', best.on),
577
+ moved: stop,
578
+ };
579
+ }
580
+ return null;
581
+ };
582
+
544
583
  const modes = /** @type {Mode[]} */ (['light', 'dark']);
545
584
  const neutral = fams.find(f => f.id === 'neutral');
546
585
  if (neutral) {
@@ -649,7 +688,9 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
649
688
  return fillPair(names.fill, names.on, f.id, m, fillStart(f.id));
650
689
  const exact = exactDarkFill(names.fill, names.on, f.id, fillStart(f.id));
651
690
  if (exact.pair) return exact.pair;
652
- const pair = fillPair(names.fill, names.on, f.id, m, FILL[1]);
691
+ const pair =
692
+ nearestDarkFill(names.on, f.id, fillStart(f.id)) ??
693
+ fillPair(names.fill, names.on, f.id, m, FILL[1]);
653
694
  if (has(names.fill))
654
695
  checks.push({
655
696
  token: names.fill,
@@ -604,9 +604,14 @@ async function rankedPages(words, cwd, notes, flags) {
604
604
  const suggest = (/** @type {string[]} */ list) =>
605
605
  list.slice(0, 3).map(n => `${PREVIEW} add --template ${n}${flags}`);
606
606
  // No page relates when the ranking fell back to a frame with no direct
607
- // match, and no page the search found matches two words of the request.
608
- const termsMatched = (/** @type {any} */ r) =>
609
- Number(/^matches (\d+)\//.exec(String(r.reason ?? ''))?.[1] ?? 0);
607
+ // match, and no page the search found matches three words of the request
608
+ // or two fifths of them.
609
+ const termsMatched = (/** @type {any} */ r) => {
610
+ const m = /^matches (\d+)\/(\d+)/.exec(String(r.reason ?? ''));
611
+ if (!m) return 0;
612
+ const [hit, of] = [Number(m[1]), Number(m[2])];
613
+ return hit >= 3 || hit / of >= 0.4 ? hit : 0;
614
+ };
610
615
  const unrelated =
611
616
  !pages.length ||
612
617
  (start &&
@@ -615,7 +620,8 @@ async function rankedPages(words, cwd, notes, flags) {
615
620
  !kit.data.directMatch &&
616
621
  !found.some(
617
622
  (/** @type {any} */ r) => !frames.has(r.name) && termsMatched(r) >= 2,
618
- ));
623
+ ) &&
624
+ !APP_PAGES.some(([re]) => re.test(words.toLowerCase())));
619
625
  if (unrelated)
620
626
  refuse(
621
627
  E.ERR_NOT_FOUND,
@@ -643,12 +649,28 @@ async function rankedPages(words, cwd, notes, flags) {
643
649
  /** @type {Map<string, string>} */
644
650
  const reasons = new Map();
645
651
  if (app) {
646
- const id = /** @type {string} */ (app[1].find(exists));
647
- if (pages.includes(id)) pages.splice(pages.indexOf(id), 1);
648
- pages.unshift(id);
649
- reasons.set(
650
- id,
651
- `the description names ${/** @type {RegExpExecArray} */ (app[0].exec(text))[0]}, and an app page shows a theme better than a hero`,
652
+ // The ranked page stays first when it already serves the app named;
653
+ // the app's pages come next, in order, so the next one is taken when
654
+ // one cannot be shown here.
655
+ const named = /** @type {RegExpExecArray} */ (app[0].exec(text))[0];
656
+ const keep = app[1].includes(pages[0]) ? pages[0] : null;
657
+ const ids = app[1].filter(id => exists(id) && id !== keep);
658
+ for (const id of [...ids].reverse()) {
659
+ if (pages.includes(id)) pages.splice(pages.indexOf(id), 1);
660
+ pages.splice(keep ? 1 : 0, 0, id);
661
+ }
662
+ if (keep)
663
+ reasons.set(
664
+ keep,
665
+ `the description names ${named}, and this page is that app`,
666
+ );
667
+ ids.forEach((id, k) =>
668
+ reasons.set(
669
+ id,
670
+ k === 0 && !keep
671
+ ? `the description names ${named}, and an app page shows a theme better than a hero`
672
+ : `the next page for ${named}`,
673
+ ),
652
674
  );
653
675
  } else if (side && listed.some(t => t.id === 'side-gallery')) {
654
676
  if (pages.includes('side-gallery'))
@@ -681,21 +703,34 @@ async function rankedPages(words, cwd, notes, flags) {
681
703
  }
682
704
 
683
705
  /**
684
- * App pages for the apps a description can name, best first.
706
+ * App pages for the apps a description names, best first. Each is matched
707
+ * by a phrase, never one loose word, so "buy tickets" is not an issue
708
+ * tracker and "an AI tool" is not a chat. A detail view comes before its
709
+ * list.
685
710
  * @type {Array<[RegExp, string[]]>}
686
711
  */
687
712
  const APP_PAGES = [
688
713
  [
689
- /\b(issue[- ]?tracker|issues|tickets?|bug tracker|backlog)\b/,
690
- ['table-grouped', 'work-item-detail', 'table'],
714
+ /\b(issue|ticket|bug|task|work[- ]item|story) (detail|details|view|page)\b/,
715
+ ['work-item-detail', 'detail-page'],
716
+ ],
717
+ [
718
+ /\b(issue[- ]?tracker|bug[- ]tracker|issue (list|table|queue|board)|ticket(ing)? (system|queue|tracker)|backlog)\b/,
719
+ ['table-grouped', 'table'],
720
+ ],
721
+ [/\b(kanban|task board|project board)\b/, ['kanban-board']],
722
+ [/\b(analytics )?dashboard\b|\banalytics (app|page|view)\b/, ['dashboard']],
723
+ [
724
+ /\b(email|mail) (inbox|client|app)\b|\binbox (app|view|page)\b/,
725
+ ['table-inbox'],
726
+ ],
727
+ [
728
+ /\b(chat (app|interface|ui|window|screen|view)|chatbot|ai (chat|assistant) (app|interface|ui))\b/,
729
+ ['ai-chat'],
691
730
  ],
692
- [/\b(kanban|task board|boards?)\b/, ['kanban-board']],
693
- [/\b(dashboard|analytics|metrics|charts?)\b/, ['dashboard']],
694
- [/\b(inbox|email|messages)\b/, ['table-inbox']],
695
- [/\b(chat|assistant|ai)\b/, ['ai-chat', 'ai-chat-landing']],
696
- [/\b(settings|preferences)\b/, ['settings']],
697
- [/\b(docs|documentation)\b/, ['documentation']],
698
- [/\b(data ?table|table|spreadsheet|data grid)\b/, ['table']],
731
+ [/\b(settings|preferences) (page|screen|panel|view)\b/, ['settings']],
732
+ [/\b(docs|documentation) (site|page|portal)\b/, ['documentation']],
733
+ [/\b(data ?table|spreadsheet|data grid)\b/, ['table']],
699
734
  [
700
735
  /\b(app|product) (screenshot|window|preview|ui)\b/,
701
736
  ['table-grouped', 'dashboard', 'table'],
@@ -236,6 +236,10 @@
236
236
  "kind": "component",
237
237
  "name": "TransferList"
238
238
  },
239
+ {
240
+ "kind": "component",
241
+ "name": "WeightedSVGIcon"
242
+ },
239
243
  {
240
244
  "kind": "template",
241
245
  "name": "CommentComposerShowcase"
@@ -324,14 +324,9 @@ function changeBlocks(r) {
324
324
  d.was != null
325
325
  ? `[ok] ${d.theme}: ${s.thing} ${d.was} -> ${s.value}`
326
326
  : `[ok] ${d.theme}: ${d.action === 'set' ? describe(s) : `removed ${describe(s)}; it is back to the base theme's value`}`;
327
- // On undo the setting is the one removed: it prints as `removed`, never as
328
- // the value now in effect.
329
- const {setting, ...rest} = d;
330
- void setting;
331
- return [
332
- status,
333
- ...project(/** @type {any} */ (d.action === 'undo' ? rest : d)),
334
- ];
327
+ // On undo, `setting` and `removed` both name the setting removed, as in
328
+ // the JSON; the status line says the base theme's value is back.
329
+ return [status, ...project(/** @type {any} */ (d))];
335
330
  }
336
331
 
337
332
  /**
@@ -135,7 +135,7 @@ export const doc = {
135
135
  value: 'themeEdit.undo',
136
136
  stability: 'experimental',
137
137
  description:
138
- "An undo. One step back (`action` `step`): what was `undone`, the `settings` count now, the `stepsLeft`, the `preview` page and any `pictures`. One setting removed (`action` `undo`): the same fields as `themeEdit.set`, with `setting` naming the one removed, which is back to the base theme's value. Experimental: may change or be removed in a patch release.",
138
+ "An undo. One step back (`action` `step`): what was `undone`, the `settings` count now, the `stepsLeft`, the `preview` page and any `pictures`. One setting removed (`action` `undo`): the same fields as `themeEdit.set`, with `setting` and `removed` both naming the setting removed (not the value now in effect: that is the base theme's, and `changedTokens` lists it). Experimental: may change or be removed in a patch release.",
139
139
  },
140
140
  {
141
141
  value: 'themeEdit.previewAdd',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.14-canary.g3825554",
3
+ "version": "0.7.14-canary.g7deca33",
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",
@@ -125,7 +125,7 @@
125
125
  "zod": "^4.6.7"
126
126
  },
127
127
  "peerDependencies": {
128
- "@astryxdesign/core": "0.7.14-canary.g3825554"
128
+ "@astryxdesign/core": "0.7.14-canary.g7deca33"
129
129
  },
130
130
  "peerDependenciesMeta": {
131
131
  "@astryxdesign/core": {
@@ -133,10 +133,10 @@
133
133
  }
134
134
  },
135
135
  "devDependencies": {
136
- "@astryxdesign/charts": "0.7.14-canary.g3825554",
137
- "@astryxdesign/core": "0.7.14-canary.g3825554",
138
- "@astryxdesign/lab": "0.7.14-canary.g3825554",
139
- "@astryxdesign/theme-neutral": "0.7.14-canary.g3825554",
136
+ "@astryxdesign/charts": "0.7.14-canary.g7deca33",
137
+ "@astryxdesign/core": "0.7.14-canary.g7deca33",
138
+ "@astryxdesign/lab": "0.7.14-canary.g7deca33",
139
+ "@astryxdesign/theme-neutral": "0.7.14-canary.g7deca33",
140
140
  "@heroicons/react": "^2.2.0",
141
141
  "@stylexjs/stylex": "^0.19.1",
142
142
  "@types/babel__core": "^7.20.5",