@codefast/cli 0.9.0 → 0.10.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 (159) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +329 -149
  3. package/dist/arrange/analyze.d.ts +10 -0
  4. package/dist/arrange/cli-schema.d.ts +50 -0
  5. package/dist/arrange/command.d.ts +7 -0
  6. package/dist/arrange/domain/analyze-service.d.ts +18 -0
  7. package/dist/arrange/domain/ast/ast-node.d.ts +394 -0
  8. package/dist/arrange/domain/ast/collectors-cn.d.ts +26 -0
  9. package/dist/arrange/domain/ast/collectors-jsx.d.ts +8 -0
  10. package/dist/arrange/domain/ast/collectors-tv.d.ts +34 -0
  11. package/dist/arrange/domain/ast/helpers.d.ts +36 -0
  12. package/dist/arrange/domain/ast/helpers.js +1 -0
  13. package/dist/arrange/domain/ast/simplify-targets.d.ts +22 -0
  14. package/dist/arrange/domain/ast/targets.d.ts +20 -0
  15. package/dist/arrange/domain/constants.d.ts +111 -0
  16. package/dist/arrange/domain/grouping-service.d.ts +100 -0
  17. package/dist/arrange/domain/grouping.d.ts +21 -0
  18. package/dist/arrange/domain/imports.d.ts +14 -0
  19. package/dist/arrange/domain/source-text-formatters.d.ts +33 -0
  20. package/dist/arrange/domain/tailwind-token.d.ts +24 -0
  21. package/dist/arrange/domain/token-classifier.d.ts +47 -0
  22. package/dist/arrange/domain/types.d.ts +208 -0
  23. package/dist/arrange/output.d.ts +26 -0
  24. package/dist/arrange/process-file.d.ts +11 -0
  25. package/dist/arrange/resolve-target.d.ts +10 -0
  26. package/dist/arrange/resolve-target.js +3 -16
  27. package/dist/arrange/scan-target.d.ts +7 -0
  28. package/dist/arrange/simplify-process-file.d.ts +11 -0
  29. package/dist/arrange/simplify-sync.d.ts +13 -0
  30. package/dist/arrange/source-parse.d.ts +7 -0
  31. package/dist/arrange/suggest.d.ts +8 -0
  32. package/dist/arrange/sync.d.ts +11 -0
  33. package/dist/arrange/typescript-ast-translator.d.ts +31 -0
  34. package/dist/arrange/workspace.d.ts +13 -0
  35. package/dist/arrange/workspace.js +2 -2
  36. package/dist/audit/cli-schema.d.ts +93 -0
  37. package/dist/audit/cli-schema.js +3 -3
  38. package/dist/audit/command.d.ts +8 -0
  39. package/dist/audit/command.js +12 -12
  40. package/dist/audit/domain/audit-file.d.ts +7 -0
  41. package/dist/audit/domain/comment-content.d.ts +26 -0
  42. package/dist/audit/domain/comment-dividers.d.ts +62 -0
  43. package/dist/audit/domain/display-names.d.ts +11 -0
  44. package/dist/audit/domain/import-policy.d.ts +34 -0
  45. package/dist/audit/domain/import-policy.js +147 -0
  46. package/dist/audit/domain/link-references.d.ts +40 -0
  47. package/dist/audit/domain/mappings.d.ts +45 -0
  48. package/dist/audit/domain/markdown-links.d.ts +44 -0
  49. package/dist/audit/domain/since-versions.d.ts +26 -0
  50. package/dist/audit/domain/tokenize.d.ts +14 -0
  51. package/dist/audit/domain/tsdoc-syntax.d.ts +20 -0
  52. package/dist/audit/domain/types.d.ts +171 -0
  53. package/dist/audit/output.d.ts +91 -0
  54. package/dist/audit/output.js +11 -11
  55. package/dist/audit/prepare.d.ts +70 -0
  56. package/dist/audit/prepare.js +11 -11
  57. package/dist/audit/run-comments.d.ts +17 -0
  58. package/dist/audit/run-display-names.d.ts +14 -0
  59. package/dist/audit/run-imports.d.ts +14 -0
  60. package/dist/audit/{run-react.js → run-imports.js} +15 -5
  61. package/dist/audit/run-links.d.ts +14 -0
  62. package/dist/audit/run.d.ts +14 -0
  63. package/dist/bin.d.ts +2 -0
  64. package/dist/cli.d.ts +6 -0
  65. package/dist/core/cli/format-error.d.ts +7 -0
  66. package/dist/core/cli/global-options.d.ts +15 -0
  67. package/dist/core/cli/positional.d.ts +6 -0
  68. package/dist/core/cli/result-handle.d.ts +19 -0
  69. package/dist/core/config/define-config.d.ts +7 -0
  70. package/dist/core/config/define-config.js +8 -0
  71. package/dist/core/config/loader.d.ts +18 -0
  72. package/dist/core/config/loader.js +2 -7
  73. package/dist/core/config/schema.d.ts +99 -0
  74. package/dist/core/config/schema.js +7 -85
  75. package/dist/core/config/warnings.d.ts +6 -0
  76. package/dist/core/config.d.ts +12 -0
  77. package/dist/core/errors.d.ts +25 -0
  78. package/dist/core/exit-codes.d.ts +18 -0
  79. package/dist/core/filesystem/node.d.ts +7 -0
  80. package/dist/core/filesystem/node.js +1 -0
  81. package/dist/core/filesystem/port.d.ts +44 -0
  82. package/dist/core/glob.d.ts +19 -0
  83. package/dist/core/logger.d.ts +9 -0
  84. package/dist/core/result.d.ts +30 -0
  85. package/dist/core/schema-parse.d.ts +9 -0
  86. package/dist/core/source-text-edit.d.ts +33 -0
  87. package/dist/core/verbose-diagnostics.d.ts +6 -0
  88. package/dist/core/workspace/ancestor-directories.d.ts +12 -0
  89. package/dist/core/workspace/ancestor-directories.js +30 -0
  90. package/dist/core/workspace/markdown-walk.d.ts +7 -0
  91. package/dist/core/workspace/markdown-walk.js +2 -20
  92. package/dist/core/workspace/package-version.d.ts +9 -0
  93. package/dist/core/workspace/package-version.js +8 -12
  94. package/dist/core/workspace/resolver.d.ts +39 -0
  95. package/dist/core/workspace/resolver.js +58 -75
  96. package/dist/core/workspace/skip-directories.d.ts +6 -0
  97. package/dist/core/workspace/source-walk.d.ts +16 -0
  98. package/dist/core/workspace/source-walk.js +2 -19
  99. package/dist/core/workspace/typescript-walk.d.ts +7 -0
  100. package/dist/core/workspace/typescript-walk.js +2 -23
  101. package/dist/core/workspace/walk-files.d.ts +7 -0
  102. package/dist/core/workspace/walk-files.js +27 -0
  103. package/dist/core/workspace/well-known-files.d.ts +18 -0
  104. package/dist/core/workspace/well-known-files.js +18 -0
  105. package/dist/index.d.ts +6 -0
  106. package/dist/index.js +5 -0
  107. package/dist/mirror/cli-result.d.ts +13 -0
  108. package/dist/mirror/cli-schema.d.ts +8 -0
  109. package/dist/mirror/command.d.ts +7 -0
  110. package/dist/mirror/dist-filesystem-impl.d.ts +8 -0
  111. package/dist/mirror/domain/constants.d.ts +18 -0
  112. package/dist/mirror/domain/constants.js +0 -12
  113. package/dist/mirror/domain/dirent-guard.d.ts +10 -0
  114. package/dist/mirror/domain/dist-filesystem.d.ts +9 -0
  115. package/dist/mirror/domain/errors.d.ts +24 -0
  116. package/dist/mirror/domain/exports.d.ts +36 -0
  117. package/dist/mirror/domain/package-display-name.d.ts +8 -0
  118. package/dist/mirror/domain/path-normalizer.d.ts +6 -0
  119. package/dist/mirror/domain/types.d.ts +131 -0
  120. package/dist/mirror/output.d.ts +23 -0
  121. package/dist/mirror/package-path.d.ts +19 -0
  122. package/dist/mirror/prepare.d.ts +15 -0
  123. package/dist/mirror/prepare.js +2 -2
  124. package/dist/mirror/supplement-exports.d.ts +27 -0
  125. package/dist/mirror/supplement-exports.js +2 -2
  126. package/dist/mirror/sync-reporter.d.ts +60 -0
  127. package/dist/mirror/sync-reporter.js +4 -0
  128. package/dist/mirror/sync-types.d.ts +43 -0
  129. package/dist/mirror/sync-workspace-package.d.ts +9 -0
  130. package/dist/mirror/sync-workspace-package.js +3 -3
  131. package/dist/mirror/sync.d.ts +12 -0
  132. package/dist/mirror/sync.js +5 -3
  133. package/dist/mirror/write-exports.d.ts +15 -0
  134. package/dist/pack-slim/cli-result.d.ts +13 -0
  135. package/dist/pack-slim/cli-schema.d.ts +17 -0
  136. package/dist/pack-slim/command.d.ts +7 -0
  137. package/dist/pack-slim/command.js +2 -2
  138. package/dist/pack-slim/domain/transform.d.ts +69 -0
  139. package/dist/pack-slim/domain/types.d.ts +46 -0
  140. package/dist/pack-slim/output.d.ts +15 -0
  141. package/dist/pack-slim/sync.d.ts +23 -0
  142. package/dist/pack-slim/sync.js +4 -4
  143. package/dist/pack-slim/working-tree.d.ts +20 -0
  144. package/dist/tag/cli-result.d.ts +7 -0
  145. package/dist/tag/cli-schema.d.ts +8 -0
  146. package/dist/tag/command.d.ts +7 -0
  147. package/dist/tag/domain/types.d.ts +111 -0
  148. package/dist/tag/output.d.ts +17 -0
  149. package/dist/tag/prepare.d.ts +13 -0
  150. package/dist/tag/prepare.js +2 -2
  151. package/dist/tag/resolve-target-path.d.ts +10 -0
  152. package/dist/tag/since-writer.d.ts +32 -0
  153. package/dist/tag/sync.d.ts +42 -0
  154. package/dist/tag/target-candidates.d.ts +8 -0
  155. package/dist/tag/target-candidates.js +1 -1
  156. package/dist/tag/target-runner.d.ts +8 -0
  157. package/dist/tag/version-resolver.d.ts +7 -0
  158. package/package.json +12 -1
  159. package/dist/audit/domain/react-imports.js +0 -91
