@owloops/claude-powerline 1.25.2 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/tui/types.ts CHANGED
@@ -4,6 +4,7 @@ import type { TodayInfo } from "../segments/today";
4
4
  import type { ContextInfo } from "../segments/context";
5
5
  import type { MetricsInfo } from "../segments/metrics";
6
6
  import type { GitInfo } from "../segments/git";
7
+ import type { CacheTimerInfo } from "../segments/cacheTimer";
7
8
  import type { ClaudeHookData } from "../utils/claude";
8
9
  import type { PowerlineColors } from "../themes";
9
10
  import type { PowerlineConfig } from "../config/loader";
@@ -29,6 +30,7 @@ export interface TuiData {
29
30
  contextInfo: ContextInfo | null;
30
31
  metricsInfo: MetricsInfo | null;
31
32
  gitInfo: GitInfo | null;
33
+ cacheTimerInfo: CacheTimerInfo | null;
32
34
  tmuxSessionId: string | null;
33
35
  colors: PowerlineColors;
34
36
  }
@@ -51,6 +53,9 @@ const SEGMENT_NAME_LIST = [
51
53
  "metrics",
52
54
  "activity",
53
55
  "env",
56
+ "agent",
57
+ "thinking",
58
+ "cacheTimer",
54
59
  ] as const;
55
60
 
56
61
  export type SegmentName = (typeof SEGMENT_NAME_LIST)[number];
@@ -103,6 +108,9 @@ export const SEGMENT_PARTS: Record<SegmentName, readonly string[]> = {
103
108
  tmux: ["label", "value"],
104
109
  dir: ["icon", "value"],
105
110
  env: ["prefix", "value"],
111
+ agent: ["icon", "name"],
112
+ thinking: ["icon", "enabled", "effort"],
113
+ cacheTimer: ["icon", "value"],
106
114
  } as const;
107
115
 
108
116
  export function isValidSegmentRef(name: string): boolean {
@@ -1,9 +1,18 @@
1
+ import type { BudgetItemConfig } from "../config/loader";
2
+
1
3
  export interface BudgetStatus {
2
4
  percentage: number | null;
3
5
  isWarning: boolean;
4
6
  displayText: string;
5
7
  }
6
8
 
9
+ export interface BudgetDisplayState {
10
+ suppressAll: boolean;
11
+ showBase: boolean;
12
+ percentText: string;
13
+ percentageOnly: boolean;
14
+ }
15
+
7
16
  export function calculateBudgetPercentage(
8
17
  cost: number,
9
18
  budget: number | undefined,
@@ -45,3 +54,63 @@ export function getBudgetStatus(
45
54
  displayText,
46
55
  };
47
56
  }
57
+
58
+ export function pickBudgetValue(
59
+ cost: number | null,
60
+ tokens: number | null,
61
+ budgetType: "cost" | "tokens" | undefined,
62
+ ): number | null {
63
+ return budgetType === "tokens" ? tokens : cost;
64
+ }
65
+
66
+ export function resolveBudgetDisplay(
67
+ cost: number | null,
68
+ tokens: number | null,
69
+ budget?: BudgetItemConfig,
70
+ ): BudgetDisplayState {
71
+ if (!budget?.amount || budget.amount <= 0) {
72
+ return {
73
+ suppressAll: false,
74
+ showBase: true,
75
+ percentText: "",
76
+ percentageOnly: false,
77
+ };
78
+ }
79
+
80
+ const showValue = budget.showValue ?? true;
81
+ const showPercentage = budget.showPercentage ?? true;
82
+ const budgetValue = pickBudgetValue(cost, tokens, budget.type);
83
+
84
+ if (budgetValue === null) {
85
+ return {
86
+ suppressAll: false,
87
+ showBase: true,
88
+ percentText: "",
89
+ percentageOnly: false,
90
+ };
91
+ }
92
+
93
+ if (!showValue && !showPercentage) {
94
+ return {
95
+ suppressAll: true,
96
+ showBase: false,
97
+ percentText: "",
98
+ percentageOnly: false,
99
+ };
100
+ }
101
+
102
+ const percentText = showPercentage
103
+ ? getBudgetStatus(
104
+ budgetValue,
105
+ budget.amount,
106
+ budget.warningThreshold,
107
+ ).displayText.trimStart()
108
+ : "";
109
+
110
+ return {
111
+ suppressAll: false,
112
+ showBase: showValue,
113
+ percentText,
114
+ percentageOnly: !showValue,
115
+ };
116
+ }
@@ -53,6 +53,35 @@ export interface ClaudeHookData {
53
53
  resets_at: number;
54
54
  };
55
55
  };
