@astryxdesign/cli 0.6.3-canary.98a2e4e → 0.6.3-canary.a860a50

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 (291) hide show
  1. package/README.md +32 -18
  2. package/api/build/build.doc.mjs +3 -3
  3. package/api/build/build.test.mjs +14 -3
  4. package/api/build/build.type.d.mts +36 -2
  5. package/api/build/build.type.mjs +25 -4
  6. package/api/build/help/help.d.mts +8 -5
  7. package/api/build/help/help.mjs +56 -6
  8. package/api/component/component.doc.mjs +11 -2
  9. package/api/component/component.mjs +29 -0
  10. package/api/component/component.test.mjs +38 -0
  11. package/api/component/component.type.d.mts +17 -7
  12. package/api/component/component.type.mjs +27 -20
  13. package/api/discover/discover.doc.mjs +1 -1
  14. package/api/discover/discover.type.d.mts +4 -4
  15. package/api/discover/discover.type.mjs +10 -10
  16. package/api/docs/_adapter.d.mts +30 -27
  17. package/api/docs/_adapter.mjs +154 -124
  18. package/api/docs/compiled-topics.test.mjs +78 -0
  19. package/api/docs/detail/detail.d.mts +0 -15
  20. package/api/docs/detail/detail.mjs +14 -78
  21. package/api/docs/detail/section/section.mjs +22 -18
  22. package/api/docs/detail/section/section.test.mjs +4 -3
  23. package/api/docs/docs.type.d.mts +4 -4
  24. package/api/docs/docs.type.mjs +10 -10
  25. package/api/docs/index/index.mjs +6 -5
  26. package/api/doctor/doctor.mjs +3 -7
  27. package/api/gap-report/gap-report.doc.mjs +7 -4
  28. package/api/hook/hook.type.d.mts +3 -3
  29. package/api/hook/hook.type.mjs +11 -11
  30. package/api/init/init.doc.mjs +4 -0
  31. package/api/init/init.test.mjs +41 -1
  32. package/api/init/remove/remove.mjs +1 -1
  33. package/api/init/run/run.mjs +20 -10
  34. package/api/integration/add-contribution.component-names.test.mjs +120 -0
  35. package/api/integration/add-contribution.mjs +16 -3
  36. package/api/integration/add-contribution.test.mjs +84 -4
  37. package/api/integration/integrationAdd.doc.mjs +7 -4
  38. package/api/integration/integrationAddComponent.doc.mjs +1 -1
  39. package/api/integration/pack-check.mjs +49 -7
  40. package/api/integration/pack-check.test.mjs +249 -0
  41. package/api/integration/validate-integration.mjs +2 -0
  42. package/api/integration/validate-integration.test.mjs +91 -0
  43. package/api/integration/validateIntegration.doc.mjs +1 -1
  44. package/api/json/envelope-types.test.mjs +76 -0
  45. package/api/json/parseResponse.doc.mjs +2 -2
  46. package/api/layout/expand/expand.mjs +7 -5
  47. package/api/layout/expand/expand.path-safety.test.mjs +53 -0
  48. package/api/layout/grammar/grammar.mjs +2 -1
  49. package/api/layout/layoutExpand.doc.mjs +1 -1
  50. package/api/search/search-return-type.test.mjs +54 -0
  51. package/api/search/search.d.mts +2 -9
  52. package/api/search/search.doc.mjs +5 -1
  53. package/api/search/search.mjs +15 -8
  54. package/api/search/search.test.mjs +34 -0
  55. package/api/search/search.type.d.mts +1 -1
  56. package/api/search/search.type.mjs +1 -1
  57. package/api/swizzle/copy/copy.mjs +28 -11
  58. package/api/swizzle/swizzle.doc.mjs +1 -1
  59. package/api/swizzle/swizzle.type.d.mts +2 -2
  60. package/api/swizzle/swizzle.type.mjs +2 -2
  61. package/api/template/copy/copy.mjs +17 -23
  62. package/api/template/copy/copy.test.mjs +17 -0
  63. package/api/template/template.doc.mjs +2 -1
  64. package/api/template/template.type.d.mts +5 -5
  65. package/api/template/template.type.mjs +12 -12
  66. package/api/theme/add/add.binary.test.mjs +91 -0
  67. package/api/theme/add/add.mjs +15 -2
  68. package/api/theme/build/build.mjs +133 -42
  69. package/api/theme/build/build.public-component-vars.test.mjs +1 -1
  70. package/api/theme/build/build.receipt-doc.test.mjs +111 -0
  71. package/api/theme/build/build.test.mjs +127 -0
  72. package/api/theme/build/font-warning.mjs +3 -3
  73. package/api/theme/build/font-warning.test.mjs +5 -2
  74. package/api/theme/palette/generate/generate.mjs +8 -3
  75. package/api/theme/palette/generate/generate.test.mjs +96 -0
  76. package/api/theme/palette/generate/generator.d.mts +10 -13
  77. package/api/theme/palette/generate/generator.mjs +15 -4
  78. package/api/theme/palette/generate/generator.test.mjs +10 -0
  79. package/api/theme/template/template.mjs +11 -2
  80. package/api/theme/template/template.test.mjs +15 -0
  81. package/api/theme/theme.type.d.mts +170 -11
  82. package/api/theme/theme.type.mjs +94 -27
  83. package/api/theme/themeBuild.doc.mjs +7 -4
  84. package/api/theme/themeTemplate.doc.mjs +4 -1
  85. package/api/upgrade/_adapter.mjs +27 -4
  86. package/api/upgrade/list/list.mjs +2 -1
  87. package/api/upgrade/list/list.test.mjs +73 -0
  88. package/api/upgrade/status/status.mjs +2 -2
  89. package/api/upgrade/upgrade.doc.mjs +2 -1
  90. package/api/upgrade/upgrade.type.d.mts +8 -4
  91. package/api/upgrade/upgrade.type.mjs +11 -10
  92. package/assets/codemods/integration-discovery.mjs +40 -2
  93. package/assets/codemods/integration-discovery.test.mjs +58 -0
  94. package/assets/codemods/term-log.mjs +32 -8
  95. package/assets/codemods/term-log.test.mjs +19 -1
  96. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
  97. package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
  98. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
  99. package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
  100. package/assets/docs/cli-integrations.doc.mjs +9 -0
  101. package/assets/docs/styling-libraries.doc.mjs +1 -1
  102. package/assets/docs/working-with-ai.doc.mjs +1 -1
  103. package/assets/templates/pages/table-tree/page.tsx +1704 -0
  104. package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
  105. package/authoring/_shared/contract.ts +22 -0
  106. package/authoring/codemod/codemod.doc.mjs +6 -1
  107. package/authoring/codemod/parse.d.mts +8 -8
  108. package/authoring/codemod/parse.mjs +8 -6
  109. package/authoring/config/config.doc.mjs +1 -1
  110. package/authoring/config/debug-composition.test.mjs +92 -0
  111. package/authoring/config/parse.d.mts +13 -13
  112. package/authoring/config/parse.mjs +8 -8
  113. package/authoring/config/type.ts +18 -6
  114. package/authoring/debug/parse.d.mts +4 -4
  115. package/authoring/debug/parse.mjs +3 -3
  116. package/authoring/doctypes/_schema.d.mts +121 -11
  117. package/authoring/doctypes/_schema.mjs +144 -13
  118. package/authoring/doctypes/base/graph-fields.doc.mjs +11 -4
  119. package/authoring/doctypes/base/type.ts +8 -4
  120. package/authoring/doctypes/command/command.doc.mjs +3 -2
  121. package/authoring/doctypes/command/parse.d.mts +2 -2
  122. package/authoring/doctypes/command/parse.mjs +1 -1
  123. package/authoring/doctypes/command/type.ts +2 -2
  124. package/authoring/doctypes/component/component.doc.mjs +5 -2
  125. package/authoring/doctypes/component/parse.d.mts +2 -2
  126. package/authoring/doctypes/component/parse.mjs +1 -1
  127. package/authoring/doctypes/component/type.ts +1 -1
  128. package/authoring/doctypes/enum/parse.d.mts +2 -2
  129. package/authoring/doctypes/enum/parse.mjs +1 -1
  130. package/authoring/doctypes/enum/type.ts +1 -1
  131. package/authoring/doctypes/function/function.doc.mjs +4 -0
  132. package/authoring/doctypes/function/parse.d.mts +2 -2
  133. package/authoring/doctypes/function/parse.mjs +1 -1
  134. package/authoring/doctypes/function/type.ts +1 -1
  135. package/authoring/doctypes/hook/hook.doc.mjs +4 -0
  136. package/authoring/doctypes/hook/parse.d.mts +2 -2
  137. package/authoring/doctypes/hook/parse.mjs +1 -1
  138. package/authoring/doctypes/hook/type.ts +1 -1
  139. package/authoring/doctypes/legacy.d.mts +6 -6
  140. package/authoring/doctypes/legacy.mjs +3 -3
  141. package/authoring/doctypes/load-contract.test.mjs +207 -0
  142. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -3
  143. package/authoring/doctypes/namespace/parse.d.mts +2 -2
  144. package/authoring/doctypes/namespace/parse.mjs +1 -1
  145. package/authoring/doctypes/namespace/type.ts +2 -2
  146. package/authoring/doctypes/parse.d.mts +18 -18
  147. package/authoring/doctypes/parse.mjs +9 -9
  148. package/authoring/doctypes/reference/parse.d.mts +2 -2
  149. package/authoring/doctypes/reference/parse.mjs +1 -1
  150. package/authoring/doctypes/reference/reference.doc.mjs +6 -2
  151. package/authoring/doctypes/reference/type.ts +1 -1
  152. package/authoring/doctypes/schema/parse.d.mts +2 -2
  153. package/authoring/doctypes/schema/parse.mjs +1 -1
  154. package/authoring/doctypes/schema/type.ts +2 -2
  155. package/authoring/doctypes/template/parse.d.mts +92 -1
  156. package/authoring/doctypes/template/parse.mjs +33 -1
  157. package/authoring/doctypes/template/template.doc.mjs +4 -0
  158. package/authoring/doctypes/template/type.ts +4 -1
  159. package/authoring/doctypes/types.ts +10 -10
  160. package/authoring/gap-report/parse.d.mts +9 -9
  161. package/authoring/gap-report/parse.mjs +6 -6
  162. package/authoring/gap-report/type.ts +1 -1
  163. package/authoring/identity/identity.doc.mjs +3 -2
  164. package/authoring/identity/type.ts +10 -10
  165. package/authoring/index.d.ts +19 -19
  166. package/authoring/integration/parse.d.mts +2 -2
  167. package/authoring/integration/parse.mjs +1 -1
  168. package/authoring/integration/schema.d.mts +4 -4
  169. package/authoring/integration/schema.mjs +3 -3
  170. package/authoring/integration/type.ts +1 -1
  171. package/clients/cli/command-load-failure.test.mjs +83 -0
  172. package/clients/cli/commands/blog.mjs +23 -8
  173. package/clients/cli/commands/blog.test.mjs +42 -1
  174. package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
  175. package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
  176. package/clients/cli/commands/build-theme.mjs +5 -5
  177. package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
  178. package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
  179. package/clients/cli/commands/build.doc.mjs +4 -1
  180. package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
  181. package/clients/cli/commands/build.mjs +32 -47
  182. package/clients/cli/commands/build.playbook.test.mjs +75 -0
  183. package/clients/cli/commands/build.text-fields.test.mjs +40 -0
  184. package/clients/cli/commands/component/index.mjs +2 -7
  185. package/clients/cli/commands/component-package.test.mjs +18 -0
  186. package/clients/cli/commands/component-resolution.test.mjs +21 -0
  187. package/clients/cli/commands/component.test.mjs +19 -0
  188. package/clients/cli/commands/detail-levels.test.mjs +2 -2
  189. package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
  190. package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
  191. package/clients/cli/commands/discover.doc.mjs +4 -2
  192. package/clients/cli/commands/discover.mjs +3 -3
  193. package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
  194. package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
  195. package/clients/cli/commands/doctor.mjs +6 -16
  196. package/clients/cli/commands/doctor.test.mjs +42 -0
  197. package/clients/cli/commands/gap-report.doc.mjs +16 -5
  198. package/clients/cli/commands/gap-report.test.mjs +72 -0
  199. package/clients/cli/commands/hook/index.mjs +7 -17
  200. package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
  201. package/clients/cli/commands/init.doc.mjs +19 -8
  202. package/clients/cli/commands/init.flag-help.test.mjs +153 -0
  203. package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
  204. package/clients/cli/commands/integration-add.doc.mjs +21 -5
  205. package/clients/cli/commands/integration-authoring.test.mjs +13 -9
  206. package/clients/cli/commands/interactive-guard.test.mjs +101 -24
  207. package/clients/cli/commands/json-contract.test.mjs +33 -0
  208. package/clients/cli/commands/layout-check.doc.mjs +14 -3
  209. package/clients/cli/commands/layout-expand.doc.mjs +21 -4
  210. package/clients/cli/commands/layout.doc.mjs +2 -2
  211. package/clients/cli/commands/layout.mjs +21 -9
  212. package/clients/cli/commands/layout.path-help.test.mjs +33 -0
  213. package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
  214. package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
  215. package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
  216. package/clients/cli/commands/search.doc.mjs +5 -2
  217. package/clients/cli/commands/search.mjs +13 -2
  218. package/clients/cli/commands/search.test.mjs +61 -0
  219. package/clients/cli/commands/swizzle.doc.mjs +2 -1
  220. package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
  221. package/clients/cli/commands/template.doc.mjs +28 -6
  222. package/clients/cli/commands/template.flag-help.test.mjs +117 -0
  223. package/clients/cli/commands/template.path-help.test.mjs +40 -0
  224. package/clients/cli/commands/theme-add.doc.mjs +2 -1
  225. package/clients/cli/commands/theme-build.doc.mjs +7 -6
  226. package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
  227. package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
  228. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  229. package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
  230. package/clients/cli/commands/upgrade.doc.mjs +17 -6
  231. package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
  232. package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
  233. package/clients/cli/index.mjs +13 -30
  234. package/clients/cli/latest-version-env.test.mjs +50 -0
  235. package/clients/cli/lib/cli-error.test.mjs +7 -0
  236. package/clients/cli/lib/component-format.mjs +9 -9
  237. package/clients/cli/lib/component-format.test.mjs +1 -1
  238. package/clients/cli/lib/define-command.mjs +32 -6
  239. package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
  240. package/clients/cli/lib/exit-codes.test.mjs +97 -0
  241. package/clients/cli/lib/hook-format.mjs +5 -5
  242. package/clients/cli/lib/json-shim.mjs +38 -2
  243. package/clients/cli/lib/json-shim.test.mjs +83 -0
  244. package/clients/cli/lib/manifest.d.ts +2 -0
  245. package/clients/cli/lib/manifest.mjs +22 -0
  246. package/clients/cli/lib/manifest.test.mjs +17 -0
  247. package/foundation/agent-docs/agent-docs.d.mts +4 -0
  248. package/foundation/agent-docs/agent-docs.mjs +69 -3
  249. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
  250. package/foundation/config/integration-debug.test.mjs +28 -3
  251. package/foundation/config/project.mjs +123 -9
  252. package/foundation/config/project.test.mjs +126 -0
  253. package/foundation/discovery/authoring-self-docs.test.mjs +71 -12
  254. package/foundation/discovery/docs-discovery.d.mts +4 -0
  255. package/foundation/discovery/docs-discovery.mjs +16 -2
  256. package/foundation/discovery/docs-discovery.test.mjs +47 -11
  257. package/foundation/discovery/template-adapter.d.mts +14 -5
  258. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
  259. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
  260. package/foundation/discovery/template-adapter.mjs +292 -25
  261. package/foundation/discovery/theming-targets.test.mjs +4 -0
  262. package/foundation/doc-compiler/compile.d.mts +162 -0
  263. package/foundation/doc-compiler/compile.mjs +262 -0
  264. package/foundation/doc-compiler/doc-compiler.test.mjs +687 -0
  265. package/foundation/doc-compiler/ir.d.mts +9 -0
  266. package/foundation/doc-compiler/ir.mjs +287 -0
  267. package/foundation/doc-compiler/lenses.d.mts +33 -0
  268. package/foundation/doc-compiler/lenses.mjs +127 -0
  269. package/foundation/fs/module-loader.d.mts +1 -0
  270. package/foundation/fs/module-loader.mjs +50 -1
  271. package/foundation/fs/module-loader.stdout.test.mjs +332 -0
  272. package/foundation/fs/path-safety.d.mts +3 -2
  273. package/foundation/fs/path-safety.mjs +49 -19
  274. package/foundation/fs/path-safety.test.mjs +50 -0
  275. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
  276. package/foundation/integrations/autolink.mjs +6 -1
  277. package/foundation/response/base.d.ts +8 -4
  278. package/foundation/response/error-codes.doc.mjs +1 -2
  279. package/foundation/response/error-codes.mjs +1 -1
  280. package/foundation/response/error-codes.test.mjs +83 -0
  281. package/foundation/response/json-contract.test.mjs +11 -0
  282. package/foundation/response/json.d.mts +4 -2
  283. package/foundation/response/json.mjs +8 -10
  284. package/foundation/response/response-types.doc.mjs +3 -3
  285. package/foundation/xle/expand.d.mts +2 -0
  286. package/foundation/xle/expand.mjs +3 -2
  287. package/foundation/xle/expand.test.mjs +54 -0
  288. package/package.json +9 -11
  289. package/clients/cli/lib/update-check.mjs +0 -83
  290. package/clients/cli/lib/update-check.test.mjs +0 -137
  291. package/clients/cli/update-hint-commands.test.mjs +0 -54
