@codefast/cli 0.10.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 (220) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +16 -2
  3. package/dist/arrange/command.js +96 -132
  4. package/dist/arrange/domain/ast/simplify-targets.js +18 -23
  5. package/dist/arrange/{typescript-ast-translator.d.ts → domain/ast/translator.d.ts} +5 -4
  6. package/dist/arrange/{typescript-ast-translator.js → domain/ast/translator.js} +19 -22
  7. package/dist/arrange/group/cli-result.d.ts +7 -0
  8. package/dist/arrange/group/cli-result.js +12 -0
  9. package/dist/arrange/group/cli-schema.d.ts +17 -0
  10. package/dist/arrange/group/cli-schema.js +13 -0
  11. package/dist/arrange/group/output.d.ts +7 -0
  12. package/dist/arrange/group/output.js +10 -0
  13. package/dist/arrange/{suggest.d.ts → group/suggest.d.ts} +1 -1
  14. package/dist/arrange/inspect/cli-result.d.ts +7 -0
  15. package/dist/arrange/inspect/cli-result.js +8 -0
  16. package/dist/arrange/inspect/cli-schema.d.ts +15 -0
  17. package/dist/arrange/inspect/cli-schema.js +9 -0
  18. package/dist/arrange/inspect/output.d.ts +7 -0
  19. package/dist/arrange/inspect/output.js +42 -0
  20. package/dist/arrange/{analyze.d.ts → inspect/run.d.ts} +2 -2
  21. package/dist/arrange/{analyze.js → inspect/run.js} +2 -2
  22. package/dist/arrange/{workspace.d.ts → prepare.d.ts} +2 -2
  23. package/dist/arrange/{workspace.js → prepare.js} +5 -8
  24. package/dist/arrange/regroup/cli-result.d.ts +13 -0
  25. package/dist/arrange/regroup/cli-result.js +23 -0
  26. package/dist/arrange/regroup/cli-schema.d.ts +20 -0
  27. package/dist/arrange/regroup/cli-schema.js +14 -0
  28. package/dist/arrange/regroup/output.d.ts +14 -0
  29. package/dist/arrange/regroup/output.js +72 -0
  30. package/dist/arrange/{process-file.d.ts → regroup/process-file.d.ts} +2 -2
  31. package/dist/arrange/{sync.d.ts → regroup/run.d.ts} +3 -3
  32. package/dist/arrange/{sync.js → regroup/run.js} +2 -2
  33. package/dist/arrange/resolve-target.d.ts +2 -2
  34. package/dist/arrange/scan-target.d.ts +2 -2
  35. package/dist/arrange/simplify/cli-result.d.ts +7 -0
  36. package/dist/arrange/simplify/cli-result.js +8 -0
  37. package/dist/arrange/simplify/cli-schema.d.ts +17 -0
  38. package/dist/arrange/simplify/cli-schema.js +11 -0
  39. package/dist/arrange/simplify/fold-targets.d.ts +13 -0
  40. package/dist/arrange/simplify/fold-targets.js +139 -0
  41. package/dist/arrange/simplify/output.d.ts +7 -0
  42. package/dist/arrange/simplify/output.js +15 -0
  43. package/dist/arrange/{simplify-process-file.d.ts → simplify/process-file.d.ts} +4 -2
  44. package/dist/arrange/simplify/process-file.js +49 -0
  45. package/dist/arrange/{simplify-sync.d.ts → simplify/run.d.ts} +3 -2
  46. package/dist/arrange/simplify/run.js +38 -0
  47. package/dist/arrange/simplify/variant-classname-probe.d.ts +35 -0
  48. package/dist/arrange/simplify/variant-classname-probe.js +95 -0
  49. package/dist/arrange/source-parse.js +1 -1
  50. package/dist/audit/command.js +134 -211
  51. package/dist/audit/comments/cli-result.d.ts +13 -0
  52. package/dist/audit/comments/cli-result.js +22 -0
  53. package/dist/audit/comments/cli-schema.d.ts +19 -0
  54. package/dist/audit/comments/cli-schema.js +13 -0
  55. package/dist/audit/comments/output.d.ts +7 -0
  56. package/dist/audit/comments/output.js +27 -0
  57. package/dist/audit/comments/prepare.d.ts +16 -0
  58. package/dist/audit/comments/prepare.js +12 -0
  59. package/dist/audit/{run-comments.d.ts → comments/run.d.ts} +2 -2
  60. package/dist/audit/{run-comments.js → comments/run.js} +5 -5
  61. package/dist/audit/display-names/cli-result.d.ts +13 -0
  62. package/dist/audit/display-names/cli-result.js +22 -0
  63. package/dist/audit/display-names/cli-schema.d.ts +18 -0
  64. package/dist/audit/display-names/cli-schema.js +12 -0
  65. package/dist/audit/display-names/output.d.ts +7 -0
  66. package/dist/audit/display-names/output.js +21 -0
  67. package/dist/audit/display-names/prepare.d.ts +16 -0
  68. package/dist/audit/display-names/prepare.js +12 -0
  69. package/dist/audit/{run-display-names.d.ts → display-names/run.d.ts} +2 -2
  70. package/dist/audit/{run-display-names.js → display-names/run.js} +1 -1
  71. package/dist/audit/imports/cli-result.d.ts +13 -0
  72. package/dist/audit/imports/cli-result.js +22 -0
  73. package/dist/audit/imports/cli-schema.d.ts +18 -0
  74. package/dist/audit/imports/cli-schema.js +12 -0
  75. package/dist/audit/{domain → imports/domain}/import-policy.d.ts +2 -2
  76. package/dist/audit/{domain → imports/domain}/import-policy.js +4 -11
  77. package/dist/audit/imports/output.d.ts +7 -0
  78. package/dist/audit/imports/output.js +21 -0
  79. package/dist/audit/imports/prepare.d.ts +16 -0
  80. package/dist/audit/imports/prepare.js +12 -0
  81. package/dist/audit/{run-imports.d.ts → imports/run.d.ts} +2 -2
  82. package/dist/audit/{run-imports.js → imports/run.js} +2 -2
  83. package/dist/audit/links/cli-result.d.ts +13 -0
  84. package/dist/audit/links/cli-result.js +22 -0
  85. package/dist/audit/links/cli-schema.d.ts +18 -0
  86. package/dist/audit/links/cli-schema.js +12 -0
  87. package/dist/audit/links/output.d.ts +7 -0
  88. package/dist/audit/links/output.js +21 -0
  89. package/dist/audit/links/prepare.d.ts +16 -0
  90. package/dist/audit/links/prepare.js +12 -0
  91. package/dist/audit/{run-links.d.ts → links/run.d.ts} +2 -2
  92. package/dist/audit/{run-links.js → links/run.js} +1 -1
  93. package/dist/audit/prepare.d.ts +11 -50
  94. package/dist/audit/prepare.js +9 -132
  95. package/dist/audit/rtl/cli-result.d.ts +13 -0
  96. package/dist/audit/rtl/cli-result.js +22 -0
  97. package/dist/audit/rtl/cli-schema.d.ts +18 -0
  98. package/dist/audit/rtl/cli-schema.js +12 -0
  99. package/dist/audit/{domain → rtl/domain}/audit-file.js +2 -2
  100. package/dist/audit/rtl/output.d.ts +7 -0
  101. package/dist/audit/rtl/output.js +21 -0
  102. package/dist/audit/rtl/prepare.d.ts +13 -0
  103. package/dist/audit/rtl/prepare.js +41 -0
  104. package/dist/audit/{run.d.ts → rtl/run.d.ts} +2 -2
  105. package/dist/audit/{run.js → rtl/run.js} +1 -1
  106. package/dist/core/cli/command-pipeline.d.ts +91 -0
  107. package/dist/core/cli/command-pipeline.js +83 -0
  108. package/dist/core/cli/global-options.d.ts +1 -1
  109. package/dist/core/cli/global-options.js +1 -1
  110. package/dist/core/cli/resolve-root.d.ts +9 -0
  111. package/dist/core/cli/resolve-root.js +16 -0
  112. package/dist/core/cli/result-handle.d.ts +1 -7
  113. package/dist/core/cli/result-handle.js +0 -13
  114. package/dist/core/config/loader.d.ts +2 -2
  115. package/dist/core/config/schema.d.ts +1 -1
  116. package/dist/core/config/schema.js +1 -1
  117. package/dist/core/config.d.ts +2 -2
  118. package/dist/core/filesystem/{port.d.ts → filesystem.d.ts} +1 -1
  119. package/dist/core/filesystem/node.d.ts +3 -3
  120. package/dist/core/filesystem/node.js +1 -1
  121. package/dist/core/source-text-edit.d.ts +14 -0
  122. package/dist/core/source-text-edit.js +22 -0
  123. package/dist/core/workspace/markdown-walk.d.ts +2 -2
  124. package/dist/core/workspace/package-version.d.ts +2 -2
  125. package/dist/core/workspace/resolver.d.ts +3 -3
  126. package/dist/core/workspace/source-walk.d.ts +2 -2
  127. package/dist/core/workspace/typescript-walk.d.ts +2 -2
  128. package/dist/core/workspace/walk-files.d.ts +2 -2
  129. package/dist/mirror/cli-schema.d.ts +2 -2
  130. package/dist/mirror/cli-schema.js +1 -1
  131. package/dist/mirror/command.js +31 -60
  132. package/dist/mirror/{dist-filesystem-impl.d.ts → dist-filesystem-node.d.ts} +3 -3
  133. package/dist/mirror/{dist-filesystem-impl.js → dist-filesystem-node.js} +1 -1
  134. package/dist/mirror/domain/dirent-guard.d.ts +1 -1
  135. package/dist/mirror/domain/types.d.ts +57 -0
  136. package/dist/mirror/output.d.ts +1 -3
  137. package/dist/mirror/output.js +126 -1
  138. package/dist/mirror/package-path.d.ts +3 -3
  139. package/dist/mirror/prepare.d.ts +3 -3
  140. package/dist/mirror/prepare.js +6 -10
  141. package/dist/mirror/run.d.ts +12 -0
  142. package/dist/mirror/supplement-exports.d.ts +3 -3
  143. package/dist/mirror/sync-workspace-package.d.ts +2 -2
  144. package/dist/mirror/sync-workspace-package.js +1 -1
  145. package/dist/mirror/write-exports.d.ts +2 -2
  146. package/dist/pack-slim/cli-schema.d.ts +1 -1
  147. package/dist/pack-slim/cli-schema.js +1 -1
  148. package/dist/pack-slim/command.js +31 -66
  149. package/dist/pack-slim/prepare.d.ts +21 -0
  150. package/dist/pack-slim/prepare.js +14 -0
  151. package/dist/pack-slim/{sync.d.ts → run.d.ts} +2 -2
  152. package/dist/tag/cli-result.d.ts +8 -2
  153. package/dist/tag/cli-result.js +14 -1
  154. package/dist/tag/cli-schema.d.ts +4 -4
  155. package/dist/tag/cli-schema.js +3 -4
  156. package/dist/tag/command.js +33 -60
  157. package/dist/tag/domain/skip-filter.d.ts +13 -0
  158. package/dist/tag/domain/skip-filter.js +29 -0
  159. package/dist/tag/domain/types.d.ts +21 -1
  160. package/dist/tag/domain/version-summary.d.ts +13 -0
  161. package/dist/tag/domain/version-summary.js +24 -0
  162. package/dist/tag/output.d.ts +4 -4
  163. package/dist/tag/output.js +6 -9
  164. package/dist/tag/prepare.d.ts +2 -2
  165. package/dist/tag/prepare.js +2 -2
  166. package/dist/tag/run.d.ts +10 -0
  167. package/dist/tag/{sync.js → run.js} +20 -50
  168. package/dist/tag/{target-candidates.d.ts → target/candidates.d.ts} +2 -2
  169. package/dist/tag/{target-candidates.js → target/candidates.js} +1 -1
  170. package/dist/tag/{resolve-target-path.d.ts → target/resolve-path.d.ts} +2 -2
  171. package/dist/tag/{target-runner.d.ts → target/runner.d.ts} +2 -2
  172. package/dist/tag/{target-runner.js → target/runner.js} +2 -2
  173. package/dist/tag/{since-writer.d.ts → writer/since-writer.d.ts} +2 -2
  174. package/dist/tag/{version-resolver.d.ts → writer/version-resolver.d.ts} +2 -2
  175. package/package.json +10 -2
  176. package/dist/arrange/cli-schema.d.ts +0 -50
  177. package/dist/arrange/cli-schema.js +0 -34
  178. package/dist/arrange/output.d.ts +0 -26
  179. package/dist/arrange/output.js +0 -127
  180. package/dist/arrange/simplify-process-file.js +0 -30
  181. package/dist/arrange/simplify-sync.js +0 -30
  182. package/dist/audit/cli-schema.d.ts +0 -93
  183. package/dist/audit/cli-schema.js +0 -66
  184. package/dist/audit/output.d.ts +0 -91
  185. package/dist/audit/output.js +0 -213
  186. package/dist/mirror/sync-reporter.d.ts +0 -60
  187. package/dist/mirror/sync-reporter.js +0 -128
  188. package/dist/mirror/sync-types.d.ts +0 -43
  189. package/dist/mirror/sync-types.js +0 -1
  190. package/dist/mirror/sync.d.ts +0 -12
  191. package/dist/tag/sync.d.ts +0 -42
  192. /package/dist/arrange/{suggest.js → group/suggest.js} +0 -0
  193. /package/dist/arrange/{domain → inspect/domain}/analyze-service.d.ts +0 -0
  194. /package/dist/arrange/{domain → inspect/domain}/analyze-service.js +0 -0
  195. /package/dist/arrange/{process-file.js → regroup/process-file.js} +0 -0
  196. /package/dist/audit/{domain → comments/domain}/comment-content.d.ts +0 -0
  197. /package/dist/audit/{domain → comments/domain}/comment-content.js +0 -0
  198. /package/dist/audit/{domain → comments/domain}/comment-dividers.d.ts +0 -0
  199. /package/dist/audit/{domain → comments/domain}/comment-dividers.js +0 -0
  200. /package/dist/audit/{domain → comments/domain}/link-references.d.ts +0 -0
  201. /package/dist/audit/{domain → comments/domain}/link-references.js +0 -0
  202. /package/dist/audit/{domain → comments/domain}/since-versions.d.ts +0 -0
  203. /package/dist/audit/{domain → comments/domain}/since-versions.js +0 -0
  204. /package/dist/audit/{domain → comments/domain}/tsdoc-syntax.d.ts +0 -0
  205. /package/dist/audit/{domain → comments/domain}/tsdoc-syntax.js +0 -0
  206. /package/dist/audit/{domain → display-names/domain}/display-names.d.ts +0 -0
  207. /package/dist/audit/{domain → display-names/domain}/display-names.js +0 -0
  208. /package/dist/audit/{domain → links/domain}/markdown-links.d.ts +0 -0
  209. /package/dist/audit/{domain → links/domain}/markdown-links.js +0 -0
  210. /package/dist/audit/{domain → rtl/domain}/audit-file.d.ts +0 -0
  211. /package/dist/audit/{domain → rtl/domain}/mappings.d.ts +0 -0
  212. /package/dist/audit/{domain → rtl/domain}/mappings.js +0 -0
  213. /package/dist/audit/{domain → rtl/domain}/tokenize.d.ts +0 -0
  214. /package/dist/audit/{domain → rtl/domain}/tokenize.js +0 -0
  215. /package/dist/core/filesystem/{port.js → filesystem.js} +0 -0
  216. /package/dist/mirror/{sync.js → run.js} +0 -0
  217. /package/dist/pack-slim/{sync.js → run.js} +0 -0
  218. /package/dist/tag/{resolve-target-path.js → target/resolve-path.js} +0 -0
  219. /package/dist/tag/{since-writer.js → writer/since-writer.js} +0 -0
  220. /package/dist/tag/{version-resolver.js → writer/version-resolver.js} +0 -0
