@codefast/cli 0.10.0 → 0.12.0

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 (303) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +66 -41
  3. package/dist/arrange/command.js +99 -136
  4. package/dist/arrange/domain/ast/collectors-cn.d.ts +2 -2
  5. package/dist/arrange/domain/ast/collectors-cn.js +2 -2
  6. package/dist/arrange/domain/ast/collectors-jsx.d.ts +2 -2
  7. package/dist/arrange/domain/ast/collectors-jsx.js +1 -1
  8. package/dist/arrange/domain/ast/collectors-tv.d.ts +2 -2
  9. package/dist/arrange/domain/ast/collectors-tv.js +5 -5
  10. package/dist/arrange/domain/ast/helpers.d.ts +2 -2
  11. package/dist/arrange/domain/ast/helpers.js +3 -4
  12. package/dist/arrange/domain/ast/simplify-targets.d.ts +1 -1
  13. package/dist/arrange/domain/ast/simplify-targets.js +23 -28
  14. package/dist/arrange/domain/ast/targets.d.ts +2 -2
  15. package/dist/arrange/domain/ast/targets.js +9 -9
  16. package/dist/arrange/{typescript-ast-translator.d.ts → domain/ast/translator.d.ts} +6 -5
  17. package/dist/arrange/{typescript-ast-translator.js → domain/ast/translator.js} +20 -23
  18. package/dist/arrange/domain/constants.d.ts +1 -1
  19. package/dist/arrange/domain/grouping-service.d.ts +2 -2
  20. package/dist/arrange/domain/grouping-service.js +3 -3
  21. package/dist/arrange/domain/grouping.js +3 -3
  22. package/dist/arrange/domain/imports.d.ts +1 -1
  23. package/dist/arrange/domain/imports.js +2 -2
  24. package/dist/arrange/domain/source-text-formatters.js +1 -1
  25. package/dist/arrange/domain/tailwind-token.js +1 -1
  26. package/dist/arrange/domain/token-classifier.d.ts +1 -1
  27. package/dist/arrange/domain/token-classifier.js +2 -2
  28. package/dist/arrange/domain/types.d.ts +3 -3
  29. package/dist/arrange/group/cli-result.d.ts +7 -0
  30. package/dist/arrange/group/cli-result.js +12 -0
  31. package/dist/arrange/group/cli-schema.d.ts +17 -0
  32. package/dist/arrange/group/cli-schema.js +13 -0
  33. package/dist/arrange/group/output.d.ts +7 -0
  34. package/dist/arrange/group/output.js +10 -0
  35. package/dist/arrange/group/suggest.d.ts +8 -0
  36. package/dist/arrange/{suggest.js → group/suggest.js} +2 -2
  37. package/dist/arrange/inspect/cli-result.d.ts +7 -0
  38. package/dist/arrange/inspect/cli-result.js +8 -0
  39. package/dist/arrange/inspect/cli-schema.d.ts +15 -0
  40. package/dist/arrange/inspect/cli-schema.js +9 -0
  41. package/dist/arrange/{domain → inspect/domain}/analyze-service.d.ts +2 -2
  42. package/dist/arrange/{domain → inspect/domain}/analyze-service.js +7 -7
  43. package/dist/arrange/inspect/output.d.ts +7 -0
  44. package/dist/arrange/inspect/output.js +42 -0
  45. package/dist/arrange/inspect/run.d.ts +10 -0
  46. package/dist/arrange/{analyze.js → inspect/run.js} +7 -7
  47. package/dist/arrange/prepare.d.ts +13 -0
  48. package/dist/arrange/{workspace.js → prepare.js} +9 -12
  49. package/dist/arrange/regroup/cli-result.d.ts +13 -0
  50. package/dist/arrange/regroup/cli-result.js +23 -0
  51. package/dist/arrange/regroup/cli-schema.d.ts +20 -0
  52. package/dist/arrange/regroup/cli-schema.js +14 -0
  53. package/dist/arrange/regroup/output.d.ts +14 -0
  54. package/dist/arrange/regroup/output.js +72 -0
  55. package/dist/arrange/{process-file.d.ts → regroup/process-file.d.ts} +3 -3
  56. package/dist/arrange/{process-file.js → regroup/process-file.js} +3 -3
  57. package/dist/arrange/regroup/run.d.ts +11 -0
  58. package/dist/arrange/{sync.js → regroup/run.js} +5 -5
  59. package/dist/arrange/resolve-target.d.ts +2 -2
  60. package/dist/arrange/resolve-target.js +2 -2
  61. package/dist/arrange/scan-target.d.ts +2 -2
  62. package/dist/arrange/scan-target.js +3 -3
  63. package/dist/arrange/simplify/cli-result.d.ts +7 -0
  64. package/dist/arrange/simplify/cli-result.js +8 -0
  65. package/dist/arrange/simplify/cli-schema.d.ts +17 -0
  66. package/dist/arrange/simplify/cli-schema.js +11 -0
  67. package/dist/arrange/simplify/fold-targets.d.ts +13 -0
  68. package/dist/arrange/simplify/fold-targets.js +139 -0
  69. package/dist/arrange/simplify/output.d.ts +7 -0
  70. package/dist/arrange/simplify/output.js +15 -0
  71. package/dist/arrange/simplify/process-file.d.ts +13 -0
  72. package/dist/arrange/simplify/process-file.js +49 -0
  73. package/dist/arrange/simplify/run.d.ts +14 -0
  74. package/dist/arrange/simplify/run.js +38 -0
  75. package/dist/arrange/simplify/variant-classname-probe.d.ts +35 -0
  76. package/dist/arrange/simplify/variant-classname-probe.js +95 -0
  77. package/dist/arrange/source-parse.d.ts +1 -1
  78. package/dist/arrange/source-parse.js +3 -3
  79. package/dist/audit/command.js +152 -212
  80. package/dist/audit/comments/cli-result.d.ts +13 -0
  81. package/dist/audit/comments/cli-result.js +22 -0
  82. package/dist/audit/comments/cli-schema.d.ts +19 -0
  83. package/dist/audit/comments/cli-schema.js +13 -0
  84. package/dist/audit/comments/output.d.ts +7 -0
  85. package/dist/audit/comments/output.js +27 -0
  86. package/dist/audit/comments/prepare.d.ts +16 -0
  87. package/dist/audit/comments/prepare.js +12 -0
  88. package/dist/audit/{run-comments.d.ts → comments/run.d.ts} +5 -5
  89. package/dist/audit/{run-comments.js → comments/run.js} +9 -9
  90. package/dist/audit/display-names/cli-result.d.ts +13 -0
  91. package/dist/audit/display-names/cli-result.js +22 -0
  92. package/dist/audit/display-names/cli-schema.d.ts +18 -0
  93. package/dist/audit/display-names/cli-schema.js +12 -0
  94. package/dist/audit/{domain → display-names/domain}/display-names.d.ts +1 -1
  95. package/dist/audit/display-names/output.d.ts +7 -0
  96. package/dist/audit/display-names/output.js +21 -0
  97. package/dist/audit/display-names/prepare.d.ts +16 -0
  98. package/dist/audit/display-names/prepare.js +12 -0
  99. package/dist/audit/display-names/run.d.ts +14 -0
  100. package/dist/audit/{run-display-names.js → display-names/run.js} +5 -5
  101. package/dist/audit/domain/types.d.ts +43 -0
  102. package/dist/audit/imports/cli-result.d.ts +13 -0
  103. package/dist/audit/imports/cli-result.js +22 -0
  104. package/dist/audit/imports/cli-schema.d.ts +18 -0
  105. package/dist/audit/imports/cli-schema.js +12 -0
  106. package/dist/audit/{domain → imports/domain}/import-policy.d.ts +3 -3
  107. package/dist/audit/{domain → imports/domain}/import-policy.js +4 -11
  108. package/dist/audit/imports/output.d.ts +7 -0
  109. package/dist/audit/imports/output.js +21 -0
  110. package/dist/audit/imports/prepare.d.ts +16 -0
  111. package/dist/audit/imports/prepare.js +12 -0
  112. package/dist/audit/imports/run.d.ts +14 -0
  113. package/dist/audit/{run-imports.js → imports/run.js} +6 -6
  114. package/dist/audit/links/cli-result.d.ts +13 -0
  115. package/dist/audit/links/cli-result.js +22 -0
  116. package/dist/audit/links/cli-schema.d.ts +18 -0
  117. package/dist/audit/links/cli-schema.js +12 -0
  118. package/dist/audit/{domain → links/domain}/markdown-links.d.ts +3 -3
  119. package/dist/audit/{domain → links/domain}/markdown-links.js +22 -8
  120. package/dist/audit/links/output.d.ts +7 -0
  121. package/dist/audit/links/output.js +21 -0
  122. package/dist/audit/links/prepare.d.ts +16 -0
  123. package/dist/audit/links/prepare.js +12 -0
  124. package/dist/audit/links/run.d.ts +14 -0
  125. package/dist/audit/{run-links.js → links/run.js} +4 -4
  126. package/dist/audit/prepare.d.ts +13 -52
  127. package/dist/audit/prepare.js +13 -136
  128. package/dist/audit/publish/cli-result.d.ts +13 -0
  129. package/dist/audit/publish/cli-result.js +22 -0
  130. package/dist/audit/publish/cli-schema.d.ts +18 -0
  131. package/dist/audit/publish/cli-schema.js +12 -0
  132. package/dist/audit/publish/domain/legacy-subpath.d.ts +8 -0
  133. package/dist/audit/publish/domain/legacy-subpath.js +22 -0
  134. package/dist/audit/publish/output.d.ts +7 -0
  135. package/dist/audit/publish/output.js +24 -0
  136. package/dist/audit/publish/prepare.d.ts +16 -0
  137. package/dist/audit/publish/prepare.js +12 -0
  138. package/dist/audit/publish/run.d.ts +14 -0
  139. package/dist/audit/publish/run.js +62 -0
  140. package/dist/audit/rtl/cli-result.d.ts +13 -0
  141. package/dist/audit/rtl/cli-result.js +22 -0
  142. package/dist/audit/rtl/cli-schema.d.ts +18 -0
  143. package/dist/audit/rtl/cli-schema.js +12 -0
  144. package/dist/audit/{domain → rtl/domain}/audit-file.d.ts +1 -1
  145. package/dist/audit/{domain → rtl/domain}/audit-file.js +2 -2
  146. package/dist/audit/{domain → rtl/domain}/tokenize.d.ts +1 -1
  147. package/dist/audit/rtl/output.d.ts +7 -0
  148. package/dist/audit/rtl/output.js +21 -0
  149. package/dist/audit/rtl/prepare.d.ts +13 -0
  150. package/dist/audit/rtl/prepare.js +41 -0
  151. package/dist/audit/rtl/run.d.ts +14 -0
  152. package/dist/audit/{run.js → rtl/run.js} +4 -4
  153. package/dist/bin.js +1 -1
  154. package/dist/cli.js +5 -5
  155. package/dist/core/cli/command-pipeline.d.ts +90 -0
  156. package/dist/core/cli/command-pipeline.js +83 -0
  157. package/dist/core/cli/format-error.d.ts +1 -1
  158. package/dist/core/cli/global-options.d.ts +1 -1
  159. package/dist/core/cli/global-options.js +1 -1
  160. package/dist/core/cli/resolve-root.d.ts +9 -0
  161. package/dist/core/cli/resolve-root.js +16 -0
  162. package/dist/core/cli/result-handle.d.ts +3 -9
  163. package/dist/core/cli/result-handle.js +4 -17
  164. package/dist/core/config/define-config.d.ts +1 -1
  165. package/dist/core/config/loader.d.ts +3 -3
  166. package/dist/core/config/loader.js +2 -2
  167. package/dist/core/config/schema.d.ts +1 -1
  168. package/dist/core/config/schema.js +1 -1
  169. package/dist/core/config/warnings.js +1 -1
  170. package/dist/core/config.d.ts +5 -5
  171. package/dist/core/config.js +4 -4
  172. package/dist/core/filesystem/{port.d.ts → filesystem.d.ts} +1 -1
  173. package/dist/core/filesystem/node.d.ts +3 -3
  174. package/dist/core/filesystem/node.js +1 -1
  175. package/dist/core/schema-parse.d.ts +2 -2
  176. package/dist/core/schema-parse.js +2 -2
  177. package/dist/core/source-text-edit.d.ts +14 -0
  178. package/dist/core/source-text-edit.js +22 -0
  179. package/dist/core/workspace/markdown-walk.d.ts +2 -2
  180. package/dist/core/workspace/markdown-walk.js +1 -1
  181. package/dist/core/workspace/package-version.d.ts +2 -2
  182. package/dist/core/workspace/package-version.js +2 -2
  183. package/dist/core/workspace/resolver.d.ts +3 -3
  184. package/dist/core/workspace/resolver.js +5 -5
  185. package/dist/core/workspace/source-walk.d.ts +2 -2
  186. package/dist/core/workspace/source-walk.js +1 -1
  187. package/dist/core/workspace/typescript-walk.d.ts +2 -2
  188. package/dist/core/workspace/typescript-walk.js +1 -1
  189. package/dist/core/workspace/walk-files.d.ts +2 -2
  190. package/dist/core/workspace/walk-files.js +1 -1
  191. package/dist/index.d.ts +3 -3
  192. package/dist/index.js +2 -2
  193. package/dist/mirror/cli-result.d.ts +1 -1
  194. package/dist/mirror/cli-result.js +1 -1
  195. package/dist/mirror/cli-schema.d.ts +2 -2
  196. package/dist/mirror/cli-schema.js +1 -1
  197. package/dist/mirror/command.js +36 -65
  198. package/dist/mirror/dist-filesystem-node.d.ts +8 -0
  199. package/dist/mirror/{dist-filesystem-impl.js → dist-filesystem-node.js} +3 -3
  200. package/dist/mirror/domain/dirent-guard.d.ts +1 -1
  201. package/dist/mirror/domain/exports.d.ts +2 -2
  202. package/dist/mirror/domain/exports.js +1 -1
  203. package/dist/mirror/domain/types.d.ts +59 -2
  204. package/dist/mirror/output.d.ts +1 -3
  205. package/dist/mirror/output.js +127 -2
  206. package/dist/mirror/package-path.d.ts +5 -5
  207. package/dist/mirror/package-path.js +3 -3
  208. package/dist/mirror/prepare.d.ts +6 -6
  209. package/dist/mirror/prepare.js +8 -12
  210. package/dist/mirror/run.d.ts +12 -0
  211. package/dist/mirror/{sync.js → run.js} +7 -7
  212. package/dist/mirror/supplement-exports.d.ts +3 -3
  213. package/dist/mirror/supplement-exports.js +2 -2
  214. package/dist/mirror/sync-workspace-package.d.ts +4 -4
  215. package/dist/mirror/sync-workspace-package.js +11 -14
  216. package/dist/mirror/write-exports.d.ts +3 -3
  217. package/dist/mirror/write-exports.js +3 -3
  218. package/dist/pack-slim/cli-result.d.ts +1 -1
  219. package/dist/pack-slim/cli-result.js +1 -1
  220. package/dist/pack-slim/cli-schema.d.ts +1 -1
  221. package/dist/pack-slim/cli-schema.js +1 -1
  222. package/dist/pack-slim/command.js +36 -71
  223. package/dist/pack-slim/domain/transform.d.ts +22 -1
  224. package/dist/pack-slim/domain/transform.js +65 -8
  225. package/dist/pack-slim/output.d.ts +1 -1
  226. package/dist/pack-slim/output.js +1 -1
  227. package/dist/pack-slim/prepare.d.ts +21 -0
  228. package/dist/pack-slim/prepare.js +14 -0
  229. package/dist/pack-slim/{sync.d.ts → run.d.ts} +6 -6
  230. package/dist/pack-slim/{sync.js → run.js} +5 -5
  231. package/dist/pack-slim/working-tree.d.ts +2 -2
  232. package/dist/pack-slim/working-tree.js +2 -2
  233. package/dist/tag/cli-result.d.ts +8 -2
  234. package/dist/tag/cli-result.js +15 -2
  235. package/dist/tag/cli-schema.d.ts +4 -4
  236. package/dist/tag/cli-schema.js +3 -4
  237. package/dist/tag/command.js +34 -61
  238. package/dist/tag/domain/skip-filter.d.ts +13 -0
  239. package/dist/tag/domain/skip-filter.js +29 -0
  240. package/dist/tag/domain/types.d.ts +22 -2
  241. package/dist/tag/domain/version-summary.d.ts +13 -0
  242. package/dist/tag/domain/version-summary.js +24 -0
  243. package/dist/tag/output.d.ts +4 -4
  244. package/dist/tag/output.js +7 -10
  245. package/dist/tag/prepare.d.ts +5 -5
  246. package/dist/tag/prepare.js +5 -5
  247. package/dist/tag/run.d.ts +10 -0
  248. package/dist/tag/{sync.js → run.js} +23 -53
  249. package/dist/tag/target/candidates.d.ts +8 -0
  250. package/dist/tag/{target-candidates.js → target/candidates.js} +3 -3
  251. package/dist/tag/{resolve-target-path.d.ts → target/resolve-path.d.ts} +2 -2
  252. package/dist/tag/target/runner.d.ts +8 -0
  253. package/dist/tag/{target-runner.js → target/runner.js} +3 -3
  254. package/dist/tag/{since-writer.d.ts → writer/since-writer.d.ts} +3 -3
  255. package/dist/tag/{since-writer.js → writer/since-writer.js} +1 -1
  256. package/dist/tag/{version-resolver.d.ts → writer/version-resolver.d.ts} +2 -2
  257. package/dist/tag/{version-resolver.js → writer/version-resolver.js} +1 -1
  258. package/package.json +15 -7
  259. package/dist/arrange/analyze.d.ts +0 -10
  260. package/dist/arrange/cli-schema.d.ts +0 -50
  261. package/dist/arrange/cli-schema.js +0 -34
  262. package/dist/arrange/output.d.ts +0 -26
  263. package/dist/arrange/output.js +0 -127
  264. package/dist/arrange/simplify-process-file.d.ts +0 -11
  265. package/dist/arrange/simplify-process-file.js +0 -30
  266. package/dist/arrange/simplify-sync.d.ts +0 -13
  267. package/dist/arrange/simplify-sync.js +0 -30
  268. package/dist/arrange/suggest.d.ts +0 -8
  269. package/dist/arrange/sync.d.ts +0 -11
  270. package/dist/arrange/workspace.d.ts +0 -13
  271. package/dist/audit/cli-schema.d.ts +0 -93
  272. package/dist/audit/cli-schema.js +0 -66
  273. package/dist/audit/output.d.ts +0 -91
  274. package/dist/audit/output.js +0 -213
  275. package/dist/audit/run-display-names.d.ts +0 -14
  276. package/dist/audit/run-imports.d.ts +0 -14
  277. package/dist/audit/run-links.d.ts +0 -14
  278. package/dist/audit/run.d.ts +0 -14
  279. package/dist/mirror/dist-filesystem-impl.d.ts +0 -8
  280. package/dist/mirror/sync-reporter.d.ts +0 -60
  281. package/dist/mirror/sync-reporter.js +0 -128
  282. package/dist/mirror/sync-types.d.ts +0 -43
  283. package/dist/mirror/sync-types.js +0 -1
  284. package/dist/mirror/sync.d.ts +0 -12
  285. package/dist/tag/sync.d.ts +0 -42
  286. package/dist/tag/target-candidates.d.ts +0 -8
  287. package/dist/tag/target-runner.d.ts +0 -8
  288. /package/dist/audit/{domain → comments/domain}/comment-content.d.ts +0 -0
  289. /package/dist/audit/{domain → comments/domain}/comment-content.js +0 -0
  290. /package/dist/audit/{domain → comments/domain}/comment-dividers.d.ts +0 -0
  291. /package/dist/audit/{domain → comments/domain}/comment-dividers.js +0 -0
  292. /package/dist/audit/{domain → comments/domain}/link-references.d.ts +0 -0
  293. /package/dist/audit/{domain → comments/domain}/link-references.js +0 -0
  294. /package/dist/audit/{domain → comments/domain}/since-versions.d.ts +0 -0
  295. /package/dist/audit/{domain → comments/domain}/since-versions.js +0 -0
  296. /package/dist/audit/{domain → comments/domain}/tsdoc-syntax.d.ts +0 -0
  297. /package/dist/audit/{domain → comments/domain}/tsdoc-syntax.js +0 -0
  298. /package/dist/audit/{domain → display-names/domain}/display-names.js +0 -0
  299. /package/dist/audit/{domain → rtl/domain}/mappings.d.ts +0 -0
  300. /package/dist/audit/{domain → rtl/domain}/mappings.js +0 -0
  301. /package/dist/audit/{domain → rtl/domain}/tokenize.js +0 -0
  302. /package/dist/core/filesystem/{port.js → filesystem.js} +0 -0
  303. /package/dist/tag/{resolve-target-path.js → target/resolve-path.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,89 @@
1
1
  # @codefast/cli
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#892](https://github.com/codefastlabs/codefast/pull/892) [`4c97c5b`](https://github.com/codefastlabs/codefast/commit/4c97c5b8c2314f25ee9df7eac5a4b5dd723d6d90) Thanks [@thevuong](https://github.com/thevuong)! - Add `codefast audit publish`, a static publish-surface check. It flags `#/`-prefixed internal import specifiers — valid
8
+ to the in-repo runners but rejected by Node's ESM resolver on the supported floor, so they break the published package —
9
+ and any `exports`/`imports` target the slimmed publish manifest would not ship. It joins the `audit` family and gates
10
+ CI, replacing an external `publint` step.
11
+
12
+ ### Patch Changes
13
+
14
+ - [#885](https://github.com/codefastlabs/codefast/pull/885) [`8580a2b`](https://github.com/codefastlabs/codefast/commit/8580a2b2dd9f502d7c330e5a2f0a3942041633b6) Thanks [@thevuong](https://github.com/thevuong)! - Match GitHub's heading-slug algorithm in `audit links`, so a cross-reference that resolves on GitHub resolves in the
15
+ audit.
16
+
17
+ Heading anchors are now slugged the way GitHub does: each space becomes its own hyphen with runs left intact,
18
+ underscores are kept as slug characters, and repeated headings gain `-1`, `-2`, … suffixes in heading order. The
19
+ previous slugger collapsed whitespace, dropped underscores, and offered only the base slug for duplicates, so a link a
20
+ browser lands on could be reported as dangling — the `@remarks` already claimed GitHub parity the code did not deliver.
21
+
22
+ - [#892](https://github.com/codefastlabs/codefast/pull/892) [`4c97c5b`](https://github.com/codefastlabs/codefast/commit/4c97c5b8c2314f25ee9df7eac5a4b5dd723d6d90) Thanks [@thevuong](https://github.com/thevuong)! - Lower the monorepo's Node floor from 24 to 22.12, so the packages install and run on the active Node 22 LTS line.
23
+
24
+ `engines.node` becomes `>=22.12.0` across every package — the floor the shared toolchain (oxlint, Vite, Vitest, TanStack
25
+ Start) already requires. Development stays on the latest Node (`.node-version`) for speed, and a CI matrix exercises the
26
+ floor and the active LTS directly, so the floor is a contract CI proves rather than one everyone has to run.
27
+ `@types/node` is pinned to the floor's major (`^22`), with a workspace override holding the whole tree there so a dev
28
+ tool's `@types/node: "*"` peer can no longer pull a newer major and mask an API the floor lacks. The floor stays
29
+ mechanical, not advisory: `@codefast/di` keeps its own `Map` upsert helpers rather than the ES2025
30
+ `Map.prototype.getOrInsert` (which would raise the floor to 26) and its `lib` stays `ES2024`. `@codefast/cli`'s mirror
31
+ step now calls the `node:path` functions directly instead of aliasing them, which the floor's types correctly flag as
32
+ unbound methods.
33
+
34
+ The shared `@codefast/typescript-config` presets pin `lib` and `target` to `ES2024` (was `ESNext`) so the compiler's
35
+ ECMAScript surface matches the Node floor: an ES2025 builtin such as `Map.prototype.getOrInsert` now fails to type-check
36
+ rather than compiling and crashing on Node 22.12. `@codefast/di` and `@codefast/di-testing` already pinned `lib` and are
37
+ unchanged.
38
+
39
+ Internal subpath imports move from a `#/` prefix to a bare `#` (`#core/token`, not `#/core/token`), and the
40
+ `package.json#imports` keys become `#*`/`#tests/*`/`#examples/*` to match. Node's native ESM resolver rejects a
41
+ `#/`-prefixed specifier with `ERR_INVALID_MODULE_SPECIFIER` on the whole Node 22 line (and on Node 24 before 24.14), and
42
+ each package ships those specifiers verbatim inside its published `dist/*.js` for a consumer's Node to resolve — so this
43
+ rename is what actually lets the packages import on the new floor. Purely internal: a consumer's own import paths are
44
+ unchanged.
45
+
46
+ - [#892](https://github.com/codefastlabs/codefast/pull/892) [`4c97c5b`](https://github.com/codefastlabs/codefast/commit/4c97c5b8c2314f25ee9df7eac5a4b5dd723d6d90) Thanks [@thevuong](https://github.com/thevuong)! - Fix `pack-slim` stripping the stylesheet source of packages that export CSS.
47
+
48
+ `codefast pack-slim` removed the whole `src` directory from a package's published `files`, but `@codefast/ui` and
49
+ `@codefast/tracking` ship Tailwind source through `./css/*` → `./src/css/*`, so their published tarballs went out with
50
+ no CSS at all and the `./css/*` export resolved to nothing. pack-slim now keeps the `src` subtrees a surviving
51
+ `exports`/`imports` target still points into (e.g. `src/css`) and drops the rest of `src`, so the stylesheets ship while
52
+ the TypeScript source stays out. Surfaced and now guarded by the new `codefast audit publish` check.
53
+
54
+ ## 0.11.0
55
+
56
+ ### Minor Changes
57
+
58
+ - [#855](https://github.com/codefastlabs/codefast/pull/855) [`76cf7a6`](https://github.com/codefastlabs/codefast/commit/76cf7a65372c5f13f779c7b59200cb956d93b882) Thanks [@thevuong](https://github.com/thevuong)! - Fix `codefast arrange simplify` changing rendered output: a mixed `cn()` call moved every static literal to the front,
59
+ which flipped tailwind-merge precedence and dropped overrides that sat after a variant call. It now coalesces only
60
+ adjacent static literals and preserves argument order.
61
+
62
+ Add `codefast arrange simplify --fold-variant-classname` (alias `--fold-variant-class-name`), which folds
63
+ `cn(buttonVariants({ size: "sm" }), "flex-1")` into `buttonVariants({ size: "sm", className: "flex-1" })`. The fold is
64
+ gated on the native TypeScript type server confirming the callee accepts a `className`/`class`, so it loads the
65
+ `typescript` package (a new optional peer, v7) and applies only inside a `tsconfig`; the default pass is unchanged.
66
+
67
+ The fold splices `className` in after the last option, so a trailing comma or line comment in the options object no
68
+ longer breaks the rewrite. Overlapping edits are now resolved before they are applied — keeping the outermost of any
69
+ nested `cn()`/variant pair — so nested calls no longer corrupt the output.
70
+
71
+ - [#854](https://github.com/codefastlabs/codefast/pull/854) [`a7ad2d8`](https://github.com/codefastlabs/codefast/commit/a7ad2d8b24b10b5554a5809be943aca00e22e844) Thanks [@thevuong](https://github.com/thevuong)! - `codefast audit imports` now enforces the Zod namespace form (`import * as z from "zod"`) in every workspace package,
72
+ not only the front-end/bundled ones. The rule's `scope` restriction is dropped, so a named `import { z } from "zod"` is
73
+ flagged everywhere — backend/tsc packages such as `cli` itself included. Type-only imports
74
+ (`import type { ZodType } from "zod"`) stay allowed; only the value `z` is banned.
75
+
76
+ ### Patch Changes
77
+
78
+ - [#855](https://github.com/codefastlabs/codefast/pull/855) [`9e481c5`](https://github.com/codefastlabs/codefast/commit/9e481c554b7f60216b130495fd157fe3a459721e) Thanks [@thevuong](https://github.com/thevuong)! - Fix `codefast arrange --dry-run --json` printing human-readable preview lines to stdout ahead of the JSON summary, which
79
+ broke piping the output to a JSON parser. Dry-run previews are now emitted only in human mode; `--json` writes a single
80
+ JSON object.
81
+
82
+ - [#854](https://github.com/codefastlabs/codefast/pull/854) [`504a61a`](https://github.com/codefastlabs/codefast/commit/504a61a996684fbd4fb6703141612d3cd97dbfde) Thanks [@thevuong](https://github.com/thevuong)! - Reorganize the CLI source into a uniform per-command and per-subcommand directory layout. Each command follows one
83
+ skeleton (`command.ts`, `cli-schema.ts`, `prepare.ts`, `run*.ts`, `output.ts`, `cli-result.ts`, `domain/`), and every
84
+ `audit`/`arrange` subcommand is now its own mini-command directory (`audit/rtl/`, `arrange/inspect/`, …) with the shared
85
+ runner and grouping engine kept at the command root. Internal refactor only — no public API or behavior change.
86
+
3
87
  ## 0.10.0
4
88
 
5
89
  ### Minor Changes
package/README.md CHANGED
@@ -16,13 +16,13 @@ encode an opinionated house style (called out below) that you can adopt, ignore,
16
16
 
17
17
  - **Safe by default.** Every writing command supports `--dry-run`, and every audit is read-only except
18
18
  `audit comments --fix`.
19
- - **Scriptable.** `--json` prints one JSON object on stdout and suppresses the human progress output.
19
+ - **Scriptable.** `--json` prints one JSON object on stdout instead of the human-readable output.
20
20
  - **CI-ready.** Audits exit non-zero when findings remain, so they gate a pipeline with no extra glue.
21
21
  - **Configurable.** An optional `codefast.config.*` file, validated by a strict schema, adjusts every command.
22
22
 
23
23
  ## Requirements
24
24
 
25
- - **Node.js ≥ 24** (the CLI is published as ESM).
25
+ - **Node.js ≥ 22.12** (the CLI is published as ESM).
26
26
  - **A project root — workspace or single package.** Commands resolve their root by walking up from the current
27
27
  directory: the nearest `pnpm-workspace.yaml` marks a **workspace** (every package under it is in scope), and with no
28
28
  workspace file the nearest `package.json` marks a **single package** (that one package is the whole scope). Only
@@ -75,22 +75,72 @@ codefast audit links # find broken markdown cross-
75
75
  `codefast mirror --no-color`.
76
76
  - **Writing commands write by default; pass `--dry-run` to preview.** The audits are read-only — the one exception is
77
77
  `audit comments --fix`, which repairs section dividers in place.
78
- - **`--json` prints a single JSON object on stdout** and suppresses the human-readable progress output, so any command
79
- can gate a script or a CI job.
78
+ - **`--json` prints a single JSON object on stdout** instead of the human-readable output, so any command can gate a
79
+ script or a CI job.
80
+ - **Set `CODEFAST_VERBOSE=1` (or `true`) for verbose error diagnostics.** On an unexpected infrastructure failure the
81
+ CLI also prints the underlying stack trace. This is distinct from `mirror --verbose`, which adds per-package progress
82
+ detail to that one command.
80
83
 
81
84
  ## Commands at a glance
82
85
 
86
+ ```text
87
+ codefast # Codefast monorepo developer CLI
88
+ │ ├─ --no-color # disable ANSI color output
89
+ │ └─ --version
90
+ │
91
+ ├─ arrange [target] # regroup Tailwind classes in cn()/tv() in render-pipeline order
92
+ │ │ ├─ --dry-run # preview, without writing files
93
+ │ │ ├─ --with-class-name # append className as the final cn() argument (alias: --with-classname)
94
+ │ │ ├─ --cn-import <spec> # override the module specifier when adding a cn import
95
+ │ │ └─ --json
96
+ │ │
97
+ │ ├─ inspect [target] # report long strings, cn nested in tv() (read-only)
98
+ │ │ └─ --json
99
+ │ ├─ simplify [target] # flatten grouped arrays & static cn() to plain strings in tv() slots
100
+ │ │ ├─ --dry-run
101
+ │ │ └─ --fold-variant-class-name # fold cn() overrides into the variant's className option (uses the TS type server)
102
+ │ └─ group <tokens...> # group a pasted class string (stdout: cn(...) or a tv() array with --tv)
103
+ │ ├─ --tv # emit a tv()-style array instead of a cn() call
104
+ │ ├─ --with-class-name
105
+ │ └─ --json
106
+ │
107
+ ├─ audit # source audits (read-only source scans)
108
+ │ ├─ rtl [target] # physical-direction Tailwind classes to make logical / rtl:-paired
109
+ │ ├─ links [target] # markdown links pointing at a missing path/anchor
110
+ │ ├─ imports [target] # banned import forms (React by-name, Zod namespace in front-end, …)
111
+ │ ├─ display-names [target] # token()/tag()/module names breaking the <namespace>:<Name> convention
112
+ │ └─ comments [target] # section dividers not in the one allowed form
113
+ │ └─ --fix # rewrite every fixable divider in place (the only audit that writes)
114
+ │ (each audit also takes [target] + --json)
115
+ │
116
+ ├─ mirror [package] # write package.json#exports from dist/ for workspace packages
117
+ │ ├─ --dry-run
118
+ │ ├─ -v, --verbose
119
+ │ └─ --json
120
+ │
121
+ ├─ pack-slim [package] # strip src, source conditions, dev-only scripts/devDeps, source maps before publish
122
+ │ ├─ --dry-run
123
+ │ ├─ --force # run even if the git working tree has uncommitted changes
124
+ │ └─ --json
125
+ │
126
+ └─ tag [target] # add @since <version> to exported declarations
127
+ ├─ --dry-run
128
+ └─ --json
129
+ ```
130
+
131
+ Every command also responds to `--help`; each command's section below explains what its flags do.
132
+
83
133
  | Command | What it does | Writes? |
84
134
  | --------------------- | -------------------------------------------------------------------------- | ----------------- |
85
135
  | `arrange` | Regroup Tailwind classes in `cn()` / `tv()` calls in render-pipeline order | yes (`--dry-run`) |
86
136
  | `mirror` | Write each package's `package.json#exports` from its built `dist/` | yes (`--dry-run`) |
87
137
  | `pack-slim` | Strip the dev-only surface from a package right before publish | yes (`--dry-run`) |
88
138
  | `tag` | Stamp `@since <version>` on exported declarations that lack one | yes (`--dry-run`) |
89
- | `audit links` | Report markdown cross-references that resolve to nothing | no |
90
139
  | `audit rtl` | Report physical-direction Tailwind classes that should be logical | no |
140
+ | `audit links` | Report markdown cross-references that resolve to nothing | no |
91
141
  | `audit imports` | Enforce the import policy (React by-name, Zod namespace in front-end) | no (report only) |
92
- | `audit comments` | Check doc-comment conventions; repair section dividers | `--fix` only |
93
142
  | `audit display-names` | Enforce the `namespace:Name` display-name convention | no |
143
+ | `audit comments` | Check doc-comment conventions; repair section dividers | `--fix` only |
94
144
 
95
145
  **Which of these are for you?** `arrange`, `mirror`, `pack-slim`, `tag`, and `audit links` are general-purpose — they
96
146
  work for any pnpm workspace or single package that builds with `tsc`. The other four audits encode codefast's own house
@@ -120,13 +170,6 @@ intentional; pass such a file explicitly to process it.
120
170
  `#lib/utils` re-export, any `…/utils` path, or a dedicated `cn.ts` module — so an unrelated local `cn` is left alone.
121
171
  Long static JSX `className` strings are regrouped regardless of where `cn` comes from.
122
172
 
123
- | Flag | Description |
124
- | -------------------- | ----------------------------------------------------------------------------- |
125
- | `--dry-run` | Preview suggested replacements without writing files. |
126
- | `--with-classname` | Append `className` as the final `cn()` argument (alias: `--with-class-name`). |
127
- | `--cn-import <spec>` | Override the module specifier used when a missing `cn` import is added. |
128
- | `--json` | Print one JSON object on stdout (suppresses human progress). |
129
-
130
173
  Exits `1` when the `arrange.onAfterWrite` hook fails, `0` otherwise.
131
174
 
132
175
  ### `arrange inspect [target]`
@@ -136,7 +179,15 @@ Read-only report of long strings, nested `cn` inside `tv()`, and related finding
136
179
  ### `arrange simplify [target]`
137
180
 
138
181
  Flattens grouped arrays and static-only `cn()` calls back to plain strings in `tv()` slots — the inverse cleanup pass.
139
- Accepts `--dry-run` and `--json`.
182
+ In a mixed `cn()` call it coalesces only _adjacent_ static literals and keeps argument order, so tailwind-merge
183
+ precedence is unchanged (a later argument still overrides an earlier one).
184
+
185
+ With `--fold-variant-classname`, `cn(buttonVariants({ size: "sm" }), "flex-1")` becomes
186
+ `buttonVariants({ size: "sm", className: "flex-1" })`, and a dynamic or multi-part override folds into a `className`
187
+ array. The fold fires only when the native TypeScript type server confirms the callee's options accept a `className` (or
188
+ `class`) of the right shape, so it loads the `typescript` package (an optional peer, v7) and needs the target inside a
189
+ `tsconfig`; files outside a project keep the base pass. Run a formatter afterward — a folded call can exceed the print
190
+ width until it is wrapped.
140
191
 
141
192
  ### `arrange group <tokens...>`
142
193
 
@@ -148,11 +199,7 @@ codefast arrange group "relative flex h-10 w-full items-center rounded-md bg-pri
148
199
  codefast arrange group --tv "flex items-center gap-2"
149
200
  ```
150
201
 
151
- | Flag | Description |
152
- | ------------------ | ----------------------------------------------------------------------------- |
153
- | `--tv` | Emit a `tv()`-style array instead of a `cn()` call. |
154
- | `--with-classname` | Append `className` as the final `cn()` argument (alias: `--with-class-name`). |
155
- | `--json` | Emit `{ schemaVersion, primaryLine, bucketsCommentLine }` on stdout. |
202
+ With `--json`, that object is `{ schemaVersion, primaryLine, bucketsCommentLine }`.
156
203
 
157
204
  ## `mirror`
158
205
 
@@ -167,12 +214,6 @@ codefast mirror packages/ui # one package (path relative to repo root)
167
214
  codefast mirror --dry-run # report changes without writing
168
215
  ```
169
216
 
170
- | Flag | Description |
171
- | ----------------- | ------------------------------------------------------------- |
172
- | `--dry-run` | Report what would change without writing any `package.json`. |
173
- | `-v`, `--verbose` | Print extra diagnostics. |
174
- | `--json` | Print one JSON summary on stdout (suppresses human progress). |
175
-
176
217
  Exits `1` when any package fails, `0` otherwise.
177
218
 
178
219
  ### Per-package `mirror` configuration
@@ -221,12 +262,6 @@ codefast pack-slim packages/ui # one package (path relative to repo root)
221
262
  codefast pack-slim --dry-run # report what would be stripped without touching a file
222
263
  ```
223
264
 
224
- | Flag | Description |
225
- | ----------- | ----------------------------------------------------------------- |
226
- | `--dry-run` | Report what would be stripped without touching any file. |
227
- | `--force` | Run even if the git working tree has uncommitted tracked changes. |
228
- | `--json` | Print one JSON summary on stdout (suppresses human progress). |
229
-
230
265
  Exits `1` when any package fails, `0` otherwise.
231
266
 
232
267
  ## `tag`
@@ -242,11 +277,6 @@ codefast tag packages/ui/src # tag one directory or file
242
277
  codefast tag --dry-run # summary only, no writes
243
278
  ```
244
279
 
245
- | Flag | Description |
246
- | ----------- | ------------------------------------------------------------- |
247
- | `--dry-run` | Show summary without writing files. |
248
- | `--json` | Print one JSON summary on stdout (suppresses human progress). |
249
-
250
280
  Exits `1` when no target is selected, when any target fails, or when the `tag.onAfterWrite` hook fails.
251
281
 
252
282
  ## `audit`
@@ -317,11 +347,6 @@ codefast audit comments --fix # rewrite fixable dividers in place
317
347
  codefast audit comments --json # machine-readable summary
318
348
  ```
319
349
 
320
- | Flag | Description |
321
- | -------- | ---------------------------------------------------- |
322
- | `--fix` | Rewrite every mechanically fixable divider in place. |
323
- | `--json` | Print one JSON summary on stdout. |
324
-
325
350
  Configure exceptions via `audit.comments.allowlist` — each entry is a divider line as written or
326
351
  `repo/relative/path.ts:<divider>`.
327
352
 
@@ -1,18 +1,95 @@
1
- import process from "node:process";
2
1
  import { Command } from "commander";
3
- import { analyzeDirectory } from "#/arrange/analyze";
4
- import { arrangeAnalyzeDirectoryRequestSchema, arrangeSuggestGroupsRequestSchema, arrangeSyncRunRequestSchema, } from "#/arrange/cli-schema";
5
- import { printAnalyzeReport, printGroupFilePreviewFromWork, printSimplifyResult, printSyncResult, } from "#/arrange/output";
6
- import { runArrangeSimplify } from "#/arrange/simplify-sync";
7
- import { suggestCnGroupsFromCli } from "#/arrange/suggest";
8
- import { runArrangeSync } from "#/arrange/sync";
9
- import { prepareArrangeWorkspace } from "#/arrange/workspace";
10
- import { readOptionalPositionalArg } from "#/core/cli/positional";
11
- import { consumeCliAppError, runCliResultAsync } from "#/core/cli/result-handle";
12
- import { CLI_EXIT_GENERAL_ERROR, CLI_EXIT_SUCCESS } from "#/core/exit-codes";
13
- import { nodeFilesystem } from "#/core/filesystem/node";
14
- import { logger } from "#/core/logger";
15
- import { parseWithSchema } from "#/core/schema-parse";
2
+ import { formatArrangeGroupJsonOutput } from "#arrange/group/cli-result";
3
+ import { arrangeSuggestGroupsRequestSchema } from "#arrange/group/cli-schema";
4
+ import { presentArrangeGroupResult } from "#arrange/group/output";
5
+ import { suggestCnGroupsFromCli } from "#arrange/group/suggest";
6
+ import { formatArrangeAnalyzeJsonOutput } from "#arrange/inspect/cli-result";
7
+ import { arrangeAnalyzeDirectoryRequestSchema } from "#arrange/inspect/cli-schema";
8
+ import { presentAnalyzeReport } from "#arrange/inspect/output";
9
+ import { runArrangeInspect } from "#arrange/inspect/run";
10
+ import { prepareArrangeWorkspace } from "#arrange/prepare";
11
+ import { exitCodeForArrangeResult, formatArrangeJsonOutput } from "#arrange/regroup/cli-result";
12
+ import { arrangeRunRequestSchema } from "#arrange/regroup/cli-schema";
13
+ import { presentArrangeResult, presentGroupFilePreviewFromWork } from "#arrange/regroup/output";
14
+ import { runArrange } from "#arrange/regroup/run";
15
+ import { formatArrangeSimplifyJsonOutput } from "#arrange/simplify/cli-result";
16
+ import { arrangeSimplifyRunRequestSchema } from "#arrange/simplify/cli-schema";
17
+ import { presentSimplifyResult } from "#arrange/simplify/output";
18
+ import { runArrangeSimplify } from "#arrange/simplify/run";
19
+ import { applyCommandPipeline, registerPipelineSubcommand } from "#core/cli/command-pipeline";
20
+ import { consumeCliAppError } from "#core/cli/result-handle";
21
+ import { CLI_EXIT_SUCCESS } from "#core/exit-codes";
22
+ import { nodeFilesystem } from "#core/filesystem/node";
23
+ import { logger } from "#core/logger";
24
+ import { parseWithSchema } from "#core/schema-parse";
25
+ const targetHelp = "Directory or file (default: nearest package directory from cwd)";
26
+ const prepareWorkspace = (fs, input) => prepareArrangeWorkspace(fs, { currentWorkingDirectory: input.currentWorkingDirectory, rawTarget: input.rawArg });
27
+ const regroupPipeline = {
28
+ positional: { name: "[target]", help: targetHelp },
29
+ schema: arrangeRunRequestSchema,
30
+ configureArgv: (command) => {
31
+ command.option("--dry-run", "Preview suggested replacements without writing files", false);
32
+ command.option("--with-classname, --with-class-name", "Append className as final cn() argument", false);
33
+ command.option("--cn-import <spec>", "Override module specifier when adding cn import");
34
+ },
35
+ prepare: prepareWorkspace,
36
+ buildRequest: ({ prelude, opts }) => ({
37
+ rootDir: prelude.rootDir,
38
+ targetPath: prelude.resolvedTarget,
39
+ write: !opts.dryRun,
40
+ withClassName: opts.withClassName,
41
+ cnImport: opts.cnImport,
42
+ config: prelude.config.arrange ?? {},
43
+ }),
44
+ run: (fs, request) => runArrange(fs, request),
45
+ presentHuman: ({ result, opts }) => {
46
+ // Dry-run previews are human-only; the --json summary omits the non-serializable plans.
47
+ if (opts.dryRun) {
48
+ for (const plan of result.previewPlans) {
49
+ presentGroupFilePreviewFromWork(plan);
50
+ }
51
+ }
52
+ presentArrangeResult(result, !opts.dryRun);
53
+ },
54
+ formatJson: ({ result, opts }) => formatArrangeJsonOutput(result, !opts.dryRun),
55
+ exitCode: exitCodeForArrangeResult,
56
+ };
57
+ const inspectPipeline = {
58
+ name: "inspect",
59
+ description: "Report long strings, nested cn in tv(), and related findings (read-only)",
60
+ positional: { name: "[target]", help: targetHelp },
61
+ schema: arrangeAnalyzeDirectoryRequestSchema,
62
+ prepare: prepareWorkspace,
63
+ buildRequest: ({ prelude }) => ({ analyzeRootPath: prelude.resolvedTarget }),
64
+ run: async (fs, request) => runArrangeInspect(fs, request.analyzeRootPath),
65
+ presentHuman: ({ result, prelude }) => {
66
+ presentAnalyzeReport(prelude.resolvedTarget, result);
67
+ },
68
+ formatJson: ({ result, prelude }) => formatArrangeAnalyzeJsonOutput(prelude.resolvedTarget, result),
69
+ exitCode: () => CLI_EXIT_SUCCESS,
70
+ };
71
+ const simplifyPipeline = {
72
+ name: "simplify",
73
+ description: "Flatten grouped arrays and static-only cn() calls back to plain strings in tv() slots",
74
+ positional: { name: "[target]", help: targetHelp },
75
+ schema: arrangeSimplifyRunRequestSchema,
76
+ configureArgv: (command) => {
77
+ command.option("--dry-run", "Show what simplify would change without writing files", false);
78
+ command.option("--fold-variant-classname, --fold-variant-class-name", "Fold cn() overrides into a variant function's className option (uses the TypeScript type server)", false);
79
+ },
80
+ prepare: prepareWorkspace,
81
+ buildRequest: ({ prelude, opts }) => ({
82
+ targetPath: prelude.resolvedTarget,
83
+ write: !opts.dryRun,
84
+ foldVariantClassName: opts.foldVariantClassName,
85
+ }),
86
+ run: (fs, request) => runArrangeSimplify(fs, request),
87
+ presentHuman: ({ result, opts }) => {
88
+ presentSimplifyResult(result, !opts.dryRun);
89
+ },
90
+ formatJson: ({ result, opts }) => formatArrangeSimplifyJsonOutput(result, !opts.dryRun),
91
+ exitCode: () => CLI_EXIT_SUCCESS,
92
+ };
16
93
  /**
17
94
  * Creates the `arrange` command and its subcommands.
18
95
  *
@@ -23,110 +100,19 @@ export function createArrangeCommand() {
23
100
  .description("Regroup Tailwind classes in cn() / tv() calls in render-pipeline order")
24
101
  // The parent action shares option names (--json) with subcommands; positional
25
102
  // options ensure tokens after a subcommand bind to that subcommand, not the parent.
26
- .enablePositionalOptions()
27
- .argument("[target]", "Directory or file (default: nearest package directory from cwd)")
28
- .option("--dry-run", "Preview suggested replacements without writing files", false)
29
- .option("--with-classname, --with-class-name", "Append className as final cn() argument", false)
30
- .option("--cn-import <spec>", "Override module specifier when adding cn import")
31
- .option("--json", "Print one JSON object on stdout (suppresses human progress)", false)
32
- .action(async (target, opts) => {
33
- const write = !opts.dryRun;
34
- const prelude = await prepareArrangeWorkspace(nodeFilesystem, {
35
- currentWorkingDirectory: process.cwd(),
36
- rawTarget: readOptionalPositionalArg(target),
37
- });
38
- if (!consumeCliAppError(prelude)) {
39
- return;
40
- }
41
- const { resolvedTarget, rootDir, config } = prelude.value;
42
- const parsed = parseWithSchema(arrangeSyncRunRequestSchema, {
43
- rootDir,
44
- targetPath: resolvedTarget,
45
- write,
46
- withClassName: opts.withClassName,
47
- cnImport: opts.cnImport,
48
- config: config.arrange ?? {},
49
- });
50
- if (!consumeCliAppError(parsed)) {
51
- return;
52
- }
53
- await runCliResultAsync(runArrangeSync(nodeFilesystem, parsed.value), (value) => {
54
- if (!write) {
55
- for (const plan of value.previewPlans) {
56
- printGroupFilePreviewFromWork(plan);
57
- }
58
- }
59
- if (opts.json) {
60
- logger.out(formatArrangeSyncJsonOutput(value, write));
61
- return exitCodeForArrangeSyncResult(value);
62
- }
63
- printSyncResult(value, write);
64
- return exitCodeForArrangeSyncResult(value);
65
- });
66
- });
67
- cmd
68
- .command("inspect")
69
- .description("Report long strings, nested cn in tv(), and related findings (read-only)")
70
- .argument("[target]", "Directory or file (default: nearest package directory from cwd)")
71
- .option("--json", "Print one JSON object on stdout instead of a human report", false)
72
- .action(async (target, opts) => {
73
- const prelude = await prepareArrangeWorkspace(nodeFilesystem, {
74
- currentWorkingDirectory: process.cwd(),
75
- rawTarget: readOptionalPositionalArg(target),
76
- });
77
- if (!consumeCliAppError(prelude)) {
78
- return;
79
- }
80
- const { resolvedTarget } = prelude.value;
81
- const parsed = parseWithSchema(arrangeAnalyzeDirectoryRequestSchema, {
82
- analyzeRootPath: resolvedTarget,
83
- });
84
- if (!consumeCliAppError(parsed)) {
85
- return;
86
- }
87
- const outcome = analyzeDirectory(nodeFilesystem, parsed.value.analyzeRootPath);
88
- if (!consumeCliAppError(outcome)) {
89
- return;
90
- }
91
- if (opts.json) {
92
- logger.out(formatArrangeAnalyzeJsonOutput(resolvedTarget, outcome.value));
93
- }
94
- else {
95
- printAnalyzeReport(resolvedTarget, outcome.value);
96
- }
97
- });
98
- cmd
99
- .command("simplify")
100
- .description("Flatten grouped arrays and static-only cn() calls back to plain strings in tv() slots")
101
- .argument("[target]", "Directory or file (default: nearest package directory from cwd)")
102
- .option("--dry-run", "Show what simplify would change without writing files", false)
103
- .option("--json", "Print one JSON object on stdout (suppresses human progress)", false)
104
- .action(async (target, opts) => {
105
- const write = !opts.dryRun;
106
- const prelude = await prepareArrangeWorkspace(nodeFilesystem, {
107
- currentWorkingDirectory: process.cwd(),
108
- rawTarget: readOptionalPositionalArg(target),
109
- });
110
- if (!consumeCliAppError(prelude)) {
111
- return;
112
- }
113
- const { resolvedTarget } = prelude.value;
114
- await runCliResultAsync(runArrangeSimplify(nodeFilesystem, { targetPath: resolvedTarget, write }), (value) => {
115
- if (opts.json) {
116
- logger.out(JSON.stringify({ schemaVersion: 1, ok: true, write, result: value }));
117
- return CLI_EXIT_SUCCESS;
118
- }
119
- printSimplifyResult(value, write);
120
- return CLI_EXIT_SUCCESS;
121
- });
122
- });
103
+ .enablePositionalOptions();
104
+ applyCommandPipeline(cmd, nodeFilesystem, regroupPipeline);
105
+ registerPipelineSubcommand(cmd, nodeFilesystem, inspectPipeline);
106
+ registerPipelineSubcommand(cmd, nodeFilesystem, simplifyPipeline);
107
+ // `group` is a pure token-string transform — no workspace prelude, a variadic positional — so it
108
+ // does not fit the workspace pipeline and stays wired by hand.
123
109
  cmd
124
110
  .command("group")
125
111
  .description("Try grouping on a pasted class string (stdout: cn(...) or tv array with --tv)")
126
112
  .argument("<tokens...>", "Class tokens (quote a single string if it contains spaces)")
127
113
  .option("--tv", "Emit tv()-style array instead of cn() call", false)
128
114
  .option("--with-classname, --with-class-name", "Append className as final cn() argument", false)
129
- .option("--json", "Print one JSON object on stdout instead of plain lines", false)
115
+ .option("--json", "Print one JSON object on stdout instead of the human-readable output", false)
130
116
  .action(async (classTokenSeries, opts) => {
131
117
  const parsed = parseWithSchema(arrangeSuggestGroupsRequestSchema, {
132
118
  inlineClasses: classTokenSeries.join(" ").trim(),
@@ -141,31 +127,8 @@ export function createArrangeCommand() {
141
127
  logger.out(formatArrangeGroupJsonOutput(output));
142
128
  }
143
129
  else {
144
- logger.out(output.primaryLine);
145
- logger.out(output.bucketsCommentLine);
130
+ presentArrangeGroupResult(output);
146
131
  }
147
132
  });
148
133
  return cmd;
149
- }
150
- function formatArrangeAnalyzeJsonOutput(analyzeRootPath, report) {
151
- return JSON.stringify({ schemaVersion: 1, analyzeRootPath, report });
152
- }
153
- function formatArrangeSyncJsonOutput(result, write) {
154
- const { previewPlans: _plans, ...serializableResult } = result;
155
- return JSON.stringify({
156
- schemaVersion: 1,
157
- ok: result.hookError === null,
158
- write,
159
- result: serializableResult,
160
- });
161
- }
162
- function formatArrangeGroupJsonOutput(output) {
163
- return JSON.stringify({
164
- schemaVersion: 1,
165
- primaryLine: output.primaryLine,
166
- bucketsCommentLine: output.bucketsCommentLine,
167
- });
168
- }
169
- function exitCodeForArrangeSyncResult(result) {
170
- return result.hookError !== null ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
171
134
  }
@@ -1,5 +1,5 @@
1
- import type { DomainAstNode } from "#/arrange/domain/ast/ast-node";
2
- import type { ForEachStringLiteralInClassExpressionOptions, TailwindClassLiteral } from "#/arrange/domain/types";
1
+ import type { DomainAstNode } from "#arrange/domain/ast/ast-node";
2
+ import type { ForEachStringLiteralInClassExpressionOptions, TailwindClassLiteral } from "#arrange/domain/types";
3
3
  /**
4
4
  * Visits every static class literal reachable inside a class expression.
5
5
  *
@@ -1,5 +1,5 @@
1
- import { DomainBinaryOperator, DomainSyntaxKind, isDomainArrayLiteralExpression, isDomainTailwindClassLiteral, } from "#/arrange/domain/ast/ast-node";
2
- import { MAX_CLASS_EXPR_DEPTH } from "#/arrange/domain/constants";
1
+ import { DomainBinaryOperator, DomainSyntaxKind, isDomainArrayLiteralExpression, isDomainTailwindClassLiteral, } from "#arrange/domain/ast/ast-node";
2
+ import { MAX_CLASS_EXPR_DEPTH } from "#arrange/domain/constants";
3
3
  /**
4
4
  * Visits every static class literal reachable inside a class expression.
5
5
  *
@@ -1,5 +1,5 @@
1
- import type { DomainJsxAttribute } from "#/arrange/domain/ast/ast-node";
2
- import type { JsxClassNameStatic } from "#/arrange/domain/types";
1
+ import type { DomainJsxAttribute } from "#arrange/domain/ast/ast-node";
2
+ import type { JsxClassNameStatic } from "#arrange/domain/types";
3
3
  /**
4
4
  * Extracts the static literal of a JSX `className` attribute, or `undefined` when it is not static.
5
5
  *
@@ -1,4 +1,4 @@
1
- import { isDomainIdentifier, isDomainJsxExpression, isDomainTailwindClassLiteral } from "#/arrange/domain/ast/ast-node";
1
+ import { isDomainIdentifier, isDomainJsxExpression, isDomainTailwindClassLiteral } from "#arrange/domain/ast/ast-node";
2
2
  /**
3
3
  * Extracts the static literal of a JSX `className` attribute, or `undefined` when it is not static.
4
4
  *
@@ -1,5 +1,5 @@
1
- import type { DomainCallExpression, DomainObjectLiteralExpression, DomainSourceFile } from "#/arrange/domain/ast/ast-node";
2
- import type { StringNode, TailwindClassLiteral } from "#/arrange/domain/types";
1
+ import type { DomainCallExpression, DomainObjectLiteralExpression, DomainSourceFile } from "#arrange/domain/ast/ast-node";
2
+ import type { StringNode, TailwindClassLiteral } from "#arrange/domain/types";
3
3
  type StringNodeVisitor = (classLiteral: TailwindClassLiteral, sourceFile: DomainSourceFile, cnCall?: DomainCallExpression) => void;
4
4
  /**
5
5
  * Visits every class literal reachable inside a `tv({ ... })` object, including `cn()` arguments.
@@ -1,8 +1,8 @@
1
- import { isDomainArrayLiteralExpression, isDomainCallExpression, isDomainObjectLiteralExpression, isDomainPropertyAssignment, isDomainSpreadElement, isDomainTailwindClassLiteral, forEachDomainChild, } from "#/arrange/domain/ast/ast-node";
2
- import { CN_APPLY_LITERAL_WALK_OPTS, collectUnconditionalTailwindLiteralsFromCnArguments, forEachStringLiteralInClassExpression, isUnsafeLiteralForCnStyleApplySplit, } from "#/arrange/domain/ast/collectors-cn";
3
- import { buildKnownCnTvBindings, isCnOrTvIdentifier, propertyAssignmentNameText } from "#/arrange/domain/ast/helpers";
4
- import { APPLY_MIN_TOKENS, MAX_OBJECT_DEPTH } from "#/arrange/domain/constants";
5
- import { tokenizeClassString } from "#/arrange/domain/tailwind-token";
1
+ import { isDomainArrayLiteralExpression, isDomainCallExpression, isDomainObjectLiteralExpression, isDomainPropertyAssignment, isDomainSpreadElement, isDomainTailwindClassLiteral, forEachDomainChild, } from "#arrange/domain/ast/ast-node";
2
+ import { CN_APPLY_LITERAL_WALK_OPTS, collectUnconditionalTailwindLiteralsFromCnArguments, forEachStringLiteralInClassExpression, isUnsafeLiteralForCnStyleApplySplit, } from "#arrange/domain/ast/collectors-cn";
3
+ import { buildKnownCnTvBindings, isCnOrTvIdentifier, propertyAssignmentNameText } from "#arrange/domain/ast/helpers";
4
+ import { APPLY_MIN_TOKENS, MAX_OBJECT_DEPTH } from "#arrange/domain/constants";
5
+ import { tokenizeClassString } from "#arrange/domain/tailwind-token";
6
6
  /**
7
7
  * Visits every class literal reachable inside a `tv({ ... })` object, including `cn()` arguments.
8
8
  *
@@ -1,5 +1,5 @@
1
- import type { DomainAstNode, DomainCallExpression, DomainPropertyAssignment, DomainSourceFile } from "#/arrange/domain/ast/ast-node";
2
- import { applyEditsDescending } from "#/core/source-text-edit";
1
+ import type { DomainAstNode, DomainCallExpression, DomainPropertyAssignment, DomainSourceFile } from "#arrange/domain/ast/ast-node";
2
+ import { applyEditsDescending } from "#core/source-text-edit";
3
3
  /**
4
4
  * Builds a set of local binding names that are imported from a known cn/tv
5
5
  * module in `sourceFile`.
@@ -1,6 +1,6 @@
1
- import { isDomainIdentifier, isDomainImportDeclaration, isDomainNamedImports, isDomainNamespaceImport, isDomainPropertyAccessExpression, isDomainStringLiteral, lineOfSourcePosition, } from "#/arrange/domain/ast/ast-node";
2
- import { EMPTY_CN_TV_BINDINGS } from "#/arrange/domain/constants";
3
- import { applyEditsDescending, indentOfLineContaining } from "#/core/source-text-edit";
1
+ import { isDomainIdentifier, isDomainImportDeclaration, isDomainNamedImports, isDomainNamespaceImport, isDomainPropertyAccessExpression, isDomainStringLiteral, lineOfSourcePosition, } from "#arrange/domain/ast/ast-node";
2
+ import { EMPTY_CN_TV_BINDINGS } from "#arrange/domain/constants";
3
+ import { applyEditsDescending, indentOfLineContaining } from "#core/source-text-edit";
4
4
  /**
5
5
  * Known module specifiers that export `cn` / `tv`.
6
6
  */
@@ -12,7 +12,6 @@ const KNOWN_CN_TV_MODULES = new Set([
12
12
  // from "tailwind-variants"; new code should prefer "@codefast/tailwind-variants".
13
13
  "tailwind-variants",
14
14
  "#lib/utils",
15
- "#/lib/utils",
16
15
  "~/lib/utils",
17
16
  "@/lib/utils",
18
17
  ]);
@@ -1,4 +1,4 @@
1
- import type { DomainSourceFile } from "#/arrange/domain/ast/ast-node";
1
+ import type { DomainSourceFile } from "#arrange/domain/ast/ast-node";
2
2
  /**
3
3
  * A planned text replacement produced by the simplify pass.
4
4
  *