@owloops/claude-powerline 1.25.1 → 1.26.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.
- package/README.md +120 -4
- package/dist/browser.d.ts +88 -9
- package/dist/browser.js +3 -3
- package/dist/index.mjs +13 -12
- package/package.json +1 -1
- package/src/browser.ts +5 -0
- package/src/config/defaults.ts +3 -0
- package/src/config/loader.ts +9 -0
- package/src/powerline.ts +148 -5
- package/src/segments/cacheTimer.ts +72 -0
- package/src/segments/index.ts +5 -0
- package/src/segments/renderer.ts +177 -58
- package/src/themes/dark.ts +9 -0
- package/src/themes/gruvbox.ts +9 -0
- package/src/themes/index.ts +27 -0
- package/src/themes/light.ts +9 -0
- package/src/themes/nord.ts +9 -0
- package/src/themes/rose-pine.ts +9 -0
- package/src/themes/tokyo-night.ts +9 -0
- package/src/tui/layouts.ts +56 -20
- package/src/tui/primitives.ts +12 -3
- package/src/tui/sections.ts +555 -124
- package/src/tui/types.ts +8 -0
- package/src/utils/budget.ts +69 -0
- package/src/utils/claude.ts +29 -0
- package/src/utils/constants.ts +6 -0
- package/src/utils/formatters.ts +8 -0
- package/src/utils/icon-visibility.ts +31 -0
package/src/tui/layouts.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RenderCtx } from "./types";
|
|
2
2
|
|
|
3
3
|
import { formatCost } from "../utils/formatters";
|
|
4
|
+
import { resolveIconVisibility } from "../utils/icon-visibility";
|
|
4
5
|
import {
|
|
5
6
|
contentRow,
|
|
6
7
|
divider,
|
|
@@ -51,7 +52,7 @@ export function renderWideBottom(ctx: RenderCtx): void {
|
|
|
51
52
|
reset,
|
|
52
53
|
colors,
|
|
53
54
|
} = ctx;
|
|
54
|
-
const leftParts = collectWorkspaceParts(data, sym, reset, colors);
|
|
55
|
+
const leftParts = collectWorkspaceParts(data, sym, reset, colors, config);
|
|
55
56
|
const rightParts = collectFooterParts(data, sym, config, reset, colors);
|
|
56
57
|
|
|
57
58
|
const leftStr = leftParts.join(" ");
|
|
@@ -82,27 +83,39 @@ export function renderMediumMetrics(ctx: RenderCtx): void {
|
|
|
82
83
|
const line1Parts: string[] = [];
|
|
83
84
|
const line2Parts: string[] = [];
|
|
84
85
|
|
|
86
|
+
const showBlockIcon = resolveIconVisibility(config, "block");
|
|
87
|
+
const showWeeklyIcon = resolveIconVisibility(config, "weekly");
|
|
88
|
+
const showTodayIcon = resolveIconVisibility(config, "today");
|
|
89
|
+
const showSessionIcon = resolveIconVisibility(config, "session");
|
|
90
|
+
|
|
85
91
|
if (data.blockInfo) {
|
|
86
92
|
line1Parts.push(
|
|
87
93
|
colorize(
|
|
88
|
-
formatBlockSegment(data.blockInfo, sym, config),
|
|
94
|
+
formatBlockSegment(data.blockInfo, sym, config, showBlockIcon),
|
|
89
95
|
colors.blockFg,
|
|
90
96
|
reset,
|
|
97
|
+
colors.blockBold,
|
|
91
98
|
),
|
|
92
99
|
);
|
|
93
100
|
}
|
|
94
101
|
const sevenDay = data.hookData.rate_limits?.seven_day;
|
|
95
102
|
if (sevenDay) {
|
|
96
103
|
line1Parts.push(
|
|
97
|
-
colorize(
|
|
104
|
+
colorize(
|
|
105
|
+
formatWeeklySegment(sevenDay, sym, showWeeklyIcon),
|
|
106
|
+
colors.weeklyFg,
|
|
107
|
+
reset,
|
|
108
|
+
colors.weeklyBold,
|
|
109
|
+
),
|
|
98
110
|
);
|
|
99
111
|
}
|
|
100
112
|
if (data.todayInfo) {
|
|
101
113
|
line1Parts.push(
|
|
102
114
|
colorize(
|
|
103
|
-
formatTodaySegment(data.todayInfo, sym, config),
|
|
115
|
+
formatTodaySegment(data.todayInfo, sym, config, showTodayIcon),
|
|
104
116
|
colors.todayFg,
|
|
105
117
|
reset,
|
|
118
|
+
colors.todayBold,
|
|
106
119
|
),
|
|
107
120
|
);
|
|
108
121
|
}
|
|
@@ -110,16 +123,22 @@ export function renderMediumMetrics(ctx: RenderCtx): void {
|
|
|
110
123
|
if (data.usageInfo) {
|
|
111
124
|
line2Parts.push(
|
|
112
125
|
colorize(
|
|
113
|
-
formatSessionSegment(data.usageInfo, sym, config),
|
|
126
|
+
formatSessionSegment(data.usageInfo, sym, config, showSessionIcon),
|
|
114
127
|
colors.sessionFg,
|
|
115
128
|
reset,
|
|
129
|
+
colors.sessionBold,
|
|
116
130
|
),
|
|
117
131
|
);
|
|
118
132
|
}
|
|
119
133
|
const activityParts = collectActivityParts(data, sym);
|
|
120
134
|
if (activityParts.length > 0) {
|
|
121
135
|
line2Parts.push(
|
|
122
|
-
colorize(
|
|
136
|
+
colorize(
|
|
137
|
+
activityParts.join(" · "),
|
|
138
|
+
colors.metricsFg,
|
|
139
|
+
reset,
|
|
140
|
+
colors.metricsBold,
|
|
141
|
+
),
|
|
123
142
|
);
|
|
124
143
|
}
|
|
125
144
|
|
|
@@ -151,7 +170,13 @@ export function renderMediumBottom(ctx: RenderCtx): void {
|
|
|
151
170
|
reset,
|
|
152
171
|
colors,
|
|
153
172
|
} = ctx;
|
|
154
|
-
const workspaceParts = collectWorkspaceParts(
|
|
173
|
+
const workspaceParts = collectWorkspaceParts(
|
|
174
|
+
data,
|
|
175
|
+
sym,
|
|
176
|
+
reset,
|
|
177
|
+
colors,
|
|
178
|
+
config,
|
|
179
|
+
);
|
|
155
180
|
if (workspaceParts.length > 0) {
|
|
156
181
|
lines.push(divider(box, innerWidth));
|
|
157
182
|
lines.push(
|
|
@@ -188,14 +213,20 @@ export function renderNarrowMetrics(ctx: RenderCtx): void {
|
|
|
188
213
|
reset,
|
|
189
214
|
colors,
|
|
190
215
|
} = ctx;
|
|
216
|
+
const showBlockIcon = resolveIconVisibility(config, "block");
|
|
217
|
+
const showWeeklyIcon = resolveIconVisibility(config, "weekly");
|
|
218
|
+
const showSessionIcon = resolveIconVisibility(config, "session");
|
|
219
|
+
const showTodayIcon = resolveIconVisibility(config, "today");
|
|
220
|
+
|
|
191
221
|
if (data.blockInfo) {
|
|
192
222
|
lines.push(
|
|
193
223
|
contentRow(
|
|
194
224
|
box,
|
|
195
225
|
colorize(
|
|
196
|
-
formatBlockSegment(data.blockInfo, sym, config),
|
|
226
|
+
formatBlockSegment(data.blockInfo, sym, config, showBlockIcon),
|
|
197
227
|
colors.blockFg,
|
|
198
228
|
reset,
|
|
229
|
+
colors.blockBold,
|
|
199
230
|
),
|
|
200
231
|
innerWidth,
|
|
201
232
|
),
|
|
@@ -207,9 +238,10 @@ export function renderNarrowMetrics(ctx: RenderCtx): void {
|
|
|
207
238
|
contentRow(
|
|
208
239
|
box,
|
|
209
240
|
colorize(
|
|
210
|
-
formatWeeklySegment(narrowSevenDay, sym),
|
|
241
|
+
formatWeeklySegment(narrowSevenDay, sym, showWeeklyIcon),
|
|
211
242
|
colors.weeklyFg,
|
|
212
243
|
reset,
|
|
244
|
+
colors.weeklyBold,
|
|
213
245
|
),
|
|
214
246
|
innerWidth,
|
|
215
247
|
),
|
|
@@ -218,21 +250,19 @@ export function renderNarrowMetrics(ctx: RenderCtx): void {
|
|
|
218
250
|
|
|
219
251
|
const sessionAndToday: string[] = [];
|
|
220
252
|
if (data.usageInfo) {
|
|
253
|
+
const sessionText = showSessionIcon
|
|
254
|
+
? `${sym.session_cost} ${formatCost(data.usageInfo.session.cost)}`
|
|
255
|
+
: formatCost(data.usageInfo.session.cost);
|
|
221
256
|
sessionAndToday.push(
|
|
222
|
-
colorize(
|
|
223
|
-
`${sym.session_cost} ${formatCost(data.usageInfo.session.cost)}`,
|
|
224
|
-
colors.sessionFg,
|
|
225
|
-
reset,
|
|
226
|
-
),
|
|
257
|
+
colorize(sessionText, colors.sessionFg, reset, colors.sessionBold),
|
|
227
258
|
);
|
|
228
259
|
}
|
|
229
260
|
if (data.todayInfo) {
|
|
261
|
+
const todayText = showTodayIcon
|
|
262
|
+
? `${sym.today_cost} ${formatCost(data.todayInfo.cost)} today`
|
|
263
|
+
: `${formatCost(data.todayInfo.cost)} today`;
|
|
230
264
|
sessionAndToday.push(
|
|
231
|
-
colorize(
|
|
232
|
-
`${sym.today_cost} ${formatCost(data.todayInfo.cost)} today`,
|
|
233
|
-
colors.todayFg,
|
|
234
|
-
reset,
|
|
235
|
-
),
|
|
265
|
+
colorize(todayText, colors.todayFg, reset, colors.todayBold),
|
|
236
266
|
);
|
|
237
267
|
}
|
|
238
268
|
if (sessionAndToday.length > 0) {
|
|
@@ -262,7 +292,13 @@ export function renderNarrowBottom(ctx: RenderCtx): void {
|
|
|
262
292
|
reset,
|
|
263
293
|
colors,
|
|
264
294
|
} = ctx;
|
|
265
|
-
const workspaceParts = collectWorkspaceParts(
|
|
295
|
+
const workspaceParts = collectWorkspaceParts(
|
|
296
|
+
data,
|
|
297
|
+
sym,
|
|
298
|
+
reset,
|
|
299
|
+
colors,
|
|
300
|
+
config,
|
|
301
|
+
);
|
|
266
302
|
if (workspaceParts.length > 0) {
|
|
267
303
|
lines.push(divider(box, innerWidth));
|
|
268
304
|
lines.push(
|
package/src/tui/primitives.ts
CHANGED
|
@@ -2,11 +2,20 @@ import type { BoxChars } from "./types";
|
|
|
2
2
|
|
|
3
3
|
import { visibleLength, stripAnsi, ESC, ANSI_SPLIT } from "../utils/terminal";
|
|
4
4
|
|
|
5
|
-
export function colorize(
|
|
6
|
-
|
|
5
|
+
export function colorize(
|
|
6
|
+
text: string,
|
|
7
|
+
fgColor: string,
|
|
8
|
+
reset: string,
|
|
9
|
+
bold = false,
|
|
10
|
+
): string {
|
|
11
|
+
const useBold = bold && reset !== "";
|
|
12
|
+
if (!fgColor && !useBold) {
|
|
7
13
|
return text;
|
|
8
14
|
}
|
|
9
|
-
|
|
15
|
+
if (!useBold) {
|
|
16
|
+
return `${fgColor}${text}${reset}`;
|
|
17
|
+
}
|
|
18
|
+
return `${fgColor}\x1b[1m${text}\x1b[22m${reset}`;
|
|
10
19
|
}
|
|
11
20
|
|
|
12
21
|
export function padRight(text: string, width: number): string {
|