@owloops/claude-powerline 1.5.3 → 1.5.5

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 CHANGED
@@ -247,7 +247,8 @@ Configuration priority (top overrides bottom):
247
247
  "showLastResponseTime": false,
248
248
  "showDuration": true,
249
249
  "showMessageCount": true
250
- }
250
+ },
251
+ "version": { "enabled": true }
251
252
  }
252
253
  }
253
254
  ]
@@ -266,6 +267,7 @@ Configuration priority (top overrides bottom):
266
267
  - **context**: Context window usage and auto-compact threshold
267
268
  - **tmux**: Tmux session name and window info (when in tmux)
268
269
  - **metrics**: Performance analytics (see Metrics Configuration below)
270
+ - **version**: Claude Code version (e.g., v1.0.81)
269
271
 
270
272
  #### Directory Configuration
271
273
 
@@ -426,7 +428,8 @@ To prevent segment cutoff, configure multiple lines:
426
428
  "today": { "enabled": true, "type": "cost" },
427
429
  "context": { "enabled": true },
428
430
  "tmux": { "enabled": false },
429
- "metrics": { "enabled": true }
431
+ "metrics": { "enabled": true },
432
+ "version": { "enabled": true }
430
433
  }
431
434
  }
432
435
  ]
@@ -454,12 +457,19 @@ To customize colors, copy dark or light theme colors from `src/themes/` in the r
454
457
  "today": { "bg": "#303030", "fg": "#dddddd" },
455
458
  "context": { "bg": "#4a5568", "fg": "#ffffff" },
456
459
  "tmux": { "bg": "#228b22", "fg": "#ffffff" },
457
- "metrics": { "bg": "#374151", "fg": "#ffffff" }
460
+ "metrics": { "bg": "#374151", "fg": "#ffffff" },
461
+ "version": { "bg": "#2d3748", "fg": "#ffffff" }
458
462
  }
459
463
  }
460
464
  }
