@astryxdesign/cli 0.7.15 → 0.7.16-canary.g8514aae

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 (116) hide show
  1. package/README.md +5 -3
  2. package/api/component/_adapter.d.mts +1 -1
  3. package/api/component/_adapter.mjs +28 -1
  4. package/api/doctor/_adapter.d.mts +17 -0
  5. package/api/doctor/_adapter.mjs +35 -0
  6. package/api/doctor/doctor.mjs +18 -4
  7. package/api/integration/validate-integration.mjs +1 -1
  8. package/api/theme/_adapter.d.mts +5 -2
  9. package/api/theme/_adapter.mjs +43 -12
  10. package/api/theme/build/build.d.mts +1 -21
  11. package/api/theme/build/build.mjs +149 -37
  12. package/api/theme/eject/eject.mjs +22 -1
  13. package/api/theme/template/template.d.mts +19 -0
  14. package/api/theme/template/template.mjs +91 -19
  15. package/api/theme/theme.type.d.mts +5 -1
  16. package/api/theme/theme.type.mjs +2 -1
  17. package/api/theme/themeBuild.doc.mjs +3 -3
  18. package/api/theme/themeEject.doc.mjs +1 -1
  19. package/api/theme/themeTemplate.doc.mjs +9 -3
  20. package/api/theme-edit/_adapter.d.mts +21 -0
  21. package/api/theme-edit/_adapter.mjs +176 -22
  22. package/api/theme-edit/_check.d.mts +7 -0
  23. package/api/theme-edit/_check.mjs +1050 -173
  24. package/api/theme-edit/_color.d.mts +2 -8
  25. package/api/theme-edit/_color.mjs +292 -219
  26. package/api/theme-edit/_compiler.d.mts +1 -0
  27. package/api/theme-edit/_compiler.mjs +20 -1
  28. package/api/theme-edit/_context.d.mts +21 -0
  29. package/api/theme-edit/_context.mjs +235 -12
  30. package/api/theme-edit/_css.d.mts +50 -1
  31. package/api/theme-edit/_css.mjs +310 -28
  32. package/api/theme-edit/_edit.d.mts +9 -0
  33. package/api/theme-edit/_edit.mjs +907 -123
  34. package/api/theme-edit/_how-commands.d.mts +11 -26
  35. package/api/theme-edit/_how-commands.mjs +30 -2
  36. package/api/theme-edit/_how-question.d.mts +7 -0
  37. package/api/theme-edit/_how-question.mjs +1304 -176
  38. package/api/theme-edit/_how.mjs +144 -30
  39. package/api/theme-edit/_palette.d.mts +6 -0
  40. package/api/theme-edit/_palette.mjs +164 -62
  41. package/api/theme-edit/_parts.d.mts +16 -0
  42. package/api/theme-edit/_parts.mjs +49 -1
  43. package/api/theme-edit/_png.mjs +19 -14
  44. package/api/theme-edit/_preview-app.mjs +514 -27
  45. package/api/theme-edit/_preview.d.mts +11 -0
  46. package/api/theme-edit/_preview.mjs +245 -24
  47. package/api/theme-edit/_project.d.mts +11 -0
  48. package/api/theme-edit/_project.mjs +35 -9
  49. package/api/theme-edit/_settings.d.mts +122 -5
  50. package/api/theme-edit/_settings.mjs +1363 -71
  51. package/api/theme-edit/_tables.d.mts +19 -0
  52. package/api/theme-edit/_tables.mjs +205 -149
  53. package/api/theme-edit/_vet.d.mts +42 -0
  54. package/api/theme-edit/_vet.mjs +144 -0
  55. package/api/theme-edit/theme-edit.type.d.mts +2 -1
  56. package/api/theme-edit/theme-edit.type.mjs +1 -1
  57. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  58. package/api/theme-edit/themeEditShow.doc.mjs +11 -3
  59. package/assets/docs/tree/single-component.doc.mjs +11 -2
  60. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  61. package/assets/docs.generated.json +2 -2
  62. package/assets/preview-app/next.config.mjs +7 -1
  63. package/assets/preview-app/src/app/globals.css +1 -0
  64. package/assets/self-audit.generated.json +1 -1
  65. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
  66. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
  67. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
  68. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
  69. package/assets/templates/components.generated.json +1 -1
  70. package/authoring/doctypes/_schema.d.mts +52 -5
  71. package/authoring/doctypes/_schema.mjs +62 -7
  72. package/authoring/doctypes/base/type.ts +10 -0
  73. package/authoring/doctypes/component/component.doc.mjs +1 -1
  74. package/authoring/doctypes/function/function.doc.mjs +6 -0
  75. package/authoring/doctypes/function/type.ts +3 -0
  76. package/authoring/doctypes/legacy.mjs +5 -1
  77. package/authoring/index.d.ts +1 -0
  78. package/clients/cli/build-id.generated.json +1 -1
  79. package/clients/cli/commands/doctor.doc.mjs +2 -2
  80. package/clients/cli/commands/experimental/theme.mjs +188 -37
  81. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  82. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
  83. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  84. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  85. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  86. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
  87. package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
  88. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  89. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  90. package/clients/cli/commands/theme-template.doc.mjs +3 -1
  91. package/clients/cli/commands/theme.mjs +89 -6
  92. package/clients/cli/formatters/index.mjs +7 -4
  93. package/clients/cli/lib/cli-error.mjs +9 -3
  94. package/clients/cli/lib/component-format.mjs +27 -9
  95. package/clients/cli/lib/json-shim.mjs +40 -2
  96. package/clients/cli/manifest.generated.json +1 -1
  97. package/foundation/config/project.mjs +50 -14
  98. package/foundation/discovery/theme-discovery.d.mts +5 -1
  99. package/foundation/discovery/theme-discovery.mjs +24 -3
  100. package/foundation/fs/gather-cache.d.mts +9 -2
  101. package/foundation/fs/gather-cache.mjs +36 -10
  102. package/foundation/fs/paths.d.mts +16 -0
  103. package/foundation/fs/paths.mjs +25 -0
  104. package/foundation/render/host-exit.d.mts +8 -0
  105. package/foundation/render/host-exit.mjs +11 -0
  106. package/foundation/render/page-host.mjs +56 -10
  107. package/foundation/render/page-worker.mjs +14 -0
  108. package/foundation/render/render-page.mjs +37 -2
  109. package/foundation/response/error-codes.d.mts +2 -1
  110. package/foundation/response/error-codes.d.ts +1 -0
  111. package/foundation/response/error-codes.doc.mjs +5 -0
  112. package/foundation/response/error-codes.mjs +3 -0
  113. package/foundation/response/json.d.mts +15 -0
  114. package/foundation/response/json.mjs +52 -1
  115. package/foundation/response/response-types.doc.mjs +1 -1
  116. package/package.json +7 -6
