@codefast/cli 0.9.0 → 0.11.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 (279) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +345 -151
  3. package/dist/arrange/command.d.ts +7 -0
  4. package/dist/arrange/command.js +96 -132
  5. package/dist/arrange/domain/ast/ast-node.d.ts +394 -0
  6. package/dist/arrange/domain/ast/collectors-cn.d.ts +26 -0
  7. package/dist/arrange/domain/ast/collectors-jsx.d.ts +8 -0
  8. package/dist/arrange/domain/ast/collectors-tv.d.ts +34 -0
  9. package/dist/arrange/domain/ast/helpers.d.ts +36 -0
  10. package/dist/arrange/domain/ast/helpers.js +1 -0
  11. package/dist/arrange/domain/ast/simplify-targets.d.ts +22 -0
  12. package/dist/arrange/domain/ast/simplify-targets.js +18 -23
  13. package/dist/arrange/domain/ast/targets.d.ts +20 -0
  14. package/dist/arrange/domain/ast/translator.d.ts +32 -0
  15. package/dist/arrange/{typescript-ast-translator.js → domain/ast/translator.js} +19 -22
  16. package/dist/arrange/domain/constants.d.ts +111 -0
  17. package/dist/arrange/domain/grouping-service.d.ts +100 -0
  18. package/dist/arrange/domain/grouping.d.ts +21 -0
  19. package/dist/arrange/domain/imports.d.ts +14 -0
  20. package/dist/arrange/domain/source-text-formatters.d.ts +33 -0
  21. package/dist/arrange/domain/tailwind-token.d.ts +24 -0
  22. package/dist/arrange/domain/token-classifier.d.ts +47 -0
  23. package/dist/arrange/domain/types.d.ts +208 -0
  24. package/dist/arrange/group/cli-result.d.ts +7 -0
  25. package/dist/arrange/group/cli-result.js +12 -0
  26. package/dist/arrange/group/cli-schema.d.ts +17 -0
  27. package/dist/arrange/group/cli-schema.js +13 -0
  28. package/dist/arrange/group/output.d.ts +7 -0
  29. package/dist/arrange/group/output.js +10 -0
  30. package/dist/arrange/group/suggest.d.ts +8 -0
  31. package/dist/arrange/inspect/cli-result.d.ts +7 -0
  32. package/dist/arrange/inspect/cli-result.js +8 -0
  33. package/dist/arrange/inspect/cli-schema.d.ts +15 -0
  34. package/dist/arrange/inspect/cli-schema.js +9 -0
  35. package/dist/arrange/inspect/domain/analyze-service.d.ts +18 -0
  36. package/dist/arrange/inspect/output.d.ts +7 -0
  37. package/dist/arrange/inspect/output.js +42 -0
  38. package/dist/arrange/inspect/run.d.ts +10 -0
  39. package/dist/arrange/{analyze.js → inspect/run.js} +2 -2
  40. package/dist/arrange/prepare.d.ts +13 -0
  41. package/dist/arrange/{workspace.js → prepare.js} +5 -8
  42. package/dist/arrange/regroup/cli-result.d.ts +13 -0
  43. package/dist/arrange/regroup/cli-result.js +23 -0
  44. package/dist/arrange/regroup/cli-schema.d.ts +20 -0
  45. package/dist/arrange/regroup/cli-schema.js +14 -0
  46. package/dist/arrange/regroup/output.d.ts +14 -0
  47. package/dist/arrange/regroup/output.js +72 -0
  48. package/dist/arrange/regroup/process-file.d.ts +11 -0
  49. package/dist/arrange/regroup/run.d.ts +11 -0
  50. package/dist/arrange/{sync.js → regroup/run.js} +2 -2
  51. package/dist/arrange/resolve-target.d.ts +10 -0
  52. package/dist/arrange/resolve-target.js +3 -16
  53. package/dist/arrange/scan-target.d.ts +7 -0
  54. package/dist/arrange/simplify/cli-result.d.ts +7 -0
  55. package/dist/arrange/simplify/cli-result.js +8 -0
  56. package/dist/arrange/simplify/cli-schema.d.ts +17 -0
  57. package/dist/arrange/simplify/cli-schema.js +11 -0
  58. package/dist/arrange/simplify/fold-targets.d.ts +13 -0
  59. package/dist/arrange/simplify/fold-targets.js +139 -0
  60. package/dist/arrange/simplify/output.d.ts +7 -0
  61. package/dist/arrange/simplify/output.js +15 -0
  62. package/dist/arrange/simplify/process-file.d.ts +13 -0
  63. package/dist/arrange/simplify/process-file.js +49 -0
  64. package/dist/arrange/simplify/run.d.ts +14 -0
  65. package/dist/arrange/simplify/run.js +38 -0
  66. package/dist/arrange/simplify/variant-classname-probe.d.ts +35 -0
  67. package/dist/arrange/simplify/variant-classname-probe.js +95 -0
  68. package/dist/arrange/source-parse.d.ts +7 -0
  69. package/dist/arrange/source-parse.js +1 -1
  70. package/dist/audit/command.d.ts +8 -0
  71. package/dist/audit/command.js +134 -211
  72. package/dist/audit/comments/cli-result.d.ts +13 -0
  73. package/dist/audit/comments/cli-result.js +22 -0
  74. package/dist/audit/comments/cli-schema.d.ts +19 -0
  75. package/dist/audit/comments/cli-schema.js +13 -0
  76. package/dist/audit/comments/domain/comment-content.d.ts +26 -0
  77. package/dist/audit/comments/domain/comment-dividers.d.ts +62 -0
  78. package/dist/audit/comments/domain/link-references.d.ts +40 -0
  79. package/dist/audit/comments/domain/since-versions.d.ts +26 -0
  80. package/dist/audit/comments/domain/tsdoc-syntax.d.ts +20 -0
  81. package/dist/audit/comments/output.d.ts +7 -0
  82. package/dist/audit/comments/output.js +27 -0
  83. package/dist/audit/comments/prepare.d.ts +16 -0
  84. package/dist/audit/comments/prepare.js +12 -0
  85. package/dist/audit/comments/run.d.ts +17 -0
  86. package/dist/audit/{run-comments.js → comments/run.js} +5 -5
  87. package/dist/audit/display-names/cli-result.d.ts +13 -0
  88. package/dist/audit/display-names/cli-result.js +22 -0
  89. package/dist/audit/display-names/cli-schema.d.ts +18 -0
  90. package/dist/audit/display-names/cli-schema.js +12 -0
  91. package/dist/audit/display-names/domain/display-names.d.ts +11 -0
  92. package/dist/audit/display-names/output.d.ts +7 -0
  93. package/dist/audit/display-names/output.js +21 -0
  94. package/dist/audit/display-names/prepare.d.ts +16 -0
  95. package/dist/audit/display-names/prepare.js +12 -0
  96. package/dist/audit/display-names/run.d.ts +14 -0
  97. package/dist/audit/{run-display-names.js → display-names/run.js} +1 -1
  98. package/dist/audit/domain/types.d.ts +171 -0
  99. package/dist/audit/imports/cli-result.d.ts +13 -0
  100. package/dist/audit/imports/cli-result.js +22 -0
  101. package/dist/audit/imports/cli-schema.d.ts +18 -0
  102. package/dist/audit/imports/cli-schema.js +12 -0
  103. package/dist/audit/imports/domain/import-policy.d.ts +34 -0
  104. package/dist/audit/imports/domain/import-policy.js +140 -0
  105. package/dist/audit/imports/output.d.ts +7 -0
  106. package/dist/audit/imports/output.js +21 -0
  107. package/dist/audit/imports/prepare.d.ts +16 -0
  108. package/dist/audit/imports/prepare.js +12 -0
  109. package/dist/audit/imports/run.d.ts +14 -0
  110. package/dist/audit/{run-react.js → imports/run.js} +15 -5
  111. package/dist/audit/links/cli-result.d.ts +13 -0
  112. package/dist/audit/links/cli-result.js +22 -0
  113. package/dist/audit/links/cli-schema.d.ts +18 -0
  114. package/dist/audit/links/cli-schema.js +12 -0
  115. package/dist/audit/links/domain/markdown-links.d.ts +44 -0
  116. package/dist/audit/links/output.d.ts +7 -0
  117. package/dist/audit/links/output.js +21 -0
  118. package/dist/audit/links/prepare.d.ts +16 -0
  119. package/dist/audit/links/prepare.js +12 -0
  120. package/dist/audit/links/run.d.ts +14 -0
  121. package/dist/audit/{run-links.js → links/run.js} +1 -1
  122. package/dist/audit/prepare.d.ts +31 -0
  123. package/dist/audit/prepare.js +11 -134
  124. package/dist/audit/rtl/cli-result.d.ts +13 -0
  125. package/dist/audit/rtl/cli-result.js +22 -0
  126. package/dist/audit/rtl/cli-schema.d.ts +18 -0
  127. package/dist/audit/rtl/cli-schema.js +12 -0
  128. package/dist/audit/rtl/domain/audit-file.d.ts +7 -0
  129. package/dist/audit/{domain → rtl/domain}/audit-file.js +2 -2
  130. package/dist/audit/rtl/domain/mappings.d.ts +45 -0
  131. package/dist/audit/rtl/domain/tokenize.d.ts +14 -0
  132. package/dist/audit/rtl/output.d.ts +7 -0
  133. package/dist/audit/rtl/output.js +21 -0
  134. package/dist/audit/rtl/prepare.d.ts +13 -0
  135. package/dist/audit/rtl/prepare.js +41 -0
  136. package/dist/audit/rtl/run.d.ts +14 -0
  137. package/dist/audit/{run.js → rtl/run.js} +1 -1
  138. package/dist/bin.d.ts +2 -0
  139. package/dist/cli.d.ts +6 -0
  140. package/dist/core/cli/command-pipeline.d.ts +91 -0
  141. package/dist/core/cli/command-pipeline.js +83 -0
  142. package/dist/core/cli/format-error.d.ts +7 -0
  143. package/dist/core/cli/global-options.d.ts +15 -0
  144. package/dist/core/cli/global-options.js +1 -1
  145. package/dist/core/cli/positional.d.ts +6 -0
  146. package/dist/core/cli/resolve-root.d.ts +9 -0
  147. package/dist/core/cli/resolve-root.js +16 -0
  148. package/dist/core/cli/result-handle.d.ts +13 -0
  149. package/dist/core/cli/result-handle.js +0 -13
  150. package/dist/core/config/define-config.d.ts +7 -0
  151. package/dist/core/config/define-config.js +8 -0
  152. package/dist/core/config/loader.d.ts +18 -0
  153. package/dist/core/config/loader.js +2 -7
  154. package/dist/core/config/schema.d.ts +99 -0
  155. package/dist/core/config/schema.js +8 -86
  156. package/dist/core/config/warnings.d.ts +6 -0
  157. package/dist/core/config.d.ts +12 -0
  158. package/dist/core/errors.d.ts +25 -0
  159. package/dist/core/exit-codes.d.ts +18 -0
  160. package/dist/core/filesystem/filesystem.d.ts +44 -0
  161. package/dist/core/filesystem/node.d.ts +7 -0
  162. package/dist/core/filesystem/node.js +2 -1
  163. package/dist/core/glob.d.ts +19 -0
  164. package/dist/core/logger.d.ts +9 -0
  165. package/dist/core/result.d.ts +30 -0
  166. package/dist/core/schema-parse.d.ts +9 -0
  167. package/dist/core/source-text-edit.d.ts +47 -0
  168. package/dist/core/source-text-edit.js +22 -0
  169. package/dist/core/verbose-diagnostics.d.ts +6 -0
  170. package/dist/core/workspace/ancestor-directories.d.ts +12 -0
  171. package/dist/core/workspace/ancestor-directories.js +30 -0
  172. package/dist/core/workspace/markdown-walk.d.ts +7 -0
  173. package/dist/core/workspace/markdown-walk.js +2 -20
  174. package/dist/core/workspace/package-version.d.ts +9 -0
  175. package/dist/core/workspace/package-version.js +8 -12
  176. package/dist/core/workspace/resolver.d.ts +39 -0
  177. package/dist/core/workspace/resolver.js +58 -75
  178. package/dist/core/workspace/skip-directories.d.ts +6 -0
  179. package/dist/core/workspace/source-walk.d.ts +16 -0
  180. package/dist/core/workspace/source-walk.js +2 -19
  181. package/dist/core/workspace/typescript-walk.d.ts +7 -0
  182. package/dist/core/workspace/typescript-walk.js +2 -23
  183. package/dist/core/workspace/walk-files.d.ts +7 -0
  184. package/dist/core/workspace/walk-files.js +27 -0
  185. package/dist/core/workspace/well-known-files.d.ts +18 -0
  186. package/dist/core/workspace/well-known-files.js +18 -0
  187. package/dist/index.d.ts +6 -0
  188. package/dist/index.js +5 -0
  189. package/dist/mirror/cli-result.d.ts +13 -0
  190. package/dist/mirror/cli-schema.d.ts +8 -0
  191. package/dist/mirror/cli-schema.js +1 -1
  192. package/dist/mirror/command.d.ts +7 -0
  193. package/dist/mirror/command.js +31 -60
  194. package/dist/mirror/dist-filesystem-node.d.ts +8 -0
  195. package/dist/mirror/{dist-filesystem-impl.js → dist-filesystem-node.js} +1 -1
  196. package/dist/mirror/domain/constants.d.ts +18 -0
  197. package/dist/mirror/domain/constants.js +0 -12
  198. package/dist/mirror/domain/dirent-guard.d.ts +10 -0
  199. package/dist/mirror/domain/dist-filesystem.d.ts +9 -0
  200. package/dist/mirror/domain/errors.d.ts +24 -0
  201. package/dist/mirror/domain/exports.d.ts +36 -0
  202. package/dist/mirror/domain/package-display-name.d.ts +8 -0
  203. package/dist/mirror/domain/path-normalizer.d.ts +6 -0
  204. package/dist/mirror/domain/types.d.ts +188 -0
  205. package/dist/mirror/output.d.ts +21 -0
  206. package/dist/mirror/output.js +126 -1
  207. package/dist/mirror/package-path.d.ts +19 -0
  208. package/dist/mirror/prepare.d.ts +15 -0
  209. package/dist/mirror/prepare.js +6 -10
  210. package/dist/mirror/run.d.ts +12 -0
  211. package/dist/mirror/{sync.js → run.js} +5 -3
  212. package/dist/mirror/supplement-exports.d.ts +27 -0
  213. package/dist/mirror/supplement-exports.js +2 -2
  214. package/dist/mirror/sync-workspace-package.d.ts +9 -0
  215. package/dist/mirror/sync-workspace-package.js +4 -4
  216. package/dist/mirror/write-exports.d.ts +15 -0
  217. package/dist/pack-slim/cli-result.d.ts +13 -0
  218. package/dist/pack-slim/cli-schema.d.ts +17 -0
  219. package/dist/pack-slim/cli-schema.js +1 -1
  220. package/dist/pack-slim/command.d.ts +7 -0
  221. package/dist/pack-slim/command.js +31 -66
  222. package/dist/pack-slim/domain/transform.d.ts +69 -0
  223. package/dist/pack-slim/domain/types.d.ts +46 -0
  224. package/dist/pack-slim/output.d.ts +15 -0
  225. package/dist/pack-slim/prepare.d.ts +21 -0
  226. package/dist/pack-slim/prepare.js +14 -0
  227. package/dist/pack-slim/run.d.ts +23 -0
  228. package/dist/pack-slim/{sync.js → run.js} +4 -4
  229. package/dist/pack-slim/working-tree.d.ts +20 -0
  230. package/dist/tag/cli-result.d.ts +13 -0
  231. package/dist/tag/cli-result.js +14 -1
  232. package/dist/tag/cli-schema.d.ts +8 -0
  233. package/dist/tag/cli-schema.js +3 -4
  234. package/dist/tag/command.d.ts +7 -0
  235. package/dist/tag/command.js +33 -60
  236. package/dist/tag/domain/skip-filter.d.ts +13 -0
  237. package/dist/tag/domain/skip-filter.js +29 -0
  238. package/dist/tag/domain/types.d.ts +131 -0
  239. package/dist/tag/domain/version-summary.d.ts +13 -0
  240. package/dist/tag/domain/version-summary.js +24 -0
  241. package/dist/tag/output.d.ts +17 -0
  242. package/dist/tag/output.js +6 -9
  243. package/dist/tag/prepare.d.ts +13 -0
  244. package/dist/tag/prepare.js +4 -4
  245. package/dist/tag/run.d.ts +10 -0
  246. package/dist/tag/{sync.js → run.js} +20 -50
  247. package/dist/tag/target/candidates.d.ts +8 -0
  248. package/dist/tag/{target-candidates.js → target/candidates.js} +2 -2
  249. package/dist/tag/target/resolve-path.d.ts +10 -0
  250. package/dist/tag/target/runner.d.ts +8 -0
  251. package/dist/tag/{target-runner.js → target/runner.js} +2 -2
  252. package/dist/tag/writer/since-writer.d.ts +32 -0
  253. package/dist/tag/writer/version-resolver.d.ts +7 -0
  254. package/package.json +21 -2
  255. package/dist/arrange/cli-schema.js +0 -34
  256. package/dist/arrange/output.js +0 -127
  257. package/dist/arrange/simplify-process-file.js +0 -30
  258. package/dist/arrange/simplify-sync.js +0 -30
  259. package/dist/audit/cli-schema.js +0 -66
  260. package/dist/audit/domain/react-imports.js +0 -91
  261. package/dist/audit/output.js +0 -213
  262. package/dist/mirror/sync-reporter.js +0 -124
  263. package/dist/mirror/sync-types.js +0 -1
  264. /package/dist/arrange/{suggest.js → group/suggest.js} +0 -0
  265. /package/dist/arrange/{domain → inspect/domain}/analyze-service.js +0 -0
  266. /package/dist/arrange/{process-file.js → regroup/process-file.js} +0 -0
  267. /package/dist/audit/{domain → comments/domain}/comment-content.js +0 -0
  268. /package/dist/audit/{domain → comments/domain}/comment-dividers.js +0 -0
  269. /package/dist/audit/{domain → comments/domain}/link-references.js +0 -0
  270. /package/dist/audit/{domain → comments/domain}/since-versions.js +0 -0
  271. /package/dist/audit/{domain → comments/domain}/tsdoc-syntax.js +0 -0
  272. /package/dist/audit/{domain → display-names/domain}/display-names.js +0 -0
  273. /package/dist/audit/{domain → links/domain}/markdown-links.js +0 -0
  274. /package/dist/audit/{domain → rtl/domain}/mappings.js +0 -0
  275. /package/dist/audit/{domain → rtl/domain}/tokenize.js +0 -0
  276. /package/dist/core/filesystem/{port.js → filesystem.js} +0 -0
  277. /package/dist/tag/{resolve-target-path.js → target/resolve-path.js} +0 -0
  278. /package/dist/tag/{since-writer.js → writer/since-writer.js} +0 -0
  279. /package/dist/tag/{version-resolver.js → writer/version-resolver.js} +0 -0