@@ -0,0 +1,16 @@
1
+ import type { AuditCommandPrelude } from "#/audit/prepare";
2
+ import type { AppError } from "#/core/errors";
3
+ import type { Filesystem } from "#/core/filesystem/filesystem";
4
+ import type { Result } from "#/core/result";
5
+ /**
6
+ * Loads config and resolves the scan target for `audit comments`.
7
+ *
8
+ * @remarks Defaults to the repo root: a divider convention that only holds inside one package
9
+ * is not a convention.
10
+ *
11
+ * @since 0.6.0
12
+ */
13
+ export declare function prepareCommentAudit(fs: Filesystem, args: {
14
+ readonly currentWorkingDirectory: string;
15
+ readonly rawTarget: string | undefined;
16
+ }): Promise<Result<AuditCommandPrelude, AppError>>;
@@ -0,0 +1,12 @@
1
+ import { prepareRepoRootAudit } from "#/audit/prepare";
2
+ /**
3
+ * Loads config and resolves the scan target for `audit comments`.
4
+ *
5
+ * @remarks Defaults to the repo root: a divider convention that only holds inside one package
6
+ * is not a convention.
7
+ *
8
+ * @since 0.6.0
9
+ */
10
+ export async function prepareCommentAudit(fs, args) {
11
+ return prepareRepoRootAudit(fs, args, (config) => config.audit?.comments?.allowlist ?? []);
12
+ }
@@ -1,6 +1,6 @@
1
1
  import type { CommentAuditResult } from "#/audit/domain/types";