@@ -0,0 +1,10 @@
1
+ import type { AnalyzeReport } from "#/arrange/domain/types";
2
+ import { AppError } from "#/core/errors";
3
+ import type { FilesystemPort } from "#/core/filesystem/port";
4
+ import type { Result } from "#/core/result";
5
+ /**
6
+ * Scans a directory's arrange targets and returns the accumulated analyze report.
7
+ *
8
+ * @since 0.3.16-canary.0
9
+ */
10
+ export declare function analyzeDirectory(fs: FilesystemPort, analyzeRootPath: string): Result<AnalyzeReport, AppError>;
@@ -0,0 +1,50 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The request payload for `arrange analyze`.
4
+ *
5
+ * @since 0.3.16-canary.0
6
+ */
7
+ export type ArrangeAnalyzeDirectoryRequest = {
8
+ analyzeRootPath: string;
9
+ };
10
+ /**
11
+ * The request payload for a top-level `arrange` run.
12
+ *
13
+ * @since 0.3.16-canary.0
14
+ */
15
+ export type ArrangeSyncRunRequest = {
16
+ rootDir: string;
17
+ targetPath: string;
18
+ write: boolean;
19
+ withClassName?: boolean | undefined;
20
+ cnImport?: string | undefined;
21
+ config?: unknown;
22
+ };
23
+ /**
24
+ * The request payload for `arrange group`.
25
+ *
26
+ * @since 0.3.16-canary.0
27
+ */
28
+ export type ArrangeSuggestGroupsRequest = {
29
+ inlineClasses: string;
30
+ emitTvStyleArray: boolean;
31
+ trailingClassName: boolean;
32
+ };
33
+ /**
34
+ * The `zod` schema validating an `arrange analyze` request.
35
+ *
36
+ * @since 0.3.16-canary.0
37
+ */
38
+ export declare const arrangeAnalyzeDirectoryRequestSchema: z.ZodType<ArrangeAnalyzeDirectoryRequest>;
39
+ /**
40
+ * The `zod` schema validating an `arrange` run request.
41
+ *
42
+ * @since 0.3.16-canary.0
43
+ */
44
+ export declare const arrangeSyncRunRequestSchema: z.ZodType<ArrangeSyncRunRequest>;
45
+ /**
46
+ * The `zod` schema validating an `arrange group` request.
47
+ *
48
+ * @since 0.3.16-canary.0
49
+ */
50
+ export declare const arrangeSuggestGroupsRequestSchema: z.ZodType<ArrangeSuggestGroupsRequest>;
@@ -0,0 +1,7 @@
1
+ import { Command } from "commander";
2
+ /**
3
+ * Creates the `arrange` command and its subcommands.
4
+ *
5
+ * @since 0.3.16-canary.0
6
+ */
7
+ export declare function createArrangeCommand(): Command;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Rich domain: Tailwind/cn/tv analysis rules (counts, long literals, nested cn in tv).
3
+ * Pure orchestration of domain collectors and invariants — no I/O.
4
+ */
5
+ import type { DomainSourceFile } from "#/arrange/domain/ast/ast-node";
6
+ import type { AnalyzeReport } from "#/arrange/domain/types";
7
+ /**
8
+ * Creates a zeroed analyze report ready for accumulation.
9
+ *
10
+ * @since 0.3.16-canary.0
11
+ */
12
+ export declare function createEmptyAnalyzeReport(): AnalyzeReport;
13
+ /**
14
+ * Accumulates findings for one parsed source file into `report` (mutates report).
15
+ *
16
+ * @since 0.3.16-canary.0
17
+ */
18
+ export declare function accumulateAnalyzeReportForSourceFile(report: AnalyzeReport, domainSf: DomainSourceFile, sourceText: string, filePath: string): void;
@@ -0,0 +1,394 @@
1
+ /**
2
+ * Pure-domain AST shapes for arrange analysis. No TypeScript compiler types.
3
+ * Positions mirror `getStart(sourceFile)` / `getEnd()` semantics from translation.
4
+ *
5
+ * @since 0.3.16-canary.0
6
+ */
7
+ export declare enum DomainSyntaxKind {
8
+ Unknown = 1,
9
+ Identifier = 2,
10
+ StringLiteral = 3,
11
+ NoSubstitutionTemplateLiteral = 4,
12
+ ImportDeclaration = 5,
13
+ ImportClause = 6,
14
+ NamedImports = 7,
15
+ NamespaceImport = 8,
16
+ ImportSpecifier = 9,
17
+ CallExpression = 10,
18
+ PropertyAccessExpression = 11,
19
+ ObjectLiteralExpression = 12,
20
+ PropertyAssignment = 13,
21
+ ArrayLiteralExpression = 14,
22
+ SpreadElement = 15,
23
+ ParenthesizedExpression = 16,
24
+ AsExpression = 17,
25
+ SatisfiesExpression = 18,
26
+ NonNullExpression = 19,
27
+ ConditionalExpression = 20,
28
+ BinaryExpression = 21,
29
+ ExpressionStatement = 22,
30
+ JsxAttribute = 23,
31
+ JsxExpression = 24
32
+ }
33
+ /**
34
+ * The binary operators the domain AST distinguishes.
35
+ *
36
+ * @since 0.3.16-canary.0
37
+ */
38
+ export declare enum DomainBinaryOperator {
39
+ Plus = 0,
40
+ Other = 1
41
+ }
42
+ /**
43
+ * The pure-domain counterpart of a parsed source file.
44
+ *
45
+ * @since 0.3.16-canary.0
46
+ */
47
+ export interface DomainSourceFile {
48
+ readonly fileName: string;
49
+ readonly text: string;
50
+ readonly statements: ReadonlyArray<DomainAstNode>;
51
+ }
52
+ interface DomainNodeBase {
53
+ readonly kind: DomainSyntaxKind;
54
+ readonly pos: number;
55
+ readonly end: number;
56
+ readonly parent: DomainAstNode | null;
57
+ }
58
+ /**
59
+ * A node kind the translator does not model, retained only for its children.
60
+ *
61
+ * @since 0.3.16-canary.0
62
+ */
63
+ export interface DomainUnknownAstNode extends DomainNodeBase {
64
+ readonly kind: DomainSyntaxKind.Unknown;
65
+ readonly children: ReadonlyArray<DomainAstNode>;
66
+ }
67
+ /**
68
+ * An identifier node.
69
+ *
70
+ * @since 0.3.16-canary.0
71
+ */
72
+ export interface DomainIdentifier extends DomainNodeBase {
73
+ readonly kind: DomainSyntaxKind.Identifier;
74
+ readonly text: string;
75
+ }
76
+ /**
77
+ * A string literal node.
78
+ *
79
+ * @since 0.3.16-canary.0
80
+ */
81
+ export interface DomainStringLiteral extends DomainNodeBase {
82
+ readonly kind: DomainSyntaxKind.StringLiteral;
83
+ readonly text: string;
84
+ }
85
+ /**
86
+ * A template literal without substitutions.
87
+ *
88
+ * @since 0.3.16-canary.0
89
+ */
90
+ export interface DomainNoSubstitutionTemplateLiteral extends DomainNodeBase {
91
+ readonly kind: DomainSyntaxKind.NoSubstitutionTemplateLiteral;
92
+ readonly text: string;
93
+ }
94
+ /**
95
+ * An `import` declaration node.
96
+ *
97
+ * @since 0.3.16-canary.0
98
+ */
99
+ export interface DomainImportDeclaration extends DomainNodeBase {
100
+ readonly kind: DomainSyntaxKind.ImportDeclaration;
101
+ readonly importClause: DomainImportClause | undefined;
102
+ readonly moduleSpecifier: DomainAstNode;
103
+ }
104
+ /**
105
+ * The clause of an import declaration — default name plus named or namespace bindings.
106
+ *
107
+ * @since 0.3.16-canary.0
108
+ */
109
+ export interface DomainImportClause extends DomainNodeBase {
110
+ readonly kind: DomainSyntaxKind.ImportClause;
111
+ readonly isTypeOnly: boolean;
112
+ readonly name: DomainIdentifier | undefined;
113
+ readonly namedBindings: DomainNamedImports | DomainNamespaceImport | undefined;
114
+ }
115
+ /**
116
+ * The named-bindings list of an import clause.
117
+ *
118
+ * @since 0.3.16-canary.0
119
+ */
120
+ export interface DomainNamedImports extends DomainNodeBase {
121
+ readonly kind: DomainSyntaxKind.NamedImports;
122
+ readonly elements: ReadonlyArray<DomainImportSpecifier>;
123
+ }
124
+ /**
125
+ * A namespace (`* as name`) import binding.
126
+ *
127
+ * @since 0.3.16-canary.0
128
+ */
129
+ export interface DomainNamespaceImport extends DomainNodeBase {
130
+ readonly kind: DomainSyntaxKind.NamespaceImport;
131
+ readonly name: DomainIdentifier;
132
+ }
133
+ /**
134
+ * A single named-import specifier.
135
+ *
136
+ * @since 0.3.16-canary.0
137
+ */
138
+ export interface DomainImportSpecifier extends DomainNodeBase {
139
+ readonly kind: DomainSyntaxKind.ImportSpecifier;
140
+ readonly name: DomainIdentifier;
141
+ readonly propertyName: DomainIdentifier | undefined;
142
+ }
143
+ /**
144
+ * A call expression node.
145
+ *
146
+ * @since 0.3.16-canary.0
147
+ */
148
+ export interface DomainCallExpression extends DomainNodeBase {
149
+ readonly kind: DomainSyntaxKind.CallExpression;
150
+ readonly expression: DomainAstNode;
151
+ readonly arguments: ReadonlyArray<DomainAstNode>;
152
+ }
153
+ /**
154
+ * A property access (`object.name`) node.
155
+ *
156
+ * @since 0.3.16-canary.0
157
+ */
158
+ export interface DomainPropertyAccessExpression extends DomainNodeBase {
159
+ readonly kind: DomainSyntaxKind.PropertyAccessExpression;
160
+ readonly expression: DomainAstNode;
161
+ readonly name: DomainIdentifier;
162
+ }
163
+ /**
164
+ * An object literal node.
165
+ *
166
+ * @since 0.3.16-canary.0
167
+ */
168
+ export interface DomainObjectLiteralExpression extends DomainNodeBase {
169
+ readonly kind: DomainSyntaxKind.ObjectLiteralExpression;
170
+ readonly properties: ReadonlyArray<DomainAstNode>;
171
+ }
172
+ /**
173
+ * A `name: value` property inside an object literal.
174
+ *
175
+ * @since 0.3.16-canary.0
176
+ */
177
+ export interface DomainPropertyAssignment extends DomainNodeBase {
178
+ readonly kind: DomainSyntaxKind.PropertyAssignment;
179
+ readonly name: DomainAstNode;
180
+ readonly initializer: DomainAstNode;
181
+ }
182
+ /**
183
+ * An array literal node.
184
+ *
185
+ * @since 0.3.16-canary.0
186
+ */
187
+ export interface DomainArrayLiteralExpression extends DomainNodeBase {
188
+ readonly kind: DomainSyntaxKind.ArrayLiteralExpression;
189
+ readonly elements: ReadonlyArray<DomainAstNode>;
190
+ }
191
+ /**
192
+ * A spread (`...expression`) element node.
193
+ *
194
+ * @since 0.3.16-canary.0
195
+ */
196
+ export interface DomainSpreadElement extends DomainNodeBase {
197
+ readonly kind: DomainSyntaxKind.SpreadElement;
198
+ readonly expression: DomainAstNode;
199
+ }
200
+ /**
201
+ * A parenthesized expression node.
202
+ *
203
+ * @since 0.3.16-canary.0
204
+ */
205
+ export interface DomainParenthesizedExpression extends DomainNodeBase {
206
+ readonly kind: DomainSyntaxKind.ParenthesizedExpression;
207
+ readonly expression: DomainAstNode;
208
+ }
209
+ /**
210
+ * An `as` type-assertion node.
211
+ *
212
+ * @since 0.3.16-canary.0
213
+ */
214
+ export interface DomainAsExpression extends DomainNodeBase {
215
+ readonly kind: DomainSyntaxKind.AsExpression;
216
+ readonly expression: DomainAstNode;
217
+ }
218
+ /**
219
+ * A `satisfies` expression node.
220
+ *
221
+ * @since 0.3.16-canary.0
222
+ */
223
+ export interface DomainSatisfiesExpression extends DomainNodeBase {
224
+ readonly kind: DomainSyntaxKind.SatisfiesExpression;
225
+ readonly expression: DomainAstNode;
226
+ }
227
+ /**
228
+ * A non-null assertion (`expression!`) node.
229
+ *
230
+ * @since 0.3.16-canary.0
231
+ */
232
+ export interface DomainNonNullExpression extends DomainNodeBase {
233
+ readonly kind: DomainSyntaxKind.NonNullExpression;
234
+ readonly expression: DomainAstNode;
235
+ }
236
+ /**
237
+ * A ternary conditional node.
238
+ *
239
+ * @since 0.3.16-canary.0
240
+ */
241
+ export interface DomainConditionalExpression extends DomainNodeBase {
242
+ readonly kind: DomainSyntaxKind.ConditionalExpression;
243
+ readonly condition: DomainAstNode;
244
+ readonly whenTrue: DomainAstNode;
245
+ readonly whenFalse: DomainAstNode;
246
+ }
247
+ /**
248
+ * A binary expression node.
249
+ *
250
+ * @since 0.3.16-canary.0
251
+ */
252
+ export interface DomainBinaryExpression extends DomainNodeBase {
253
+ readonly kind: DomainSyntaxKind.BinaryExpression;
254
+ readonly left: DomainAstNode;
255
+ readonly operator: DomainBinaryOperator;
256
+ readonly right: DomainAstNode;
257
+ }
258
+ /**
259
+ * An expression statement node.
260
+ *
261
+ * @since 0.3.16-canary.0
262
+ */
263
+ export interface DomainExpressionStatement extends DomainNodeBase {
264
+ readonly kind: DomainSyntaxKind.ExpressionStatement;
265
+ readonly expression: DomainAstNode;
266
+ }
267
+ /**
268
+ * A JSX attribute node.
269
+ *
270
+ * @since 0.3.16-canary.0
271
+ */
272
+ export interface DomainJsxAttribute extends DomainNodeBase {
273
+ readonly kind: DomainSyntaxKind.JsxAttribute;
274
+ readonly name: DomainAstNode;
275
+ readonly initializer: DomainAstNode | undefined;
276
+ }
277
+ /**
278
+ * A JSX expression container node.
279
+ *
280
+ * @since 0.3.16-canary.0
281
+ */
282
+ export interface DomainJsxExpression extends DomainNodeBase {
283
+ readonly kind: DomainSyntaxKind.JsxExpression;
284
+ readonly expression: DomainAstNode | undefined;
285
+ }
286
+ /**
287
+ * The union of every node shape the domain AST models.
288
+ *
289
+ * @since 0.3.16-canary.0
290
+ */
291
+ export type DomainAstNode = DomainUnknownAstNode | DomainIdentifier | DomainStringLiteral | DomainNoSubstitutionTemplateLiteral | DomainImportDeclaration | DomainImportClause | DomainNamedImports | DomainNamespaceImport | DomainImportSpecifier | DomainCallExpression | DomainPropertyAccessExpression | DomainObjectLiteralExpression | DomainPropertyAssignment | DomainArrayLiteralExpression | DomainSpreadElement | DomainParenthesizedExpression | DomainAsExpression | DomainSatisfiesExpression | DomainNonNullExpression | DomainConditionalExpression | DomainBinaryExpression | DomainExpressionStatement | DomainJsxAttribute | DomainJsxExpression;
292
+ /**
293
+ * A literal node that can carry a Tailwind class string.
294
+ *
295
+ * @since 0.3.16-canary.0
296
+ */
297
+ export type DomainTailwindClassLiteral = DomainStringLiteral | DomainNoSubstitutionTemplateLiteral;
298
+ /**
299
+ * Narrows a node to `DomainIdentifier`.
300
+ *
301
+ * @since 0.3.16-canary.0
302
+ */
303
+ export declare function isDomainIdentifier(node: DomainAstNode): node is DomainIdentifier;
304
+ /**
305
+ * Narrows a node to `DomainStringLiteral`.
306
+ *
307
+ * @since 0.3.16-canary.0
308
+ */
309
+ export declare function isDomainStringLiteral(node: DomainAstNode): node is DomainStringLiteral;
310
+ /**
311
+ * Narrows a node to a literal that can carry Tailwind classes.
312
+ *
313
+ * @since 0.3.16-canary.0
314
+ */
315
+ export declare function isDomainTailwindClassLiteral(node: DomainAstNode): node is DomainTailwindClassLiteral;
316
+ /**
317
+ * Narrows a node to `DomainImportDeclaration`.
318
+ *
319
+ * @since 0.3.16-canary.0
320
+ */
321
+ export declare function isDomainImportDeclaration(node: DomainAstNode): node is DomainImportDeclaration;
322
+ /**
323
+ * Narrows a node to `DomainNamedImports`.
324
+ *
325
+ * @since 0.3.16-canary.0
326
+ */
327
+ export declare function isDomainNamedImports(node: DomainAstNode): node is DomainNamedImports;
328
+ /**
329
+ * Narrows a node to `DomainNamespaceImport`.
330
+ *
331
+ * @since 0.3.16-canary.0
332
+ */
333
+ export declare function isDomainNamespaceImport(node: DomainAstNode): node is DomainNamespaceImport;
334
+ /**
335
+ * Narrows a node to `DomainCallExpression`.
336
+ *
337
+ * @since 0.3.16-canary.0
338
+ */
339
+ export declare function isDomainCallExpression(node: DomainAstNode): node is DomainCallExpression;
340
+ /**
341
+ * Narrows a node to `DomainObjectLiteralExpression`.
342
+ *
343
+ * @since 0.3.16-canary.0
344
+ */
345
+ export declare function isDomainObjectLiteralExpression(node: DomainAstNode): node is DomainObjectLiteralExpression;
346
+ /**
347
+ * Narrows a node to `DomainPropertyAssignment`.
348
+ *
349
+ * @since 0.3.16-canary.0
350
+ */
351
+ export declare function isDomainPropertyAssignment(node: DomainAstNode): node is DomainPropertyAssignment;
352
+ /**
353
+ * Narrows a node to `DomainArrayLiteralExpression`.
354
+ *
355
+ * @since 0.3.16-canary.0
356
+ */
357
+ export declare function isDomainArrayLiteralExpression(node: DomainAstNode): node is DomainArrayLiteralExpression;
358
+ /**
359
+ * Narrows a node to `DomainSpreadElement`.
360
+ *
361
+ * @since 0.3.16-canary.0
362
+ */
363
+ export declare function isDomainSpreadElement(node: DomainAstNode): node is DomainSpreadElement;
364
+ /**
365
+ * Narrows a node to `DomainPropertyAccessExpression`.
366
+ *
367
+ * @since 0.3.16-canary.0
368
+ */
369
+ export declare function isDomainPropertyAccessExpression(node: DomainAstNode): node is DomainPropertyAccessExpression;
370
+ /**
371
+ * Narrows a node to `DomainJsxAttribute`.
372
+ *
373
+ * @since 0.3.16-canary.0
374
+ */
375
+ export declare function isDomainJsxAttribute(node: DomainAstNode): node is DomainJsxAttribute;
376
+ /**
377
+ * Narrows a node to `DomainJsxExpression`.
378
+ *
379
+ * @since 0.3.16-canary.0
380
+ */
381
+ export declare function isDomainJsxExpression(node: DomainAstNode): node is DomainJsxExpression;
382
+ /**
383
+ * Visits each direct child of a domain node.
384
+ *
385
+ * @since 0.3.16-canary.0
386
+ */
387
+ export declare function forEachDomainChild(node: DomainAstNode, visit: (child: DomainAstNode) => void): void;
388
+ /**
389
+ * Resolves the one-based line number of a position in source text.
390
+ *
391
+ * @since 0.3.16-canary.0
392
+ */
393
+ export declare function lineOfSourcePosition(sourceText: string, pos: number): number;
394
+ export {};
@@ -0,0 +1,26 @@
1
+ import type { DomainAstNode } from "#/arrange/domain/ast/ast-node";
2
+ import type { ForEachStringLiteralInClassExpressionOptions, TailwindClassLiteral } from "#/arrange/domain/types";
3
+ /**
4
+ * Visits every static class literal reachable inside a class expression.
5
+ *
6
+ * @since 0.3.16-canary.0
7
+ */
8
+ export declare function forEachStringLiteralInClassExpression(expr: DomainAstNode, sink: (classLiteral: TailwindClassLiteral) => void, depth?: number, options?: ForEachStringLiteralInClassExpressionOptions): void;
9
+ /**
10
+ * Checks whether a literal sits directly inside an array literal, where splitting it apart is unsafe.
11
+ *
12
+ * @since 0.3.16-canary.0
13
+ */
14
+ export declare function isUnsafeLiteralForCnStyleApplySplit(classLiteral: TailwindClassLiteral): boolean;
15
+ /**
16
+ * The walk options for building the `cn` apply pool — conditional branches are never descended into.
17
+ *
18
+ * @since 0.3.16-canary.0
19
+ */
20
+ export declare const CN_APPLY_LITERAL_WALK_OPTS: ForEachStringLiteralInClassExpressionOptions;
21
+ /**
22
+ * Collects the static class literals in `cn()` arguments that are safe to regroup.
23
+ *
24
+ * @since 0.3.16-canary.0
25
+ */
26
+ export declare function collectUnconditionalTailwindLiteralsFromCnArguments(args: ReadonlyArray<DomainAstNode>): Array<TailwindClassLiteral>;
@@ -0,0 +1,8 @@
1
+ import type { DomainJsxAttribute } from "#/arrange/domain/ast/ast-node";
2
+ import type { JsxClassNameStatic } from "#/arrange/domain/types";
3
+ /**
4
+ * Extracts the static literal of a JSX `className` attribute, or `undefined` when it is not static.
5
+ *
6
+ * @since 0.3.16-canary.0
7
+ */
8
+ export declare function jsxClassNameStaticLiteral(jsxClassNameAttribute: DomainJsxAttribute): JsxClassNameStatic | undefined;
@@ -0,0 +1,34 @@
1
+ import type { DomainCallExpression, DomainObjectLiteralExpression, DomainSourceFile } from "#/arrange/domain/ast/ast-node";
2
+ import type { StringNode, TailwindClassLiteral } from "#/arrange/domain/types";
3
+ type StringNodeVisitor = (classLiteral: TailwindClassLiteral, sourceFile: DomainSourceFile, cnCall?: DomainCallExpression) => void;
4
+ /**
5
+ * Visits every class literal reachable inside a `tv({ ... })` object, including `cn()` arguments.
6
+ *
7
+ * @since 0.3.16-canary.0
8
+ */
9
+ export declare function traverseTvObject(sourceFile: DomainSourceFile, obj: DomainObjectLiteralExpression, visitor: StringNodeVisitor, depth?: number, knownBindings?: Set<string>): void;
10
+ /**
11
+ * Collects the `cn()` calls nested inside a `tv({ ... })` object.
12
+ *
13
+ * @since 0.3.16-canary.0
14
+ */
15
+ export declare function collectCnCallsInsideTv(sourceFile: DomainSourceFile, obj: DomainObjectLiteralExpression, knownBindings: Set<string>, depth?: number): Array<DomainCallExpression>;
16
+ /**
17
+ * Collects every `cn()` call nested inside any `tv()` call in a source file.
18
+ *
19
+ * @since 0.3.16-canary.0
20
+ */
21
+ export declare function listAllCnCallsInsideTvInSourceFile(sourceFile: DomainSourceFile, knownBindings: Set<string>): Array<DomainCallExpression>;
22
+ /**
23
+ * Joins a slot's literals into one space-separated class string.
24
+ *
25
+ * @since 0.3.16-canary.0
26
+ */
27
+ export declare function slotClassString(stringNode: StringNode): string;
28
+ /**
29
+ * Collects every groupable `cn()` / `tv()` string slot in a source file.
30
+ *
31
+ * @since 0.3.16-canary.0
32
+ */
33
+ export declare function collectGroupableStringNodes(sourceFile: DomainSourceFile): Array<StringNode>;
34
+ export {};
@@ -0,0 +1,36 @@
1
+ import type { DomainAstNode, DomainCallExpression, DomainPropertyAssignment, DomainSourceFile } from "#/arrange/domain/ast/ast-node";
2
+ import { applyEditsDescending } from "#/core/source-text-edit";
3
+ /**
4
+ * Builds a set of local binding names that are imported from a known cn/tv
5
+ * module in `sourceFile`.
6
+ *
7
+ * @since 0.3.16-canary.0
8
+ */
9
+ export declare function buildKnownCnTvBindings(sourceFile: DomainSourceFile): Set<string>;
10
+ /**
11
+ * Returns true when `expr` is an identifier whose name matches `name` AND
12
+ * that name is listed in `knownBindings` from a recognized import.
13
+ *
14
+ * @since 0.3.16-canary.0
15
+ */
16
+ export declare function isCnOrTvIdentifier(expr: DomainAstNode, name: "cn" | "tv", knownBindings?: Set<string>): boolean;
17
+ /**
18
+ * Resolves a property assignment's name text, or `undefined` for computed names.
19
+ *
20
+ * @since 0.3.16-canary.0
21
+ */
22
+ export declare function propertyAssignmentNameText(prop: DomainPropertyAssignment): string | undefined;
23
+ /**
24
+ * Resolves the one-based line number a node starts on.
25
+ *
26
+ * @since 0.3.16-canary.0
27
+ */
28
+ export declare function lineOf(sourceFile: DomainSourceFile, node: DomainAstNode): number;
29
+ export { applyEditsDescending };
30
+ /**
31
+ * Replace `cn(...)` nested in `tv({...})` with a plain string (one arg) or a string
32
+ * array (multiple args). Returns undefined when there are zero arguments.
33
+ *
34
+ * @since 0.3.16-canary.0
35
+ */
36
+ export declare function unwrapCnInsideTvCallReplacement(call: DomainCallExpression, sourceText: string): string | undefined;
@@ -12,6 +12,7 @@ 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",
15
16
  "~/lib/utils",