@@ -221,3 +221,61 @@ describe('integration codemod discovery', () => {
221
221
  ).rejects.toThrow(/across versions/i);
222
222
  });
223
223
  });
224
+
225
+ describe('test files beside a codemod', () => {
226
+ // The incident this closes: every .ts/.mjs/.js under a version folder was
227
+ // loaded AND VALIDATED as a codemod, so a test file colocated with its
228
+ // transform failed validation — and because a definition error is a hard
229
+ // error, it took every codemod in that version with it. `astryx upgrade`
230
+ // then applied nothing and reported success. Core is immune because its own
231
+ // codemods are enumerated in a registry rather than discovered by walking a
232
+ // directory, so its colocated tests are simply never visited. Only
233
+ // integrations carry the landmine.
234
+ const TRANSFORM = `
235
+ export default {
236
+ type: 'code',
237
+ title: 'Drop foo',
238
+ transform: (file) => file.source.replace(/foo/g, 'bar'),
239
+ };
240
+ `;
241
+ // Not a codemod: no default export of the right shape. Loading it throws.
242
+ const A_TEST = `
243
+ import {describe, it, expect} from 'vitest';
244
+ describe('drop-foo', () => {
245
+ it('drops foo', () => expect(1).toBe(1));
246
+ });
247
+ `;
248
+
249
+ it.each([
250
+ ['a .test. sibling', '0.2.0/drop-foo.test.mjs'],
251
+ ['a .spec. sibling', '0.2.0/drop-foo.spec.mjs'],
252
+ ['a fixture sibling', '0.2.0/drop-foo.fixture.mjs'],
253
+ ['a __tests__ directory', '0.2.0/__tests__/drop-foo.mjs'],
254
+ ['a __fixtures__ directory', '0.2.0/__fixtures__/input.mjs'],
255
+ ])('ignores %s and still discovers the codemod', async (_label, testPath) => {
256
+ scaffold({'0.2.0/drop-foo.mjs': TRANSFORM, [testPath]: A_TEST});
257
+
258
+ const project = await Project.load(tmpDir);
259
+ const byVersion = await discoverIntegrationCodemods(
260
+ project.loadedIntegrations,
261
+ );
262
+
263
+ expect([...byVersion.keys()]).toEqual(['0.2.0']);
264
+ expect(byVersion.get('0.2.0').map(entry => entry.id)).toEqual(['drop-foo']);
265
+ });
266
+
267
+ it('a nested helper directory is still walked', async () => {
268
+ // Only test and fixture names are skipped. A package that organises its
269
+ // transforms into subdirectories keeps working.
270
+ scaffold({'0.2.0/imports/drop-foo.mjs': TRANSFORM});
271
+
272
+ const project = await Project.load(tmpDir);
273
+ const byVersion = await discoverIntegrationCodemods(
274
+ project.loadedIntegrations,
275
+ );
276
+
277
+ expect(byVersion.get('0.2.0').map(entry => entry.id)).toEqual([
278
+ 'imports/drop-foo',
279
+ ]);
280
+ });
281
+ });
@@ -11,6 +11,8 @@
11
11
  * `p.log.step(...)`, `p.log.success(...)`, etc. All output routes through
