claude-scope 0.8.21 → 0.8.23

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.
@@ -8419,6 +8419,108 @@ async function loadWidgetConfig() {
8419
8419
  init_renderer();
8420
8420
  init_style_types();
8421
8421
 
8422
+ // src/providers/system-provider.ts
8423
+ var import_node_module = require("node:module");
8424
+ var import_meta = {};
8425
+ var require2 = (0, import_node_module.createRequire)(import_meta.url);
8426
+ var si = null;
8427
+ try {
8428
+ si = require2("systeminformation");
8429
+ } catch {
8430
+ }
8431
+ var SystemProvider = class {
8432
+ intervalId;
8433
+ lastNetworkStats = /* @__PURE__ */ new Map();
8434
+ lastErrorTime = 0;
8435
+ ERROR_LOG_INTERVAL = 6e4;
8436
+ // 1 minute
8437
+ async getMetrics() {
8438
+ if (!si) {
8439
+ return null;
8440
+ }
8441
+ try {
8442
+ const [cpuLoad, mem, fs2, net] = await Promise.all([
8443
+ si.currentLoad(),
8444
+ si.mem(),
8445
+ si.fsSize(),
8446
+ si.networkStats()
8447
+ ]);
8448
+ const cpuPercent = Math.round(cpuLoad.currentLoad ?? 0);
8449
+ const memUsedGB = mem.active / 1024 / 1024 / 1024;
8450
+ const memTotalGB = mem.total / 1024 / 1024 / 1024;
8451
+ const memPercent = Math.round(mem.active / mem.total * 100);
8452
+ const mainFs = Array.isArray(fs2) ? fs2[0] : fs2;
8453
+ const diskUsedGB = mainFs.used / 1024 / 1024 / 1024;
8454
+ const diskTotalGB = mainFs.size / 1024 / 1024 / 1024;
8455
+ const diskPercent = Math.round(mainFs.use);
8456
+ const iface = Array.isArray(net) && net.length > 0 ? net[0] : net;
8457
+ const networkSpeed = this.calculateNetworkSpeed(iface);
8458
+ return {
8459
+ cpu: { percent: cpuPercent },
8460
+ memory: {
8461
+ used: Number(memUsedGB.toFixed(1)),
8462
+ total: Number(memTotalGB.toFixed(1)),
8463
+ percent: memPercent
8464
+ },
8465
+ disk: {
8466
+ used: Number(diskUsedGB.toFixed(1)),
8467
+ total: Number(diskTotalGB.toFixed(1)),
8468
+ percent: diskPercent
8469
+ },
8470
+ network: networkSpeed
8471
+ };
8472
+ } catch (error) {
8473
+ this.logError(error);
8474
+ return null;
8475
+ }
8476
+ }
8477
+ startUpdate(intervalMs, callback) {
8478
+ this.intervalId = setInterval(() => {
8479
+ this.getMetrics().then((metrics) => {
8480
+ if (metrics) {
8481
+ callback(metrics);
8482
+ }
8483
+ }).catch((error) => {
8484
+ this.logError(error);
8485
+ });
8486
+ }, intervalMs);
8487
+ }
8488
+ stopUpdate() {
8489
+ if (this.intervalId) {
8490
+ clearInterval(this.intervalId);
8491
+ this.intervalId = void 0;
8492
+ }
8493
+ }
8494
+ calculateNetworkSpeed(iface) {
8495
+ if (!iface || iface.iface === void 0) {
8496
+ return { rxSec: 0, txSec: 0 };
8497
+ }
8498
+ const ifaceKey = iface.iface;
8499
+ const last = this.lastNetworkStats.get(ifaceKey);
8500
+ if (!last) {
8501
+ this.lastNetworkStats.set(ifaceKey, { rx: iface.rx_bytes, tx: iface.tx_bytes });
8502
+ return { rxSec: 0, txSec: 0 };
8503
+ }
8504
+ const timeDiff = 2;
8505
+ const rxDiff = iface.rx_bytes - last.rx;
8506
+ const txDiff = iface.tx_bytes - last.tx;
8507
+ const rx_sec = rxDiff / timeDiff / 1024 / 1024;
8508
+ const tx_sec = txDiff / timeDiff / 1024 / 1024;
8509
+ this.lastNetworkStats.set(ifaceKey, { rx: iface.rx_bytes, tx: iface.tx_bytes });
8510
+ return {
8511
+ rxSec: Math.max(0, Number(rx_sec.toFixed(2))),
8512
+ txSec: Math.max(0, Number(tx_sec.toFixed(2)))
8513
+ };
8514
+ }
8515
+ logError(error) {
8516
+ const now = Date.now();
8517
+ if (now - this.lastErrorTime > this.ERROR_LOG_INTERVAL) {
8518
+ console.error("SystemProvider error:", error);
8519
+ this.lastErrorTime = now;
8520
+ }
8521
+ }
8522
+ };
8523
+
8422
8524
  // src/core/widget-factory.ts
8423
8525
  init_theme();
8424
8526
  init_active_tools();
@@ -9137,8 +9239,10 @@ var PokerWidget = class extends StdinDataWidget {
9137
9239
  // src/core/widget-factory.ts
9138
9240
  var WidgetFactory = class {
9139
9241
  transcriptProvider;
9242
+ systemProvider;
9140
9243
  constructor() {
9141
9244
  this.transcriptProvider = new TranscriptProvider();
9245
+ this.systemProvider = new SystemProvider();
9142
9246
  }
9143
9247
  /**
9144
9248
  * Create a widget instance by ID
@@ -9174,7 +9278,7 @@ var WidgetFactory = class {
9174
9278
  case "poker":
9175
9279
  return new PokerWidget(DEFAULT_THEME);
9176
9280
  case "sysmon":
9177
- return new SysmonWidget(DEFAULT_THEME);
9281
+ return new SysmonWidget(DEFAULT_THEME, this.systemProvider);
9178
9282
  case "empty-line":
9179
9283
  return new EmptyLineWidget();
9180
9284
  default:
@@ -9425,7 +9529,7 @@ async function main() {
9425
9529
  ...widgetConfigItem,
9426
9530
  line: parseInt(lineNum, 10)
9427
9531
  });
9428
- await registry.register(widget);
9532
+ await registry.register(widget, { config: { ...widgetConfigItem } });
9429
9533
  }
9430
9534
  }
9431
9535
  }
@@ -9434,7 +9538,7 @@ async function main() {
9434
9538
  for (const widgetId of defaultWidgets) {
9435
9539
  const widget = factory.createWidget(widgetId);
9436
9540
  if (widget) {
9437
- await registry.register(widget);
9541
+ await registry.register(widget, { config: {} });
9438
9542
  }
9439
9543
  }
9440
9544
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-scope",
3
- "version": "0.8.21",
3
+ "version": "0.8.23",
4
4
  "description": "Claude Code plugin for session status and analytics",
5
5
  "license": "MIT",
6
6
  "type": "module",