@astryxdesign/cli 0.7.15 → 0.7.16-canary.g22213fd

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 (222) hide show
  1. package/README.md +6 -4
  2. package/api/build/_adapter.d.mts +10 -0
  3. package/api/build/_adapter.mjs +24 -0
  4. package/api/build/blocks/blocks.d.mts +1 -0
  5. package/api/build/blocks/blocks.mjs +18 -1
  6. package/api/build/kit/shell.weights.json +1 -0
  7. package/api/build/kit/shellcall.d.mts +26 -0
  8. package/api/build/kit/shellcall.mjs +87 -0
  9. package/api/build/kit/start.mjs +67 -4
  10. package/api/build/kit/weights.d.mts +15 -0
  11. package/api/build/kit/weights.mjs +27 -0
  12. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  13. package/api/component/_adapter.d.mts +1 -1
  14. package/api/component/_adapter.mjs +28 -1
  15. package/api/doctor/_adapter.d.mts +38 -2
  16. package/api/doctor/_adapter.mjs +76 -1
  17. package/api/doctor/built-checks.mjs +1 -1
  18. package/api/doctor/doctor.d.mts +26 -0
  19. package/api/doctor/doctor.doc.mjs +1 -1
  20. package/api/doctor/doctor.mjs +156 -11
  21. package/api/doctor/theme-checks.mjs +163 -18
  22. package/api/icon/_adapter.d.mts +7 -3
  23. package/api/icon/_adapter.mjs +12 -3
  24. package/api/icon/icon.type.d.mts +15 -0
  25. package/api/icon/icon.type.mjs +10 -3
  26. package/api/icon/iconUse.doc.mjs +19 -5
  27. package/api/icon/list/list.mjs +7 -1
  28. package/api/icon/use/use.d.mts +8 -5
  29. package/api/icon/use/use.mjs +95 -13
  30. package/api/init/run/run.mjs +1 -0
  31. package/api/integration/add-contribution.mjs +3 -3
  32. package/api/integration/pack-check.mjs +14 -8
  33. package/api/integration/validate-integration.mjs +1 -1
  34. package/api/search/_adapter.mjs +15 -16
  35. package/api/search/_entries.d.mts +2 -1
  36. package/api/search/_entries.mjs +28 -1
  37. package/api/swizzle/_moduleGraph.mjs +1 -1
  38. package/api/template/template.type.d.mts +6 -2
  39. package/api/template/template.type.mjs +2 -1
  40. package/api/theme/_adapter.d.mts +5 -2
  41. package/api/theme/_adapter.mjs +59 -14
  42. package/api/theme/_fork.mjs +1 -1
  43. package/api/theme/build/build.d.mts +120 -32
  44. package/api/theme/build/build.mjs +471 -111
  45. package/api/theme/eject/eject.mjs +22 -1
  46. package/api/theme/generateTonalPalette.doc.mjs +2 -2
  47. package/api/theme/palette/generate/generator.mjs +141 -2
  48. package/api/theme/template/template.d.mts +19 -0
  49. package/api/theme/template/template.mjs +102 -25
  50. package/api/theme/theme.type.d.mts +44 -1
  51. package/api/theme/theme.type.mjs +23 -1
  52. package/api/theme/themeBuild.doc.mjs +4 -4
  53. package/api/theme/themeEject.doc.mjs +1 -1
  54. package/api/theme/themePaletteGenerate.doc.mjs +1 -1
  55. package/api/theme/themeTemplate.doc.mjs +9 -3
  56. package/api/theme-edit/_adapter.d.mts +33 -2
  57. package/api/theme-edit/_adapter.mjs +276 -41
  58. package/api/theme-edit/_check.d.mts +93 -4
  59. package/api/theme-edit/_check.mjs +1712 -223
  60. package/api/theme-edit/_color.d.mts +2 -8
  61. package/api/theme-edit/_color.mjs +292 -219
  62. package/api/theme-edit/_compiler.d.mts +1 -0
  63. package/api/theme-edit/_compiler.mjs +20 -1
  64. package/api/theme-edit/_context.d.mts +31 -1
  65. package/api/theme-edit/_context.mjs +445 -41
  66. package/api/theme-edit/_css.d.mts +60 -1
  67. package/api/theme-edit/_css.mjs +404 -28
  68. package/api/theme-edit/_edit.d.mts +25 -0
  69. package/api/theme-edit/_edit.mjs +1620 -154
  70. package/api/theme-edit/_how-commands.d.mts +11 -26
  71. package/api/theme-edit/_how-commands.mjs +30 -2
  72. package/api/theme-edit/_how-question.d.mts +15 -0
  73. package/api/theme-edit/_how-question.mjs +1469 -194
  74. package/api/theme-edit/_how.mjs +144 -30
  75. package/api/theme-edit/_marks.d.mts +13 -0
  76. package/api/theme-edit/_marks.mjs +15 -0
  77. package/api/theme-edit/_overview.mjs +2 -0
  78. package/api/theme-edit/_palette.d.mts +38 -0
  79. package/api/theme-edit/_palette.mjs +306 -73
  80. package/api/theme-edit/_parts.d.mts +33 -0
  81. package/api/theme-edit/_parts.mjs +138 -9
  82. package/api/theme-edit/_png.d.mts +18 -0
  83. package/api/theme-edit/_png.mjs +95 -14
  84. package/api/theme-edit/_preview-app.d.mts +55 -1
  85. package/api/theme-edit/_preview-app.mjs +1552 -101
  86. package/api/theme-edit/_preview.d.mts +71 -3
  87. package/api/theme-edit/_preview.mjs +565 -35
  88. package/api/theme-edit/_project.d.mts +15 -0
  89. package/api/theme-edit/_project.mjs +68 -13
  90. package/api/theme-edit/_settings.d.mts +299 -5
  91. package/api/theme-edit/_settings.mjs +2806 -158
  92. package/api/theme-edit/_tables.d.mts +24 -0
  93. package/api/theme-edit/_tables.mjs +212 -150
  94. package/api/theme-edit/_vet.d.mts +42 -0
  95. package/api/theme-edit/_vet.mjs +144 -0
  96. package/api/theme-edit/theme-edit.type.d.mts +31 -2
  97. package/api/theme-edit/theme-edit.type.mjs +10 -2
  98. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  99. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  100. package/api/theme-edit/themeEditShow.doc.mjs +11 -3
  101. package/api/upgrade/registry/registry.mjs +6 -1
  102. package/assets/codemods/parse.mjs +2 -2
  103. package/assets/docs/author-a-theme.doc.mjs +1 -1
  104. package/assets/docs/theme.doc.dense.mjs +1 -1
  105. package/assets/docs/theme.doc.mjs +1 -1
  106. package/assets/docs/theme.doc.zh.mjs +4 -3
  107. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  108. package/assets/docs/tree/icon-sets.doc.mjs +63 -8
  109. package/assets/docs/tree/single-component.doc.mjs +11 -2
  110. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  111. package/assets/docs.generated.json +2 -2
  112. package/assets/preview-app/next.config.mjs +7 -1
  113. package/assets/preview-app/package.json +1 -0
  114. package/assets/preview-app/src/app/globals.css +1 -0
  115. package/assets/self-audit.generated.json +1 -1
  116. package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs +21 -0
  117. package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx +62 -0
  118. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
  119. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
  120. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
  121. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
  122. package/assets/templates/components.generated.json +1 -1
  123. package/assets/templates/pages/ai-chat/page.tsx +20 -2
  124. package/assets/templates/pages/dashboard/page.tsx +1 -1
  125. package/assets/templates/themes/neutral/neutralPalettes.generated.receipt.json +2 -0
  126. package/authoring/config/config.doc.mjs +8 -0
  127. package/authoring/config/parse.d.mts +1 -0
  128. package/authoring/config/parse.mjs +12 -0
  129. package/authoring/config/type.ts +8 -0
  130. package/authoring/doctypes/_schema.d.mts +52 -5
  131. package/authoring/doctypes/_schema.mjs +62 -7
  132. package/authoring/doctypes/base/type.ts +10 -0
  133. package/authoring/doctypes/component/component.doc.mjs +1 -1
  134. package/authoring/doctypes/function/function.doc.mjs +6 -0
  135. package/authoring/doctypes/function/type.ts +3 -0
  136. package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +3 -3
  137. package/authoring/doctypes/legacy.mjs +5 -1
  138. package/authoring/index.d.ts +1 -0
  139. package/authoring/shadcn/source-variants.d.mts +1 -1
  140. package/authoring/shadcn/source-variants.mjs +32 -10
  141. package/clients/cli/build-id.generated.json +1 -1
  142. package/clients/cli/commands/doctor.doc.mjs +2 -2
  143. package/clients/cli/commands/experimental/icon.mjs +61 -6
  144. package/clients/cli/commands/experimental/theme.mjs +244 -45
  145. package/clients/cli/commands/experimental-icon-use.doc.mjs +12 -5
  146. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  147. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  148. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
  149. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -3
  150. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  151. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  152. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
  153. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  154. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  155. package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
  156. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  157. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  158. package/clients/cli/commands/theme-template.doc.mjs +3 -1
  159. package/clients/cli/commands/theme.doc.mjs +7 -2
  160. package/clients/cli/commands/theme.mjs +222 -55
  161. package/clients/cli/commands.generated.json +1 -1
  162. package/clients/cli/formatters/index.mjs +7 -4
  163. package/clients/cli/index.mjs +25 -5
  164. package/clients/cli/lib/cli-error.mjs +9 -3
  165. package/clients/cli/lib/component-format.mjs +27 -9
  166. package/clients/cli/lib/json-shim.mjs +72 -2
  167. package/clients/cli/manifest.generated.json +1 -1
  168. package/clients/cli/run.mjs +49 -0
  169. package/foundation/agent-docs/agent-docs-target.d.mts +2 -6
  170. package/foundation/agent-docs/agent-docs-target.mjs +9 -17
  171. package/foundation/agent-docs/agent-docs.mjs +4 -3
  172. package/foundation/config/config-writer.d.mts +23 -0
  173. package/foundation/config/config-writer.mjs +152 -58
  174. package/foundation/config/project.mjs +103 -16
  175. package/foundation/discovery/component-discovery.mjs +11 -22
  176. package/foundation/discovery/icon-set-checks.mjs +164 -48
  177. package/foundation/discovery/icon-set-discovery.d.mts +38 -5
  178. package/foundation/discovery/icon-set-discovery.mjs +50 -6
  179. package/foundation/discovery/icon-set-theme-maps.d.mts +59 -0
  180. package/foundation/discovery/icon-set-theme-maps.mjs +95 -0
  181. package/foundation/discovery/icon-set-writer.d.mts +2 -3
  182. package/foundation/discovery/icon-set-writer.mjs +58 -17
  183. package/foundation/discovery/module-exports.mjs +1 -15
  184. package/foundation/discovery/template-adapter.mjs +44 -19
  185. package/foundation/discovery/template-icons.d.mts +27 -10
  186. package/foundation/discovery/template-icons.mjs +142 -26
  187. package/foundation/discovery/template-source-tree.mjs +3 -16
  188. package/foundation/discovery/theme-discovery.d.mts +30 -1
  189. package/foundation/discovery/theme-discovery.mjs +109 -50
  190. package/foundation/fs/exact-codec.d.mts +35 -0
  191. package/foundation/fs/exact-codec.mjs +148 -0
  192. package/foundation/fs/gather-cache.d.mts +15 -5
  193. package/foundation/fs/gather-cache.mjs +129 -31
  194. package/foundation/fs/paths.d.mts +39 -0
  195. package/foundation/fs/paths.mjs +44 -11
  196. package/foundation/fs/read-record.mjs +11 -1
  197. package/foundation/integrations/autolink.d.mts +4 -2
  198. package/foundation/integrations/autolink.mjs +4 -2
  199. package/foundation/integrations/cli-requirement.d.mts +16 -5
  200. package/foundation/integrations/cli-requirement.mjs +27 -6
  201. package/foundation/integrations/contribution-fixes.mjs +1 -16
  202. package/foundation/integrations/may-have-integrations.mjs +7 -3
  203. package/foundation/integrations/missing-dependency.d.mts +9 -0
  204. package/foundation/integrations/missing-dependency.mjs +100 -0
  205. package/foundation/integrations/public-imports.mjs +1 -1
  206. package/foundation/render/embedded-imports.mjs +1 -1
  207. package/foundation/render/host-exit.d.mts +8 -0
  208. package/foundation/render/host-exit.mjs +11 -0
  209. package/foundation/render/page-host.mjs +56 -10
  210. package/foundation/render/page-worker.mjs +14 -0
  211. package/foundation/render/render-page.mjs +37 -2
  212. package/foundation/response/error-codes.d.mts +2 -1
  213. package/foundation/response/error-codes.d.ts +1 -0
  214. package/foundation/response/error-codes.doc.mjs +5 -0
  215. package/foundation/response/error-codes.mjs +3 -0
  216. package/foundation/response/json.d.mts +15 -0
  217. package/foundation/response/json.mjs +52 -1
  218. package/foundation/response/response-types.doc.mjs +1 -1
  219. package/foundation/runtime/lazy-dependencies.d.mts +14 -0
  220. package/foundation/runtime/lazy-dependencies.mjs +82 -0
  221. package/foundation/xle/browser.d.mts +2 -2
  222. package/package.json +7 -6
