@owloops/claude-powerline 1.3.2 → 1.4.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 +43 -5
- package/dist/index.js +342 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
|
|
53
53
|
- **Vim-style powerline** with proper arrows and segments
|
|
54
54
|
- **Real-time session tracking** with costs and tokens
|
|
55
|
+
- **Performance metrics** with response times and burn rates
|
|
55
56
|
- **Context monitoring** showing tokens used and auto-compact threshold
|
|
56
57
|
- **Git integration** with branch, status, ahead/behind counts
|
|
57
58
|
|
|
@@ -128,6 +129,9 @@ Options are specified by command line flags. Overall configuration can also use
|
|
|
128
129
|
| `--install-fonts` | - | Install powerline fonts to system |
|
|
129
130
|
| `-h, --help` | - | Show help message |
|
|
130
131
|
|
|
132
|
+
> [!NOTE]
|
|
133
|
+
> Global options have CLI flags and environment variables. Individual segments are configured through config files.
|
|
134
|
+
|
|
131
135
|
### Usage Display Types
|
|
132
136
|
|
|
133
137
|
- **cost**: Show dollar amounts (`$0.05`)
|
|
@@ -182,8 +186,8 @@ curl -o ~/.claude/claude-powerline.json https://raw.githubusercontent.com/Owloop
|
|
|
182
186
|
|
|
183
187
|
Configuration priority (top overrides bottom):
|
|
184
188
|
|
|
185
|
-
1. CLI arguments (`--theme`, `--style`, `--usage`, `--config`)
|
|
186
|
-
2. Environment variables (`CLAUDE_POWERLINE_THEME`, `CLAUDE_POWERLINE_STYLE`, `CLAUDE_POWERLINE_USAGE_TYPE`, `CLAUDE_POWERLINE_CONFIG`)
|
|
189
|
+
1. CLI arguments (`--theme`, `--style`, `--usage`, `--session-budget`, `--config`)
|
|
190
|
+
2. Environment variables (`CLAUDE_POWERLINE_THEME`, `CLAUDE_POWERLINE_STYLE`, `CLAUDE_POWERLINE_USAGE_TYPE`, `CLAUDE_POWERLINE_SESSION_BUDGET`, `CLAUDE_POWERLINE_CONFIG`)
|
|
187
191
|
3. Config files (first found):
|
|
188
192
|
- `./.claude-powerline.json` (project)
|
|
189
193
|
- `~/.claude/claude-powerline.json` (user)
|
|
@@ -206,7 +210,15 @@ Configuration priority (top overrides bottom):
|
|
|
206
210
|
"model": { "enabled": true },
|
|
207
211
|
"session": { "enabled": true, "type": "tokens" },
|
|
208
212
|
"context": { "enabled": true },
|
|
209
|
-
"tmux": { "enabled": true }
|
|
213
|
+
"tmux": { "enabled": true },
|
|
214
|
+
"metrics": {
|
|
215
|
+
"enabled": true,
|
|
216
|
+
"showResponseTime": true,
|
|
217
|
+
"showDuration": true,
|
|
218
|
+
"showMessageCount": true,
|
|
219
|
+
"showCostBurnRate": false,
|
|
220
|
+
"showTokenBurnRate": false
|
|
221
|
+
}
|
|
210
222
|
}
|
|
211
223
|
}
|
|
212
224
|
]
|
|
@@ -222,6 +234,30 @@ Configuration priority (top overrides bottom):
|
|
|
222
234
|
- **session**: Token usage and costs for current session
|
|
223
235
|
- **context**: Context window usage and auto-compact threshold
|
|
224
236
|
- **tmux**: Tmux session name and window info (when in tmux)
|
|
237
|
+
- **metrics**: Performance analytics (response time, session duration, message count, burn rates)
|
|
238
|
+
|
|
239
|
+
#### Metrics Configuration
|
|
240
|
+
|
|
241
|
+
The metrics segment displays performance analytics from your Claude sessions:
|
|
242
|
+
|
|
243
|
+
```json
|
|
244
|
+
"metrics": {
|
|
245
|
+
"enabled": true,
|
|
246
|
+
"showResponseTime": true,
|
|
247
|
+
"showDuration": true,
|
|
248
|
+
"showMessageCount": true,
|
|
249
|
+
"showCostBurnRate": false,
|
|
250
|
+
"showTokenBurnRate": false
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Options:**
|
|
255
|
+
|
|
256
|
+
- `showResponseTime`: Average response time per message (`⧖ 3.2s`)
|
|
257
|
+
- `showDuration`: Total session duration (`⧗ 28m`)
|
|
258
|
+
- `showMessageCount`: Number of user messages (`⟐ 93`)
|
|
259
|
+
- `showCostBurnRate`: Cost burn rate per hour (`⟢ $1.20/h`)
|
|
260
|
+
- `showTokenBurnRate`: Token burn rate per hour (`⟢ 450K/h`)
|
|
225
261
|
|
|
226
262
|
### Multi-line Layout (Optional)
|
|
227
263
|
|
|
@@ -242,7 +278,8 @@ To prevent segment cutoff, configure multiple lines:
|
|
|
242
278
|
"segments": {
|
|
243
279
|
"session": { "enabled": true, "type": "tokens" },
|
|
244
280
|
"context": { "enabled": true },
|
|
245
|
-
"tmux": { "enabled":
|
|
281
|
+
"tmux": { "enabled": false },
|
|
282
|
+
"metrics": { "enabled": true }
|
|
246
283
|
}
|
|
247
284
|
}
|
|
248
285
|
]
|
|
@@ -267,7 +304,8 @@ To customize colors, copy dark or light theme colors from `src/themes/` in the r
|
|
|
267
304
|
"model": { "bg": "#9900cc", "fg": "#ffffff" },
|
|
268
305
|
"session": { "bg": "#cc0099", "fg": "#ffffff" },
|
|
269
306
|
"context": { "bg": "#4a5568", "fg": "#ffffff" },
|
|
270
|
-
"tmux": { "bg": "#228b22", "fg": "#ffffff" }
|
|
307
|
+
"tmux": { "bg": "#228b22", "fg": "#ffffff" },
|
|
308
|
+
"metrics": { "bg": "#374151", "fg": "#ffffff" }
|
|
271
309
|
}
|
|
272
310
|
}
|
|
273
311
|
}
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,8 @@ var darkTheme = {
|
|
|
36
36
|
model: { bg: "#2d2d2d", fg: "#ffffff" },
|
|
37
37
|
session: { bg: "#202020", fg: "#00ffff" },
|
|
38
38
|
tmux: { bg: "#2f4f2f", fg: "#90ee90" },
|
|
39
|
-
context: { bg: "#4a5568", fg: "#cbd5e0" }
|
|
39
|
+
context: { bg: "#4a5568", fg: "#cbd5e0" },
|
|
40
|
+
metrics: { bg: "#374151", fg: "#d1d5db" }
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
// src/themes/light.ts
|
|
@@ -46,7 +47,8 @@ var lightTheme = {
|
|
|
46
47
|
model: { bg: "#87ceeb", fg: "#000000" },
|
|
47
48
|
session: { bg: "#da70d6", fg: "#ffffff" },
|
|
48
49
|
tmux: { bg: "#32cd32", fg: "#ffffff" },
|
|
49
|
-
context: { bg: "#718096", fg: "#ffffff" }
|
|
50
|
+
context: { bg: "#718096", fg: "#ffffff" },
|
|
51
|
+
metrics: { bg: "#6b7280", fg: "#ffffff" }
|
|
50
52
|
};
|
|
51
53
|
|
|
52
54
|
// src/themes/nord.ts
|
|
@@ -56,7 +58,8 @@ var nordTheme = {
|
|
|
56
58
|
model: { bg: "#4c566a", fg: "#81a1c1" },
|
|
57
59
|
session: { bg: "#2e3440", fg: "#88c0d0" },
|
|
58
60
|
tmux: { bg: "#2e3440", fg: "#8fbcbb" },
|
|
59
|
-
context: { bg: "#5e81ac", fg: "#eceff4" }
|
|
61
|
+
context: { bg: "#5e81ac", fg: "#eceff4" },
|
|
62
|
+
metrics: { bg: "#b48ead", fg: "#2e3440" }
|
|
60
63
|
};
|
|
61
64
|
|
|
62
65
|
// src/themes/tokyo-night.ts
|
|
@@ -66,7 +69,8 @@ var tokyoNightTheme = {
|
|
|
66
69
|
model: { bg: "#191b29", fg: "#fca7ea" },
|
|
67
70
|
session: { bg: "#222436", fg: "#86e1fc" },
|
|
68
71
|
tmux: { bg: "#191b29", fg: "#4fd6be" },
|
|
69
|
-
context: { bg: "#414868", fg: "#c0caf5" }
|
|
72
|
+
context: { bg: "#414868", fg: "#c0caf5" },
|
|
73
|
+
metrics: { bg: "#bb9af7", fg: "#1a1b26" }
|
|
70
74
|
};
|
|
71
75
|
|
|
72
76
|
// src/themes/rose-pine.ts
|
|
@@ -76,7 +80,8 @@ var rosePineTheme = {
|
|
|
76
80
|
model: { bg: "#191724", fg: "#ebbcba" },
|
|
77
81
|
session: { bg: "#26233a", fg: "#f6c177" },
|
|
78
82
|
tmux: { bg: "#26233a", fg: "#908caa" },
|
|
79
|
-
context: { bg: "#393552", fg: "#e0def4" }
|
|
83
|
+
context: { bg: "#393552", fg: "#e0def4" },
|
|
84
|
+
metrics: { bg: "#c4a7e7", fg: "#191724" }
|
|
80
85
|
};
|
|
81
86
|
|
|
82
87
|
// src/themes/index.ts
|
|
@@ -230,9 +235,6 @@ var TmuxService = class {
|
|
|
230
235
|
|
|
231
236
|
// src/segments/session.ts
|
|
232
237
|
import { readFile } from "fs/promises";
|
|
233
|
-
import { existsSync } from "fs";
|
|
234
|
-
import { join } from "path";
|
|
235
|
-
import { homedir } from "os";
|
|
236
238
|
|
|
237
239
|
// src/segments/pricing.ts
|
|
238
240
|
var OFFLINE_PRICING_DATA = {
|
|
@@ -530,8 +532,7 @@ var PricingService = class {
|
|
|
530
532
|
if (typeof model === "string") {
|
|
531
533
|
return model;
|
|
532
534
|
}
|
|
533
|
-
|
|
534
|
-
return modelObj.id || "claude-3-5-sonnet-20241022";
|
|
535
|
+
return model?.id || "claude-3-5-sonnet-20241022";
|
|
535
536
|
}
|
|
536
537
|
if (entry.model_id && typeof entry.model_id === "string") {
|
|
537
538
|
return entry.model_id;
|
|
@@ -540,52 +541,57 @@ var PricingService = class {
|
|
|
540
541
|
}
|
|
541
542
|
};
|
|
542
543
|
|
|
543
|
-
// src/
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
544
|
+
// src/utils/claude.ts
|
|
545
|
+
import { readdir } from "fs/promises";
|
|
546
|
+
import { existsSync } from "fs";
|
|
547
|
+
import { join } from "path";
|
|
548
|
+
import { homedir } from "os";
|
|
549
|
+
function getClaudePaths() {
|
|
550
|
+
const paths = [];
|
|
551
|
+
const homeDir = homedir();
|
|
552
|
+
const defaultPath = join(homeDir, ".claude");
|
|
553
|
+
if (existsSync(defaultPath)) {
|
|
554
|
+
paths.push(defaultPath);
|
|
555
|
+
}
|
|
556
|
+
return paths;
|
|
557
|
+
}
|
|
558
|
+
async function findProjectPaths(claudePaths) {
|
|
559
|
+
const projectPaths = [];
|
|
560
|
+
for (const claudePath of claudePaths) {
|
|
561
|
+
const projectsDir = join(claudePath, "projects");
|
|
562
|
+
if (existsSync(projectsDir)) {
|
|
563
|
+
try {
|
|
564
|
+
const entries = await readdir(projectsDir, { withFileTypes: true });
|
|
565
|
+
for (const entry of entries) {
|
|
566
|
+
if (entry.isDirectory()) {
|
|
567
|
+
const projectPath = join(projectsDir, entry.name);
|
|
568
|
+
projectPaths.push(projectPath);
|
|
567
569
|
}
|
|
568
|
-
} catch (error) {
|
|
569
|
-
debug(`Failed to read projects directory ${projectsDir}:`, error);
|
|
570
570
|
}
|
|
571
|
+
} catch (error) {
|
|
572
|
+
debug(`Failed to read projects directory ${projectsDir}:`, error);
|
|
571
573
|
}
|
|
572
574
|
}
|
|
573
|
-
return projectPaths;
|
|
574
575
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
576
|
+
return projectPaths;
|
|
577
|
+
}
|
|
578
|
+
async function findTranscriptFile(sessionId) {
|
|
579
|
+
const claudePaths = getClaudePaths();
|
|
580
|
+
const projectPaths = await findProjectPaths(claudePaths);
|
|
581
|
+
for (const projectPath of projectPaths) {
|
|
582
|
+
const transcriptPath = join(projectPath, `${sessionId}.jsonl`);
|
|
583
|
+
if (existsSync(transcriptPath)) {
|
|
584
|
+
return transcriptPath;
|
|
583
585
|
}
|
|
584
|
-
return null;
|
|
585
586
|
}
|
|
587
|
+
return null;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// src/segments/session.ts
|
|
591
|
+
var SessionProvider = class {
|
|
586
592
|
async getSessionUsage(sessionId) {
|
|
587
593
|
try {
|
|
588
|
-
const transcriptPath = await
|
|
594
|
+
const transcriptPath = await findTranscriptFile(sessionId);
|
|
589
595
|
if (!transcriptPath) {
|
|
590
596
|
debug(`No transcript found for session: ${sessionId}`);
|
|
591
597
|
return null;
|
|
@@ -730,7 +736,7 @@ var ContextProvider = class {
|
|
|
730
736
|
100,
|
|
731
737
|
Math.max(0, Math.round(contextLength / contextLimit * 100))
|
|
732
738
|
);
|
|
733
|
-
const usableLimit = Math.round(contextLimit * 0.
|
|
739
|
+
const usableLimit = Math.round(contextLimit * 0.75);
|
|
734
740
|
const usablePercentage = Math.min(
|
|
735
741
|
100,
|
|
736
742
|
Math.max(0, Math.round(contextLength / usableLimit * 100))
|
|
@@ -756,6 +762,191 @@ var ContextProvider = class {
|
|
|
756
762
|
}
|
|
757
763
|
};
|
|
758
764
|
|
|
765
|
+
// src/segments/metrics.ts
|
|
766
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
767
|
+
var MetricsProvider = class {
|
|
768
|
+
async loadTranscriptEntries(sessionId) {
|
|
769
|
+
try {
|
|
770
|
+
const transcriptPath = await findTranscriptFile(sessionId);
|
|
771
|
+
if (!transcriptPath) {
|
|
772
|
+
debug(`No transcript found for session: ${sessionId}`);
|
|
773
|
+
return [];
|
|
774
|
+
}
|
|
775
|
+
debug(`Loading transcript from: ${transcriptPath}`);
|
|
776
|
+
const content = await readFile2(transcriptPath, "utf-8");
|
|
777
|
+
const lines = content.trim().split("\n").filter((line) => line.trim());
|
|
778
|
+
const entries = [];
|
|
779
|
+
for (const line of lines) {
|
|
780
|
+
try {
|
|
781
|
+
const entry = JSON.parse(line);
|
|
782
|
+
entries.push(entry);
|
|
783
|
+
} catch (parseError) {
|
|
784
|
+
debug(`Failed to parse JSONL line: ${parseError}`);
|
|
785
|
+
continue;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
debug(`Loaded ${entries.length} transcript entries`);
|
|
789
|
+
return entries;
|
|
790
|
+
} catch (error) {
|
|
791
|
+
debug(`Error loading transcript for ${sessionId}:`, error);
|
|
792
|
+
return [];
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
calculateResponseTimes(entries) {
|
|
796
|
+
const userMessages = [];
|
|
797
|
+
const assistantMessages = [];
|
|
798
|
+
for (const entry of entries) {
|
|
799
|
+
if (!entry.timestamp) continue;
|
|
800
|
+
try {
|
|
801
|
+
const timestamp = new Date(entry.timestamp);
|
|
802
|
+
const messageType = entry.type || entry.message?.role || entry.message?.type;
|
|
803
|
+
if (messageType === "user" || messageType === "human") {
|
|
804
|
+
userMessages.push(timestamp);
|
|
805
|
+
debug(`Found user message at ${timestamp.toISOString()}`);
|
|
806
|
+
} else if (messageType === "assistant" || messageType === "ai") {
|
|
807
|
+
assistantMessages.push(timestamp);
|
|
808
|
+
debug(`Found assistant message at ${timestamp.toISOString()}`);
|
|
809
|
+
} else if (entry.message?.usage) {
|
|
810
|
+
assistantMessages.push(timestamp);
|
|
811
|
+
debug(
|
|
812
|
+
`Found assistant message with usage at ${timestamp.toISOString()}`
|
|
813
|
+
);
|
|
814
|
+
} else {
|
|
815
|
+
debug(
|
|
816
|
+
`Unknown message type: ${messageType}, has usage: ${!!entry.message?.usage}`
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
} catch {
|
|
820
|
+
continue;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
if (userMessages.length === 0 || assistantMessages.length === 0) {
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
const responseTimes = [];
|
|
827
|
+
for (const assistantTime of assistantMessages) {
|
|
828
|
+
const priorUsers = userMessages.filter(
|
|
829
|
+
(userTime) => userTime < assistantTime
|
|
830
|
+
);
|
|
831
|
+
if (priorUsers.length > 0) {
|
|
832
|
+
const userTime = new Date(
|
|
833
|
+
Math.max(...priorUsers.map((d) => d.getTime()))
|
|
834
|
+
);
|
|
835
|
+
const responseTime = (assistantTime.getTime() - userTime.getTime()) / 1e3;
|
|
836
|
+
if (responseTime > 0.1 && responseTime < 300) {
|
|
837
|
+
responseTimes.push(responseTime);
|
|
838
|
+
debug(`Valid response time: ${responseTime.toFixed(1)}s`);
|
|
839
|
+
} else {
|
|
840
|
+
debug(
|
|
841
|
+
`Rejected response time: ${responseTime.toFixed(1)}s (outside 0.1s-5m range)`
|
|
842
|
+
);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
if (responseTimes.length === 0) {
|
|
847
|
+
return null;
|
|
848
|
+
}
|
|
849
|
+
return responseTimes.reduce((sum, time) => sum + time, 0) / responseTimes.length;
|
|
850
|
+
}
|
|
851
|
+
calculateSessionDuration(entries) {
|
|
852
|
+
const timestamps = [];
|
|
853
|
+
for (const entry of entries) {
|
|
854
|
+
if (!entry.timestamp) continue;
|
|
855
|
+
try {
|
|
856
|
+
timestamps.push(new Date(entry.timestamp));
|
|
857
|
+
} catch {
|
|
858
|
+
continue;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
if (timestamps.length < 2) {
|
|
862
|
+
return null;
|
|
863
|
+
}
|
|
864
|
+
timestamps.sort((a, b) => a.getTime() - b.getTime());
|
|
865
|
+
const lastTimestamp = timestamps[timestamps.length - 1];
|
|
866
|
+
const firstTimestamp = timestamps[0];
|
|
867
|
+
if (!lastTimestamp || !firstTimestamp) {
|
|
868
|
+
return null;
|
|
869
|
+
}
|
|
870
|
+
const duration = (lastTimestamp.getTime() - firstTimestamp.getTime()) / 1e3;
|
|
871
|
+
return duration > 0 ? duration : null;
|
|
872
|
+
}
|
|
873
|
+
calculateMessageCount(entries) {
|
|
874
|
+
return entries.filter((entry) => {
|
|
875
|
+
const messageType = entry.type || entry.message?.role || entry.message?.type;
|
|
876
|
+
return messageType === "user" || messageType === "human";
|
|
877
|
+
}).length;
|
|
878
|
+
}
|
|
879
|
+
async calculateTotalCost(entries) {
|
|
880
|
+
let total = 0;
|
|
881
|
+
for (const entry of entries) {
|
|
882
|
+
if (typeof entry.costUSD === "number") {
|
|
883
|
+
total += entry.costUSD;
|
|
884
|
+
} else if (entry.message?.usage) {
|
|
885
|
+
const cost = await PricingService.calculateCostForEntry(entry);
|
|
886
|
+
total += cost;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return total;
|
|
890
|
+
}
|
|
891
|
+
calculateTotalTokens(entries) {
|
|
892
|
+
return entries.reduce((total, entry) => {
|
|
893
|
+
const usage = entry.message?.usage;
|
|
894
|
+
if (!usage) return total;
|
|
895
|
+
return total + (usage.input_tokens || 0) + (usage.output_tokens || 0) + (usage.cache_creation_input_tokens || 0) + (usage.cache_read_input_tokens || 0);
|
|
896
|
+
}, 0);
|
|
897
|
+
}
|
|
898
|
+
async getMetricsInfo(sessionId) {
|
|
899
|
+
try {
|
|
900
|
+
debug(`Starting metrics calculation for session: ${sessionId}`);
|
|
901
|
+
const entries = await this.loadTranscriptEntries(sessionId);
|
|
902
|
+
if (entries.length === 0) {
|
|
903
|
+
return {
|
|
904
|
+
responseTime: null,
|
|
905
|
+
sessionDuration: null,
|
|
906
|
+
messageCount: null,
|
|
907
|
+
costBurnRate: null,
|
|
908
|
+
tokenBurnRate: null
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
const responseTime = this.calculateResponseTimes(entries);
|
|
912
|
+
const sessionDuration = this.calculateSessionDuration(entries);
|
|
913
|
+
const messageCount = this.calculateMessageCount(entries);
|
|
914
|
+
let costBurnRate = null;
|
|
915
|
+
let tokenBurnRate = null;
|
|
916
|
+
if (sessionDuration && sessionDuration > 0) {
|
|
917
|
+
const hoursElapsed = sessionDuration / 3600;
|
|
918
|
+
const totalCost = await this.calculateTotalCost(entries);
|
|
919
|
+
const totalTokens = this.calculateTotalTokens(entries);
|
|
920
|
+
if (totalCost > 0) {
|
|
921
|
+
costBurnRate = totalCost / hoursElapsed;
|
|
922
|
+
}
|
|
923
|
+
if (totalTokens > 0) {
|
|
924
|
+
tokenBurnRate = totalTokens / hoursElapsed;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
debug(
|
|
928
|
+
`Metrics calculated: responseTime=${responseTime?.toFixed(2) || "null"}s, sessionDuration=${sessionDuration?.toFixed(0) || "null"}s, messageCount=${messageCount}`
|
|
929
|
+
);
|
|
930
|
+
return {
|
|
931
|
+
responseTime,
|
|
932
|
+
sessionDuration,
|
|
933
|
+
messageCount,
|
|
934
|
+
costBurnRate,
|
|
935
|
+
tokenBurnRate
|
|
936
|
+
};
|
|
937
|
+
} catch (error) {
|
|
938
|
+
debug(`Error calculating metrics for session ${sessionId}:`, error);
|
|
939
|
+
return {
|
|
940
|
+
responseTime: null,
|
|
941
|
+
sessionDuration: null,
|
|
942
|
+
messageCount: null,
|
|
943
|
+
costBurnRate: null,
|
|
944
|
+
tokenBurnRate: null
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
|
|
759
950
|
// src/utils/formatters.ts
|
|
760
951
|
function formatCost(cost) {
|
|
761
952
|
if (cost === null) return "$0.00";
|
|
@@ -914,6 +1105,60 @@ var SegmentRenderer = class {
|
|
|
914
1105
|
fgColor: colors.contextFg
|
|
915
1106
|
};
|
|
916
1107
|
}
|
|
1108
|
+
renderMetrics(metricsInfo, colors, config) {
|
|
1109
|
+
if (!metricsInfo) {
|
|
1110
|
+
return {
|
|
1111
|
+
text: `${this.symbols.metrics_response} new`,
|
|
1112
|
+
bgColor: colors.metricsBg,
|
|
1113
|
+
fgColor: colors.metricsFg
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
const parts = [];
|
|
1117
|
+
if (config?.showResponseTime !== false && metricsInfo.responseTime !== null) {
|
|
1118
|
+
const responseTime = metricsInfo.responseTime < 60 ? `${metricsInfo.responseTime.toFixed(1)}s` : `${(metricsInfo.responseTime / 60).toFixed(1)}m`;
|
|
1119
|
+
parts.push(`${this.symbols.metrics_response} ${responseTime}`);
|
|
1120
|
+
}
|
|
1121
|
+
if (config?.showDuration !== false && metricsInfo.sessionDuration !== null) {
|
|
1122
|
+
const duration = this.formatDuration(metricsInfo.sessionDuration);
|
|
1123
|
+
parts.push(`${this.symbols.metrics_duration} ${duration}`);
|
|
1124
|
+
}
|
|
1125
|
+
if (config?.showMessageCount !== false && metricsInfo.messageCount !== null) {
|
|
1126
|
+
parts.push(
|
|
1127
|
+
`${this.symbols.metrics_messages} ${metricsInfo.messageCount}`
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
if (config?.showCostBurnRate && metricsInfo.costBurnRate !== null) {
|
|
1131
|
+
const burnRate = metricsInfo.costBurnRate < 1 ? `${(metricsInfo.costBurnRate * 100).toFixed(0)}\xA2/h` : `$${metricsInfo.costBurnRate.toFixed(2)}/h`;
|
|
1132
|
+
parts.push(`${this.symbols.metrics_burn} ${burnRate}`);
|
|
1133
|
+
}
|
|
1134
|
+
if (config?.showTokenBurnRate && metricsInfo.tokenBurnRate !== null) {
|
|
1135
|
+
const tokenRate = formatTokens(Math.round(metricsInfo.tokenBurnRate));
|
|
1136
|
+
parts.push(`${this.symbols.metrics_burn} ${tokenRate}/h`);
|
|
1137
|
+
}
|
|
1138
|
+
if (parts.length === 0) {
|
|
1139
|
+
return {
|
|
1140
|
+
text: `${this.symbols.metrics_response} active`,
|
|
1141
|
+
bgColor: colors.metricsBg,
|
|
1142
|
+
fgColor: colors.metricsFg
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
return {
|
|
1146
|
+
text: parts.join(" "),
|
|
1147
|
+
bgColor: colors.metricsBg,
|
|
1148
|
+
fgColor: colors.metricsFg
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
formatDuration(seconds) {
|
|
1152
|
+
if (seconds < 60) {
|
|
1153
|
+
return `${seconds.toFixed(0)}s`;
|
|
1154
|
+
} else if (seconds < 3600) {
|
|
1155
|
+
return `${(seconds / 60).toFixed(0)}m`;
|
|
1156
|
+
} else if (seconds < 86400) {
|
|
1157
|
+
return `${(seconds / 3600).toFixed(1)}h`;
|
|
1158
|
+
} else {
|
|
1159
|
+
return `${(seconds / 86400).toFixed(1)}d`;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
917
1162
|
getDisplayDirectoryName(currentDir, projectDir) {
|
|
918
1163
|
if (projectDir && projectDir !== currentDir) {
|
|
919
1164
|
const projectName = projectDir.split("/").pop() || "project";
|
|
@@ -963,6 +1208,7 @@ var PowerlineRenderer = class {
|
|
|
963
1208
|
this.contextProvider = new ContextProvider();
|
|
964
1209
|
this.gitService = new GitService();
|
|
965
1210
|
this.tmuxService = new TmuxService();
|
|
1211
|
+
this.metricsProvider = new MetricsProvider();
|
|
966
1212
|
this.segmentRenderer = new SegmentRenderer(config, this.symbols);
|
|
967
1213
|
}
|
|
968
1214
|
symbols;
|
|
@@ -970,6 +1216,7 @@ var PowerlineRenderer = class {
|
|
|
970
1216
|
contextProvider;
|
|
971
1217
|
gitService;
|
|
972
1218
|
tmuxService;
|
|
1219
|
+
metricsProvider;
|
|
973
1220
|
segmentRenderer;
|
|
974
1221
|
needsUsageInfo() {
|
|
975
1222
|
return this.config.display.lines.some(
|
|
@@ -989,18 +1236,30 @@ var PowerlineRenderer = class {
|
|
|
989
1236
|
(line) => line.segments.context?.enabled
|
|
990
1237
|
);
|
|
991
1238
|
}
|
|
1239
|
+
needsMetricsInfo() {
|
|
1240
|
+
return this.config.display.lines.some(
|
|
1241
|
+
(line) => line.segments.metrics?.enabled
|
|
1242
|
+
);
|
|
1243
|
+
}
|
|
992
1244
|
async generateStatusline(hookData) {
|
|
993
1245
|
const usageInfo = this.needsUsageInfo() ? await this.usageProvider.getUsageInfo(hookData.session_id) : null;
|
|
994
1246
|
const contextInfo = this.needsContextInfo() ? this.contextProvider.calculateContextTokens(
|
|
995
1247
|
hookData.transcript_path,
|
|
996
1248
|
hookData.model?.id
|
|
997
1249
|
) : null;
|
|
1250
|
+
const metricsInfo = this.needsMetricsInfo() ? await this.metricsProvider.getMetricsInfo(hookData.session_id) : null;
|
|
998
1251
|
const lines = this.config.display.lines.map(
|
|
999
|
-
(lineConfig) => this.renderLine(
|
|
1252
|
+
(lineConfig) => this.renderLine(
|
|
1253
|
+
lineConfig,
|
|
1254
|
+
hookData,
|
|
1255
|
+
usageInfo,
|
|
1256
|
+
contextInfo,
|
|
1257
|
+
metricsInfo
|
|
1258
|
+
)
|
|
1000
1259
|
).filter((line) => line.length > 0);
|
|
1001
1260
|
return lines.join("\n");
|
|
1002
1261
|
}
|
|
1003
|
-
renderLine(lineConfig, hookData, usageInfo, contextInfo) {
|
|
1262
|
+
renderLine(lineConfig, hookData, usageInfo, contextInfo, metricsInfo) {
|
|
1004
1263
|
const colors = this.getThemeColors();
|
|
1005
1264
|
const currentDir = hookData.workspace?.current_dir || hookData.cwd || "/";
|
|
1006
1265
|
const segments = Object.entries(lineConfig.segments).filter(
|
|
@@ -1018,6 +1277,7 @@ var PowerlineRenderer = class {
|
|
|
1018
1277
|
hookData,
|
|
1019
1278
|
usageInfo,
|
|
1020
1279
|
contextInfo,
|
|
1280
|
+
metricsInfo,
|
|
1021
1281
|
colors,
|
|
1022
1282
|
currentDir
|
|
1023
1283
|
);
|
|
@@ -1032,7 +1292,7 @@ var PowerlineRenderer = class {
|
|
|
1032
1292
|
}
|
|
1033
1293
|
return line;
|
|
1034
1294
|
}
|
|
1035
|
-
renderSegment(segment, hookData, usageInfo, contextInfo, colors, currentDir) {
|
|
1295
|
+
renderSegment(segment, hookData, usageInfo, contextInfo, metricsInfo, colors, currentDir) {
|
|
1036
1296
|
switch (segment.type) {
|
|
1037
1297
|
case "directory":
|
|
1038
1298
|
return this.segmentRenderer.renderDirectory(hookData, colors);
|
|
@@ -1054,6 +1314,13 @@ var PowerlineRenderer = class {
|
|
|
1054
1314
|
case "context":
|
|
1055
1315
|
if (!this.needsContextInfo()) return null;
|
|
1056
1316
|
return this.segmentRenderer.renderContext(contextInfo, colors);
|
|
1317
|
+
case "metrics":
|
|
1318
|
+
const metricsConfig = segment.config;
|
|
1319
|
+
return this.segmentRenderer.renderMetrics(
|
|
1320
|
+
metricsInfo,
|
|
1321
|
+
colors,
|
|
1322
|
+
metricsConfig
|
|
1323
|
+
);
|
|
1057
1324
|
default:
|
|
1058
1325
|
return null;
|
|
1059
1326
|
}
|
|
@@ -1070,7 +1337,11 @@ var PowerlineRenderer = class {
|
|
|
1070
1337
|
git_ahead: "\u2191",
|
|
1071
1338
|
git_behind: "\u2193",
|
|
1072
1339
|
session_cost: "\u22A1",
|
|
1073
|
-
context_time: "\u25F7"
|
|
1340
|
+
context_time: "\u25F7",
|
|
1341
|
+
metrics_response: "\u29D6",
|
|
1342
|
+
metrics_duration: "\u29D7",
|
|
1343
|
+
metrics_messages: "\u27D0",
|
|
1344
|
+
metrics_burn: "\u27E2"
|
|
1074
1345
|
};
|
|
1075
1346
|
}
|
|
1076
1347
|
getThemeColors() {
|
|
@@ -1105,7 +1376,9 @@ var PowerlineRenderer = class {
|
|
|
1105
1376
|
tmuxBg: hexToAnsi(colorTheme.tmux.bg, true),
|
|
1106
1377
|
tmuxFg: hexToAnsi(colorTheme.tmux.fg, false),
|
|
1107
1378
|
contextBg: hexToAnsi(colorTheme.context.bg, true),
|
|
1108
|
-
contextFg: hexToAnsi(colorTheme.context.fg, false)
|
|
1379
|
+
contextFg: hexToAnsi(colorTheme.context.fg, false),
|
|
1380
|
+
metricsBg: hexToAnsi(colorTheme.metrics.bg, true),
|
|
1381
|
+
metricsFg: hexToAnsi(colorTheme.metrics.fg, false)
|
|
1109
1382
|
};
|
|
1110
1383
|
}
|
|
1111
1384
|
getSegmentBgColor(segmentType, colors) {
|
|
@@ -1122,6 +1395,8 @@ var PowerlineRenderer = class {
|
|
|
1122
1395
|
return colors.tmuxBg;
|
|
1123
1396
|
case "context":
|
|
1124
1397
|
return colors.contextBg;
|
|
1398
|
+
case "metrics":
|
|
1399
|
+
return colors.metricsBg;
|
|
1125
1400
|
default:
|
|
1126
1401
|
return colors.modeBg;
|
|
1127
1402
|
}
|
|
@@ -1160,7 +1435,8 @@ var DEFAULT_CONFIG = {
|
|
|
1160
1435
|
model: { enabled: true },
|
|
1161
1436
|
session: { enabled: true, type: "tokens" },
|
|
1162
1437
|
tmux: { enabled: false },
|
|
1163
|
-
context: { enabled: true }
|
|
1438
|
+
context: { enabled: true },
|
|
1439
|
+
metrics: { enabled: false }
|
|
1164
1440
|
}
|
|
1165
1441
|
}
|
|
1166
1442
|
]
|
|
@@ -1245,6 +1521,18 @@ function loadEnvConfig() {
|
|
|
1245
1521
|
config.usageType = usageType;
|
|
1246
1522
|
}
|
|
1247
1523
|
}
|
|
1524
|
+
if (process.env.CLAUDE_POWERLINE_SESSION_BUDGET) {
|
|
1525
|
+
const sessionBudget = parseFloat(process.env.CLAUDE_POWERLINE_SESSION_BUDGET);
|
|
1526
|
+
if (!isNaN(sessionBudget) && sessionBudget > 0) {
|
|
1527
|
+
config.budget = {
|
|
1528
|
+
...config.budget,
|
|
1529
|
+
session: {
|
|
1530
|
+
...DEFAULT_CONFIG.budget?.session,
|
|
1531
|
+
amount: sessionBudget
|
|
1532
|
+
}
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1248
1536
|
return config;
|
|
1249
1537
|
}
|
|
1250
1538
|
function getConfigPathFromEnv() {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/colors.ts","../src/themes/dark.ts","../src/themes/light.ts","../src/themes/nord.ts","../src/themes/tokyo-night.ts","../src/themes/rose-pine.ts","../src/themes/index.ts","../src/segments/git.ts","../src/utils/logger.ts","../src/segments/tmux.ts","../src/segments/session.ts","../src/segments/pricing.ts","../src/segments/context.ts","../src/utils/formatters.ts","../src/utils/budget.ts","../src/segments/renderer.ts","../src/powerline.ts","../src/config/loader.ts","../src/config/defaults.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport process from \"node:process\";\nimport path from \"node:path\";\nimport fs from \"node:fs\";\nimport { execSync } from \"node:child_process\";\nimport os from \"node:os\";\nimport { json } from \"node:stream/consumers\";\nimport { PowerlineRenderer } from \"./powerline\";\nimport { loadConfigFromCLI } from \"./config/loader\";\nimport { debug } from \"./utils/logger\";\nexport interface ClaudeHookData {\n hook_event_name: string;\n session_id: string;\n transcript_path: string;\n cwd: string;\n model: {\n id: string;\n display_name: string;\n };\n workspace: {\n current_dir: string;\n project_dir: string;\n };\n}\n\nasync function installFonts(): Promise<void> {\n try {\n const platform = os.platform();\n let fontDir: string;\n\n if (platform === \"darwin\") {\n fontDir = path.join(os.homedir(), \"Library\", \"Fonts\");\n } else if (platform === \"linux\") {\n fontDir = path.join(os.homedir(), \".local\", \"share\", \"fonts\");\n } else if (platform === \"win32\") {\n fontDir = path.join(\n os.homedir(),\n \"AppData\",\n \"Local\",\n \"Microsoft\",\n \"Windows\",\n \"Fonts\"\n );\n } else {\n console.log(\"Unsupported platform for font installation\");\n return;\n }\n\n if (!fs.existsSync(fontDir)) {\n fs.mkdirSync(fontDir, { recursive: true });\n }\n\n console.log(\"📦 Installing Powerline Fonts...\");\n console.log(\"Downloading from https://github.com/powerline/fonts\");\n\n const tempDir = path.join(os.tmpdir(), \"powerline-fonts\");\n\n try {\n if (fs.existsSync(tempDir)) {\n fs.rmSync(tempDir, { recursive: true, force: true });\n }\n\n console.log(\"Cloning powerline fonts repository...\");\n execSync(\n \"git clone --depth=1 https://github.com/powerline/fonts.git powerline-fonts\",\n {\n stdio: \"inherit\",\n cwd: os.tmpdir(),\n }\n );\n\n console.log(\"Installing fonts...\");\n const installScript = path.join(tempDir, \"install.sh\");\n\n if (fs.existsSync(installScript)) {\n fs.chmodSync(installScript, 0o755);\n execSync(\"./install.sh\", { stdio: \"inherit\", cwd: tempDir });\n } else {\n throw new Error(\n \"Install script not found in powerline fonts repository\"\n );\n }\n\n console.log(\"✅ Powerline fonts installation complete!\");\n console.log(\n \"Please restart your terminal and set your terminal font to a powerline font.\"\n );\n console.log(\n \"Popular choices: Source Code Pro Powerline, DejaVu Sans Mono Powerline, Ubuntu Mono Powerline\"\n );\n } finally {\n if (fs.existsSync(tempDir)) {\n fs.rmSync(tempDir, { recursive: true, force: true });\n }\n }\n } catch (error) {\n console.error(\n \"Error installing fonts:\",\n error instanceof Error ? error.message : String(error)\n );\n console.log(\n \"💡 You can manually install fonts from: https://github.com/powerline/fonts\"\n );\n }\n}\n\nasync function main(): Promise<void> {\n try {\n const showHelp =\n process.argv.includes(\"--help\") || process.argv.includes(\"-h\");\n const installFontsFlag = process.argv.includes(\"--install-fonts\");\n\n if (installFontsFlag) {\n await installFonts();\n process.exit(0);\n }\n\n if (showHelp) {\n console.log(`\nclaude-powerline - Beautiful powerline statusline for Claude Code\n\nUsage: claude-powerline [options]\n\nStandalone Commands:\n --install-fonts Install powerline fonts to system\n -h, --help Show this help\n\nDebugging:\n CLAUDE_POWERLINE_DEBUG=1 Enable debug logging for troubleshooting\n\nClaude Code Options (for settings.json):\n --theme=THEME Set theme: dark, light, nord, tokyo-night, rose-pine, custom\n --style=STYLE Set separator style: minimal, powerline\n --usage=TYPE Usage display: cost, tokens, both, breakdown\n --session-budget=AMOUNT Set session budget for percentage tracking\n --config=PATH Use custom config file path\n\nConfiguration:\n Config files are loaded in this order (highest priority first):\n 1. CLI arguments (--theme, --style, --usage, --config)\n 2. Environment variables (CLAUDE_POWERLINE_THEME, CLAUDE_POWERLINE_STYLE, CLAUDE_POWERLINE_USAGE_TYPE, CLAUDE_POWERLINE_CONFIG)\n 3. ./.claude-powerline.json (project)\n 4. ~/.claude/claude-powerline.json (user)\n 5. ~/.config/claude-powerline/config.json (XDG)\n\nCreating a config file:\n Copy example from: https://github.com/Owloops/claude-powerline/blob/main/.claude-powerline.json\n\nUsage in Claude Code settings.json:\n{\n \"statusLine\": {\n \"type\": \"command\",\n \"command\": \"claude-powerline\",\n \"padding\": 0\n }\n}\n`);\n process.exit(0);\n }\n\n if (process.stdin.isTTY === true) {\n console.error(`Error: This tool requires input from Claude Code\n\nclaude-powerline is designed to be used as a Claude Code statusLine command.\nIt reads hook data from stdin and outputs formatted statusline.\n\nAdd to ~/.claude/settings.json:\n{\n \"statusLine\": {\n \"type\": \"command\",\n \"command\": \"claude-powerline --style=powerline\"\n }\n}\n\nRun with --help for more options.\n\nTo test output manually:\necho '{\"session_id\":\"test-session\",\"workspace\":{\"project_dir\":\"/path/to/project\"},\"model\":{\"id\":\"claude-3-5-sonnet\",\"display_name\":\"Claude\"}}' | claude-powerline --style=powerline`);\n process.exit(1);\n }\n\n debug(`Working directory: ${process.cwd()}`);\n debug(`Process args:`, process.argv);\n\n const hookData = (await json(process.stdin)) as ClaudeHookData;\n debug(`Received hook data:`, JSON.stringify(hookData, null, 2));\n\n if (!hookData) {\n console.error(\"Error: No input data received from stdin\");\n console.log(`\nclaude-powerline - Beautiful powerline statusline for Claude Code\n\nUsage: claude-powerline [options]\n\nOptions:\n --theme=THEME Set theme: dark, light, nord, tokyo-night, rose-pine, custom\n --style=STYLE Set separator style: minimal, powerline\n --usage=TYPE Usage display: cost, tokens, both, breakdown\n --session-budget=AMOUNT Set session budget for percentage tracking\n --config=PATH Use custom config file path\n --install-fonts Install powerline fonts to system\n -h, --help Show this help\n\nSee example config at: https://github.com/Owloops/claude-powerline/blob/main/.claude-powerline.json\n`);\n process.exit(1);\n }\n\n const projectDir = hookData.workspace?.project_dir;\n const config = loadConfigFromCLI(process.argv, projectDir);\n const renderer = new PowerlineRenderer(config);\n const statusline = await renderer.generateStatusline(hookData);\n\n console.log(statusline);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(\"Error generating statusline:\", errorMessage);\n process.exit(1);\n }\n}\n\nmain();\n","export function hexToAnsi(hex: string, isBackground: boolean): string {\n const r = parseInt(hex.slice(1, 3), 16);\n const g = parseInt(hex.slice(3, 5), 16);\n const b = parseInt(hex.slice(5, 7), 16);\n return `\\x1b[${isBackground ? \"48\" : \"38\"};2;${r};${g};${b}m`;\n}\n\nexport function extractBgToFg(ansiCode: string): string {\n const match = ansiCode.match(/48;2;(\\d+);(\\d+);(\\d+)/);\n if (match) {\n return `\\x1b[38;2;${match[1]};${match[2]};${match[3]}m`;\n }\n return ansiCode.replace(\"48\", \"38\");\n}\n","import type { ColorTheme } from \"./index\";\n\nexport const darkTheme: ColorTheme = {\n directory: { bg: \"#8b4513\", fg: \"#ffffff\" },\n git: { bg: \"#404040\", fg: \"#ffffff\" },\n model: { bg: \"#2d2d2d\", fg: \"#ffffff\" },\n session: { bg: \"#202020\", fg: \"#00ffff\" },\n tmux: { bg: \"#2f4f2f\", fg: \"#90ee90\" },\n context: { bg: \"#4a5568\", fg: \"#cbd5e0\" },\n};\n","import type { ColorTheme } from \"./index\";\n\nexport const lightTheme: ColorTheme = {\n directory: { bg: \"#ff6b47\", fg: \"#ffffff\" },\n git: { bg: \"#4fb3d9\", fg: \"#ffffff\" },\n model: { bg: \"#87ceeb\", fg: \"#000000\" },\n session: { bg: \"#da70d6\", fg: \"#ffffff\" },\n tmux: { bg: \"#32cd32\", fg: \"#ffffff\" },\n context: { bg: \"#718096\", fg: \"#ffffff\" },\n};\n","import type { ColorTheme } from \"./index\";\n\nexport const nordTheme: ColorTheme = {\n directory: { bg: \"#434c5e\", fg: \"#d8dee9\" },\n git: { bg: \"#3b4252\", fg: \"#a3be8c\" },\n model: { bg: \"#4c566a\", fg: \"#81a1c1\" },\n session: { bg: \"#2e3440\", fg: \"#88c0d0\" },\n tmux: { bg: \"#2e3440\", fg: \"#8fbcbb\" },\n context: { bg: \"#5e81ac\", fg: \"#eceff4\" },\n};\n","import type { ColorTheme } from \"./index\";\n\nexport const tokyoNightTheme: ColorTheme = {\n directory: { bg: \"#2f334d\", fg: \"#82aaff\" },\n git: { bg: \"#1e2030\", fg: \"#c3e88d\" },\n model: { bg: \"#191b29\", fg: \"#fca7ea\" },\n session: { bg: \"#222436\", fg: \"#86e1fc\" },\n tmux: { bg: \"#191b29\", fg: \"#4fd6be\" },\n context: { bg: \"#414868\", fg: \"#c0caf5\" },\n};\n","import type { ColorTheme } from \"./index\";\n\nexport const rosePineTheme: ColorTheme = {\n directory: { bg: \"#26233a\", fg: \"#c4a7e7\" },\n git: { bg: \"#1f1d2e\", fg: \"#9ccfd8\" },\n model: { bg: \"#191724\", fg: \"#ebbcba\" },\n session: { bg: \"#26233a\", fg: \"#f6c177\" },\n tmux: { bg: \"#26233a\", fg: \"#908caa\" },\n context: { bg: \"#393552\", fg: \"#e0def4\" },\n};\n","import { darkTheme } from \"./dark\";\nimport { lightTheme } from \"./light\";\nimport { nordTheme } from \"./nord\";\nimport { tokyoNightTheme } from \"./tokyo-night\";\nimport { rosePineTheme } from \"./rose-pine\";\n\nexport interface SegmentColor {\n bg: string;\n fg: string;\n}\n\nexport interface ColorTheme {\n directory: SegmentColor;\n git: SegmentColor;\n model: SegmentColor;\n session: SegmentColor;\n tmux: SegmentColor;\n context: SegmentColor;\n}\n\nexport interface PowerlineColors {\n reset: string;\n modeBg: string;\n modeFg: string;\n gitBg: string;\n gitFg: string;\n modelBg: string;\n modelFg: string;\n sessionBg: string;\n sessionFg: string;\n tmuxBg: string;\n tmuxFg: string;\n contextBg: string;\n contextFg: string;\n}\n\nexport const BUILT_IN_THEMES: Record<string, ColorTheme> = {\n dark: darkTheme,\n light: lightTheme,\n nord: nordTheme,\n \"tokyo-night\": tokyoNightTheme,\n \"rose-pine\": rosePineTheme,\n};\n\nexport function getTheme(themeName: string): ColorTheme | null {\n return BUILT_IN_THEMES[themeName] || null;\n}\n\nexport { darkTheme, lightTheme, nordTheme, tokyoNightTheme, rosePineTheme };\n","import { execSync } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { debug } from \"../utils/logger\";\n\nexport interface GitInfo {\n branch: string;\n status: \"clean\" | \"dirty\" | \"conflicts\";\n ahead: number;\n behind: number;\n sha?: string;\n}\n\nexport class GitService {\n private isGitRepo(workingDir: string): boolean {\n try {\n return fs.existsSync(path.join(workingDir, \".git\"));\n } catch {\n return false;\n }\n }\n\n getGitInfo(workingDir: string, showSha = false): GitInfo | null {\n if (!this.isGitRepo(workingDir)) {\n return {\n branch: \"detached\",\n status: \"clean\",\n ahead: 0,\n behind: 0,\n sha: undefined,\n };\n }\n\n try {\n const branch = this.getBranch(workingDir);\n const status = this.getStatus(workingDir);\n const { ahead, behind } = this.getAheadBehind(workingDir);\n const sha = showSha ? this.getSha(workingDir) || undefined : undefined;\n\n return {\n branch: branch || \"detached\",\n status,\n ahead,\n behind,\n sha,\n };\n } catch {\n return null;\n }\n }\n\n private getBranch(workingDir: string): string | null {\n try {\n return (\n execSync(\"git branch --show-current\", {\n cwd: workingDir,\n encoding: \"utf8\",\n timeout: 1000,\n }).trim() || null\n );\n } catch (error) {\n debug(`Git branch command failed in ${workingDir}:`, error);\n return null;\n }\n }\n\n private getStatus(workingDir: string): \"clean\" | \"dirty\" | \"conflicts\" {\n try {\n const gitStatus = execSync(\"git status --porcelain\", {\n cwd: workingDir,\n encoding: \"utf8\",\n timeout: 1000,\n }).trim();\n\n if (!gitStatus) return \"clean\";\n\n if (\n gitStatus.includes(\"UU\") ||\n gitStatus.includes(\"AA\") ||\n gitStatus.includes(\"DD\")\n ) {\n return \"conflicts\";\n }\n\n return \"dirty\";\n } catch (error) {\n debug(`Git status command failed in ${workingDir}:`, error);\n return \"clean\";\n }\n }\n\n private getAheadBehind(workingDir: string): {\n ahead: number;\n behind: number;\n } {\n try {\n const aheadResult = execSync(\"git rev-list --count @{u}..HEAD\", {\n cwd: workingDir,\n encoding: \"utf8\",\n timeout: 1000,\n }).trim();\n\n const behindResult = execSync(\"git rev-list --count HEAD..@{u}\", {\n cwd: workingDir,\n encoding: \"utf8\",\n timeout: 1000,\n }).trim();\n\n return {\n ahead: parseInt(aheadResult) || 0,\n behind: parseInt(behindResult) || 0,\n };\n } catch (error) {\n debug(`Git ahead/behind command failed in ${workingDir}:`, error);\n return { ahead: 0, behind: 0 };\n }\n }\n\n private getSha(workingDir: string): string | null {\n try {\n const sha = execSync(\"git rev-parse --short=7 HEAD\", {\n cwd: workingDir,\n encoding: \"utf8\",\n timeout: 1000,\n }).trim();\n\n return sha || null;\n } catch {\n return null;\n }\n }\n}","const debug = (message: string, ...args: any[]): void => {\n if (process.env.CLAUDE_POWERLINE_DEBUG) {\n console.error(`[DEBUG] ${message}`, ...args);\n }\n};\n\nexport { debug };\n","import { execSync } from \"node:child_process\";\nimport { debug } from \"../utils/logger\";\n\nexport class TmuxService {\n getSessionId(): string | null {\n try {\n if (!process.env.TMUX_PANE) {\n debug(`TMUX_PANE not set, not in tmux session`);\n return null;\n }\n\n debug(`Getting tmux session ID, TMUX_PANE: ${process.env.TMUX_PANE}`);\n\n const sessionId = execSync(\"tmux display-message -p '#S'\", {\n encoding: \"utf8\",\n timeout: 1000,\n }).trim();\n\n debug(`Tmux session ID: ${sessionId || \"empty\"}`);\n\n return sessionId || null;\n } catch (error) {\n debug(`Error getting tmux session ID:`, error);\n return null;\n }\n }\n\n isInTmux(): boolean {\n return !!process.env.TMUX_PANE;\n }\n}","import { readFile } from \"node:fs/promises\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { debug } from \"../utils/logger\";\nimport { PricingService } from \"./pricing\";\n\nexport interface SessionUsageEntry {\n timestamp: string;\n message: {\n usage: {\n input_tokens: number;\n output_tokens: number;\n cache_creation_input_tokens?: number;\n cache_read_input_tokens?: number;\n };\n };\n costUSD?: number;\n}\n\nexport interface SessionUsage {\n totalCost: number;\n entries: SessionUsageEntry[];\n}\n\nexport interface TokenBreakdown {\n input: number;\n output: number;\n cacheCreation: number;\n cacheRead: number;\n}\n\nexport interface SessionInfo {\n cost: number | null;\n tokens: number | null;\n tokenBreakdown: TokenBreakdown | null;\n}\n\nexport interface UsageInfo {\n session: SessionInfo;\n}\n\nexport class SessionProvider {\n private getClaudePaths(): string[] {\n const paths: string[] = [];\n \n const homeDir = homedir();\n const defaultPath = join(homeDir, \".claude\");\n \n if (existsSync(defaultPath)) {\n paths.push(defaultPath);\n }\n \n return paths;\n }\n\n private async findProjectPaths(claudePaths: string[]): Promise<string[]> {\n const projectPaths: string[] = [];\n \n for (const claudePath of claudePaths) {\n const projectsDir = join(claudePath, \"projects\");\n \n if (existsSync(projectsDir)) {\n try {\n const { readdir } = await import(\"node:fs/promises\");\n const entries = await readdir(projectsDir, { withFileTypes: true });\n \n for (const entry of entries) {\n if (entry.isDirectory()) {\n const projectPath = join(projectsDir, entry.name);\n projectPaths.push(projectPath);\n }\n }\n } catch (error) {\n debug(`Failed to read projects directory ${projectsDir}:`, error);\n }\n }\n }\n \n return projectPaths;\n }\n\n private async findTranscriptFile(sessionId: string): Promise<string | null> {\n const claudePaths = this.getClaudePaths();\n const projectPaths = await this.findProjectPaths(claudePaths);\n \n for (const projectPath of projectPaths) {\n const transcriptPath = join(projectPath, `${sessionId}.jsonl`);\n if (existsSync(transcriptPath)) {\n return transcriptPath;\n }\n }\n \n return null;\n }\n\n async getSessionUsage(sessionId: string): Promise<SessionUsage | null> {\n try {\n const transcriptPath = await this.findTranscriptFile(sessionId);\n if (!transcriptPath) {\n debug(`No transcript found for session: ${sessionId}`);\n return null;\n }\n\n debug(`Found transcript at: ${transcriptPath}`);\n \n const content = await readFile(transcriptPath, 'utf-8');\n const lines = content.trim().split('\\n').filter(line => line.trim());\n \n if (lines.length === 0) {\n return { totalCost: 0, entries: [] };\n }\n\n const entries: SessionUsageEntry[] = [];\n let totalCost = 0;\n\n for (const line of lines) {\n try {\n const entry = JSON.parse(line) as Record<string, unknown>;\n \n if (entry.message && typeof entry.message === 'object') {\n const message = entry.message as Record<string, unknown>;\n if (message.usage && typeof message.usage === 'object') {\n const sessionEntry: SessionUsageEntry = {\n timestamp: (entry.timestamp as string) || new Date().toISOString(),\n message: {\n usage: message.usage as SessionUsageEntry['message']['usage']\n }\n };\n\n if (typeof entry.costUSD === 'number') {\n sessionEntry.costUSD = entry.costUSD;\n totalCost += entry.costUSD;\n } else {\n const cost = await PricingService.calculateCostForEntry(entry);\n sessionEntry.costUSD = cost;\n totalCost += cost;\n }\n\n entries.push(sessionEntry);\n }\n }\n } catch (parseError) {\n debug(`Failed to parse JSONL line: ${parseError}`);\n continue;\n }\n }\n\n debug(`Parsed ${entries.length} usage entries, total cost: $${totalCost.toFixed(4)}`);\n return { totalCost, entries };\n\n } catch (error) {\n debug(`Error reading session usage for ${sessionId}:`, error);\n return null;\n }\n }\n\n calculateTokenBreakdown(entries: SessionUsageEntry[]): TokenBreakdown {\n return entries.reduce(\n (breakdown, entry) => ({\n input: breakdown.input + (entry.message.usage.input_tokens || 0),\n output: breakdown.output + (entry.message.usage.output_tokens || 0),\n cacheCreation: breakdown.cacheCreation + (entry.message.usage.cache_creation_input_tokens || 0),\n cacheRead: breakdown.cacheRead + (entry.message.usage.cache_read_input_tokens || 0),\n }),\n { input: 0, output: 0, cacheCreation: 0, cacheRead: 0 }\n );\n }\n\n async getSessionInfo(sessionId: string): Promise<SessionInfo> {\n const sessionUsage = await this.getSessionUsage(sessionId);\n \n if (!sessionUsage || sessionUsage.entries.length === 0) {\n return { cost: null, tokens: null, tokenBreakdown: null };\n }\n\n const tokenBreakdown = this.calculateTokenBreakdown(sessionUsage.entries);\n const totalTokens = tokenBreakdown.input + tokenBreakdown.output + \n tokenBreakdown.cacheCreation + tokenBreakdown.cacheRead;\n\n return {\n cost: sessionUsage.totalCost,\n tokens: totalTokens,\n tokenBreakdown,\n };\n }\n}\n\nexport class UsageProvider {\n private sessionProvider = new SessionProvider();\n\n async getUsageInfo(sessionId: string): Promise<UsageInfo> {\n try {\n debug(`Starting usage info retrieval for session: ${sessionId}`);\n \n const sessionInfo = await this.sessionProvider.getSessionInfo(sessionId);\n \n return {\n session: sessionInfo,\n };\n } catch (error) {\n debug(`Error getting usage info for session ${sessionId}:`, error);\n return {\n session: { cost: null, tokens: null, tokenBreakdown: null },\n };\n }\n }\n}","import { debug } from \"../utils/logger\";\n\n\nexport interface ModelPricing {\n name: string;\n input: number;\n cache_write_5m: number;\n cache_write_1h: number;\n cache_read: number;\n output: number;\n}\nconst OFFLINE_PRICING_DATA: Record<string, ModelPricing> = {\n \"claude-3-haiku-20240307\": {\n name: \"Claude 3 Haiku\",\n input: 0.25,\n output: 1.25,\n cache_write_5m: 0.30,\n cache_write_1h: 0.50,\n cache_read: 0.03\n },\n \"claude-3-5-haiku-20241022\": {\n name: \"Claude 3.5 Haiku\",\n input: 0.80,\n output: 4.00,\n cache_write_5m: 1.00,\n cache_write_1h: 1.60,\n cache_read: 0.08\n },\n \"claude-3-5-haiku-latest\": {\n name: \"Claude 3.5 Haiku Latest\",\n input: 1.00,\n output: 5.00,\n cache_write_5m: 1.25,\n cache_write_1h: 2.00,\n cache_read: 0.10\n },\n \"claude-3-opus-latest\": {\n name: \"Claude 3 Opus Latest\",\n input: 15.00,\n output: 75.00,\n cache_write_5m: 18.75,\n cache_write_1h: 30.00,\n cache_read: 1.50\n },\n \"claude-3-opus-20240229\": {\n name: \"Claude 3 Opus\",\n input: 15.00,\n output: 75.00,\n cache_write_5m: 18.75,\n cache_write_1h: 30.00,\n cache_read: 1.50\n },\n \"claude-3-5-sonnet-latest\": {\n name: \"Claude 3.5 Sonnet Latest\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n },\n \"claude-3-5-sonnet-20240620\": {\n name: \"Claude 3.5 Sonnet\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n },\n \"claude-3-5-sonnet-20241022\": {\n name: \"Claude 3.5 Sonnet\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n },\n \"claude-opus-4-20250514\": {\n name: \"Claude Opus 4\",\n input: 15.00,\n output: 75.00,\n cache_write_5m: 18.75,\n cache_write_1h: 30.00,\n cache_read: 1.50\n },\n \"claude-opus-4-1\": {\n name: \"Claude Opus 4.1\",\n input: 15.00,\n output: 75.00,\n cache_write_5m: 18.75,\n cache_write_1h: 30.00,\n cache_read: 1.50\n },\n \"claude-opus-4-1-20250805\": {\n name: \"Claude Opus 4.1\",\n input: 15.00,\n output: 75.00,\n cache_write_5m: 18.75,\n cache_write_1h: 30.00,\n cache_read: 1.50\n },\n \"claude-sonnet-4-20250514\": {\n name: \"Claude Sonnet 4\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n },\n \"claude-4-opus-20250514\": {\n name: \"Claude 4 Opus\",\n input: 15.00,\n output: 75.00,\n cache_write_5m: 18.75,\n cache_write_1h: 30.00,\n cache_read: 1.50\n },\n \"claude-4-sonnet-20250514\": {\n name: \"Claude 4 Sonnet\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n },\n \"claude-3-7-sonnet-latest\": {\n name: \"Claude 3.7 Sonnet Latest\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n },\n \"claude-3-7-sonnet-20250219\": {\n name: \"Claude 3.7 Sonnet\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n }\n};\n\nexport class PricingService {\n private static memoryCache: Map<string, { data: Record<string, ModelPricing>; timestamp: number }> = new Map();\n private static readonly CACHE_TTL = 24 * 60 * 60 * 1000;\n private static readonly GITHUB_PRICING_URL = \"https://raw.githubusercontent.com/Owloops/claude-powerline/main/pricing.json\";\n\n private static getCacheFilePath(): string {\n const { homedir } = require('os');\n const { join } = require('path');\n const { mkdirSync } = require('fs');\n \n const cacheDir = join(homedir(), '.claude', 'cache');\n try {\n mkdirSync(cacheDir, { recursive: true });\n } catch {}\n \n return join(cacheDir, 'pricing.json');\n }\n\n private static loadDiskCache(): { data: Record<string, ModelPricing>; timestamp: number } | null {\n try {\n const { readFileSync } = require('fs');\n const cacheFile = this.getCacheFilePath();\n const content = readFileSync(cacheFile, 'utf-8');\n const cached = JSON.parse(content);\n \n if (cached && cached.data && cached.timestamp) {\n return cached;\n }\n } catch {}\n return null;\n }\n\n private static saveDiskCache(data: Record<string, ModelPricing>): void {\n try {\n const { writeFileSync } = require('fs');\n const cacheFile = this.getCacheFilePath();\n const cacheData = { data, timestamp: Date.now() };\n writeFileSync(cacheFile, JSON.stringify(cacheData));\n } catch (error) {\n debug('Failed to save pricing cache to disk:', error);\n }\n }\n\n static async getCurrentPricing(): Promise<Record<string, ModelPricing>> {\n const now = Date.now();\n\n const memCached = this.memoryCache.get('pricing');\n if (memCached && now - memCached.timestamp < this.CACHE_TTL) {\n debug(`Using memory cached pricing data for ${Object.keys(memCached.data).length} models`);\n return memCached.data;\n }\n\n const diskCached = this.loadDiskCache();\n if (diskCached && now - diskCached.timestamp < this.CACHE_TTL) {\n this.memoryCache.set('pricing', diskCached);\n debug(`Using disk cached pricing data for ${Object.keys(diskCached.data).length} models`);\n return diskCached.data;\n }\n\n try {\n const response = await globalThis.fetch(this.GITHUB_PRICING_URL, {\n headers: {\n 'User-Agent': 'claude-powerline',\n 'Cache-Control': 'no-cache'\n }\n });\n\n if (response.ok) {\n const data = await response.json();\n \n const dataObj = data as Record<string, unknown>;\n const meta = dataObj._meta as { updated?: string } | undefined;\n \n const pricingData: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(dataObj)) {\n if (key !== '_meta') {\n pricingData[key] = value;\n }\n }\n \n if (this.validatePricingData(pricingData)) {\n this.memoryCache.set('pricing', { data: pricingData, timestamp: now });\n this.saveDiskCache(pricingData);\n debug(`Fetched fresh pricing from GitHub for ${Object.keys(pricingData).length} models`);\n debug(`Pricing last updated: ${meta?.updated || 'unknown'}`);\n return pricingData;\n }\n }\n } catch (error) {\n debug('Failed to fetch pricing from GitHub, using fallback:', error);\n }\n\n if (diskCached) {\n this.memoryCache.set('pricing', diskCached);\n debug(`Using stale cached pricing data for ${Object.keys(diskCached.data).length} models`);\n return diskCached.data;\n }\n\n debug(`Using offline pricing data for ${Object.keys(OFFLINE_PRICING_DATA).length} models`);\n return OFFLINE_PRICING_DATA;\n }\n\n private static validatePricingData(data: unknown): data is Record<string, ModelPricing> {\n if (!data || typeof data !== 'object') return false;\n \n for (const [, value] of Object.entries(data)) {\n if (!value || typeof value !== 'object') return false;\n const pricing = value as Record<string, unknown>;\n \n if (typeof pricing.input !== 'number' || \n typeof pricing.output !== 'number' ||\n typeof pricing.cache_read !== 'number') {\n return false;\n }\n }\n \n return true;\n }\n\n static async getModelPricing(modelId: string): Promise<ModelPricing> {\n const allPricing = await this.getCurrentPricing();\n \n if (allPricing[modelId]) {\n return allPricing[modelId];\n }\n\n return this.fuzzyMatchModel(modelId, allPricing);\n }\n\n\n private static fuzzyMatchModel(modelId: string, allPricing: Record<string, ModelPricing>): ModelPricing {\n const lowerModelId = modelId.toLowerCase();\n \n for (const [key, pricing] of Object.entries(allPricing)) {\n if (key.toLowerCase() === lowerModelId) {\n return pricing;\n }\n }\n const patterns = [\n { pattern: ['opus-4-1', 'claude-opus-4-1'], fallback: 'claude-opus-4-1-20250805' },\n { pattern: ['opus-4', 'claude-opus-4'], fallback: 'claude-opus-4-20250514' },\n { pattern: ['sonnet-4', 'claude-sonnet-4'], fallback: 'claude-sonnet-4-20250514' },\n { pattern: ['sonnet-3.7', '3-7-sonnet'], fallback: 'claude-3-7-sonnet-20250219' },\n { pattern: ['3-5-sonnet', 'sonnet-3.5'], fallback: 'claude-3-5-sonnet-20241022' },\n { pattern: ['3-5-haiku', 'haiku-3.5'], fallback: 'claude-3-5-haiku-20241022' },\n { pattern: ['haiku', '3-haiku'], fallback: 'claude-3-haiku-20240307' },\n { pattern: ['opus'], fallback: 'claude-opus-4-20250514' },\n { pattern: ['sonnet'], fallback: 'claude-3-5-sonnet-20241022' },\n ];\n\n for (const { pattern, fallback } of patterns) {\n if (pattern.some(p => lowerModelId.includes(p))) {\n if (allPricing[fallback]) {\n return allPricing[fallback];\n }\n }\n }\n\n return allPricing['claude-3-5-sonnet-20241022'] || {\n name: `${modelId} (Unknown Model)`,\n input: 3.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30,\n output: 15.00\n };\n }\n\n static async calculateCostForEntry(entry: Record<string, unknown>): Promise<number> {\n const message = entry.message as Record<string, unknown> | undefined;\n const usage = message?.usage as Record<string, unknown> | undefined;\n if (!usage) return 0;\n\n const modelId = this.extractModelId(entry);\n const pricing = await this.getModelPricing(modelId);\n \n const inputTokens = (usage.input_tokens as number) || 0;\n const outputTokens = (usage.output_tokens as number) || 0;\n const cacheCreationTokens = (usage.cache_creation_input_tokens as number) || 0;\n const cacheReadTokens = (usage.cache_read_input_tokens as number) || 0;\n \n const inputCost = (inputTokens / 1_000_000) * pricing.input;\n const outputCost = (outputTokens / 1_000_000) * pricing.output;\n const cacheReadCost = (cacheReadTokens / 1_000_000) * pricing.cache_read;\n const cacheCreationCost = (cacheCreationTokens / 1_000_000) * pricing.cache_write_5m;\n \n return inputCost + outputCost + cacheCreationCost + cacheReadCost;\n }\n\n private static extractModelId(entry: Record<string, unknown>): string {\n if (entry.model && typeof entry.model === 'string') {\n return entry.model;\n }\n \n const message = entry.message as Record<string, unknown> | undefined;\n if (message?.model) {\n const model = message.model;\n if (typeof model === 'string') {\n return model;\n }\n const modelObj = model as Record<string, unknown>;\n return (modelObj.id as string) || 'claude-3-5-sonnet-20241022';\n }\n \n if (entry.model_id && typeof entry.model_id === 'string') {\n return entry.model_id;\n }\n \n return 'claude-3-5-sonnet-20241022';\n }\n}","import { readFileSync } from \"node:fs\";\nimport { debug } from \"../utils/logger\";\n\nexport interface ContextInfo {\n inputTokens: number;\n percentage: number;\n usablePercentage: number;\n contextLeftPercentage: number;\n maxTokens: number;\n usableTokens: number;\n}\n\ninterface ContextUsageThresholds {\n LOW: number;\n MEDIUM: number;\n}\n\ninterface TranscriptEntry {\n message?: {\n usage?: {\n input_tokens?: number;\n cache_read_input_tokens?: number;\n cache_creation_input_tokens?: number;\n };\n };\n isSidechain?: boolean;\n timestamp?: string;\n}\n\nexport class ContextProvider {\n private readonly thresholds: ContextUsageThresholds = {\n LOW: 50,\n MEDIUM: 80,\n };\n\n getContextUsageThresholds(): ContextUsageThresholds {\n return this.thresholds;\n }\n\n private getContextLimit(_modelId: string): number {\n return 200000;\n }\n\n calculateContextTokens(\n transcriptPath: string,\n modelId?: string\n ): ContextInfo | null {\n try {\n debug(`Calculating context tokens from transcript: ${transcriptPath}`);\n\n const content = readFileSync(transcriptPath, \"utf-8\");\n if (!content) {\n debug(\"Transcript file is empty\");\n return null;\n }\n\n const lines = content.trim().split(\"\\n\");\n if (lines.length === 0) {\n debug(\"No lines in transcript\");\n return null;\n }\n\n let mostRecentEntry: TranscriptEntry | null = null;\n let mostRecentTime = 0;\n\n for (const line of lines) {\n if (!line.trim()) continue;\n\n try {\n const entry: TranscriptEntry = JSON.parse(line);\n\n if (!entry.message?.usage?.input_tokens) continue;\n\n if (entry.isSidechain === true) continue;\n\n if (!entry.timestamp) continue;\n\n const entryTime = new Date(entry.timestamp).getTime();\n if (entryTime > mostRecentTime) {\n mostRecentTime = entryTime;\n mostRecentEntry = entry;\n }\n } catch {}\n }\n\n if (mostRecentEntry?.message?.usage) {\n const usage = mostRecentEntry.message.usage;\n const contextLength =\n (usage.input_tokens || 0) +\n (usage.cache_read_input_tokens || 0) +\n (usage.cache_creation_input_tokens || 0);\n\n const contextLimit = modelId ? this.getContextLimit(modelId) : 200000;\n\n debug(\n `Most recent main chain context: ${contextLength} tokens (limit: ${contextLimit})`\n );\n\n const percentage = Math.min(\n 100,\n Math.max(0, Math.round((contextLength / contextLimit) * 100))\n );\n\n const usableLimit = Math.round(contextLimit * 0.8);\n const usablePercentage = Math.min(\n 100,\n Math.max(0, Math.round((contextLength / usableLimit) * 100))\n );\n\n const contextLeftPercentage = Math.max(0, 100 - usablePercentage);\n\n return {\n inputTokens: contextLength,\n percentage,\n usablePercentage,\n contextLeftPercentage,\n maxTokens: contextLimit,\n usableTokens: usableLimit,\n };\n }\n\n debug(\"No main chain entries with usage data found\");\n return null;\n } catch (error) {\n debug(\n `Error reading transcript: ${error instanceof Error ? error.message : String(error)}`\n );\n return null;\n }\n }\n}","interface TokenBreakdown {\n input: number;\n output: number;\n cacheCreation: number;\n cacheRead: number;\n}\n\nexport function formatCost(cost: number | null): string {\n if (cost === null) return \"$0.00\";\n if (cost < 0.01) return \"<$0.01\";\n return `$${cost.toFixed(2)}`;\n}\n\nexport function formatTokens(tokens: number | null): string {\n if (tokens === null) return \"0 tokens\";\n if (tokens === 0) return \"0 tokens\";\n if (tokens >= 1_000_000) {\n return `${(tokens / 1_000_000).toFixed(1)}M tokens`;\n } else if (tokens >= 1_000) {\n return `${(tokens / 1_000).toFixed(1)}K tokens`;\n }\n return `${tokens} tokens`;\n}\n\nexport function formatTokenBreakdown(breakdown: TokenBreakdown | null): string {\n if (!breakdown) return \"0 tokens\";\n\n const parts: string[] = [];\n\n if (breakdown.input > 0) {\n parts.push(`${formatTokens(breakdown.input).replace(\" tokens\", \"\")}in`);\n }\n\n if (breakdown.output > 0) {\n parts.push(`${formatTokens(breakdown.output).replace(\" tokens\", \"\")}out`);\n }\n\n if (breakdown.cacheCreation > 0 || breakdown.cacheRead > 0) {\n const totalCached = breakdown.cacheCreation + breakdown.cacheRead;\n parts.push(`${formatTokens(totalCached).replace(\" tokens\", \"\")}cached`);\n }\n\n return parts.length > 0 ? parts.join(\" + \") : \"0 tokens\";\n}\n","export interface BudgetStatus {\n percentage: number | null;\n isWarning: boolean;\n displayText: string;\n}\n\nexport function calculateBudgetPercentage(\n cost: number,\n budget: number | undefined\n): number | null {\n if (!budget || budget <= 0 || cost < 0) return null;\n return Math.min(100, (cost / budget) * 100);\n}\n\nexport function getBudgetStatus(\n cost: number,\n budget: number | undefined,\n warningThreshold = 80\n): BudgetStatus {\n const percentage = calculateBudgetPercentage(cost, budget);\n\n if (percentage === null) {\n return {\n percentage: null,\n isWarning: false,\n displayText: \"\",\n };\n }\n\n const percentStr = `${percentage.toFixed(0)}%`;\n const isWarning = percentage >= warningThreshold;\n\n let displayText = \"\";\n if (isWarning) {\n displayText = ` !${percentStr}`;\n } else if (percentage >= 50) {\n displayText = ` +${percentStr}`;\n } else {\n displayText = ` ${percentStr}`;\n }\n\n return {\n percentage,\n isWarning,\n displayText,\n };\n}\n","import type { ClaudeHookData } from \"../index\";\nimport type { PowerlineColors } from \"../themes\";\nimport type { PowerlineConfig } from \"../config/loader\";\n\nexport interface SegmentConfig {\n enabled: boolean;\n}\n\nexport interface GitSegmentConfig extends SegmentConfig {\n showSha: boolean;\n}\n\nexport interface UsageSegmentConfig extends SegmentConfig {\n type: \"cost\" | \"tokens\" | \"both\" | \"breakdown\";\n}\n\nexport interface TmuxSegmentConfig extends SegmentConfig {}\n\nexport interface ContextSegmentConfig extends SegmentConfig {}\n\nexport type AnySegmentConfig =\n | SegmentConfig\n | GitSegmentConfig\n | UsageSegmentConfig\n | TmuxSegmentConfig\n | ContextSegmentConfig;\n\nimport {\n formatCost,\n formatTokens,\n formatTokenBreakdown,\n} from \"../utils/formatters\";\nimport { getBudgetStatus } from \"../utils/budget\";\nimport type { UsageInfo, TokenBreakdown, GitInfo, ContextInfo } from \".\";\n\nexport interface PowerlineSymbols {\n right: string;\n branch: string;\n model: string;\n git_clean: string;\n git_dirty: string;\n git_conflicts: string;\n git_ahead: string;\n git_behind: string;\n session_cost: string;\n context_time: string;\n}\n\nexport interface SegmentData {\n text: string;\n bgColor: string;\n fgColor: string;\n}\n\nexport class SegmentRenderer {\n constructor(\n private readonly config: PowerlineConfig,\n private readonly symbols: PowerlineSymbols\n ) {}\n\n renderDirectory(\n hookData: ClaudeHookData,\n colors: PowerlineColors\n ): SegmentData {\n const currentDir = hookData.workspace?.current_dir || hookData.cwd || \"/\";\n const projectDir = hookData.workspace?.project_dir;\n const dirName = this.getDisplayDirectoryName(currentDir, projectDir);\n\n return {\n text: dirName,\n bgColor: colors.modeBg,\n fgColor: colors.modeFg,\n };\n }\n\n renderGit(\n gitInfo: GitInfo,\n colors: PowerlineColors,\n showSha = false\n ): SegmentData | null {\n if (!gitInfo) return null;\n\n let gitStatusIcon = this.symbols.git_clean;\n if (gitInfo.status === \"conflicts\") {\n gitStatusIcon = this.symbols.git_conflicts;\n } else if (gitInfo.status === \"dirty\") {\n gitStatusIcon = this.symbols.git_dirty;\n }\n\n let text = `${this.symbols.branch} ${gitInfo.branch} ${gitStatusIcon}`;\n\n if (gitInfo.sha && showSha) {\n text += ` ${gitInfo.sha}`;\n }\n\n if (gitInfo.ahead > 0 && gitInfo.behind > 0) {\n text += ` ${this.symbols.git_ahead}${gitInfo.ahead}${this.symbols.git_behind}${gitInfo.behind}`;\n } else if (gitInfo.ahead > 0) {\n text += ` ${this.symbols.git_ahead}${gitInfo.ahead}`;\n } else if (gitInfo.behind > 0) {\n text += ` ${this.symbols.git_behind}${gitInfo.behind}`;\n }\n\n return {\n text,\n bgColor: colors.gitBg,\n fgColor: colors.gitFg,\n };\n }\n\n renderModel(hookData: ClaudeHookData, colors: PowerlineColors): SegmentData {\n const modelName = hookData.model?.display_name || \"Claude\";\n\n return {\n text: `${this.symbols.model} ${modelName}`,\n bgColor: colors.modelBg,\n fgColor: colors.modelFg,\n };\n }\n\n renderSession(\n usageInfo: UsageInfo,\n colors: PowerlineColors,\n type = \"cost\"\n ): SegmentData {\n const sessionBudget = this.config.budget?.session;\n const text = `${this.symbols.session_cost} ${this.formatUsageWithBudget(\n usageInfo.session.cost,\n usageInfo.session.tokens,\n usageInfo.session.tokenBreakdown,\n type,\n sessionBudget?.amount,\n sessionBudget?.warningThreshold || 80\n )}`;\n\n return {\n text,\n bgColor: colors.sessionBg,\n fgColor: colors.sessionFg,\n };\n }\n\n renderTmux(\n sessionId: string | null,\n colors: PowerlineColors\n ): SegmentData | null {\n if (!sessionId) {\n return {\n text: `tmux:none`,\n bgColor: colors.tmuxBg,\n fgColor: colors.tmuxFg,\n };\n }\n\n return {\n text: `tmux:${sessionId}`,\n bgColor: colors.tmuxBg,\n fgColor: colors.tmuxFg,\n };\n }\n\n renderContext(\n contextInfo: ContextInfo | null,\n colors: PowerlineColors\n ): SegmentData | null {\n if (!contextInfo) {\n return {\n text: `${this.symbols.context_time} 0 (100%)`,\n bgColor: colors.contextBg,\n fgColor: colors.contextFg,\n };\n }\n\n const tokenDisplay = contextInfo.inputTokens.toLocaleString();\n\n const contextLeft = `${contextInfo.contextLeftPercentage}%`;\n\n return {\n text: `${this.symbols.context_time} ${tokenDisplay} (${contextLeft})`,\n bgColor: colors.contextBg,\n fgColor: colors.contextFg,\n };\n }\n\n private getDisplayDirectoryName(\n currentDir: string,\n projectDir?: string\n ): string {\n if (projectDir && projectDir !== currentDir) {\n const projectName = projectDir.split(\"/\").pop() || \"project\";\n const currentDirName = currentDir.split(\"/\").pop() || \"root\";\n\n if (currentDir.includes(projectDir)) {\n return `${projectName}/${currentDirName}`;\n }\n\n return currentDirName;\n }\n\n return currentDir.split(\"/\").pop() || \"root\";\n }\n\n private formatUsageDisplay(\n cost: number | null,\n tokens: number | null,\n tokenBreakdown: TokenBreakdown | null,\n type: string\n ): string {\n switch (type) {\n case \"cost\":\n return formatCost(cost);\n case \"tokens\":\n return formatTokens(tokens);\n case \"both\":\n return `${formatCost(cost)} (${formatTokens(tokens)})`;\n case \"breakdown\":\n return formatTokenBreakdown(tokenBreakdown);\n default:\n return formatCost(cost);\n }\n }\n\n private formatUsageWithBudget(\n cost: number | null,\n tokens: number | null,\n tokenBreakdown: TokenBreakdown | null,\n type: string,\n budget: number | undefined,\n warningThreshold = 80\n ): string {\n const baseDisplay = this.formatUsageDisplay(\n cost,\n tokens,\n tokenBreakdown,\n type\n );\n\n if (budget && budget > 0 && cost !== null) {\n const budgetStatus = getBudgetStatus(cost, budget, warningThreshold);\n return baseDisplay + budgetStatus.displayText;\n }\n\n return baseDisplay;\n }\n}\n","import type { ClaudeHookData } from \"./index\";\nimport type { PowerlineColors } from \"./themes\";\nimport type { PowerlineConfig, LineConfig } from \"./config/loader\";\nimport { hexToAnsi, extractBgToFg } from \"./utils/colors\";\nimport { getTheme } from \"./themes\";\nimport {\n UsageProvider,\n UsageInfo,\n ContextProvider,\n ContextInfo,\n GitService,\n TmuxService,\n SegmentRenderer,\n PowerlineSymbols,\n AnySegmentConfig,\n GitSegmentConfig,\n UsageSegmentConfig,\n} from \"./segments\";\n\nexport class PowerlineRenderer {\n private readonly symbols: PowerlineSymbols;\n private readonly usageProvider: UsageProvider;\n private readonly contextProvider: ContextProvider;\n private readonly gitService: GitService;\n private readonly tmuxService: TmuxService;\n private readonly segmentRenderer: SegmentRenderer;\n\n constructor(private readonly config: PowerlineConfig) {\n this.symbols = this.initializeSymbols();\n this.usageProvider = new UsageProvider();\n this.contextProvider = new ContextProvider();\n this.gitService = new GitService();\n this.tmuxService = new TmuxService();\n this.segmentRenderer = new SegmentRenderer(config, this.symbols);\n }\n\n private needsUsageInfo(): boolean {\n return this.config.display.lines.some(\n (line) => line.segments.session?.enabled\n );\n }\n\n private needsGitInfo(): boolean {\n return this.config.display.lines.some((line) => line.segments.git?.enabled);\n }\n\n private needsTmuxInfo(): boolean {\n return this.config.display.lines.some(\n (line) => line.segments.tmux?.enabled\n );\n }\n\n private needsContextInfo(): boolean {\n return this.config.display.lines.some(\n (line) => line.segments.context?.enabled\n );\n }\n\n async generateStatusline(hookData: ClaudeHookData): Promise<string> {\n const usageInfo = this.needsUsageInfo()\n ? await this.usageProvider.getUsageInfo(hookData.session_id)\n : null;\n\n const contextInfo = this.needsContextInfo()\n ? this.contextProvider.calculateContextTokens(\n hookData.transcript_path,\n hookData.model?.id\n )\n : null;\n\n const lines = this.config.display.lines\n .map((lineConfig) =>\n this.renderLine(lineConfig, hookData, usageInfo, contextInfo)\n )\n .filter((line) => line.length > 0);\n\n return lines.join(\"\\n\");\n }\n\n private renderLine(\n lineConfig: LineConfig,\n hookData: ClaudeHookData,\n usageInfo: UsageInfo | null,\n contextInfo: ContextInfo | null\n ): string {\n const colors = this.getThemeColors();\n const currentDir = hookData.workspace?.current_dir || hookData.cwd || \"/\";\n\n const segments = Object.entries(lineConfig.segments)\n .filter(\n ([_, config]: [string, AnySegmentConfig | undefined]) => config?.enabled\n )\n .map(([type, config]: [string, AnySegmentConfig]) => ({ type, config }));\n\n let line = colors.reset;\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n if (!segment) continue;\n\n const isLast = i === segments.length - 1;\n const nextSegment = !isLast ? segments[i + 1] : null;\n const nextBgColor = nextSegment\n ? this.getSegmentBgColor(nextSegment.type, colors)\n : \"\";\n\n const segmentData = this.renderSegment(\n segment,\n hookData,\n usageInfo,\n contextInfo,\n colors,\n currentDir\n );\n\n if (segmentData) {\n line += this.formatSegment(\n segmentData.bgColor,\n segmentData.fgColor,\n segmentData.text,\n isLast ? undefined : nextBgColor\n );\n }\n }\n\n return line;\n }\n\n private renderSegment(\n segment: { type: string; config: AnySegmentConfig },\n hookData: ClaudeHookData,\n usageInfo: UsageInfo | null,\n contextInfo: ContextInfo | null,\n colors: PowerlineColors,\n currentDir: string\n ) {\n switch (segment.type) {\n case \"directory\":\n return this.segmentRenderer.renderDirectory(hookData, colors);\n\n case \"git\":\n if (!this.needsGitInfo()) return null;\n const showSha = (segment.config as GitSegmentConfig)?.showSha || false;\n const gitInfo = this.gitService.getGitInfo(currentDir, showSha);\n return gitInfo\n ? this.segmentRenderer.renderGit(gitInfo, colors, showSha)\n : null;\n\n case \"model\":\n return this.segmentRenderer.renderModel(hookData, colors);\n\n case \"session\":\n if (!usageInfo) return null;\n const usageType =\n (segment.config as UsageSegmentConfig)?.type || \"cost\";\n return this.segmentRenderer.renderSession(usageInfo, colors, usageType);\n\n case \"tmux\":\n if (!this.needsTmuxInfo()) return null;\n const tmuxSessionId = this.tmuxService.getSessionId();\n return this.segmentRenderer.renderTmux(tmuxSessionId, colors);\n\n case \"context\":\n if (!this.needsContextInfo()) return null;\n return this.segmentRenderer.renderContext(contextInfo, colors);\n\n default:\n return null;\n }\n }\n\n private initializeSymbols(): PowerlineSymbols {\n const isMinimalStyle = this.config.display.style === \"minimal\";\n\n return {\n right: isMinimalStyle ? \"\" : \"\\uE0B0\",\n branch: \"⑂\",\n model: \"⚡\",\n git_clean: \"✓\",\n git_dirty: \"●\",\n git_conflicts: \"⚠\",\n git_ahead: \"↑\",\n git_behind: \"↓\",\n session_cost: \"⊡\",\n context_time: \"◷\",\n };\n }\n\n private getThemeColors(): PowerlineColors {\n const theme = this.config.theme;\n let colorTheme;\n\n if (theme === \"custom\") {\n colorTheme = this.config.colors?.custom;\n if (!colorTheme) {\n throw new Error(\n \"Custom theme selected but no colors provided in configuration\"\n );\n }\n } else {\n colorTheme = getTheme(theme);\n if (!colorTheme) {\n console.warn(\n `Built-in theme '${theme}' not found, falling back to 'dark' theme`\n );\n colorTheme = getTheme(\"dark\")!;\n }\n }\n\n return {\n reset: \"\\x1b[0m\",\n modeBg: hexToAnsi(colorTheme.directory.bg, true),\n modeFg: hexToAnsi(colorTheme.directory.fg, false),\n gitBg: hexToAnsi(colorTheme.git.bg, true),\n gitFg: hexToAnsi(colorTheme.git.fg, false),\n modelBg: hexToAnsi(colorTheme.model.bg, true),\n modelFg: hexToAnsi(colorTheme.model.fg, false),\n sessionBg: hexToAnsi(colorTheme.session.bg, true),\n sessionFg: hexToAnsi(colorTheme.session.fg, false),\n tmuxBg: hexToAnsi(colorTheme.tmux.bg, true),\n tmuxFg: hexToAnsi(colorTheme.tmux.fg, false),\n contextBg: hexToAnsi(colorTheme.context.bg, true),\n contextFg: hexToAnsi(colorTheme.context.fg, false),\n };\n }\n\n private getSegmentBgColor(\n segmentType: string,\n colors: PowerlineColors\n ): string {\n switch (segmentType) {\n case \"directory\":\n return colors.modeBg;\n case \"git\":\n return colors.gitBg;\n case \"model\":\n return colors.modelBg;\n case \"session\":\n return colors.sessionBg;\n case \"tmux\":\n return colors.tmuxBg;\n case \"context\":\n return colors.contextBg;\n default:\n return colors.modeBg;\n }\n }\n\n private formatSegment(\n bgColor: string,\n fgColor: string,\n text: string,\n nextBgColor?: string\n ): string {\n let output = `${bgColor}${fgColor} ${text} `;\n\n const reset = \"\\x1b[0m\";\n\n if (nextBgColor) {\n const arrowFgColor = extractBgToFg(bgColor);\n output += `${reset}${nextBgColor}${arrowFgColor}${this.symbols.right}`;\n } else {\n output += `${reset}${extractBgToFg(bgColor)}${this.symbols.right}${reset}`;\n }\n\n return output;\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport os from \"node:os\";\nimport { DEFAULT_CONFIG } from \"./defaults\";\nimport type { ColorTheme } from \"../themes\";\nimport type {\n SegmentConfig,\n GitSegmentConfig,\n UsageSegmentConfig,\n TmuxSegmentConfig,\n ContextSegmentConfig,\n} from \"../segments/renderer\";\n\nexport interface LineConfig {\n segments: {\n directory?: SegmentConfig;\n git?: GitSegmentConfig;\n model?: SegmentConfig;\n session?: UsageSegmentConfig;\n tmux?: TmuxSegmentConfig;\n context?: ContextSegmentConfig;\n };\n}\n\nexport interface DisplayConfig {\n lines: LineConfig[];\n style?: \"minimal\" | \"powerline\";\n}\n\nexport interface BudgetItemConfig {\n amount?: number;\n warningThreshold?: number;\n}\n\nexport interface BudgetConfig {\n session?: BudgetItemConfig;\n}\n\nexport interface PowerlineConfig {\n theme: \"light\" | \"dark\" | \"nord\" | \"tokyo-night\" | \"rose-pine\" | \"custom\";\n display: DisplayConfig;\n colors?: {\n custom: ColorTheme;\n };\n budget?: BudgetConfig;\n usageType?: \"cost\" | \"tokens\" | \"both\" | \"breakdown\";\n}\n\nexport interface ConfigLoadOptions {\n configPath?: string;\n ignoreEnvVars?: boolean;\n cliOverrides?: Partial<PowerlineConfig>;\n projectDir?: string;\n}\n\nfunction deepMerge<T extends Record<string, any>>(\n target: T,\n source: Partial<T>\n): T {\n const result = { ...target };\n\n for (const key in source) {\n const sourceValue = source[key];\n if (sourceValue !== undefined) {\n if (\n typeof sourceValue === \"object\" &&\n sourceValue !== null &&\n !Array.isArray(sourceValue)\n ) {\n const targetValue = result[key] || {};\n result[key] = deepMerge(\n targetValue as Record<string, any>,\n sourceValue as Record<string, any>\n ) as T[Extract<keyof T, string>];\n } else if (Array.isArray(sourceValue) && sourceValue.length === 0) {\n const targetValue = result[key];\n if (!Array.isArray(targetValue) || targetValue.length > 0) {\n continue;\n } else {\n result[key] = sourceValue as T[Extract<keyof T, string>];\n }\n } else {\n result[key] = sourceValue as T[Extract<keyof T, string>];\n }\n }\n }\n\n return result;\n}\n\nfunction findConfigFile(\n customPath?: string,\n projectDir?: string\n): string | null {\n if (customPath) {\n return fs.existsSync(customPath) ? customPath : null;\n }\n\n const locations = [\n ...(projectDir ? [path.join(projectDir, \".claude-powerline.json\")] : []),\n path.join(process.cwd(), \".claude-powerline.json\"),\n path.join(os.homedir(), \".claude\", \"claude-powerline.json\"),\n path.join(os.homedir(), \".config\", \"claude-powerline\", \"config.json\"),\n ];\n\n return locations.find(fs.existsSync) || null;\n}\n\nfunction loadConfigFile(filePath: string): Partial<PowerlineConfig> {\n try {\n const content = fs.readFileSync(filePath, \"utf-8\");\n return JSON.parse(content);\n } catch (error) {\n throw new Error(\n `Failed to load config file ${filePath}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n}\n\nfunction loadEnvConfig(): Partial<PowerlineConfig> {\n const config: Partial<PowerlineConfig> = {};\n\n if (process.env.CLAUDE_POWERLINE_THEME) {\n config.theme = process.env.CLAUDE_POWERLINE_THEME as\n | \"light\"\n | \"dark\"\n | \"custom\";\n }\n\n if (process.env.CLAUDE_POWERLINE_STYLE) {\n if (!config.display) {\n config.display = { lines: [] };\n }\n const style = process.env.CLAUDE_POWERLINE_STYLE;\n if (style === \"minimal\" || style === \"powerline\") {\n config.display.style = style;\n } else {\n console.warn(\n `Invalid display style '${style}' from environment variable, falling back to 'minimal'`\n );\n config.display.style = \"minimal\";\n }\n }\n\n if (process.env.CLAUDE_POWERLINE_USAGE_TYPE) {\n const usageType = process.env.CLAUDE_POWERLINE_USAGE_TYPE as\n | \"cost\"\n | \"tokens\"\n | \"both\"\n | \"breakdown\";\n if ([\"cost\", \"tokens\", \"both\", \"breakdown\"].includes(usageType)) {\n config.usageType = usageType;\n }\n }\n\n return config;\n}\n\nfunction getConfigPathFromEnv(): string | undefined {\n return process.env.CLAUDE_POWERLINE_CONFIG;\n}\n\nfunction parseCLIOverrides(args: string[]): Partial<PowerlineConfig> {\n const config: Partial<PowerlineConfig> = {};\n\n const themeIndex = args.findIndex((arg) => arg.startsWith(\"--theme=\"));\n if (themeIndex !== -1) {\n const theme = args[themeIndex]?.split(\"=\")[1];\n if (theme) {\n config.theme = theme as \"light\" | \"dark\" | \"custom\";\n }\n }\n\n const styleIndex = args.findIndex((arg) => arg.startsWith(\"--style=\"));\n if (styleIndex !== -1) {\n const style = args[styleIndex]?.split(\"=\")[1];\n if (style) {\n if (!config.display) {\n config.display = { lines: [] };\n }\n if (style === \"minimal\" || style === \"powerline\") {\n config.display.style = style;\n } else {\n console.warn(\n `Invalid display style '${style}' from CLI argument, falling back to 'minimal'`\n );\n config.display.style = \"minimal\";\n }\n }\n }\n\n\n const sessionBudgetIndex = args.findIndex((arg) =>\n arg.startsWith(\"--session-budget=\")\n );\n if (sessionBudgetIndex !== -1) {\n const sessionBudget = parseFloat(\n args[sessionBudgetIndex]?.split(\"=\")[1] || \"\"\n );\n if (!isNaN(sessionBudget) && sessionBudget > 0) {\n config.budget = {\n ...config.budget,\n session: {\n ...DEFAULT_CONFIG.budget?.session,\n amount: sessionBudget,\n },\n };\n }\n }\n\n const usageIndex = args.findIndex((arg) => arg.startsWith(\"--usage=\"));\n if (usageIndex !== -1) {\n const usageType = args[usageIndex]?.split(\"=\")[1] as\n | \"cost\"\n | \"tokens\"\n | \"both\"\n | \"breakdown\";\n if (\n usageType &&\n [\"cost\", \"tokens\", \"both\", \"breakdown\"].includes(usageType)\n ) {\n config.usageType = usageType;\n }\n }\n\n return config;\n}\n\nexport function loadConfig(options: ConfigLoadOptions = {}): PowerlineConfig {\n const {\n configPath,\n ignoreEnvVars = false,\n cliOverrides = {},\n projectDir,\n } = options;\n\n let config: PowerlineConfig = JSON.parse(JSON.stringify(DEFAULT_CONFIG));\n\n const configFile = findConfigFile(configPath, projectDir);\n if (configFile) {\n try {\n const fileConfig = loadConfigFile(configFile);\n config = deepMerge(config, fileConfig);\n } catch (err) {\n console.warn(\n `Warning: ${err instanceof Error ? err.message : String(err)}`\n );\n }\n }\n\n if (\n config.display?.style &&\n config.display.style !== \"minimal\" &&\n config.display.style !== \"powerline\"\n ) {\n console.warn(\n `Invalid display style '${config.display.style}' in config file, falling back to 'minimal'`\n );\n config.display.style = \"minimal\";\n }\n\n if (!ignoreEnvVars) {\n const envConfig = loadEnvConfig();\n config = deepMerge(config, envConfig);\n }\n\n config = deepMerge(config, cliOverrides);\n\n if (config.usageType) {\n config.display.lines.forEach((line) => {\n if (line.segments.session) {\n line.segments.session.type = config.usageType!;\n }\n });\n delete config.usageType;\n }\n\n return config;\n}\n\nexport function loadConfigFromCLI(\n args: string[] = process.argv,\n projectDir?: string\n): PowerlineConfig {\n const configPathIndex = args.findIndex((arg) => arg.startsWith(\"--config=\"));\n const configPath =\n configPathIndex !== -1\n ? args[configPathIndex]?.split(\"=\")[1]\n : getConfigPathFromEnv();\n\n const cliOverrides = parseCLIOverrides(args);\n\n return loadConfig({ configPath, cliOverrides, projectDir });\n}\n\nexport function getConfigPath(\n customPath?: string,\n projectDir?: string\n): string | null {\n return findConfigFile(customPath, projectDir);\n}\n","import type { PowerlineConfig } from \"./loader\";\n\nexport const DEFAULT_CONFIG: PowerlineConfig = {\n theme: \"dark\",\n display: {\n style: \"minimal\",\n lines: [\n {\n segments: {\n directory: { enabled: true },\n git: {\n enabled: true,\n showSha: false,\n },\n model: { enabled: true },\n session: { enabled: true, type: \"tokens\" },\n tmux: { enabled: false },\n context: { enabled: true },\n },\n },\n ],\n },\n budget: {\n session: {\n warningThreshold: 80,\n },\n },\n};\n"],"mappings":";;;;;;;;;A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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oLAgBgK;AAC9K,MAAAA,SAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,UAAM,sBAAsBA,SAAQ,IAAI,CAAC,EAAE;AAC3C,UAAM,iBAAiBA,SAAQ,IAAI;AAEnC,UAAM,WAAY,MAAM,KAAKA,SAAQ,KAAK;AAC1C,UAAM,uBAAuB,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAE9D,QAAI,CAAC,UAAU;AACb,cAAQ,MAAM,0CAA0C;AACxD,cAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAejB;AACK,MAAAA,SAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,UAAM,aAAa,SAAS,WAAW;AACvC,UAAM,SAAS,kBAAkBA,SAAQ,MAAM,UAAU;AACzD,UAAM,WAAW,IAAI,kBAAkB,MAAM;AAC7C,UAAM,aAAa,MAAM,SAAS,mBAAmB,QAAQ;AAE7D,YAAQ,IAAI,UAAU;AAAA,EACxB,SAAS,OAAO;AACd,UAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC1E,YAAQ,MAAM,gCAAgC,YAAY;AAC1D,IAAAA,SAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK;","names":["process","path","fs","execSync","os","execSync","execSync","homedir","join","readFileSync","fs","path","fs","path","os","path","fs","execSync","process"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/colors.ts","../src/themes/dark.ts","../src/themes/light.ts","../src/themes/nord.ts","../src/themes/tokyo-night.ts","../src/themes/rose-pine.ts","../src/themes/index.ts","../src/segments/git.ts","../src/utils/logger.ts","../src/segments/tmux.ts","../src/segments/session.ts","../src/segments/pricing.ts","../src/utils/claude.ts","../src/segments/context.ts","../src/segments/metrics.ts","../src/utils/formatters.ts","../src/utils/budget.ts","../src/segments/renderer.ts","../src/powerline.ts","../src/config/loader.ts","../src/config/defaults.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport process from \"node:process\";\nimport path from \"node:path\";\nimport fs from \"node:fs\";\nimport { execSync } from \"node:child_process\";\nimport os from \"node:os\";\nimport { json } from \"node:stream/consumers\";\nimport { PowerlineRenderer } from \"./powerline\";\nimport { loadConfigFromCLI } from \"./config/loader\";\nimport { debug } from \"./utils/logger\";\nexport interface ClaudeHookData {\n hook_event_name: string;\n session_id: string;\n transcript_path: string;\n cwd: string;\n model: {\n id: string;\n display_name: string;\n };\n workspace: {\n current_dir: string;\n project_dir: string;\n };\n}\n\nasync function installFonts(): Promise<void> {\n try {\n const platform = os.platform();\n let fontDir: string;\n\n if (platform === \"darwin\") {\n fontDir = path.join(os.homedir(), \"Library\", \"Fonts\");\n } else if (platform === \"linux\") {\n fontDir = path.join(os.homedir(), \".local\", \"share\", \"fonts\");\n } else if (platform === \"win32\") {\n fontDir = path.join(\n os.homedir(),\n \"AppData\",\n \"Local\",\n \"Microsoft\",\n \"Windows\",\n \"Fonts\"\n );\n } else {\n console.log(\"Unsupported platform for font installation\");\n return;\n }\n\n if (!fs.existsSync(fontDir)) {\n fs.mkdirSync(fontDir, { recursive: true });\n }\n\n console.log(\"📦 Installing Powerline Fonts...\");\n console.log(\"Downloading from https://github.com/powerline/fonts\");\n\n const tempDir = path.join(os.tmpdir(), \"powerline-fonts\");\n\n try {\n if (fs.existsSync(tempDir)) {\n fs.rmSync(tempDir, { recursive: true, force: true });\n }\n\n console.log(\"Cloning powerline fonts repository...\");\n execSync(\n \"git clone --depth=1 https://github.com/powerline/fonts.git powerline-fonts\",\n {\n stdio: \"inherit\",\n cwd: os.tmpdir(),\n }\n );\n\n console.log(\"Installing fonts...\");\n const installScript = path.join(tempDir, \"install.sh\");\n\n if (fs.existsSync(installScript)) {\n fs.chmodSync(installScript, 0o755);\n execSync(\"./install.sh\", { stdio: \"inherit\", cwd: tempDir });\n } else {\n throw new Error(\n \"Install script not found in powerline fonts repository\"\n );\n }\n\n console.log(\"✅ Powerline fonts installation complete!\");\n console.log(\n \"Please restart your terminal and set your terminal font to a powerline font.\"\n );\n console.log(\n \"Popular choices: Source Code Pro Powerline, DejaVu Sans Mono Powerline, Ubuntu Mono Powerline\"\n );\n } finally {\n if (fs.existsSync(tempDir)) {\n fs.rmSync(tempDir, { recursive: true, force: true });\n }\n }\n } catch (error) {\n console.error(\n \"Error installing fonts:\",\n error instanceof Error ? error.message : String(error)\n );\n console.log(\n \"💡 You can manually install fonts from: https://github.com/powerline/fonts\"\n );\n }\n}\n\nasync function main(): Promise<void> {\n try {\n const showHelp =\n process.argv.includes(\"--help\") || process.argv.includes(\"-h\");\n const installFontsFlag = process.argv.includes(\"--install-fonts\");\n\n if (installFontsFlag) {\n await installFonts();\n process.exit(0);\n }\n\n if (showHelp) {\n console.log(`\nclaude-powerline - Beautiful powerline statusline for Claude Code\n\nUsage: claude-powerline [options]\n\nStandalone Commands:\n --install-fonts Install powerline fonts to system\n -h, --help Show this help\n\nDebugging:\n CLAUDE_POWERLINE_DEBUG=1 Enable debug logging for troubleshooting\n\nClaude Code Options (for settings.json):\n --theme=THEME Set theme: dark, light, nord, tokyo-night, rose-pine, custom\n --style=STYLE Set separator style: minimal, powerline\n --usage=TYPE Usage display: cost, tokens, both, breakdown\n --session-budget=AMOUNT Set session budget for percentage tracking\n --config=PATH Use custom config file path\n\nConfiguration:\n Config files are loaded in this order (highest priority first):\n 1. CLI arguments (--theme, --style, --usage, --config)\n 2. Environment variables (CLAUDE_POWERLINE_THEME, CLAUDE_POWERLINE_STYLE, CLAUDE_POWERLINE_USAGE_TYPE, CLAUDE_POWERLINE_CONFIG)\n 3. ./.claude-powerline.json (project)\n 4. ~/.claude/claude-powerline.json (user)\n 5. ~/.config/claude-powerline/config.json (XDG)\n\nCreating a config file:\n Copy example from: https://github.com/Owloops/claude-powerline/blob/main/.claude-powerline.json\n\nUsage in Claude Code settings.json:\n{\n \"statusLine\": {\n \"type\": \"command\",\n \"command\": \"claude-powerline\",\n \"padding\": 0\n }\n}\n`);\n process.exit(0);\n }\n\n if (process.stdin.isTTY === true) {\n console.error(`Error: This tool requires input from Claude Code\n\nclaude-powerline is designed to be used as a Claude Code statusLine command.\nIt reads hook data from stdin and outputs formatted statusline.\n\nAdd to ~/.claude/settings.json:\n{\n \"statusLine\": {\n \"type\": \"command\",\n \"command\": \"claude-powerline --style=powerline\"\n }\n}\n\nRun with --help for more options.\n\nTo test output manually:\necho '{\"session_id\":\"test-session\",\"workspace\":{\"project_dir\":\"/path/to/project\"},\"model\":{\"id\":\"claude-3-5-sonnet\",\"display_name\":\"Claude\"}}' | claude-powerline --style=powerline`);\n process.exit(1);\n }\n\n debug(`Working directory: ${process.cwd()}`);\n debug(`Process args:`, process.argv);\n\n const hookData = (await json(process.stdin)) as ClaudeHookData;\n debug(`Received hook data:`, JSON.stringify(hookData, null, 2));\n\n if (!hookData) {\n console.error(\"Error: No input data received from stdin\");\n console.log(`\nclaude-powerline - Beautiful powerline statusline for Claude Code\n\nUsage: claude-powerline [options]\n\nOptions:\n --theme=THEME Set theme: dark, light, nord, tokyo-night, rose-pine, custom\n --style=STYLE Set separator style: minimal, powerline\n --usage=TYPE Usage display: cost, tokens, both, breakdown\n --session-budget=AMOUNT Set session budget for percentage tracking\n --config=PATH Use custom config file path\n --install-fonts Install powerline fonts to system\n -h, --help Show this help\n\nSee example config at: https://github.com/Owloops/claude-powerline/blob/main/.claude-powerline.json\n`);\n process.exit(1);\n }\n\n const projectDir = hookData.workspace?.project_dir;\n const config = loadConfigFromCLI(process.argv, projectDir);\n const renderer = new PowerlineRenderer(config);\n const statusline = await renderer.generateStatusline(hookData);\n\n console.log(statusline);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(\"Error generating statusline:\", errorMessage);\n process.exit(1);\n }\n}\n\nmain();\n","export function hexToAnsi(hex: string, isBackground: boolean): string {\n const r = parseInt(hex.slice(1, 3), 16);\n const g = parseInt(hex.slice(3, 5), 16);\n const b = parseInt(hex.slice(5, 7), 16);\n return `\\x1b[${isBackground ? \"48\" : \"38\"};2;${r};${g};${b}m`;\n}\n\nexport function extractBgToFg(ansiCode: string): string {\n const match = ansiCode.match(/48;2;(\\d+);(\\d+);(\\d+)/);\n if (match) {\n return `\\x1b[38;2;${match[1]};${match[2]};${match[3]}m`;\n }\n return ansiCode.replace(\"48\", \"38\");\n}\n","import type { ColorTheme } from \"./index\";\n\nexport const darkTheme: ColorTheme = {\n directory: { bg: \"#8b4513\", fg: \"#ffffff\" },\n git: { bg: \"#404040\", fg: \"#ffffff\" },\n model: { bg: \"#2d2d2d\", fg: \"#ffffff\" },\n session: { bg: \"#202020\", fg: \"#00ffff\" },\n tmux: { bg: \"#2f4f2f\", fg: \"#90ee90\" },\n context: { bg: \"#4a5568\", fg: \"#cbd5e0\" },\n metrics: { bg: \"#374151\", fg: \"#d1d5db\" },\n};\n","import type { ColorTheme } from \"./index\";\n\nexport const lightTheme: ColorTheme = {\n directory: { bg: \"#ff6b47\", fg: \"#ffffff\" },\n git: { bg: \"#4fb3d9\", fg: \"#ffffff\" },\n model: { bg: \"#87ceeb\", fg: \"#000000\" },\n session: { bg: \"#da70d6\", fg: \"#ffffff\" },\n tmux: { bg: \"#32cd32\", fg: \"#ffffff\" },\n context: { bg: \"#718096\", fg: \"#ffffff\" },\n metrics: { bg: \"#6b7280\", fg: \"#ffffff\" },\n};\n","import type { ColorTheme } from \"./index\";\n\nexport const nordTheme: ColorTheme = {\n directory: { bg: \"#434c5e\", fg: \"#d8dee9\" },\n git: { bg: \"#3b4252\", fg: \"#a3be8c\" },\n model: { bg: \"#4c566a\", fg: \"#81a1c1\" },\n session: { bg: \"#2e3440\", fg: \"#88c0d0\" },\n tmux: { bg: \"#2e3440\", fg: \"#8fbcbb\" },\n context: { bg: \"#5e81ac\", fg: \"#eceff4\" },\n metrics: { bg: \"#b48ead\", fg: \"#2e3440\" },\n};\n","import type { ColorTheme } from \"./index\";\n\nexport const tokyoNightTheme: ColorTheme = {\n directory: { bg: \"#2f334d\", fg: \"#82aaff\" },\n git: { bg: \"#1e2030\", fg: \"#c3e88d\" },\n model: { bg: \"#191b29\", fg: \"#fca7ea\" },\n session: { bg: \"#222436\", fg: \"#86e1fc\" },\n tmux: { bg: \"#191b29\", fg: \"#4fd6be\" },\n context: { bg: \"#414868\", fg: \"#c0caf5\" },\n metrics: { bg: \"#bb9af7\", fg: \"#1a1b26\" },\n};\n","import type { ColorTheme } from \"./index\";\n\nexport const rosePineTheme: ColorTheme = {\n directory: { bg: \"#26233a\", fg: \"#c4a7e7\" },\n git: { bg: \"#1f1d2e\", fg: \"#9ccfd8\" },\n model: { bg: \"#191724\", fg: \"#ebbcba\" },\n session: { bg: \"#26233a\", fg: \"#f6c177\" },\n tmux: { bg: \"#26233a\", fg: \"#908caa\" },\n context: { bg: \"#393552\", fg: \"#e0def4\" },\n metrics: { bg: \"#c4a7e7\", fg: \"#191724\" },\n};\n","import { darkTheme } from \"./dark\";\nimport { lightTheme } from \"./light\";\nimport { nordTheme } from \"./nord\";\nimport { tokyoNightTheme } from \"./tokyo-night\";\nimport { rosePineTheme } from \"./rose-pine\";\n\nexport interface SegmentColor {\n bg: string;\n fg: string;\n}\n\nexport interface ColorTheme {\n directory: SegmentColor;\n git: SegmentColor;\n model: SegmentColor;\n session: SegmentColor;\n tmux: SegmentColor;\n context: SegmentColor;\n metrics: SegmentColor;\n}\n\nexport interface PowerlineColors {\n reset: string;\n modeBg: string;\n modeFg: string;\n gitBg: string;\n gitFg: string;\n modelBg: string;\n modelFg: string;\n sessionBg: string;\n sessionFg: string;\n tmuxBg: string;\n tmuxFg: string;\n contextBg: string;\n contextFg: string;\n metricsBg: string;\n metricsFg: string;\n}\n\nexport const BUILT_IN_THEMES: Record<string, ColorTheme> = {\n dark: darkTheme,\n light: lightTheme,\n nord: nordTheme,\n \"tokyo-night\": tokyoNightTheme,\n \"rose-pine\": rosePineTheme,\n};\n\nexport function getTheme(themeName: string): ColorTheme | null {\n return BUILT_IN_THEMES[themeName] || null;\n}\n\nexport { darkTheme, lightTheme, nordTheme, tokyoNightTheme, rosePineTheme };\n","import { execSync } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { debug } from \"../utils/logger\";\n\nexport interface GitInfo {\n branch: string;\n status: \"clean\" | \"dirty\" | \"conflicts\";\n ahead: number;\n behind: number;\n sha?: string;\n}\n\nexport class GitService {\n private isGitRepo(workingDir: string): boolean {\n try {\n return fs.existsSync(path.join(workingDir, \".git\"));\n } catch {\n return false;\n }\n }\n\n getGitInfo(workingDir: string, showSha = false): GitInfo | null {\n if (!this.isGitRepo(workingDir)) {\n return {\n branch: \"detached\",\n status: \"clean\",\n ahead: 0,\n behind: 0,\n sha: undefined,\n };\n }\n\n try {\n const branch = this.getBranch(workingDir);\n const status = this.getStatus(workingDir);\n const { ahead, behind } = this.getAheadBehind(workingDir);\n const sha = showSha ? this.getSha(workingDir) || undefined : undefined;\n\n return {\n branch: branch || \"detached\",\n status,\n ahead,\n behind,\n sha,\n };\n } catch {\n return null;\n }\n }\n\n private getBranch(workingDir: string): string | null {\n try {\n return (\n execSync(\"git branch --show-current\", {\n cwd: workingDir,\n encoding: \"utf8\",\n timeout: 1000,\n }).trim() || null\n );\n } catch (error) {\n debug(`Git branch command failed in ${workingDir}:`, error);\n return null;\n }\n }\n\n private getStatus(workingDir: string): \"clean\" | \"dirty\" | \"conflicts\" {\n try {\n const gitStatus = execSync(\"git status --porcelain\", {\n cwd: workingDir,\n encoding: \"utf8\",\n timeout: 1000,\n }).trim();\n\n if (!gitStatus) return \"clean\";\n\n if (\n gitStatus.includes(\"UU\") ||\n gitStatus.includes(\"AA\") ||\n gitStatus.includes(\"DD\")\n ) {\n return \"conflicts\";\n }\n\n return \"dirty\";\n } catch (error) {\n debug(`Git status command failed in ${workingDir}:`, error);\n return \"clean\";\n }\n }\n\n private getAheadBehind(workingDir: string): {\n ahead: number;\n behind: number;\n } {\n try {\n const aheadResult = execSync(\"git rev-list --count @{u}..HEAD\", {\n cwd: workingDir,\n encoding: \"utf8\",\n timeout: 1000,\n }).trim();\n\n const behindResult = execSync(\"git rev-list --count HEAD..@{u}\", {\n cwd: workingDir,\n encoding: \"utf8\",\n timeout: 1000,\n }).trim();\n\n return {\n ahead: parseInt(aheadResult) || 0,\n behind: parseInt(behindResult) || 0,\n };\n } catch (error) {\n debug(`Git ahead/behind command failed in ${workingDir}:`, error);\n return { ahead: 0, behind: 0 };\n }\n }\n\n private getSha(workingDir: string): string | null {\n try {\n const sha = execSync(\"git rev-parse --short=7 HEAD\", {\n cwd: workingDir,\n encoding: \"utf8\",\n timeout: 1000,\n }).trim();\n\n return sha || null;\n } catch {\n return null;\n }\n }\n}","const debug = (message: string, ...args: any[]): void => {\n if (process.env.CLAUDE_POWERLINE_DEBUG) {\n console.error(`[DEBUG] ${message}`, ...args);\n }\n};\n\nexport { debug };\n","import { execSync } from \"node:child_process\";\nimport { debug } from \"../utils/logger\";\n\nexport class TmuxService {\n getSessionId(): string | null {\n try {\n if (!process.env.TMUX_PANE) {\n debug(`TMUX_PANE not set, not in tmux session`);\n return null;\n }\n\n debug(`Getting tmux session ID, TMUX_PANE: ${process.env.TMUX_PANE}`);\n\n const sessionId = execSync(\"tmux display-message -p '#S'\", {\n encoding: \"utf8\",\n timeout: 1000,\n }).trim();\n\n debug(`Tmux session ID: ${sessionId || \"empty\"}`);\n\n return sessionId || null;\n } catch (error) {\n debug(`Error getting tmux session ID:`, error);\n return null;\n }\n }\n\n isInTmux(): boolean {\n return !!process.env.TMUX_PANE;\n }\n}","import { readFile } from \"node:fs/promises\";\nimport { debug } from \"../utils/logger\";\nimport { PricingService } from \"./pricing\";\nimport { findTranscriptFile } from \"../utils/claude\";\n\nexport interface SessionUsageEntry {\n timestamp: string;\n message: {\n usage: {\n input_tokens: number;\n output_tokens: number;\n cache_creation_input_tokens?: number;\n cache_read_input_tokens?: number;\n };\n };\n costUSD?: number;\n}\n\nexport interface SessionUsage {\n totalCost: number;\n entries: SessionUsageEntry[];\n}\n\nexport interface TokenBreakdown {\n input: number;\n output: number;\n cacheCreation: number;\n cacheRead: number;\n}\n\nexport interface SessionInfo {\n cost: number | null;\n tokens: number | null;\n tokenBreakdown: TokenBreakdown | null;\n}\n\nexport interface UsageInfo {\n session: SessionInfo;\n}\n\nexport class SessionProvider {\n\n async getSessionUsage(sessionId: string): Promise<SessionUsage | null> {\n try {\n const transcriptPath = await findTranscriptFile(sessionId);\n if (!transcriptPath) {\n debug(`No transcript found for session: ${sessionId}`);\n return null;\n }\n\n debug(`Found transcript at: ${transcriptPath}`);\n \n const content = await readFile(transcriptPath, 'utf-8');\n const lines = content.trim().split('\\n').filter(line => line.trim());\n \n if (lines.length === 0) {\n return { totalCost: 0, entries: [] };\n }\n\n const entries: SessionUsageEntry[] = [];\n let totalCost = 0;\n\n for (const line of lines) {\n try {\n const entry = JSON.parse(line) as Record<string, unknown>;\n \n if (entry.message && typeof entry.message === 'object') {\n const message = entry.message as Record<string, unknown>;\n if (message.usage && typeof message.usage === 'object') {\n const sessionEntry: SessionUsageEntry = {\n timestamp: (entry.timestamp as string) || new Date().toISOString(),\n message: {\n usage: message.usage as SessionUsageEntry['message']['usage']\n }\n };\n\n if (typeof entry.costUSD === 'number') {\n sessionEntry.costUSD = entry.costUSD;\n totalCost += entry.costUSD;\n } else {\n const cost = await PricingService.calculateCostForEntry(entry);\n sessionEntry.costUSD = cost;\n totalCost += cost;\n }\n\n entries.push(sessionEntry);\n }\n }\n } catch (parseError) {\n debug(`Failed to parse JSONL line: ${parseError}`);\n continue;\n }\n }\n\n debug(`Parsed ${entries.length} usage entries, total cost: $${totalCost.toFixed(4)}`);\n return { totalCost, entries };\n\n } catch (error) {\n debug(`Error reading session usage for ${sessionId}:`, error);\n return null;\n }\n }\n\n calculateTokenBreakdown(entries: SessionUsageEntry[]): TokenBreakdown {\n return entries.reduce(\n (breakdown, entry) => ({\n input: breakdown.input + (entry.message.usage.input_tokens || 0),\n output: breakdown.output + (entry.message.usage.output_tokens || 0),\n cacheCreation: breakdown.cacheCreation + (entry.message.usage.cache_creation_input_tokens || 0),\n cacheRead: breakdown.cacheRead + (entry.message.usage.cache_read_input_tokens || 0),\n }),\n { input: 0, output: 0, cacheCreation: 0, cacheRead: 0 }\n );\n }\n\n async getSessionInfo(sessionId: string): Promise<SessionInfo> {\n const sessionUsage = await this.getSessionUsage(sessionId);\n \n if (!sessionUsage || sessionUsage.entries.length === 0) {\n return { cost: null, tokens: null, tokenBreakdown: null };\n }\n\n const tokenBreakdown = this.calculateTokenBreakdown(sessionUsage.entries);\n const totalTokens = tokenBreakdown.input + tokenBreakdown.output + \n tokenBreakdown.cacheCreation + tokenBreakdown.cacheRead;\n\n return {\n cost: sessionUsage.totalCost,\n tokens: totalTokens,\n tokenBreakdown,\n };\n }\n}\n\nexport class UsageProvider {\n private sessionProvider = new SessionProvider();\n\n async getUsageInfo(sessionId: string): Promise<UsageInfo> {\n try {\n debug(`Starting usage info retrieval for session: ${sessionId}`);\n \n const sessionInfo = await this.sessionProvider.getSessionInfo(sessionId);\n \n return {\n session: sessionInfo,\n };\n } catch (error) {\n debug(`Error getting usage info for session ${sessionId}:`, error);\n return {\n session: { cost: null, tokens: null, tokenBreakdown: null },\n };\n }\n }\n}","import { debug } from \"../utils/logger\";\n\n\nexport interface ModelPricing {\n name: string;\n input: number;\n cache_write_5m: number;\n cache_write_1h: number;\n cache_read: number;\n output: number;\n}\nconst OFFLINE_PRICING_DATA: Record<string, ModelPricing> = {\n \"claude-3-haiku-20240307\": {\n name: \"Claude 3 Haiku\",\n input: 0.25,\n output: 1.25,\n cache_write_5m: 0.30,\n cache_write_1h: 0.50,\n cache_read: 0.03\n },\n \"claude-3-5-haiku-20241022\": {\n name: \"Claude 3.5 Haiku\",\n input: 0.80,\n output: 4.00,\n cache_write_5m: 1.00,\n cache_write_1h: 1.60,\n cache_read: 0.08\n },\n \"claude-3-5-haiku-latest\": {\n name: \"Claude 3.5 Haiku Latest\",\n input: 1.00,\n output: 5.00,\n cache_write_5m: 1.25,\n cache_write_1h: 2.00,\n cache_read: 0.10\n },\n \"claude-3-opus-latest\": {\n name: \"Claude 3 Opus Latest\",\n input: 15.00,\n output: 75.00,\n cache_write_5m: 18.75,\n cache_write_1h: 30.00,\n cache_read: 1.50\n },\n \"claude-3-opus-20240229\": {\n name: \"Claude 3 Opus\",\n input: 15.00,\n output: 75.00,\n cache_write_5m: 18.75,\n cache_write_1h: 30.00,\n cache_read: 1.50\n },\n \"claude-3-5-sonnet-latest\": {\n name: \"Claude 3.5 Sonnet Latest\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n },\n \"claude-3-5-sonnet-20240620\": {\n name: \"Claude 3.5 Sonnet\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n },\n \"claude-3-5-sonnet-20241022\": {\n name: \"Claude 3.5 Sonnet\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n },\n \"claude-opus-4-20250514\": {\n name: \"Claude Opus 4\",\n input: 15.00,\n output: 75.00,\n cache_write_5m: 18.75,\n cache_write_1h: 30.00,\n cache_read: 1.50\n },\n \"claude-opus-4-1\": {\n name: \"Claude Opus 4.1\",\n input: 15.00,\n output: 75.00,\n cache_write_5m: 18.75,\n cache_write_1h: 30.00,\n cache_read: 1.50\n },\n \"claude-opus-4-1-20250805\": {\n name: \"Claude Opus 4.1\",\n input: 15.00,\n output: 75.00,\n cache_write_5m: 18.75,\n cache_write_1h: 30.00,\n cache_read: 1.50\n },\n \"claude-sonnet-4-20250514\": {\n name: \"Claude Sonnet 4\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n },\n \"claude-4-opus-20250514\": {\n name: \"Claude 4 Opus\",\n input: 15.00,\n output: 75.00,\n cache_write_5m: 18.75,\n cache_write_1h: 30.00,\n cache_read: 1.50\n },\n \"claude-4-sonnet-20250514\": {\n name: \"Claude 4 Sonnet\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n },\n \"claude-3-7-sonnet-latest\": {\n name: \"Claude 3.7 Sonnet Latest\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n },\n \"claude-3-7-sonnet-20250219\": {\n name: \"Claude 3.7 Sonnet\",\n input: 3.00,\n output: 15.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30\n }\n};\n\nexport class PricingService {\n private static memoryCache: Map<string, { data: Record<string, ModelPricing>; timestamp: number }> = new Map();\n private static readonly CACHE_TTL = 24 * 60 * 60 * 1000;\n private static readonly GITHUB_PRICING_URL = \"https://raw.githubusercontent.com/Owloops/claude-powerline/main/pricing.json\";\n\n private static getCacheFilePath(): string {\n const { homedir } = require('os');\n const { join } = require('path');\n const { mkdirSync } = require('fs');\n \n const cacheDir = join(homedir(), '.claude', 'cache');\n try {\n mkdirSync(cacheDir, { recursive: true });\n } catch {}\n \n return join(cacheDir, 'pricing.json');\n }\n\n private static loadDiskCache(): { data: Record<string, ModelPricing>; timestamp: number } | null {\n try {\n const { readFileSync } = require('fs');\n const cacheFile = this.getCacheFilePath();\n const content = readFileSync(cacheFile, 'utf-8');\n const cached = JSON.parse(content);\n \n if (cached && cached.data && cached.timestamp) {\n return cached;\n }\n } catch {}\n return null;\n }\n\n private static saveDiskCache(data: Record<string, ModelPricing>): void {\n try {\n const { writeFileSync } = require('fs');\n const cacheFile = this.getCacheFilePath();\n const cacheData = { data, timestamp: Date.now() };\n writeFileSync(cacheFile, JSON.stringify(cacheData));\n } catch (error) {\n debug('Failed to save pricing cache to disk:', error);\n }\n }\n\n static async getCurrentPricing(): Promise<Record<string, ModelPricing>> {\n const now = Date.now();\n\n const memCached = this.memoryCache.get('pricing');\n if (memCached && now - memCached.timestamp < this.CACHE_TTL) {\n debug(`Using memory cached pricing data for ${Object.keys(memCached.data).length} models`);\n return memCached.data;\n }\n\n const diskCached = this.loadDiskCache();\n if (diskCached && now - diskCached.timestamp < this.CACHE_TTL) {\n this.memoryCache.set('pricing', diskCached);\n debug(`Using disk cached pricing data for ${Object.keys(diskCached.data).length} models`);\n return diskCached.data;\n }\n\n try {\n const response = await globalThis.fetch(this.GITHUB_PRICING_URL, {\n headers: {\n 'User-Agent': 'claude-powerline',\n 'Cache-Control': 'no-cache'\n }\n });\n\n if (response.ok) {\n const data = await response.json();\n \n const dataObj = data as Record<string, unknown>;\n const meta = dataObj._meta as { updated?: string } | undefined;\n \n const pricingData: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(dataObj)) {\n if (key !== '_meta') {\n pricingData[key] = value;\n }\n }\n \n if (this.validatePricingData(pricingData)) {\n this.memoryCache.set('pricing', { data: pricingData, timestamp: now });\n this.saveDiskCache(pricingData);\n debug(`Fetched fresh pricing from GitHub for ${Object.keys(pricingData).length} models`);\n debug(`Pricing last updated: ${meta?.updated || 'unknown'}`);\n return pricingData;\n }\n }\n } catch (error) {\n debug('Failed to fetch pricing from GitHub, using fallback:', error);\n }\n\n if (diskCached) {\n this.memoryCache.set('pricing', diskCached);\n debug(`Using stale cached pricing data for ${Object.keys(diskCached.data).length} models`);\n return diskCached.data;\n }\n\n debug(`Using offline pricing data for ${Object.keys(OFFLINE_PRICING_DATA).length} models`);\n return OFFLINE_PRICING_DATA;\n }\n\n private static validatePricingData(data: unknown): data is Record<string, ModelPricing> {\n if (!data || typeof data !== 'object') return false;\n \n for (const [, value] of Object.entries(data)) {\n if (!value || typeof value !== 'object') return false;\n const pricing = value as Record<string, unknown>;\n \n if (typeof pricing.input !== 'number' || \n typeof pricing.output !== 'number' ||\n typeof pricing.cache_read !== 'number') {\n return false;\n }\n }\n \n return true;\n }\n\n static async getModelPricing(modelId: string): Promise<ModelPricing> {\n const allPricing = await this.getCurrentPricing();\n \n if (allPricing[modelId]) {\n return allPricing[modelId];\n }\n\n return this.fuzzyMatchModel(modelId, allPricing);\n }\n\n\n private static fuzzyMatchModel(modelId: string, allPricing: Record<string, ModelPricing>): ModelPricing {\n const lowerModelId = modelId.toLowerCase();\n \n for (const [key, pricing] of Object.entries(allPricing)) {\n if (key.toLowerCase() === lowerModelId) {\n return pricing;\n }\n }\n const patterns = [\n { pattern: ['opus-4-1', 'claude-opus-4-1'], fallback: 'claude-opus-4-1-20250805' },\n { pattern: ['opus-4', 'claude-opus-4'], fallback: 'claude-opus-4-20250514' },\n { pattern: ['sonnet-4', 'claude-sonnet-4'], fallback: 'claude-sonnet-4-20250514' },\n { pattern: ['sonnet-3.7', '3-7-sonnet'], fallback: 'claude-3-7-sonnet-20250219' },\n { pattern: ['3-5-sonnet', 'sonnet-3.5'], fallback: 'claude-3-5-sonnet-20241022' },\n { pattern: ['3-5-haiku', 'haiku-3.5'], fallback: 'claude-3-5-haiku-20241022' },\n { pattern: ['haiku', '3-haiku'], fallback: 'claude-3-haiku-20240307' },\n { pattern: ['opus'], fallback: 'claude-opus-4-20250514' },\n { pattern: ['sonnet'], fallback: 'claude-3-5-sonnet-20241022' },\n ];\n\n for (const { pattern, fallback } of patterns) {\n if (pattern.some(p => lowerModelId.includes(p))) {\n if (allPricing[fallback]) {\n return allPricing[fallback];\n }\n }\n }\n\n return allPricing['claude-3-5-sonnet-20241022'] || {\n name: `${modelId} (Unknown Model)`,\n input: 3.00,\n cache_write_5m: 3.75,\n cache_write_1h: 6.00,\n cache_read: 0.30,\n output: 15.00\n };\n }\n\n static async calculateCostForEntry(entry: any): Promise<number> {\n const message = entry.message;\n const usage = message?.usage;\n if (!usage) return 0;\n\n const modelId = this.extractModelId(entry);\n const pricing = await this.getModelPricing(modelId);\n \n const inputTokens = usage.input_tokens || 0;\n const outputTokens = usage.output_tokens || 0;\n const cacheCreationTokens = usage.cache_creation_input_tokens || 0;\n const cacheReadTokens = usage.cache_read_input_tokens || 0;\n \n const inputCost = (inputTokens / 1_000_000) * pricing.input;\n const outputCost = (outputTokens / 1_000_000) * pricing.output;\n const cacheReadCost = (cacheReadTokens / 1_000_000) * pricing.cache_read;\n const cacheCreationCost = (cacheCreationTokens / 1_000_000) * pricing.cache_write_5m;\n \n return inputCost + outputCost + cacheCreationCost + cacheReadCost;\n }\n\n private static extractModelId(entry: any): string {\n if (entry.model && typeof entry.model === 'string') {\n return entry.model;\n }\n \n const message = entry.message;\n if (message?.model) {\n const model = message.model;\n if (typeof model === 'string') {\n return model;\n }\n return model?.id || 'claude-3-5-sonnet-20241022';\n }\n \n if (entry.model_id && typeof entry.model_id === 'string') {\n return entry.model_id;\n }\n \n return 'claude-3-5-sonnet-20241022';\n }\n}","import { readdir } from \"node:fs/promises\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { debug } from \"./logger\";\n\nexport function getClaudePaths(): string[] {\n const paths: string[] = [];\n \n const homeDir = homedir();\n const defaultPath = join(homeDir, \".claude\");\n \n if (existsSync(defaultPath)) {\n paths.push(defaultPath);\n }\n \n return paths;\n}\n\nexport async function findProjectPaths(claudePaths: string[]): Promise<string[]> {\n const projectPaths: string[] = [];\n \n for (const claudePath of claudePaths) {\n const projectsDir = join(claudePath, \"projects\");\n \n if (existsSync(projectsDir)) {\n try {\n const entries = await readdir(projectsDir, { withFileTypes: true });\n \n for (const entry of entries) {\n if (entry.isDirectory()) {\n const projectPath = join(projectsDir, entry.name);\n projectPaths.push(projectPath);\n }\n }\n } catch (error) {\n debug(`Failed to read projects directory ${projectsDir}:`, error);\n }\n }\n }\n \n return projectPaths;\n}\n\nexport async function findTranscriptFile(sessionId: string): Promise<string | null> {\n const claudePaths = getClaudePaths();\n const projectPaths = await findProjectPaths(claudePaths);\n \n for (const projectPath of projectPaths) {\n const transcriptPath = join(projectPath, `${sessionId}.jsonl`);\n if (existsSync(transcriptPath)) {\n return transcriptPath;\n }\n }\n \n return null;\n}","import { readFileSync } from \"node:fs\";\nimport { debug } from \"../utils/logger\";\n\nexport interface ContextInfo {\n inputTokens: number;\n percentage: number;\n usablePercentage: number;\n contextLeftPercentage: number;\n maxTokens: number;\n usableTokens: number;\n}\n\ninterface ContextUsageThresholds {\n LOW: number;\n MEDIUM: number;\n}\n\ninterface TranscriptEntry {\n message?: {\n usage?: {\n input_tokens?: number;\n cache_read_input_tokens?: number;\n cache_creation_input_tokens?: number;\n };\n };\n isSidechain?: boolean;\n timestamp?: string;\n}\n\nexport class ContextProvider {\n private readonly thresholds: ContextUsageThresholds = {\n LOW: 50,\n MEDIUM: 80,\n };\n\n getContextUsageThresholds(): ContextUsageThresholds {\n return this.thresholds;\n }\n\n private getContextLimit(_modelId: string): number {\n return 200000;\n }\n\n calculateContextTokens(\n transcriptPath: string,\n modelId?: string\n ): ContextInfo | null {\n try {\n debug(`Calculating context tokens from transcript: ${transcriptPath}`);\n\n const content = readFileSync(transcriptPath, \"utf-8\");\n if (!content) {\n debug(\"Transcript file is empty\");\n return null;\n }\n\n const lines = content.trim().split(\"\\n\");\n if (lines.length === 0) {\n debug(\"No lines in transcript\");\n return null;\n }\n\n let mostRecentEntry: TranscriptEntry | null = null;\n let mostRecentTime = 0;\n\n for (const line of lines) {\n if (!line.trim()) continue;\n\n try {\n const entry: TranscriptEntry = JSON.parse(line);\n\n if (!entry.message?.usage?.input_tokens) continue;\n\n if (entry.isSidechain === true) continue;\n\n if (!entry.timestamp) continue;\n\n const entryTime = new Date(entry.timestamp).getTime();\n if (entryTime > mostRecentTime) {\n mostRecentTime = entryTime;\n mostRecentEntry = entry;\n }\n } catch {}\n }\n\n if (mostRecentEntry?.message?.usage) {\n const usage = mostRecentEntry.message.usage;\n const contextLength =\n (usage.input_tokens || 0) +\n (usage.cache_read_input_tokens || 0) +\n (usage.cache_creation_input_tokens || 0);\n\n const contextLimit = modelId ? this.getContextLimit(modelId) : 200000;\n\n debug(\n `Most recent main chain context: ${contextLength} tokens (limit: ${contextLimit})`\n );\n\n const percentage = Math.min(\n 100,\n Math.max(0, Math.round((contextLength / contextLimit) * 100))\n );\n\n const usableLimit = Math.round(contextLimit * 0.75);\n const usablePercentage = Math.min(\n 100,\n Math.max(0, Math.round((contextLength / usableLimit) * 100))\n );\n\n const contextLeftPercentage = Math.max(0, 100 - usablePercentage);\n\n return {\n inputTokens: contextLength,\n percentage,\n usablePercentage,\n contextLeftPercentage,\n maxTokens: contextLimit,\n usableTokens: usableLimit,\n };\n }\n\n debug(\"No main chain entries with usage data found\");\n return null;\n } catch (error) {\n debug(\n `Error reading transcript: ${error instanceof Error ? error.message : String(error)}`\n );\n return null;\n }\n }\n}\n","import { readFile } from \"node:fs/promises\";\nimport { debug } from \"../utils/logger\";\nimport { PricingService } from \"./pricing\";\nimport { findTranscriptFile } from \"../utils/claude\";\n\nexport interface MetricsInfo {\n responseTime: number | null;\n sessionDuration: number | null;\n messageCount: number | null;\n costBurnRate: number | null;\n tokenBurnRate: number | null;\n}\n\ninterface TranscriptEntry {\n timestamp: string;\n type?: string;\n message?: {\n role?: string;\n type?: string;\n usage?: {\n input_tokens?: number;\n output_tokens?: number;\n cache_creation_input_tokens?: number;\n cache_read_input_tokens?: number;\n };\n };\n costUSD?: number;\n}\n\n\nexport class MetricsProvider {\n\n private async loadTranscriptEntries(\n sessionId: string\n ): Promise<TranscriptEntry[]> {\n try {\n const transcriptPath = await findTranscriptFile(sessionId);\n if (!transcriptPath) {\n debug(`No transcript found for session: ${sessionId}`);\n return [];\n }\n\n debug(`Loading transcript from: ${transcriptPath}`);\n\n const content = await readFile(transcriptPath, \"utf-8\");\n const lines = content\n .trim()\n .split(\"\\n\")\n .filter((line) => line.trim());\n\n const entries: TranscriptEntry[] = [];\n\n for (const line of lines) {\n try {\n const entry = JSON.parse(line) as TranscriptEntry;\n entries.push(entry);\n } catch (parseError) {\n debug(`Failed to parse JSONL line: ${parseError}`);\n continue;\n }\n }\n\n debug(`Loaded ${entries.length} transcript entries`);\n return entries;\n } catch (error) {\n debug(`Error loading transcript for ${sessionId}:`, error);\n return [];\n }\n }\n\n private calculateResponseTimes(entries: TranscriptEntry[]): number | null {\n const userMessages: Date[] = [];\n const assistantMessages: Date[] = [];\n\n for (const entry of entries) {\n if (!entry.timestamp) continue;\n\n try {\n const timestamp = new Date(entry.timestamp);\n\n const messageType =\n entry.type || entry.message?.role || entry.message?.type;\n\n if (messageType === \"user\" || messageType === \"human\") {\n userMessages.push(timestamp);\n debug(`Found user message at ${timestamp.toISOString()}`);\n } else if (messageType === \"assistant\" || messageType === \"ai\") {\n assistantMessages.push(timestamp);\n debug(`Found assistant message at ${timestamp.toISOString()}`);\n } else if (entry.message?.usage) {\n assistantMessages.push(timestamp);\n debug(\n `Found assistant message with usage at ${timestamp.toISOString()}`\n );\n } else {\n debug(\n `Unknown message type: ${messageType}, has usage: ${!!entry.message?.usage}`\n );\n }\n } catch {\n continue;\n }\n }\n\n if (userMessages.length === 0 || assistantMessages.length === 0) {\n return null;\n }\n\n const responseTimes: number[] = [];\n\n for (const assistantTime of assistantMessages) {\n const priorUsers = userMessages.filter(\n (userTime) => userTime < assistantTime\n );\n\n if (priorUsers.length > 0) {\n const userTime = new Date(\n Math.max(...priorUsers.map((d) => d.getTime()))\n );\n const responseTime =\n (assistantTime.getTime() - userTime.getTime()) / 1000;\n\n if (responseTime > 0.1 && responseTime < 300) {\n responseTimes.push(responseTime);\n debug(`Valid response time: ${responseTime.toFixed(1)}s`);\n } else {\n debug(\n `Rejected response time: ${responseTime.toFixed(1)}s (outside 0.1s-5m range)`\n );\n }\n }\n }\n\n if (responseTimes.length === 0) {\n return null;\n }\n\n return (\n responseTimes.reduce((sum, time) => sum + time, 0) / responseTimes.length\n );\n }\n\n private calculateSessionDuration(entries: TranscriptEntry[]): number | null {\n const timestamps: Date[] = [];\n\n for (const entry of entries) {\n if (!entry.timestamp) continue;\n\n try {\n timestamps.push(new Date(entry.timestamp));\n } catch {\n continue;\n }\n }\n\n if (timestamps.length < 2) {\n return null;\n }\n\n timestamps.sort((a, b) => a.getTime() - b.getTime());\n\n const lastTimestamp = timestamps[timestamps.length - 1];\n const firstTimestamp = timestamps[0];\n\n if (!lastTimestamp || !firstTimestamp) {\n return null;\n }\n\n const duration =\n (lastTimestamp.getTime() - firstTimestamp.getTime()) / 1000;\n return duration > 0 ? duration : null;\n }\n\n private calculateMessageCount(entries: TranscriptEntry[]): number {\n return entries.filter((entry) => {\n const messageType =\n entry.type || entry.message?.role || entry.message?.type;\n return messageType === \"user\" || messageType === \"human\";\n }).length;\n }\n\n private async calculateTotalCost(\n entries: TranscriptEntry[]\n ): Promise<number> {\n let total = 0;\n\n for (const entry of entries) {\n if (typeof entry.costUSD === \"number\") {\n total += entry.costUSD;\n } else if (entry.message?.usage) {\n const cost = await PricingService.calculateCostForEntry(entry);\n total += cost;\n }\n }\n\n return total;\n }\n\n private calculateTotalTokens(entries: TranscriptEntry[]): number {\n return entries.reduce((total, entry) => {\n const usage = entry.message?.usage;\n if (!usage) return total;\n\n return (\n total +\n (usage.input_tokens || 0) +\n (usage.output_tokens || 0) +\n (usage.cache_creation_input_tokens || 0) +\n (usage.cache_read_input_tokens || 0)\n );\n }, 0);\n }\n\n async getMetricsInfo(sessionId: string): Promise<MetricsInfo> {\n try {\n debug(`Starting metrics calculation for session: ${sessionId}`);\n\n const entries = await this.loadTranscriptEntries(sessionId);\n\n if (entries.length === 0) {\n return {\n responseTime: null,\n sessionDuration: null,\n messageCount: null,\n costBurnRate: null,\n tokenBurnRate: null,\n };\n }\n\n const responseTime = this.calculateResponseTimes(entries);\n const sessionDuration = this.calculateSessionDuration(entries);\n const messageCount = this.calculateMessageCount(entries);\n\n let costBurnRate: number | null = null;\n let tokenBurnRate: number | null = null;\n\n if (sessionDuration && sessionDuration > 0) {\n const hoursElapsed = sessionDuration / 3600;\n\n const totalCost = await this.calculateTotalCost(entries);\n const totalTokens = this.calculateTotalTokens(entries);\n\n if (totalCost > 0) {\n costBurnRate = totalCost / hoursElapsed;\n }\n\n if (totalTokens > 0) {\n tokenBurnRate = totalTokens / hoursElapsed;\n }\n }\n\n debug(\n `Metrics calculated: responseTime=${responseTime?.toFixed(2) || \"null\"}s, sessionDuration=${sessionDuration?.toFixed(0) || \"null\"}s, messageCount=${messageCount}`\n );\n\n return {\n responseTime,\n sessionDuration,\n messageCount,\n costBurnRate,\n tokenBurnRate,\n };\n } catch (error) {\n debug(`Error calculating metrics for session ${sessionId}:`, error);\n return {\n responseTime: null,\n sessionDuration: null,\n messageCount: null,\n costBurnRate: null,\n tokenBurnRate: null,\n };\n }\n }\n}\n","interface TokenBreakdown {\n input: number;\n output: number;\n cacheCreation: number;\n cacheRead: number;\n}\n\nexport function formatCost(cost: number | null): string {\n if (cost === null) return \"$0.00\";\n if (cost < 0.01) return \"<$0.01\";\n return `$${cost.toFixed(2)}`;\n}\n\nexport function formatTokens(tokens: number | null): string {\n if (tokens === null) return \"0 tokens\";\n if (tokens === 0) return \"0 tokens\";\n if (tokens >= 1_000_000) {\n return `${(tokens / 1_000_000).toFixed(1)}M tokens`;\n } else if (tokens >= 1_000) {\n return `${(tokens / 1_000).toFixed(1)}K tokens`;\n }\n return `${tokens} tokens`;\n}\n\nexport function formatTokenBreakdown(breakdown: TokenBreakdown | null): string {\n if (!breakdown) return \"0 tokens\";\n\n const parts: string[] = [];\n\n if (breakdown.input > 0) {\n parts.push(`${formatTokens(breakdown.input).replace(\" tokens\", \"\")}in`);\n }\n\n if (breakdown.output > 0) {\n parts.push(`${formatTokens(breakdown.output).replace(\" tokens\", \"\")}out`);\n }\n\n if (breakdown.cacheCreation > 0 || breakdown.cacheRead > 0) {\n const totalCached = breakdown.cacheCreation + breakdown.cacheRead;\n parts.push(`${formatTokens(totalCached).replace(\" tokens\", \"\")}cached`);\n }\n\n return parts.length > 0 ? parts.join(\" + \") : \"0 tokens\";\n}\n","export interface BudgetStatus {\n percentage: number | null;\n isWarning: boolean;\n displayText: string;\n}\n\nexport function calculateBudgetPercentage(\n cost: number,\n budget: number | undefined\n): number | null {\n if (!budget || budget <= 0 || cost < 0) return null;\n return Math.min(100, (cost / budget) * 100);\n}\n\nexport function getBudgetStatus(\n cost: number,\n budget: number | undefined,\n warningThreshold = 80\n): BudgetStatus {\n const percentage = calculateBudgetPercentage(cost, budget);\n\n if (percentage === null) {\n return {\n percentage: null,\n isWarning: false,\n displayText: \"\",\n };\n }\n\n const percentStr = `${percentage.toFixed(0)}%`;\n const isWarning = percentage >= warningThreshold;\n\n let displayText = \"\";\n if (isWarning) {\n displayText = ` !${percentStr}`;\n } else if (percentage >= 50) {\n displayText = ` +${percentStr}`;\n } else {\n displayText = ` ${percentStr}`;\n }\n\n return {\n percentage,\n isWarning,\n displayText,\n };\n}\n","import type { ClaudeHookData } from \"../index\";\nimport type { PowerlineColors } from \"../themes\";\nimport type { PowerlineConfig } from \"../config/loader\";\n\nexport interface SegmentConfig {\n enabled: boolean;\n}\n\nexport interface GitSegmentConfig extends SegmentConfig {\n showSha: boolean;\n}\n\nexport interface UsageSegmentConfig extends SegmentConfig {\n type: \"cost\" | \"tokens\" | \"both\" | \"breakdown\";\n}\n\nexport interface TmuxSegmentConfig extends SegmentConfig {}\n\nexport interface ContextSegmentConfig extends SegmentConfig {}\n\nexport interface MetricsSegmentConfig extends SegmentConfig {\n showResponseTime?: boolean;\n showDuration?: boolean;\n showMessageCount?: boolean;\n showCostBurnRate?: boolean;\n showTokenBurnRate?: boolean;\n}\n\nexport type AnySegmentConfig =\n | SegmentConfig\n | GitSegmentConfig\n | UsageSegmentConfig\n | TmuxSegmentConfig\n | ContextSegmentConfig\n | MetricsSegmentConfig;\n\nimport {\n formatCost,\n formatTokens,\n formatTokenBreakdown,\n} from \"../utils/formatters\";\nimport { getBudgetStatus } from \"../utils/budget\";\nimport type {\n UsageInfo,\n TokenBreakdown,\n GitInfo,\n ContextInfo,\n MetricsInfo,\n} from \".\";\n\nexport interface PowerlineSymbols {\n right: string;\n branch: string;\n model: string;\n git_clean: string;\n git_dirty: string;\n git_conflicts: string;\n git_ahead: string;\n git_behind: string;\n session_cost: string;\n context_time: string;\n metrics_response: string;\n metrics_duration: string;\n metrics_messages: string;\n metrics_burn: string;\n}\n\nexport interface SegmentData {\n text: string;\n bgColor: string;\n fgColor: string;\n}\n\nexport class SegmentRenderer {\n constructor(\n private readonly config: PowerlineConfig,\n private readonly symbols: PowerlineSymbols\n ) {}\n\n renderDirectory(\n hookData: ClaudeHookData,\n colors: PowerlineColors\n ): SegmentData {\n const currentDir = hookData.workspace?.current_dir || hookData.cwd || \"/\";\n const projectDir = hookData.workspace?.project_dir;\n const dirName = this.getDisplayDirectoryName(currentDir, projectDir);\n\n return {\n text: dirName,\n bgColor: colors.modeBg,\n fgColor: colors.modeFg,\n };\n }\n\n renderGit(\n gitInfo: GitInfo,\n colors: PowerlineColors,\n showSha = false\n ): SegmentData | null {\n if (!gitInfo) return null;\n\n let gitStatusIcon = this.symbols.git_clean;\n if (gitInfo.status === \"conflicts\") {\n gitStatusIcon = this.symbols.git_conflicts;\n } else if (gitInfo.status === \"dirty\") {\n gitStatusIcon = this.symbols.git_dirty;\n }\n\n let text = `${this.symbols.branch} ${gitInfo.branch} ${gitStatusIcon}`;\n\n if (gitInfo.sha && showSha) {\n text += ` ${gitInfo.sha}`;\n }\n\n if (gitInfo.ahead > 0 && gitInfo.behind > 0) {\n text += ` ${this.symbols.git_ahead}${gitInfo.ahead}${this.symbols.git_behind}${gitInfo.behind}`;\n } else if (gitInfo.ahead > 0) {\n text += ` ${this.symbols.git_ahead}${gitInfo.ahead}`;\n } else if (gitInfo.behind > 0) {\n text += ` ${this.symbols.git_behind}${gitInfo.behind}`;\n }\n\n return {\n text,\n bgColor: colors.gitBg,\n fgColor: colors.gitFg,\n };\n }\n\n renderModel(hookData: ClaudeHookData, colors: PowerlineColors): SegmentData {\n const modelName = hookData.model?.display_name || \"Claude\";\n\n return {\n text: `${this.symbols.model} ${modelName}`,\n bgColor: colors.modelBg,\n fgColor: colors.modelFg,\n };\n }\n\n renderSession(\n usageInfo: UsageInfo,\n colors: PowerlineColors,\n type = \"cost\"\n ): SegmentData {\n const sessionBudget = this.config.budget?.session;\n const text = `${this.symbols.session_cost} ${this.formatUsageWithBudget(\n usageInfo.session.cost,\n usageInfo.session.tokens,\n usageInfo.session.tokenBreakdown,\n type,\n sessionBudget?.amount,\n sessionBudget?.warningThreshold || 80\n )}`;\n\n return {\n text,\n bgColor: colors.sessionBg,\n fgColor: colors.sessionFg,\n };\n }\n\n renderTmux(\n sessionId: string | null,\n colors: PowerlineColors\n ): SegmentData | null {\n if (!sessionId) {\n return {\n text: `tmux:none`,\n bgColor: colors.tmuxBg,\n fgColor: colors.tmuxFg,\n };\n }\n\n return {\n text: `tmux:${sessionId}`,\n bgColor: colors.tmuxBg,\n fgColor: colors.tmuxFg,\n };\n }\n\n renderContext(\n contextInfo: ContextInfo | null,\n colors: PowerlineColors\n ): SegmentData | null {\n if (!contextInfo) {\n return {\n text: `${this.symbols.context_time} 0 (100%)`,\n bgColor: colors.contextBg,\n fgColor: colors.contextFg,\n };\n }\n\n const tokenDisplay = contextInfo.inputTokens.toLocaleString();\n\n const contextLeft = `${contextInfo.contextLeftPercentage}%`;\n\n return {\n text: `${this.symbols.context_time} ${tokenDisplay} (${contextLeft})`,\n bgColor: colors.contextBg,\n fgColor: colors.contextFg,\n };\n }\n\n renderMetrics(\n metricsInfo: MetricsInfo | null,\n colors: PowerlineColors,\n config?: MetricsSegmentConfig\n ): SegmentData | null {\n if (!metricsInfo) {\n return {\n text: `${this.symbols.metrics_response} new`,\n bgColor: colors.metricsBg,\n fgColor: colors.metricsFg,\n };\n }\n\n const parts: string[] = [];\n\n if (\n config?.showResponseTime !== false &&\n metricsInfo.responseTime !== null\n ) {\n const responseTime =\n metricsInfo.responseTime < 60\n ? `${metricsInfo.responseTime.toFixed(1)}s`\n : `${(metricsInfo.responseTime / 60).toFixed(1)}m`;\n parts.push(`${this.symbols.metrics_response} ${responseTime}`);\n }\n\n if (\n config?.showDuration !== false &&\n metricsInfo.sessionDuration !== null\n ) {\n const duration = this.formatDuration(metricsInfo.sessionDuration);\n parts.push(`${this.symbols.metrics_duration} ${duration}`);\n }\n\n if (\n config?.showMessageCount !== false &&\n metricsInfo.messageCount !== null\n ) {\n parts.push(\n `${this.symbols.metrics_messages} ${metricsInfo.messageCount}`\n );\n }\n\n if (config?.showCostBurnRate && metricsInfo.costBurnRate !== null) {\n const burnRate =\n metricsInfo.costBurnRate < 1\n ? `${(metricsInfo.costBurnRate * 100).toFixed(0)}¢/h`\n : `$${metricsInfo.costBurnRate.toFixed(2)}/h`;\n parts.push(`${this.symbols.metrics_burn} ${burnRate}`);\n }\n\n if (config?.showTokenBurnRate && metricsInfo.tokenBurnRate !== null) {\n const tokenRate = formatTokens(Math.round(metricsInfo.tokenBurnRate));\n parts.push(`${this.symbols.metrics_burn} ${tokenRate}/h`);\n }\n\n if (parts.length === 0) {\n return {\n text: `${this.symbols.metrics_response} active`,\n bgColor: colors.metricsBg,\n fgColor: colors.metricsFg,\n };\n }\n\n return {\n text: parts.join(\" \"),\n bgColor: colors.metricsBg,\n fgColor: colors.metricsFg,\n };\n }\n\n private formatDuration(seconds: number): string {\n if (seconds < 60) {\n return `${seconds.toFixed(0)}s`;\n } else if (seconds < 3600) {\n return `${(seconds / 60).toFixed(0)}m`;\n } else if (seconds < 86400) {\n return `${(seconds / 3600).toFixed(1)}h`;\n } else {\n return `${(seconds / 86400).toFixed(1)}d`;\n }\n }\n\n private getDisplayDirectoryName(\n currentDir: string,\n projectDir?: string\n ): string {\n if (projectDir && projectDir !== currentDir) {\n const projectName = projectDir.split(\"/\").pop() || \"project\";\n const currentDirName = currentDir.split(\"/\").pop() || \"root\";\n\n if (currentDir.includes(projectDir)) {\n return `${projectName}/${currentDirName}`;\n }\n\n return currentDirName;\n }\n\n return currentDir.split(\"/\").pop() || \"root\";\n }\n\n private formatUsageDisplay(\n cost: number | null,\n tokens: number | null,\n tokenBreakdown: TokenBreakdown | null,\n type: string\n ): string {\n switch (type) {\n case \"cost\":\n return formatCost(cost);\n case \"tokens\":\n return formatTokens(tokens);\n case \"both\":\n return `${formatCost(cost)} (${formatTokens(tokens)})`;\n case \"breakdown\":\n return formatTokenBreakdown(tokenBreakdown);\n default:\n return formatCost(cost);\n }\n }\n\n private formatUsageWithBudget(\n cost: number | null,\n tokens: number | null,\n tokenBreakdown: TokenBreakdown | null,\n type: string,\n budget: number | undefined,\n warningThreshold = 80\n ): string {\n const baseDisplay = this.formatUsageDisplay(\n cost,\n tokens,\n tokenBreakdown,\n type\n );\n\n if (budget && budget > 0 && cost !== null) {\n const budgetStatus = getBudgetStatus(cost, budget, warningThreshold);\n return baseDisplay + budgetStatus.displayText;\n }\n\n return baseDisplay;\n }\n}\n","import type { ClaudeHookData } from \"./index\";\nimport type { PowerlineColors } from \"./themes\";\nimport type { PowerlineConfig, LineConfig } from \"./config/loader\";\nimport { hexToAnsi, extractBgToFg } from \"./utils/colors\";\nimport { getTheme } from \"./themes\";\nimport {\n UsageProvider,\n UsageInfo,\n ContextProvider,\n ContextInfo,\n GitService,\n TmuxService,\n MetricsProvider,\n MetricsInfo,\n SegmentRenderer,\n PowerlineSymbols,\n AnySegmentConfig,\n GitSegmentConfig,\n UsageSegmentConfig,\n MetricsSegmentConfig,\n} from \"./segments\";\n\nexport class PowerlineRenderer {\n private readonly symbols: PowerlineSymbols;\n private readonly usageProvider: UsageProvider;\n private readonly contextProvider: ContextProvider;\n private readonly gitService: GitService;\n private readonly tmuxService: TmuxService;\n private readonly metricsProvider: MetricsProvider;\n private readonly segmentRenderer: SegmentRenderer;\n\n constructor(private readonly config: PowerlineConfig) {\n this.symbols = this.initializeSymbols();\n this.usageProvider = new UsageProvider();\n this.contextProvider = new ContextProvider();\n this.gitService = new GitService();\n this.tmuxService = new TmuxService();\n this.metricsProvider = new MetricsProvider();\n this.segmentRenderer = new SegmentRenderer(config, this.symbols);\n }\n\n private needsUsageInfo(): boolean {\n return this.config.display.lines.some(\n (line) => line.segments.session?.enabled\n );\n }\n\n private needsGitInfo(): boolean {\n return this.config.display.lines.some((line) => line.segments.git?.enabled);\n }\n\n private needsTmuxInfo(): boolean {\n return this.config.display.lines.some(\n (line) => line.segments.tmux?.enabled\n );\n }\n\n private needsContextInfo(): boolean {\n return this.config.display.lines.some(\n (line) => line.segments.context?.enabled\n );\n }\n\n private needsMetricsInfo(): boolean {\n return this.config.display.lines.some(\n (line) => line.segments.metrics?.enabled\n );\n }\n\n async generateStatusline(hookData: ClaudeHookData): Promise<string> {\n const usageInfo = this.needsUsageInfo()\n ? await this.usageProvider.getUsageInfo(hookData.session_id)\n : null;\n\n const contextInfo = this.needsContextInfo()\n ? this.contextProvider.calculateContextTokens(\n hookData.transcript_path,\n hookData.model?.id\n )\n : null;\n\n const metricsInfo = this.needsMetricsInfo()\n ? await this.metricsProvider.getMetricsInfo(hookData.session_id)\n : null;\n\n const lines = this.config.display.lines\n .map((lineConfig) =>\n this.renderLine(\n lineConfig,\n hookData,\n usageInfo,\n contextInfo,\n metricsInfo\n )\n )\n .filter((line) => line.length > 0);\n\n return lines.join(\"\\n\");\n }\n\n private renderLine(\n lineConfig: LineConfig,\n hookData: ClaudeHookData,\n usageInfo: UsageInfo | null,\n contextInfo: ContextInfo | null,\n metricsInfo: MetricsInfo | null\n ): string {\n const colors = this.getThemeColors();\n const currentDir = hookData.workspace?.current_dir || hookData.cwd || \"/\";\n\n const segments = Object.entries(lineConfig.segments)\n .filter(\n ([_, config]: [string, AnySegmentConfig | undefined]) => config?.enabled\n )\n .map(([type, config]: [string, AnySegmentConfig]) => ({ type, config }));\n\n let line = colors.reset;\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n if (!segment) continue;\n\n const isLast = i === segments.length - 1;\n const nextSegment = !isLast ? segments[i + 1] : null;\n const nextBgColor = nextSegment\n ? this.getSegmentBgColor(nextSegment.type, colors)\n : \"\";\n\n const segmentData = this.renderSegment(\n segment,\n hookData,\n usageInfo,\n contextInfo,\n metricsInfo,\n colors,\n currentDir\n );\n\n if (segmentData) {\n line += this.formatSegment(\n segmentData.bgColor,\n segmentData.fgColor,\n segmentData.text,\n isLast ? undefined : nextBgColor\n );\n }\n }\n\n return line;\n }\n\n private renderSegment(\n segment: { type: string; config: AnySegmentConfig },\n hookData: ClaudeHookData,\n usageInfo: UsageInfo | null,\n contextInfo: ContextInfo | null,\n metricsInfo: MetricsInfo | null,\n colors: PowerlineColors,\n currentDir: string\n ) {\n switch (segment.type) {\n case \"directory\":\n return this.segmentRenderer.renderDirectory(hookData, colors);\n\n case \"git\":\n if (!this.needsGitInfo()) return null;\n const showSha = (segment.config as GitSegmentConfig)?.showSha || false;\n const gitInfo = this.gitService.getGitInfo(currentDir, showSha);\n return gitInfo\n ? this.segmentRenderer.renderGit(gitInfo, colors, showSha)\n : null;\n\n case \"model\":\n return this.segmentRenderer.renderModel(hookData, colors);\n\n case \"session\":\n if (!usageInfo) return null;\n const usageType =\n (segment.config as UsageSegmentConfig)?.type || \"cost\";\n return this.segmentRenderer.renderSession(usageInfo, colors, usageType);\n\n case \"tmux\":\n if (!this.needsTmuxInfo()) return null;\n const tmuxSessionId = this.tmuxService.getSessionId();\n return this.segmentRenderer.renderTmux(tmuxSessionId, colors);\n\n case \"context\":\n if (!this.needsContextInfo()) return null;\n return this.segmentRenderer.renderContext(contextInfo, colors);\n\n case \"metrics\":\n const metricsConfig = segment.config as MetricsSegmentConfig;\n return this.segmentRenderer.renderMetrics(\n metricsInfo,\n colors,\n metricsConfig\n );\n\n default:\n return null;\n }\n }\n\n private initializeSymbols(): PowerlineSymbols {\n const isMinimalStyle = this.config.display.style === \"minimal\";\n\n return {\n right: isMinimalStyle ? \"\" : \"\\uE0B0\",\n branch: \"⑂\",\n model: \"⚡\",\n git_clean: \"✓\",\n git_dirty: \"●\",\n git_conflicts: \"⚠\",\n git_ahead: \"↑\",\n git_behind: \"↓\",\n session_cost: \"⊡\",\n context_time: \"◷\",\n metrics_response: \"⧖\",\n metrics_duration: \"⧗\",\n metrics_messages: \"⟐\",\n metrics_burn: \"⟢\",\n };\n }\n\n private getThemeColors(): PowerlineColors {\n const theme = this.config.theme;\n let colorTheme;\n\n if (theme === \"custom\") {\n colorTheme = this.config.colors?.custom;\n if (!colorTheme) {\n throw new Error(\n \"Custom theme selected but no colors provided in configuration\"\n );\n }\n } else {\n colorTheme = getTheme(theme);\n if (!colorTheme) {\n console.warn(\n `Built-in theme '${theme}' not found, falling back to 'dark' theme`\n );\n colorTheme = getTheme(\"dark\")!;\n }\n }\n\n return {\n reset: \"\\x1b[0m\",\n modeBg: hexToAnsi(colorTheme.directory.bg, true),\n modeFg: hexToAnsi(colorTheme.directory.fg, false),\n gitBg: hexToAnsi(colorTheme.git.bg, true),\n gitFg: hexToAnsi(colorTheme.git.fg, false),\n modelBg: hexToAnsi(colorTheme.model.bg, true),\n modelFg: hexToAnsi(colorTheme.model.fg, false),\n sessionBg: hexToAnsi(colorTheme.session.bg, true),\n sessionFg: hexToAnsi(colorTheme.session.fg, false),\n tmuxBg: hexToAnsi(colorTheme.tmux.bg, true),\n tmuxFg: hexToAnsi(colorTheme.tmux.fg, false),\n contextBg: hexToAnsi(colorTheme.context.bg, true),\n contextFg: hexToAnsi(colorTheme.context.fg, false),\n metricsBg: hexToAnsi(colorTheme.metrics.bg, true),\n metricsFg: hexToAnsi(colorTheme.metrics.fg, false),\n };\n }\n\n private getSegmentBgColor(\n segmentType: string,\n colors: PowerlineColors\n ): string {\n switch (segmentType) {\n case \"directory\":\n return colors.modeBg;\n case \"git\":\n return colors.gitBg;\n case \"model\":\n return colors.modelBg;\n case \"session\":\n return colors.sessionBg;\n case \"tmux\":\n return colors.tmuxBg;\n case \"context\":\n return colors.contextBg;\n case \"metrics\":\n return colors.metricsBg;\n default:\n return colors.modeBg;\n }\n }\n\n private formatSegment(\n bgColor: string,\n fgColor: string,\n text: string,\n nextBgColor?: string\n ): string {\n let output = `${bgColor}${fgColor} ${text} `;\n\n const reset = \"\\x1b[0m\";\n\n if (nextBgColor) {\n const arrowFgColor = extractBgToFg(bgColor);\n output += `${reset}${nextBgColor}${arrowFgColor}${this.symbols.right}`;\n } else {\n output += `${reset}${extractBgToFg(bgColor)}${this.symbols.right}${reset}`;\n }\n\n return output;\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport os from \"node:os\";\nimport { DEFAULT_CONFIG } from \"./defaults\";\nimport type { ColorTheme } from \"../themes\";\nimport type {\n SegmentConfig,\n GitSegmentConfig,\n UsageSegmentConfig,\n TmuxSegmentConfig,\n ContextSegmentConfig,\n MetricsSegmentConfig,\n} from \"../segments/renderer\";\n\nexport interface LineConfig {\n segments: {\n directory?: SegmentConfig;\n git?: GitSegmentConfig;\n model?: SegmentConfig;\n session?: UsageSegmentConfig;\n tmux?: TmuxSegmentConfig;\n context?: ContextSegmentConfig;\n metrics?: MetricsSegmentConfig;\n };\n}\n\nexport interface DisplayConfig {\n lines: LineConfig[];\n style?: \"minimal\" | \"powerline\";\n}\n\nexport interface BudgetItemConfig {\n amount?: number;\n warningThreshold?: number;\n}\n\nexport interface BudgetConfig {\n session?: BudgetItemConfig;\n}\n\nexport interface PowerlineConfig {\n theme: \"light\" | \"dark\" | \"nord\" | \"tokyo-night\" | \"rose-pine\" | \"custom\";\n display: DisplayConfig;\n colors?: {\n custom: ColorTheme;\n };\n budget?: BudgetConfig;\n usageType?: \"cost\" | \"tokens\" | \"both\" | \"breakdown\";\n}\n\nexport interface ConfigLoadOptions {\n configPath?: string;\n ignoreEnvVars?: boolean;\n cliOverrides?: Partial<PowerlineConfig>;\n projectDir?: string;\n}\n\nfunction deepMerge<T extends Record<string, any>>(\n target: T,\n source: Partial<T>\n): T {\n const result = { ...target };\n\n for (const key in source) {\n const sourceValue = source[key];\n if (sourceValue !== undefined) {\n if (\n typeof sourceValue === \"object\" &&\n sourceValue !== null &&\n !Array.isArray(sourceValue)\n ) {\n const targetValue = result[key] || {};\n result[key] = deepMerge(\n targetValue as Record<string, any>,\n sourceValue as Record<string, any>\n ) as T[Extract<keyof T, string>];\n } else if (Array.isArray(sourceValue) && sourceValue.length === 0) {\n const targetValue = result[key];\n if (!Array.isArray(targetValue) || targetValue.length > 0) {\n continue;\n } else {\n result[key] = sourceValue as T[Extract<keyof T, string>];\n }\n } else {\n result[key] = sourceValue as T[Extract<keyof T, string>];\n }\n }\n }\n\n return result;\n}\n\nfunction findConfigFile(\n customPath?: string,\n projectDir?: string\n): string | null {\n if (customPath) {\n return fs.existsSync(customPath) ? customPath : null;\n }\n\n const locations = [\n ...(projectDir ? [path.join(projectDir, \".claude-powerline.json\")] : []),\n path.join(process.cwd(), \".claude-powerline.json\"),\n path.join(os.homedir(), \".claude\", \"claude-powerline.json\"),\n path.join(os.homedir(), \".config\", \"claude-powerline\", \"config.json\"),\n ];\n\n return locations.find(fs.existsSync) || null;\n}\n\nfunction loadConfigFile(filePath: string): Partial<PowerlineConfig> {\n try {\n const content = fs.readFileSync(filePath, \"utf-8\");\n return JSON.parse(content);\n } catch (error) {\n throw new Error(\n `Failed to load config file ${filePath}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n}\n\nfunction loadEnvConfig(): Partial<PowerlineConfig> {\n const config: Partial<PowerlineConfig> = {};\n\n if (process.env.CLAUDE_POWERLINE_THEME) {\n config.theme = process.env.CLAUDE_POWERLINE_THEME as\n | \"light\"\n | \"dark\"\n | \"custom\";\n }\n\n if (process.env.CLAUDE_POWERLINE_STYLE) {\n if (!config.display) {\n config.display = { lines: [] };\n }\n const style = process.env.CLAUDE_POWERLINE_STYLE;\n if (style === \"minimal\" || style === \"powerline\") {\n config.display.style = style;\n } else {\n console.warn(\n `Invalid display style '${style}' from environment variable, falling back to 'minimal'`\n );\n config.display.style = \"minimal\";\n }\n }\n\n if (process.env.CLAUDE_POWERLINE_USAGE_TYPE) {\n const usageType = process.env.CLAUDE_POWERLINE_USAGE_TYPE as\n | \"cost\"\n | \"tokens\"\n | \"both\"\n | \"breakdown\";\n if ([\"cost\", \"tokens\", \"both\", \"breakdown\"].includes(usageType)) {\n config.usageType = usageType;\n }\n }\n\n if (process.env.CLAUDE_POWERLINE_SESSION_BUDGET) {\n const sessionBudget = parseFloat(process.env.CLAUDE_POWERLINE_SESSION_BUDGET);\n if (!isNaN(sessionBudget) && sessionBudget > 0) {\n config.budget = {\n ...config.budget,\n session: {\n ...DEFAULT_CONFIG.budget?.session,\n amount: sessionBudget,\n },\n };\n }\n }\n\n return config;\n}\n\nfunction getConfigPathFromEnv(): string | undefined {\n return process.env.CLAUDE_POWERLINE_CONFIG;\n}\n\nfunction parseCLIOverrides(args: string[]): Partial<PowerlineConfig> {\n const config: Partial<PowerlineConfig> = {};\n\n const themeIndex = args.findIndex((arg) => arg.startsWith(\"--theme=\"));\n if (themeIndex !== -1) {\n const theme = args[themeIndex]?.split(\"=\")[1];\n if (theme) {\n config.theme = theme as \"light\" | \"dark\" | \"custom\";\n }\n }\n\n const styleIndex = args.findIndex((arg) => arg.startsWith(\"--style=\"));\n if (styleIndex !== -1) {\n const style = args[styleIndex]?.split(\"=\")[1];\n if (style) {\n if (!config.display) {\n config.display = { lines: [] };\n }\n if (style === \"minimal\" || style === \"powerline\") {\n config.display.style = style;\n } else {\n console.warn(\n `Invalid display style '${style}' from CLI argument, falling back to 'minimal'`\n );\n config.display.style = \"minimal\";\n }\n }\n }\n\n const sessionBudgetIndex = args.findIndex((arg) =>\n arg.startsWith(\"--session-budget=\")\n );\n if (sessionBudgetIndex !== -1) {\n const sessionBudget = parseFloat(\n args[sessionBudgetIndex]?.split(\"=\")[1] || \"\"\n );\n if (!isNaN(sessionBudget) && sessionBudget > 0) {\n config.budget = {\n ...config.budget,\n session: {\n ...DEFAULT_CONFIG.budget?.session,\n amount: sessionBudget,\n },\n };\n }\n }\n\n const usageIndex = args.findIndex((arg) => arg.startsWith(\"--usage=\"));\n if (usageIndex !== -1) {\n const usageType = args[usageIndex]?.split(\"=\")[1] as\n | \"cost\"\n | \"tokens\"\n | \"both\"\n | \"breakdown\";\n if (\n usageType &&\n [\"cost\", \"tokens\", \"both\", \"breakdown\"].includes(usageType)\n ) {\n config.usageType = usageType;\n }\n }\n\n return config;\n}\n\nexport function loadConfig(options: ConfigLoadOptions = {}): PowerlineConfig {\n const {\n configPath,\n ignoreEnvVars = false,\n cliOverrides = {},\n projectDir,\n } = options;\n\n let config: PowerlineConfig = JSON.parse(JSON.stringify(DEFAULT_CONFIG));\n\n const configFile = findConfigFile(configPath, projectDir);\n if (configFile) {\n try {\n const fileConfig = loadConfigFile(configFile);\n config = deepMerge(config, fileConfig);\n } catch (err) {\n console.warn(\n `Warning: ${err instanceof Error ? err.message : String(err)}`\n );\n }\n }\n\n if (\n config.display?.style &&\n config.display.style !== \"minimal\" &&\n config.display.style !== \"powerline\"\n ) {\n console.warn(\n `Invalid display style '${config.display.style}' in config file, falling back to 'minimal'`\n );\n config.display.style = \"minimal\";\n }\n\n if (!ignoreEnvVars) {\n const envConfig = loadEnvConfig();\n config = deepMerge(config, envConfig);\n }\n\n config = deepMerge(config, cliOverrides);\n\n if (config.usageType) {\n config.display.lines.forEach((line) => {\n if (line.segments.session) {\n line.segments.session.type = config.usageType!;\n }\n });\n delete config.usageType;\n }\n\n return config;\n}\n\nexport function loadConfigFromCLI(\n args: string[] = process.argv,\n projectDir?: string\n): PowerlineConfig {\n const configPathIndex = args.findIndex((arg) => arg.startsWith(\"--config=\"));\n const configPath =\n configPathIndex !== -1\n ? args[configPathIndex]?.split(\"=\")[1]\n : getConfigPathFromEnv();\n\n const cliOverrides = parseCLIOverrides(args);\n\n return loadConfig({ configPath, cliOverrides, projectDir });\n}\n\nexport function getConfigPath(\n customPath?: string,\n projectDir?: string\n): string | null {\n return findConfigFile(customPath, projectDir);\n}\n","import type { PowerlineConfig } from \"./loader\";\n\nexport const DEFAULT_CONFIG: PowerlineConfig = {\n theme: \"dark\",\n display: {\n style: \"minimal\",\n lines: [\n {\n segments: {\n directory: { enabled: true },\n git: {\n enabled: true,\n showSha: false,\n },\n model: { enabled: true },\n session: { enabled: true, type: \"tokens\" },\n tmux: { enabled: false },\n context: { enabled: true },\n metrics: { enabled: false },\n },\n },\n ],\n },\n budget: {\n session: {\n warningThreshold: 80,\n },\n },\n};\n"],"mappings":";;;;;;;;;AAEA,OAAOA,cAAa;AACpB,OAAOC,WAAU;AACjB,OAAOC,SAAQ;AACf,SAAS,YAAAC,iBAAgB;AACzB,OAAOC,SAAQ;AACf,SAAS,YAAY;;;ACPd,SAAS,UAAU,KAAa,cAA+B;AACpE,QAAM,IAAI,SAAS,IAAI,MAAM,GAAG,CAAC,GAAG,EAAE;AACtC,QAAM,IAAI,SAAS,IAAI,MAAM,GAAG,CAAC,GAAG,EAAE;AACtC,QAAM,IAAI,SAAS,IAAI,MAAM,GAAG,CAAC,GAAG,EAAE;AACtC,SAAO,QAAQ,eAAe,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5D;AAEO,SAAS,cAAc,UAA0B;AACtD,QAAM,QAAQ,SAAS,MAAM,wBAAwB;AACrD,MAAI,OAAO;AACT,WAAO,aAAa,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAAA,EACtD;AACA,SAAO,SAAS,QAAQ,MAAM,IAAI;AACpC;;;ACXO,IAAM,YAAwB;AAAA,EACnC,WAAW,EAAE,IAAI,WAAW,IAAI,UAAU;AAAA,EAC1C,KAAK,EAAE,IAAI,WAAW,IAAI,UAAU;AAAA,EACpC,OAAO,EAAE,IAAI,WAAW,IAAI,UAAU;AAAA,EACtC,SAAS,EAAE,IAAI,WAAW,IAAI,UAAU;AAAA,EACxC,MAAM,EAAE,IAAI,WAAW,IAAI,UAAU;AAAA,EACrC,SAAS,EAAE,IAAI,WAAW,IAAI,UAAU;AAAA,EACxC,SAAS,EAAE,IAAI,WAAW,IAAI,UAAU;AAC1C;;;ACRO,IAAM,aAAyB;AAAA,EACpC,WAAW,EAAE,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AAC1E,YAAQ,MAAM,gCAAgC,YAAY;AAC1D,IAAAA,SAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK;","names":["process","path","fs","execSync","os","execSync","execSync","homedir","join","readFileSync","readFile","readFile","fs","path","fs","path","os","path","fs","execSync","process"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owloops/claude-powerline",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Beautiful vim-style powerline statusline for Claude Code with real-time cost tracking, git integration, and custom themes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|