@astryxdesign/cli 0.7.10 → 0.7.11-canary.143a5de

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 (104) hide show
  1. package/api/build/blocks/blocks.weights.json +1 -1
  2. package/api/build/build.doc.mjs +1 -1
  3. package/api/build/kit/rank.mjs +21 -4
  4. package/api/build/kit/signals.mjs +9 -3
  5. package/api/build/kit/start.d.mts +19 -0
  6. package/api/build/kit/start.mjs +49 -2
  7. package/api/build/kit/weights.d.mts +12 -0
  8. package/api/build/kit/weights.mjs +52 -16
  9. package/api/build/kit/words.d.mts +1 -0
  10. package/api/build/kit/words.mjs +1 -1
  11. package/api/docs/_adapter.mjs +2 -1
  12. package/api/doctor/_adapter.d.mts +28 -1
  13. package/api/doctor/_adapter.mjs +39 -2
  14. package/api/doctor/doctor.doc.mjs +1 -1
  15. package/api/doctor/doctor.mjs +9 -2
  16. package/api/doctor/theme-checks.d.mts +44 -3
  17. package/api/doctor/theme-checks.mjs +273 -6
  18. package/api/hook/hook.mjs +13 -0
  19. package/api/icon/_adapter.d.mts +3 -2
  20. package/api/icon/_adapter.mjs +8 -2
  21. package/api/icon/_authoring.d.mts +1 -0
  22. package/api/icon/_authoring.mjs +362 -38
  23. package/api/icon/_default-look.d.mts +155 -0
  24. package/api/icon/_default-look.mjs +474 -0
  25. package/api/icon/_records.d.mts +1 -1
  26. package/api/icon/_records.mjs +1 -0
  27. package/api/icon/add/add.mjs +224 -38
  28. package/api/icon/icon.type.d.mts +7 -2
  29. package/api/icon/icon.type.mjs +4 -2
  30. package/api/icon/iconAdd.doc.mjs +2 -2
  31. package/api/icon/iconNewDefinition.doc.mjs +3 -2
  32. package/api/icon/iconNewSet.doc.mjs +4 -4
  33. package/api/icon/search/search.mjs +10 -9
  34. package/api/integration/add-helpers.d.mts +2 -1
  35. package/api/integration/add-helpers.mjs +5 -2
  36. package/api/integration/authoring-checks.d.mts +0 -2
  37. package/api/integration/authoring-checks.mjs +1 -6
  38. package/api/integration/pack-check.d.mts +8 -6
  39. package/api/integration/pack-check.mjs +16 -6
  40. package/api/logger.mjs +2 -1
  41. package/api/render/_adapter.mjs +47 -1
  42. package/api/render/render.doc.mjs +2 -1
  43. package/api/search/_gather-components.mjs +2 -1
  44. package/api/swizzle/copy/copy.mjs +5 -1
  45. package/api/theme/build/build.mjs +15 -4
  46. package/assets/docs/author-a-theme.doc.mjs +2 -0
  47. package/assets/docs/getting-started.doc.mjs +20 -0
  48. package/assets/docs/tree/building-blocks.doc.mjs +1 -0
  49. package/assets/docs/tree/global-integrations.doc.mjs +1 -0
  50. package/assets/docs/tree/help.doc.mjs +1 -1
  51. package/assets/docs/tree/icon-sets.doc.mjs +9 -3
  52. package/assets/docs/tree/quick-start.doc.mjs +1 -0
  53. package/assets/docs/tree/render-pages.doc.mjs +1 -1
  54. package/assets/docs/tree/ship.doc.mjs +1 -1
  55. package/assets/docs/tree/tokens-color.doc.mjs +2 -2
  56. package/assets/templates/blocks/components/Table/TableLeadingMarkSelection.doc.mjs +15 -0
  57. package/assets/templates/blocks/components/Table/TableLeadingMarkSelection.tsx +134 -0
  58. package/assets/templates/pages/theme-showcase/page.tsx +724 -792
  59. package/assets/templates/pages/theme-showcase/template.doc.mjs +4 -5
  60. package/authoring/doctypes/_schema.d.mts +1 -1
  61. package/clients/cli/commands/build.doc.mjs +3 -2
  62. package/clients/cli/commands/build.mjs +34 -5
  63. package/clients/cli/commands/experimental/icon.mjs +31 -10
  64. package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
  65. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +2 -1
  66. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +2 -2
  67. package/clients/cli/index.mjs +36 -7
  68. package/foundation/discovery/authoring-self-docs.mjs +8 -3
  69. package/foundation/discovery/cli-self-docs.mjs +2 -1
  70. package/foundation/discovery/component-discovery.mjs +16 -0
  71. package/foundation/discovery/doc-types.mjs +9 -2
  72. package/foundation/discovery/docs-discovery.mjs +6 -4
  73. package/foundation/discovery/icon-definition-discovery.mjs +3 -3
  74. package/foundation/discovery/icon-ranking.d.mts +27 -3
  75. package/foundation/discovery/icon-ranking.mjs +125 -8
  76. package/foundation/discovery/icon-set-checks.mjs +40 -20
  77. package/foundation/discovery/icon-set-writer.d.mts +210 -16
  78. package/foundation/discovery/icon-set-writer.mjs +619 -79
  79. package/foundation/discovery/module-exports.d.mts +92 -4
  80. package/foundation/discovery/module-exports.mjs +410 -61
  81. package/foundation/discovery/template-adapter.mjs +5 -7
  82. package/foundation/discovery/theme-discovery.mjs +8 -10
  83. package/foundation/doc-compiler/tree.mjs +2 -2
  84. package/foundation/env/package-manager.d.mts +12 -4
  85. package/foundation/env/package-manager.mjs +15 -6
  86. package/foundation/env/semver.mjs +41 -9
  87. package/foundation/fs/listing-cache.d.mts +3 -1
  88. package/foundation/fs/listing-cache.mjs +63 -11
  89. package/foundation/fs/paths.mjs +2 -1
  90. package/foundation/release/notices.d.mts +16 -0
  91. package/foundation/release/notices.mjs +27 -6
  92. package/foundation/render/embedded-imports.d.mts +7 -0
  93. package/foundation/render/embedded-imports.mjs +1 -1
  94. package/foundation/render/page-worker.mjs +109 -4
  95. package/foundation/render/render-page.d.mts +16 -1
  96. package/foundation/render/render-page.mjs +25 -18
  97. package/foundation/render/served-packages.d.mts +33 -0
  98. package/foundation/render/served-packages.mjs +75 -0
  99. package/foundation/render/single-copy-hooks.d.mts +18 -0
  100. package/foundation/render/single-copy-hooks.mjs +44 -0
  101. package/foundation/text/shell-arg.d.mts +14 -0
  102. package/foundation/text/shell-arg.mjs +17 -0
  103. package/foundation/text/string-utils.mjs +25 -25
  104. package/package.json +6 -6