12
12
  * `humanLog`, the CLI's stdout-discipline primitive, which is a no-op in
13
13
  * `--json` mode — so these human logs can never corrupt a JSON envelope.
14
+ * Every line is plain ASCII: level prefixes are ASCII and typographic glyphs
15
+ * in a message are transliterated before it is printed.
14
16
  *
15
17
  * The side-effecting API commands (upgrade/init/themeBuild) do NOT use this;
16
18
  * they write through the shared `logger` (api/logger.mjs).
@@ -18,8 +20,30 @@
18
20
 
19
21
  import {humanLog} from '../../foundation/response/json.mjs';
20
22
 
21
- /** @param {unknown} msg */
22
- const toStr = (msg) => (msg === undefined || msg === null ? '' : String(msg));
23
+ /** @type {Array<[RegExp, string]>} */
24
+ const ASCII_GLYPHS = [
25
+ [/[\u2014\u2013]/g, '-'],
26
+ [/\u2192/g, '->'],
27
+ [/\u2713/g, '[ok]'],
28
+ [/\u2717/g, '!!'],
29
+ [/\u26a0\ufe0f?/g, '!'],
30
+ [/\u2022/g, '-'],
31
+ [/\u2026/g, '...'],
32
+ [/[\u2018\u2019]/g, "'"],
33
+ [/[\u201c\u201d]/g, '"'],
34
+ [/\u00a0/g, ' '],
35
+ ];
36
+
37
+ /**
38
+ * A message as plain ASCII: typographic glyphs become their ASCII spelling.
39
+ * @param {unknown} msg
40
+ * @returns {string}
41
+ */
42
+ export function toAscii(msg) {
43
+ let text = msg === undefined || msg === null ? '' : String(msg);
44
+ for (const [glyph, ascii] of ASCII_GLYPHS) text = text.replace(glyph, ascii);
45
+ return text;
46
+ }
23
47
 