16
17
  "@/lib/utils",
17
18
  ]);
@@ -0,0 +1,22 @@
1
+ import type { DomainSourceFile } from "#/arrange/domain/ast/ast-node";
2
+ /**
3
+ * A planned text replacement produced by the simplify pass.
4
+ *
5
+ * @since 0.3.16-canary.0
6
+ */
7
+ export type PlannedSimplifyEdit = {
8
+ start: number;
9
+ end: number;
10
+ replacement: string;
11
+ label: string;
12
+ };
13
+ /**
14
+ * Collects all simplify edits for a source file:
15
+ * - Arrays of pure string literals inside tv() slots → flat string
16
+ * - cn() calls whose every argument is a static string literal → flat string (unwrap cn)
17
+ * - cn() calls with mixed static + dynamic args → merge adjacent statics into one string
18
+ * - JSX `className={cn(...all-static...)}` → `className="flat string"`
19
+ *
20
+ * @since 0.3.16-canary.0
21
+ */
22
+ export declare function collectSimplifyTargets(sourceFile: DomainSourceFile): Array<PlannedSimplifyEdit>;
@@ -0,0 +1,20 @@
1
+ import type { DomainSourceFile } from "#/arrange/domain/ast/ast-node";
2
+ import type { GroupTarget, PlannedGroupEdit } from "#/arrange/domain/types";
3
+ /**
4
+ * Resolves the source position where a group target's replacement begins.
5
+ *
6
+ * @since 0.3.16-canary.0
7
+ */
8
+ export declare function targetReplaceStart(target: GroupTarget): number;
9
+ /**
10
+ * Collects a file's group targets — `cn()` / `tv()` slots, plus long JSX `className` literals in `.tsx`.
11
+ *
12
+ * @since 0.3.16-canary.0
13
+ */
14
+ export declare function collectGroupTargets(sourceFile: DomainSourceFile, filePath: string): Array<GroupTarget>;
15
+ /**
16
+ * Plans the grouped replacement for one target, or `undefined` when regrouping would change nothing.
17
+ *
18
+ * @since 0.3.16-canary.0
19
+ */
20
+ export declare function planGroupEditForTarget(target: GroupTarget, textAfterUnwrap: string, withClassName: boolean): PlannedGroupEdit | undefined;