@xessa/cli 0.0.0-stage → 0.1.2

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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +443 -2
  3. package/dist/args.d.ts +43 -0
  4. package/dist/args.d.ts.map +1 -0
  5. package/dist/args.js +202 -0
  6. package/dist/args.js.map +1 -0
  7. package/dist/commands/build.d.ts +44 -0
  8. package/dist/commands/build.d.ts.map +1 -0
  9. package/dist/commands/build.js +533 -0
  10. package/dist/commands/build.js.map +1 -0
  11. package/dist/commands/check.d.ts +11 -0
  12. package/dist/commands/check.d.ts.map +1 -0
  13. package/dist/commands/check.js +35 -0
  14. package/dist/commands/check.js.map +1 -0
  15. package/dist/commands/clean.d.ts +12 -0
  16. package/dist/commands/clean.d.ts.map +1 -0
  17. package/dist/commands/clean.js +140 -0
  18. package/dist/commands/clean.js.map +1 -0
  19. package/dist/commands/format.d.ts +41 -0
  20. package/dist/commands/format.d.ts.map +1 -0
  21. package/dist/commands/format.js +127 -0
  22. package/dist/commands/format.js.map +1 -0
  23. package/dist/commands/watch.d.ts +38 -0
  24. package/dist/commands/watch.d.ts.map +1 -0
  25. package/dist/commands/watch.js +338 -0
  26. package/dist/commands/watch.js.map +1 -0
  27. package/dist/compiler.d.ts +20 -0
  28. package/dist/compiler.d.ts.map +1 -0
  29. package/dist/compiler.js +57 -0
  30. package/dist/compiler.js.map +1 -0
  31. package/dist/config.d.ts +93 -0
  32. package/dist/config.d.ts.map +1 -0
  33. package/dist/config.js +331 -0
  34. package/dist/config.js.map +1 -0
  35. package/dist/formatter.d.ts +21 -0
  36. package/dist/formatter.d.ts.map +1 -0
  37. package/dist/formatter.js +38 -0
  38. package/dist/formatter.js.map +1 -0
  39. package/dist/glob.d.ts +52 -0
  40. package/dist/glob.d.ts.map +1 -0
  41. package/dist/glob.js +214 -0
  42. package/dist/glob.js.map +1 -0
  43. package/dist/index.d.ts +34 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +114 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/manifest.d.ts +56 -0
  48. package/dist/manifest.d.ts.map +1 -0
  49. package/dist/manifest.js +138 -0
  50. package/dist/manifest.js.map +1 -0
  51. package/dist/paths.d.ts +24 -0
  52. package/dist/paths.d.ts.map +1 -0
  53. package/dist/paths.js +42 -0
  54. package/dist/paths.js.map +1 -0
  55. package/dist/project.d.ts +44 -0
  56. package/dist/project.d.ts.map +1 -0
  57. package/dist/project.js +92 -0
  58. package/dist/project.js.map +1 -0
  59. package/dist/report.d.ts +128 -0
  60. package/dist/report.d.ts.map +1 -0
  61. package/dist/report.js +128 -0
  62. package/dist/report.js.map +1 -0
  63. package/dist/setup.d.ts +58 -0
  64. package/dist/setup.d.ts.map +1 -0
  65. package/dist/setup.js +181 -0
  66. package/dist/setup.js.map +1 -0
  67. package/dist/writer.d.ts +32 -0
  68. package/dist/writer.d.ts.map +1 -0
  69. package/dist/writer.js +93 -0
  70. package/dist/writer.js.map +1 -0
  71. package/package.json +40 -4
  72. package/src/args.ts +246 -0
  73. package/src/commands/build.ts +682 -0
  74. package/src/commands/check.ts +45 -0
  75. package/src/commands/clean.ts +168 -0
  76. package/src/commands/format.ts +169 -0
  77. package/src/commands/watch.ts +366 -0
  78. package/src/compiler-api.d.ts +261 -0
  79. package/src/compiler.ts +65 -0
  80. package/src/config.ts +443 -0
  81. package/src/formatter.ts +56 -0
  82. package/src/glob.ts +230 -0
  83. package/src/index.ts +137 -0
  84. package/src/manifest.ts +176 -0
  85. package/src/paths.ts +50 -0
  86. package/src/project.ts +122 -0
  87. package/src/report.ts +230 -0
  88. package/src/setup.ts +218 -0
  89. package/src/writer.ts +102 -0