24
48
  /**
25
49
  * Human-facing log surface (the small `log` API codemods use). All lines go to
@@ -28,15 +52,15 @@ const toStr = (msg) => (msg === undefined || msg === null ? '' : String(msg));
28
52
  */
29
53
  export const log = {
30
54
  /** @param {unknown} msg */
31
- message: (msg) => humanLog(toStr(msg)),
55
+ message: (msg) => humanLog(toAscii(msg)),
32
56
  /** @param {unknown} msg */
33
- info: (msg) => humanLog(toStr(msg)),
57
+ info: (msg) => humanLog(toAscii(msg)),
34
58
  /** @param {unknown} msg */
35
- step: (msg) => humanLog(toStr(msg)),
59
+ step: (msg) => humanLog(toAscii(msg)),
36
60
  /** @param {unknown} msg */
37
- success: (msg) => humanLog(`✓ ${toStr(msg)}`),
61
+ success: (msg) => humanLog(`[ok] ${toAscii(msg)}`),
38
62
  /** @param {unknown} msg */
39
- warn: (msg) => humanLog(`⚠ ${toStr(msg)}`),
63
+ warn: (msg) => humanLog(`! ${toAscii(msg)}`),
40
64
  /** @param {unknown} msg */
41
- error: (msg) => humanLog(`✗ ${toStr(msg)}`),
65
+ error: (msg) => humanLog(`!! ${toAscii(msg)}`),
42
66
  };