@@ -45,9 +45,13 @@ import {
45
45
  } from '../../../../api/theme-edit/theme-edit.mjs';
46
46
  import {
47
47
  builtInThemes,
48
+ dialValueFits,
49
+ newFlagList,
48
50
  editorCompileProblem,
49
51
  editorThemeHold,
50
52
  editorThemeRefusal,
53
+ editorThemeTemplate,
54
+ showSections,
51
55
  } from '../../../../api/theme-edit/_adapter.mjs';
52
56
  import {registerThemeSubcommands} from '../theme.mjs';
53
57
  import {doc as groupDoc} from '../experimental-theme.doc.mjs';
@@ -99,6 +103,8 @@ const cmd = line => {
99
103
  .map(part => part.split(PREFIX).join(stem))
100
104
  .join(stem);
101
105
  };
106
+ /** The project's invocation of a command line (cmd, under a name an action's own `cmd` parameter does not hide). */
107
+ const cliLine = (/** @type {string} */ line) => cmd(line);
102
108
 
103
109
  /**
104
110
  * Print blocks, a blank line between them, with this project's run prefix
@@ -348,29 +354,110 @@ const changeOptions = o => ({
348
354
  * @param {any} o
349
355
  * @returns {Record<string, string | string[]>}
350
356
  */
