@astryxdesign/cli 0.7.16 → 0.7.17-canary.gb36275e

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 (239) hide show
  1. package/README.md +13 -23
  2. package/api/build/_adapter.d.mts +5 -0
  3. package/api/build/_adapter.mjs +49 -34
  4. package/api/build/blocks/blocks.d.mts +7 -5
  5. package/api/build/blocks/blocks.mjs +113 -26
  6. package/api/build/build.doc.mjs +2 -1
  7. package/api/build/kit/rank.mjs +59 -12
  8. package/api/build/kit/weights.d.mts +16 -3
  9. package/api/build/kit/weights.json +1 -1
  10. package/api/build/kit/weights.mjs +238 -31
  11. package/api/build/kit/word-model.d.mts +23 -0
  12. package/api/build/kit/word-model.mjs +46 -0
  13. package/api/build/kit/words.d.mts +42 -0
  14. package/api/build/kit/words.mjs +82 -1
  15. package/api/component/__fixtures__/resolutions/modules.txt +4 -5
  16. package/api/component/list/list.d.mts +1 -1
  17. package/api/component/list/list.mjs +46 -5
  18. package/api/discover/_adapter.d.mts +1 -1
  19. package/api/docs/_adapter.d.mts +26 -2
  20. package/api/docs/_adapter.mjs +217 -5
  21. package/api/docs/docs.d.mts +3 -0
  22. package/api/docs/docs.doc.mjs +7 -1
  23. package/api/docs/docs.mjs +12 -0
  24. package/api/docs/docs.type.d.mts +5 -0
  25. package/api/docs/docs.type.mjs +2 -0
  26. package/api/docs/node/node.mjs +1 -1
  27. package/api/doctor/_adapter.d.mts +27 -5
  28. package/api/doctor/_adapter.mjs +77 -6
  29. package/api/doctor/built-checks.mjs +38 -13
  30. package/api/doctor/doctor.d.mts +4 -3
  31. package/api/doctor/doctor.mjs +14 -7
  32. package/api/doctor/theme-checks.mjs +121 -17
  33. package/api/render/_adapter.mjs +531 -192
  34. package/api/render/render.doc.mjs +11 -3
  35. package/api/render/render.type.d.mts +30 -0
  36. package/api/render/render.type.mjs +19 -0
  37. package/api/search/ORDERING.md +1 -1
  38. package/api/search/_candidate-score.mjs +51 -32
  39. package/api/search/_fit-order.mjs +3 -3
  40. package/api/search/_result.d.mts +5 -5
  41. package/api/search/_score.d.mts +6 -1
  42. package/api/search/_score.mjs +15 -3
  43. package/api/search/search.d.mts +1 -1
  44. package/api/theme/_adapter.mjs +10 -0
  45. package/api/theme/build/build.d.mts +47 -0
  46. package/api/theme/build/build.mjs +147 -25
  47. package/api/theme/theme.type.d.mts +10 -0
  48. package/api/theme/theme.type.mjs +7 -1
  49. package/api/theme-edit/_adapter.d.mts +48 -0
  50. package/api/theme-edit/_adapter.mjs +675 -42
  51. package/api/theme-edit/_check.d.mts +28 -22
  52. package/api/theme-edit/_check.mjs +1481 -252
  53. package/api/theme-edit/_color.d.mts +9 -0
  54. package/api/theme-edit/_color.mjs +41 -1
  55. package/api/theme-edit/_compiler.mjs +9 -0
  56. package/api/theme-edit/_context.mjs +60 -3
  57. package/api/theme-edit/_css.mjs +21 -1
  58. package/api/theme-edit/_edit.d.mts +22 -0
  59. package/api/theme-edit/_edit.mjs +1196 -88
  60. package/api/theme-edit/_how-commands.d.mts +57 -0
  61. package/api/theme-edit/_how-commands.mjs +536 -1
  62. package/api/theme-edit/_how-question.d.mts +65 -0
  63. package/api/theme-edit/_how-question.mjs +4401 -225
  64. package/api/theme-edit/_how.mjs +104 -4
  65. package/api/theme-edit/_marks.d.mts +31 -5
  66. package/api/theme-edit/_marks.mjs +57 -5
  67. package/api/theme-edit/_normal.d.mts +153 -0
  68. package/api/theme-edit/_normal.mjs +661 -0
  69. package/api/theme-edit/_palette.mjs +10 -4
  70. package/api/theme-edit/_parts.d.mts +8 -0
  71. package/api/theme-edit/_parts.mjs +103 -2
  72. package/api/theme-edit/_preview-app.d.mts +7 -1
  73. package/api/theme-edit/_preview-app.mjs +205 -17
  74. package/api/theme-edit/_preview.d.mts +64 -8
  75. package/api/theme-edit/_preview.mjs +447 -89
  76. package/api/theme-edit/_settings.d.mts +176 -5
  77. package/api/theme-edit/_settings.mjs +1936 -128
  78. package/api/theme-edit/_tables.d.mts +6 -0
  79. package/api/theme-edit/_tables.mjs +32 -1
  80. package/api/theme-edit/theme-edit.type.d.mts +10 -1
  81. package/api/theme-edit/theme-edit.type.mjs +4 -1
  82. package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
  83. package/assets/codemods/run-codemod.mjs +73 -6
  84. package/assets/codemods/transforms/next/index.mjs +11 -1
  85. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
  86. package/assets/docs/author-a-theme.doc.mjs +1 -0
  87. package/assets/docs/theme.doc.dense.mjs +2 -2
  88. package/assets/docs/theme.doc.mjs +1 -1
  89. package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
  90. package/assets/docs/tree/cli-command.doc.mjs +2 -3
  91. package/assets/docs/tree/render-pages.doc.mjs +43 -2
  92. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  93. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  94. package/assets/docs/use-a-theme.doc.mjs +1 -1
  95. package/assets/docs.generated.json +2 -2
  96. package/assets/self-audit.generated.json +1 -1
  97. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  98. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  99. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  100. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  101. package/assets/templates/components.generated.json +1 -1
  102. package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
  103. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +2 -1
  104. package/assets/templates/pages/blank/template.doc.mjs +1 -1
  105. package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
  106. package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
  107. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
  108. package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
  109. package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
  110. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
  111. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
  112. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
  113. package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
  114. package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
  115. package/assets/templates/pages/documentation/template.doc.mjs +4 -1
  116. package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
  117. package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
  118. package/assets/templates/pages/editor/template.doc.mjs +2 -8
  119. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
  120. package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
  121. package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
  122. package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
  123. package/assets/templates/pages/ide/page.tsx +24 -2
  124. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
  125. package/assets/templates/pages/library/template.doc.mjs +4 -1
  126. package/assets/templates/pages/login/template.doc.mjs +2 -1
  127. package/assets/templates/pages/login-card/template.doc.mjs +2 -1
  128. package/assets/templates/pages/login-split/template.doc.mjs +2 -1
  129. package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
  130. package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
  131. package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
  132. package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
  133. package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
  134. package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
  135. package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
  136. package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
  137. package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
  138. package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
  139. package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
  140. package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
  141. package/assets/templates/pages/table-page/template.doc.mjs +5 -4
  142. package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
  143. package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
  144. package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
  145. package/authoring/debug/parse.d.mts +3 -3
  146. package/authoring/doctypes/_schema.d.mts +3 -3
  147. package/authoring/doctypes/command/command.doc.mjs +1 -1
  148. package/authoring/doctypes/template/template.doc.mjs +1 -1
  149. package/authoring/doctypes/template/type.ts +9 -0
  150. package/clients/cli/bin/astryx.mjs +6 -9
  151. package/clients/cli/build-id.generated.json +1 -1
  152. package/clients/cli/commands/component.doc.mjs +1 -1
  153. package/clients/cli/commands/component.mjs +20 -2
  154. package/clients/cli/commands/docs.doc.mjs +7 -1
  155. package/clients/cli/commands/docs.mjs +3 -1
  156. package/clients/cli/commands/doctor.mjs +22 -14
  157. package/clients/cli/commands/experimental/render.mjs +32 -1
  158. package/clients/cli/commands/experimental/theme.mjs +65 -14
  159. package/clients/cli/commands/experimental-render.doc.mjs +2 -2
  160. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  161. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  162. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  163. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  164. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  165. package/clients/cli/commands/search.doc.mjs +2 -1
  166. package/clients/cli/commands/search.mjs +6 -1
  167. package/clients/cli/commands/template.mjs +4 -2
  168. package/clients/cli/commands/theme-build.doc.mjs +5 -1
  169. package/clients/cli/commands/theme.doc.mjs +1 -1
  170. package/clients/cli/commands/theme.mjs +153 -5
  171. package/clients/cli/commands/upgrade.mjs +42 -7
  172. package/clients/cli/index.mjs +1 -1
  173. package/clients/cli/lib/component-format.mjs +205 -98
  174. package/clients/cli/lib/hook-format.mjs +9 -19
  175. package/clients/cli/manifest.generated.json +1 -1
  176. package/foundation/agent-docs/agent-docs.mjs +1 -1
  177. package/foundation/config/theme-state.d.mts +13 -1
  178. package/foundation/config/theme-state.mjs +47 -7
  179. package/foundation/discovery/component-discovery.d.mts +11 -0
  180. package/foundation/discovery/component-discovery.mjs +27 -2
  181. package/foundation/discovery/component-replacement.mjs +130 -1
  182. package/foundation/discovery/entry-name-files.d.mts +43 -0
  183. package/foundation/discovery/entry-name-files.mjs +264 -0
  184. package/foundation/discovery/hook-discovery.d.mts +8 -2
  185. package/foundation/discovery/hook-discovery.mjs +20 -7
  186. package/foundation/discovery/package-exports.d.mts +10 -0
  187. package/foundation/discovery/package-exports.mjs +56 -3
  188. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  189. package/foundation/discovery/runner-allowlist.mjs +2 -0
  190. package/foundation/discovery/template-adapter.d.mts +52 -0
  191. package/foundation/discovery/template-adapter.mjs +173 -10
  192. package/foundation/discovery/theme-imports.d.mts +14 -0
  193. package/foundation/discovery/theme-imports.mjs +43 -1
  194. package/foundation/doc-compiler/import.mjs +7 -1
  195. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  196. package/foundation/doc-compiler/stored-docs.d.mts +22 -0
  197. package/foundation/doc-compiler/stored-docs.mjs +49 -0
  198. package/foundation/fs/cache-eviction.d.mts +21 -0
  199. package/foundation/fs/cache-eviction.mjs +73 -0
  200. package/foundation/fs/gather-cache.d.mts +25 -4
  201. package/foundation/fs/gather-cache.mjs +163 -53
  202. package/foundation/fs/jiti-cache.d.mts +19 -1
  203. package/foundation/fs/jiti-cache.mjs +130 -6
  204. package/foundation/fs/kept-tree.d.mts +60 -0
  205. package/foundation/fs/kept-tree.mjs +154 -0
  206. package/foundation/fs/module-loader.d.mts +18 -2
  207. package/foundation/fs/module-loader.mjs +92 -20
  208. package/foundation/identity/provider-identity.d.mts +6 -0
  209. package/foundation/identity/provider-identity.mjs +10 -1
  210. package/foundation/render/embedded-imports.d.mts +5 -4
  211. package/foundation/render/embedded-imports.mjs +7 -16
  212. package/foundation/render/file-header.d.mts +66 -0
  213. package/foundation/render/file-header.mjs +118 -0
  214. package/foundation/render/host-answer.d.mts +18 -0
  215. package/foundation/render/host-answer.mjs +46 -0
  216. package/foundation/render/host-exit.d.mts +1 -0
  217. package/foundation/render/host-exit.mjs +6 -1
  218. package/foundation/render/html-reader.d.mts +55 -2
  219. package/foundation/render/html-reader.mjs +145 -26
  220. package/foundation/render/markup-edits.d.mts +57 -0
  221. package/foundation/render/markup-edits.mjs +182 -0
  222. package/foundation/render/page-host.mjs +29 -12
  223. package/foundation/render/page-worker.mjs +83 -13
  224. package/foundation/render/render-page.d.mts +34 -2
  225. package/foundation/render/render-page.mjs +210 -29
  226. package/foundation/render/source-block.d.mts +73 -6
  227. package/foundation/render/source-block.mjs +170 -19
  228. package/foundation/render/ts-paths.d.mts +53 -6
  229. package/foundation/render/ts-paths.mjs +286 -41
  230. package/foundation/response/error-codes.d.mts +3 -1
  231. package/foundation/response/error-codes.d.ts +1 -0
  232. package/foundation/response/error-codes.doc.mjs +12 -1
  233. package/foundation/response/error-codes.mjs +10 -0
  234. package/foundation/text/string-utils.d.mts +3 -2
  235. package/foundation/text/string-utils.mjs +16 -3
  236. package/foundation/text/suggest-order.d.mts +9 -0
  237. package/foundation/text/suggest-order.mjs +13 -0
  238. package/host/index.mjs +8 -6
  239. package/package.json +6 -6
