@statusline/core 0.0.0-stage → 1.0.1

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 (102) hide show
  1. package/README.md +70 -2
  2. package/dist/colors.d.ts +136 -0
  3. package/dist/colors.d.ts.map +1 -0
  4. package/dist/colors.js +107 -0
  5. package/dist/colors.js.map +1 -0
  6. package/dist/config.d.ts +34 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +136 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/format.d.ts +21 -0
  11. package/dist/format.d.ts.map +1 -0
  12. package/dist/format.js +38 -0
  13. package/dist/format.js.map +1 -0
  14. package/dist/index.d.ts +21 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +28 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/layout.d.ts +33 -0
  19. package/dist/layout.d.ts.map +1 -0
  20. package/dist/layout.js +303 -0
  21. package/dist/layout.js.map +1 -0
  22. package/dist/model.d.ts +164 -0
  23. package/dist/model.d.ts.map +1 -0
  24. package/dist/model.js +31 -0
  25. package/dist/model.js.map +1 -0
  26. package/dist/priority.d.ts +65 -0
  27. package/dist/priority.d.ts.map +1 -0
  28. package/dist/priority.js +120 -0
  29. package/dist/priority.js.map +1 -0
  30. package/dist/renderer.d.ts +46 -0
  31. package/dist/renderer.d.ts.map +1 -0
  32. package/dist/renderer.js +69 -0
  33. package/dist/renderer.js.map +1 -0
  34. package/dist/renderers/cli.d.ts +29 -0
  35. package/dist/renderers/cli.d.ts.map +1 -0
  36. package/dist/renderers/cli.js +61 -0
  37. package/dist/renderers/cli.js.map +1 -0
  38. package/dist/renderers/index.d.ts +22 -0
  39. package/dist/renderers/index.d.ts.map +1 -0
  40. package/dist/renderers/index.js +50 -0
  41. package/dist/renderers/index.js.map +1 -0
  42. package/dist/renderers/neovim.d.ts +39 -0
  43. package/dist/renderers/neovim.d.ts.map +1 -0
  44. package/dist/renderers/neovim.js +101 -0
  45. package/dist/renderers/neovim.js.map +1 -0
  46. package/dist/renderers/opencode.d.ts +30 -0
  47. package/dist/renderers/opencode.d.ts.map +1 -0
  48. package/dist/renderers/opencode.js +115 -0
  49. package/dist/renderers/opencode.js.map +1 -0
  50. package/dist/renderers/vscode.d.ts +36 -0
  51. package/dist/renderers/vscode.d.ts.map +1 -0
  52. package/dist/renderers/vscode.js +94 -0
  53. package/dist/renderers/vscode.js.map +1 -0
  54. package/dist/sections/cache.d.ts +12 -0
  55. package/dist/sections/cache.d.ts.map +1 -0
  56. package/dist/sections/cache.js +114 -0
  57. package/dist/sections/cache.js.map +1 -0
  58. package/dist/sections/context.d.ts +12 -0
  59. package/dist/sections/context.d.ts.map +1 -0
  60. package/dist/sections/context.js +84 -0
  61. package/dist/sections/context.js.map +1 -0
  62. package/dist/sections/cost.d.ts +12 -0
  63. package/dist/sections/cost.d.ts.map +1 -0
  64. package/dist/sections/cost.js +57 -0
  65. package/dist/sections/cost.js.map +1 -0
  66. package/dist/sections/cursor-extensions.d.ts +12 -0
  67. package/dist/sections/cursor-extensions.d.ts.map +1 -0
  68. package/dist/sections/cursor-extensions.js +65 -0
  69. package/dist/sections/cursor-extensions.js.map +1 -0
  70. package/dist/sections/index.d.ts +27 -0
  71. package/dist/sections/index.d.ts.map +1 -0
  72. package/dist/sections/index.js +163 -0
  73. package/dist/sections/index.js.map +1 -0
  74. package/dist/sections/model.d.ts +12 -0
  75. package/dist/sections/model.d.ts.map +1 -0
  76. package/dist/sections/model.js +151 -0
  77. package/dist/sections/model.js.map +1 -0
  78. package/dist/sections/overhead.d.ts +12 -0
  79. package/dist/sections/overhead.d.ts.map +1 -0
  80. package/dist/sections/overhead.js +138 -0
  81. package/dist/sections/overhead.js.map +1 -0
  82. package/dist/sections/rate-limits.d.ts +12 -0
  83. package/dist/sections/rate-limits.d.ts.map +1 -0
  84. package/dist/sections/rate-limits.js +116 -0
  85. package/dist/sections/rate-limits.js.map +1 -0
  86. package/dist/sections/usage.d.ts +12 -0
  87. package/dist/sections/usage.d.ts.map +1 -0
  88. package/dist/sections/usage.js +62 -0
  89. package/dist/sections/usage.js.map +1 -0
  90. package/dist/sections/vim.d.ts +12 -0
  91. package/dist/sections/vim.d.ts.map +1 -0
  92. package/dist/sections/vim.js +41 -0
  93. package/dist/sections/vim.js.map +1 -0
  94. package/dist/sections/worktree.d.ts +12 -0
  95. package/dist/sections/worktree.d.ts.map +1 -0
  96. package/dist/sections/worktree.js +41 -0
  97. package/dist/sections/worktree.js.map +1 -0
  98. package/dist/width.d.ts +24 -0
  99. package/dist/width.d.ts.map +1 -0
  100. package/dist/width.js +115 -0
  101. package/dist/width.js.map +1 -0
  102. package/package.json +50 -4