@@ -0,0 +1,131 @@
1
+ import type { CodefastConfig } from "#/core/config/schema";
2
+ /**
3
+ * Per-file outcome of a tag run.
4
+ *
5
+ * @since 0.3.16-canary.0
6
+ */
7
+ export type TagFileResult = {
8
+ filePath: string;
9
+ taggedDeclarations: number;
10
+ changed: boolean;
11
+ };
12
+ /**
13
+ * Outcome of tagging one target: the version stamped and the per-file tallies.
14
+ *
15
+ * @since 0.3.16-canary.0
16
+ */
17
+ export type TagRunResult = {
18
+ version: string;
19
+ filesScanned: number;
20
+ filesChanged: number;
21
+ taggedDeclarations: number;
22
+ fileResults: Array<TagFileResult>;
23
+ };
24
+ /**
25
+ * Options for one target's tag run.
26
+ *
27
+ * @since 0.3.16-canary.0
28
+ */
29
+ export type TagRunOptions = {
30
+ write: boolean;
31
+ };
32
+ type TagTargetCandidateSource = "explicit-target" | "workspace-package" | "repo-src-fallback";
33
+ /**
34
+ * How a resolved tag target was chosen.
35
+ *
36
+ * @since 0.3.16-canary.0
37
+ */
38
+ type TagTargetSource = "explicit-target" | "workspace-package-selected-src" | "workspace-package-selected-root" | "repo-src-fallback";
39
+ /**
40
+ * A candidate path a tag run may resolve into a target.
41
+ *
42
+ * @since 0.3.16-canary.0
43
+ */
44
+ export type TagTargetCandidate = {
45
+ candidatePath: string;
46
+ rootRelativeCandidatePath: string;
47
+ source: TagTargetCandidateSource;
48
+ packageDir: string | null;
49
+ packageName: string | null;
50
+ };
51
+ /**
52
+ * A directory or file a tag run will stamp, with its owning package when known.
53
+ *
54
+ * @since 0.3.16-canary.0
55
+ */
56
+ export type TagResolvedTarget = {
57
+ targetPath: string;
58
+ rootRelativeTargetPath: string;
59
+ source: TagTargetSource;
60
+ packageDir: string | null;
61
+ packageName: string | null;
62
+ };
63
+ /**
64
+ * One target's execution outcome, carrying either its run result or its error.
65
+ *
66
+ * @since 0.3.16-canary.0
67
+ */
68
+ export type TagTargetExecutionResult = {
69
+ target: TagResolvedTarget;
70
+ targetExists: boolean;
71
+ runError: string | null;
72
+ result: TagRunResult | null;
73
+ };
74
+ /**
75
+ * Callbacks a tag run invokes as each target starts and completes.
76
+ *
77
+ * @since 0.3.16-canary.0
78
+ */
79
+ export interface TagProgressListener {
80
+ onTargetStarted: (target: TagResolvedTarget) => void;
81
+ onTargetCompleted: (target: TagResolvedTarget, result: TagTargetExecutionResult) => void;
82
+ }
83
+ /**
84
+ * Aggregate outcome of a tag run across every selected target.
85
+ *
86
+ * @since 0.3.16-canary.0
87
+ */
88
+ export type TagResult = {
89
+ mode: "applied" | "dry-run";
90
+ selectedTargets: Array<TagResolvedTarget>;
91
+ skippedPackages: Array<string>;
92
+ targetResults: Array<TagTargetExecutionResult>;
93
+ filesScanned: number;
94
+ filesChanged: number;
95
+ taggedDeclarations: number;
96
+ versionSummary: string;
97
+ distinctVersions: Array<string>;
98
+ modifiedFiles: Array<string>;
99
+ hookError: string | null;
100
+ };
101
+ /**
102
+ * Everything the `tag` action needs resolved before a run: root, config, and target path.
103
+ *
104
+ * @since 0.3.16-canary.0
105
+ */
106
+ export interface TagCommandPrelude {
107
+ readonly rootDir: string;
108
+ readonly config: CodefastConfig;
109
+ readonly resolvedTargetPath: string | undefined;
110
+ }
111
+ /**
112
+ * The inputs a tag run is invoked with.
113
+ *
114
+ * @since 0.3.16-canary.0
115
+ */
116
+ export type TagRunRequest = {
117
+ rootDir: string;
118
+ write: boolean;
119
+ targetPath?: string | undefined;
120
+ skipPackages?: Array<string> | undefined;
121
+ config?: unknown;
122
+ };
123
+ /**
124
+ * A run request paired with an optional progress listener.
125
+ *
126
+ * @since 0.3.16-canary.0
127
+ */
128
+ export type TagExecutionInput = TagRunRequest & {
129
+ readonly listener?: TagProgressListener | undefined;
130
+ };
131
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { TagTargetExecutionResult } from "#/tag/domain/types";
2
+ /**
3
+ * Collects the distinct, non-empty package versions stamped across a run's target results.
4
+ *
5
+ * @since 0.11.0
6
+ */
7
+ export declare function extractDistinctVersions(targetResults: Array<TagTargetExecutionResult>): Set<string>;
8
+ /**
9
+ * Summarizes a set of versions as `"none"`, the single version, or `"mixed"`.
10
+ *
11
+ * @since 0.11.0
12
+ */
13
+ export declare function summarizeVersions(distinctVersions: Set<string>): string;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Collects the distinct, non-empty package versions stamped across a run's target results.
3
+ *
4
+ * @since 0.11.0
5
+ */
6
+ export function extractDistinctVersions(targetResults) {
7
+ return new Set(targetResults
8
+ .map((targetResult) => targetResult.result?.version)
9
+ .filter((version) => typeof version === "string" && version.length > 0));
10
+ }
11
+ /**
12
+ * Summarizes a set of versions as `"none"`, the single version, or `"mixed"`.
13
+ *
14
+ * @since 0.11.0
15
+ */
16
+ export function summarizeVersions(distinctVersions) {
17
+ if (distinctVersions.size === 0) {
18
+ return "none";
19
+ }
20
+ if (distinctVersions.size > 1) {
21
+ return "mixed";
22
+ }
23
+ return distinctVersions.values().next().value ?? "none";
24
+ }
@@ -0,0 +1,17 @@
1
+ import type { TagProgressListener, TagResolvedTarget, TagResult, TagTargetExecutionResult } from "#/tag/domain/types";
2
+ /**
3
+ * A progress listener that prints a line as each tag target starts and completes.
4
+ *
5
+ * @since 0.3.16-canary.0
6
+ */
7
+ export declare class TagProgressPresenter implements TagProgressListener {
8
+ onTargetStarted(target: TagResolvedTarget): void;
9
+ onTargetCompleted(target: TagResolvedTarget, result: TagTargetExecutionResult): void;
10
+ private static formatProgress;
11
+ }
12
+ /**
13
+ * Prints a tag run's target table, warnings, and summary to the human reader.
14
+ *
15
+ * @since 0.3.16-canary.0
16
+ */
17
+ export declare function presentTagResult(result: TagResult, rootDir: string): void;
@@ -1,17 +1,15 @@
1
- import { CLI_EXIT_GENERAL_ERROR } from "#/core/exit-codes";
2
1
  import { logger } from "#/core/logger";