56
+ worktree?: {
57
+ name: string;
58
+ path: string;
59
+ branch?: string;
60
+ original_cwd: string;
61
+ original_branch?: string;
62
+ };
63
+ agent?: {
64
+ name: string;
65
+ };
66
+ effort?: {
67
+ level?: string;
68
+ };
69
+ thinking?: {
70
+ enabled?: boolean;
71
+ };
72
+ }
73
+
74
+ export function getEffortLevel(hookData: ClaudeHookData): string | null {
75
+ const level = hookData.effort?.level;
76
+ if (typeof level !== "string") return null;
77
+ const trimmed = level.trim();
78
+ return trimmed ? trimmed : null;
79
+ }
80
+
81
+ export function getThinkingEnabled(hookData: ClaudeHookData): boolean | null {
82
+ const enabled = hookData.thinking?.enabled;
83
+ if (typeof enabled !== "boolean") return null;
84
+ return enabled;
56
85
  }
57
86
 
58
87
  export function getClaudePaths(): string[] {
@@ -36,6 +36,9 @@ export const SYMBOLS = {
36
36
  weekly_cost: "◑",
37
37
  dir: "📁",
38
38
  activity: "⚡",
39
+ agent: "◇",
40
+ thinking: "✦",
41
+ cache_timer: "◴",
39
42
  } as const;
40
43
 
41
44
  export const BOX_CHARS = {
@@ -173,4 +176,7 @@ export const TEXT_SYMBOLS = {
173
176
  weekly_cost: "W",
174
177
  dir: "D",
175
178
  activity: "A",
179
+ agent: "&",
180
+ thinking: "T",
181
+ cache_timer: "C!",
176
182
  } as const;
@@ -158,3 +158,11 @@ export function formatLongTimeRemaining(totalMinutes: number): string {
158
158
  export function minutesUntilReset(epochSeconds: number): number {
159
159
  return Math.round(Math.max(0, epochSeconds * 1000 - Date.now()) / 60000);
160
160
  }
161
+
162
+ export function formatCacheTimerElapsed(seconds: number): string {
163
+ if (seconds >= 3600) return "1h+";
164
+ if (seconds >= 300) return `${Math.floor(seconds / 60)}m`;
165
+ const m = Math.floor(seconds / 60);
166
+ const s = Math.floor(seconds % 60);
167
+ return `${m}:${s.toString().padStart(2, "0")}`;
168
+ }
@@ -0,0 +1,31 @@
1
+ import type { PowerlineConfig, LineConfig } from "../config/loader";
2
+
3
+ export type SegmentKey = keyof LineConfig["segments"];
4
+
5
+ export function shouldShowIcon(
6
+ globalShowIcons: boolean | undefined,
7
+ perSegmentShowIcon: boolean | undefined,
8
+ ): boolean {
9
+ return perSegmentShowIcon ?? globalShowIcons ?? true;
10
+ }
11
+
12
+ export function findSegmentShowIcon(
13
+ config: PowerlineConfig,
14
+ segKey: SegmentKey,
15
+ ): boolean | undefined {
16
+ for (const line of config.display.lines) {
17
+ const seg = line.segments[segKey] as { showIcon?: boolean } | undefined;
18
+ if (seg?.showIcon !== undefined) return seg.showIcon;
19
+ }
20
+ return undefined;
21
+ }
22
+
23
+ export function resolveIconVisibility(
24
+ config: PowerlineConfig,
25
+ segKey: SegmentKey,
26
+ ): boolean {
27
+ return shouldShowIcon(
28
+ config.display?.showIcons,
29
+ findSegmentShowIcon(config, segKey),
30
+ );
31
+ }