@@ -6,7 +6,8 @@ export const doc = {
6
6
  name: 'Theme Showcase',
7
7
  displayName: 'Theme Showcase',
8
8
  description:
9
- 'Several unrelated product surfaces rendered together on one canvas so a token change can be judged across contexts at once. A comparison harness rather than a layout to ship.',
9
+ 'Multi-surface comparison shell: preview palettes, typography, icons and control states across a storefront, checkout, chat and inventory on one responsive canvas. A theme preview and design-system showcase, with an embeddable content view for an existing app shell.',
10
+ category: 'Shell - Top Nav',
10
11
  keywords: [
11
12
  'theme',
12
13
  'tokens',
@@ -16,10 +17,8 @@ export const doc = {
16
17
  'design system preview',
17
18
  ],
18
19
  isReady: true,
19
- // Surfaced via the Themes page "Open in Playground" action, not the
20
- // Templates gallery, so keep it out of the overview + playground menu.
21
- // No `category` — it's hidden from the overview gallery (the only consumer
22
- // of `category`), and 'Showcase' isn't part of the TemplateCategory taxonomy.
20
+ // The standalone entry demonstrates an application shell; the named preview
21
+ // composes into its host without nesting AppShell. Keep it out of the gallery.
23
22
  isHiddenFromOverview: true,
24
23
  icons: {
25
24
  Banknote: 'money',
@@ -510,9 +510,9 @@ export const CommandDocKindSchema: z.ZodObject<{
510
510
  when: z.ZodString;
511
511
  }, z.core.$loose>>>;
512
512
  outsideProject: z.ZodOptional<z.ZodEnum<{
513
+ own: "own";
513
514
  same: "same";
514
515
  refuse: "refuse";
515
- own: "own";
516
516
  }>>;
517
517
  related: z.ZodOptional<z.ZodArray<z.ZodString>>;
518
518
  notes: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -26,8 +26,9 @@ export const doc = {
26
26
  {
27
27
  flag: '--type <domain>',
28
28
  param: 'options.type',
29
- choices: ['component', 'hook', 'template'],
30
- description: 'Filter the kit to one domain (component|hook|template)',
29
+ choices: ['component', 'hook', 'doc', 'template', 'theme'],
30
+ description:
31
+ 'Filter the kit to one domain (component|hook|doc|template|theme); doc and theme give an empty kit',
31
32
  },
32
33
  {
33
34
  flag: '--limit <n>',
@@ -66,6 +66,24 @@ function printPlaybook(playbook) {
66
66
  );
67
67
  }
68
68
 
69
+ /** The domains search finds that a build kit has no group for. */
70
+ const SEARCH_ONLY_TYPES = ['doc', 'theme'];
71
+
72
+ /**
73
+ * In text mode, say once on stderr that a kit has no docs or themes and name
74
+ * the search that finds them, as other command notes do (`search`,
75
+ * `integration pack --check`). Stdout, the JSON envelope and the exit status
76
+ * stay as they are.
77
+ * @param {string | undefined} type
78
+ * @param {boolean} json
79
+ */
80
+ function pointToSearch(type, json) {
81
+ if (json || !type || !SEARCH_ONLY_TYPES.includes(type)) return;
82
+ console.error(
83
+ `Note: a build kit has no ${type}s. Find them with \`${formatCliCommand(`search <query> --type ${type}`)}\`.`,
84
+ );
85
+ }
86
+
69
87
  /**
70
88
  * @param {import('commander').Command} program
71
89
  */
@@ -89,6 +107,7 @@ export function registerBuild(program) {
89
107
  // one. Counting it as a result keeps "what did this run answer with"
90
108
  // true for the no-argument form too.
91
109
  const playbook = resultSet({count: 1, resultKind: 'doc'});
110
+ pointToSearch(options.type, json);
92
111
  if (json) {
93
112
  jsonOut(result);
94
113
  return playbook;
@@ -101,8 +120,7 @@ export function registerBuild(program) {
101
120
  // Parse --limit to a number; the API validates it (positive integer) and
102
121
  // throws ERR_INVALID_ARGUMENT, so we pass NaN through rather than
103
122
  // pre-rejecting with a generic code here (parity with `search`).
104
- const limit =
105
- options.limit != null ? Number(options.limit) : 60;
123
+ const limit = options.limit != null ? Number(options.limit) : 60;
106
124
 
107
125
  /** @type {import('../../../api/build/build.type.mjs').BuildKitResponse} */
108
126
  let result;
@@ -151,6 +169,7 @@ export function registerBuild(program) {
151
169
  jsonOut(result);
152
170
  return answered;
153
171
  }
172
+ pointToSearch(options.type, json);
154
173
 
155
174
  if (!hasResults && !start) {
156
175
  emit(
@@ -227,7 +246,13 @@ export function registerBuild(program) {
227
246
  start,
228
247
  verbose
229
248
  ? {
230
- fields: ['name', 'package', 'displayName', 'description', 'command'],
249
+ fields: [
250
+ 'name',
251
+ 'package',
252
+ 'displayName',
253
+ 'description',
254
+ 'command',
255
+ ],
231
256
  format: {command: formatCliCommand},
232
257
  }
233
258
  : brief(['name', 'package', 'description', 'command']),
@@ -242,7 +267,9 @@ export function registerBuild(program) {
242
267
  ),
243
268
  records(
244
269
  start.alternatives,
245
- verbose ? full : brief(['name', 'package', 'description', 'command']),
270
+ verbose
271
+ ? full
272
+ : brief(['name', 'package', 'description', 'command']),
246
273
  ),
247
274
  );
248
275
  }
@@ -283,7 +310,9 @@ export function registerBuild(program) {
283
310
  ? [
284
311
  records(
285
312
  shown(domain),
286
- verbose ? full : brief(['name', 'package', 'deprecated', 'description']),
313
+ verbose
314
+ ? full
315
+ : brief(['name', 'package', 'deprecated', 'description']),
287
316
  ),
288
317
  ]
289
318
  : []),
@@ -20,6 +20,7 @@ import {
20
20
  getCliInvocation,
21
21
  } from '../../../../foundation/env/package-manager.mjs';
22
22
  import {jsonOut} from '../../../../foundation/response/json.mjs';
23
+ import {logger} from '../../../../api/logger.mjs';
23
24
  import {resultSet} from '../../../../foundation/debug/index.mjs';
24
25
  import {
25
26
  emit,
@@ -140,7 +141,7 @@ export function registerExperimentalIcon(group, program) {
140
141
  ),
141
142
  ),
142
143
  text(
143
- `Built-in definitions are the ones every set maps. Map one: ${run} experimental icon map <definition> <icon id>`,
144
+ `Built-in definitions are the ones every set maps. Map one: ${run} experimental icon map <definition> <icon id> --set <set>`,
144
145
  ),
145
146
  );
146
147
  return answered;
@@ -157,7 +158,9 @@ export function registerExperimentalIcon(group, program) {
157
158
  `${each.id}: ${each.words.join(', ')}${each.definitions.length > 0 ? ` = ${each.definitions.join(', ')}` : ''}`,
158
159
  ),
159
160
  ),
160
- text(`Map one: ${run} experimental icon map <definition> <id>`),
161
+ text(
162
+ `Map one: ${run} experimental icon map <definition> <id> --set ${set}`,
163
+ ),
161
164
  );
162
165
  return answered;
163
166
  }
@@ -308,6 +311,9 @@ export function registerExperimentalIcon(group, program) {
308
311
  * @param {(result: any) => void} print
309
312
  */
310
313
  const run = async (call, print) => {
314
+ // Reading a large library reports its progress through the shared
315
+ // logger: on stderr in text mode, never under --json.
316
+ logger.setSilent(Boolean(program.opts().json));
311
317
  let result;
312
318
  try {
313
319
  result = await call();
@@ -436,7 +442,7 @@ export function registerExperimentalIcon(group, program) {
436
442
  return;
437
443
  }
438
444
  if (result.type === 'icon.definitionMatches') {
439
- const {matches, newDefinition} = result.data;
445
+ const {matches, newDefinition, variant} = result.data;
440
446
  emit(
441
447
  section(
442
448
  `Icon definitions for ${result.data.export} (${matches.length})`,
@@ -466,6 +472,13 @@ export function registerExperimentalIcon(group, program) {
466
472
  ),
467
473
  ]
468
474
  : []),
475
+ ...(variant
476
+ ? [
477
+ text(
478
+ `The set already has this glyph in another look. Add this one as its variant: ${formatCliCommand(variant)}`,
479
+ ),
480
+ ]
481
+ : []),
469
482
  text(
470
483
  `All icon definitions: ${cli} docs cli/experimental/icon-definitions`,
471
484
  ),
@@ -500,17 +513,25 @@ export function registerExperimentalIcon(group, program) {
500
513
  const {root, manifest, files, written, dryRun} = data;
501
514
  const state = dryRun ? 'plan' : written ? 'ok' : 'unchanged';
502
515
  const refreshed = data.refreshed === true;
516
+ const updated = data.updated === true;
517
+ const What = `${what[0].toUpperCase()}${what.slice(1)}`;
503
518
  emit(
504
519
  section(
505
520
  refreshed
506
521
  ? dryRun
507
522
  ? `Refresh ${what} plan`
508
- : `${what[0].toUpperCase()}${what.slice(1)} refreshed`
509
- : dryRun
510
- ? `New ${what} plan`
511
- : written
512
- ? `New ${what} added`
513
- : `New ${what} unchanged`,
523
+ : `${What} refreshed`
524
+ : updated
525
+ ? dryRun
526
+ ? `${What} update plan`
527
+ : written && files.length > 0
528
+ ? `${What} updated`
529
+ : `${What} unchanged`
530
+ : dryRun
531
+ ? `New ${what} plan`
532
+ : written
533
+ ? `New ${what} added`
534
+ : `New ${what} unchanged`,
514
535
  ),
515
536
  text(`[${state}] ${data.name}`),
516
537
  // What the command did (or, in a dry run, would do): never a step
@@ -542,7 +563,7 @@ export function registerExperimentalIcon(group, program) {
542
563
  list(
543
564
  data.suggestions.map(
544
565
  each =>
545
- `${each.definition} -> ${each.icon} (${each.word}): ${formatCliCommand(`astryx experimental icon map ${each.definition} ${each.icon}`)}`,
566
+ `${each.definition} -> ${each.icon} (${each.word}): ${formatCliCommand(`astryx experimental icon map ${each.definition} ${each.icon} --set ${data.name}`)}`,
546
567
  ),
547
568
  ),
548
569
  ]
@@ -30,7 +30,7 @@ export const doc = {
30
30
  flag: '--new-definition <name>',
31
31
  param: 'options.newDefinition',
32
32
  description:
33
- "Add your set's own definition, then map the icon to it; needs --description and --words",
33
+ "Add your set's own definition, named in camelCase (aiHelper) or kebab-case (ai-helper), then map the icon to it; needs --description and --words",
34
34
  },
35
35
  {
36
36
  flag: '--description <text>',
@@ -18,7 +18,8 @@ export const doc = {
18
18
  name: 'name',
19
19
  param: 'name',
20
20
  required: true,
21
- description: 'The definition name, in camelCase (rocketLaunch)',
21
+ description:
22
+ 'The definition name, in camelCase (rocketLaunch) or kebab-case (rocket-launch)',
22
23
  },
23
24
  ],
24
25
  options: [
@@ -11,7 +11,7 @@ export const doc = {
11
11
  stability: 'experimental',
12
12
  summary: 'Start an icon set in your integration package',
13
13
  description:
14
- "Run inside an integration package. Writes the set's folder with its descriptor, its data file, and its generated module, and declares the manifest's `experimental.iconSets` root on first use. With --from it wraps every icon component of a library, records the library and its version as the set's source, copies its license notice, and maps each Astryx icon definition whose name is an icon's id; definitions an icon only shares a word with are listed as suggestions, never written. Run it again to refresh. --variants and --default-variant declare the set's variants. Experimental: it may change or be removed in a patch release.",
14
+ "Run inside an integration package. Writes the set's folder with its descriptor, its data file, and its generated module, and declares the manifest's `experimental.iconSets` root on first use. With --from it wraps every icon component of a library, records the library and its version as the set's source, copies its license notice, and maps each Astryx icon definition whose name is an icon's id; definitions an icon only shares a word with are listed as suggestions, never written. A library whose export names end in looks (XOutline24WGHT500Icon) gives one icon per glyph, by its glyph id (x), in the look the default variant names, else the library's usual default. Run it again with --from to refresh. --variants and --default-variant declare the set's variants; over an existing set without --from, they, --display-name and --description update the set in place and leave its icons as they are; a set with icons changes its default variant only with --from, and only in a library whose export names encode looks. Experimental: it may change or be removed in a patch release.",
15
15
  fn: 'iconNewSet',
16
16
  args: [
17
17
  {
@@ -49,7 +49,7 @@ export const doc = {
49
49
  flag: '--default-variant <variant>',
50
50
  param: 'options.defaultVariant',
51
51
  description:
52
- "With --variants: the variant each icon's own export draws (the first variant when omitted)",
52
+ "With --variants: the variant each icon's own export draws. When omitted: in a library whose export names encode looks, the look the icons draw (the library's usual default for a new set), which --variants must list; otherwise the set's current default, which --variants must list when the set has icons, else, on a set without icons, the first variant. A set with icons changes it only with --from, and only in a library whose export names encode looks",
53
53
  },
54
54
  {
55
55
  flag: '--display-name <text>',
@@ -22,7 +22,8 @@ import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
22
22
  import {findConfigPath} from '../../foundation/config/config-path.mjs';
23
23
  import {API_VERSION, setJsonMode} from '../../foundation/response/json.mjs';
24
24
  import {answeredBy, runChoice} from '../../foundation/release/run-context.mjs';
25
- import {cliInstallAdvice, installFolder} from '../../foundation/release/notices.mjs';
25
+ import {cliInstallAdvice, installFolder, projectRelease, SETUP_REMINDER_KEY, takeNotice} from '../../foundation/release/notices.mjs';
26
+ import {isCi} from '../../foundation/release/update-notice-env.mjs';
26
27
  import {buildManifest} from './lib/manifest.mjs';
27
28
  import {cliError} from './lib/cli-error.mjs';
28
29
  import {section, text, records} from './formatters/index.mjs';
@@ -683,8 +684,11 @@ export async function createProgram({argv} = {}) {
683
684
  * repository root — see isAstryxPromptInReach), remind the user/agent that
684
685
  * setup is missing.
685
686
  *
686
- * Uses `preAction` (not postAction) so it fires for EVERY valid command — even
687
- * ones whose action errors or calls process.exit (postAction is skipped then).
687
+ * `preAction` decides the line; `postAction` prints it after a command that
688
+ * succeeds, at most once a day per project, recorded in the per-user state
689
+ * as the daily hint is, and never under CI. An agent that leaves `init` to
690
+ * its person then sees it once, not before every command. Doctor reports
691
+ * the missing setup in its own check every time.
688
692
  *
689
693
  * Suppressed in --json: that is machine output with a strict clean stdout+stderr
690
694
  * contract (json-shim.test: "error envelopes have empty stderr"), and --json
@@ -695,8 +699,29 @@ export async function createProgram({argv} = {}) {
695
699
  * or one that neither installs nor declares Astryx), and inside the CLI's own
696
700
  * source checkout when it runs from there.
697
701
  */
702
+ /** @type {{root: string, line: string} | null} */
703
+ let setupReminder = null;
704
+ /**
705
+ * Keep the reminder for `root` until the command ends.
706
+ * @param {string} root
707
+ * @param {string} line
708
+ */
709
+ const remindSetup = (root, line) => {
710
+ setupReminder = {root, line};
711
+ };
712
+ program.hook('postAction', () => {
713
+ try {
714
+ const reminder = setupReminder;
715
+ setupReminder = null;
716
+ if (reminder == null || process.exitCode || isCi(process.env)) return;
717
+ if (takeNotice(`${SETUP_REMINDER_KEY}${reminder.root}`)) console.error(reminder.line);
718
+ } catch {
719
+ // Never let the nudge break a command.
720
+ }
721
+ });
698
722
  program.hook('preAction', (thisCommand, actionCommand) => {
699
723
  try {
724
+ setupReminder = null;
700
725
  if (program.opts().json) return; // machine mode — keep --json output clean
701
726
  if (SETUP_NUDGE_EXEMPT.has(actionCommand.name())) return;
702
727
  const cwd = process.cwd();
@@ -738,9 +763,12 @@ export async function createProgram({argv} = {}) {
738
763
  // before it, so the command is the picker's for that folder, never the
739
764
  // bare `astryx` name a package runner would fetch from the registry
740
765
  // (spec AST-081 FR5).
766
+ // The command names the project's release, as run from its folder,
767
+ // never the Core this folder installs for itself.
741
768
  if (target.moved) {
742
- console.error(
743
- setupNudge(getCliInvocation(target.dir), {before: `cd ${quoteCommandArgument(target.dir)}`}).trimEnd(),
769
+ remindSetup(
770
+ target.dir,
771
+ setupNudge(getCliInvocation(target.dir, {release: projectRelease(target.dir)}), {before: `cd ${quoteCommandArgument(target.dir)}`}).trimEnd(),
744
772
  );
745
773
  return;
746
774
  }
@@ -750,13 +778,14 @@ export async function createProgram({argv} = {}) {
750
778
  // version, then run that CLI's init.
751
779
  const add = cliInstallAdvice({cwd, core: choice.coreVersion});
752
780
  if (add?.command) {
753
- console.error(
781
+ remindSetup(
782
+ add.root,
754
783
  setupNudge(getCliInvocation(add.root, {installed: true}), {before: add.command}).trimEnd(),
755
784
  );
756
785
  return;
757
786
  }
758
787
  }
759
- console.error(setupNudge(getCliInvocation(cwd)).trimEnd());
788
+ remindSetup(agentDocsTargetDir(cwd), setupNudge(getCliInvocation(cwd)).trimEnd());
760
789
  } catch {
761
790
  // Never let the nudge break a command.
762
791
  }
@@ -15,9 +15,9 @@
15
15
  * the self-doc tests fail.
16
16
  */
17
17
 
18
- import * as fs from 'node:fs';
19
18
  import * as path from 'node:path';
20
19
  import {CLI_ROOT} from '../fs/paths.mjs';
20
+ import {listDirEntries} from '../fs/listing-cache.mjs';
21
21
  import {readDocView} from '../doc-compiler/read.mjs';
22
22
  import {
23
23
  DOC_OUTPUT_BUDGET_BYTES,
@@ -75,7 +75,7 @@ export function discoverAuthoringSelfDocSources(root = AUTHORING_ROOT) {
75
75
  const found = [];
76
76
  /** @param {string} dir */
77
77
  const walk = dir => {
78
- for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
78
+ for (const entry of listDirEntries(dir)) {
79
79
  if (entry.name === 'node_modules' || entry.name.startsWith('__'))
80
80
  continue;
81
81
  const full = path.join(dir, entry.name);
@@ -229,7 +229,12 @@ export function buildAuthoringReferenceDoc(docs) {
229
229
  placement: {parent: 'namespace:authoring', slot: 'reference', order: 10},
230
230
  title: 'Field reference',
231
231
  category: 'guide',
232
- keywords: ['authoring reference', 'field reference', 'every field'],
232
+ keywords: [
233
+ 'authoring',
234
+ 'authoring reference',
235
+ 'field reference',
236
+ 'every field',
237
+ ],
233
238
  description:
234
239
  'Every file an integration author writes, field by field: the integration manifest, astryx.config, codemods, identity, and each doc type. The guides that use them are the rest of {@link namespace:authoring}.',
235
240
  sections: docs
@@ -18,6 +18,7 @@
18
18
  import * as fs from 'node:fs';
19
19
  import * as path from 'node:path';
20
20
  import {CLI_ROOT} from '../fs/paths.mjs';
21
+ import {listDirEntries} from '../fs/listing-cache.mjs';
21
22
  import {readDocView} from '../doc-compiler/read.mjs';
22
23
  import {AUTHORING_SELF_DOCS, selfDocSection} from './authoring-self-docs.mjs';
23
24
  import {
@@ -66,7 +67,7 @@ export function discoverCliSelfDocSources(root = CLI_ROOT) {
66
67
  /** @param {string} dir */
67
68
  const walk = dir => {
68
69
  if (!fs.existsSync(dir)) return;
69
- for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
70
+ for (const entry of listDirEntries(dir)) {
70
71
  if (
71
72
  entry.name === 'node_modules' ||
72
73
  entry.name.startsWith('__') ||
@@ -381,6 +381,22 @@ export function familyMember(docs, name) {
381
381
  * @returns {Record<string, string[]>}
382
382
  */
383
383
  export function discoverComponents(coreDir) {
384
+ // The component matcher calls this for each name it resolves, so one
385
+ // operation reads the docs once. Each caller gets its own copy to change.
386
+ const found = oncePerListing(`components\0${coreDir}`, () =>
387
+ readComponentGroups(coreDir),
388
+ );
389
+ return Object.fromEntries(
390
+ Object.entries(found).map(([key, names]) => [key, [...names]]),
391
+ );
392
+ }
393
+
394
+ /**
395
+ * The component groups under `coreDir`, read from disk.
396
+ * @param {string} coreDir
397
+ * @returns {Record<string, string[]>}
398
+ */
399
+ function readComponentGroups(coreDir) {
384
400
  const srcDir = path.join(coreDir, 'src');
385
401
  /** @type {Map<string, string|null>} componentName → group */
386
402
  const componentGroups = new Map();
@@ -27,7 +27,8 @@
27
27
  * none), and a `<topic>.doc.<lang>.mjs` overlay against
28
28
  * `ReferenceTranslationDoc`;
29
29
  * - themes root: `ThemeDoc`;
30
- * - iconSets root: `IconSetDoc`.
30
+ * - iconSets root: `IconSetDoc`, and a set's own definition (stamped
31
+ * `type: 'icon-definition'`) `IconDefinitionDoc`.
31
32
  * Every finding is a warning, names the field, and says how to fix it.
32
33
  *
33
34
  * @input Doc files with the root each was found in, the package root, and the
@@ -312,7 +313,13 @@ function expectedType(ts, root, exportName, node, core = false) {
312
313
  return {typeExpr: authoring('ThemeDoc'), typeName: 'ThemeDoc'};
313
314
  }
314
315
  if (root === 'icon-sets') {
315
- return {typeExpr: authoring('IconSetDoc'), typeName: 'IconSetDoc'};
316
+ // A set's own definitions live in its folder too.
317
+ return shape?.stamp === 'icon-definition'
318
+ ? {
319
+ typeExpr: authoring('IconDefinitionDoc'),
320
+ typeName: 'IconDefinitionDoc',
321
+ }
322
+ : {typeExpr: authoring('IconSetDoc'), typeName: 'IconSetDoc'};
316
323
  }
317
324
  if (translation) {
318
325
  return {
@@ -32,6 +32,7 @@
32
32
  import * as fs from 'node:fs';
33
33
  import * as path from 'node:path';
34
34
  import {CLI_ROOT} from '../fs/paths.mjs';
35
+ import {listDir, listDirEntries} from '../fs/listing-cache.mjs';
35
36
  import {importDocModule} from '../doc-compiler/import.mjs';
36
37
  import {CLI_PROVIDER_ID} from '../identity/providers.mjs';
37
38
  import {parseReadableDoc} from '../doc-compiler/parse-readable.mjs';
@@ -135,7 +136,7 @@ export function discoverBuiltinTopics() {
135
136
  /** @type {Record<string, string>} */
136
137
  const topics = Object.create(null);
137
138
  if (!fs.existsSync(BUILTIN_DOCS_DIR)) return topics;
138
- for (const file of fs.readdirSync(BUILTIN_DOCS_DIR)) {
139
+ for (const file of listDir(BUILTIN_DOCS_DIR)) {
139
140
  const match = file.match(BUILTIN_TOPIC_FILE_RE);
140
141
  if (match) topics[match[1]] = path.join(BUILTIN_DOCS_DIR, file);
141
142
  }
@@ -152,7 +153,7 @@ export function builtinGuideFiles() {
152
153
  const files = Object.values(discoverBuiltinTopics());
153
154
  const tree = path.join(BUILTIN_DOCS_DIR, 'tree');
154
155
  if (fs.existsSync(tree)) {
155
- for (const file of fs.readdirSync(tree).sort()) {
156
+ for (const file of listDir(tree).sort()) {
156
157
  if (BUILTIN_TOPIC_FILE_RE.test(file)) files.push(path.join(tree, file));
157
158
  }
158
159
  }
@@ -524,7 +525,7 @@ export async function discoverIntegrationDocs(integration) {
524
525
  const files = [];
525
526
  /** @param {string} dirPath */
526
527
  function scanDir(dirPath) {
527
- for (const entry of fs.readdirSync(dirPath, {withFileTypes: true})) {
528
+ for (const entry of listDirEntries(dirPath)) {
528
529
  if (entry.name === 'node_modules' || entry.name === '__tests__') continue;
529
530
  const full = path.join(dirPath, entry.name);
530
531
  if (entry.isDirectory()) {
@@ -737,7 +738,8 @@ export function mergeTopicReport(base, overlay) {
737
738
  // It also keeps the place an earlier `after` gave the one it replaces,
738
739
  // so sections placed after that key later still follow it.
739
740
  if (replaced[PLACED_AFTER] != null) {
740
- const placed = replacing === section ? withoutPosition({...section}) : replacing;
741
+ const placed =
742
+ replacing === section ? withoutPosition({...section}) : replacing;
741
743
  for (const symbol of Object.getOwnPropertySymbols(section)) {
742
744
  if (!(symbol in placed)) {
743
745
  Object.defineProperty(
@@ -15,10 +15,10 @@
15
15
  * surface reads
16
16
  */
17
17
 
18
- import * as fs from 'node:fs';
19
18
  import * as path from 'node:path';
20
19
  import {parseIconDefinition} from '../../authoring/doctypes/icon-definition/parse.mjs';
21
20
  import {CLI_ROOT} from '../fs/paths.mjs';
21
+ import {listDirEntries} from '../fs/listing-cache.mjs';
22
22
  import {readStaticDescriptorValue} from './theme-discovery.mjs';
23
23
 
24
24
  /** @typedef {import('../../authoring/doctypes/icon-definition/type').IconDefinitionDoc} IconDefinitionDoc */
@@ -53,10 +53,10 @@ export function readDefinitionsDir(dir, owner) {
53
53
  const definitions = [];
54
54
  /** @type {Array<{file: string, message: string}>} */
55
55
  const errors = [];
56
- /** @type {fs.Dirent[]} */
56
+ /** @type {import('node:fs').Dirent[]} */
57
57
  let entries;
58
58
  try {
59
- entries = fs.readdirSync(dir, {withFileTypes: true});
59
+ entries = listDirEntries(dir);
60
60
  } catch {
61
61
  return {definitions, errors};
62
62
  }
@@ -30,7 +30,9 @@ export function iconRecord(set: DiscoveredIconSet, icon: IconSetIcon, definition
30
30
  * @property {boolean} meaning the query is one of the icon's tags (never
31
31
  * both: a tag is a word that is not the id or one of its parts)
32
32
  * @property {number} rank within-tier key, lower first: for a name match 0
33
- * (whole id) or 1 (an id part); for a meaning match the tag's position
33
+ * (whole id), 1 (the whole id's plural or singular), 2 (an id part), or 3
34
+ * (an id part's plural or singular); for a meaning match the tag's
35
+ * position
34
36
  * @property {string} reason
35
37
  */
36
38
  /**
@@ -41,6 +43,24 @@ export function iconRecord(set: DiscoveredIconSet, icon: IconSetIcon, definition
41
43
  * @returns {IconMatch | null}
42
44
  */
43
45
  export function matchIcon(query: string, icon: IconSetIcon, definitions?: string[]): IconMatch | null;
46
+ /**
47
+ * The query without the words that only phrase it, when it has several
48
+ * words and some word names something; else the query as typed.
49
+ * @param {string} query
50
+ */
51
+ export function iconQuery(query: string): string;
52
+ /**
53
+ * The matches that answer a query: the whole-word ones (a definition or an
54
+ * exact match, 80 and up) when there are any, else word starts (60) when
55
+ * there are any, else partial matches. A longer word that only starts with
56
+ * the query (`start` for `star`) never stands beside a whole-word answer.
57
+ * @template {{score: number}} T
58
+ * @param {T[]} ranked best first
59
+ * @returns {T[]}
60
+ */
61
+ export function answeringMatches<T extends {
62
+ score: number;
63
+ }>(ranked: T[]): T[];
44
64
  /**
45
65
  * Which exact reading leads for a set of matches: meaning, unless more icons
46
66
  * carry the query as a name than as a tag.
@@ -78,7 +98,9 @@ export function withDefinitionWords(icon: IconSetIcon, definitions: string[], lo
78
98
  words: string[];
79
99
  } | undefined): IconSetIcon;
80
100
  /**
81
- * Every icon in `sets` that answers the query, ranked (FR6).
101
+ * Every icon in `sets` that answers the query, ranked. The query is
102
+ * scored as typed; when nothing answers it with a whole word (80 and up),
103
+ * it is scored again without its filler words ({@link iconQuery}).
82
104
  * @param {DiscoveredIconSet[]} sets in tie order
83
105
  * @param {string} query
84
106
  * @returns {IconMatchEntry[]}
@@ -106,7 +128,9 @@ export type IconMatch = {
106
128
  meaning: boolean;
107
129
  /**
108
130
  * within-tier key, lower first: for a name match 0
109
- * (whole id) or 1 (an id part); for a meaning match the tag's position
131
+ * (whole id), 1 (the whole id's plural or singular), 2 (an id part), or 3
132
+ * (an id part's plural or singular); for a meaning match the tag's
133
+ * position
110
134
  */
111
135
  rank: number;
112
136
  reason: string;