3
- import { exitCodeForTagSyncResult } from "#/tag/cli-result";
4
2
  /**
5
3
  * A progress listener that prints a line as each tag target starts and completes.
6
4
  *
7
5
  * @since 0.3.16-canary.0
8
6
  */
9
- export class TagSyncProgressPresenter {
7
+ export class TagProgressPresenter {
10
8
  onTargetStarted(target) {
11
- logger.out(TagSyncProgressPresenter.formatProgress({ type: "target-started", target }));
9
+ logger.out(TagProgressPresenter.formatProgress({ type: "target-started", target }));
12
10
  }
13
11
  onTargetCompleted(target, result) {
14
- logger.out(TagSyncProgressPresenter.formatProgress({ type: "target-completed", target, result }));
12
+ logger.out(TagProgressPresenter.formatProgress({ type: "target-completed", target, result }));
15
13
  }
16
14
  static formatProgress(event) {
17
15
  const targetDisplayName = (target) => target.packageName ?? target.rootRelativeTargetPath;
@@ -29,22 +27,21 @@ const colors = {
29
27
  yellow: "\x1b[33m",
30
28
  };
31
29
  /**
32
- * Prints a tag run's target table, warnings, and summary, and returns the exit code.
30
+ * Prints a tag run's target table, warnings, and summary to the human reader.
33
31
  *
34
32
  * @since 0.3.16-canary.0
35
33
  */
36
- export function presentTagSyncResult(result, rootDir) {
34
+ export function presentTagResult(result, rootDir) {
37
35
  logger.out(formatTargetTable(result.selectedTargets, rootDir));
38
36
  if (result.selectedTargets.length === 0) {
39
37
  logger.err("No packages found in workspace. Check your pnpm-workspace.yaml or provide an explicit target path.");
40
- return CLI_EXIT_GENERAL_ERROR;
38
+ return;
41
39
  }
42
40
  const warningsAndErrorsSection = formatWarningsAndErrors(result);
43
41
  if (warningsAndErrorsSection) {
44
42
  logger.err(warningsAndErrorsSection);
45
43
  }
46
44
  logger.out(formatSummary(result));
47
- return exitCodeForTagSyncResult(result);
48
45
  }
49
46
  function withColorizedLine(line, colorCode) {
50
47
  return `${colorCode}${line}${colorReset}`;
@@ -0,0 +1,13 @@
1
+ import type { AppError } from "#/core/errors";
2
+ import type { Filesystem } from "#/core/filesystem/filesystem";
3
+ import type { Result } from "#/core/result";
4
+ import type { TagCommandPrelude } from "#/tag/domain/types";
5
+ /**
6
+ * Resolves the repo root, config, and optional target path into the prelude a tag run starts from.
7
+ *
8
+ * @since 0.3.16-canary.0
9
+ */
10
+ export declare function prepareTag(fs: Filesystem, args: {
11
+ readonly currentWorkingDirectory: string;
12
+ readonly rawTarget: string | undefined;
13
+ }): Promise<Result<TagCommandPrelude, AppError>>;
@@ -1,16 +1,16 @@
1
1
  import { loadCodefastConfig } from "#/core/config";
2
2
  import { ok } from "#/core/result";
3
- import { findRepoRoot } from "#/core/workspace/resolver";
4
- import { resolveProvidedTagTargetPath } from "#/tag/resolve-target-path";
3
+ import { resolveProjectRoot } from "#/core/workspace/resolver";
4
+ import { resolveProvidedTagTargetPath } from "#/tag/target/resolve-path";
5
5
  /**
6
6
  * Resolves the repo root, config, and optional target path into the prelude a tag run starts from.
7
7
  *
8
8
  * @since 0.3.16-canary.0
9
9
  */
10
- export async function prepareTagSync(fs, args) {
10
+ export async function prepareTag(fs, args) {
11
11
  let rootDir;
12
12
  try {
13
- rootDir = findRepoRoot(args.currentWorkingDirectory, fs);
13
+ rootDir = resolveProjectRoot(args.currentWorkingDirectory, fs).rootDir;
14
14
  }
15
15
  catch {
16
16
  rootDir = args.currentWorkingDirectory;
@@ -0,0 +1,10 @@
1
+ import { AppError } from "#/core/errors";
2
+ import type { Filesystem } from "#/core/filesystem/filesystem";
3
+ import type { Result } from "#/core/result";
4
+ import type { TagExecutionInput, TagResult } from "#/tag/domain/types";
5
+ /**
6
+ * Applies `@since` tags across the selected targets and returns the aggregate result.
7
+ *
8
+ * @since 0.3.16-canary.0
9
+ */
10
+ export declare function runTag(fs: Filesystem, input: TagExecutionInput): Promise<Result<TagResult, AppError>>;
@@ -1,26 +1,37 @@
1
1
  import path from "node:path";
2
2
  import { AppError } from "#/core/errors";
3
3
  import { messageFrom } from "#/core/errors";
4
- import { createAnyGlobMatcher } from "#/core/glob";
5
4
  import { err, ok } from "#/core/result";
6
- import { resolveTagTargetCandidates } from "#/tag/target-candidates";
7
- import { runTagOnTarget } from "#/tag/target-runner";
5
+ import { filterSkippedCandidates } from "#/tag/domain/skip-filter";
6
+ import { extractDistinctVersions, summarizeVersions } from "#/tag/domain/version-summary";
7
+ import { resolveTagTargetCandidates } from "#/tag/target/candidates";
8
+ import { runTagOnTarget } from "#/tag/target/runner";
8
9
  /**
9
- * Runs the tag sync across the selected targets and returns the aggregate result.
10
+ * Applies `@since` tags across the selected targets and returns the aggregate result.
10
11
  *
11
12
  * @since 0.3.16-canary.0
12
13
  */
13
- export async function runTagSync(fs, input) {
14
+ export async function runTag(fs, input) {
14
15
  try {
15
16
  const tagConfig = input.config;
16
17
  const targetCandidates = await resolveTagTargetCandidates(fs, input.rootDir, input.targetPath);
17
18
  const { includedCandidates, skippedPackages } = filterSkippedCandidates(targetCandidates, input.skipPackages);
18
19
  const selectedTargets = includedCandidates.map((candidate) => resolveTargetSelection(fs, candidate, input.rootDir));
19
20
  const targetExecutionResults = await Promise.all(selectedTargets.map((resolvedTarget) => runOnResolvedTarget(fs, resolvedTarget, input.write, input.listener)));
20
- const allFileResults = targetExecutionResults.flatMap((targetResult) => targetResult.result?.fileResults ?? []);
21
- const filesScanned = targetExecutionResults.reduce((sum, targetResult) => sum + (targetResult.result?.filesScanned ?? 0), 0);
22
- const filesChanged = targetExecutionResults.reduce((sum, targetResult) => sum + (targetResult.result?.filesChanged ?? 0), 0);
23
- const taggedDeclarations = targetExecutionResults.reduce((sum, targetResult) => sum + (targetResult.result?.taggedDeclarations ?? 0), 0);
21
+ const allFileResults = [];
22
+ let filesScanned = 0;
23
+ let filesChanged = 0;
24
+ let taggedDeclarations = 0;
25
+ for (const targetResult of targetExecutionResults) {
26
+ const runResult = targetResult.result;
27
+ if (runResult === null) {
28
+ continue;
29
+ }
30
+ allFileResults.push(...runResult.fileResults);
31
+ filesScanned += runResult.filesScanned;
32
+ filesChanged += runResult.filesChanged;
33
+ taggedDeclarations += runResult.taggedDeclarations;
34
+ }
24
35
  const modifiedFiles = allFileResults.filter((entry) => entry.changed).map((entry) => entry.filePath);
25
36
  const hookError = input.write && modifiedFiles.length > 0
26
37
  ? await runTagOnAfterWriteHook(tagConfig?.onAfterWrite, modifiedFiles)
@@ -57,20 +68,6 @@ async function runTagOnAfterWriteHook(hook, modifiedFiles) {
57
68
  return `[tag] onAfterWrite hook failed: ${messageFrom(caughtHookError)}`;
58
69
  }
59
70
  }
60
- function summarizeVersions(distinctVersions) {
61
- if (distinctVersions.size === 0) {
62
- return "none";
63
- }
64
- if (distinctVersions.size > 1) {
65
- return "mixed";
66
- }
67
- return distinctVersions.values().next().value ?? "none";
68
- }
69
- function extractDistinctVersions(targetResults) {
70
- return new Set(targetResults
71
- .map((targetResult) => targetResult.result?.version)
72
- .filter((version) => typeof version === "string" && version.length > 0));
73
- }
74
71
  function chooseWorkspacePackageTargetPath(fs, candidate) {
75
72
  if (candidate.source !== "workspace-package") {
76
73
  return {
@@ -103,33 +100,6 @@ function resolveTargetSelection(fs, candidate, rootDir) {
103
100
  packageName: candidate.packageName,
104
101
  };
105
102
  }
106
- /**
107
- * Partition tag target candidates into those to tag and those to skip, matching
108
- * each candidate's package name against `skipPackages` as glob patterns.
109
- * Candidates without a package name (e.g. an explicit-target path) are never skipped.
110
- *
111
- * @since 0.5.0-canary.0
112
- */
113
- export function filterSkippedCandidates(targetCandidates, skipPackages) {
114
- if (!skipPackages || skipPackages.length === 0) {
115
- return {
116
- includedCandidates: targetCandidates,
117
- skippedPackages: [],
118
- };
119
- }
120
- const isSkipped = createAnyGlobMatcher(skipPackages);
121
- const includedCandidates = [];
122
- const skippedPackages = [];
123
- for (const candidate of targetCandidates) {
124
- const packageName = candidate.packageName;
125
- if (packageName && isSkipped(packageName)) {
126
- skippedPackages.push(packageName);
127
- continue;
128
- }
129
- includedCandidates.push(candidate);
130
- }
131
- return { includedCandidates, skippedPackages };
132
- }
133
103
  async function runOnResolvedTarget(fs, resolvedTarget, write, listener) {
134
104
  listener?.onTargetStarted(resolvedTarget);
135
105
  const absoluteTargetPath = path.resolve(resolvedTarget.targetPath);
@@ -0,0 +1,8 @@
1
+ import type { Filesystem } from "#/core/filesystem/filesystem";
2
+ import type { TagTargetCandidate } from "#/tag/domain/types";
3
+ /**
4
+ * Resolves the candidate targets for a tag run: the explicit target, or the discovered workspace packages.
5
+ *
6
+ * @since 0.3.16-canary.0
7
+ */
8
+ export declare function resolveTagTargetCandidates(fs: Filesystem, rootDir: string, explicitTarget: string | undefined): Promise<Array<TagTargetCandidate>>;
@@ -1,7 +1,7 @@
1
1
  import path from "node:path";
2
- import { z } from "zod";
2
+ import * as z from "zod";
3
3
  import { listWorkspacePackageDirectories } from "#/core/workspace/resolver";
4
- const packageJsonFileName = "package.json";
4
+ import { packageJsonFileName } from "#/core/workspace/well-known-files";
5
5
  const packageJsonNameSchema = z.looseObject({
6
6
  name: z.string().min(1).optional(),
7
7
  });
@@ -0,0 +1,10 @@
1
+ import type { Filesystem } from "#/core/filesystem/filesystem";
2
+ /**
3
+ * Canonicalizes the user-provided target path, or returns `undefined` when none was given.
4
+ *
5
+ * @since 0.3.16-canary.0
6
+ */
7
+ export declare function resolveProvidedTagTargetPath(fs: Filesystem, args: {
8
+ readonly currentWorkingDirectory: string;
9
+ readonly rawTarget: string | undefined;
10
+ }): string | undefined;
@@ -0,0 +1,8 @@
1
+ import type { Filesystem } from "#/core/filesystem/filesystem";
2
+ import type { TagRunOptions, TagRunResult } from "#/tag/domain/types";
3
+ /**
4
+ * Stamps `@since` tags across one target's TypeScript files and returns the run result.
5
+ *
6
+ * @since 0.3.16-canary.0
7
+ */
8
+ export declare function runTagOnTarget(fs: Filesystem, targetPath: string, opts: TagRunOptions): TagRunResult;
@@ -1,7 +1,7 @@
1
1
  import path from "node:path";
2
2
  import { walkTsxFiles } from "#/core/workspace/typescript-walk";
3
- import { TagSinceWriter } from "#/tag/since-writer";
4
- import { resolveNearestPackageVersion } from "#/tag/version-resolver";
3
+ import { TagSinceWriter } from "#/tag/writer/since-writer";
4
+ import { resolveNearestPackageVersion } from "#/tag/writer/version-resolver";
5
5
  /**
6
6
  * Stamps `@since` tags across one target's TypeScript files and returns the run result.
7
7
  *
@@ -0,0 +1,32 @@
1
+ import type { Filesystem } from "#/core/filesystem/filesystem";
2
+ import type { TagFileResult } from "#/tag/domain/types";
3
+ /**
4
+ * The writer that adds missing `@since` tags to a file's exported declarations.
5
+ *
6
+ * @since 0.3.16-canary.0
7
+ */
8
+ export declare class TagSinceWriter {
9
+ private readonly fs;
10
+ private readonly sinceDocumentationTag;
11
+ constructor(fs: Filesystem);
12
+ applySinceTagsToFile(filePath: string, version: string, write: boolean): TagFileResult;
13
+ /**
14
+ * The taggable declaration a top-level statement introduces, resolving the
15
+ * `export … <decl>` wrapper to the wrapper node — its `start` sits at `export`,
16
+ * matching `ts.getStart` on a modifier-bearing declaration.
17
+ */
18
+ private taggableDeclarationOf;
19
+ private declarationNames;
20
+ private addDeclarationName;
21
+ private collectLocalNamedDeclarations;
22
+ private collectExportedDeclarations;
23
+ /**
24
+ * The JSDoc block documenting `anchor`: the nearest preceding `/** … *\/` whose
25
+ * gap to the declaration is whitespace only, mirroring TS comment attachment.
26
+ */
27
+ private associatedJsDoc;
28
+ private jsDocHasSinceTag;
29
+ private makeJSDocSinceLine;
30
+ private makeSinceOnlyJSDocBlock;
31
+ private makeDeclarationSinceLine;
32
+ }
@@ -0,0 +1,7 @@
1
+ import type { Filesystem } from "#/core/filesystem/filesystem";
2
+ /**
3
+ * Returns the `version` of the nearest enclosing `package.json` above a target path.
4
+ *
5
+ * @since 0.3.16-canary.0
6
+ */
7
+ export declare function resolveNearestPackageVersion(fs: Filesystem, targetPath: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codefast/cli",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "Developer CLI for the Codefast monorepo (arrange, audit, mirror, pack-slim, tag)",
5
5
  "keywords": [
6
6
  "cli",
@@ -31,11 +31,22 @@
31
31
  "LICENSE"
32
32
  ],
33
33
  "type": "module",
34
+ "main": "./dist/index.js",
35
+ "module": "./dist/index.js",
36
+ "types": "./dist/index.d.ts",
34
37
  "imports": {
35
38
  "#/*": {
39
+ "types": "./dist/*.d.ts",
36
40
  "default": "./dist/*.js"
37
41
  }
38
42
  },
43
+ "exports": {
44
+ ".": {
45
+ "types": "./dist/index.d.ts",
46
+ "import": "./dist/index.js"
47
+ },
48
+ "./package.json": "./package.json"
49
+ },
39
50
  "publishConfig": {
40
51
  "access": "public"
41
52
  },
@@ -46,7 +57,15 @@
46
57
  "oxc-parser": "^0.148.0",
47
58
  "picomatch": "^4.0.7",
48
59
  "yaml": "^2.9.0",
49
- "zod": "^4.5.4"
60
+ "zod": "^4.6.2"
61
+ },
62
+ "peerDependencies": {
63
+ "typescript": "^7.0.2"
64
+ },
65
+ "peerDependenciesMeta": {
66
+ "typescript": {
67
+ "optional": true
68
+ }
50
69
  },
51
70
  "engines": {
52
71
  "node": ">=24.0.0"
@@ -1,34 +0,0 @@
1
- import { z } from "zod";
2
- /**
3
- * The `zod` schema validating an `arrange analyze` request.
4
- *
5
- * @since 0.3.16-canary.0
6
- */
7
- export const arrangeAnalyzeDirectoryRequestSchema = z.object({
8
- analyzeRootPath: z.string().min(1, "analyzeRootPath is required"),
9
- });
10
- /**
11
- * The `zod` schema validating an `arrange` run request.
12
- *
13
- * @since 0.3.16-canary.0
14
- */
15
- export const arrangeSyncRunRequestSchema = z.object({
16
- rootDir: z.string().min(1),
17
- targetPath: z.string().min(1),
18
- write: z.boolean(),
19
- withClassName: z.boolean().optional(),
20
- cnImport: z.string().optional(),
21
- config: z.unknown().optional(),
22
- });
23
- /**
24
- * The `zod` schema validating an `arrange group` request.
25
- *
26
- * @since 0.3.16-canary.0
27
- */
28
- export const arrangeSuggestGroupsRequestSchema = z.object({
29
- inlineClasses: z
30
- .string()
31
- .min(1, 'Pass a class string. Example: codefast arrange group "flex gap-2 text-sm rounded-md"'),
32
- emitTvStyleArray: z.boolean(),
33
- trailingClassName: z.boolean(),
34
- });