@@ -51,7 +51,7 @@ describe('sanity: helpers are live in human mode', () => {
51
51
  setJsonMode(false);
52
52
  p.log.success('done');
53
53
  expect(logSpy).toHaveBeenCalledTimes(1);
54
- expect(logSpy).toHaveBeenCalledWith('✓ done');
54
+ expect(logSpy).toHaveBeenCalledWith('[ok] done');
55
55
  });
56
56
 
57
57
  it('every log helper emits exactly one stdout line in human mode', () => {
@@ -60,3 +60,21 @@ describe('sanity: helpers are live in human mode', () => {
60
60
  expect(logSpy).toHaveBeenCalledTimes(6);
61
61
  });
62
62
  });
63
+
64
+ describe('ASCII output', () => {
65
+ it('prints ASCII level prefixes and transliterates glyphs in messages', () => {
66
+ setJsonMode(false);
67
+ p.log.success('src/a.tsx');
68
+ p.log.warn('stale \u2014 refresh');
69
+ p.log.error(' \u2717 src/b.tsx \u2014 rename \u2192 failed');
70
+ p.log.info(' \u2022 name \u2014 title\u2026');
71
+ const lines = logSpy.mock.calls.map(call => call.join(' '));
72
+ expect(lines).toEqual([
73
+ '[ok] src/a.tsx',
74
+ '! stale - refresh',
75
+ '!! !! src/b.tsx - rename -> failed',
76
+ ' - name - title...',
77
+ ]);
78
+ for (const line of lines) expect(line).not.toMatch(/[\u0080-\uFFFF]/);
79
+ });
80
+ });
@@ -3,7 +3,8 @@
3
3
  import {describe, it, expect} from 'vitest';
