@axplusb/kepler 1.0.10 → 2.0.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.
@@ -1,10 +1,16 @@
1
1
  /**
2
- * ANSI Terminal Renderer — zero dependencies, zero flickering.
2
+ * ANSI Terminal Renderer — cursor control, box drawing, status bars.
3
3
  *
4
- * Provides cursor control, colors, box drawing, progress bars,
5
- * in-place updates, and a persistent status bar.
4
+ * Color helpers (the `c` object) now route through the semantic palette
5
+ * (`src/ui/palette.mjs`) so the entire CLI honors the Kepler brand and
6
+ * tier fallbacks (truecolor, ansi256, ansi16, none) without touching
7
+ * each call site. Hot-swap-friendly: external semantics like `c.red`,
8
+ * `c.bold`, `c.cyan` are preserved as the legacy contract; new code
9
+ * should prefer importing `paint` directly.
6
10
  */
7
11
 
12
+ import { paint } from '../ui/palette.mjs';
13
+
8
14
  const ESC = '\x1b[';
9
15
  const write = (s) => process.stderr.write(s);
10
16
 
@@ -27,27 +33,43 @@ export const cursor = {
27
33
  };
28
34
 
29
35
  // ── Colors ──
36
+ // Legacy color names re-mapped onto semantic palette tokens. The CLI's
37
+ // branding is centralized in palette.mjs; this object is preserved only
38
+ // so existing imports keep compiling. Internal Kepler color choices are
39
+ // documented next to each mapping for the next code review.
40
+
41
+ const identity = (s) => String(s ?? '');
30
42
 
31
43
  export const c = {
32
- reset: (s) => `${ESC}0m${s}${ESC}0m`,
33
- bold: (s) => `${ESC}1m${s}${ESC}0m`,
34
- dim: (s) => `${ESC}2m${s}${ESC}0m`,
35
- italic: (s) => `${ESC}3m${s}${ESC}0m`,
36
- underline: (s) => `${ESC}4m${s}${ESC}0m`,
37
- red: (s) => `${ESC}31m${s}${ESC}0m`,
38
- green: (s) => `${ESC}32m${s}${ESC}0m`,
39
- yellow: (s) => `${ESC}33m${s}${ESC}0m`,
40
- blue: (s) => `${ESC}34m${s}${ESC}0m`,
41
- magenta: (s) => `${ESC}35m${s}${ESC}0m`,
42
- brand: (s) => `${ESC}36m${s}${ESC}0m`,
43
- cyan: (s) => `${ESC}94m${s}${ESC}0m`,
44
- cyanRegular: (s) => `${ESC}36m${s}${ESC}0m`,
45
- cyanBold: (s) => `${ESC}1;36m${s}${ESC}0m`,
46
- white: (s) => `${ESC}97m${s}${ESC}0m`,
47
- gray: (s) => `${ESC}90m${s}${ESC}0m`,
48
- bgRed: (s) => `${ESC}41m${s}${ESC}0m`,
49
- bgGreen: (s) => `${ESC}42m${s}${ESC}0m`,
50
- bgCyan: (s) => `${ESC}46m${s}${ESC}0m`,
44
+ reset: identity, // palette already wraps with RESET
45
+
46
+ // Styles — work at every tier
47
+ bold: paint.bold,
48
+ dim: paint.dim,
49
+ italic: paint.italic,
50
+ underline: paint.underline,
51
+
52
+ // State semantics
53
+ red: paint.state.danger, // failure / hard error
54
+ green: paint.state.success, // pass / aligned
55
+ yellow: paint.state.warn, // soft warn / retry
56
+
57
+ // Brand semantics
58
+ blue: paint.brand.primary, // headers, primary brand
59
+ magenta: paint.brand.accent, // attention required
60
+ brand: paint.brand.primary, // primary brand surface
61
+ cyan: paint.brand.data, // code / file paths
62
+ cyanRegular: paint.brand.data,
63
+ cyanBold: (s) => paint.bold(paint.brand.data(s)),
64
+
65
+ // Text semantics
66
+ white: paint.text.primary, // primary text
67
+ gray: paint.text.dim, // hints, metadata, dim text
68
+
69
+ // Backgrounds — kept as raw ANSI; rarely used and have no palette analog
70
+ bgRed: (s) => `${ESC}41m${String(s ?? '')}${ESC}0m`,
71
+ bgGreen: (s) => `${ESC}42m${String(s ?? '')}${ESC}0m`,
72
+ bgCyan: (s) => `${ESC}46m${String(s ?? '')}${ESC}0m`,
51
73
  };
52
74
 
53
75
  // ── Box Drawing ──