@@ -28,8 +28,14 @@ import {
28
28
  familyOf,
29
29
  } from './_tables.mjs';
30
30
  import {colorsAt, decodePng, mainColors} from './_png.mjs';
31
- import {baseThemeFile, installLine} from './_project.mjs';
32
- import {loadTheme, nearest, refuse, themeSourceProblem} from './_settings.mjs';
31
+ import {baseInstalled, installLine} from './_project.mjs';
32
+ import {
33
+ editedThemes,
34
+ loadTheme,
35
+ nearest,
36
+ refuse,
37
+ themeSourceProblem,
38
+ } from './_settings.mjs';
33
39
  import {ASPECTS, checkSetting} from './_check.mjs';
34
40
  import {MODAL} from './_compiler.mjs';
35
41
  import {PALETTE_DIALS, mappingRows, paletteFiles} from './_palette.mjs';
@@ -182,7 +188,25 @@ function withPrefix(value, cwd) {
182
188
  */
183
189
  async function answer(subject, options, cwd) {
184
190
  const {list, at = [], count} = options;
185
- const t = (subject ?? '').trim();
191
+ // "½rem": a fraction is a number before anything reads the question.
192
+ const t = (subject ?? '')
193
+ .trim()
194
+ .replace(/(\d*)(?:½|1\u20442)/g, (_, n) => `${n ? Number(n) + 0.5 : '0.5'}`)
195
+ .replace(
196
+ /(\d*)(?:¼|1\u20444)/g,
197
+ (_, n) => `${n ? Number(n) + 0.25 : '0.25'}`,
198
+ )
199
+ .replace(
200
+ /(\d*)(?:¾|3\u20444)/g,
201
+ (_, n) => `${n ? Number(n) + 0.75 : '0.75'}`,
202
+ );
203
+ // "explain spacing", "tell me about the accent": the lookup of what is
204
+ // named, never a change.
205
+ const explain =
206
+ /^(?:explain|describe|tell me about)\s+(?:the |my )?([a-z][a-z -]*?)\s*$/i.exec(
207
+ t,
208
+ );
209
+ if (explain && explain[1] !== t) return answer(explain[1], options, cwd);
186
210
  // --theme names a theme whatever the subject, so a bad one is refused
187
211
  // for a picture and a list too.
188
212
  if (options.theme === '')
@@ -246,6 +270,22 @@ async function answer(subject, options, cwd) {
246
270
  },
247
271
  );
248
272
  }
