@bastra-recall/statusline 0.7.0-beta.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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +26 -0
  3. package/bin/claude-powerline +2 -0
  4. package/dist/browser.d.ts +796 -0
  5. package/dist/browser.js +3 -0
  6. package/dist/index.mjs +48 -0
  7. package/package.json +39 -0
  8. package/src/browser.ts +208 -0
  9. package/src/config/defaults.ts +88 -0
  10. package/src/config/loader.ts +473 -0
  11. package/src/index.ts +90 -0
  12. package/src/powerline.ts +1082 -0
  13. package/src/segments/bastra.ts +123 -0
  14. package/src/segments/block.ts +31 -0
  15. package/src/segments/cacheTimer.ts +108 -0
  16. package/src/segments/context.ts +221 -0
  17. package/src/segments/git.ts +498 -0
  18. package/src/segments/index.ts +33 -0
  19. package/src/segments/metrics.ts +175 -0
  20. package/src/segments/pricing.ts +454 -0
  21. package/src/segments/renderer.ts +1002 -0
  22. package/src/segments/session.ts +207 -0
  23. package/src/segments/tmux.ts +35 -0
  24. package/src/segments/today.ts +191 -0
  25. package/src/themes/dark.ts +61 -0
  26. package/src/themes/gruvbox.ts +61 -0
  27. package/src/themes/index.ts +161 -0
  28. package/src/themes/light.ts +61 -0
  29. package/src/themes/nord.ts +61 -0
  30. package/src/themes/rose-pine.ts +61 -0
  31. package/src/themes/tokyo-night.ts +61 -0
  32. package/src/tui/grid.ts +712 -0
  33. package/src/tui/index.ts +4 -0
  34. package/src/tui/layouts.ts +321 -0
  35. package/src/tui/primitives.ts +187 -0
  36. package/src/tui/renderer.ts +206 -0
  37. package/src/tui/sections.ts +1511 -0
  38. package/src/tui/types.ts +189 -0
  39. package/src/utils/budget.ts +116 -0
  40. package/src/utils/cache.ts +247 -0
  41. package/src/utils/claude.ts +518 -0
  42. package/src/utils/color-support.ts +118 -0
  43. package/src/utils/colors.ts +120 -0
  44. package/src/utils/constants.ts +184 -0
  45. package/src/utils/formatters.ts +175 -0
  46. package/src/utils/icon-visibility.ts +31 -0
  47. package/src/utils/logger.ts +5 -0
  48. package/src/utils/terminal-width.ts +117 -0
  49. package/src/utils/terminal.ts +54 -0