461
465
  ```
462
466
 
467
+ > [!TIP]
468
+ > Use `"transparent"` or `"none"` for background colors to create a minimal look:
469
+ > ```json
470
+ > "directory": { "bg": "transparent", "fg": "#00ff00" }
471
+ > ```
472
+
463
473
  ## Custom Segments
464
474
 
465
475
  Extend the statusline by wrapping the command with shell composition:
package/dist/index.js CHANGED
@@ -10,12 +10,15 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
10
10
  import process2 from "process";
11
11
  import path4 from "path";
12
12
  import fs3 from "fs";
13
- import { execSync as execSync3 } from "child_process";
13
+ import { execSync as execSync4 } from "child_process";
14
14
  import os2 from "os";
15
15
  import { json } from "stream/consumers";
16
16
 
17
17
  // src/utils/colors.ts
18
18
  function hexToAnsi(hex, isBackground) {
19
+ if (isBackground && (hex.toLowerCase() === "transparent" || hex.toLowerCase() === "none")) {
20
+ return "\x1B[49m";
21
+ }
19
22
  const r = parseInt(hex.slice(1, 3), 16);
20
23
  const g = parseInt(hex.slice(3, 5), 16);
21
24
  const b = parseInt(hex.slice(5, 7), 16);
@@ -39,7 +42,8 @@ var darkTheme = {
39
42
  today: { bg: "#1a1a1a", fg: "#98fb98" },
40
43
  tmux: { bg: "#2f4f2f", fg: "#90ee90" },
41
44
  context: { bg: "#4a5568", fg: "#cbd5e0" },
42
- metrics: { bg: "#374151", fg: "#d1d5db" }
45
+ metrics: { bg: "#374151", fg: "#d1d5db" },
46
+ version: { bg: "#3a3a4a", fg: "#b8b8d0" }
43
47
  };
44
48
 
45
49
  // src/themes/light.ts
@@ -52,7 +56,8 @@ var lightTheme = {
52
56
  today: { bg: "#10b981", fg: "#ffffff" },
53
57
  tmux: { bg: "#32cd32", fg: "#ffffff" },
54
58
  context: { bg: "#718096", fg: "#ffffff" },
55
- metrics: { bg: "#6b7280", fg: "#ffffff" }
59
+ metrics: { bg: "#6b7280", fg: "#ffffff" },
60
+ version: { bg: "#8b7dd8", fg: "#ffffff" }
56
61
  };
57
62
 
58
63
  // src/themes/nord.ts
@@ -65,7 +70,8 @@ var nordTheme = {
65
70
  today: { bg: "#2e3440", fg: "#8fbcbb" },
66
71
  tmux: { bg: "#2e3440", fg: "#8fbcbb" },
67
72
  context: { bg: "#5e81ac", fg: "#eceff4" },
68
- metrics: { bg: "#b48ead", fg: "#2e3440" }
73
+ metrics: { bg: "#b48ead", fg: "#2e3440" },
74
+ version: { bg: "#434c5e", fg: "#88c0d0" }
69
75
  };
70
76
 
71
77
  // src/themes/tokyo-night.ts
@@ -78,7 +84,8 @@ var tokyoNightTheme = {
78
84
  today: { bg: "#1a202c", fg: "#4fd6be" },
79
85
  tmux: { bg: "#191b29", fg: "#4fd6be" },
80
86
  context: { bg: "#414868", fg: "#c0caf5" },
81
- metrics: { bg: "#3d59a1", fg: "#c0caf5" }
87
+ metrics: { bg: "#3d59a1", fg: "#c0caf5" },
88
+ version: { bg: "#292e42", fg: "#bb9af7" }
82
89
  };
83
90
 
84
91
  // src/themes/rose-pine.ts
@@ -91,7 +98,8 @@ var rosePineTheme = {
91
98
  today: { bg: "#232136", fg: "#9ccfd8" },
92
99
  tmux: { bg: "#26233a", fg: "#908caa" },
93
100
  context: { bg: "#393552", fg: "#e0def4" },
94
- metrics: { bg: "#524f67", fg: "#e0def4" }
101
+ metrics: { bg: "#524f67", fg: "#e0def4" },
102
+ version: { bg: "#2a273f", fg: "#c4a7e7" }
95
103
  };
96
104
 
97
105
  // src/themes/index.ts
@@ -1400,6 +1408,42 @@ var MetricsProvider = class {
1400
1408
  }
1401
1409
  };
1402
1410
 
1411
+ // src/segments/version.ts
1412
+ import { execSync as execSync3 } from "child_process";
1413
+ var VersionProvider = class {
1414
+ cachedVersion = null;
1415
+ cacheTimestamp = 0;
1416
+ CACHE_TTL = 3e4;
1417
+ getClaudeVersion() {
1418
+ const now = Date.now();
1419
+ if (this.cachedVersion !== null && now - this.cacheTimestamp < this.CACHE_TTL) {
1420
+ return this.cachedVersion;
1421
+ }
1422
+ try {
1423
+ const output = execSync3("claude --version", {
1424
+ encoding: "utf8",
1425
+ timeout: 1e3
1426
+ }).trim();
1427
+ const match = output.match(/^([\d.]+)/);
1428
+ if (match) {
1429
+ this.cachedVersion = `v${match[1]}`;
1430
+ this.cacheTimestamp = now;
1431
+ debug(`Claude Code version: ${this.cachedVersion}`);
1432
+ return this.cachedVersion;
1433
+ }
1434
+ debug(`Could not parse version from: ${output}`);
1435
+ return null;
1436
+ } catch (error) {
1437
+ debug(`Error getting Claude Code version:`, error);
1438
+ return null;
1439
+ }
1440
+ }
1441
+ async getVersionInfo() {
1442
+ const version = this.getClaudeVersion();
1443
+ return { version };
1444
+ }
1445
+ };
1446
+
1403
1447
  // src/segments/renderer.ts
1404
1448
  import path2 from "path";
1405
1449
 
@@ -1794,6 +1838,16 @@ var SegmentRenderer = class {
1794
1838
  }
1795
1839
  return baseDisplay;
1796
1840
  }
1841
+ renderVersion(versionInfo, colors, _config) {
1842
+ if (!versionInfo || !versionInfo.version) {
1843
+ return null;
1844
+ }
1845
+ return {
1846
+ text: `${this.symbols.version} ${versionInfo.version}`,
1847
+ bgColor: colors.versionBg,
1848
+ fgColor: colors.versionFg
1849
+ };
1850
+ }
1797
1851
  };
1798
1852
 
1799
1853
  // src/segments/block.ts
@@ -2134,6 +2188,7 @@ var PowerlineRenderer = class {
2134
2188
  this.gitService = new GitService();
2135
2189
  this.tmuxService = new TmuxService();
2136
2190
  this.metricsProvider = new MetricsProvider();
2191
+ this.versionProvider = new VersionProvider();
2137
2192
  this.segmentRenderer = new SegmentRenderer(config, this.symbols);
2138
2193
  }
2139
2194
  symbols;
@@ -2144,6 +2199,7 @@ var PowerlineRenderer = class {
2144
2199
  gitService;
2145
2200
  tmuxService;
2146
2201
  metricsProvider;
2202
+ versionProvider;
2147
2203
  segmentRenderer;
2148
2204
  needsUsageInfo() {
2149
2205
  return this.config.display.lines.some(
@@ -2178,6 +2234,11 @@ var PowerlineRenderer = class {
2178
2234
  (line) => line.segments.today?.enabled
2179
2235
  );
2180
2236
  }
2237
+ needsVersionInfo() {
2238
+ return this.config.display.lines.some(
2239
+ (line) => line.segments.version?.enabled
2240
+ );
2241
+ }
2181
2242
  async generateStatusline(hookData) {
2182
2243
  const usageInfo = this.needsUsageInfo() ? await this.usageProvider.getUsageInfo(hookData.session_id) : null;
2183
2244
  const blockInfo = this.needsBlockInfo() ? await this.blockProvider.getActiveBlockInfo() : null;
@@ -2187,6 +2248,7 @@ var PowerlineRenderer = class {
2187
2248
  hookData.model?.id
2188
2249
  ) : null;
2189
2250
  const metricsInfo = this.needsMetricsInfo() ? await this.metricsProvider.getMetricsInfo(hookData.session_id) : null;
2251
+ const versionInfo = this.needsVersionInfo() ? await this.versionProvider.getVersionInfo() : null;
2190
2252
  const lines = this.config.display.lines.map(
2191
2253
  (lineConfig) => this.renderLine(
2192
2254
  lineConfig,
@@ -2195,12 +2257,13 @@ var PowerlineRenderer = class {
2195
2257
  blockInfo,
2196
2258
  todayInfo,
2197
2259
  contextInfo,
2198
- metricsInfo
2260
+ metricsInfo,
2261
+ versionInfo
2199
2262
  )
2200
2263
  ).filter((line) => line.length > 0);
2201
2264
  return lines.join("\n");
2202
2265
  }
2203
- renderLine(lineConfig, hookData, usageInfo, blockInfo, todayInfo, contextInfo, metricsInfo) {
2266
+ renderLine(lineConfig, hookData, usageInfo, blockInfo, todayInfo, contextInfo, metricsInfo, versionInfo) {
2204
2267
  const colors = this.getThemeColors();
2205
2268
  const currentDir = hookData.workspace?.current_dir || hookData.cwd || "/";
2206
2269
  const segments = Object.entries(lineConfig.segments).filter(
@@ -2221,6 +2284,7 @@ var PowerlineRenderer = class {
2221
2284
  todayInfo,
2222
2285
  contextInfo,
2223
2286
  metricsInfo,
2287
+ versionInfo,
2224
2288
  colors,
2225
2289
  currentDir
2226
2290
  );
@@ -2235,7 +2299,7 @@ var PowerlineRenderer = class {
2235
2299
  }
2236
2300
  return line;
2237
2301
  }
2238
- renderSegment(segment, hookData, usageInfo, blockInfo, todayInfo, contextInfo, metricsInfo, colors, currentDir) {
2302
+ renderSegment(segment, hookData, usageInfo, blockInfo, todayInfo, contextInfo, metricsInfo, versionInfo, colors, currentDir) {
2239
2303
  switch (segment.type) {
2240
2304
  case "directory":
2241
2305
  return this.segmentRenderer.renderDirectory(
@@ -2290,6 +2354,10 @@ var PowerlineRenderer = class {
2290
2354
  if (!todayInfo) return null;
2291
2355
  const todayType = segment.config?.type || "cost";
2292
2356
  return this.segmentRenderer.renderToday(todayInfo, colors, todayType);
2357
+ case "version":
2358
+ if (!versionInfo) return null;
2359
+ const versionConfig = segment.config;
2360
+ return this.segmentRenderer.renderVersion(versionInfo, colors, versionConfig);
2293
2361
  default:
2294
2362
  return null;
2295
2363
  }
@@ -2319,7 +2387,8 @@ var PowerlineRenderer = class {
2319
2387
  metrics_last_response: "\u0394",
2320
2388
  metrics_duration: "\u29D7",
2321
2389
  metrics_messages: "\u27D0",
2322
- metrics_burn: "\u27E2"
2390
+ metrics_burn: "\u27E2",
2391
+ version: "\u25C8"
2323
2392
  };
2324
2393
  }
2325
2394
  getThemeColors() {
@@ -2341,26 +2410,59 @@ var PowerlineRenderer = class {
2341
2410
  colorTheme = getTheme("dark");
2342
2411
  }
2343
2412
  }
2413
+ const fallbackTheme = getTheme("dark");
2344
2414
  return {
2345
2415
  reset: "\x1B[0m",
2346
- modeBg: hexToAnsi(colorTheme.directory.bg, true),
2347
- modeFg: hexToAnsi(colorTheme.directory.fg, false),
2348
- gitBg: hexToAnsi(colorTheme.git.bg, true),
2349
- gitFg: hexToAnsi(colorTheme.git.fg, false),
2350
- modelBg: hexToAnsi(colorTheme.model.bg, true),
2351
- modelFg: hexToAnsi(colorTheme.model.fg, false),
2352
- sessionBg: hexToAnsi(colorTheme.session.bg, true),
2353
- sessionFg: hexToAnsi(colorTheme.session.fg, false),
2354
- blockBg: hexToAnsi(colorTheme.block.bg, true),
2355
- blockFg: hexToAnsi(colorTheme.block.fg, false),
2356
- todayBg: hexToAnsi(colorTheme.today.bg, true),
2357
- todayFg: hexToAnsi(colorTheme.today.fg, false),
2358
- tmuxBg: hexToAnsi(colorTheme.tmux.bg, true),
2359
- tmuxFg: hexToAnsi(colorTheme.tmux.fg, false),
2360
- contextBg: hexToAnsi(colorTheme.context.bg, true),
2361
- contextFg: hexToAnsi(colorTheme.context.fg, false),
2362
- metricsBg: hexToAnsi(colorTheme.metrics.bg, true),
2363
- metricsFg: hexToAnsi(colorTheme.metrics.fg, false)
2416
+ modeBg: hexToAnsi(
2417
+ colorTheme.directory?.bg || fallbackTheme.directory.bg,
2418
+ true
2419
+ ),
2420
+ modeFg: hexToAnsi(
2421
+ colorTheme.directory?.fg || fallbackTheme.directory.fg,
2422
+ false
2423
+ ),
2424
+ gitBg: hexToAnsi(colorTheme.git?.bg || fallbackTheme.git.bg, true),
2425
+ gitFg: hexToAnsi(colorTheme.git?.fg || fallbackTheme.git.fg, false),
2426
+ modelBg: hexToAnsi(colorTheme.model?.bg || fallbackTheme.model.bg, true),
2427
+ modelFg: hexToAnsi(colorTheme.model?.fg || fallbackTheme.model.fg, false),
2428
+ sessionBg: hexToAnsi(
2429
+ colorTheme.session?.bg || fallbackTheme.session.bg,
2430
+ true
2431
+ ),
2432
+ sessionFg: hexToAnsi(
2433
+ colorTheme.session?.fg || fallbackTheme.session.fg,
2434
+ false
2435
+ ),
2436
+ blockBg: hexToAnsi(colorTheme.block?.bg || fallbackTheme.block.bg, true),
2437
+ blockFg: hexToAnsi(colorTheme.block?.fg || fallbackTheme.block.fg, false),
2438
+ todayBg: hexToAnsi(colorTheme.today?.bg || fallbackTheme.today.bg, true),
2439
+ todayFg: hexToAnsi(colorTheme.today?.fg || fallbackTheme.today.fg, false),
2440
+ tmuxBg: hexToAnsi(colorTheme.tmux?.bg || fallbackTheme.tmux.bg, true),
2441
+ tmuxFg: hexToAnsi(colorTheme.tmux?.fg || fallbackTheme.tmux.fg, false),
2442
+ contextBg: hexToAnsi(
2443
+ colorTheme.context?.bg || fallbackTheme.context.bg,
2444
+ true
2445
+ ),
2446
+ contextFg: hexToAnsi(
2447
+ colorTheme.context?.fg || fallbackTheme.context.fg,
2448
+ false
2449
+ ),
2450
+ metricsBg: hexToAnsi(
2451
+ colorTheme.metrics?.bg || fallbackTheme.metrics.bg,
2452
+ true
2453
+ ),
2454
+ metricsFg: hexToAnsi(
2455
+ colorTheme.metrics?.fg || fallbackTheme.metrics.fg,
2456
+ false
2457
+ ),
2458
+ versionBg: hexToAnsi(
2459
+ colorTheme.version?.bg || fallbackTheme.version.bg,
2460
+ true
2461
+ ),
2462
+ versionFg: hexToAnsi(
2463
+ colorTheme.version?.fg || fallbackTheme.version.fg,
2464
+ false
2465
+ )
2364
2466
  };
2365
2467
  }
2366
2468
  getSegmentBgColor(segmentType, colors) {
@@ -2383,6 +2485,8 @@ var PowerlineRenderer = class {
2383
2485
  return colors.contextBg;
2384
2486
  case "metrics":
2385
2487
  return colors.metricsBg;
2488
+ case "version":
2489
+ return colors.versionBg;
2386
2490
  default:
2387
2491
  return colors.modeBg;
2388
2492
  }
@@ -2668,7 +2772,7 @@ async function installFonts() {
2668
2772
  fs3.rmSync(tempDir, { recursive: true, force: true });
2669
2773
  }
2670
2774
  console.log("Cloning powerline fonts repository...");
2671
- execSync3(
2775
+ execSync4(
2672
2776
  "git clone --depth=1 https://github.com/powerline/fonts.git powerline-fonts",
2673
2777
  {
2674
2778
  stdio: "inherit",
@@ -2679,7 +2783,7 @@ async function installFonts() {
2679
2783
  const installScript = path4.join(tempDir, "install.sh");
2680
2784
  if (fs3.existsSync(installScript)) {
2681
2785
  fs3.chmodSync(installScript, 493);
2682
- execSync3("./install.sh", { stdio: "inherit", cwd: tempDir });
2786
+ execSync4("./install.sh", { stdio: "inherit", cwd: tempDir });
2683
2787
  } else {
2684
2788
  throw new Error(
2685
2789
  "Install script not found in powerline fonts repository"