273
+ // "how b make buttons pill": a first word typed as its own argument that
274
+ // names an existing theme, with more words after it, is the theme, as for
275
+ // set, show and undo. A quoted question ("how 'accent red'") is one
276
+ // argument: its first word is never a theme.
277
+ const argv = /** @type {string[] | undefined} */ (options.words);
278
+ if (
279
+ !options.theme &&
280
+ argv &&
281
+ argv.length >= 2 &&
282
+ editedThemes(cwd).includes(argv[0])
283
+ )
284
+ return answer(
285
+ argv.slice(1).join(' '),
286
+ {...options, words: undefined, theme: argv[0]},
287
+ cwd,
288
+ );
249
289
  const ctx = await context(cwd);
250
290
  const {C} = ctx;
251
291
  const env = await howTheme(ctx, cwd, options.theme);
@@ -332,14 +372,8 @@ async function answer(subject, options, cwd) {
332
372
  const d = DIALS[key];
333
373
  // A base is named only when it is installed here; the others are
334
374
  // listed with the line that installs them.
335
- const installed = (/** @type {string} */ b) => {
336
- try {
337
- baseThemeFile(ctx.project, b);
338
- return true;
339
- } catch {
340
- return false;
341
- }
342
- };
375
+ const installed = (/** @type {string} */ b) =>
376
+ baseInstalled(ctx.project, b);
343
377
  const missing = key === 'base' ? LIKE.filter(b => !installed(b)) : [];
344
378
  return {
345
379
  kind: 'setting',
@@ -459,7 +493,7 @@ async function answer(subject, options, cwd) {
459
493
  };
460
494
  }
461
495
  // A question about the tool itself gets the command that answers it.
462
- const tool = toolAnswer(t, env);
496
+ const tool = toolAnswer(t, env, ctx.project.target);
463
497
  if (tool === 'list') {
464
498
  const kind =
465
499
  /\b(dials?|tokens?|parts?|groups?|properties|property)\b/i
@@ -650,21 +684,22 @@ function partAnswer(ctx, env, subject, key, unknown, themeFields) {
650
684
  const group = familyOf(key);
651
685
  // Only the states set takes on this part (it refuses one that never
652
686
  // applies there).
687
+ // Only the states set takes on this part: a state is dropped when the
688
+ // same change without it passes and with it is refused.
689
+ const takes = (/** @type {string | undefined} */ st) => {
690
+ try {
691
+ checkSetting(ctx, env.slug, env.data, 'opacity', '1', {
692
+ on: key,
693
+ ...(st ? {state: st} : {}),
694
+ });
695
+ return true;
696
+ } catch {
697
+ return false;
698
+ }
699
+ };
700
+ const plainOk = takes(undefined);
653
701
  const states = [...new Set([...target.states, ...COMMON_STATES])].filter(
654
- st => {
655
- try {
656
- checkSetting(ctx, env.slug, env.data, 'opacity', '1', {
657
- on: key,
658
- state: st,
659
- });
660
- return true;
661
- } catch (e) {
662
- return !(
663
- /** @type {any} */ (e)?.code === 'ERR_THEME_NO_EFFECT' &&
664
- /--state/.test(String(/** @type {any} */ (e)?.message))
665
- );
666
- }
667
- },
702
+ st => !plainOk || takes(st),
668
703
  );
669
704
  const reads = Object.fromEntries(
670
705
  Object.keys(GROUPS).map(g => [
@@ -845,8 +880,11 @@ function tokenAnswer(ctx, env, subject, key, unknown, themeFields) {
845
880
  const {C} = ctx;
846
881
  const readers = C.anyReader(key);
847
882
  const type = C.typeOf(key);
883
+ // The theme's own value (its settings applied), else the base theme's.
848
884
  const now =
849
- env.base.light[key] ?? String(ctx.project.core.tokenDefaults[key]);
885
+ env.own?.light[key] ??
886
+ env.base.light[key] ??
887
+ String(ctx.project.core.tokenDefaults[key]);
850
888
  const value = exampleForToken(type, key, now);
851
889
  const {commands, refused} = value
852
890
  ? checked(env, [
@@ -937,9 +975,10 @@ function colorsAnswer(env, dialCommands) {
937
975
  * the caller lists the kind the question names.
938
976
  * @param {string} t
939
977
  * @param {import('./_how-commands.mjs').HowTheme} env
978
+ * @param {Map<string, unknown>} targets the parts Core styles
940
979
  * @returns {Array<{text: string, commands: string[]}> | 'list' | null}
941
980
  */
942
- function toolAnswer(t, env) {
981
+ function toolAnswer(t, env, targets) {
943
982
  const q = t
944
983
  .trim()
945
984
  .toLowerCase()
@@ -1011,7 +1050,82 @@ function toolAnswer(t, env) {
1011
1050
  commands: [`${P} new ${env.slug}-2 --like ${env.data.like ?? 'none'}`],
1012
1051
  },
1013
1052
  ];
1014
- if (/\b(version|which cli|what cli)\b/.test(q))
1053
+ // Screen-size, print and device conditions: the editor has none.
1054
+ if (
1055
+ /\bmedia quer|^(on|for) (mobile|phones?|tablets?|desktops?|print)$|^(print|printing|print styles?)$/.test(
1056
+ q,
1057
+ )
1058
+ )
1059
+ return [
1060
+ {
1061
+ text: 'the theme editor has no screen-size, print or device conditions: every setting applies on every screen; a media query needs your own CSS',
1062
+ commands: [`${HOW} --help`],
1063
+ },
1064
+ ];
1065
+ // Questions about what is set now, or the choices: a lookup, never a
1066
+ // write.
1067
+ const asks =
1068
+ /^(how (round|big|small|large|thick|dark|light|bold|wide|tall) (is|are)|what (is|are) the (current|available)|which \w+ (does|do|is|are)|what (font|color|colour|radius|accent) (does|do|is|are)|what (values|options|choices))\b|\b(right now|currently|at the moment)\??$|\bnow\?$/.exec(
1069
+ q,
1070
+ );
1071
+ // "is my theme valid", "how many dials", "list every change".
1072
+ if (
1073
+ /^(is|are) (my|the|this) theme (valid|ok|okay|broken|working)\b|^(check|validate) (my|the) theme\b/.test(
1074
+ q,
1075
+ )
1076
+ )
1077
+ return [
1078
+ {
1079
+ text: `show builds ${env.slug} and says what is wrong with it, if anything`,
1080
+ commands: [`${P} show ${env.slug}`],
1081
+ },
1082
+ ];
1083
+ if (
1084
+ /^how many (dials|settings|tokens|parts)\b|^(list|show) (every|all|each) (dial|setting|token|part)s?\b/.test(
1085
+ q,
1086
+ )
1087
+ )
1088
+ return 'list';
1089
+ if (/^(list|show) (every|all|my) (changes?|edits?|settings)\b/.test(q))
1090
+ return [
1091
+ {
1092
+ text: `show lists every setting ${env.slug} has`,
1093
+ commands: [`${P} show ${env.slug}`],
1094
+ },
1095
+ ];
1096
+ if (
1097
+ asks ||
1098
+ /^which parts (are|does|do)\b/.test(q) ||
1099
+ (/^why (is|are|does|do)\b/.test(q) && !/\bnot\b|n'?t\b/.test(q))
1100
+ ) {
1101
+ // The part or setting the question names gets its own lookup.
1102
+ const named = q
1103
+ .split(/[^a-z-]+/)
1104
+ .find(
1105
+ w =>
1106
+ w.length > 2 &&
1107
+ (targets.has(w) ||
1108
+ targets.has(w.replace(/s$/, '')) ||
1109
+ ['inputs', 'checks'].includes(w)),
1110
+ );
1111
+ const key =
1112
+ named && !targets.has(named) && !['inputs', 'checks'].includes(named)
1113
+ ? named.replace(/s$/, '')
1114
+ : named;
1115
+ return [
1116
+ {
1117
+ text: key
1118
+ ? `how ${key} says what ${key} reads and what sets it; show lists what ${env.slug} sets now`
1119
+ : `show lists what ${env.slug} sets now; how <part> or how <setting> says what a part reads and the values a setting takes`,
1120
+ commands: [...(key ? [`${HOW} ${key}`] : []), `${P} show ${env.slug}`],
1121
+ },
1122
+ ];
1123
+ }
1124
+ if (
1125
+ /\b((astryx|cli) version|version of (the )?(cli|astryx)|which cli|what cli)\b/.test(
1126
+ q,
1127
+ )
1128
+ )
1015
1129
  return [{text: 'the CLI says its version', commands: ['astryx --version']}];
1016
1130
  if (/\bwhere (are|is|do) .*\b(stored|saved|kept|live|files?)\b/.test(q))
1017
1131
  return [
@@ -1070,7 +1184,7 @@ function wholeThemeTokens(ctx, env, aspect) {
1070
1184
  /** @type {string[]} */
1071
1185
  let commands = [];
1072
1186
  for (const tok of toks) {
1073
- const now = env.base.light[tok] ?? '';
1187
+ const now = env.own?.light[tok] ?? env.base.light[tok] ?? '';
1074
1188
  if (parseFloat(now) >= 999) continue;
1075
1189
  const value = exampleForToken(C.typeOf(tok), tok, now);
1076
1190
  if (!value) continue;
@@ -0,0 +1,13 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @file The markers the theme editor writes at the top of the files it
6
+ * generates, in one place for the editor and for doctor.
7
+ *
8
+ * @position api/theme-edit — internal
9
+ */
10
+ /** The first words of a generated settings module the editor writes. */
11
+ export const EDITOR_GENERATED_MARK: "Generated by `astryx experimental theme editor`";
12
+ /** The words on every file of a theme's app copy (src/themes/<theme>/). */
13
+ export const APP_COPY_MARK: "Written by `astryx experimental theme editor`";
@@ -0,0 +1,15 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The markers the theme editor writes at the top of the files it
5
+ * generates, in one place for the editor and for doctor.
6
+ *
7
+ * @position api/theme-edit — internal
8
+ */
9
+
10
+ /** The first words of a generated settings module the editor writes. */
11
+ export const EDITOR_GENERATED_MARK =
12
+ 'Generated by `astryx experimental theme editor`';
13
+
14
+ /** The words on every file of a theme's app copy (src/themes/<theme>/). */
15
+ export const APP_COPY_MARK = 'Written by `astryx experimental theme editor`';
@@ -70,6 +70,8 @@ export const OVERVIEW_SECTIONS = [
70
70
  'Popover',
71
71
  {
72
72
  isOpen: true,
73
+ // Shown open on the page: it never takes focus.
74
+ hasAutoFocus: false,
73
75
  label: 'Menu',
74
76
  placement: 'below',
75
77
  content: h(
@@ -1,6 +1,11 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * Give the reader of the tokens a theme's own source sets.
6
+ * @param {(cwd: string, slug: string) => Record<string, string>} read
7
+ */
8
+ export function setOwnTokenReader(read: (cwd: string, slug: string) => Record<string, string>): void;
4
9
  /**
5
10
  * Write a file whole: a temp file beside it, renamed into place, so a link
6
11
  * there is replaced, never written through, and a stopped write leaves the
@@ -96,6 +101,33 @@ export function syncPalette(cwd: string, slug: string, data: {
96
101
  light: Record<string, string>;
97
102
  dark: Record<string, string>;
98
103
  }): string[];
104
+ /**
105
+ * The record of the files the editor wrote into a theme folder,
106
+ * `themes/<theme>/<theme>.pictures.json`: each by name, with the hash of
107
+ * what was written (its pictures and its color config). The one reader and
108
+ * writer of that record.
109
+ * @param {string} cwd
110
+ * @param {string} slug
111
+ * @returns {Record<string, string>}
112
+ */
113
+ export function readWrittenRecord(cwd: string, slug: string): Record<string, string>;
114
+ /**
115
+ * Write the record whole, or remove it when it names nothing. A record that
116
+ * cannot be written leaves nothing removed later: the safe way round.
117
+ * @param {string} cwd
118
+ * @param {string} slug
119
+ * @param {Record<string, string>} map
120
+ */
121
+ export function writeWrittenRecord(cwd: string, slug: string, map: Record<string, string>): void;
122
+ /**
123
+ * Note a file the editor wrote into a theme folder, by name with the hash
124
+ * of what it wrote, or forget it (null).
125
+ * @param {string} cwd
126
+ * @param {string} slug
127
+ * @param {string} name
128
+ * @param {string | null} hash
129
+ */
130
+ export function noteWritten(cwd: string, slug: string, name: string, hash: string | null): void;
99
131
  /**
100
132
  * Whether a theme's palette file was edited by hand. Its bytes match its
101
133
  * receipt, or its colors (read as data, so formatting, a BOM or semicolons
@@ -175,6 +207,7 @@ export function mappingRows(dial: string): string[];
175
207
  * @returns {string[]}
176
208
  */
177
209
  export function paletteNotes(pal: PaletteMapping | null, dial: string, slug: string, modes?: Mode[]): string[];
210
+ export function isEditorTemp(name: string): boolean;
178
211
  /** @typedef {'light' | 'dark'} Mode */
179
212
  /** @typedef {import('./_settings.mjs').Setting} Setting */
180
213
  /** @typedef {import('../theme/theme.type.mjs').TonalPaletteCandidate} Candidate */
@@ -210,6 +243,7 @@ export function paletteNotes(pal: PaletteMapping | null, dial: string, slug: str
210
243
  * @property {ContrastCheck[]} contrast
211
244
  * @property {number} vibrancy - The generator's vibrancy, 0 to 100.
212
245
  * @property {Record<string, Partial<Record<Mode, string>>>} exact - Main tokens the theme sets exactly, the value per mode: the dial's fill gives way to them.
246
+ * @property {Record<string, string>} [unread] - Main tokens the theme sets exactly to a value the editor cannot read as one color in some mode, as written: the text on them is not picked for that value.
213
247
  * @property {string[]} notes - What the config writer kept or replaced of a hand edit.
214
248
  * @property {Record<string, Partial<Record<Mode, StopRef>>> | null} lift - Lifted secondary text per background token of LIFT_PARTS (the accent tint, the neutral track), per mode, from the neutral color; null without one.
215
249
  */
@@ -330,6 +364,10 @@ export type PaletteMapping = {
330
364
  * - Main tokens the theme sets exactly, the value per mode: the dial's fill gives way to them.
331
365
  */
332
366
  exact: Record<string, Partial<Record<Mode, string>>>;
367
+ /**
368
+ * - Main tokens the theme sets exactly to a value the editor cannot read as one color in some mode, as written: the text on them is not picked for that value.
369
+ */
370
+ unread?: Record<string, string> | undefined;
333
371
  /**
334
372
  * - What the config writer kept or replaced of a hand edit.
335
373
  */