package/src/browser.ts ADDED
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Browser-safe entry point for claude-powerline.
3
+ *
4
+ * Exports all rendering modules, themes, types, and utilities needed
5
+ * to generate statusline output without any Node.js built-in modules.
6
+ *
7
+ * Data providers (git, session, metrics, etc.) are NOT exported here —
8
+ * supply pre-built data objects to the rendering functions instead.
9
+ */
10
+
11
+ // --- Types ---
12
+
13
+ export type { ClaudeHookData } from "./utils/claude";
14
+
15
+ export type {
16
+ PowerlineConfig,
17
+ DisplayConfig,
18
+ LineConfig,
19
+ BudgetConfig,
20
+ BudgetItemConfig,
21
+ } from "./config/loader";
22
+
23
+ export type { ColorTheme, PowerlineColors, SegmentColor } from "./themes";
24
+
25
+ export type { GitInfo } from "./segments/git";
26
+ export type {
27
+ UsageInfo,
28
+ SessionInfo,
29
+ TokenBreakdown,
30
+ } from "./segments/session";
31
+ export type { ContextInfo } from "./segments/context";
32
+ export type { MetricsInfo } from "./segments/metrics";
33
+ export type { BlockInfo } from "./segments/block";
34
+ export type { TodayInfo } from "./segments/today";
35
+ export type { CacheTimerInfo } from "./segments/cacheTimer";
36
+
37
+ export type {
38
+ SegmentConfig,
39
+ AnySegmentConfig,
40
+ DirectorySegmentConfig,
41
+ GitSegmentConfig,
42
+ UsageSegmentConfig,
43
+ ContextSegmentConfig,
44
+ MetricsSegmentConfig,
45
+ BlockSegmentConfig,
46
+ TodaySegmentConfig,
47
+ VersionSegmentConfig,
48
+ SessionIdSegmentConfig,
49
+ EnvSegmentConfig,
50
+ WeeklySegmentConfig,
51
+ AgentSegmentConfig,
52
+ ThinkingSegmentConfig,
53
+ CacheTimerSegmentConfig,
54
+ PowerlineSymbols,
55
+ SegmentData,
56
+ BarDisplayStyle,
57
+ } from "./segments/renderer";
58
+
59
+ export type {
60
+ TuiData,
61
+ BoxChars,
62
+ TuiGridConfig,
63
+ TuiGridBreakpoint,
64
+ TuiTitleConfig,
65
+ TuiFooterConfig,
66
+ SegmentTemplate,
67
+ SegmentName,
68
+ AlignValue,
69
+ LayoutMode,
70
+ SymbolSet,
71
+ RenderCtx,
72
+ JustifyValue,
73
+ GridCell,
74
+ } from "./tui/types";
75
+
76
+ // --- Rendering ---
77
+
78
+ export { SegmentRenderer } from "./segments/renderer";
79
+ export { renderTuiPanel } from "./tui/renderer";
80
+ export type { TuiPanelOptions } from "./tui/renderer";
81
+
82
+ // --- Themes ---
83
+
84
+ export { getTheme, BUILT_IN_THEMES } from "./themes";
85
+ export {
86
+ darkTheme,
87
+ darkAnsi256Theme,
88
+ darkAnsiTheme,
89
+ lightTheme,
90
+ lightAnsi256Theme,
91
+ lightAnsiTheme,
92
+ nordTheme,
93
+ nordAnsi256Theme,
94
+ nordAnsiTheme,
95
+ tokyoNightTheme,
96
+ tokyoNightAnsi256Theme,
97
+ tokyoNightAnsiTheme,
98
+ rosePineTheme,
99
+ rosePineAnsi256Theme,
100
+ rosePineAnsiTheme,
101
+ gruvboxTheme,
102
+ gruvboxAnsi256Theme,
103
+ gruvboxAnsiTheme,
104
+ } from "./themes";
105
+
106
+ // --- Constants ---
107
+
108
+ export {
109
+ SYMBOLS,
110
+ TEXT_SYMBOLS,
111
+ RESET_CODE,
112
+ BOX_CHARS,
113
+ BOX_CHARS_TEXT,
114
+ BOX_PRESETS,
115
+ } from "./utils/constants";
116
+
117
+ // --- Pure utilities ---
118
+
119
+ export {
120
+ hexToAnsi,
121
+ extractBgToFg,
122
+ hexTo256Ansi,
123
+ hexToBasicAnsi,
124
+ hexColorDistance,
125
+ } from "./utils/colors";
126
+ export { stripAnsi, visibleLength, ESC } from "./utils/terminal";
127
+ export {
128
+ formatCost,
129
+ formatTokens,
130
+ formatTokenBreakdown,
131
+ formatTimeSince,
132
+ formatDuration,
133
+ formatModelName,
134
+ abbreviateFishStyle,
135
+ formatResponseTime,
136
+ formatTokenCount,
137
+ formatBurnRate,
138
+ collapseHome,
139
+ formatTimeRemaining,
140
+ formatLongTimeRemaining,
141
+ minutesUntilReset,
142
+ formatCacheTimerElapsed,
143
+ } from "./utils/formatters";
144
+ export { getBudgetStatus } from "./utils/budget";
145
+
146
+ // --- TUI components ---
147
+
148
+ export {
149
+ contentRow,
150
+ bottomBorder,
151
+ divider,
152
+ spreadEven,
153
+ spreadTwo,
154
+ colorize,
155
+ truncateAnsi,
156
+ padRight,
157
+ padLeft,
158
+ padCenter,
159
+ } from "./tui/primitives";
160
+ export {
161
+ buildTitleBar,
162
+ buildContextLine,
163
+ buildContextBar,
164
+ buildBlockBar,
165
+ buildWeeklyBar,
166
+ resolveSegments,
167
+ composeTemplate,
168
+ resolveTitleToken,
169
+ collectMetricSegments,
170
+ collectActivityParts,
171
+ collectWorkspaceParts,
172
+ collectFooterParts,
173
+ } from "./tui/sections";
174
+ export {
175
+ renderWideMetrics,
176
+ renderWideBottom,
177
+ renderMediumMetrics,
178
+ renderMediumBottom,
179
+ renderNarrowMetrics,
180
+ renderNarrowBottom,
181
+ } from "./tui/layouts";
182
+
183
+ // --- TUI grid helpers ---
184
+
185
+ export {
186
+ parseAreas,
187
+ cullMatrix,
188
+ calculateColumnWidths,
189
+ selectBreakpoint,
190
+ solveFitContentLayout,
191
+ renderGrid,
192
+ DIVIDER,
193
+ EMPTY_CELL,
194
+ LATE_RESOLVE_SEGMENTS,
195
+ } from "./tui/grid";
196
+ export type { GridResult } from "./tui/grid";
197
+
198
+ // --- Config defaults ---
199
+
200
+ export { DEFAULT_CONFIG } from "./config/defaults";
201
+
202
+ // --- Segment ref validation ---
203
+
204
+ export {
205
+ isValidSegmentRef,
206
+ VALID_SEGMENT_NAMES,
207
+ SEGMENT_PARTS,
208
+ } from "./tui/types";
@@ -0,0 +1,88 @@
1
+ import type { PowerlineConfig } from "./loader";
2
+
3
+ export const DEFAULT_CONFIG: PowerlineConfig = {
4
+ theme: "dark",
5
+ display: {
6
+ style: "powerline",
7
+ charset: "unicode",
8
+ colorCompatibility: "auto",
9
+ autoWrap: false,
10
+ padding: 1,
11
+ lines: [
12
+ {
13
+ segments: {
14
+ directory: {
15
+ enabled: true,
16
+ style: "basename",
17
+ },
18
+ git: {
19
+ enabled: true,
20
+ showSha: false,
21
+ showWorkingTree: false,
22
+ showOperation: false,
23
+ showTag: false,
24
+ showTimeSinceCommit: false,
25
+ showStashCount: false,
26
+ showUpstream: false,
27
+ showRepoName: false,
28
+ },
29
+ model: { enabled: true },
30
+ session: {
31
+ enabled: false,
32
+ type: "tokens",
33
+ costSource: "calculated",
34
+ showUnits: true,
35
+ },
36
+ today: { enabled: false, type: "cost", showUnits: true },
37
+ block: {
38
+ enabled: false,
39
+ type: "cost",
40
+ burnType: "cost",
41
+ displayStyle: "text",
42
+ },
43
+ weekly: { enabled: true, displayStyle: "text" },
44
+ version: { enabled: false },
45
+ tmux: { enabled: false },
46
+ sessionId: { enabled: false, showIdLabel: true },
47
+ context: {
48
+ enabled: true,
49
+ showPercentageOnly: false,
50
+ displayStyle: "text",
51
+ autocompactBuffer: 33000,
52
+ },
53
+ metrics: {
54
+ enabled: false,
55
+ showResponseTime: true,
56
+ showLastResponseTime: true,
57
+ showDuration: true,
58
+ showMessageCount: true,
59
+ showLinesAdded: true,
60
+ showLinesRemoved: true,
61
+ },
62
+ agent: { enabled: true, showLabel: false },
63
+ thinking: { enabled: false, showEnabled: true, showEffort: true },
64
+ cacheTimer: { enabled: false },
65
+ bastra: { enabled: true },
66
+ },
67
+ },
68
+ ],
69
+ },
70
+ budget: {
71
+ session: {
72
+ warningThreshold: 80,
73
+ },
74
+ today: {
75
+ warningThreshold: 80,
76
+ amount: 50,
77
+ },
78
+ block: {
79
+ warningThreshold: 80,
80
+ amount: 15,
81
+ },
82
+ },
83
+ modelContextLimits: {
84
+ default: 200000,
85
+ sonnet: 200000,
86
+ opus: 200000,
87
+ },
88
+ };