@astryxdesign/cli 0.7.18-canary.gfca8508 → 0.7.18

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 (341) hide show
  1. package/CHANGELOG.md +185 -19
  2. package/README.md +19 -19
  3. package/api/component/_adapter.d.mts +2 -1
  4. package/api/component/_adapter.mjs +2 -1
  5. package/api/docs/_adapter.d.mts +6 -5
  6. package/api/docs/_adapter.mjs +36 -5
  7. package/api/doctor/_adapter.d.mts +6 -3
  8. package/api/doctor/_adapter.mjs +13 -5
  9. package/api/doctor/doctor.mjs +2 -2
  10. package/api/doctor/font-packages.d.mts +36 -0
  11. package/api/doctor/font-packages.mjs +124 -0
  12. package/api/doctor/theme-checks.mjs +110 -49
  13. package/api/experimental.d.mts +0 -2
  14. package/api/experimental.mjs +0 -12
  15. package/api/icon/_adapter.d.mts +1 -1
  16. package/api/icon/_adapter.mjs +1 -0
  17. package/api/icon/_authoring.mjs +17 -8
  18. package/api/icon/_default-look.mjs +15 -15
  19. package/api/icon/add/add.mjs +9 -4
  20. package/api/icon/exportIconIndex.doc.mjs +1 -1
  21. package/api/icon/icon.doc.mjs +1 -1
  22. package/api/icon/icon.type.d.mts +33 -33
  23. package/api/icon/icon.type.mjs +45 -45
  24. package/api/icon/iconAdd.doc.mjs +1 -1
  25. package/api/icon/iconNewSet.doc.mjs +3 -3
  26. package/api/icon/iconUse.doc.mjs +5 -5
  27. package/api/icon/rankIconIndex.doc.mjs +1 -1
  28. package/api/icon/use/use.mjs +4 -4
  29. package/api/init/run/run.mjs +0 -1
  30. package/api/integration/add-helpers.mjs +1 -1
  31. package/api/render/_adapter.mjs +7 -1
  32. package/api/search/ORDERING.md +1 -1
  33. package/api/search/_candidate-score.mjs +20 -0
  34. package/api/search/_words.d.mts +8 -0
  35. package/api/search/_words.mjs +15 -0
  36. package/api/template/template.type.d.mts +2 -2
  37. package/api/template/template.type.mjs +2 -2
  38. package/api/theme/_adapter.mjs +19 -11
  39. package/api/theme/build/build.d.mts +19 -51
  40. package/api/theme/build/build.mjs +195 -189
  41. package/api/theme/build/font-warning.d.mts +19 -2
  42. package/api/theme/build/font-warning.mjs +46 -5
  43. package/api/theme/generateTonalPalette.doc.mjs +1 -1
  44. package/api/theme/palette/generate/derive-look.mjs +108 -37
  45. package/api/theme/palette/generate/mapping.mjs +2 -0
  46. package/api/theme/template/template.d.mts +0 -17
  47. package/api/theme/template/template.mjs +1 -42
  48. package/api/theme/theme.type.d.mts +5 -4
  49. package/api/theme/theme.type.mjs +5 -4
  50. package/api/theme/themePaletteGenerate.doc.mjs +1 -1
  51. package/api/theme/themeRemove.doc.mjs +1 -1
  52. package/assets/codemods/transforms/v0.7.0/preserve-bottom-sheet-content-padding.mjs +3 -1
  53. package/assets/component-list.generated.json +1 -1
  54. package/assets/discover/official-packages.json +26 -2
  55. package/assets/docs/author-a-theme.doc.mjs +6 -5
  56. package/assets/docs/browser-support.doc.mjs +1 -0
  57. package/assets/docs/icons.doc.mjs +8 -7
  58. package/assets/docs/motion.doc.mjs +46 -0
  59. package/assets/docs/theme.doc.dense.mjs +6 -17
  60. package/assets/docs/theme.doc.mjs +6 -16
  61. package/assets/docs/theme.doc.zh.mjs +6 -16
  62. package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
  63. package/assets/docs/tree/font-setup.doc.mjs +30 -0
  64. package/assets/docs/tree/icon-sets.doc.mjs +1 -1
  65. package/assets/docs/tree/template-icons.doc.mjs +3 -3
  66. package/assets/docs/tree/tokens-color.doc.mjs +5 -0
  67. package/assets/docs/tree/tokens.doc.mjs +4 -3
  68. package/assets/docs/tree/updates.doc.mjs +1 -1
  69. package/assets/docs-routes.generated.json +1 -1
  70. package/assets/docs.generated.json +2 -2
  71. package/assets/icons/definitions/drag.doc.mjs +1 -0
  72. package/assets/search-catalog.generated.json +2 -2
  73. package/assets/self-audit.generated.json +1 -1
  74. package/assets/templates/blocks/components/Card/SelectableCardElevated.doc.mjs +1 -1
  75. package/assets/templates/blocks/components/Card/SelectableCardElevated.tsx +20 -10
  76. package/assets/templates/blocks/components/Card/SelectableCardShowcase.doc.mjs +1 -1
  77. package/assets/templates/blocks/components/Card/SelectableCardShowcase.tsx +36 -16
  78. package/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx +6 -0
  79. package/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx +6 -0
  80. package/assets/templates/blocks/components/Hooks/useIndicatorFocusRingHookUsage.doc.mjs +14 -0
  81. package/assets/templates/blocks/components/Hooks/useIndicatorFocusRingHookUsage.tsx +63 -0
  82. package/assets/templates/blocks/components/Hooks/useLongPressHookUsage.doc.mjs +29 -0
  83. package/assets/templates/blocks/components/Hooks/useLongPressHookUsage.tsx +237 -0
  84. package/assets/templates/blocks/components/SideNav/SideNavShowcase.tsx +10 -72
  85. package/assets/templates/blocks/components/SideNav/SideNavWithHeaderMenu.doc.mjs +1 -1
  86. package/assets/templates/blocks/components/SideNav/SideNavWithHeaderMenu.tsx +7 -7
  87. package/assets/templates/blocks/components/Table/TableCustomRowTable.doc.mjs +14 -0
  88. package/assets/templates/blocks/components/Table/TableCustomRowTable.tsx +96 -0
  89. package/assets/templates/components.generated.json +1 -1
  90. package/assets/templates/pages/ai-chat-landing/page.tsx +4 -0
  91. package/assets/templates/pages/dashboard-scorecard/page.tsx +26 -7
  92. package/assets/templates/pages/editor/page.tsx +13 -3
  93. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +2 -2
  94. package/assets/templates/themes/butter/butterTheme.ts +12 -10
  95. package/assets/templates/themes/butter/icons.tsx +2 -0
  96. package/assets/templates/themes/chocolate/chocolateTheme.ts +1 -0
  97. package/assets/templates/themes/chocolate/icons.tsx +2 -0
  98. package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +1 -1
  99. package/assets/templates/themes/gothic/gothicTheme.ts +1 -0
  100. package/assets/templates/themes/gothic/icons.tsx +2 -0
  101. package/assets/templates/themes/matcha/icons.tsx +2 -0
  102. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +2 -2
  103. package/assets/templates/themes/matcha/matchaTheme.ts +1 -0
  104. package/assets/templates/themes/neutral/icons.tsx +2 -0
  105. package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +2 -2
  106. package/assets/templates/themes/neutral/neutralTheme.ts +1 -0
  107. package/assets/templates/themes/stone/icons.tsx +2 -0
  108. package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +1 -1
  109. package/assets/templates/themes/stone/stoneTheme.ts +1 -0
  110. package/assets/templates/themes/y2k/icons.tsx +2 -0
  111. package/assets/templates/themes/y2k/y2kTheme.ts +1 -0
  112. package/assets/theme.template.ts +9 -5
  113. package/authoring/config/parse.mjs +1 -1
  114. package/authoring/doctypes/base/type.ts +2 -3
  115. package/authoring/doctypes/component/component.doc.mjs +1 -1
  116. package/authoring/doctypes/icon-set/icon-names.mjs +1 -0
  117. package/authoring/integration/integration.doc.mjs +1 -1
  118. package/authoring/integration/type.ts +1 -1
  119. package/clients/cli/build-id.generated.json +1 -1
  120. package/clients/cli/commands/experimental/icon.mjs +7 -7
  121. package/clients/cli/commands/experimental/index.mjs +0 -5
  122. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +2 -2
  123. package/clients/cli/commands/experimental-icon-use.doc.mjs +4 -4
  124. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  125. package/clients/cli/commands/experimental.doc.mjs +2 -6
  126. package/clients/cli/commands/template.mjs +1 -1
  127. package/clients/cli/commands/theme-build.doc.mjs +8 -1
  128. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -1
  129. package/clients/cli/commands/theme-remove.doc.mjs +1 -1
  130. package/clients/cli/commands/theme.doc.mjs +1 -11
  131. package/clients/cli/commands/theme.mjs +110 -475
  132. package/clients/cli/commands.generated.json +1 -1
  133. package/clients/cli/index.mjs +4 -34
  134. package/clients/cli/lib/base-gate.mjs +2 -3
  135. package/clients/cli/lib/cli-error.mjs +8 -72
  136. package/clients/cli/lib/define-command.mjs +0 -19
  137. package/clients/cli/lib/json-shim.mjs +11 -633
  138. package/clients/cli/lib/manifest.mjs +0 -4
  139. package/clients/cli/lib/stray-option.mjs +1 -2
  140. package/clients/cli/manifest.generated.json +1 -1
  141. package/foundation/agent-docs/agent-docs.mjs +1 -1
  142. package/foundation/color/css-color.mjs +2 -3
  143. package/foundation/discovery/app-layout.d.mts +13 -0
  144. package/foundation/discovery/app-layout.mjs +35 -0
  145. package/foundation/discovery/fixture-refs.d.mts +51 -0
  146. package/foundation/discovery/fixture-refs.mjs +351 -0
  147. package/foundation/discovery/icon-definition-discovery.mjs +1 -1
  148. package/foundation/discovery/icon-ranking.mjs +2 -2
  149. package/foundation/discovery/icon-set-checks.mjs +1 -1
  150. package/foundation/discovery/icon-set-discovery.mjs +1 -1
  151. package/foundation/discovery/icon-set-writer.d.mts +24 -7
  152. package/foundation/discovery/icon-set-writer.mjs +66 -22
  153. package/foundation/discovery/static-descriptor.d.mts +49 -0
  154. package/foundation/discovery/static-descriptor.mjs +548 -0
  155. package/foundation/discovery/template-adapter.d.mts +0 -47
  156. package/foundation/discovery/template-adapter.mjs +1 -333
  157. package/foundation/discovery/theme-discovery.d.mts +6 -47
  158. package/foundation/discovery/theme-discovery.mjs +15 -537
  159. package/foundation/doc-compiler/import.mjs +1 -1
  160. package/foundation/env/user-dirs.d.mts +5 -2
  161. package/foundation/env/user-dirs.mjs +12 -5
  162. package/foundation/fonts/next-font.d.mts +26 -0
  163. package/foundation/fonts/next-font.mjs +149 -0
  164. package/foundation/fs/empty-folder.mjs +2 -2
  165. package/foundation/fs/read-record.mjs +11 -4
  166. package/foundation/pictures/pictures.d.mts +1 -45
  167. package/foundation/pictures/pictures.mjs +8 -8
  168. package/foundation/release/folder-lock.mjs +3 -2
  169. package/foundation/render/cut-short.d.mts +2 -2
  170. package/foundation/render/cut-short.mjs +2 -2
  171. package/foundation/render/drawn-contrast.d.mts +2 -2
  172. package/foundation/render/drawn-contrast.mjs +2 -2
  173. package/foundation/render/font-probe.d.mts +2 -2
  174. package/foundation/render/font-probe.mjs +2 -2
  175. package/foundation/render/layers.mjs +1 -2
  176. package/foundation/render/package-resolve-hooks.d.mts +25 -5
  177. package/foundation/render/package-resolve-hooks.mjs +77 -14
  178. package/foundation/render/page-worker.mjs +24 -12
  179. package/foundation/render/part-boxes.d.mts +2 -3
  180. package/foundation/render/part-boxes.mjs +2 -3
  181. package/foundation/render/picture-chrome.mjs +5 -0
  182. package/foundation/render/render-page.d.mts +1 -1
  183. package/foundation/render/render-page.mjs +4 -5
  184. package/foundation/render/single-copy-hooks.d.mts +2 -0
  185. package/foundation/render/single-copy-hooks.mjs +2 -0
  186. package/foundation/response/error-codes.doc.mjs +14 -14
  187. package/foundation/response/error-codes.mjs +13 -13
  188. package/foundation/response/response-types.doc.mjs +7 -68
  189. package/foundation/runtime/css-tree.mjs +2 -2
  190. package/foundation/runtime/word-table.d.mts +1 -1
  191. package/foundation/runtime/word-table.mjs +1 -1
  192. package/foundation/suggest/other-command.d.mts +52 -15
  193. package/foundation/suggest/other-command.mjs +168 -45
  194. package/foundation/text/suggest-order.d.mts +7 -0
  195. package/foundation/text/suggest-order.mjs +1 -1
  196. package/package.json +7 -8
  197. package/api/theme-edit/_adapter.d.mts +0 -228
  198. package/api/theme-edit/_adapter.mjs +0 -2025
  199. package/api/theme-edit/_catalog.d.mts +0 -172
  200. package/api/theme-edit/_catalog.mjs +0 -806
  201. package/api/theme-edit/_check.d.mts +0 -391
  202. package/api/theme-edit/_check.mjs +0 -9370
  203. package/api/theme-edit/_color.d.mts +0 -135
  204. package/api/theme-edit/_color.mjs +0 -480
  205. package/api/theme-edit/_compiler.d.mts +0 -77
  206. package/api/theme-edit/_compiler.mjs +0 -1053
  207. package/api/theme-edit/_context.d.mts +0 -399
  208. package/api/theme-edit/_context.mjs +0 -1778
  209. package/api/theme-edit/_css.d.mts +0 -169
  210. package/api/theme-edit/_css.mjs +0 -1167
  211. package/api/theme-edit/_edit.d.mts +0 -167
  212. package/api/theme-edit/_edit.mjs +0 -11220
  213. package/api/theme-edit/_how-commands.d.mts +0 -315
  214. package/api/theme-edit/_how-commands.mjs +0 -1664
  215. package/api/theme-edit/_how-question.d.mts +0 -341
  216. package/api/theme-edit/_how-question.mjs +0 -33339
  217. package/api/theme-edit/_how-sides.d.mts +0 -22
  218. package/api/theme-edit/_how-sides.mjs +0 -173
  219. package/api/theme-edit/_how-steps.d.mts +0 -42
  220. package/api/theme-edit/_how-steps.mjs +0 -208
  221. package/api/theme-edit/_how-values.d.mts +0 -29
  222. package/api/theme-edit/_how-values.mjs +0 -111
  223. package/api/theme-edit/_how-words.d.mts +0 -15
  224. package/api/theme-edit/_how-words.mjs +0 -239
  225. package/api/theme-edit/_how.d.mts +0 -55
  226. package/api/theme-edit/_how.mjs +0 -2388
  227. package/api/theme-edit/_importers.d.mts +0 -38
  228. package/api/theme-edit/_importers.mjs +0 -188
  229. package/api/theme-edit/_marks.d.mts +0 -39
  230. package/api/theme-edit/_marks.mjs +0 -67
  231. package/api/theme-edit/_missed.d.mts +0 -56
  232. package/api/theme-edit/_missed.mjs +0 -1128
  233. package/api/theme-edit/_name-rule.d.mts +0 -11
  234. package/api/theme-edit/_name-rule.mjs +0 -12
  235. package/api/theme-edit/_normal.d.mts +0 -365
  236. package/api/theme-edit/_normal.mjs +0 -1978
  237. package/api/theme-edit/_overview.d.mts +0 -9
  238. package/api/theme-edit/_overview.mjs +0 -293
  239. package/api/theme-edit/_palette.d.mts +0 -616
  240. package/api/theme-edit/_palette.mjs +0 -2776
  241. package/api/theme-edit/_part-pieces.d.mts +0 -54
  242. package/api/theme-edit/_part-pieces.mjs +0 -179
  243. package/api/theme-edit/_part-words.d.mts +0 -39
  244. package/api/theme-edit/_part-words.mjs +0 -242
  245. package/api/theme-edit/_parts.d.mts +0 -402
  246. package/api/theme-edit/_parts.mjs +0 -2322
  247. package/api/theme-edit/_picture-traits.d.mts +0 -259
  248. package/api/theme-edit/_picture-traits.mjs +0 -1030
  249. package/api/theme-edit/_png.d.mts +0 -94
  250. package/api/theme-edit/_png.mjs +0 -479
  251. package/api/theme-edit/_preview-app.d.mts +0 -172
  252. package/api/theme-edit/_preview-app.mjs +0 -6430
  253. package/api/theme-edit/_preview.d.mts +0 -484
  254. package/api/theme-edit/_preview.mjs +0 -2775
  255. package/api/theme-edit/_project.d.mts +0 -207
  256. package/api/theme-edit/_project.mjs +0 -643
  257. package/api/theme-edit/_resolved.d.mts +0 -46
  258. package/api/theme-edit/_resolved.mjs +0 -800
  259. package/api/theme-edit/_set-line.d.mts +0 -29
  260. package/api/theme-edit/_set-line.mjs +0 -100
  261. package/api/theme-edit/_settings.d.mts +0 -2426
  262. package/api/theme-edit/_settings.mjs +0 -18449
  263. package/api/theme-edit/_tables.d.mts +0 -227
  264. package/api/theme-edit/_tables.mjs +0 -1128
  265. package/api/theme-edit/_text-looks.d.mts +0 -78
  266. package/api/theme-edit/_text-looks.mjs +0 -376
  267. package/api/theme-edit/_vet.d.mts +0 -50
  268. package/api/theme-edit/_vet.mjs +0 -166
  269. package/api/theme-edit/how/how.d.mts +0 -17
  270. package/api/theme-edit/how/how.mjs +0 -28
  271. package/api/theme-edit/new/new.d.mts +0 -11
  272. package/api/theme-edit/new/new.mjs +0 -22
  273. package/api/theme-edit/preview-add/preview-add.d.mts +0 -14
  274. package/api/theme-edit/preview-add/preview-add.mjs +0 -25
  275. package/api/theme-edit/preview-app/preview-app.d.mts +0 -13
  276. package/api/theme-edit/preview-app/preview-app.mjs +0 -24
  277. package/api/theme-edit/preview-list/preview-list.d.mts +0 -10
  278. package/api/theme-edit/preview-list/preview-list.mjs +0 -21
  279. package/api/theme-edit/preview-remove/preview-remove.d.mts +0 -12
  280. package/api/theme-edit/preview-remove/preview-remove.mjs +0 -23
  281. package/api/theme-edit/set/set.d.mts +0 -13
  282. package/api/theme-edit/set/set.mjs +0 -24
  283. package/api/theme-edit/show/show.d.mts +0 -13
  284. package/api/theme-edit/show/show.mjs +0 -24
  285. package/api/theme-edit/theme-edit.d.mts +0 -12
  286. package/api/theme-edit/theme-edit.mjs +0 -36
  287. package/api/theme-edit/theme-edit.type.d.mts +0 -730
  288. package/api/theme-edit/theme-edit.type.mjs +0 -342
  289. package/api/theme-edit/themeEditHow.doc.d.mts +0 -6
  290. package/api/theme-edit/themeEditHow.doc.mjs +0 -105
  291. package/api/theme-edit/themeEditNew.doc.d.mts +0 -5
  292. package/api/theme-edit/themeEditNew.doc.mjs +0 -112
  293. package/api/theme-edit/themeEditPreviewAdd.doc.d.mts +0 -6
  294. package/api/theme-edit/themeEditPreviewAdd.doc.mjs +0 -121
  295. package/api/theme-edit/themeEditPreviewApp.doc.d.mts +0 -6
  296. package/api/theme-edit/themeEditPreviewApp.doc.mjs +0 -87
  297. package/api/theme-edit/themeEditPreviewList.doc.d.mts +0 -6
  298. package/api/theme-edit/themeEditPreviewList.doc.mjs +0 -62
  299. package/api/theme-edit/themeEditPreviewRemove.doc.d.mts +0 -6
  300. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +0 -96
  301. package/api/theme-edit/themeEditSet.doc.d.mts +0 -6
  302. package/api/theme-edit/themeEditSet.doc.mjs +0 -175
  303. package/api/theme-edit/themeEditShow.doc.d.mts +0 -6
  304. package/api/theme-edit/themeEditShow.doc.mjs +0 -118
  305. package/api/theme-edit/themeEditUndo.doc.d.mts +0 -6
  306. package/api/theme-edit/themeEditUndo.doc.mjs +0 -133
  307. package/api/theme-edit/undo/undo.d.mts +0 -13
  308. package/api/theme-edit/undo/undo.mjs +0 -24
  309. package/assets/preview-app/README.md +0 -6
  310. package/assets/preview-app/css.d.ts +0 -5
  311. package/assets/preview-app/gitignore +0 -4
  312. package/assets/preview-app/next.config.mjs +0 -12
  313. package/assets/preview-app/package.json +0 -24
  314. package/assets/preview-app/src/app/globals.css +0 -6
  315. package/assets/preview-app/src/app/layout.tsx +0 -21
  316. package/assets/preview-app/src/app/page.tsx +0 -94
  317. package/assets/preview-app/src/app/providers.tsx +0 -16
  318. package/assets/preview-app/tsconfig.json +0 -27
  319. package/clients/cli/commands/experimental/theme.mjs +0 -2990
  320. package/clients/cli/commands/experimental-theme-add.doc.mjs +0 -80
  321. package/clients/cli/commands/experimental-theme-compile.doc.mjs +0 -98
  322. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +0 -196
  323. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +0 -174
  324. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +0 -139
  325. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +0 -77
  326. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +0 -105
  327. package/clients/cli/commands/experimental-theme-editor.doc.mjs +0 -49
  328. package/clients/cli/commands/experimental-theme-eject.doc.mjs +0 -72
  329. package/clients/cli/commands/experimental-theme-list.doc.mjs +0 -49
  330. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +0 -88
  331. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +0 -61
  332. package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +0 -48
  333. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +0 -59
  334. package/clients/cli/commands/experimental-theme-preview.doc.mjs +0 -41
  335. package/clients/cli/commands/experimental-theme-remove.doc.mjs +0 -57
  336. package/clients/cli/commands/experimental-theme-targets.doc.mjs +0 -62
  337. package/clients/cli/commands/experimental-theme-template.doc.mjs +0 -63
  338. package/clients/cli/commands/experimental-theme-use.doc.mjs +0 -57
  339. package/clients/cli/commands/experimental-theme.doc.mjs +0 -60
  340. package/foundation/fonts/fontsource-families.generated.d.mts +0 -5
  341. package/foundation/fonts/fontsource-families.generated.mjs +0 -2110