2
2
  import { AppError } from "#/core/errors";
3
- import type { FilesystemPort } from "#/core/filesystem/port";
3
+ import type { Filesystem } from "#/core/filesystem/filesystem";
4
4
  import type { Result } from "#/core/result";
5
5
  /**
6
6
  * Reports every comment off the repo's conventions: divider form (which `fix` rewrites), banned
@@ -9,7 +9,7 @@ import type { Result } from "#/core/result";
9
9
  *
10
10
  * @since 0.6.0
11
11
  */
12
- export declare function runCommentAudit(fs: FilesystemPort, args: {
12
+ export declare function runCommentAudit(fs: Filesystem, args: {
13
13
  readonly rootDir: string;
14
14
  readonly targetPath: string;
15
15
  readonly allowlist: ReadonlyArray<string>;
@@ -1,9 +1,9 @@
1
1
  import path from "node:path";
2
- import { scanCommentContent } from "#/audit/domain/comment-content";
3
- import { applyCommentDividerFixes, DIVIDER_COLUMN, scanCommentDividers } from "#/audit/domain/comment-dividers";
4
- import { countHeadMentions, isPathLinkTarget, linkTargetHead, scanLinkReferences, } from "#/audit/domain/link-references";
5
- import { scanImpossibleSinceTags } from "#/audit/domain/since-versions";
6
- import { scanTsdocSyntax } from "#/audit/domain/tsdoc-syntax";
2
+ import { scanCommentContent } from "#/audit/comments/domain/comment-content";
3
+ import { applyCommentDividerFixes, DIVIDER_COLUMN, scanCommentDividers, } from "#/audit/comments/domain/comment-dividers";
4
+ import { countHeadMentions, isPathLinkTarget, linkTargetHead, scanLinkReferences, } from "#/audit/comments/domain/link-references";
5
+ import { scanImpossibleSinceTags } from "#/audit/comments/domain/since-versions";
6
+ import { scanTsdocSyntax } from "#/audit/comments/domain/tsdoc-syntax";
7
7
  import { AppError, messageFrom } from "#/core/errors";
8
8
  import { err, ok } from "#/core/result";
9
9
  import { findNearestPackageVersion } from "#/core/workspace/package-version";
@@ -0,0 +1,13 @@
1
+ import type { DisplayNameAuditResult } from "#/audit/domain/types";
2
+ /**
3
+ * Exit `1` when any non-allowlisted display-name violation remains.
4
+ *
5
+ * @since 0.9.0
6
+ */
7
+ export declare function exitCodeForDisplayNameAuditResult(result: DisplayNameAuditResult): number;
8
+ /**
9
+ * Machine-readable display-name summary for `--json`.
10
+ *
11
+ * @since 0.9.0
12
+ */
13
+ export declare function formatDisplayNameAuditJsonOutput(result: DisplayNameAuditResult, rootDir: string): string;
@@ -0,0 +1,22 @@
1
+ import { CLI_EXIT_GENERAL_ERROR, CLI_EXIT_SUCCESS } from "#/core/exit-codes";
2
+ /**
3
+ * Exit `1` when any non-allowlisted display-name violation remains.
4
+ *
5
+ * @since 0.9.0
6
+ */
7
+ export function exitCodeForDisplayNameAuditResult(result) {
8
+ return result.violationCount > 0 ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
9
+ }
10
+ /**
11
+ * Machine-readable display-name summary for `--json`.
12
+ *
13
+ * @since 0.9.0
14
+ */
15
+ export function formatDisplayNameAuditJsonOutput(result, rootDir) {
16
+ return JSON.stringify({
17
+ schemaVersion: 1,
18
+ ok: result.violationCount === 0,
19
+ cwd: rootDir,
20
+ result,
21
+ });
22
+ }
@@ -0,0 +1,18 @@
1
+ import * as z from "zod";
2
+ /**
3
+ * Resolved request for a single display-name audit run.
4
+ *
5
+ * @since 0.9.0
6
+ */
7
+ export type DisplayNameAuditRunRequest = {
8
+ readonly rootDir: string;
9
+ readonly targetPath: string;
10
+ readonly allowlist?: ReadonlyArray<string> | undefined;
11
+ readonly json: boolean;
12
+ };
13
+ /**
14
+ * Zod schema for {@link DisplayNameAuditRunRequest}.
15
+ *
16
+ * @since 0.9.0
17
+ */
18
+ export declare const displayNameAuditRunRequestSchema: z.ZodType<DisplayNameAuditRunRequest>;
@@ -0,0 +1,12 @@
1
+ import * as z from "zod";
2
+ /**
3
+ * Zod schema for {@link DisplayNameAuditRunRequest}.
4
+ *
5
+ * @since 0.9.0
6
+ */
7
+ export const displayNameAuditRunRequestSchema = z.object({
8
+ rootDir: z.string().min(1),
9
+ targetPath: z.string().min(1),
10
+ allowlist: z.array(z.string()).optional(),
11
+ json: z.boolean(),
12
+ });
@@ -0,0 +1,7 @@
1
+ import type { DisplayNameAuditResult } from "#/audit/domain/types";
2
+ /**
3
+ * Human-readable display-name report.
4
+ *
5
+ * @since 0.9.0
6
+ */
7
+ export declare function presentDisplayNameAuditResult(result: DisplayNameAuditResult): void;
@@ -0,0 +1,21 @@
1
+ import { logger } from "#/core/logger";
2
+ /**
3
+ * Human-readable display-name report.
4
+ *
5
+ * @since 0.9.0
6
+ */
7
+ export function presentDisplayNameAuditResult(result) {
8
+ for (const file of result.files) {
9
+ logger.out(`\n${file.relativePath}`);
10
+ for (const { line, raw, reason } of file.violations) {
11
+ logger.out(` ${line}: ${raw} → ${reason}`);
12
+ }
13
+ }
14
+ const allowlistSuffix = result.allowlistedCount > 0 ? ` (${result.allowlistedCount} allowlisted)` : "";
15
+ if (result.violationCount > 0) {
16
+ logger.out(`\n✖ ${result.violationCount} display name(s) off the convention${allowlistSuffix}`);
17
+ }
18
+ else {
19
+ logger.out(`✓ Every token, tag and module display name follows <namespace>:<Name> across ${result.scannedFileCount} file(s)${allowlistSuffix}`);
20
+ }
21
+ }
@@ -0,0 +1,16 @@
1
+ import type { AuditCommandPrelude } from "#/audit/prepare";
2
+ import type { AppError } from "#/core/errors";
3
+ import type { Filesystem } from "#/core/filesystem/filesystem";
4
+ import type { Result } from "#/core/result";
5
+ /**
6
+ * Loads config and resolves the scan target for `audit display-names`.
7
+ *
8
+ * @remarks Defaults to the repo root: a display name collides across packages, so the convention
9
+ * has to hold across them.
10
+ *
11
+ * @since 0.9.0
12
+ */
13
+ export declare function prepareDisplayNameAudit(fs: Filesystem, args: {
14
+ readonly currentWorkingDirectory: string;
15
+ readonly rawTarget: string | undefined;
16
+ }): Promise<Result<AuditCommandPrelude, AppError>>;
@@ -0,0 +1,12 @@
1
+ import { prepareRepoRootAudit } from "#/audit/prepare";
2
+ /**
3
+ * Loads config and resolves the scan target for `audit display-names`.
4
+ *
5
+ * @remarks Defaults to the repo root: a display name collides across packages, so the convention
6
+ * has to hold across them.
7
+ *
8
+ * @since 0.9.0
9
+ */
10
+ export async function prepareDisplayNameAudit(fs, args) {
11
+ return prepareRepoRootAudit(fs, args, (config) => config.audit?.displayNames?.allowlist ?? []);
12
+ }
@@ -1,13 +1,13 @@
1
1
  import type { DisplayNameAuditResult } from "#/audit/domain/types";
2
2
  import { AppError } from "#/core/errors";
3
- import type { FilesystemPort } from "#/core/filesystem/port";
3
+ import type { Filesystem } from "#/core/filesystem/filesystem";
4
4
  import type { Result } from "#/core/result";
5
5
  /**
6
6
  * Scans a target path for `token()`, `tag()` and module display names that break the convention.
7
7
  *
8
8
  * @since 0.9.0
9
9
  */
10
- export declare function runDisplayNameAudit(fs: FilesystemPort, args: {
10
+ export declare function runDisplayNameAudit(fs: Filesystem, args: {
11
11
  readonly rootDir: string;
12
12
  readonly targetPath: string;
13
13
  readonly allowlist: ReadonlyArray<string>;
@@ -1,5 +1,5 @@
1
1
  import path from "node:path";
2
- import { auditDisplayNames } from "#/audit/domain/display-names";
2
+ import { auditDisplayNames } from "#/audit/display-names/domain/display-names";
3
3
  import { AppError, messageFrom } from "#/core/errors";
4
4
  import { err, ok } from "#/core/result";
5
5
  import { walkMarkdownFiles } from "#/core/workspace/markdown-walk";
@@ -0,0 +1,13 @@
1
+ import type { ImportsAuditResult } from "#/audit/domain/types";
2
+ /**
3
+ * Exit `1` when any non-allowlisted import-policy violation remains.
4
+ *
5
+ * @since 0.10.0
6
+ */
7
+ export declare function exitCodeForImportsAuditResult(result: ImportsAuditResult): number;
8
+ /**
9
+ * Machine-readable import-policy summary for `--json`.
10
+ *
11
+ * @since 0.10.0
12
+ */
13
+ export declare function formatImportsAuditJsonOutput(result: ImportsAuditResult, rootDir: string): string;
@@ -0,0 +1,22 @@
1
+ import { CLI_EXIT_GENERAL_ERROR, CLI_EXIT_SUCCESS } from "#/core/exit-codes";
2
+ /**
3
+ * Exit `1` when any non-allowlisted import-policy violation remains.
4
+ *
5
+ * @since 0.10.0
6
+ */
7
+ export function exitCodeForImportsAuditResult(result) {
8
+ return result.violationCount > 0 ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
9
+ }
10
+ /**
11
+ * Machine-readable import-policy summary for `--json`.
12
+ *
13
+ * @since 0.10.0
14
+ */
15
+ export function formatImportsAuditJsonOutput(result, rootDir) {
16
+ return JSON.stringify({
17
+ schemaVersion: 1,
18
+ ok: result.violationCount === 0,
19
+ cwd: rootDir,
20
+ result,
21
+ });
22
+ }
@@ -0,0 +1,18 @@
1
+ import * as z from "zod";
2
+ /**
3
+ * Resolved request for a single import-policy audit run.
4
+ *
5
+ * @since 0.10.0
6
+ */
7
+ export type ImportsAuditRunRequest = {
8
+ readonly rootDir: string;
9
+ readonly targetPath: string;
10
+ readonly allowlist?: ReadonlyArray<string> | undefined;
11
+ readonly json: boolean;
12
+ };
13
+ /**
14
+ * Zod schema for {@link ImportsAuditRunRequest}.
15
+ *
16
+ * @since 0.10.0
17
+ */
18
+ export declare const importsAuditRunRequestSchema: z.ZodType<ImportsAuditRunRequest>;
@@ -0,0 +1,12 @@
1
+ import * as z from "zod";
2
+ /**
3
+ * Zod schema for {@link ImportsAuditRunRequest}.
4
+ *
5
+ * @since 0.10.0
6
+ */
7
+ export const importsAuditRunRequestSchema = z.object({
8
+ rootDir: z.string().min(1),
9
+ targetPath: z.string().min(1),
10
+ allowlist: z.array(z.string()).optional(),
11
+ json: z.boolean(),
12
+ });
@@ -16,8 +16,8 @@ export interface ImportPolicyRule {
16
16
  }
17
17
  /**
18
18
  * The import policies enforced across the monorepo: React members by name (never a namespace,
19
- * default, or implicit `React.*` UMD global), and Zod as a namespace in front-end packages so
20
- * bundlers can tree-shake it (a named `import { z }` pins Zod's full locale set into the bundle).
19
+ * default, or implicit `React.*` UMD global), and Zod as a namespace repo-wide — the house form,
20
+ * so a named `import { z }` never pins Zod's full locale set into a package that ships bundled.
21
21
  *
22
22
  * @since 0.10.0
23
23
  */
@@ -1,8 +1,8 @@
1
1
  import { parseSync } from "oxc-parser";
2
2
  /**
3
3
  * The import policies enforced across the monorepo: React members by name (never a namespace,
4
- * default, or implicit `React.*` UMD global), and Zod as a namespace in front-end packages so
5
- * bundlers can tree-shake it (a named `import { z }` pins Zod's full locale set into the bundle).
4
+ * default, or implicit `React.*` UMD global), and Zod as a namespace repo-wide — the house form,
5
+ * so a named `import { z }` never pins Zod's full locale set into a package that ships bundled.
6
6
  *
7
7
  * @since 0.10.0
8
8
  */
@@ -16,15 +16,8 @@ export const defaultImportPolicyRules = [
16
16
  {
17
17
  module: "zod",
18
18
  ban: ["named:z"],
19
- scope: [
20
- "packages/theme/**",
21
- "packages/ui/**",
22
- "packages/tailwind-variants/**",
23
- "apps/web/**",
24
- "examples/*/**",
25
- "internal/benchmark-viewer/**",
26
- ],
27
- message: 'import Zod as a namespace so bundlers can tree-shake it: import * as z from "zod"',
19
+ message: 'import Zod as a namespace: import * as z from "zod" (repo house form; a named import { z } pins Zod\'s full ' +
20
+ "locale set into any bundle that reaches it)",
28
21
  },
29
22
  ];
30
23
  function isOxcNode(value) {
@@ -0,0 +1,7 @@
1
+ import type { ImportsAuditResult } from "#/audit/domain/types";
2
+ /**
3
+ * Human-readable import-policy report.
4
+ *
5
+ * @since 0.10.0
6
+ */
7
+ export declare function presentImportsAuditResult(result: ImportsAuditResult): void;
@@ -0,0 +1,21 @@
1
+ import { logger } from "#/core/logger";
2
+ /**
3
+ * Human-readable import-policy report.
4
+ *
5
+ * @since 0.10.0
6
+ */
7
+ export function presentImportsAuditResult(result) {
8
+ for (const file of result.files) {
9
+ logger.out(`\n${file.relativePath}`);
10
+ for (const { line, raw, reason } of file.violations) {
11
+ logger.out(` ${line}: ${raw} → ${reason}`);
12
+ }
13
+ }
14
+ const allowlistSuffix = result.allowlistedCount > 0 ? ` (${result.allowlistedCount} allowlisted)` : "";
15
+ if (result.violationCount > 0) {
16
+ logger.out(`\n✖ ${result.violationCount} import-policy violation(s)${allowlistSuffix}`);
17
+ }
18
+ else {
19
+ logger.out(`✓ No import-policy violations across ${result.scannedFileCount} file(s)${allowlistSuffix}`);
20
+ }
21
+ }
@@ -0,0 +1,16 @@
1
+ import type { AuditCommandPrelude } from "#/audit/prepare";
2
+ import type { AppError } from "#/core/errors";
3
+ import type { Filesystem } from "#/core/filesystem/filesystem";
4
+ import type { Result } from "#/core/result";
5
+ /**
6
+ * Loads config and resolves the scan target for `audit imports`.
7
+ *
8
+ * @remarks Defaults to the repo root: the import policy is repo-wide, and generated or vendored
9
+ * trees are already excluded by the shared walk.
10
+ *
11
+ * @since 0.10.0
12
+ */
13
+ export declare function prepareImportsAudit(fs: Filesystem, args: {
14
+ readonly currentWorkingDirectory: string;
15
+ readonly rawTarget: string | undefined;
16
+ }): Promise<Result<AuditCommandPrelude, AppError>>;
@@ -0,0 +1,12 @@
1
+ import { prepareRepoRootAudit } from "#/audit/prepare";
2
+ /**
3
+ * Loads config and resolves the scan target for `audit imports`.
4
+ *
5
+ * @remarks Defaults to the repo root: the import policy is repo-wide, and generated or vendored
6
+ * trees are already excluded by the shared walk.
7
+ *
8
+ * @since 0.10.0
9
+ */
10
+ export async function prepareImportsAudit(fs, args) {
11
+ return prepareRepoRootAudit(fs, args, (config) => config.audit?.imports?.allowlist ?? []);
12
+ }
@@ -1,13 +1,13 @@
1
1
  import type { ImportsAuditResult } from "#/audit/domain/types";
2
2
  import { AppError } from "#/core/errors";
3
- import type { FilesystemPort } from "#/core/filesystem/port";
3
+ import type { Filesystem } from "#/core/filesystem/filesystem";
4
4
  import type { Result } from "#/core/result";
5
5
  /**
6
6
  * Scans a target path for import-policy violations, applying each rule only to files in its scope.
7
7
  *
8
8
  * @since 0.10.0
9
9
  */
10
- export declare function runImportsAudit(fs: FilesystemPort, args: {
10
+ export declare function runImportsAudit(fs: Filesystem, args: {
11
11
  readonly rootDir: string;
12
12
  readonly targetPath: string;
13
13
  readonly allowlist: ReadonlyArray<string>;
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
- import { defaultImportPolicyRules } from "#/audit/domain/import-policy";
3
- import { auditImportPolicySource } from "#/audit/domain/import-policy";
2
+ import { defaultImportPolicyRules } from "#/audit/imports/domain/import-policy";
3
+ import { auditImportPolicySource } from "#/audit/imports/domain/import-policy";
4
4
  import { AppError, messageFrom } from "#/core/errors";
5
5
  import { createAnyGlobMatcher } from "#/core/glob";
6
6
  import { err, ok } from "#/core/result";
@@ -0,0 +1,13 @@
1
+ import type { LinkAuditResult } from "#/audit/domain/types";
2
+ /**
3
+ * Exit `1` when any non-allowlisted broken link remains.
4
+ *
5
+ * @since 0.5.0
6
+ */
7
+ export declare function exitCodeForLinkAuditResult(result: LinkAuditResult): number;
8
+ /**
9
+ * Machine-readable link audit summary for `--json`.
10
+ *
11
+ * @since 0.5.0
12
+ */
13
+ export declare function formatLinkAuditJsonOutput(result: LinkAuditResult, rootDir: string): string;
@@ -0,0 +1,22 @@
1
+ import { CLI_EXIT_GENERAL_ERROR, CLI_EXIT_SUCCESS } from "#/core/exit-codes";
2
+ /**
3
+ * Exit `1` when any non-allowlisted broken link remains.
4
+ *
5
+ * @since 0.5.0
6
+ */
7
+ export function exitCodeForLinkAuditResult(result) {
8
+ return result.breakageCount > 0 ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
9
+ }
10
+ /**
11
+ * Machine-readable link audit summary for `--json`.
12
+ *
13
+ * @since 0.5.0
14
+ */
15
+ export function formatLinkAuditJsonOutput(result, rootDir) {
16
+ return JSON.stringify({
17
+ schemaVersion: 1,
18
+ ok: result.breakageCount === 0,
19
+ cwd: rootDir,
20
+ result,
21
+ });
22
+ }
@@ -0,0 +1,18 @@
1
+ import * as z from "zod";
2
+ /**
3
+ * Resolved request for a single link audit run.
4
+ *
5
+ * @since 0.5.0
6
+ */
7
+ export type LinkAuditRunRequest = {
8
+ readonly rootDir: string;
9
+ readonly targetPath: string;
10
+ readonly allowlist?: ReadonlyArray<string> | undefined;
11
+ readonly json: boolean;
12
+ };
13
+ /**
14
+ * Zod schema for {@link LinkAuditRunRequest}.
15
+ *
16
+ * @since 0.5.0
17
+ */
18
+ export declare const linkAuditRunRequestSchema: z.ZodType<LinkAuditRunRequest>;
@@ -0,0 +1,12 @@
1
+ import * as z from "zod";
2
+ /**
3
+ * Zod schema for {@link LinkAuditRunRequest}.
4
+ *
5
+ * @since 0.5.0
6
+ */
7
+ export const linkAuditRunRequestSchema = z.object({
8
+ rootDir: z.string().min(1),
9
+ targetPath: z.string().min(1),
10
+ allowlist: z.array(z.string()).optional(),
11
+ json: z.boolean(),
12
+ });
@@ -0,0 +1,7 @@
1
+ import type { LinkAuditResult } from "#/audit/domain/types";
2
+ /**
3
+ * Human-readable link audit report.
4
+ *
5
+ * @since 0.5.0
6
+ */
7
+ export declare function presentLinkAuditResult(result: LinkAuditResult): void;
@@ -0,0 +1,21 @@
1
+ import { logger } from "#/core/logger";
2
+ /**
3
+ * Human-readable link audit report.
4
+ *
5
+ * @since 0.5.0
6
+ */
7
+ export function presentLinkAuditResult(result) {
8
+ for (const file of result.files) {
9
+ logger.out(`\n${file.relativePath}`);
10
+ for (const { line, raw, reason } of file.breakages) {
11
+ logger.out(` ${line}: ${raw} → ${reason}`);
12
+ }
13
+ }
14
+ const allowlistSuffix = result.allowlistedCount > 0 ? ` (${result.allowlistedCount} allowlisted)` : "";
15
+ if (result.breakageCount > 0) {
16
+ logger.out(`\n✖ ${result.breakageCount} broken link(s)${allowlistSuffix}`);
17
+ }
18
+ else {
19
+ logger.out(`✓ ${result.linkCount} repo-local link(s) across ${result.scannedFileCount} document(s) all resolve${allowlistSuffix}`);
20
+ }
21
+ }
@@ -0,0 +1,16 @@
1
+ import type { AuditCommandPrelude } from "#/audit/prepare";
2
+ import type { AppError } from "#/core/errors";
3
+ import type { Filesystem } from "#/core/filesystem/filesystem";
4
+ import type { Result } from "#/core/result";
5
+ /**
6
+ * Loads config and resolves the scan target for `audit links`.
7
+ *
8
+ * @remarks Defaults to the repo root rather than a configured path: a link audit that only covers one
9
+ * package cannot see the cross-package references that are the ones most likely to rot.
10
+ *
11
+ * @since 0.5.0
12
+ */
13
+ export declare function prepareLinkAudit(fs: Filesystem, args: {
14
+ readonly currentWorkingDirectory: string;
15
+ readonly rawTarget: string | undefined;
16
+ }): Promise<Result<AuditCommandPrelude, AppError>>;
@@ -0,0 +1,12 @@
1
+ import { prepareRepoRootAudit } from "#/audit/prepare";
2
+ /**
3
+ * Loads config and resolves the scan target for `audit links`.
4
+ *
5
+ * @remarks Defaults to the repo root rather than a configured path: a link audit that only covers one
6
+ * package cannot see the cross-package references that are the ones most likely to rot.
7
+ *
8
+ * @since 0.5.0
9
+ */
10
+ export async function prepareLinkAudit(fs, args) {
11
+ return prepareRepoRootAudit(fs, args, (config) => config.audit?.links?.allowlist ?? []);
12
+ }
@@ -1,13 +1,13 @@
1
1
  import type { LinkAuditResult } from "#/audit/domain/types";
2
2
  import { AppError } from "#/core/errors";
3
- import type { FilesystemPort } from "#/core/filesystem/port";
3
+ import type { Filesystem } from "#/core/filesystem/filesystem";
4
4
  import type { Result } from "#/core/result";
5
5
  /**
6
6
  * Reports markdown links that point at nothing — a missing path, or an anchor the target does not offer.
7
7
  *
8
8
  * @since 0.5.0
9
9
  */
10
- export declare function runLinkAudit(fs: FilesystemPort, args: {
10
+ export declare function runLinkAudit(fs: Filesystem, args: {
11
11
  readonly rootDir: string;
12
12
  readonly targetPath: string;
13
13
  readonly allowlist: ReadonlyArray<string>;
@@ -1,5 +1,5 @@
1
1
  import path from "node:path";
2
- import { collectMarkdownAnchors, scanMarkdownLinks } from "#/audit/domain/markdown-links";
2
+ import { collectMarkdownAnchors, scanMarkdownLinks } from "#/audit/links/domain/markdown-links";
3
3
  import { AppError, messageFrom } from "#/core/errors";
4
4
  import { err, ok } from "#/core/result";
5
5
  import { walkMarkdownFiles } from "#/core/workspace/markdown-walk";