@trazum/cli 1.74.0 → 1.76.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.
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The CLI's presentation layer — the 1.75 arc.
3
+ *
4
+ * Six painters, one measurer, one table renderer, one proportion bar, one
5
+ * heading rule. Everything here decorates figures the prose already states;
6
+ * the chapter-four guard strips the paint and asserts nothing was lost and
7
+ * nothing was hiding in it.
8
+ *
9
+ * Colour is on for a TTY unless `NO_COLOR` says otherwise, and on anywhere
10
+ * when `FORCE_COLOR=1` — the door the guard itself walks through, since a
11
+ * test that wants to see what colour does runs under a pipe. A plain pipe
12
+ * stays plain: every `trazum ... | grep` in somebody's script is owed the
13
+ * bytes their script was written against.
14
+ */
15
+ export declare const useColor: boolean;
16
+ export declare const c: {
17
+ bold: (s: string) => string;
18
+ dim: (s: string) => string;
19
+ green: (s: string) => string;
20
+ red: (s: string) => string;
21
+ yellow: (s: string) => string;
22
+ cyan: (s: string) => string;
23
+ };
24
+ /** The report's text column. Headings rule out to it; nothing else needs it. */
25
+ export declare const REPORT_WIDTH = 74;
26
+ /**
27
+ * A string's width as a terminal draws it — the ANSI codes not counted.
28
+ *
29
+ * Every hand-rolled `padStart` in the CLI miscounted the moment a painted
30
+ * cell reached it, which is why nothing painted ever sat in a column. All
31
+ * padding below measures through this.
32
+ */
33
+ export declare function visibleWidth(s: string): number;
34
+ export declare function padCell(s: string, width: number, align: 'left' | 'right'): string;
35
+ export interface TableColumn {
36
+ /** The header cell, already localized. Empty string for a headerless column. */
37
+ header: string;
38
+ align: 'left' | 'right';
39
+ }
40
+ /**
41
+ * The one table renderer, for the eleven layouts that each rebuilt it.
42
+ *
43
+ * Widths come from the content, headers print dimmed, and cells may arrive
44
+ * painted — the measurement ignores the paint. Returns lines; the caller
45
+ * owns the `console.log` and the indent, because some tables live inside a
46
+ * bullet and some at the margin.
47
+ */
48
+ export declare function table(columns: TableColumn[], rows: string[][], indent?: string): string[];
49
+ /**
50
+ * A share the line already states, readable from further away: `███░░░░░░░`.
51
+ *
52
+ * The bar is content, not paint — it prints in a pipe too, so the stripped
53
+ * and plain outputs stay byte-identical. It never carries information the
54
+ * text does not: the percentage beside it is the number, the bar is the
55
+ * glance. Clamped, because a share over 1 is the caller's bug and a bar
56
+ * wider than asked would make it the layout's.
57
+ */
58
+ export declare function bar(share: number, width?: number): string;
59
+ /**
60
+ * A section heading an eye can stop on: the text bold, the line completed
61
+ * with a dim rule out to the report's width.
62
+ *
63
+ * Adónde fue el dinero ─────────────────────────────────────────────
64
+ *
65
+ * The rule is content (it survives the strip); the weight is paint.
66
+ */
67
+ export declare function sectionHeading(text: string, width?: number): string;
68
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,eAAO,MAAM,QAAQ,SAAkF,CAAC;AAExG,eAAO,MAAM,CAAC;IACZ,IAAI,MAAM,MAAM;IAChB,GAAG,MAAM,MAAM;IACf,KAAK,MAAM,MAAM;IACjB,GAAG,MAAM,MAAM;IACf,MAAM,MAAM,MAAM;IAClB,IAAI,MAAM,MAAM;CACjB,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,YAAY,KAAK,CAAC;AAI/B;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAGjF;AAED,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,SAAO,GAAG,MAAM,EAAE,CAiBvF;AAED;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,MAAM,CAIrD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAe,GAAG,MAAM,CAGzE"}
package/dist/style.js ADDED
@@ -0,0 +1,88 @@
1
+ /**
2
+ * The CLI's presentation layer — the 1.75 arc.
3
+ *
4
+ * Six painters, one measurer, one table renderer, one proportion bar, one
5
+ * heading rule. Everything here decorates figures the prose already states;
6
+ * the chapter-four guard strips the paint and asserts nothing was lost and
7
+ * nothing was hiding in it.
8
+ *
9
+ * Colour is on for a TTY unless `NO_COLOR` says otherwise, and on anywhere
10
+ * when `FORCE_COLOR=1` — the door the guard itself walks through, since a
11
+ * test that wants to see what colour does runs under a pipe. A plain pipe
12
+ * stays plain: every `trazum ... | grep` in somebody's script is owed the
13
+ * bytes their script was written against.
14
+ */
15
+ const forced = process.env.FORCE_COLOR === '1';
16
+ export const useColor = forced || (process.stdout.isTTY === true && process.env.NO_COLOR === undefined);
17
+ export const c = {
18
+ bold: (s) => (useColor ? `\u001b[1m${s}\u001b[22m` : s),
19
+ dim: (s) => (useColor ? `\u001b[2m${s}\u001b[22m` : s),
20
+ green: (s) => (useColor ? `\u001b[32m${s}\u001b[39m` : s),
21
+ red: (s) => (useColor ? `\u001b[31m${s}\u001b[39m` : s),
22
+ yellow: (s) => (useColor ? `\u001b[33m${s}\u001b[39m` : s),
23
+ cyan: (s) => (useColor ? `\u001b[36m${s}\u001b[39m` : s),
24
+ };
25
+ /** The report's text column. Headings rule out to it; nothing else needs it. */
26
+ export const REPORT_WIDTH = 74;
27
+ const ANSI = /\u001b\[[0-9;]*m/g;
28
+ /**
29
+ * A string's width as a terminal draws it — the ANSI codes not counted.
30
+ *
31
+ * Every hand-rolled `padStart` in the CLI miscounted the moment a painted
32
+ * cell reached it, which is why nothing painted ever sat in a column. All
33
+ * padding below measures through this.
34
+ */
35
+ export function visibleWidth(s) {
36
+ return s.replace(ANSI, '').length;
37
+ }
38
+ export function padCell(s, width, align) {
39
+ const gap = Math.max(0, width - visibleWidth(s));
40
+ return align === 'right' ? ' '.repeat(gap) + s : s + ' '.repeat(gap);
41
+ }
42
+ /**
43
+ * The one table renderer, for the eleven layouts that each rebuilt it.
44
+ *
45
+ * Widths come from the content, headers print dimmed, and cells may arrive
46
+ * painted — the measurement ignores the paint. Returns lines; the caller
47
+ * owns the `console.log` and the indent, because some tables live inside a
48
+ * bullet and some at the margin.
49
+ */
50
+ export function table(columns, rows, indent = ' ') {
51
+ const widths = columns.map((col, i) => Math.max(visibleWidth(col.header), ...rows.map((row) => visibleWidth(row[i] ?? ''))));
52
+ const lines = [];
53
+ if (columns.some((col) => col.header !== '')) {
54
+ lines.push(indent +
55
+ columns.map((col, i) => padCell(c.dim(col.header), widths[i] ?? 0, col.align)).join(' ').trimEnd());
56
+ }
57
+ for (const row of rows) {
58
+ lines.push(indent + columns.map((col, i) => padCell(row[i] ?? '', widths[i] ?? 0, col.align)).join(' ').trimEnd());
59
+ }
60
+ return lines;
61
+ }
62
+ /**
63
+ * A share the line already states, readable from further away: `███░░░░░░░`.
64
+ *
65
+ * The bar is content, not paint — it prints in a pipe too, so the stripped
66
+ * and plain outputs stay byte-identical. It never carries information the
67
+ * text does not: the percentage beside it is the number, the bar is the
68
+ * glance. Clamped, because a share over 1 is the caller's bug and a bar
69
+ * wider than asked would make it the layout's.
70
+ */
71
+ export function bar(share, width = 10) {
72
+ const clamped = Math.max(0, Math.min(1, share));
73
+ const filled = Math.round(clamped * width);
74
+ return c.cyan('█'.repeat(filled)) + c.dim('░'.repeat(width - filled));
75
+ }
76
+ /**
77
+ * A section heading an eye can stop on: the text bold, the line completed
78
+ * with a dim rule out to the report's width.
79
+ *
80
+ * Adónde fue el dinero ─────────────────────────────────────────────
81
+ *
82
+ * The rule is content (it survives the strip); the weight is paint.
83
+ */
84
+ export function sectionHeading(text, width = REPORT_WIDTH) {
85
+ const room = Math.max(0, width - visibleWidth(text) - 1);
86
+ return `${c.bold(text)} ${c.dim('─'.repeat(room))}`.trimEnd();
87
+ }
88
+ //# sourceMappingURL=style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.js","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG,CAAC;AAC/C,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;AAExG,MAAM,CAAC,MAAM,CAAC,GAAG;IACf,IAAI,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,GAAG,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,KAAK,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,GAAG,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAA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MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,KAAK,GAAG,YAAY;IAC/D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACzD,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;AAChE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trazum/cli",
3
- "version": "1.74.0",
3
+ "version": "1.76.0",
4
4
  "description": "Trazum CLI: find where your LLM bill goes, price every finding per month, and enforce token budgets in CI.",
5
5
  "license": "MIT",
6
6
  "author": "David Mu\u00f1oz Rey",
@@ -37,7 +37,7 @@
37
37
  "prepublishOnly": "npm run build && npm test"
38
38
  },
39
39
  "dependencies": {
40
- "@trazum/core": "1.74.0"
40
+ "@trazum/core": "1.76.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^26.2.0",