@@ -32,7 +32,7 @@ export const doc = {
32
32
  flag: '--png',
33
33
  param: 'options.png',
34
34
  description:
35
- 'Also take PNG pictures of the previews (light and dark), with no dev server running: it needs a Playwright installed in the project or a Chrome or Chromium found on the machine, and adds a few seconds while the browser starts; without one, the result says how to get it. Each picture carries the editor stamp and is recorded, by name and content, in themes/<theme>/<theme>.pictures.json; a file of yours named like a picture (preview.png, sheet.png) is never written over: no picture is taken, and the result names the file',
35
+ 'Also take PNG pictures of the previews (light and dark), with no dev server running: it needs a Playwright installed in the project or a Chrome or Chromium found on the machine, and adds a few seconds while the browser starts; without one, the result says how to get it. Each picture carries the editor stamp and is recorded, by name and content, in themes/<theme>/<theme>.pictures.json; a file of yours named like a picture (preview.png, sheet.png) is never written over: no picture is taken, and the result names the file. Taking pictures changes nothing in the app, except that show first brings the app copy (src/themes/<theme>/) and an in-app preview up to date after a hand edit to <theme>.theme.ts',
36
36
  },
37
37
  ],
38
38
  examples: [
@@ -54,7 +54,7 @@ export const doc = {
54
54
  flag: '--mode <mode>',
55
55
  param: 'options.mode',
56
56
  description:
57
- 'light or dark: only that color mode. Colors only; sizes, numbers, fonts and shadows are the same in both modes, and a light-only or dark-only theme takes no --mode',
57
+ 'light or dark: only that color mode. Colors only; sizes, numbers, fonts and shadows are the same in both modes. In a light-only or dark-only theme, it removes a setting saved for one mode (one made before the theme became one-mode)',
58
58
  },
59
59
  {
60
60
  flag: '--only',
@@ -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; build them again with `astryx experimental theme compile themes/<theme>/<theme>.theme.ts`, which checks the editor's settings first. Every build also writes the theme's app copy, src/themes/<theme>/: a standard local theme (descriptor, source, built module and stylesheets), never edited by hand, so `astryx theme add <theme>` puts the theme into the app and `theme use`, `remove` and `list` take it as they take any local theme. A folder there that is not the editor's copy is left alone, and `new` and `show` then print the import lines by hand instead (`wiring`). 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 build also writes the theme's app copy, src/themes/<theme>/: a standard local theme (descriptor, source, built module and stylesheets), never edited by hand, so `astryx theme add <theme>` puts the theme into the app and `theme use`, `remove` and `list` take it as they take any local theme. Your own files in that folder are left as they are and the copy is written around them; a file, folder or link of yours at one of the copy's names, a link on the way to it, or a folder that cannot be written stops it, and every set, undo, show and compile says so (`appCopyStale`), with `compile --check` failing while the copy is behind or gone. 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
  {
@@ -12,7 +12,7 @@ export const doc = {
12
12
  summary:
13
13
  'Make a new starter app with the theme preview inside, ready to install and run',
14
14
  description:
15
- "Writes a new starter app into <dir> (Next.js app router, Core and the neutral theme, with the Astryx packages pinned to this CLI's release; with --theme, Core and the base theme are pinned to the versions this project has, the ones the copied build was made on, with a note), with the theme preview route and its default pages (the sample app page and every component grouped) in src/app/theme-preview/. With --theme, the theme folder is copied into the app's themes/ and the pages wear it; a base theme or font package it needs is added to package.json. No install runs: it prints the install and dev commands and the page to open. <dir> must be new or empty, inside the current folder; a folder that is not empty is refused, with a free folder name to use instead. Every check runs before the first write, so a refusal changes nothing. Later pages go in with `experimental theme preview add`, run in the new app. Every open font the theme names is added to package.json, at the version this project has or a pinned range, and the route imports it; a theme with generated colors gets the Colors page too, and a one-mode theme starts the route in its mode. The app is written into a temp folder beside the folder and moved into place, so a failure leaves nothing behind. A folder holding only .git, .DS_Store or Thumbs.db counts as empty. The folder is refused when it is a file, a dangling link, inside this app's routes folder, themes/, node_modules/ or Next's build folder (.next/, out/ or the distDir next.config names), or written with Windows separators, white space at either end or a name too long. A theme whose build is missing or older than its settings is built first, with a note. The app's home page links to the preview, and its .gitignore leaves out node_modules, next-env.d.ts and *.tsbuildinfo. Inside a project with a tsconfig.json, a note says to exclude the new folder. It takes one folder; more arguments are refused. With a theme, it holds that theme's lock while it builds and copies it, so an `editor set` on the same theme waits for it. A folder given from a subfolder of the project is taken from where it was given. An app is refused in public/ (served as files at the site root) and under a name Windows does not allow; a base theme passed to --theme is named as a package theme, installed or not, with the command that adds it. Experimental: it may change or be removed in a patch release.",
15
+ "Writes a new starter app into <dir> (Next.js app router, Core and the neutral theme, with the Astryx packages pinned to this CLI's release; with --theme, Core and the base theme are pinned to the versions this project has, the ones the copied build was made on, with a note), with the theme preview route and its default pages (the sample app page and every component grouped) in src/app/theme-preview/. With --theme, the theme folder is copied into the app's themes/ and the pages wear it; a base theme or font package it needs is added to package.json. No install runs: it prints the install and dev commands and the page to open. <dir> must be new or empty, inside the project folder (from a subfolder too); a folder that is not empty is refused, with a free folder name to use instead. Every check runs before the first write, so a refusal changes nothing. Later pages go in with `experimental theme preview add`, run in the new app. Every open font the theme names is added to package.json, at the version this project has or a pinned range, and the route imports it; a theme with generated colors gets the Colors page too, and a one-mode theme starts the route in its mode. The app is written into a temp folder beside the folder and moved into place, so a failure leaves nothing behind. A folder holding only .git, .DS_Store or Thumbs.db counts as empty. The folder is refused when it is a file, a dangling link, inside this app's routes folder, themes/, node_modules/ or Next's build folder (.next/, out/ or the distDir next.config names), or written with Windows separators, white space at either end or a name too long. A theme whose build is missing or older than its settings is built first, with a note. The app's home page links to the preview, and its .gitignore leaves out node_modules, next-env.d.ts and *.tsbuildinfo. Inside a project with a tsconfig.json, a note says to exclude the new folder. It takes one folder; more arguments are refused. With a theme, it holds that theme's lock while it builds and copies it, so an `editor set` on the same theme waits for it. A folder given from a subfolder of the project is taken from where it was given. An app is refused in public/ (served as files at the site root) and under a name Windows does not allow; a base theme passed to --theme is named as a package theme, installed or not, with the command that adds it. Experimental: it may change or be removed in a patch release.",
16
16
  fn: 'themeEditPreviewApp',
17
17
  args: [
18
18
  {
@@ -36,7 +36,8 @@ export const doc = {
36
36
  },
37
37
  {
38
38
  flag: '--verbose',
39
- description: "Also print each result's score and match reason",
39
+ description:
40
+ "Also print each result's score and match reason, and its whole description",
40
41
  },
41
42
  ],
42
43
  examples: [
@@ -17,7 +17,7 @@
17
17
  * astryx search dark mode Every word is part of the query
18
18
  * astryx search modal --type component Filter to a single domain
19
19
  * astryx search forms --limit 5 Cap the result count
20
- * astryx search button --verbose Also print score / reason
20
+ * astryx search button --verbose Also print score / reason, whole descriptions
21
21
  * astryx search button --json Typed JSON envelope
22
22
  */
23
23
 
@@ -32,6 +32,7 @@ import {cliError} from '../lib/cli-error.mjs';
32
32
  import {defineCommand} from '../lib/define-command.mjs';
33
33
  import {search as searchApi} from '../../../api/search/search.mjs';
34
34
  import {Project} from '../../../foundation/config/project.mjs';
35
+ import {firstSentence} from '../../../foundation/text/string-utils.mjs';
35
36
  import {warnOnIntegrationIssues} from '../../../foundation/integrations/integration-warnings.mjs';
36
37
  import {doc as searchCommand} from './search.doc.mjs';
37
38
  import {doc as searchFn} from '../../../api/search/search.doc.mjs';
@@ -183,6 +184,10 @@ export function registerSearch(program) {
183
184
  command: formatCliCommand,
184
185
  parent: formatCliCommand,
185
186
  deprecated: formatDeprecation,
187
+ // The text view keeps a description's first sentence. A
188
+ // component, hook or doc result's command prints the whole doc;
189
+ // --verbose and --json keep the description whole.
190
+ ...(options.verbose ? {} : {description: firstSentence}),
186
191
  },
187
192
  }),
188
193
  ...note,
@@ -18,6 +18,7 @@ import {template as templateApi} from '../../../api/template/template.mjs';
18
18
  import {Project} from '../../../foundation/config/project.mjs';
19
19
  import {warnOnIntegrationIssues} from '../../../foundation/integrations/integration-warnings.mjs';
20
20
  import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
21
+ import {firstSentence} from '../../../foundation/text/string-utils.mjs';
21
22
  import {defineCommand} from '../lib/define-command.mjs';
22
23
  import {NO_RESULT_SET, resultSet} from '../../../foundation/debug/index.mjs';
23
24
  import {doc as templateCommand} from './template.doc.mjs';
@@ -236,12 +237,13 @@ export function registerTemplate(program) {
236
237
 
237
238
  // Project each entry to its JSON-mirroring fields; the WIP marker is
238
239
  // folded into `name` (as before) and the package is shown only when it
239
- // isn't the built-in core package.
240
+ // isn't the built-in core package. The text keeps a description's
241
+ // first sentence; --json keeps it whole.
240
242
  /** @param {import('../../../api/template/template.type.mjs').TemplateListEntry} t */
241
243
  const toRow = t => ({
242
244
  id: t.id,
243
245
  name: t.isReady ? t.name : `${t.name} (WIP)`,
244
- description: t.description,
246
+ description: firstSentence(t.description ?? ''),
245
247
  package:
246
248
  t.package && t.package !== '@astryxdesign/core'
247
249
  ? t.package
@@ -23,7 +23,11 @@ export const doc = {
23
23
  'With --check it writes nothing and reports source drift. --icons-specifier keeps ' +
24
24
  'its existing generated-module behavior. It prints one line per built theme and ' +
25
25
  'one line naming fonts the themes do not load; --detail full adds the install ' +
26
- 'example and the font recipe, once for a batch.',
26
+ 'example and the font recipe, once for a batch. A source that also exports ' +
27
+ "`colorModes` (`['light']` or `['dark']`) for a theme with one color mode gets " +
28
+ 'the same export in its built module, which `theme add` reads to wire the theme ' +
29
+ 'in that mode; any other value is ignored without a warning, and a --family ' +
30
+ 'build never writes the export.',
27
31
  fn: 'themeBuild',
28
32
  args: [{name: 'files', param: 'file', required: true, variadic: true}],
29
33
  options: [
@@ -14,7 +14,7 @@ export const doc = {
14
14
  summary:
15
15
  'Add, switch, build, and author themes (to make or change one, use experimental theme editor)',
16
16
  description:
17
- 'To make or change a theme (colors, fonts, corners, spacing, a look from a picture), use the experimental theme editor: `astryx experimental theme editor new <name> --like neutral`, then `editor set` and `editor how`; it writes and checks the theme, and `astryx theme add <name>` wires it. Look at every change with `astryx experimental theme editor show <name> --png` (pictures; nothing changes in the app): a theme change is not done until you have looked. The theme command group. Add built themes to an app, choose its default, remove them, list available and added themes, or eject source to make a local fork. The authoring commands build themes, generate palettes, write the annotated template, and list component theme targets.',
17
+ 'To make or change a theme (colors, fonts, corners, spacing, a look from a picture), use the experimental theme editor: `astryx experimental theme editor new <name> --like neutral`, then `editor set` and `editor how`; it writes and checks the theme, and `astryx theme add <name>` wires it. Look at every change with `astryx experimental theme editor show <name> --png` (takes pictures of real components): a theme change is not done until you have looked. The theme command group. Add built themes to an app, choose its default, remove them, list available and added themes, or eject source to make a local fork. The authoring commands build themes, generate palettes, write the annotated template, and list component theme targets.',
18
18
  subcommands: [
19
19
  'build',
20
20
  'list',
@@ -85,6 +85,7 @@ import {
85
85
  themeSourceFiles,
86
86
  themeSourceGuesses,
87
87
  buildSuggestion,
88
+ generatedSourceCommand,
88
89
  writeDeferredBuildOutputs,
89
90
  } from '../../../api/theme/build/build.mjs';
90
91
  import {defineCommand} from '../lib/define-command.mjs';
@@ -119,7 +120,11 @@ import {doc as themePaletteGenerateFn} from '../../../api/theme/themePaletteGene
119
120
  * @property {string} build - The build subcommand's name: `build` or `compile`.
120
121
  * @property {(err: import('../../../api/error.mjs').AstryxError, cwd: string) => import('../../../api/error.mjs').AstryxError | null} [explain] - A clearer refusal for this group, or null.
121
122
  * @property {(files: string[], options: {cwd: string, check?: boolean, family?: boolean, iconsSpecifier?: string, out?: string}) => Promise<import('../../../api/error.mjs').AstryxError | null>} [preflight] - A refusal before a build starts, or null.
123
+ * @property {(err: import('../../../api/error.mjs').AstryxError, cwd: string) => Promise<import('../../../api/error.mjs').AstryxError>} [follow] - The refusal with its first suggested build checked and repaired as the build would check it.
122
124
  * @property {(files: string[], options: {cwd: string}) => Promise<() => Promise<void>>} [hold] - Locks held while a build or check runs; resolves to their release.
125
+ * @property {(file: string, cwd: string, opts: {check: boolean, upToDate?: boolean}) => Record<string, unknown> | null | Promise<Record<string, unknown> | null>} [extraData] - Fields a group adds to a build's result data (the editor's `appCopyStale`); in a check, `upToDate: false` fails it.
126
+ * @property {(file: string, cwd: string) => (['light'] | ['dark'] | null)} [colorModes] - The one color mode a theme file has that the file itself cannot say, for the build to write into the built module.
127
+ * @property {(file: string, cwd: string) => ((family: string) => boolean) | null | Promise<((family: string) => boolean) | null>} [loadedFonts] - Font families the app loads for a theme file that the file itself cannot say, so the build does not name them as unloaded.
123
128
  * @property {(file: string, cwd: string) => {name: string, reason: string} | null} [missingSource] - For a source file that is not there, this group's way to write it again, or null.
124
129
  * @property {(options: {targetPath?: string, overwrite?: boolean, cwd?: string}) => import('../../../api/theme/theme.type.mjs').ThemeTemplateResponse} [template] - This group's template write, in place of `themeTemplate`.
125
130
  */
@@ -629,6 +634,7 @@ function printThemeApp(result) {
629
634
  'stylesheet',
630
635
  'fontStylesheet',
631
636
  'source',
637
+ 'mode',
632
638
  ],
633
639
  layout: 'stacked',
634
640
  }),
@@ -641,6 +647,7 @@ function printThemeApp(result) {
641
647
  slug: change.slug,
642
648
  changed: change.changed,
643
649
  firstAdd: change.firstAdd,
650
+ ...(change.wireModes ? {wireModes: true} : {}),
644
651
  },
645
652
  ],
646
653
  {
@@ -651,20 +658,40 @@ function printThemeApp(result) {
651
658
  'slug',
652
659
  'changed',
653
660
  'firstAdd',
661
+ 'wireModes',
654
662
  ],
655
663
  layout: 'stacked',
656
664
  },
657
665
  ),
658
666
  );
659
667
  for (const note of result.data.notes ?? []) emit(text(`[note] ${note}`));
660
- if (!change.firstAdd) return;
661
668
  const stem = path.basename(modulePath, path.extname(modulePath));
669
+ if (!change.firstAdd) {
670
+ // The module now lists one-mode themes' modes: the app's wiring, made
671
+ // without them, passes the selected theme's mode from now on.
672
+ if (change.wireModes)
673
+ emit(
674
+ text(
675
+ "The theme module now exports themeModes. Pass the selected theme's mode to Theme in the app root:",
676
+ ),
677
+ code(
678
+ "import {Theme} from '@astryxdesign/core/theme';\n" +
679
+ `import {themes, defaultThemeSlug, themeModes} from './${stem}';\n\n` +
680
+ "<Theme theme={themes[defaultThemeSlug]} mode={themeModes[defaultThemeSlug] ?? 'system'}>\n <App />\n</Theme>",
681
+ ),
682
+ );
683
+ return;
684
+ }
685
+ // With a theme of one color mode added, the generated module lists each
686
+ // such theme's mode in `themeModes`, and the wiring passes the selected
687
+ // theme's (none for a two-mode theme, which follows the system).
688
+ const modes = result.data.themes.some(t => t.mode);
662
689
  emit(
663
690
  text('Wire the generated module once in the app root:'),
664
691
  code(
665
692
  "import {Theme} from '@astryxdesign/core/theme';\n" +
666
- `import {themes, defaultThemeSlug} from './${stem}';\n\n` +
667
- '<Theme theme={themes[defaultThemeSlug]}>\n <App />\n</Theme>',
693
+ `import {themes, defaultThemeSlug${modes ? ', themeModes' : ''}} from './${stem}';\n\n` +
694
+ `<Theme theme={themes[defaultThemeSlug]}${modes ? " mode={themeModes[defaultThemeSlug] ?? 'system'}" : ''}>\n <App />\n</Theme>`,
668
695
  ),
669
696
  );
670
697
  }
@@ -996,6 +1023,28 @@ function registerThemeCommands(theme, program, docs, words) {
996
1023
  const rewrite = looksGlobby
997
1024
  ? null
998
1025
  : (words.missingSource?.(entry.file, process.cwd()) ?? null);
1026
+ // A file another command generates, gone from a folder whose other
1027
+ // files carry that command's mark: that command writes it again; a
1028
+ // blank theme template is no way back.
1029
+ const by =
1030
+ rewrite || looksGlobby
1031
+ ? null
1032
+ : generatedSourceCommand(entry.filePath);
1033
+ if (by)
1034
+ return cliError(
1035
+ `File not found: ${entry.filePath}. It is a generated file: the files beside it are written by ${by}, so rebuild it with the command that made it.`,
1036
+ {
1037
+ code: ERROR_CODES.ERR_FILE_NOT_FOUND,
1038
+ suggestions: /^astryx(\s|$)/.test(by)
1039
+ ? [
1040
+ {
1041
+ name: `${getCliInvocation(process.cwd())} ${by.replace(/^astryx\s*/, '')}`.trim(),
1042
+ reason: 'the command that writes these files',
1043
+ },
1044
+ ]
1045
+ : [],
1046
+ },
1047
+ );
999
1048
  return cliError(`File not found: ${entry.filePath}`, {
1000
1049
  code: ERROR_CODES.ERR_FILE_NOT_FOUND,
1001
1050
  suggestions: rewrite
@@ -1229,7 +1278,12 @@ function registerThemeCommands(theme, program, docs, words) {
1229
1278
  iconsSpecifier: options.iconsSpecifier,
1230
1279
  out: options.out,
1231
1280
  });
1232
- if (refused) return themeError(refused, words, buildFallback);
1281
+ if (refused)
1282
+ return themeError(
1283
+ (await words.follow?.(refused, process.cwd())) ?? refused,
1284
+ words,
1285
+ buildFallback,
1286
+ );
1233
1287
 
1234
1288
  if (options.family) {
1235
1289
  try {
@@ -1308,6 +1362,48 @@ function registerThemeCommands(theme, program, docs, words) {
1308
1362
  const writes = [];
1309
1363
  const log = logger.log;
1310
1364
  const warn = logger.warn;
1365
+ // A group may know fonts the app loads that the theme file cannot
1366
+ // say (the editor's app copy stylesheet): those are not named as
1367
+ // unloaded, in the notices, the trailer or the full help.
1368
+ const loads =
1369
+ (await words.loadedFonts?.(entry.file, process.cwd())) ?? null;
1370
+ /** @param {string} msg */
1371
+ const namesOnlyLoaded = msg => {
1372
+ // The families the notice names: on its first line, after the
1373
+ // theme's own name.
1374
+ const line =
1375
+ msg
1376
+ .split('\n')
1377
+ .find(l => /not load/.test(l))
1378
+ ?.replace(/^.*?(names fonts it does not load:|Font )/, '') ?? '';
1379
+ const fonts = [...line.matchAll(/"([^"]+)"/g)].map(m => m[1]);
1380
+ return (
1381
+ Boolean(loads) && fonts.length > 0 && fonts.every(f => loads?.(f))
1382
+ );
1383
+ };
1384
+ // A check whose result a group may still fail holds its lines
1385
+ // until the group has looked.
1386
+ /** @type {Array<string | undefined> | null} */
1387
+ let held = null;
1388
+ if (options.check && words.extraData && !deferred) {
1389
+ held = [];
1390
+ logger.log = (/** @type {string | undefined} */ message) => {
1391
+ held?.push(message);
1392
+ };
1393
+ }
1394
+ if (loads && !deferred && !held) {
1395
+ logger.log = (/** @type {string | undefined} */ message) => {
1396
+ if (
1397
+ typeof message === 'string' &&
1398
+ /names fonts it does not load|named by this theme but not loaded/.test(
1399
+ message,
1400
+ ) &&
1401
+ namesOnlyLoaded(message)
1402
+ )
1403
+ return;
1404
+ log.call(logger, message);
1405
+ };
1406
+ }
1311
1407
  if (deferred) {
1312
1408
  logger.log = (/** @type {string | undefined} */ message) => {
1313
1409
  lines.push(() => log.call(logger, message));
@@ -1327,6 +1423,7 @@ function registerThemeCommands(theme, program, docs, words) {
1327
1423
  claimedOutputs,
1328
1424
  deferredWrites: deferred ? writes : undefined,
1329
1425
  commandWords: words,
1426
+ colorModes: words.colorModes?.(entry.file, process.cwd()) ?? null,
1330
1427
  };
1331
1428
  let result;
1332
1429
  if (report) {
@@ -1338,6 +1435,19 @@ function registerThemeCommands(theme, program, docs, words) {
1338
1435
  handOff,
1339
1436
  );
1340
1437
  result = built.receipt;
1438
+ if (loads && built.trailer) {
1439
+ const named = (/** @type {string} */ msg) =>
1440
+ built.trailer?.unloadedFonts.some(
1441
+ (/** @type {string} */ f) =>
1442
+ loads(f) && msg.includes(`"${f}"`),
1443
+ ) ?? false;
1444
+ built.trailer.fontNotices = built.trailer.fontNotices.filter(
1445
+ (/** @type {string} */ m) => !named(m),
1446
+ );
1447
+ built.trailer.unloadedFonts = built.trailer.unloadedFonts.filter(
1448
+ (/** @type {string} */ f) => !loads(f),
1449
+ );
1450
+ }
1341
1451
  if (built.trailer) trailers.push(built.trailer);
1342
1452
  if (compact && result?.type === 'theme.build') {
1343
1453
  const {outputs, sizeKB, tokenCount, componentCount} = result.data;
@@ -1360,6 +1470,36 @@ function registerThemeCommands(theme, program, docs, words) {
1360
1470
  }
1361
1471
  logger.log = log;
1362
1472
  logger.warn = warn;
1473
+ const data = /** @type {any} */ (result)?.data;
1474
+ if (loads && data && Array.isArray(data.notices))
1475
+ data.notices = data.notices.filter(
1476
+ (/** @type {string} */ m) =>
1477
+ !(
1478
+ /named by this theme but not loaded/.test(m) &&
1479
+ namesOnlyLoaded(m)
1480
+ ),
1481
+ );
1482
+ // A group may add to a build's result (the editor's app copy:
1483
+ // what keeps it behind, and in a check whether it is current).
1484
+ const extra = await words.extraData?.(entry.file, process.cwd(), {
1485
+ check: Boolean(options.check),
1486
+ upToDate: /** @type {any} */ (result)?.data?.upToDate,
1487
+ });
1488
+ if (extra && result?.data) Object.assign(result.data, extra);
1489
+ // A check the group failed says so where the check said ok.
1490
+ if (held) {
1491
+ logger.log = log;
1492
+ for (const line of held)
1493
+ log.call(
1494
+ logger,
1495
+ extra?.upToDate === false &&
1496
+ typeof line === 'string' &&
1497
+ /^\s*\[ok\]/.test(line)
1498
+ ? `[fail] ${String(extra.appCopyStale ?? 'not up to date')}`
1499
+ : line,
1500
+ );
1501
+ held = null;
1502
+ }
1363
1503
  results.push({file: entry.file, receipt: result ?? null});
1364
1504
  if (deferred) built.push({writes, lines});
1365
1505
  if (
@@ -1373,6 +1513,8 @@ function registerThemeCommands(theme, program, docs, words) {
1373
1513
  } catch (e) {
1374
1514
  logger.log = log;
1375
1515
  logger.warn = warn;
1516
+ for (const line of held ?? []) log.call(logger, line);
1517
+ held = null;
1376
1518
  const err =
1377
1519
  /** @type {import('../../../api/error.mjs').AstryxError} */ (e);
1378
1520
  // Stop at the first failure, as a shell loop under `set -e` does.
@@ -1401,7 +1543,13 @@ function registerThemeCommands(theme, program, docs, words) {
1401
1543
  if (report && compact) printCompactTrailer(trailers);
1402
1544
  else if (report) printBatchTrailer(trailers);
1403
1545
  if (entries.length > 1) err.message = `${entry.file}: ${err.message}`;
1404
- return themeError(err, words, buildFallback);
1546
+ return themeError(
1547
+ entries.length === 1
1548
+ ? ((await words.follow?.(err, process.cwd())) ?? err)
1549
+ : err,
1550
+ words,
1551
+ buildFallback,
1552
+ );
1405
1553
  }
1406
1554
  }
1407
1555
  if (deferred) {
@@ -22,6 +22,44 @@ import {doc as upgradeCommand} from './upgrade.doc.mjs';
22
22
  import {doc as upgradeFn} from '../../../api/upgrade/upgrade.doc.mjs';
23
23
  import {NO_RESULT_SET, resultSet} from '../../../foundation/debug/index.mjs';
24
24
 
25
+ /**
26
+ * The codemod list as text: a heading that says how many codemods there are
27
+ * and names their package when they share one, then each version with one
28
+ * line per codemod, its name and title, and `(optional)` on a codemod that
29
+ * runs only on request. When codemods come from more than one package, every
30
+ * line names its package.
31
+ * @param {import('../../../api/upgrade/upgrade.type.mjs').UpgradeListResponse['data']} codemods
32
+ * @returns {import('../formatters/index.mjs').Block[]}
33
+ */
34
+ function codemodListBlocks(codemods) {
35
+ const packages = new Set(codemods.map(c => c.package));
36
+ const shared = packages.size === 1 ? [...packages][0] : null;
37
+ /** @type {Map<string, typeof codemods>} */
38
+ const byVersion = new Map();
39
+ for (const c of codemods) {
40
+ byVersion.set(c.version, [...(byVersion.get(c.version) ?? []), c]);
41
+ }
42
+ const count = `${codemods.length} codemod${codemods.length === 1 ? '' : 's'}`;
43
+ return [
44
+ section(
45
+ 'Available codemods',
46
+ `${count}${shared ? ` from ${shared}` : ''}, oldest first`,
47
+ ),
48
+ ...[...byVersion].flatMap(([version, group]) => [
49
+ section(version),
50
+ records(
51
+ group.map(c => ({
52
+ name: c.name,
53
+ title: c.title,
54
+ optional: c.optional ? '(optional)' : undefined,
55
+ package: shared ? undefined : c.package,
56
+ })),
57
+ {fields: ['name', 'title', 'optional', 'package'], layout: 'inline'},
58
+ ),
59
+ ]),
60
+ ];
61
+ }
62
+
25
63
  /**
26
64
  * @param {import('commander').Command} program
27
65
  */
@@ -79,13 +117,10 @@ export function registerUpgrade(program) {
79
117
  if (json) jsonOut(result);
80
118
  else if (result.type === 'upgrade.list') {
81
119
  // Render the list from the result, not the API logger, so the text
82
- // carries the same fields the JSON does (name, title, version, optional).
83
- emit(
84
- section('Available codemods'),
85
- records(result.data, {
86
- fields: ['name', 'package', 'title', 'version', 'optional'],
87
- }),
88
- );
120
+ // carries the same fields the JSON does. One line per codemod under
121
+ // its version: the list gains a line per codemod each release, not a
122
+ // five-line record.
123
+ emit(...codemodListBlocks(result.data));
89
124
  }
90
125
 
91
126
  const registrySummary =
@@ -595,7 +595,7 @@ export async function createProgram({argv} = {}) {
595
595
 
596
596
  program
597
597
  .name('astryx')
598
- .description('Design system CLI — components, themes, and tooling\n\nMaking or changing a theme? Use the experimental theme editor: astryx experimental theme editor new <name> --like neutral, then editor set / editor how "<what you want>"; after each change look at it with astryx experimental theme editor show <name> --png (writes PNGs, changes nothing in the app): a theme change is not done until you have looked. No app yet: astryx experimental theme preview app <dir>.')
598
+ .description('Design system CLI — components, themes, and tooling\n\nMaking or changing a theme? Use the experimental theme editor: astryx experimental theme editor new <name> --like neutral, then editor set / editor how "<what you want>"; after each change look at it with astryx experimental theme editor show <name> --png (takes pictures of real components): a theme change is not done until you have looked. No app yet: astryx experimental theme preview app <dir>.')
599
599
  .version(pkg.version)
600
600
  // These four change only the reads named in their text; every other
601
601
  // command ignores them.