351
- function newSettings(o) {
357
+ function newSettings(o, themeName = '<theme>') {
352
358
  /** @type {Record<string, string | string[]>} */
353
359
  const out = {};
360
+ // --like given two values is refused like a dial given two.
361
+ const likes = flagValues('like');
362
+ if (new Set(likes).size > 1) {
363
+ // The suggestion keeps the first built-in theme given, or drops --like.
364
+ const like = likes
365
+ .map(l => l.toLowerCase())
366
+ .find(l => builtInThemes().includes(l));
367
+ throw new AstryxError(
368
+ `--like was given twice (${likes.join(', ')}); give it once. Nothing was changed.`,
369
+ [
370
+ {
371
+ name: cmd(`${EDITOR} new ${themeName}${newFlagLine({...o, like})}`),
372
+ reason: like
373
+ ? 'do this instead: the first built-in theme given'
374
+ : 'do this instead: none of them is a built-in theme',
375
+ },
376
+ ],
377
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
378
+ );
379
+ }
354
380
  for (const opt of newDoc.options ?? []) {
355
381
  if (opt.param !== 'options.settings') continue;
356
- const name = opt.flag.split(' ')[0].slice(2);
357
- const value = o[name.replace(/-([a-z])/g, (_, c) => c.toUpperCase())];
382
+ const flag = opt.flag.split(' ')[0].slice(2);
383
+ const key = flag.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
384
+ const value = o[key];
358
385
  if (value == null) continue;
359
386
  // A flag given twice: headings takes one value per axis (a weight and a
360
387
  // tracking); any other flag given two different values is refused.
361
- const all = flagValues(name);
362
- if (name === 'headings' && all.length > 1) out[name] = all;
363
- else if (new Set(all).size > 1)
388
+ const all = flagValues(flag);
389
+ if (flag === 'headings' && all.length > 1) out[flag] = all;
390
+ else if (new Set(all).size > 1) {
391
+ // The suggestion keeps the first value the dial takes, or drops it.
392
+ const fits = all.find(v => dialValueFits(flag, v));
364
393
  throw new AstryxError(
365
- `--${name} was given twice (${all.join(', ')}); give it once. Nothing was changed.`,
366
- [],
394
+ `--${flag} was given twice (${all.join(', ')}); give it once. Nothing was changed.`,
395
+ [
396
+ {
397
+ name: cmd(
398
+ `${EDITOR} new ${themeName}${newFlagLine({...o, [key]: fits})}`,
399
+ ),
400
+ reason: fits
401
+ ? 'do this instead: the first value it takes'
402
+ : `do this instead: none of them is a value --${flag} takes`,
403
+ },
404
+ ],
367
405
  ERROR_CODES.ERR_INVALID_ARGUMENT,
368
406
  );
369
- else out[name] = String(value);
407
+ } else out[flag] = String(value);
370
408
  }
371
409
  return out;
372
410
  }
373
411
 
412
+ /**
413
+ * The options a `new` was given, as flags for a suggested command, so a
414
+ * corrected command makes the theme that was asked for.
415
+ * @param {any} o
416
+ * @returns {string}
417
+ */
418
+ function newFlagLine(o) {
419
+ /** @type {Record<string, string | string[]>} */
420
+ const settings = {};
421
+ for (const opt of newDoc.options ?? []) {
422
+ if (opt.param !== 'options.settings') continue;
423
+ const flag = opt.flag.split(' ')[0].slice(2);
424
+ const value = o[flag.replace(/-([a-z])/g, (_, c) => c.toUpperCase())];
425
+ if (value != null) settings[flag] = value;
426
+ }
427
+ const parts = newFlagList(
428
+ o.like == null ? undefined : String(o.like),
429
+ settings,
430
+ Boolean(o.png),
431
+ );
432
+ return parts.length ? ` ${parts.join(' ')}` : '';
433
+ }
434
+
435
+ /**
436
+ * Refuse a preview flag given twice with different values: the command
437
+ * would keep only the last one without a word. Undefined when each is
438
+ * given once.
439
+ * @param {string} command the preview subcommand, for the suggestion
440
+ * @param {string[]} flags
441
+ * @returns {undefined}
442
+ */
443
+ function previewFlagsOnce(command, flags) {
444
+ for (const flag of flags) {
445
+ const all = flagValues(flag);
446
+ if (new Set(all).size > 1)
447
+ throw new AstryxError(
448
+ `--${flag} was given twice (${all.join(', ')}); give it once. Nothing was changed.`,
449
+ [
450
+ {
451
+ name: cmd(`${PREFIX} preview ${command} --help`),
452
+ reason: 'every option it takes',
453
+ },
454
+ ],
455
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
456
+ );
457
+ }
458
+ return undefined;
459
+ }
460
+
374
461
  /**
375
462
  * Every value one flag was given on the command line, in order.
376
463
  * @param {string} name
@@ -707,7 +794,7 @@ export function registerExperimentalTheme(group, program) {
707
794
  const editor = defineGroup(theme, editorDoc);
708
795
  explained(editor, editorDoc);
709
796
 
710
- explained(
797
+ const newCli = explained(
711
798
  defineCommand(editor, newDoc, {
712
799
  fn: newFn,
713
800
  action: (
@@ -718,38 +805,80 @@ export function registerExperimentalTheme(group, program) {
718
805
  run(
719
806
  program,
720
807
  () => {
808
+ // An option new does not take (--force, --dry-run, -t) is refused
809
+ // with new's help, as every editor command's unknown option is.
810
+ const takes = new Set(
811
+ (newDoc.options ?? []).flatMap(opt =>
812
+ String(opt.flag)
813
+ .split(/[\s,]+/)
814
+ .filter(w => w.startsWith('-'))
815
+ .map(w => w.replace(/[<[].*$/, '')),
816
+ ),
817
+ );
818
+ const stray = (cmd?.args ?? [])
819
+ .slice(1)
820
+ .map(String)
821
+ .find(
822
+ (/** @type {string} */ w) =>
823
+ /^-/.test(w) && !takes.has(w.split('=')[0]),
824
+ );
825
+ if (stray)
826
+ return cliError(`unknown option '${stray}'.`, {
827
+ suggestions: [
828
+ {
829
+ name: cliLine(`${EDITOR} new --help`),
830
+ reason: 'every option it takes',
831
+ },
832
+ ],
833
+ code: ERROR_CODES.ERR_INVALID_OPTION,
834
+ });
721
835
  // A word after the name is never dropped without a word.
722
836
  const extra = (cmd?.args ?? []).slice(1);
723
- if (extra.length)
837
+ if (extra.length) {
838
+ // Words after `--` that are `--<option> <value>` pairs new
839
+ // takes become options; the other words were most likely
840
+ // part of the name. The options given stay in the suggestion.
841
+ /** @type {Record<string, unknown>} */
842
+ const given = {...o};
843
+ /** @type {string[]} */
844
+ const words = [];
845
+ for (let i = 0; i < extra.length; i++) {
846
+ const w = String(extra[i]);
847
+ if (w.startsWith('--')) {
848
+ const key = w
849
+ .slice(2)
850
+ .replace(/-([a-z])/g, (_, c) => c.toUpperCase());
851
+ if (extra[i + 1] != null && given[key] == null)
852
+ given[key] = extra[++i];
853
+ continue;
854
+ }
855
+ words.push(w);
856
+ }
857
+ const builtIn =
858
+ words.length && builtInThemes().includes(words[0]);
859
+ if (builtIn && given.like == null) given.like = words[0];
860
+ const fixed = builtIn
861
+ ? name
862
+ : [name, ...words]
863
+ .join('-')
864
+ .toLowerCase()
865
+ .replace(/[^a-z0-9-]+/g, '-');
724
866
  throw new AstryxError(
725
867
  `new takes one theme name; "${extra.join(' ')}" is extra. For a base theme, use --like. Nothing was changed.`,
726
- // A built-in theme after the name is the base; other words
727
- // were most likely part of the name.
728
- builtInThemes().includes(extra[0])
729
- ? [
730
- {
731
- name: `${EDITOR} new ${name} --like ${extra[0]}`,
732
- reason: 'do this instead',
733
- },
734
- ]
735
- : [
736
- {
737
- name: `${EDITOR} new ${quoteCommandArgument(
738
- [name, ...extra]
739
- .join('-')
740
- .toLowerCase()
741
- .replace(/[^a-z0-9-]+/g, '-'),
742
- )}`,
743
- reason: 'do this instead',
744
- },
745
- ],
868
+ [
869
+ {
870
+ name: `${EDITOR} new ${quoteCommandArgument(fixed)}${newFlagLine(given)}`,
871
+ reason: 'do this instead',
872
+ },
873
+ ],
746
874
  ERROR_CODES.ERR_INVALID_ARGUMENT,
747
875
  );
876
+ }
748
877
  return themeEditNew(name, {
749
878
  cwd: process.cwd(),
750
879
  like: o.like,
751
880
  png: o.png ?? false,
752
- settings: newSettings(o),
881
+ settings: newSettings(o, name),
753
882
  });