@@ -47,7 +47,6 @@ import {
47
47
  toErrorEnvelope,
48
48
  } from '../../../foundation/response/json.mjs';
49
49
  import {answeredBy} from '../../../foundation/release/run-context.mjs';
50
- import {unknownSubcommandSuggestions} from './cli-error.mjs';
51
50
  import {
52
51
  answerBareSubcommand,
53
52
  answersBareSubcommands,
@@ -59,18 +58,13 @@ import {
59
58
  recordHelp,
60
59
  recordCommandResult,
61
60
  } from '../../../foundation/debug/index.mjs';
62
- import {
63
- formatCliCommand,
64
- getCliInvocation,
65
- quoteCommandArgument,
66
- } from '../../../foundation/env/package-manager.mjs';
61
+ import {formatCliCommand} from '../../../foundation/env/package-manager.mjs';
67
62
  import {
68
63
  commandAvailable,
69
64
  helpBase,
70
65
  optionAvailable,
71
66
  servedHelpDescription,
72
67
  servedHelpOptionDescription,
73
- servedSubcommands,
74
68
  } from './base-gate.mjs';
75
69
  import {commandPath} from './command-path.mjs';
76
70
 
@@ -213,8 +207,6 @@ function commanderCodeToErrorCode(commanderCode, message) {
213
207
  return ERROR_CODES.ERR_UNKNOWN_COMMAND;
214
208
  case 'commander.unknownOption':
215
209
  return ERROR_CODES.ERR_INVALID_OPTION;
216
- case UNKNOWN_SUBCOMMAND:
217
- return ERROR_CODES.ERR_UNKNOWN_SUBCOMMAND;
218
210
  case 'commander.missingArgument':
219
211
  case 'commander.optionMissingArgument':
220
212
  case 'commander.missingMandatoryOptionValue':
@@ -319,279 +311,6 @@ function applyShimRecursively(cmd) {
319
311
  /** Carries the command Commander rejected from exitOverride to the error handler. */
320
312
  const REJECTED_COMMAND = Symbol.for('astryx.jsonShim.rejectedCommand');
321
313
 
322
- /** A group given a word that is none of its subcommands. */
323
- const UNKNOWN_SUBCOMMAND = 'astryx.unknownSubcommand';
324
-
325
- /**
326
- * The word typed after a group's own words that is none of its
327
- * subcommands, read from the command line; null when there is none.
328
- * @param {any} group
329
- * @returns {string | null}
330
- */
331
- function unknownGroupWord(group) {
332
- const chain = [];
333
- for (let node = group; node?.parent; node = node.parent)
334
- chain.unshift(node.name());
335
- let root = group;
336
- while (root.parent) root = root.parent;
337
- const argv = /** @type {string[]} */ (root.rawArgs ?? process.argv);
338
- const names = group.commands.flatMap((/** @type {any} */ c) => [
339
- c.name(),
340
- ...c.aliases(),
341
- ]);
342
- // The words that are no option, and no option's value: the word after an
343
- // option the group does not read is its value unless it names one of the
344
- // group's subcommands (`preview --theme t`: t is --theme's).
345
- /** @type {string[]} */
346
- const words = [];
347
- const typed = argv.slice(2).map(String);
348
- for (let i = 0; i < typed.length; i++) {
349
- const w = typed[i];
350
- if (!w.startsWith('-')) {
351
- words.push(w);
352
- continue;
353
- }
354
- const next = typed[i + 1];
355
- if (
356
- words.length >= chain.length &&
357
- !w.includes('=') &&
358
- next != null &&
359
- !next.startsWith('-') &&
360
- !names.includes(next)
361
- )
362
- i++;
363
- }
364
- for (let i = 0; i < chain.length; i++) if (words[i] !== chain[i]) return null;
365
- const next = words[chain.length];
366
- return next != null && !names.includes(next) ? next : null;
367
- }
368
-
369
- /**
370
- * Options typed after a group with no subcommand at all (`preview --theme
371
- * t`, `editor --mode light`): each option as typed, with its value, and the
372
- * subcommands that take every one of them; null when a word that is no
373
- * option's value follows (an unknown subcommand) or a subcommand does.
374
- * @param {any} group
375
- * @returns {{group: string, typed: string[], takers: any[]} | null}
376
- */
377
- function optionsWithoutSubcommand(group) {
378
- const chain = [];
379
- for (let node = group; node?.parent; node = node.parent)
380
- chain.unshift(node.name());
381
- let root = group;
382
- while (root.parent) root = root.parent;
383
- const argv = /** @type {string[]} */ (root.rawArgs ?? process.argv)
384
- .slice(2)
385
- .map(String);
386
- let at = 0;
387
- for (const word of chain) {
388
- while (at < argv.length && argv[at] !== word) at++;
389
- if (at === argv.length) return null;
390
- at++;
391
- }
392
- const rest = argv.slice(at);
393
- if (!rest.length || !rest[0].startsWith('-')) return null;
394
- const subs = servedSubcommands(group);
395
- /** @type {string[]} */
396
- const flags = [];
397
- /** @type {string[]} */
398
- const typed = [];
399
- for (let i = 0; i < rest.length; i++) {
400
- const token = rest[i];
401
- // A word that is no option's value: a subcommand or an unknown word,
402
- // which other readers name.
403
- if (!token.startsWith('-')) return null;
404
- const [flag, inline] = token.split(/=(.*)/su);
405
- const program = (root.options ?? []).find(
406
- (/** @type {any} */ o) => o.long === flag || o.short === flag,
407
- );
408
- const next = rest[i + 1];
409
- const value =
410
- inline ??
411
- (next != null &&
412
- !next.startsWith('-') &&
413
- !(program && !(program.required || program.optional)) &&
414
- !subs.some(c => c.name() === next || c.aliases().includes(next))
415
- ? rest[++i]
416
- : undefined);
417
- // The program's own options (`--json`) are read wherever they are.
418
- if (program) continue;
419
- flags.push(flag);
420
- typed.push(
421
- value === undefined ? flag : `${flag} ${quoteCommandArgument(value)}`,
422
- );
423
- }
424
- if (!typed.length) return null;
425
- const takers = subs.filter(c =>
426
- flags.every(f =>
427
- (c.options ?? []).some(
428
- (/** @type {any} */ o) => o.long === f || o.short === f,
429
- ),
430
- ),
431
- );
432
- return {group: chain.join(' '), typed, takers};
433
- }
434
-
435
- /**
436
- * Options typed before a group's real subcommand (`preview --theme t list`,
437
- * `editor --mode light set t accent red`): the subcommand, the options it
438
- * takes (each with its value, where it takes one) and the ones it does not,
439
- * and the command with those it takes moved after it; null when no word after
440
- * the options is one of the group's subcommands. An option's value is never
441
- * read as a subcommand.
442
- * @param {any} group
443
- * @returns {{sub: string, line: string, moved: string[], dropped: string[]} | null}
444
- */
445
- function optionsBeforeSubcommand(group) {
446
- const chain = [];
447
- for (let node = group; node?.parent; node = node.parent)
448
- chain.unshift(node.name());
449
- let root = group;
450
- while (root.parent) root = root.parent;
451
- const argv = /** @type {string[]} */ (root.rawArgs ?? process.argv).slice(2);
452
- // The group's own words, in order, then what follows them.
453
- let at = 0;
454
- for (const word of chain) {
455
- while (at < argv.length && argv[at] !== word) at++;
456
- if (at === argv.length) return null;
457
- at++;
458
- }
459
- const rest = argv.slice(at);
460
- if (!rest.length || !String(rest[0]).startsWith('-')) return null;
461
- const subs = servedSubcommands(group);
462
- /** The command a list of commands names by a word. @param {any[]} list @param {unknown} w */
463
- const named = (list, w) =>
464
- list.find(c => c.name() === w || c.aliases().includes(w));
465
- /** @type {any} */
466
- let sub = null;
467
- let index = -1;
468
- /** The subcommand words from the group's own on (`editor set`). @type {string[]} */
469
- let subWords = [];
470
- let end = -1;
471
- /**
472
- * The command the words from rest[i] on name: a subcommand, into a nested
473
- * group (`theme --mode dark editor set …`) as far as the words go; null
474
- * when rest[i] names none.
475
- * @param {number} i
476
- */
477
- const resolve = i => {
478
- const first = String(rest[i]).startsWith('-') ? null : named(subs, rest[i]);
479
- if (!first) return null;
480
- let target = first;
481
- const words = [first.name()];
482
- let j = i + 1;
483
- while (named(servedSubcommands(target), rest[j])) {
484
- target = named(servedSubcommands(target), rest[j]);
485
- words.push(target.name());
486
- j++;
487
- }
488
- return {target, words, end: j};
489
- };
490
- /** Whether a command takes a flag with a value. @param {any} cmd @param {string} flag */
491
- const takesValue = (cmd, flag) =>
492
- (cmd.options ?? []).some(
493
- (/** @type {any} */ o) =>
494
- (o.long === flag || o.short === flag) && (o.required || o.optional),
495
- );
496
- for (let i = 1; i < rest.length && !sub; i++) {
497
- const found = resolve(i);
498
- if (!found) continue;
499
- // The word straight after an option that this command, or a later one
500
- // named after it, takes with a value is that value (`--on set set t …`,
501
- // `--on show set t …`), never the subcommand.
502
- const prev = String(rest[i - 1]);
503
- if (prev.startsWith('-') && !prev.includes('=')) {
504
- let valued = takesValue(found.target, prev);
505
- for (let k = i + 1; !valued && k < rest.length; k++) {
506
- const later = resolve(k);
507
- if (later && takesValue(later.target, prev)) valued = true;
508
- }
509
- if (valued) continue;
510
- }
511
- sub = found.target;
512
- index = i;
513
- subWords = found.words;
514
- end = found.end;
515
- }
516
- if (!sub) return null;
517
- /** @type {string[]} */
518
- const moved = [];
519
- /** @type {string[]} */
520
- const dropped = [];
521
- // The program's own options (`--json`) are read wherever they are typed:
522
- // never moved, named, or carried into the line.
523
- const own = (/** @type {string} */ flag) =>
524
- (root.options ?? []).find(
525
- (/** @type {any} */ o) => o.long === flag || o.short === flag,
526
- );
527
- const before = rest.slice(0, index);
528
- for (let i = 0; i < before.length; i++) {
529
- const token = String(before[i]);
530
- if (!token.startsWith('-')) continue;
531
- const [flag, inline] = token.split(/=(.*)/su);
532
- const program = own(flag);
533
- if (program) {
534
- if ((program.required || program.optional) && inline == null) i++;
535
- continue;
536
- }
537
- const opt = (sub.options ?? []).find(
538
- (/** @type {any} */ o) => o.long === flag || o.short === flag,
539
- );
540
- // The word after an option is its value when the option takes one, or
541
- // when no subcommand reads it (it is not an option itself).
542
- const next = before[i + 1];
543
- const takesValue = opt
544
- ? Boolean(opt.required || opt.optional)
545
- : next != null && !String(next).startsWith('-');
546
- const value =
547
- inline ??
548
- (takesValue && next != null && !String(next).startsWith('-')
549
- ? String(before[++i])
550
- : undefined);
551
- const typed =
552
- value === undefined ? flag : `${flag} ${quoteCommandArgument(value)}`;
553
- (opt ? moved : dropped).push(typed);
554
- }
555
- /** @type {string[]} */
556
- const after = [];
557
- const tail = rest.slice(end).map(String);
558
- for (let i = 0; i < tail.length; i++) {
559
- const program = own(tail[i].split('=')[0]);
560
- if (program) {
561
- if ((program.required || program.optional) && !tail[i].includes('=')) i++;
562
- continue;
563
- }
564
- after.push(quoteCommandArgument(tail[i]));
565
- }
566
- const line = [
567
- getCliInvocation(process.cwd()),
568
- ...chain,
569
- ...subWords,
570
- ...after,
571
- ...moved,
572
- ].join(' ');
573
- return {sub: [...chain, ...subWords].join(' '), line, moved, dropped};
574
- }
575
-
576
- /**
577
- * Whether a parse error came from a theme editor or preview command, whose
578
- * missing-argument message names what was given.
579
- * @param {unknown} err
580
- */
581
- function isEditorCommand(err) {
582
- const parts = [];
583
- for (
584
- let node = /** @type {any} */ (err)?.[REJECTED_COMMAND];
585
- node;
586
- node = node.parent
587
- )
588
- parts.unshift(node.name());
589
- return (
590
- parts.slice(1, 3).join(' ') === 'experimental theme' &&
591
- ['editor', 'preview'].includes(parts[3])
592
- );
593
- }
594
-
595
314
  /**
596
315
  * The usage line of the command a parse error came from, as a suggestion, for
597
316
  * an option given without its value.
@@ -604,28 +323,6 @@ function usageSuggestion(err, code) {
604
323
  if (!cmd) return undefined;
605
324
  const parts = [];
606
325
  for (let node = cmd; node; node = node.parent) parts.unshift(node.name());
607
- // The theme editor and its preview commands name what is missing with
608
- // their usage and help, as the project runs the CLI.
609
- if (
610
- code === 'commander.missingArgument' &&
611
- parts.slice(1, 3).join(' ') === 'experimental theme' &&
612
- ['editor', 'preview'].includes(parts[3])
613
- )
614
- return editorMissingSuggestions(cmd);
615
- // An experimental theme command missing its argument (`experimental
616
- // theme compile`): its usage and help, as the project runs the CLI.
617
- // Stable commands (`theme build`) keep their output as released.
618
- if (
619
- code === 'commander.missingArgument' &&
620
- parts.slice(1, 3).join(' ') === 'experimental theme'
621
- ) {
622
- const words = parts.slice(1).join(' ');
623
- const invocation = getCliInvocation(process.cwd());
624
- return [
625
- {name: `${invocation} ${words} ${cmd.usage()}`.trim(), reason: 'usage'},
626
- {name: `${invocation} ${words} --help`, reason: 'what each argument is'},
627
- ];
628
- }
629
326
  if (code !== 'commander.optionMissingArgument') return undefined;
630
327
  // The command's usage with the option in it, as it takes its value
631
328
  // (`astryx theme build --out <path> <files...>`).
@@ -641,219 +338,6 @@ function usageSuggestion(err, code) {
641
338
  return [{name: `${parts.join(' ')} ${usage}`.trim(), reason: 'usage'}];
642
339
  }
643
340
 
644
- /**
645
- * The theme editor's message for a missing argument: what the command takes
646
- * and the words it was given, in order.
647
- * @param {unknown} err
648
- * @param {string} message Commander's message
649
- */
650
- function editorMissingMessage(err, message) {
651
- const cmd = /** @type {any} */ (err)?.[REJECTED_COMMAND];
652
- const wants = (cmd?.registeredArguments ?? [])
653
- .filter((/** @type {any} */ a) => a.required)
654
- .map((/** @type {any} */ a) => a.name());
655
- return editorMissingArgument(cmd, wants, /'([^']+)'/.exec(message)?.[1])
656
- .message;
657
- }
658
-
659
- /**
660
- * The editor themes of the app a command runs in, as the theme editor
661
- * lists them; the editor registers it, so this module reads no theme files.
662
- * @type {(cwd: string) => string[]}
663
- */
664
- let editorThemesHere = () => [];
665
-
666
- /**
667
- * How the theme commands read an option commander does not know, or one
668
- * given no value (commander's code says which), which the editor
669
- * registers: the message and the commands that work, or undefined for a
670
- * command it does not read.
671
- * @type {(cmd: any, code: string) => {message: string, suggestions: Array<{name: string, reason: string}>} | undefined | Promise<{message: string, suggestions: Array<{name: string, reason: string}>} | undefined>}
672
- */
673
- let unknownOptionReader = () => undefined;
674
-
675
- /**
676
- * Register how the theme commands read an option they do not take.
677
- * @param {(cmd: any, code: string) => {message: string, suggestions: Array<{name: string, reason: string}>} | undefined | Promise<{message: string, suggestions: Array<{name: string, reason: string}>} | undefined>} read
678
- */
679
- export function setUnknownOptionReader(read) {
680
- unknownOptionReader = read;
681
- }
682
-
683
- /**
684
- * The word a theme command missing its one argument is offered, the one its
685
- * own refusals offer (`new`: a theme name no theme here has; `preview app`:
686
- * a folder that is free), with why; null for a command that has none. The
687
- * editor registers it, so this module reads no theme files.
688
- * @type {(cwd: string, words: string) => {word: string, reason: string} | null}
689
- */
690
- let freeArgument = () => null;
691
-
692
- /**
693
- * Register the word a theme command missing its one argument is offered.
694
- * @param {(cwd: string, words: string) => {word: string, reason: string} | null} free
695
- * `words`: the command's words after the program, `experimental theme editor new`
696
- */
697
- export function setFreeArgument(free) {
698
- freeArgument = free;
699
- }
700
-
701
- /**
702
- * Register how the theme editor lists the themes of the app a command runs
703
- * in, for the missing-theme suggestions.
704
- * @param {(cwd: string) => string[]} list
705
- */
706
- export function setEditorThemeList(list) {
707
- editorThemesHere = list;
708
- }
709
-
710
- /**
711
- * The options a command was given on its command line, as they were typed
712
- * (`--on card --mode dark --only`), so a line offered for it keeps them:
713
- * dropped, a line for one part or mode would change the whole theme.
714
- * @param {any} cmd the Commander command
715
- * @returns {string} the options, or ''
716
- */
717
- function typedOptions(cmd) {
718
- /** @type {string[]} */
719
- const out = [];
720
- for (const opt of cmd?.options ?? []) {
721
- const key = opt.attributeName();
722
- if (cmd.getOptionValueSource?.(key) !== 'cli') continue;
723
- const value = cmd.getOptionValue(key);
724
- const flag = opt.long ?? opt.short;
725
- if (typeof value === 'boolean') out.push(flag);
726
- else
727
- for (const v of Array.isArray(value) ? value : [value])
728
- out.push(`${flag} ${quoteCommandArgument(String(v))}`);
729
- }
730
- return out.join(' ');
731
- }
732
-
733
- /**
734
- * The theme editor's usage and help suggestions for a missing argument, as
735
- * the project runs the CLI. A line that names the missing word keeps the
736
- * options typed (typedOptions).
737
- * @param {any} cmd
738
- * @returns {Array<{name: string, reason: string}>}
739
- */
740
- function editorMissingSuggestions(cmd) {
741
- const parts = [];
742
- for (let node = cmd; node; node = node.parent) parts.unshift(node.name());
743
- const words = parts.slice(1).join(' ');
744
- const invocation = getCliInvocation(process.cwd());
745
- const typed = typedOptions(cmd);
746
- const withTyped = (/** @type {string} */ line) =>
747
- typed ? `${line} ${typed}` : line;
748
- // No theme named, and the app has exactly one editor theme: the command
749
- // on that theme, when the theme is all it takes.
750
- const wants = (cmd?.registeredArguments ?? []).filter(
751
- (/** @type {any} */ a) => a.required,
752
- );
753
- // (`new` names a theme that does not exist yet: never the one here.)
754
- if (
755
- !(cmd?.args ?? []).length &&
756
- wants.length === 1 &&
757
- wants[0].name() === 'theme' &&
758
- cmd.name() !== 'new'
759
- ) {
760
- const themes = editorThemesHere(process.cwd());
761
- if (themes.length === 1)
762
- return [
763
- {
764
- name: withTyped(`${invocation} ${words} ${themes[0]}`),
765
- reason: `do this instead: ${themes[0]} is the theme here`,
766
- },
767
- {
768
- name: `${invocation} ${words} --help`,
769
- reason: 'what each argument is',
770
- },
771
- ];
772
- }
773
- // Words given with the theme left out (`set corners pill`), in an app
774
- // with one editor theme that none of the words names: the same words on
775
- // that theme.
776
- const given = (cmd?.args ?? []).map(String);
777
- if (given.length && wants[0]?.name() === 'theme' && cmd.name() !== 'new') {
778
- const themes = editorThemesHere(process.cwd());
779
- // A whole command pasted as one word (`set 'set t accent red'`, `set
780
- // 'npx … editor set t accent red'`): the command it is, its words read
781
- // as typed, when its theme is one here.
782
- if (given.length === 1 && /\s/.test(given[0])) {
783
- const pasted = given[0]
784
- .trim()
785
- .replace(/^.*?\beditor\s+/, '')
786
- .replace(new RegExp(`^${cmd.name()}\\s+`), '')
787
- .split(/\s+/);
788
- if (themes.includes(pasted[0]))
789
- return [
790
- {
791
- name: withTyped(
792
- `${invocation} ${words} ${pasted.map((/** @type {string} */ w) => quoteCommandArgument(w)).join(' ')}`,
793
- ),
794
- reason:
795
- 'do this instead: the command pasted as one word, read as its words',
796
- },
797
- {
798
- name: `${invocation} ${words} --help`,
799
- reason: 'what each argument is',
800
- },
801
- ];
802
- }
803
- if (themes.length === 1 && !given.includes(themes[0]))
804
- return [
805
- {
806
- name: withTyped(
807
- `${invocation} ${words} ${themes[0]} ${given.map((/** @type {string} */ w) => quoteCommandArgument(w)).join(' ')}`,
808
- ),
809
- reason: `do this instead: ${themes[0]} is the theme here`,
810
- },
811
- {
812
- name: `${invocation} ${words} --help`,
813
- reason: 'what each argument is',
814
- },
815
- ];
816
- }
817
- // A command whose one argument names something new (`new`'s theme,
818
- // `preview app`'s folder), given none: the free word its own refusals
819
- // offer.
820
- const free =
821
- !(cmd?.args ?? []).length && wants.length === 1
822
- ? freeArgument(process.cwd(), words)
823
- : null;
824
- if (free)
825
- return [
826
- {
827
- name: withTyped(`${invocation} ${words} ${free.word}`),
828
- reason: `do this instead: ${free.reason}`,
829
- },
830
- {name: `${invocation} ${words} --help`, reason: 'what each argument is'},
831
- ];
832
- return [
833
- {name: `${invocation} ${words} ${cmd.usage()}`.trim(), reason: 'usage'},
834
- {name: `${invocation} ${words} --help`, reason: 'what each argument is'},
835
- ];
836
- }
837
-
838
- /**
839
- * The theme editor's missing-argument report: what the command takes, the
840
- * words it was given and what each was read as, and its usage and help.
841
- * The parser's error uses it, and so does a command that checks its own
842
- * arguments (set, whose value may come inside a pasted declaration).
843
- * @param {any} cmd the Commander command
844
- * @param {string[]} wants the argument names it takes, in order
845
- * @param {string | undefined} missing the argument that is missing
846
- * @returns {{message: string, suggestions: Array<{name: string, reason: string}>}}
847
- */
848
- export function editorMissingArgument(cmd, wants, missing) {
849
- const given = /** @type {string[]} */ (cmd?.args ?? []);
850
- const shown = wants.map(w => `<${w}>`);
851
- return {
852
- message: `${cmd.name()} takes ${shown.join(' ')}, and ${given.length ? `was given ${given.length} (${given.join(' ')}), read as ${shown.slice(0, given.length).join(' ')}` : 'was given none'}: ${missing ? `<${missing}>` : 'an argument'} is missing.`,
853
- suggestions: editorMissingSuggestions(cmd),
854
- };
855
- }
856
-
857
341
  /** Marks a command whose `command`/`addCommand` already self-install the shim. */
858
342
  const SELF_INSTALLING = Symbol.for('astryx.jsonShim.selfInstalling');
859
343
 
@@ -1031,94 +515,9 @@ export function handleCommanderError(err) {
1031
515
  code: commanderCodeToErrorCode(code, message),
1032
516
  });
1033
517
 
1034
- // A group of the experimental theme commands given a word it does not
1035
- // have, then an option (`experimental theme preview path --theme t`): the
1036
- // word is what is wrong, named as when no option follows it, with the
1037
- // group's subcommands closest first. Stable groups keep their error.
1038
518
  const rejected = /** @type {any} */ (err)?.[REJECTED_COMMAND];
1039
- const group = rejected;
1040
- const chain = [];
1041
- for (let node = group; node?.parent; node = node.parent)
1042
- chain.unshift(node.name());
1043
- // Options typed before one of the group's subcommands: the subcommand is
1044
- // what was meant, with the options it takes after it.
1045
- const early =
1046
- code === 'commander.unknownOption' &&
1047
- group?.commands?.length &&
1048
- chain.slice(0, 2).join(' ') === 'experimental theme'
1049
- ? optionsBeforeSubcommand(group)
1050
- : null;
1051
- if (early) {
1052
- const help = `${getCliInvocation(process.cwd())} ${early.sub} --help`;
1053
- return finishParseError(err, code, message, exitCode, {
1054
- message: early.dropped.length
1055
- ? `${early.dropped.join(', ')} ${early.dropped.length > 1 ? 'are' : 'is'} typed before ${early.sub}, which takes no such option.`
1056
- : `${early.moved.join(', ')} ${early.moved.length > 1 ? 'go' : 'goes'} after the subcommand: ${early.sub} takes ${early.moved.length > 1 ? 'them' : 'it'} there.`,
1057
- suggestions: [
1058
- {
1059
- name: early.line,
1060
- reason: early.dropped.length
1061
- ? `do this instead: without ${early.dropped.join(', ')}${early.moved.length ? `, with ${early.moved.join(', ')} after the subcommand` : ''}`
1062
- : 'do this instead: the options after the subcommand',
1063
- },
1064
- {name: help, reason: 'the options it takes'},
1065
- ],
1066
- });
1067
- }
1068
- // Options with no subcommand at all (`preview --theme t`): no option's
1069
- // value is a subcommand; the subcommands that take them are named.
1070
- const bare =
1071
- code === 'commander.unknownOption' &&
1072
- group?.commands?.length &&
1073
- chain.slice(0, 2).join(' ') === 'experimental theme'
1074
- ? optionsWithoutSubcommand(group)
1075
- : null;
1076
- if (bare) {
1077
- const inv = getCliInvocation(process.cwd());
1078
- const these = bare.typed.join(' ');
1079
- const many = bare.typed.length > 1;
1080
- return finishParseError(err, code, message, exitCode, {
1081
- message: bare.takers.length
1082
- ? `${bare.typed.join(', ')} ${many ? 'are' : 'is'} typed with no subcommand of ${bare.group}; ${bare.takers.map(c => c.name()).join(', ')} ${bare.takers.length > 1 ? 'take' : 'takes'} ${many ? 'them' : 'it'}.`
1083
- : `${bare.group} needs a subcommand, and none of its subcommands takes ${bare.typed.join(', ')}.`,
1084
- suggestions: [
1085
- // A subcommand that needs nothing more runs with the options; one
1086
- // that needs its own words shows them.
1087
- ...bare.takers.slice(0, 3).map(c =>
1088
- (c.registeredArguments ?? []).some(
1089
- (/** @type {any} */ a) => a.required,
1090
- )
1091
- ? {
1092
- name: `${inv} ${bare.group} ${c.name()} --help`,
1093
- reason: `${c.name()} takes ${these}; what else it needs`,
1094
- }
1095
- : {
1096
- name: `${inv} ${bare.group} ${c.name()} ${these}`,
1097
- reason: `do this instead: ${c.name()} with ${these}`,
1098
- },
1099
- ),
1100
- {name: `${inv} ${bare.group} --help`, reason: 'its subcommands'},
1101
- ],
1102
- });
1103
- }
1104
- const word =
1105
- code === 'commander.unknownOption' &&
1106
- group?.commands?.length &&
1107
- chain.slice(0, 2).join(' ') === 'experimental theme'
1108
- ? unknownGroupWord(group)
1109
- : null;
1110
- if (word) {
1111
- return finishParseError(err, UNKNOWN_SUBCOMMAND, message, exitCode, {
1112
- message: `unknown subcommand '${chain.join(' ')} ${word}'`,
1113
- suggestions: unknownSubcommandSuggestions(
1114
- `${getCliInvocation(process.cwd())} ${chain.join(' ')}`,
1115
- word,
1116
- servedSubcommands(group).map((/** @type {any} */ c) => c.name()),
1117
- ),
1118
- });
1119
- }
1120
- // An option a command does not take: the editor's own reader reads its
1121
- // commands' options; every other command gets the generic answer.
519
+ // An option a command does not take: the options the command takes and
520
+ // the run as meant.
1122
521
  if (code === 'commander.unknownOption' && rejected)
1123
522
  return answerStrayOption(err, rejected, message, exitCode);
1124
523
 
@@ -1132,26 +531,14 @@ export function handleCommanderError(err) {
1132
531
 
1133
532
  // Real error paths. Strip Commander's "error: " prefix once: in the envelope
1134
533
  // the key is already `error`, and in text mode the Astryx prefix replaces it.
1135
- // The editor's reader also reads an option given without its value and
1136
- // words a theme command does not take.
1137
- const read =
1138
- code === 'commander.optionMissingArgument' ||
1139
- code === 'commander.excessArguments'
1140
- ? unknownOptionReader(rejected, code)
1141
- : undefined;
1142
- // The reader checks the commands it offers as the command itself would
1143
- // (which may take a moment): the answer is written once it has them.
1144
- if (read instanceof Promise)
1145
- return read.then(r => finishParseError(err, code, message, exitCode, r));
1146
- return finishParseError(err, code, message, exitCode, read);
534
+ return finishParseError(err, code, message, exitCode, undefined);
1147
535
  }
1148
536
 
1149
537
  /**
1150
538
  * The answer to an option a command does not take, loaded only for this
1151
539
  * error. On the program itself, before a word that names no command
1152
540
  * (`astryx describe Table --format json`), the unknown command is the fault
1153
- * to report, and its answer names the command meant. Otherwise the editor's
1154
- * reader reads the option for its own commands, and every other command
541
+ * to report, and its answer names the command meant. Otherwise the command
1155
542
  * gets the options it takes and the run as meant (./stray-option.mjs).
1156
543
  * @param {unknown} err
1157
544
  * @param {any} rejected the command that refused the option
@@ -1232,16 +619,14 @@ async function answerStrayOption(err, rejected, message, exitCode) {
1232
619
  );
1233
620
  }
1234
621
  }
1235
- const read = await unknownOptionReader(rejected, code);
1236
622
  return finishParseError(
1237
623
  err,
1238
624
  code,
1239
625
  message,
1240
626
  exitCode,
1241
- read ??
1242
- strayOptionAnswer(rejected, message.replace(/^error:\s*/i, ''), words, {
1243
- jsonSupported,
1244
- }),
627
+ strayOptionAnswer(rejected, message.replace(/^error:\s*/i, ''), words, {
628
+ jsonSupported,
629
+ }),
1245
630
  );