package/dist/paths.js ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Small POSIX-style path helpers shared by the CLI.
3
+ *
4
+ * Node's `node:path` handles platform separators and drive letters; every value
5
+ * that crosses a CLI boundary (reports, manifests, compiler input) is converted
6
+ * to POSIX form with forward slashes.
7
+ */
8
+ import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
9
+ /** Convert platform separators to forward slashes. */
10
+ export function toPosix(path) {
11
+ return path.replace(/\\/g, "/");
12
+ }
13
+ /** Resolve `value` against `base` (when relative) and return a POSIX absolute path. */
14
+ export function absolutePath(base, value) {
15
+ return toPosix(isAbsolute(value) ? resolve(value) : resolve(base, value));
16
+ }
17
+ /** POSIX path of `to` relative to `from`. */
18
+ export function relativePosix(from, to) {
19
+ return toPosix(relative(from, to));
20
+ }
21
+ /** POSIX parent directory. */
22
+ export function dirnamePosix(path) {
23
+ return toPosix(dirname(path));
24
+ }
25
+ /** POSIX basename. */
26
+ export function basenamePosix(path) {
27
+ return toPosix(basename(path));
28
+ }
29
+ /** POSIX join. */
30
+ export function joinPosix(...parts) {
31
+ return toPosix(join(...parts));
32
+ }
33
+ /** Whether `target` is `root` itself or nested inside it. */
34
+ export function isWithin(root, target) {
35
+ const rel = relativePosix(root, target);
36
+ return rel === "" || (!isAbsolute(rel) && rel !== ".." && !rel.startsWith("../"));
37
+ }
38
+ /** Whether a relative path is absolute or escapes its base. */
39
+ export function isEscapingPath(relativePath) {
40
+ return isAbsolute(relativePath) || relativePath === ".." || relativePath.startsWith("../");
41
+ }
42
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnF,sDAAsD;AACtD,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,KAAa;IACtD,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workspace root (nearest `xessa.config.json`, else nearest
5
+ * `package.json`, ADR-0007), the configuration found there and the entry list:
6
+ * either one explicit file or the sources matched by the config include globs.
7
+ * Configuration is optional for project runs: without a file the root still
8
+ * comes from the workspace walk and discovery uses {@link DEFAULT_INCLUDE}.
9
+ */
10
+ import type { CliInvocation } from "./args.js";
11
+ import { type CliConfig } from "./config.js";
12
+ /** Resolved project inputs for one CLI run. */
13
+ export interface ProjectContext {
14
+ /** Absolute POSIX workspace root. */
15
+ readonly root: string;
16
+ /** Loaded configuration, or `null` for a config-less project/single-file run. */
17
+ readonly config: CliConfig | null;
18
+ /** Non-fatal configuration notes (ignored unknown keys outside strict mode). */
19
+ readonly configWarnings: readonly string[];
20
+ /** Entry sources, workspace-relative POSIX and deterministically sorted. */
21
+ readonly entries: readonly string[];
22
+ /** Whether the run targets one explicit file instead of the whole project. */
23
+ readonly singleEntry: boolean;
24
+ }
25
+ /** Outcome of {@link prepareProject}. */
26
+ export type ProjectContextResult = {
27
+ readonly ok: true;
28
+ readonly context: ProjectContext;
29
+ } | {
30
+ readonly ok: false;
31
+ readonly message: string;
32
+ };
33
+ /**
34
+ * Resolve configuration, workspace root and entries for build/check/watch.
35
+ *
36
+ * Configuration is optional. Without a file, the workspace root is the nearest
37
+ * `package.json` ancestor (ADR-0007) and project discovery uses
38
+ * {@link DEFAULT_INCLUDE}; a single-entry run falls back to the file's
39
+ * directory when no package boundary exists. Explicitly configuring an empty
40
+ * `include` list remains an invocation error, and an empty discovery result is
41
+ * reported by the command as a configuration error (typo protection).
42
+ */
43
+ export declare function prepareProject(invocation: CliInvocation, cwd: string): Promise<ProjectContextResult>;
44
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,KAAK,SAAS,EAAkD,MAAM,aAAa,CAAC;AAI7F,+CAA+C;AAC/C,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IAClC,gFAAgF;IAChF,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,8EAA8E;IAC9E,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAED,yCAAyC;AACzC,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;CAAE,GACvD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,aAAa,EACzB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,oBAAoB,CAAC,CAiE/B"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Project resolution shared by every command.
3
+ *
4
+ * A project is the workspace root (nearest `xessa.config.json`, else nearest
5
+ * `package.json`, ADR-0007), the configuration found there and the entry list:
6
+ * either one explicit file or the sources matched by the config include globs.
7
+ * Configuration is optional for project runs: without a file the root still
8
+ * comes from the workspace walk and discovery uses {@link DEFAULT_INCLUDE}.
9
+ */
10
+ import { stat } from "node:fs/promises";
11
+ import { DEFAULT_INCLUDE, findWorkspaceRoot, loadConfig } from "./config.js";
12
+ import { discoverSources } from "./glob.js";
13
+ import { absolutePath, dirnamePosix, isWithin, relativePosix } from "./paths.js";
14
+ /**
15
+ * Resolve configuration, workspace root and entries for build/check/watch.
16
+ *
17
+ * Configuration is optional. Without a file, the workspace root is the nearest
18
+ * `package.json` ancestor (ADR-0007) and project discovery uses
19
+ * {@link DEFAULT_INCLUDE}; a single-entry run falls back to the file's
20
+ * directory when no package boundary exists. Explicitly configuring an empty
21
+ * `include` list remains an invocation error, and an empty discovery result is
22
+ * reported by the command as a configuration error (typo protection).
23
+ */
24
+ export async function prepareProject(invocation, cwd) {
25
+ const fileArgument = invocation.file;
26
+ let fileAbsolute;
27
+ let startDir = cwd;
28
+ if (fileArgument !== undefined) {
29
+ fileAbsolute = absolutePath(cwd, fileArgument);
30
+ if (!(await isFile(fileAbsolute))) {
31
+ return { ok: false, message: `Source file not found: ${fileArgument}` };
32
+ }
33
+ startDir = dirnamePosix(fileAbsolute);
34
+ }
35
+ const loaded = await loadConfig({
36
+ cwd,
37
+ startDir,
38
+ ...(invocation.configPath === undefined ? {} : { explicitPath: invocation.configPath }),
39
+ });
40
+ if (!loaded.ok)
41
+ return { ok: false, message: loaded.message };
42
+ const config = loaded.config;
43
+ const root = config === null ? await findWorkspaceRoot(startDir) : config.root;
44
+ if (fileAbsolute !== undefined) {
45
+ if (!isWithin(root, fileAbsolute)) {
46
+ return {
47
+ ok: false,
48
+ message: `Source file "${fileArgument ?? fileAbsolute}" is outside the workspace root "${root}". Pass --config for the containing project.`,
49
+ };
50
+ }
51
+ return {
52
+ ok: true,
53
+ context: {
54
+ root,
55
+ config,
56
+ configWarnings: loaded.warnings,
57
+ entries: [relativePosix(root, fileAbsolute)],
58
+ singleEntry: true,
59
+ },
60
+ };
61
+ }
62
+ if (config !== null && config.include.length === 0) {
63
+ return {
64
+ ok: false,
65
+ message: `"include" in ${config.file} must list at least one glob.`,
66
+ };
67
+ }
68
+ const entries = await discoverSources({
69
+ root,
70
+ include: config?.include ?? DEFAULT_INCLUDE,
71
+ exclude: config?.exclude ?? [],
72
+ });
73
+ return {
74
+ ok: true,
75
+ context: {
76
+ root,
77
+ config,
78
+ configWarnings: loaded.warnings,
79
+ entries,
80
+ singleEntry: false,
81
+ },
82
+ };
83
+ }
84
+ async function isFile(path) {
85
+ try {
86
+ return (await stat(path)).isFile();
87
+ }
88
+ catch {
89
+ return false;
90
+ }
91
+ }
92
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAkB,eAAe,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAqBjF;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,UAAyB,EACzB,GAAW;IAEX,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC;IACrC,IAAI,YAAgC,CAAC;IACrC,IAAI,QAAQ,GAAG,GAAG,CAAC;IAEnB,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,YAAY,GAAG,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC;YAClC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,0BAA0B,YAAY,EAAE,EAAE,CAAC;QAC1E,CAAC;QACD,QAAQ,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC;QAC9B,GAAG;QACH,QAAQ;QACR,GAAG,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,UAAU,CAAC,UAAU,EAAE,C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IAAI;YACJ,MAAM;YACN,cAAc,EAAE,MAAM,CAAC,QAAQ;YAC/B,OAAO;YACP,WAAW,EAAE,KAAK;SACnB;KACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,MAAM,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Reporting helpers: diagnostic positioning, text output and JSON shapes.
3
+ *
4
+ * Compiler diagnostics carry UTF-16 offsets (`Span`), so the CLI converts them
5
+ * to 1-based line and column numbers using the entry sources it already reads.
6
+ * Machine-readable output is stable and documented in the A11 report.
7
+ */
8
+ import type { Diagnostic, OutputKind } from "@xessa/compiler";
9
+ /** A compiler diagnostic positioned for humans and machine consumers. */
10
+ export interface CliDiagnostic {
11
+ /** Stable compiler code (`XESSA####`) or CLI code (`XESSACLI###`). */
12
+ readonly code: string;
13
+ /** `error` fails a build/check; `warning` is advisory. */
14
+ readonly severity: "error" | "warning";
15
+ /** User-facing explanation. */
16
+ readonly message: string;
17
+ /** Workspace-relative POSIX path of the diagnostic origin. */
18
+ readonly file: string;
19
+ /** 1-based line number. */
20
+ readonly line: number;
21
+ /** 1-based column number. */
22
+ readonly column: number;
23
+ }
24
+ /** One planned artifact and whether this run wrote it. */
25
+ export interface OutputRecord {
26
+ /** Artifact kind. */
27
+ readonly kind: OutputKind;
28
+ /** Workspace-relative POSIX destination. */
29
+ readonly path: string;
30
+ /** Absolute destination. */
31
+ readonly absolutePath: string;
32
+ /** Whether the artifact was written by this run. */
33
+ readonly written: boolean;
34
+ /** Why the artifact was not written, when applicable. */
35
+ readonly reason?: string;
36
+ }
37
+ /** Per-entry result of a build or check. */
38
+ export interface EntryReport {
39
+ /** Workspace-relative POSIX path of the entry source. */
40
+ readonly file: string;
41
+ /** Workspace-relative POSIX paths of reachable modules, excluding the entry. */
42
+ readonly dependencies: readonly string[];
43
+ /** Planned artifacts in planner order. */
44
+ readonly outputs: readonly OutputRecord[];
45
+ /** Positioned diagnostics for this entry and its modules. */
46
+ readonly diagnostics: readonly CliDiagnostic[];
47
+ }
48
+ /** Result of one build or check run. */
49
+ export interface BuildReport {
50
+ /** Command that produced the report. */
51
+ readonly command: "build" | "check";
52
+ /** Absolute POSIX workspace root. */
53
+ readonly workspaceRoot: string;
54
+ /** Absolute path of the configuration file, when one was used. */
55
+ readonly configFile: string | null;
56
+ /** Whether the run only reported planned work. */
57
+ readonly dryRun: boolean;
58
+ /** One report per entry, sorted like the input entries. */
59
+ readonly entries: readonly EntryReport[];
60
+ /** All positioned diagnostics, deduplicated. */
61
+ readonly diagnostics: readonly CliDiagnostic[];
62
+ /** Non-diagnostic notes and warnings. */
63
+ readonly warnings: readonly string[];
64
+ /** Non-diagnostic failures such as write or manifest errors. */
65
+ readonly errors: readonly string[];
66
+ }
67
+ /** Machine-readable artifact record. */
68
+ export interface JsonOutputFile {
69
+ readonly kind: OutputKind;
70
+ readonly path: string;
71
+ readonly written: boolean;
72
+ readonly reason?: string;
73
+ }
74
+ /** Machine-readable entry record. */
75
+ export interface JsonEntry {
76
+ readonly file: string;
77
+ readonly dependencies: readonly string[];
78
+ readonly outputs: readonly JsonOutputFile[];
79
+ readonly diagnostics: readonly CliDiagnostic[];
80
+ }
81
+ /** Machine-readable build/check report (`--json`). */
82
+ export interface JsonBuildReport {
83
+ readonly command: "build" | "check";
84
+ readonly success: boolean;
85
+ readonly exitCode: number;
86
+ readonly dryRun: boolean;
87
+ readonly workspaceRoot: string;
88
+ readonly configFile: string | null;
89
+ readonly entries: readonly JsonEntry[];
90
+ readonly diagnostics: readonly CliDiagnostic[];
91
+ readonly warnings: readonly string[];
92
+ readonly errors: readonly string[];
93
+ }
94
+ /** Converts compiler spans into 1-based line/column diagnostics. */
95
+ export declare class DiagnosticPositions {
96
+ private readonly root;
97
+ private readonly cache;
98
+ constructor(root: string);
99
+ /** Convert raw compiler diagnostics to positioned CLI diagnostics. */
100
+ convert(diagnostics: readonly Diagnostic[]): Promise<CliDiagnostic[]>;
101
+ private displayPath;
102
+ private readSource;
103
+ }
104
+ /** Convert a UTF-16 offset to 1-based line and column. */
105
+ export declare function positionAt(text: string, offset: number): {
106
+ line: number;
107
+ column: number;
108
+ };
109
+ /** One-line human diagnostic: `file:line:col severity CODE: message`. */
110
+ export declare function formatDiagnostic(diagnostic: CliDiagnostic): string;
111
+ /** Write one line to stdout. */
112
+ export declare function writeLine(text: string): void;
113
+ /** Write one line to stderr. */
114
+ export declare function writeErrorLine(text: string): void;
115
+ /** Serialize a JSON report with a trailing newline. */
116
+ export declare function toJson(report: unknown): string;
117
+ /** Whether any diagnostics in the list are errors. */
118
+ export declare function hasErrors(diagnostics: readonly CliDiagnostic[]): boolean;
119
+ /** Deduplicate positioned diagnostics while preserving first-seen order. */
120
+ export declare function dedupeDiagnostics(diagnostics: readonly CliDiagnostic[]): CliDiagnostic[];
121
+ /**
122
+ * Report an invocation or configuration failure and return exit code 2.
123
+ *
124
+ * With `--json` the failure is still machine-readable; otherwise it goes to
125
+ * stderr with a `xessa:` prefix.
126
+ */
127
+ export declare function invocationFailure(command: string, message: string, json: boolean): number;
128
+ //# sourceMappingURL=report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG9D,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE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EAAE,CAAC;CACpC;AAKD,oEAAoE;AACpE,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoC;gBAE9C,IAAI,EAAE,MAAM;IAIxB,sEAAsE;IAChE,OAAO,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAqB3E,OAAO,CAAC,WAAW;YAQL,UAAU;CAYzB;AAED,0DAA0D;AAC1D,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAczF;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,aAAa,GAAG,MAAM,CAElE;AAED,gCAAgC;AAChC,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,gCAAgC;AAChC,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED,uDAAuD;AACvD,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAE9C;AAED,sDAAsD;AACtD,wBAAgB,SAAS,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAExE;AAED,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,GAAG,aAAa,EAAE,CAUxF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAOzF"}
package/dist/report.js ADDED
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Reporting helpers: diagnostic positioning, text output and JSON shapes.
3
+ *
4
+ * Compiler diagnostics carry UTF-16 offsets (`Span`), so the CLI converts them
5
+ * to 1-based line and column numbers using the entry sources it already reads.
6
+ * Machine-readable output is stable and documented in the A11 report.
7
+ */
8
+ import { readFile } from "node:fs/promises";
9
+ import { isAbsolute } from "node:path";
10
+ import { joinPosix, relativePosix, toPosix } from "./paths.js";
11
+ /** Maximum offset-to-line scan cost per distinct source file. */
12
+ const POSITION_CACHE_LIMIT = 512;
13
+ /** Converts compiler spans into 1-based line/column diagnostics. */
14
+ export class DiagnosticPositions {
15
+ root;
16
+ cache = new Map();
17
+ constructor(root) {
18
+ this.root = root;
19
+ }
20
+ /** Convert raw compiler diagnostics to positioned CLI diagnostics. */
21
+ async convert(diagnostics) {
22
+ const result = [];
23
+ for (const diagnostic of diagnostics) {
24
+ const absolute = isAbsolute(diagnostic.span.file)
25
+ ? toPosix(diagnostic.span.file)
26
+ : joinPosix(this.root, diagnostic.span.file);
27
+ const text = await this.readSource(absolute);
28
+ const position = text === null ? { line: 1, column: 1 } : positionAt(text, diagnostic.span.start);
29
+ result.push({
30
+ code: diagnostic.code,
31
+ severity: diagnostic.severity,
32
+ message: diagnostic.message,
33
+ file: this.displayPath(absolute),
34
+ line: position.line,
35
+ column: position.column,
36
+ });
37
+ }
38
+ return result;
39
+ }
40
+ displayPath(absolute) {
41
+ const relative = relativePosix(this.root, absolute);
42
+ if (relative === "" || relative === ".." || relative.startsWith("../")) {
43
+ return toPosix(absolute);
44
+ }
45
+ return relative;
46
+ }
47
+ async readSource(absolute) {
48
+ if (this.cache.has(absolute))
49
+ return this.cache.get(absolute) ?? null;
50
+ let text = null;
51
+ try {
52
+ text = await readFile(absolute, "utf8");
53
+ }
54
+ catch {
55
+ text = null;
56
+ }
57
+ if (this.cache.size >= POSITION_CACHE_LIMIT)
58
+ this.cache.clear();
59
+ this.cache.set(absolute, text);
60
+ return text;
61
+ }
62
+ }
63
+ /** Convert a UTF-16 offset to 1-based line and column. */
64
+ export function positionAt(text, offset) {
65
+ const limit = Math.max(0, Math.min(offset, text.length));
66
+ let line = 1;
67
+ let column = 1;
68
+ for (let index = 0; index < limit; index += 1) {
69
+ const character = text.charAt(index);
70
+ if (character === "\n") {
71
+ line += 1;
72
+ column = 1;
73
+ }
74
+ else {
75
+ column += 1;
76
+ }
77
+ }
78
+ return { line, column };
79
+ }
80
+ /** One-line human diagnostic: `file:line:col severity CODE: message`. */
81
+ export function formatDiagnostic(diagnostic) {
82
+ return `${diagnostic.file}:${diagnostic.line}:${diagnostic.column} ${diagnostic.severity} ${diagnostic.code}: ${diagnostic.message}`;
83
+ }
84
+ /** Write one line to stdout. */
85
+ export function writeLine(text) {
86
+ process.stdout.write(`${text}\n`);
87
+ }
88
+ /** Write one line to stderr. */
89
+ export function writeErrorLine(text) {
90
+ process.stderr.write(`${text}\n`);
91
+ }
92
+ /** Serialize a JSON report with a trailing newline. */
93
+ export function toJson(report) {
94
+ return `${JSON.stringify(report, null, 2)}\n`;
95
+ }
96
+ /** Whether any diagnostics in the list are errors. */
97
+ export function hasErrors(diagnostics) {
98
+ return diagnostics.some((diagnostic) => diagnostic.severity === "error");
99
+ }
100
+ /** Deduplicate positioned diagnostics while preserving first-seen order. */
101
+ export function dedupeDiagnostics(diagnostics) {
102
+ const seen = new Set();
103
+ const result = [];
104
+ for (const diagnostic of diagnostics) {
105
+ const key = `${diagnostic.code}\u0000${diagnostic.severity}\u0000${diagnostic.file}\u0000${diagnostic.line}\u0000${diagnostic.column}\u0000${diagnostic.message}`;
106
+ if (seen.has(key))
107
+ continue;
108
+ seen.add(key);
109
+ result.push(diagnostic);
110
+ }
111
+ return result;
112
+ }
113
+ /**
114
+ * Report an invocation or configuration failure and return exit code 2.
115
+ *
116
+ * With `--json` the failure is still machine-readable; otherwise it goes to
117
+ * stderr with a `xessa:` prefix.
118
+ */
119
+ export function invocationFailure(command, message, json) {
120
+ if (json) {
121
+ writeLine(toJson({ command, success: false, exitCode: 2, error: message }).trimEnd());
122
+ }
123
+ else {
124
+ writeErrorLine(`xessa: ${message}`);
125
+ }
126
+ return 2;
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I planning.
3
+ *
4
+ * The compiler returns artifacts but not the output plan it used
5
+ * (`CompileResult` has no destination list), so the CLI must build the same
6
+ * `PlanOutputsInput` the compiler builds internally: defaults, project
7
+ * configuration and decoded file `@setup` values, in that order. This module
8
+ * mirrors the documented precedence and the planner's provenance rules from
9
+ * `.ai/reports/CSSX-A10.md`. A future public plan on `CompileResult` would
10
+ * remove the duplication.
11
+ */
12
+ import type { ResolvedSetup, Stylesheet } from "@xessa/compiler";
13
+ import type { CliConfig } from "./config.js";
14
+ /** Authored file-level `@setup` values; absent keys mean "not authored". */
15
+ export interface FileSetupValues {
16
+ readonly prefix?: string;
17
+ readonly cssDir?: string;
18
+ /** File-level `css-dir` list when more than one destination was authored. */
19
+ readonly cssDirs?: readonly string[];
20
+ readonly cssName?: string;
21
+ readonly mapDir?: string;
22
+ readonly mapName?: string;
23
+ readonly emitCss?: boolean;
24
+ readonly emitMap?: boolean;
25
+ /** Resolved declaration flag; `map-types` is canonical, `emit-types` the alias. */
26
+ readonly emitTypes?: boolean;
27
+ readonly sourceMap?: boolean;
28
+ readonly minify?: boolean;
29
+ /** Module map inheritance default (ADR-0020): `@setup { map-inherit: false; }`. */
30
+ readonly mapInherit?: boolean;
31
+ /** Class-map CSS side-effect import (ADR-0021): `@setup { import-css: true; }`. */
32
+ readonly importCss?: boolean;
33
+ /** `@setup { module: true }`: rule-bearing module with no artifacts of its own (ADR-0014). */
34
+ readonly module?: boolean;
35
+ }
36
+ /** Decode every top-level `@setup` block of an entry, first occurrence winning. */
37
+ export declare function decodeFileSetup(ast: Stylesheet): FileSetupValues;
38
+ /**
39
+ * Built-in setup defaults for a workspace-relative source path.
40
+ *
41
+ * Directories default to the source directory and names to `<stem>.css` /
42
+ * `<stem>.map.js`, matching SPECIFICATION.md §9 and the planner's defaults.
43
+ */
44
+ export declare function defaultSetupFor(relativeFile: string): ResolvedSetup;
45
+ /**
46
+ * Merge built-in defaults, project configuration and file `@setup` into the
47
+ * effective setup for one entry.
48
+ *
49
+ * Precedence is defaults < project config < `module: true` suppression < file
50
+ * `@setup` < explicit overrides. The optional `--minify`/`--no-minify` flag is
51
+ * applied last for reporting; the compiler's project API cannot place it above
52
+ * file `@setup`, which the caller reports as a warning when a file authors a
53
+ * conflicting value. `@setup { module: true }` (ADR-0014) removes the default
54
+ * CSS, map and type outputs of a rule-bearing module; authoring one of those
55
+ * keys explicitly restores it.
56
+ */
57
+ export declare function resolveEffectiveSetup(relativeFile: string, config: CliConfig | null, fileSetup: FileSetupValues, minifyFlag: boolean | undefined): ResolvedSetup;
58
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAc,UAAU,EAAkB,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,mFAAmF;IACnF,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO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