754
883
  },
755
884
  r => [
@@ -761,6 +890,8 @@ export function registerExperimentalTheme(group, program) {
761
890
  }),
762
891
  newDoc,
763
892
  );
893
+ // new refuses an option it does not take itself, naming its help.
894
+ newCli.allowUnknownOption();
764
895
 
765
896
  explained(
766
897
  defineCommand(editor, setDoc, {
@@ -799,7 +930,11 @@ export function registerExperimentalTheme(group, program) {
799
930
  {
800
931
  suggestions: [
801
932
  {
802
- name: `${EDITOR} show ${name} --section ${flagValues('section')[0]}`,
933
+ // The first section given that `show` takes, else the
934
+ // whole sheet.
935
+ name: cmd(
936
+ `${EDITOR} show ${name}${(sec => (sec ? ` --section ${sec}` : ''))(flagValues('section').find(v => showSections().includes(v)))}`,
937
+ ),
803
938
  reason: 'do this instead',
804
939
  },
805
940
  ],
@@ -870,6 +1005,7 @@ export function registerExperimentalTheme(group, program) {
870
1005
  run(
871
1006
  program,
872
1007
  () =>
1008
+ previewFlagsOnce('add', ['theme', 'template', 'top', 'path']) ??
873
1009
  themeEditPreviewAdd([words ?? []].flat().join(' ') || undefined, {
874
1010
  cwd: process.cwd(),
875
1011
  theme: o.theme,
@@ -916,6 +1052,7 @@ export function registerExperimentalTheme(group, program) {
916
1052
  run(
917
1053
  program,
918
1054
  () =>
1055
+ previewFlagsOnce('app', ['theme']) ??
919
1056
  themeEditPreviewApp(dir, {
920
1057
  cwd: process.cwd(),
921
1058
  theme: o.theme,
@@ -954,10 +1091,20 @@ export function registerExperimentalTheme(group, program) {
954
1091
  action: (/** @type {any} */ o) =>
955
1092
  run(
956
1093
  program,
957
- () => themeEditPreviewList({cwd: process.cwd(), path: o.path}),
1094
+ () =>
1095
+ previewFlagsOnce('list', ['path']) ??
1096
+ themeEditPreviewList({cwd: process.cwd(), path: o.path}),
958
1097
  r =>
959
1098
  r.data.folder
960
- ? project(/** @type {any} */ (r.data))
1099
+ ? project(
1100
+ /** @type {any} */ ({
1101
+ ...r.data,
1102
+ // A page whose file is gone says so in words.
1103
+ pages: r.data.pages.map(({missing, ...p}) =>
1104
+ missing ? {...p, file: 'missing'} : p,
1105
+ ),
1106
+ }),
1107
+ )
961
1108
  : [
962
1109
  ...project(/** @type {any} */ (r.data)),
963
1110
  `Tip: ${PREFIX} preview add${o.path == null ? '' : ` --path ${quoteCommandArgument(String(o.path))}`}`,
@@ -980,6 +1127,7 @@ export function registerExperimentalTheme(group, program) {
980
1127
  run(
981
1128
  program,
982
1129
  () =>
1130
+ previewFlagsOnce('remove', ['path']) ??
983
1131
  themeEditPreviewRemove(page, {cwd: process.cwd(), path: o.path}),
984
1132
  r => [
985
1133
  r.data.pages.length
@@ -1025,14 +1173,16 @@ export function registerExperimentalTheme(group, program) {
1025
1173
  );
1026
1174
  if (themeFlags.length > 1)
1027
1175
  return cliError('--theme is given twice; give it once.', {
1028
- suggestions: [{name: `${HOW} --help`, reason: 'give --theme once'}],
1176
+ suggestions: [
1177
+ {name: cmd(`${HOW} --help`), reason: 'give --theme once'},
1178
+ ],
1029
1179
  code: ERROR_CODES.ERR_INVALID_ARGUMENT,
1030
1180
  });
1031
1181
  if (listFlags.length > 1)
1032
1182
  return cliError('--list is given twice; give it once.', {
1033
1183
  suggestions: [
1034
1184
  {
1035
- name: `${HOW} --list tokens accent`,
1185
+ name: cmd(`${HOW} --list tokens accent`),
1036
1186
  reason: 'one list, then the filter',
1037
1187
  },
1038
1188
  ],
@@ -1124,6 +1274,7 @@ export function registerExperimentalTheme(group, program) {
1124
1274
  build: 'compile',
1125
1275
  explain: editorThemeRefusal,
1126
1276
  preflight: editorCompileProblem,
1277
+ template: editorThemeTemplate,
1127
1278
  hold: editorThemeHold,
1128
1279
  },
1129
1280
  );
@@ -39,7 +39,7 @@ export const doc = {
39
39
  flag: '-o, --out <path>',
40
40
  param: 'options.out',
41
41
  description:
42
- 'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A folder, or a path ending in /, writes <theme name>.css into it. A build never replaces the theme source (ERR_THEME_INVALID). At a path --out names, it replaces only its own earlier outputs: any other existing file fails with ERR_FILE_EXISTS and nothing is written. A build writes only inside the working directory, the defaults beside the source too (ERR_PATH_TRAVERSAL); --check writes nothing, so it compares outputs anywhere and refuses only a relative path that escapes the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID)',
42
+ 'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A folder, or a path ending in /, writes <theme name>.css into it. The path should end in .css; another name still builds, with a warning. A build never replaces the theme source (ERR_THEME_INVALID). At a path --out names, it replaces its own earlier outputs, and the output of another theme source with a warning that names both sources; any other existing file fails with ERR_FILE_EXISTS and nothing is written. Into a folder the theme editor made (folder <slug>/ holds <slug>.settings.json), a source outside that folder builds there too, with a warning; to keep the editor folder to its own theme, build beside the source, or pass an --out outside it. A build writes only inside the working directory, the defaults beside the source too (ERR_PATH_TRAVERSAL); --check writes nothing, so it compares outputs anywhere and refuses only a relative path that escapes the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID)',
43
43
  },
44
44
  {
45
45
  flag: '--icons-specifier <specifier>',
@@ -89,7 +89,7 @@ export const doc = {
89
89
  },
90
90
  {
91
91
  code: 1,
92
- when: 'a build or validation error (an error envelope), or --check finds stale or missing outputs (the check result, with upToDate false and the stale files, is still printed: it is a result, not an error). One exception: an editor theme whose settings changed after its build is refused (ERR_THEME_INVALID, an error envelope) before any file is checked, with `editor show <theme>` to build it again',
92
+ when: 'a build or validation error (an error envelope), or --check finds stale or missing outputs (the check result, with upToDate false, the stale files and code ERR_THEME_STALE, is still printed: it is a result, not an error). One exception: an editor theme whose settings changed after its build is refused (ERR_THEME_INVALID, an error envelope) before any file is checked, with `editor show <theme>` to build it again. An editor theme run from a folder other than its app root is refused (ERR_INVALID_ARGUMENT) with the `cd` to the root and the same command; `--family` does not take an editor theme (ERR_INVALID_ARGUMENT); its damaged or unbuildable settings are refused (ERR_THEME_INVALID)',
93
93
  },
94
94
  ],
95
95
  related: ['experimental theme add', 'experimental theme list'],
@@ -11,7 +11,7 @@ export const doc = {
11
11
  stability: 'experimental',
12
12
  summary: 'Start a theme in themes/<theme>/, optionally on a built-in theme',
13
13
  description:
14
- 'Makes themes/<theme>/ with <theme>.settings.json (the settings this command owns), the generated <theme>.settings.ts, <theme>.theme.ts (which extends it and is yours), and the built <theme>.css and <theme>.js (the same build as `astryx theme build`), then writes preview.html, the sample app page with the theme. --like builds on a built-in theme (neutral, stone, matcha, y2k, gothic, chocolate, butter; its package must be installed); without it, or with --like none, the theme starts from Astryx defaults. Any `set` dial can be a flag too (--accent "#7c3aed" --font inter --corners round --vibrancy 60 ...): the same names, values and checks as `set`, all applied in the one build, with one result that lists them. Change the base later with `astryx experimental theme editor set <theme> base <theme|none>`. Afterwards, <theme>.theme.ts is yours: it extends the generated <theme>.settings.ts, and every later change rewrites only the settings files, so your own edits in <theme>.theme.ts survive. A theme name is lowercase letters, digits and dashes, starts with a letter, has 64 characters at most, and is not the name of a built-in theme or a name Windows reserves for a device (con, prn, aux, nul, com1-com9, lpt1-lpt9). Experimental: it may change or be removed in a patch release.',
14
+ 'Makes themes/<theme>/ with <theme>.settings.json (the settings this command owns), the generated <theme>.settings.ts, <theme>.theme.ts (which extends it and is yours), and the built <theme>.css and <theme>.js (build them again with `astryx experimental theme compile themes/<theme>/<theme>.theme.ts`, which checks the editor settings first), then writes preview.html, the sample app page with the theme. --like builds on a built-in theme (neutral, stone, matcha, y2k, gothic, chocolate, butter; its package must be installed); without it, or with --like none, the theme starts from Astryx defaults. Any `set` dial can be a flag too (--accent "#7c3aed" --font inter --corners round --vibrancy 60 ...): the same names, values and checks as `set`, all applied in the one build, with one result that lists them. Change the base later with `astryx experimental theme editor set <theme> base <theme|none>`. Afterwards, <theme>.theme.ts is yours: it extends the generated <theme>.settings.ts, and every later change rewrites only the settings files, so your own edits in <theme>.theme.ts survive. A theme name is lowercase letters, digits and dashes, starts with a letter, has 64 characters at most, and is not the name of a built-in theme or a name Windows reserves for a device (con, prn, aux, nul, com1-com9, lpt1-lpt9). Experimental: it may change or be removed in a patch release.',
15
15
  fn: 'themeEditNew',
16
16
  args: [
17
17
  {
@@ -12,7 +12,7 @@ export const doc = {
12
12
  summary:
13
13
  'Every setting, key values, problems the theme caused, and the theme-building page with every component',
14
14
  description:
15
- 'Lists every setting with where it applies and its source (dial, token or property), the resolved value of key tokens in each mode, the colors (the vibrancy; each color with its seed and the shade each token uses in light and dark, marked when an exact token setting wins; any shade moved so text reads), contrast problems this theme caused versus its base, font notes, and last the generated color files. Writes two self-contained HTML files: preview.html (the sample app page) and sheet.html (the theme-building page: every component grouped, each variant side by side, overlays open, and real template pages, with an auto/light/dark switch). A theme with no build is built first, and an in-app preview (`preview add`) of the theme has its route and Colors page rewritten. --section limits the sheet to one section. Experimental: it may change or be removed in a patch release.',
15
+ 'Lists every setting with where it applies and its source (dial, token or property), the resolved value of key tokens in each mode, the colors (the vibrancy; each color with its seed and the shade each token uses in light and dark, marked when an exact token setting wins; any shade moved so text reads), contrast problems this theme caused versus its base, font notes, and last the generated color files. Writes two self-contained HTML files: preview.html (the sample app page) and sheet.html (the theme-building page: every component grouped, each variant side by side, overlays open, and real template pages, with an auto/light/dark switch). A theme with no build is built first, and an in-app preview (`preview add`) of the theme has its route and Colors page rewritten. --section limits the sheet to one section. An own change to <theme>.theme.ts since the last build is built first, and the colors mark where it wins over a generated shade; a theme source that no longer builds, or a token in it that is not text, is refused (ERR_THEME_INVALID, exit 1) and the folder stays as it was. Experimental: it may change or be removed in a patch release.',
16
16
  fn: 'themeEditShow',
17
17
  args: [
18
18
  {
@@ -59,7 +59,7 @@ export const doc = {
59
59
  },
60
60
  {
61
61
  code: 1,
62
- when: 'the theme does not exist, an unknown --section, or a page that does not render; or a folder outside a project with Core installed (ERR_PROJECT_REQUIRED)',
62
+ when: 'the theme does not exist or its base theme package is not installed (ERR_UNKNOWN_THEME), an unknown --section (ERR_INVALID_ARGUMENT), a theme source that does not build or parse or a token in it that is not text (ERR_THEME_INVALID), a folder where a built file goes (ERR_FILE_EXISTS), a built file that cannot be read or written (ERR_WRITE_FAILED), another command changing the theme (ERR_THEME_BUSY), a page that does not render (ERR_RENDER_FAILED), or a folder outside a project with Core installed (ERR_PROJECT_REQUIRED)',
63
63
  },
64
64
  ],
65
65
  related: ['experimental theme editor', 'experimental theme compile'],
@@ -12,7 +12,7 @@ export const doc = {
12
12
  summary:
13
13
  'Step back one change, or remove one setting; the result says what applies instead',
14
14
  description:
15
- "With only the theme, it steps back one change: the settings, the generated settings module and the build go back to how they were before the last change (your <theme>.theme.ts is not touched), and the preview is rewritten; the result names what was undone and how many earlier steps are left. When the settings file is damaged (not valid JSON), the step back restores the settings from before the last change without reading it. With a thing, it removes that one setting wherever it is in the settings, and the result says what applies now (`now`): the whole-theme setting for a part setting removed, or the base theme's value; the theme is rebuilt and previewed. Name the setting the way it was set: the same thing and the same --on, --when, --state, --mode and --only (`show` lists every setting that way). For the headings dial, name which half: weight or tracking (default weight). Removing a color (accent, neutral, success, warning, danger, info) stops generating it, and the tokens it fed go back to the base theme; with no color left, the generated color files the editor wrote are deleted; a palette.config.json you made, or one that holds a color of your own, stays. Removing vibrancy makes the colors again at the default, 50; removing the last color removes vibrancy too, as it needs a color. A setting the theme does not have is refused and the error lists the settings it has for that thing. `undo <theme> base` and `undo <theme> mode` go back to the base and mode the theme was made with; when they never changed, that is refused. The history keeps the last 80 steps (in <theme>.history.json); older steps are dropped. Experimental: it may change or be removed in a patch release.",
15
+ "With only the theme, it steps back one change: the settings, the generated settings module and the build go back to how they were before the last change (your <theme>.theme.ts is not touched), and the preview is rewritten; the result names what was undone and how many earlier steps are left. When the settings file is damaged (not valid JSON), the step back restores the settings from before the last change without reading it. With a thing, it removes that one setting wherever it is in the settings, and the result says what applies now (`now`): the whole-theme setting for a part setting removed, or the base theme's value; the theme is rebuilt and previewed. Name the setting the way it was set: the same thing and the same --on, --when, --state, --mode and --only (`show` lists every setting that way). For the headings dial, name which half: weight or tracking; with no half named it removes the weight half, or the tracking half when that is the only one set. Removing a color (accent, neutral, success, warning, danger, info) stops generating it, and the tokens it fed go back to the base theme; with no color left, the generated color files the editor wrote are deleted; a palette.config.json you made, or one that holds a color of your own, stays. Removing vibrancy makes the colors again at the default, 50; removing the last color removes vibrancy too, as it needs a color. A setting the theme does not have is refused and the error lists the settings it has for that thing. `undo <theme> base` and `undo <theme> mode` go back to the base and mode the theme was made with; when they never changed, that is refused. The history keeps the last 80 steps (in <theme>.history.json); older steps are dropped. Experimental: it may change or be removed in a patch release.",
16
16
  fn: 'themeEditUndo',
17
17
  args: [
18
18
  {
@@ -15,7 +15,7 @@ export const doc = {
15
15
  summary:
16
16
  'Make and change a theme one checked change at a time (dials, tokens, part styles), with previews',
17
17
  description:
18
- "A type-safe compiler for themes. A theme lives in themes/<theme>/: <theme>.settings.json holds the checked settings and is owned by this command; <theme>.settings.ts is generated from it on every change; <theme>.theme.ts extends it, is written once and is yours to edit; <theme>.css and <theme>.js are built from it by the same build as `astryx theme build` (`experimental theme compile`). Every change is CHECKED against what the installed Core's components really read (derived from Core itself, version for version, and cached under node_modules/.cache/) and against the token's type; a change that cannot take effect is refused, nothing is written, and the error leads with the command that works. The thing you set is a dial (a big move with named rungs: corners, spacing, font, headings, text-size, base, mode; or a color: accent, neutral, success, warning, danger, info, each generating its light and dark shades from one color for the color tokens, and vibrancy, how saturated they are), a design token by name, or a CSS property on a part. Where it applies: --on <part|group>, --when <prop>:<value>, --state <state>, --mode light|dark, --only. Every accepted change rebuilds and writes preview.html (the sample app page); `show` adds the theme-building page with every component. PNG pictures only with --png. Commands on one theme run one after the other, through a lock in node_modules/.cache/astryx-theme/ of the project; when node_modules cannot be written (a read-only install), changes are refused and `show` still reads the last build. `how` answers everything else: what a part, group, setting or aspect does, how the colors are made, plain-words questions (with exact commands), a picture's colors, and lists of what you can set. Experimental: it may change or be removed in a patch release.",
18
+ "A type-safe compiler for themes. A theme lives in themes/<theme>/: <theme>.settings.json holds the checked settings and is owned by this command; <theme>.settings.ts is generated from it on every change; <theme>.theme.ts extends it, is written once and is yours to edit; <theme>.css and <theme>.js are built from it; build them again with `astryx experimental theme compile themes/<theme>/<theme>.theme.ts`, which checks the editor's settings first. Every change is CHECKED against what the installed Core's components really read (derived from Core itself, version for version, and cached under node_modules/.cache/) and against the token's type; a change that cannot take effect is refused, nothing is written, and the error leads with the command that works. The thing you set is a dial (a big move with named rungs: corners, spacing, font, headings, text-size, base, mode; or a color: accent, neutral, success, warning, danger, info, each generating its light and dark shades from one color for the color tokens, and vibrancy, how saturated they are), a design token by name, or a CSS property on a part. Where it applies: --on <part|group>, --when <prop>:<value>, --state <state>, --mode light|dark, --only. Every accepted change rebuilds and writes preview.html (the sample app page); `show` adds the theme-building page with every component. PNG pictures only with --png. Commands on one theme run one after the other, through a lock in node_modules/.cache/astryx-theme/ of the project; when node_modules cannot be written (a read-only install), changes are refused and `show` still reads the last build. `how` answers everything else: what a part, group, setting or aspect does, how the colors are made, plain-words questions (with exact commands), a picture's colors, and lists of what you can set. Experimental: it may change or be removed in a patch release.",
19
19
  subcommands: ['new', 'set', 'undo', 'show', 'how'],
20
20
  examples: [
21
21
  {
@@ -14,7 +14,7 @@ export const doc = {
14
14
  stability: 'experimental',
15
15
  summary: 'Fork a theme as editable local source',
16
16
  description:
17
- "Copies a bundled or installed package theme's complete source into the local themes root, including a local descriptor. Writes are atomic. Existing files require --overwrite. Eject never writes into a folder that holds another theme or a theme the theme editor made, even with --overwrite. When the fork imports packages the app lacks, the result names them with an install command. Use --package when package themes share a slug.",
17
+ "Copies a bundled or installed package theme's complete source into the local themes root, including a local descriptor. Writes are atomic. Existing files require --overwrite. Eject never writes into a folder that holds another theme or a theme the theme editor made, even with --overwrite. A subfolder of a folder the theme editor made is written, and the CLI warns; to keep the editor folder to its own theme, fork into the default folder or a path outside it. When the fork imports packages the app lacks, the result names them with an install command. Use --package when package themes share a slug.",
18
18
  fn: 'themeEject',
19
19
  args: [
20
20
  {
@@ -14,7 +14,7 @@ export const doc = {
14
14
  stability: 'experimental',
15
15
  summary: 'Write the annotated theme template into your project',
16
16
  description:
17
- 'Writes theme.template.ts: the annotated reference for the whole theme surface, covering every defineTheme field, the token families, the component override syntax, and how a theme is consumed, naming the CLI command that prints the authoritative reference for each. Read it, copy what you need into your own theme file, delete it. Use `experimental theme add <slug>` to use an installed built theme, extend that theme for ordinary customization, or use `experimental theme eject <slug>` for a complete source fork. The path is a .ts file, never a folder. Leaves an existing file untouched unless --overwrite, which replaces only an earlier copy of the template or a file named like a theme source (`*.theme.ts`, `*Theme.ts`, `*.template.ts`).',
17
+ 'Writes theme.template.ts: the annotated reference for the whole theme surface, covering every defineTheme field, the token families, the component override syntax, and how a theme is consumed, naming the CLI command that prints the authoritative reference for each. Read it, copy what you need into your own theme file, delete it. Use `experimental theme add <slug>` to use an installed built theme, extend that theme for ordinary customization, or use `experimental theme eject <slug>` for a complete source fork. The path is a .ts file, never a folder. Leaves an existing file untouched unless --overwrite, which replaces only an earlier copy of the template or a file named like a theme source (`*.theme.ts`, `*Theme.ts`, `*.template.ts`). A path is read from the current folder and must stay inside the project root (the nearest folder with a package.json); with no path it writes at the project root. Outside a project (no package.json in the folder or above it) it writes in the current folder and warns; run it inside a project, or run `npm init -y` in the folder first, to write it at a project root.',
18
18
  fn: 'themeTemplate',
19
19
  args: [
20
20
  {
@@ -28,7 +28,7 @@ export const doc = {
28
28
  flag: '-f, --overwrite',
29
29
  param: 'options.overwrite',
30
30
  description:
31
- 'Replace an existing copy of the template or theme source file. Any other file, such as package.json, or a file in a folder the theme editor made, fails with ERR_FILE_EXISTS and is left as it was',
31
+ 'Replace an existing copy of the template or theme source file. Any other .ts file, such as util.ts, or a file the theme editor owns (named after its folder, beside its settings, such as themes/t/t.theme.ts), fails with ERR_FILE_EXISTS and is left as it was; an earlier template in that folder is replaced. A path that is not .ts, such as package.json, fails with ERR_INVALID_ARGUMENT, with or without --overwrite',
32
32
  },
33
33
  ],
34
34
  examples: [
@@ -41,7 +41,7 @@ export const doc = {
41
41
  flag: '-o, --out <path>',
42
42
  param: 'options.out',
43
43
  description:
44
- 'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A folder, or a path ending in /, writes <theme name>.css into it. The path should end in .css; another name still builds, with a warning. A build never replaces the theme source (ERR_THEME_INVALID). At a path --out names, it replaces its own earlier outputs, and the output of another theme source with a warning that names both sources; any other existing file fails with ERR_FILE_EXISTS and nothing is written. A build writes only inside the working directory, the defaults beside the source too (ERR_PATH_TRAVERSAL); --check writes nothing, so it compares outputs anywhere and refuses only a relative path that escapes the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID)',
44
+ 'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A folder, or a path ending in /, writes <theme name>.css into it. The path should end in .css; another name still builds, with a warning. A build never replaces the theme source (ERR_THEME_INVALID). At a path --out names, it replaces its own earlier outputs, and the output of another theme source with a warning that names both sources; any other existing file fails with ERR_FILE_EXISTS and nothing is written. Into a folder the theme editor made (folder <slug>/ holds <slug>.settings.json), a source outside that folder builds there too, with a warning; to keep the editor folder to its own theme, build beside the source, or pass an --out outside it. A build writes only inside the working directory, the defaults beside the source too (ERR_PATH_TRAVERSAL); --check writes nothing, so it compares outputs anywhere and refuses only a relative path that escapes the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID)',
45
45
  },
46
46
  {
47
47
  flag: '--icons-specifier <specifier>',
@@ -91,7 +91,7 @@ export const doc = {
91
91
  },
92
92
  {
93
93
  code: 1,
94
- when: 'a build or validation error, or --check finds stale or missing outputs',
94
+ when: 'a build or validation error (an error envelope), or --check finds stale or missing outputs (the check result, with upToDate false, the stale files and code ERR_THEME_STALE)',
95
95
  },
96
96
  ],
97
97
  related: ['theme add', 'theme list'],
@@ -10,7 +10,7 @@ export const doc = {
10
10
  namespace: 'cli/commands',
11
11
  summary: 'Fork a theme as editable local source',
12
12
  description:
13
- "Copies a bundled or installed package theme's complete source into the local themes root, including a local descriptor. Writes are atomic. Existing files require --overwrite. Eject never writes into a folder that holds another theme or a theme the theme editor made, even with --overwrite. When the fork imports packages the app lacks, the result names them with an install command. Use --package when package themes share a slug.",
13
+ "Copies a bundled or installed package theme's complete source into the local themes root, including a local descriptor. Writes are atomic. Existing files require --overwrite. Eject never writes into a folder that holds another theme or a theme the theme editor made, even with --overwrite. A subfolder of a folder the theme editor made is written, and the CLI warns; to keep the editor folder to its own theme, fork into the default folder or a path outside it. When the fork imports packages the app lacks, the result names them with an install command. Use --package when package themes share a slug.",
14
14
  fn: 'themeEject',
15
15
  args: [
16
16
  {name: 'slug', param: 'slug', required: true},
@@ -21,7 +21,9 @@ export const doc = {
21
21
  'consumed, naming the CLI command that prints the authoritative reference for each. Read ' +
22
22
  'it, copy what you need into your own theme file, delete it. Use `theme add <slug>` to ' +
23
23
  'use an installed built theme, extend that theme for ordinary customization, or use ' +
24
- '`theme eject <slug>` for a complete source fork. The path is a .ts file, never a folder. Leaves an existing file untouched unless --overwrite, which replaces only an earlier copy of the template or a file named like a theme source (`*.theme.ts`, `*Theme.ts`, `*.template.ts`).',
24
+ '`theme eject <slug>` for a complete source fork. The path is a .ts file, never a folder. Leaves an existing file untouched unless --overwrite, which replaces only an earlier copy of the template or a file named like a theme source (`*.theme.ts`, `*Theme.ts`, `*.template.ts`).' +
25
+ ' A path is read from the current folder and must stay inside the project root (the nearest folder with a package.json); with no path it writes at the project root.' +
26
+ ' Outside a project (no package.json in the folder or above it) it writes in the current folder and warns; run it inside a project, or run `npm init -y` in the folder first, to write it at a project root.',
25
27
  fn: 'themeTemplate',
26
28
  args: [{name: 'path', param: 'options.targetPath', required: false}],
27
29
  options: [