1246
631
  }
1247
632
 
@@ -1285,8 +670,8 @@ async function answerBareMissingArgument(err, rejected, message, exitCode) {
1285
670
 
1286
671
  /**
1287
672
  * The rest of {@link handleCommanderError} for a parse failure: the message
1288
- * and suggestions written (the theme reader's answer when it read the
1289
- * option), and the exit.
673
+ * and suggestions written (the reader's answer when one read the error), and
674
+ * the exit.
1290
675
  * @param {unknown} err
1291
676
  * @param {string} code
1292
677
  * @param {string} message
@@ -1299,16 +684,9 @@ async function answerBareMissingArgument(err, rejected, message, exitCode) {
1299
684
  function finishParseError(err, code, message, exitCode, read, errorCode) {
1300
685
  const answer = read ?? undefined;
1301
686
  const suggestions = answer?.suggestions ?? usageSuggestion(err, code);
1302
- // In the theme editor a missing argument names what was given: in
1303
- // `set corners small` the first word is read as the theme, so "value" alone
1304
- // would name the wrong thing.
1305
687
  const cleaned = answer
1306
688
  ? answer.message
1307
- : code === 'commander.missingArgument' &&
1308
- suggestions?.length === 2 &&
1309
- isEditorCommand(err)
1310
- ? editorMissingMessage(err, message)
1311
- : message.replace(/^error:\s*/i, '');
689
+ : message.replace(/^error:\s*/i, '');
1312
690
  if (jsonActive()) {
1313
691
  emitJsonError(
1314
692
  cleaned,