4
4
 
5
5
  async function applyTransform(source, path = 'test.ts') {
6
- const {default: transform} = await import('../unwrap-authoring-factories.mjs');
6
+ const {default: transform} =
7
+ await import('../unwrap-authoring-factories.mjs');
7
8
  const jscodeshift = (await import('jscodeshift')).default;
8
9
  const j = jscodeshift.withParser('tsx');
9
10
  const api = {jscodeshift: j, stats: () => {}, report: () => {}};
@@ -18,7 +19,7 @@ export default createConfig({integrations: ['@acme/widgets']});
18
19
  `;
19
20
  const output = await applyTransform(input);
20
21
  expect(output).not.toContain('createConfig');
21
- expect(output).toContain("export default {");
22
+ expect(output).toContain('export default {');
22
23
  expect(output).toContain("integrations: ['@acme/widgets']");
23
24
  expect(output).not.toContain('type:');
24
25
  });
@@ -132,13 +133,34 @@ export default createComponentDoc();
132
133
  expect(output).toContain("type: 'component'");
133
134
  });
134
135
 
136
+ it('leaves same-named factories from unrelated packages unchanged', async () => {
137
+ const input = `import {createConfig} from '@acme/eslint';
138
+ export default createConfig({strict: true});
139
+ `;
140
+ expect(await applyTransform(input)).toBe(input);
141
+ });
142
+
143
+ it('keeps an unrelated same-named import when another factory is migrated', async () => {
144
+ const input = `import {createConfig as createLintConfig} from '@acme/eslint';
145
+ import {createDoc} from '@astryxdesign/cli/doc';
146
+ export const lintConfig = createLintConfig({strict: true});
147
+ export const doc = createDoc({name: 'Theming', description: 'How theming works.'});
148
+ `;
149
+ const output = await applyTransform(input);
150
+ expect(output).toContain(
151
+ "import {createConfig as createLintConfig} from '@acme/eslint'",
152
+ );
153
+ expect(output).toContain('createLintConfig({strict: true})');
154
+ expect(output).not.toContain('createDoc');
155
+ expect(output).toContain("type: 'generic'");
156
+ });
157
+
135
158
  it('is a no-op when no authoring factory is imported', async () => {
136
159
  const input = `import {Button} from '@astryxdesign/core';
137
160
  export default Button;
138
161
  `;
139
- const {default: transform} = await import(
140
- '../unwrap-authoring-factories.mjs'
141
- );
162
+ const {default: transform} =
163
+ await import('../unwrap-authoring-factories.mjs');
142
164
  const jscodeshift = (await import('jscodeshift')).default;
143
165
  const j = jscodeshift.withParser('tsx');
144
166
  const api = {jscodeshift: j, stats: () => {}, report: () => {}};
@@ -5,8 +5,9 @@
5
5
  *
6
6
  * v0.3.0 removes the authoring factories. Authoring is now types + parsers: an
7
7
  * author writes a plain object and stamps its `type` directly. This transform
8
- * rewrites every factory call to the plain object the factory used to return,
9
- * then drops the now-dead factory imports:
8
+ * rewrites factory calls imported from the retired Astryx authoring entrypoints
9
+ * to the plain object the factory used to return, then drops the now-dead
10
+ * factory imports:
10
11
  *
11
12
  * createConfig(o) / createIntegration(o) -> o (no discriminant)
12
13
  * createComponentDoc(o) -> { ...o, type: 'component' }
@@ -25,8 +26,9 @@
25
26
  *
26
27
  * Import aliases are followed (`import {createDoc as mk}` → calls to `mk`), and
27
28
  * the factory specifiers are removed afterward (the whole import statement goes
28
- * if nothing else was imported from it). Run this BEFORE
29
- * `migrate-authoring-imports`, which repoints the surviving type imports.
29
+ * if nothing else was imported from it). Same-named imports from other packages
30
+ * remain untouched. Run this BEFORE `migrate-authoring-imports`, which repoints
31
+ * the surviving type imports.
30
32
  */
31
33
 
32
34
  export const meta = {
@@ -35,13 +37,24 @@ export const meta = {
35
37
  'Rewrites createConfig/createIntegration/createComponentDoc/' +
36
38
  'createFunctionDoc/createDoc/createPageTemplate/createBlockTemplate/' +
37
39
  'createCodemod/createConfigCodemod calls to the plain object they returned ' +
38
- "(stamping the doc/template/codemod `type` discriminant), and removes the " +
40
+ '(stamping the doc/template/codemod `type` discriminant), and removes the ' +
39
41
  'now-dead factory imports. Authoring is types + parsers in v0.3.0 — there ' +
40
42
  'are no factories.',
41
43
  pr: '#4612',
42
44
  fileExtensions: ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs'],
43
45
  };
44
46
 
47
+ /** Legacy Astryx authoring entrypoints that exported the removed factories. */
48
+ const AUTHORING_SOURCES = new Set([
49
+ '@astryxdesign/cli/config',
50
+ '@astryxdesign/cli/doc',
51
+ '@astryxdesign/cli/integration',
52
+ '@astryxdesign/cli/template',
53
+ '@astryxdesign/cli/codemod',
54
+ '@astryxdesign/core/authoring',
55
+ '@astryxdesign/core/config',
56
+ ]);
57
+
45
58
  /**
46
59
  * Factory name → the `type` discriminant it stamped, or `null` for the config /
47
60
  * integration factories, which were pure typed-identity (no discriminant).
@@ -108,6 +121,7 @@ export default function transformer(file, api) {
108
121
  /** @type {Map<string, string>} */
109
122
  const localToFactory = new Map();
110
123
  root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => {
124
+ if (!AUTHORING_SOURCES.has(path.node.source.value)) return;
111
125
  for (const spec of path.node.specifiers ?? []) {
112
126
  if (spec.type !== 'ImportSpecifier') continue;
113
127
  const importedName = spec.imported?.name;
@@ -163,6 +177,7 @@ export default function transformer(file, api) {
163
177
  // Drop the now-dead factory import specifiers; remove any import statement
164
178
  // left empty.
165
179
  root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => {
180
+ if (!AUTHORING_SOURCES.has(path.node.source.value)) return;
166
181
  const specs = path.node.specifiers ?? [];
167
182
  const kept = specs.filter(
168
183
  (/** @type {any} */ spec) =>
@@ -220,4 +220,51 @@ function wrapper(useResizable) {
220
220
  const output = await apply('rename-resizable-pixel-bounds', input);
221
221
  expect(output).toBe(input);
222
222
  });
223
+
224
+ it('renames bounds when useResizable comes from a namespace import', async () => {
225
+ const input = `import * as Astryx from '@astryxdesign/core';
226
+ const region = Astryx.useResizable({defaultSize: 240, minSizePx: 120, maxSizePx: 480});`;
227
+ const output = await apply('rename-resizable-pixel-bounds', input);
228
+ expect(output).toContain('minSize: 120');
229
+ expect(output).toContain('maxSize: 480');
230
+ expect(output).not.toContain('minSizePx');
231
+ expect(output).not.toContain('maxSizePx');
232
+ });
233
+
234
+ it('leaves a namespace that does not come from Astryx alone', async () => {
235
+ const input = `import * as Other from 'other-resizable';
236
+ const region = Other.useResizable({minSizePx: 120});`;
237
+ const output = await apply('rename-resizable-pixel-bounds', input);
238
+ expect(output).toContain('minSizePx: 120');
239
+ });
240
+
241
+ it('does not rewrite a parameter that shadows the namespace import', async () => {
242
+ const input = `import * as Astryx from '@astryxdesign/core';
243
+ function build(Astryx) {
244
+ return Astryx.useResizable({minSizePx: 120});
245
+ }`;
246
+ const output = await apply('rename-resizable-pixel-bounds', input);
247
+ expect(output).toContain('minSizePx: 120');
248
+ });
249
+
250
+ it.each([
251
+ ['as const', '{defaultSize: 240, minSizePx: 120} as const'],
252
+ ['satisfies', '{defaultSize: 240, minSizePx: 120} satisfies object'],
253
+ ])('renames a static configuration wrapped in %s', async (_label, config) => {
254
+ const input = `import {useResizable} from '@astryxdesign/core/Resizable';
255
+ const region = useResizable(${config});`;
256
+ const output = await apply('rename-resizable-pixel-bounds', input);
257
+ expect(output).toContain('minSize: 120');
258
+ expect(output).not.toContain('minSizePx');
259
+ });
260
+
261
+ it('renames wrapped multi-region configurations', async () => {
262
+ const input = `import {useResizable} from '@astryxdesign/core';
263
+ const regions = useResizable({regions: {
264
+ nav: {defaultSize: 240, minSizePx: 120} as const,
265
+ } as const});`;
266
+ const output = await apply('rename-resizable-pixel-bounds', input);
267
+ expect(output).toContain('minSize: 120');
268
+ expect(output).not.toContain('minSizePx');
269
+ });
223
270
  });
@@ -8,6 +8,9 @@
8
8
  * released conflict rule (the unified property wins when both are present).
9
9
  * A spread or computed property can change precedence invisibly, so dynamic
10
10
  * objects stay unchanged and receive a manual-migration TODO instead.
11
+ * Named and namespace imports both count, and a type-only wrapper (`as`,
12
+ * `satisfies`, a non-null assertion, parentheses) does not make a
13
+ * configuration dynamic.
11
14
  */
12
15
 
13
16
  export const meta = {
@@ -33,6 +36,26 @@ const MANUAL_MIGRATION_COMMENT =
33
36
  'or computed property. Rename minSizePx/maxSizePx to minSize/maxSize ' +
34
37
  'manually without changing property precedence. ';
35
38
 
39
+ const TYPE_WRAPPERS = new Set([
40
+ 'TSAsExpression',
41
+ 'TSSatisfiesExpression',
42
+ 'TSTypeAssertion',
43
+ 'TSNonNullExpression',
44
+ 'ParenthesizedExpression',
45
+ ]);
46
+
47
+ /**
48
+ * The expression under type-only wrappers such as `{...} as const`.
49
+ * @param {any} node
50
+ */
51
+ function unwrap(node) {
52
+ let current = node;
53
+ while (current && TYPE_WRAPPERS.has(current.type)) {
54
+ current = current.expression;
55
+ }
56
+ return current;
57
+ }
58
+
36
59
  /** @param {any} property */
37
60
  function staticPropertyName(property) {
38
61
  if (property.computed) return null;
@@ -128,6 +151,8 @@ export default function transformer(file, api) {
128
151
  const root = j(file.source);
129
152
  /** @type {Map<string, any>} */
130
153
  const bindings = new Map();
154
+ /** @type {Map<string, any>} */
155
+ const namespaces = new Map();
131
156
 
132
157
  root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => {
133
158
  if (!IMPORT_SOURCES.has(path.node.source.value)) return;
@@ -138,17 +163,40 @@ export default function transformer(file, api) {
138
163
  ) {
139
164
  const local = specifier.local?.name ?? 'useResizable';
140
165
  bindings.set(local, path.scope.lookup(local) ?? path.scope);
166
+ } else if (specifier.type === 'ImportNamespaceSpecifier') {
167
+ const local = specifier.local.name;
168
+ namespaces.set(local, path.scope.lookup(local) ?? path.scope);
141
169
  }
142
170
  }
143
171
  });
144
- if (bindings.size === 0) return undefined;
172
+ if (bindings.size === 0 && namespaces.size === 0) return undefined;
173
+
174
+ /**
175
+ * @param {any} callee
176
+ * @param {any} scope
177
+ */
178
+ const isUseResizable = (callee, scope) => {
179
+ if (callee.type === 'Identifier') {
180
+ return (
181
+ bindings.has(callee.name) &&
182
+ scope.lookup(callee.name) === bindings.get(callee.name)
183
+ );
184
+ }
185
+ return (
186
+ callee.type === 'MemberExpression' &&
187
+ !callee.computed &&
188
+ callee.object.type === 'Identifier' &&
189
+ callee.property.type === 'Identifier' &&
190
+ callee.property.name === 'useResizable' &&
191
+ namespaces.has(callee.object.name) &&
192
+ scope.lookup(callee.object.name) === namespaces.get(callee.object.name)
193
+ );
194
+ };
145
195
 
146
196
  let changed = false;
147
197
  root.find(j.CallExpression).forEach((/** @type {any} */ path) => {
148
- const callee = path.node.callee;
149
- if (callee.type !== 'Identifier' || !bindings.has(callee.name)) return;
150
- if (path.scope.lookup(callee.name) !== bindings.get(callee.name)) return;
151
- const config = path.node.arguments[0];
198
+ if (!isUseResizable(path.node.callee, path.scope)) return;
199
+ const config = unwrap(path.node.arguments[0]);
152
200
  if (config?.type !== 'ObjectExpression') return;
153
201
 
154
202
  changed = migrateObject(j, config) || changed;
@@ -158,13 +206,12 @@ export default function transformer(file, api) {
158
206
  staticPropertyName(property) === 'regions',
159
207
  );
160
208
  if (!regions || !('value' in regions)) return;
161
- const regionsObject = regions.value;
209
+ const regionsObject = unwrap(regions.value);
162
210
  if (regionsObject?.type !== 'ObjectExpression') return;
163
211
  for (const region of regionsObject.properties) {
164
- if (!('value' in region) || region.value?.type !== 'ObjectExpression') {
165
- continue;
166
- }
167
- changed = migrateObject(j, region.value) || changed;
212
+ const regionConfig = 'value' in region ? unwrap(region.value) : null;
213
+ if (regionConfig?.type !== 'ObjectExpression') continue;
214
+ changed = migrateObject(j, regionConfig) || changed;
168
215
  }
169
216
  });
170
217
 
@@ -320,6 +320,15 @@ export const docs = {
320
320
  type: 'prose',
321
321
  text: 'Codemod ids (the extension-less relative path under the version folder, e.g. `rename-widget-prop`, `config/rename-integration`) must be unique within a package across all versions. A duplicate id across versions is a hard error.',
322
322
  },
323
+ {
324
+ type: 'prose',
325
+ text: 'The loader automatically skips test and fixture files so you can colocate tests with transforms. Reserved names: files matching `*.test.*`, `*.spec.*`, or `*.fixture.*`, and any file under a `__tests__/` or `__fixtures__/` directory. These are never loaded as codemods regardless of their extension.',
326
+ },
327
+ {
328
+ type: 'code',
329
+ lang: 'text',
330
+ code: 'codemods/\n 0.2.0/\n rename-widget-prop.ts # loaded as a codemod\n rename-widget-prop.test.ts # skipped (reserved name)\n __tests__/\n rename-widget-prop.test.ts # skipped (reserved directory)',
331
+ },
323
332
  {
324
333
  type: 'code',
325
334
  lang: 'typescript',
@@ -351,7 +351,7 @@ tokens: {
351
351
  },
352
352
  },
353
353
  shortcuts: {
354
- 'xds-card': 'bg-surface text-primary border border-border rounded-lg p-4',
354
+ 'astryx-card': 'bg-surface text-primary border border-border rounded-lg p-4',
355
355
  },
356
356
  });`,
357
357
  },
@@ -182,7 +182,7 @@ astryx docs tokens --dense`,
182
182
  label: 'MCP config (same for all tools)',
183
183
  code: `{
184
184
  "mcpServers": {
185
- "xds": {
185
+ "astryx": {
186
186
  "type": "url",
187
187
  "url": "https://astryx.atmeta.com/mcp"
188
188
  }