package/README.md CHANGED
@@ -1,3 +1,71 @@
1
- # Temporary Holding Version
1
+ # @statusline/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Core library for section-priority-based status line rendering.
4
+
5
+ ## Overview
6
+
7
+ This package provides the foundational building blocks for rendering rich, adaptive status lines across different coding agents (Claude Code, Cursor, OpenCode).
8
+
9
+ ## Features
10
+
11
+ - **Section-priority pipeline**: Sections declare priority levels; layout engine drops lowest-priority items first on narrow terminals
12
+ - **Unicode-aware width calculation**: Correctly handles CJK characters, emoji, and combining marks
13
+ - **Multiple renderers**: CLI (ANSI), VS Code, Neovim, OpenCode TUI
14
+ - **Zero runtime dependencies**: Pure TypeScript, compiled to ESM
15
+ - **Configurable sections**: Model, context, cost, cache, rate limits, tokens, worktree, vim mode
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install @statusline/core
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```typescript
26
+ import { getSections, buildLayout, cliRenderer } from '@statusline/core';
27
+
28
+ const sections = getSections(input);
29
+ const layout = buildLayout(sections, { width: 120 });
30
+ const output = cliRenderer(layout);
31
+ ```
32
+
33
+ ## Sections
34
+
35
+ | Section | Description |
36
+ |---------|-------------|
37
+ | `model` | Model name, price multiplier, effort level |
38
+ | `context` | Context window usage bar + percentage |
39
+ | `cost` | Session cost, next request cost, compaction cost, restart thresholds |
40
+ | `cache` | Prompt cache timer + hit rate |
41
+ | `resets` | Rate-limit reset windows |
42
+ | `tokens` | Total session tokens |
43
+ | `worktree` | Git branch / worktree info |
44
+ | `vim` | Vim mode indicator |
45
+
46
+ ## Architecture
47
+
48
+ ```
49
+ getSections(input) → Section[]
50
+ │
51
+ ├── modelSection()
52
+ ├── contextSection()
53
+ ├── costSection() (overhead + cost)
54
+ ├── cacheSection()
55
+ ├── resetsSection()
56
+ ├── tokensSection()
57
+ ├── worktreeSection()
58
+ └── vimSection()
59
+
60
+ buildLayout(sections, options) → Layout
61
+ │
62
+ ├── regroup() — merges sections into priority groups
63
+ ├── measure() — calculates display width per item
64
+ └── dropLowPriority() — strict priority-based truncation
65
+
66
+ cliRenderer(layout) → ANSI string
67
+ ```
68
+
69
+ ## License
70
+
71
+ MIT
@@ -0,0 +1,136 @@
1
+ /**
2
+ * ANSI color scheme for CLI renderer.
3
+ * Extended from src/shared/colors.ts
4
+ */
5
+ export declare const RESET = "\u001B[0m";
6
+ export declare const BOLD = "\u001B[1m";
7
+ export declare const DIM = "\u001B[2m";
8
+ export declare const ITALIC = "\u001B[3m";
9
+ export declare const UNDERLINE = "\u001B[4m";
10
+ export declare const BLACK = "\u001B[30m";
11
+ export declare const RED = "\u001B[31m";
12
+ export declare const GREEN = "\u001B[32m";
13
+ export declare const YELLOW = "\u001B[33m";
14
+ export declare const BLUE = "\u001B[34m";
15
+ export declare const MAGENTA = "\u001B[35m";
16
+ export declare const CYAN = "\u001B[36m";
17
+ export declare const WHITE = "\u001B[37m";
18
+ export declare const GRAY = "\u001B[90m";
19
+ export declare const BRIGHT_BLACK = "\u001B[90m";
20
+ export declare const BRIGHT_RED = "\u001B[91m";
21
+ export declare const BRIGHT_GREEN = "\u001B[92m";
22
+ export declare const BRIGHT_YELLOW = "\u001B[93m";
23
+ export declare const BRIGHT_BLUE = "\u001B[94m";
24
+ export declare const BRIGHT_MAGENTA = "\u001B[95m";
25
+ export declare const BRIGHT_CYAN = "\u001B[96m";
26
+ export declare const BRIGHT_WHITE = "\u001B[97m";
27
+ /** Apply color to text */
28
+ export declare function colorize(text: string, color: string): string;
29
+ /** Style functions */
30
+ export declare const style: {
31
+ reset: (text: string) => string;
32
+ bold: (text: string) => string;
33
+ dim: (text: string) => string;
34
+ italic: (text: string) => string;
35
+ underline: (text: string) => string;
36
+ black: (text: string) => string;
37
+ red: (text: string) => string;
38
+ green: (text: string) => string;
39
+ yellow: (text: string) => string;
40
+ blue: (text: string) => string;
41
+ magenta: (text: string) => string;
42
+ cyan: (text: string) => string;
43
+ white: (text: string) => string;
44
+ gray: (text: string) => string;
45
+ brightRed: (text: string) => string;
46
+ brightGreen: (text: string) => string;
47
+ brightYellow: (text: string) => string;
48
+ brightBlue: (text: string) => string;
49
+ brightMagenta: (text: string) => string;
50
+ brightCyan: (text: string) => string;
51
+ brightWhite: (text: string) => string;
52
+ };
53
+ /** Color scheme for sections */
54
+ export declare const sectionColors: {
55
+ readonly model: (text: string) => string;
56
+ readonly context: (text: string) => string;
57
+ readonly cost: (text: string) => string;
58
+ readonly cache: (text: string) => string;
59
+ readonly "rate-limits": (text: string) => string;
60
+ readonly usage: (text: string) => string;
61
+ readonly vim: (text: string) => string;
62
+ readonly worktree: (text: string) => string;
63
+ readonly "cursor-extensions": (text: string) => string;
64
+ };
65
+ /** Color scheme for priority levels */
66
+ export declare const priorityColors: {
67
+ readonly critical: (text: string) => string;
68
+ readonly high: (text: string) => string;
69
+ readonly medium: (text: string) => string;
70
+ readonly low: (text: string) => string;
71
+ readonly none: (text: string) => string;
72
+ };
73
+ /** Default color scheme object */
74
+ export declare const colors: {
75
+ readonly sectionColors: {
76
+ readonly model: (text: string) => string;
77
+ readonly context: (text: string) => string;
78
+ readonly cost: (text: string) => string;
79
+ readonly cache: (text: string) => string;
80
+ readonly "rate-limits": (text: string) => string;
81
+ readonly usage: (text: string) => string;
82
+ readonly vim: (text: string) => string;
83
+ readonly worktree: (text: string) => string;
84
+ readonly "cursor-extensions": (text: string) => string;
85
+ };
86
+ readonly priorityColors: {
87
+ readonly critical: (text: string) => string;
88
+ readonly high: (text: string) => string;
89
+ readonly medium: (text: string) => string;
90
+ readonly low: (text: string) => string;
91
+ readonly none: (text: string) => string;
92
+ };
93
+ readonly reset: (text: string) => string;
94
+ readonly bold: (text: string) => string;
95
+ readonly dim: (text: string) => string;
96
+ readonly italic: (text: string) => string;
97
+ readonly underline: (text: string) => string;
98
+ readonly black: (text: string) => string;
99
+ readonly red: (text: string) => string;
100
+ readonly green: (text: string) => string;
101
+ readonly yellow: (text: string) => string;
102
+ readonly blue: (text: string) => string;
103
+ readonly magenta: (text: string) => string;
104
+ readonly cyan: (text: string) => string;
105
+ readonly white: (text: string) => string;
106
+ readonly gray: (text: string) => string;
107
+ readonly brightRed: (text: string) => string;
108
+ readonly brightGreen: (text: string) => string;
109
+ readonly brightYellow: (text: string) => string;
110
+ readonly brightBlue: (text: string) => string;
111
+ readonly brightMagenta: (text: string) => string;
112
+ readonly brightCyan: (text: string) => string;
113
+ readonly brightWhite: (text: string) => string;
114
+ readonly RESET: "\u001B[0m";
115
+ readonly BOLD: "\u001B[1m";
116
+ readonly DIM: "\u001B[2m";
117
+ readonly BLACK: "\u001B[30m";
118
+ readonly RED: "\u001B[31m";
119
+ readonly GREEN: "\u001B[32m";
120
+ readonly YELLOW: "\u001B[33m";
121
+ readonly BLUE: "\u001B[34m";
122
+ readonly MAGENTA: "\u001B[35m";
123
+ readonly CYAN: "\u001B[36m";
124
+ readonly WHITE: "\u001B[37m";
125
+ readonly GRAY: "\u001B[90m";
126
+ readonly BRIGHT_BLACK: "\u001B[90m";
127
+ readonly BRIGHT_RED: "\u001B[91m";
128
+ readonly BRIGHT_GREEN: "\u001B[92m";
129
+ readonly BRIGHT_YELLOW: "\u001B[93m";
130
+ readonly BRIGHT_BLUE: "\u001B[94m";
131
+ readonly BRIGHT_MAGENTA: "\u001B[95m";
132
+ readonly BRIGHT_CYAN: "\u001B[96m";
133
+ readonly BRIGHT_WHITE: "\u001B[97m";
134
+ readonly colorize: typeof colorize;
135
+ };
136
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,KAAK,cAAY,CAAC;AAC/B,eAAO,MAAM,IAAI,cAAY,CAAC;AAC9B,eAAO,MAAM,GAAG,cAAY,CAAC;AAC7B,eAAO,MAAM,MAAM,cAAY,CAAC;AAChC,eAAO,MAAM,SAAS,cAAY,CAAC;AAGnC,eAAO,MAAM,KAAK,eAAa,CAAC;AAChC,eAAO,MAAM,GAAG,eAAa,CAAC;AAC9B,eAAO,MAAM,KAAK,eAAa,CAAC;AAChC,eAAO,MAAM,MAAM,eAAa,CAAC;AACjC,eAAO,MAAM,IAAI,eAAa,CAAC;AAC/B,eAAO,MAAM,OAAO,eAAa,CAAC;AAClC,eAAO,MAAM,IAAI,eAAa,CAAC;AAC/B,eAAO,MAAM,KAAK,eAAa,CAAC;AAChC,eAAO,MAAM,IAAI,eAAa,CAAC;AAG/B,eAAO,MAAM,YAAY,eAAa,CAAC;AACvC,eAAO,MAAM,UAAU,eAAa,CAAC;AACrC,eAAO,MAAM,YAAY,eAAa,CAAC;AACvC,eAAO,MAAM,aAAa,eAAa,CAAC;AACxC,eAAO,MAAM,WAAW,eAAa,CAAC;AACtC,eAAO,MAAM,cAAc,eAAa,CAAC;AACzC,eAAO,MAAM,WAAW,eAAa,CAAC;AACtC,eAAO,MAAM,YAAY,eAAa,CAAC;AAEvC,0BAA0B;AAC1B,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,sBAAsB;AACtB,eAAO,MAAM,KAAK;kBACF,MAAM;iBACP,MAAM;gBACP,MAAM;mBACH,MAAM;sBACH,MAAM;kBAGV,MAAM;gBACR,MAAM;kBACJ,MAAM;mBACL,MAAM;iBACR,MAAM;oBACH,MAAM;iBACT,MAAM;kBACL,MAAM;iBACP,MAAM;sBAGD,MAAM;wBACJ,MAAM;yBACL,MAAM;uBACR,MAAM;0BACH,MAAM;uBACT,MAAM;wBACL,MAAM;CAC3B,CAAC;AAEF,gCAAgC;AAChC,eAAO,MAAM,aAAa;2BAfX,MAAM;6BAJL,MAAM;0BACL,MAAM;2BACR,MAAM;mCACH,MAAM;2BAER,MAAM;yBACP,MAAM;8BAAN,MAAM;yCAAN,MAAM;CAuBX,CAAC;AAEX,uCAAuC;AACvC,eAAO,MAAM,cAAc;8BAxCZ,MAAM;0BAaL,MAAM;4BACP,MAAM;yBAbP,MAAM;0BAAN,MAAM;CA6CV,CAAC;AAEX,kCAAkC;AAClC,eAAO,MAAM,MAAM;;+BArCJ,MAAM;iCAJL,MAAM;8BACL,MAAM;+BACR,MAAM;uCACH,MAAM;+BAER,MAAM;6BACP,MAAM;kCAAN,MAAM;6CAAN,MAAM;;;kCAdN,MAAM;8BAaL,MAAM;gCACP,MAAM;6BAbP,MAAM;8BAAN,MAAM;;2BAFJ,MAAM;0BACP,MAAM;yBACP,MAAM;4BACH,MAAM;+BACH,MAAM;2BAGV,MAAM;yBACR,MAAM;2BACJ,MAAM;4BACL,MAAM;0BACR,MAAM;6BACH,MAAM;0BACT,MAAM;2BACL,MAAM;0BACP,MAAM;+BAGD,MAAM;iCACJ,MAAM;kCACL,MAAM;gCACR,MAAM;mCACH,MAAM;gCACT,MAAM;iCACL,MAAM;;;;;;;;;;;;;;;;;;;;;;CAmDlB,CAAC"}
package/dist/colors.js ADDED
@@ -0,0 +1,107 @@
1
+ /**
2
+ * ANSI color scheme for CLI renderer.
3
+ * Extended from src/shared/colors.ts
4
+ */
5
+ // ANSI color codes
6
+ export const RESET = "\x1b[0m";
7
+ export const BOLD = "\x1b[1m";
8
+ export const DIM = "\x1b[2m";
9
+ export const ITALIC = "\x1b[3m";
10
+ export const UNDERLINE = "\x1b[4m";
11
+ // Foreground colors
12
+ export const BLACK = "\x1b[30m";
13
+ export const RED = "\x1b[31m";
14
+ export const GREEN = "\x1b[32m";
15
+ export const YELLOW = "\x1b[33m";
16
+ export const BLUE = "\x1b[34m";
17
+ export const MAGENTA = "\x1b[35m";
18
+ export const CYAN = "\x1b[36m";
19
+ export const WHITE = "\x1b[37m";
20
+ export const GRAY = "\x1b[90m";
21
+ // Bright foreground colors
22
+ export const BRIGHT_BLACK = "\x1b[90m";
23
+ export const BRIGHT_RED = "\x1b[91m";
24
+ export const BRIGHT_GREEN = "\x1b[92m";
25
+ export const BRIGHT_YELLOW = "\x1b[93m";
26
+ export const BRIGHT_BLUE = "\x1b[94m";
27
+ export const BRIGHT_MAGENTA = "\x1b[95m";
28
+ export const BRIGHT_CYAN = "\x1b[96m";
29
+ export const BRIGHT_WHITE = "\x1b[97m";
30
+ /** Apply color to text */
31
+ export function colorize(text, color) {
32
+ return `${color}${text}${RESET}`;
33
+ }
34
+ /** Style functions */
35
+ export const style = {
36
+ reset: (text) => `${RESET}${text}${RESET}`,
37
+ bold: (text) => `${BOLD}${text}${RESET}`,
38
+ dim: (text) => `${DIM}${text}${RESET}`,
39
+ italic: (text) => `${ITALIC}${text}${RESET}`,
40
+ underline: (text) => `${UNDERLINE}${text}${RESET}`,
41
+ // Colors
42
+ black: (text) => colorize(text, BLACK),
43
+ red: (text) => colorize(text, RED),
44
+ green: (text) => colorize(text, GREEN),
45
+ yellow: (text) => colorize(text, YELLOW),
46
+ blue: (text) => colorize(text, BLUE),
47
+ magenta: (text) => colorize(text, MAGENTA),
48
+ cyan: (text) => colorize(text, CYAN),
49
+ white: (text) => colorize(text, WHITE),
50
+ gray: (text) => colorize(text, GRAY),
51
+ // Bright colors
52
+ brightRed: (text) => colorize(text, BRIGHT_RED),
53
+ brightGreen: (text) => colorize(text, BRIGHT_GREEN),
54
+ brightYellow: (text) => colorize(text, BRIGHT_YELLOW),
55
+ brightBlue: (text) => colorize(text, BRIGHT_BLUE),
56
+ brightMagenta: (text) => colorize(text, BRIGHT_MAGENTA),
57
+ brightCyan: (text) => colorize(text, BRIGHT_CYAN),
58
+ brightWhite: (text) => colorize(text, BRIGHT_WHITE),
59
+ };
60
+ /** Color scheme for sections */
61
+ export const sectionColors = {
62
+ model: style.cyan,
63
+ context: style.green,
64
+ cost: style.yellow,
65
+ cache: style.blue,
66
+ "rate-limits": style.magenta,
67
+ usage: style.white,
68
+ vim: style.gray,
69
+ worktree: style.gray,
70
+ "cursor-extensions": style.gray,
71
+ };
72
+ /** Color scheme for priority levels */
73
+ export const priorityColors = {
74
+ critical: style.bold,
75
+ high: style.white,
76
+ medium: style.gray,
77
+ low: style.dim,
78
+ none: style.dim,
79
+ };
80
+ /** Default color scheme object */
81
+ export const colors = {
82
+ RESET,
83
+ BOLD,
84
+ DIM,
85
+ BLACK,
86
+ RED,
87
+ GREEN,
88
+ YELLOW,
89
+ BLUE,
90
+ MAGENTA,
91
+ CYAN,
92
+ WHITE,
93
+ GRAY,
94
+ BRIGHT_BLACK,
95
+ BRIGHT_RED,
96
+ BRIGHT_GREEN,
97
+ BRIGHT_YELLOW,
98
+ BRIGHT_BLUE,
99
+ BRIGHT_MAGENTA,
100
+ BRIGHT_CYAN,
101
+ BRIGHT_WHITE,
102
+ colorize,
103
+ ...style,
104
+ sectionColors,
105
+ priorityColors,
106
+ };
107
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.js","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,mBAAmB;AACnB,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAG,SAAS,CAAC;AAC9B,MAAM,CAAC,MAAM,GAAG,GAAG,SAAS,CAAC;AAC7B,MAAM,CAAC,MAAM,MAAM,GAAG,SA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KAAK;IACL,GAAG;IACH,KAAK;IACL,MAAM;IACN,IAAI;IACJ,OAAO;IACP,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,YAAY;IACZ,UAAU;IACV,YAAY;IACZ,aAAa;IACb,WAAW;IACX,cAAc;IACd,WAAW;IACX,YAAY;IACZ,QAAQ;IACR,GAAG,KAAK;IACR,aAAa;IACb,cAAc;CACN,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Configuration system for section-priority-based rendering.
3
+ * Handles user config overrides for sections and items.
4
+ */
5
+ import type { Section, UserConfig, Priority } from "./model.js";
6
+ /**
7
+ * Apply user configuration to base sections.
8
+ * Returns new sections array with config applied.
9
+ */
10
+ export declare function applyConfig(baseSections: Section[], config: UserConfig): Section[];
11
+ /**
12
+ * Merge user config with defaults.
13
+ */
14
+ export declare function mergeConfig(userConfig: Partial<UserConfig>): UserConfig;
15
+ /**
16
+ * Validate user config.
17
+ * Returns array of validation errors (empty if valid).
18
+ */
19
+ export declare function validateConfig(config: UserConfig): string[];
20
+ /**
21
+ * Get default config schema for documentation/UI generation.
22
+ */
23
+ export declare function getConfigSchema(): {
24
+ sections: Record<string, {
25
+ priority: Priority;
26
+ minItems?: number;
27
+ }>;
28
+ items: Record<string, {
29
+ priority: Priority;
30
+ minWidth?: number;
31
+ }>;
32
+ };
33
+ export { DEFAULT_CONFIG } from "./model.js";
34
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAA6B,QAAQ,EAAe,MAAM,YAAY,CAAC;AAIxG;;;GAGG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,EAAE,CA0DlF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAavE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE,CA2C3D;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI;IACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClE,CAKA;AAGD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Configuration system for section-priority-based rendering.
3
+ * Handles user config overrides for sections and items.
4
+ */
5
+ import { parsePriority, PriorityLevel as P } from "./priority.js";
6
+ import { DEFAULT_CONFIG } from "./model.js";
7
+ /**
8
+ * Apply user configuration to base sections.
9
+ * Returns new sections array with config applied.
10
+ */
11
+ export function applyConfig(baseSections, config) {
12
+ const result = [];
13
+ for (const baseSection of baseSections) {
14
+ const sectionConfig = config.sections?.[baseSection.id];
15
+ // Check if section is disabled
16
+ if (sectionConfig?.enabled === false)
17
+ continue;
18
+ // Create section with config overrides
19
+ let section = { ...baseSection };
20
+ // Apply section-level config
21
+ if (sectionConfig) {
22
+ if (sectionConfig.priority !== undefined) {
23
+ section = { ...section, priority: parsePriority(sectionConfig.priority) };
24
+ }
25
+ if (sectionConfig.minItems !== undefined) {
26
+ section = { ...section, minItems: sectionConfig.minItems };
27
+ }
28
+ }
29
+ // Apply item-level config
30
+ const itemsConfig = config.items ?? {};
31
+ section = {
32
+ ...section,
33
+ items: section.items.map((item) => {
34
+ // Config key can be "sectionId.itemId" or just "itemId"
35
+ const itemConfig = itemsConfig[`${section.id}.${item.id}`] ?? itemsConfig[item.id];
36
+ if (!itemConfig)
37
+ return item;
38
+ // Check if item is disabled
39
+ if (itemConfig.enabled === false)
40
+ return null;
41
+ const overrides = {};
42
+ if (itemConfig.priority !== undefined)
43
+ overrides.priority = parsePriority(itemConfig.priority);
44
+ if (itemConfig.minWidth !== undefined)
45
+ overrides.minWidth = itemConfig.minWidth;
46
+ return { ...item, ...overrides };
47
+ }).filter((item) => item !== null),
48
+ };
49
+ // Apply global priority threshold
50
+ if (config.priorityThreshold !== undefined) {
51
+ const threshold = parsePriority(config.priorityThreshold);
52
+ section = {
53
+ ...section,
54
+ items: section.items.filter((item) => item.priority >= threshold),
55
+ };
56
+ }
57
+ // Skip sections with no visible items
58
+ if (section.items.length === 0)
59
+ continue;
60
+ result.push(section);
61
+ }
62
+ return result;
63
+ }
64
+ /**
65
+ * Merge user config with defaults.
66
+ */
67
+ export function mergeConfig(userConfig) {
68
+ return {
69
+ ...DEFAULT_CONFIG,
70
+ ...userConfig,
71
+ sections: {
72
+ ...DEFAULT_CONFIG.sections,
73
+ ...userConfig.sections,
74
+ },
75
+ items: {
76
+ ...DEFAULT_CONFIG.items,
77
+ ...userConfig.items,
78
+ },
79
+ };
80
+ }
81
+ /**
82
+ * Validate user config.
83
+ * Returns array of validation errors (empty if valid).
84
+ */
85
+ export function validateConfig(config) {
86
+ const errors = [];
87
+ // Validate section configs
88
+ if (config.sections) {
89
+ for (const [sectionId, sectionConfig] of Object.entries(config.sections)) {
90
+ if (sectionConfig.priority !== undefined) {
91
+ // Check raw value before parsing
92
+ const raw = sectionConfig.priority;
93
+ if (typeof raw === "number" && (raw < 0 || raw > 100)) {
94
+ errors.push(`Section "${sectionId}": priority must be 0-100`);
95
+ }
96
+ }
97
+ if (sectionConfig.minItems !== undefined && sectionConfig.minItems < 0) {
98
+ errors.push(`Section "${sectionId}": minItems must be >= 0`);
99
+ }
100
+ }
101
+ }
102
+ // Validate item configs
103
+ if (config.items) {
104
+ for (const [itemKey, itemConfig] of Object.entries(config.items)) {
105
+ if (itemConfig.priority !== undefined) {
106
+ const raw = itemConfig.priority;
107
+ if (typeof raw === "number" && (raw < 0 || raw > 100)) {
108
+ errors.push(`Item "${itemKey}": priority must be 0-100`);
109
+ }
110
+ }
111
+ if (itemConfig.minWidth !== undefined && itemConfig.minWidth < 0) {
112
+ errors.push(`Item "${itemKey}": minWidth must be >= 0`);
113
+ }
114
+ }
115
+ }
116
+ // Validate global priority threshold
117
+ if (config.priorityThreshold !== undefined) {
118
+ const raw = config.priorityThreshold;
119
+ if (typeof raw === "number" && (raw < 0 || raw > 100)) {
120
+ errors.push(`priorityThreshold must be 0-100`);
121
+ }
122
+ }
123
+ return errors;
124
+ }
125
+ /**
126
+ * Get default config schema for documentation/UI generation.
127
+ */
128
+ export function getConfigSchema() {
129
+ return {
130
+ sections: {},
131
+ items: {},
132
+ };
133
+ }
134
+ // Re-export DEFAULT_CONFIG from model
135
+ export { DEFAULT_CONFIG } from "./model.js";
136
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,aAAa,IAAI,CAAC,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,YAAuB,EAAE,MAAkB;IACrE,MAAM,MAAM,GAAc,EAAE,CAAC;IAE7B,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAExD,+BAA+B;QAC/B,IAAI,aAAa,EAAE,OAAO,KAAK,KAAK;YAAE,SAAS;QAE/C,uCAAuC;QACvC,IAAI,OAAO,GAAY,EAAE,GAAG,WAAW,EAAE,CAAC;QAE1C,6BAA6B;QAC7B,IA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GAAG,GAAG,GAAG,CAAC,EAAE,CAAC;YACtD,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAI7B,OAAO;QACL,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,EAAE;KACV,CAAC;AACJ,CAAC;AAED,sCAAsC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Per-item text style. Three levels, most readable first:
3
+ * words "next call 3.6¢" short "next 3.6¢" glyph "⚡3.6¢" ascii "nx 3.6c" (plain ASCII, never auto-picked by width)
4
+ * Resolution: formats["section.item"] > formats["section"] > format (unless "auto")
5
+ * > the level the layout picked for the current width (ctx.formatLevel) > "glyph".
6
+ */
7
+ import type { RenderContext } from "./model.js";
8
+ export type ItemFormat = "words" | "short" | "glyph" | "ascii";
9
+ /** Most readable first: the layout tries these in order and keeps the first that fits. */
10
+ export declare const FORMAT_LEVELS: ItemFormat[];
11
+ export declare function itemFormat(ctx: RenderContext, section: string, item: string): ItemFormat;
12
+ /** Parse "section.item=words,section=glyph" into a formats map; ignores malformed entries. */
13
+ export declare function parseFormats(value: string | undefined): Record<string, ItemFormat>;
14
+ /** Plain-ASCII form of a cost string. */
15
+ export declare const asciiCost: (s: string) => string;
16
+ /**
17
+ * Whether the environment can show non-ASCII symbols. False for a non-UTF-8 locale or a
18
+ * bare console (TERM=linux/dumb). Says nothing about missing glyphs in a font; the wizard asks.
19
+ */
20
+ export declare function unicodeOk(env?: NodeJS.ProcessEnv, platform?: string): boolean;
21
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAC/D,0FAA0F;AAC1F,eAAO,MAAM,aAAa,EAAE,UAAU,EAAgC,CAAC;AAEvE,wBAAgB,UAAU,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAIxF;AAED,8FAA8F;AAC9F,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAOlF;AAED,yCAAyC;AACzC,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,KAAG,MAA8B,CAAC;AAErE;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,EAAE,QAAQ,GAAE,MAAyB,GAAG,OAAO,CAK5G"}
package/dist/format.js ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Per-item text style. Three levels, most readable first:
3
+ * words "next call 3.6¢" short "next 3.6¢" glyph "⚡3.6¢" ascii "nx 3.6c" (plain ASCII, never auto-picked by width)
4
+ * Resolution: formats["section.item"] > formats["section"] > format (unless "auto")
5
+ * > the level the layout picked for the current width (ctx.formatLevel) > "glyph".
6
+ */
7
+ /** Most readable first: the layout tries these in order and keeps the first that fits. */
8
+ export const FORMAT_LEVELS = ["words", "short", "glyph"];
9
+ export function itemFormat(ctx, section, item) {
10
+ const c = ctx?.config;
11
+ const forced = c?.formats?.[`${section}.${item}`] ?? c?.formats?.[section] ?? (c?.format && c.format !== "auto" ? c.format : undefined);
12
+ return forced ?? ctx?.formatLevel ?? "glyph";
13
+ }
14
+ /** Parse "section.item=words,section=glyph" into a formats map; ignores malformed entries. */
15
+ export function parseFormats(value) {
16
+ const out = {};
17
+ for (const part of (value ?? "").split(",")) {
18
+ const [k, v] = part.split("=").map((x) => x.trim());
19
+ if (k && (v === "words" || v === "short" || v === "glyph" || v === "ascii"))
20
+ out[k] = v;
21
+ }
22
+ return out;
23
+ }
24
+ /** Plain-ASCII form of a cost string. */
25
+ export const asciiCost = (s) => s.replace(/¢/g, "c");
26
+ /**
27
+ * Whether the environment can show non-ASCII symbols. False for a non-UTF-8 locale or a
28
+ * bare console (TERM=linux/dumb). Says nothing about missing glyphs in a font; the wizard asks.
29
+ */
30
+ export function unicodeOk(env = process.env, platform = process.platform) {
31
+ if (env.TERM === "linux" || env.TERM === "dumb")
32
+ return false;
33
+ if (platform === "win32")
34
+ return true;
35
+ const loc = env.LC_ALL || env.LC_CTYPE || env.LANG;
36
+ return !loc || /utf-?8/i.test(loc) || loc === "C.UTF-8";
37
+ }
38
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,aAAa,GAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAEvE,MAAM,UAAU,UAAU,CAAC,GAAkB,EAAE,OAAe,EAAE,IAAY;IAC1E,MAAM,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC;IACtB,MAAM,MAAM,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACxI,OAAO,MAAM,IAAI,GAAG,EAAE,WAAW,IAAI,OAAO,CAAC;AAC/C,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,YAAY,CAAC,KAAyB;IACpD,MAAM,GAAG,GAA+B,EAAE,CAAC;IAC3C,KAAK,MAAM,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5C,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,OAAO,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,yCAAyC;AACzC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAErE;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAAyB,OAAO,CAAC,GAAG,EAAE,WAAmB,OAAO,CAAC,QAAQ;IACjG,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAC9D,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC;IACnD,OAAO,CAAC,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,SAAS,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @statusline/core - Core library for section-priority-based status line rendering.
3
+ *
4
+ * This package provides:
5
+ * - Type definitions for sections, items, and priorities
6
+ * - Priority constants and helpers
7
+ * - Built-in sections for common status line elements
8
+ * - Layout engine with priority-based shrinking
9
+ * - Renderer interface and implementations (CLI, VS Code, Neovim, OpenCode)
10
+ * - Configuration system for user customization
11
+ */
12
+ export * from "./model.js";
13
+ export * from "./priority.js";
14
+ export * from "./format.js";
15
+ export { visibleWidth, setEmojiWidth } from "./width.js";
16
+ export { buildLayout, estimateWidth } from "./layout.js";
17
+ export * from "./sections/index.js";
18
+ export * from "./renderers/index.js";
19
+ export * from "./colors.js";
20
+ export * from "./config.js";
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGzD,cAAc,qBAAqB,CAAC;AAGpC,cAAc,sBAAsB,CAAC;AAErC,cAAc,aAAa,CAAC;AAG5B,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @statusline/core - Core library for section-priority-based status line rendering.
3
+ *
4
+ * This package provides:
5
+ * - Type definitions for sections, items, and priorities
6
+ * - Priority constants and helpers
7
+ * - Built-in sections for common status line elements
8
+ * - Layout engine with priority-based shrinking
9
+ * - Renderer interface and implementations (CLI, VS Code, Neovim, OpenCode)
10
+ * - Configuration system for user customization
11
+ */
12
+ // Types and models
13
+ export * from "./model.js";
14
+ export * from "./priority.js";
15
+ export * from "./format.js";
16
+ // Width calculation (Unicode-aware) — shared by layout + renderers
17
+ export { visibleWidth, setEmojiWidth } from "./width.js";
18
+ // Layout engine (Phase 3)
19
+ export { buildLayout, estimateWidth } from "./layout.js";
20
+ // Sections (Phase 2)
21
+ export * from "./sections/index.js";
22
+ // Renderers (Phase 4)
23
+ export * from "./renderers/index.js";
24
+ // export * from "./renderer.js"; // getRenderer is re-exported from renderers/index
25
+ export * from "./colors.js";
26
+ // Configuration (Phase 5)
27
+ export * from "./config.js";
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mBAAmB;AACnB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAE5B,mEAAmE;AACnE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEzD,0BAA0B;AAC1B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEzD,qBAAqB;AACrB,cAAc,qBAAqB,CAAC;AAEpC,sBAAsB;AACtB,cAAc,sBAAsB,CAAC;AACrC,oFAAoF;AACpF,cAAc,aAAa,CAAC;AAE5B,0BAA0B;AAC1B,cAAc,aAAa,CAAC"}