claude-scope 0.4.3 → 0.5.1

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.
@@ -264,6 +264,20 @@ var NativeGit = class {
264
264
  return { files: [] };
265
265
  }
266
266
  }
267
+ async latestTag() {
268
+ try {
269
+ const { stdout } = await execFileAsync(
270
+ "git",
271
+ ["describe", "--tags", "--abbrev=0"],
272
+ {
273
+ cwd: this.cwd
274
+ }
275
+ );
276
+ return stdout.trim();
277
+ } catch {
278
+ return null;
279
+ }
280
+ }
267
281
  };
268
282
  function createGit(cwd) {
269
283
  return new NativeGit(cwd);
@@ -323,6 +337,69 @@ var GitWidget = class {
323
337
  }
324
338
  };
325
339
 
340
+ // src/ui/utils/colors.ts
341
+ var reset = "\x1B[0m";
342
+ var red = "\x1B[31m";
343
+ var green = "\x1B[32m";
344
+ var gray = "\x1B[90m";
345
+ var lightGray = "\x1B[37m";
346
+ var bold = "\x1B[1m";
347
+
348
+ // src/widgets/git/git-tag-widget.ts
349
+ var GitTagWidget = class {
350
+ id = "git-tag";
351
+ metadata = createWidgetMetadata(
352
+ "Git Tag Widget",
353
+ "Displays the latest git tag",
354
+ "1.0.0",
355
+ "claude-scope",
356
+ 1
357
+ // Second line
358
+ );
359
+ gitFactory;
360
+ git = null;
361
+ enabled = true;
362
+ cwd = null;
363
+ latestTag = null;
364
+ /**
365
+ * @param gitFactory - Optional factory function for creating IGit instances
366
+ * If not provided, uses default createGit (production)
367
+ * Tests can inject MockGit factory here
368
+ */
369
+ constructor(gitFactory) {
370
+ this.gitFactory = gitFactory || createGit;
371
+ }
372
+ async initialize(context) {
373
+ this.enabled = context.config?.enabled !== false;
374
+ }
375
+ async render(context) {
376
+ if (!this.enabled || !this.git || !this.cwd) {
377
+ return null;
378
+ }
379
+ try {
380
+ this.latestTag = await (this.git.latestTag?.() ?? Promise.resolve(null));
381
+ if (!this.latestTag) {
382
+ return `${gray}Tag:${reset} no tag`;
383
+ }
384
+ const tagValue = `${green}${this.latestTag}${reset}`;
385
+ return `${gray}Tag:${reset} ${tagValue}`;
386
+ } catch {
387
+ return null;
388
+ }
389
+ }
390
+ async update(data) {
391
+ if (data.cwd !== this.cwd) {
392
+ this.cwd = data.cwd;
393
+ this.git = this.gitFactory(data.cwd);
394
+ }
395
+ }
396
+ isEnabled() {
397
+ return this.enabled;
398
+ }
399
+ async cleanup() {
400
+ }
401
+ };
402
+
326
403
  // src/widgets/core/stdin-data-widget.ts
327
404
  var StdinDataWidget = class {
328
405
  /**
@@ -439,12 +516,6 @@ function colorize(text, color) {
439
516
  return `${color}${text}${ANSI_COLORS.RESET}`;
440
517
  }
441
518
 
442
- // src/ui/utils/colors.ts
443
- var reset = "\x1B[0m";
444
- var red = "\x1B[31m";
445
- var gray = "\x1B[90m";
446
- var bold = "\x1B[1m";
447
-
448
519
  // src/ui/theme/default-theme.ts
449
520
  var DEFAULT_THEME = {
450
521
  context: {
@@ -1240,6 +1311,9 @@ var PokerWidget = class extends StdinDataWidget {
1240
1311
  holeCards = [];
1241
1312
  boardCards = [];
1242
1313
  handResult = null;
1314
+ lastUpdateTimestamp = 0;
1315
+ THROTTLE_MS = 5e3;
1316
+ // 5 seconds
1243
1317
  constructor() {
1244
1318
  super();
1245
1319
  }
@@ -1248,6 +1322,10 @@ var PokerWidget = class extends StdinDataWidget {
1248
1322
  */
1249
1323
  async update(data) {
1250
1324
  await super.update(data);
1325
+ const now = Date.now();
1326
+ if (now - this.lastUpdateTimestamp < this.THROTTLE_MS) {
1327
+ return;
1328
+ }
1251
1329
  const deck = new Deck();
1252
1330
  const hole = [deck.deal(), deck.deal()];
1253
1331
  const board = [deck.deal(), deck.deal(), deck.deal(), deck.deal(), deck.deal()];
@@ -1272,6 +1350,7 @@ var PokerWidget = class extends StdinDataWidget {
1272
1350
  participatingIndices: result.participatingCards
1273
1351
  };
1274
1352
  }
1353
+ this.lastUpdateTimestamp = now;
1275
1354
  }
1276
1355
  /**
1277
1356
  * Format card with appropriate color (red for ♥♦, gray for ♠♣)
@@ -1289,7 +1368,7 @@ var PokerWidget = class extends StdinDataWidget {
1289
1368
  const color = isRedSuit(cardData.card.suit) ? red : gray;
1290
1369
  const cardText = formatCard(cardData.card);
1291
1370
  if (isParticipating) {
1292
- return `${color}${bold}(${cardText})${reset}`;
1371
+ return `${color}${bold}(${cardText})${reset} `;
1293
1372
  } else {
1294
1373
  return `${color}${cardText}${reset} `;
1295
1374
  }
@@ -1298,8 +1377,8 @@ var PokerWidget = class extends StdinDataWidget {
1298
1377
  const participatingSet = new Set(this.handResult?.participatingIndices || []);
1299
1378
  const handStr = this.holeCards.map((hc, idx) => this.formatCardByParticipation(hc, participatingSet.has(idx))).join("");
1300
1379
  const boardStr = this.boardCards.map((bc, idx) => this.formatCardByParticipation(bc, participatingSet.has(idx + 2))).join("");
1301
- const handLabel = colorize("Hand:", gray);
1302
- const boardLabel = colorize("Board:", gray);
1380
+ const handLabel = colorize("Hand:", lightGray);
1381
+ const boardLabel = colorize("Board:", lightGray);
1303
1382
  return `${handLabel} ${handStr} | ${boardLabel} ${boardStr} \u2192 ${this.handResult?.text}`;
1304
1383
  }
1305
1384
  };
@@ -1505,6 +1584,7 @@ async function main() {
1505
1584
  await registry.register(new LinesWidget());
1506
1585
  await registry.register(new DurationWidget());
1507
1586
  await registry.register(new GitWidget());
1587
+ await registry.register(new GitTagWidget());
1508
1588
  await registry.register(new GitChangesWidget());
1509
1589
  await registry.register(new ConfigCountWidget());
1510
1590
  await registry.register(new PokerWidget());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-scope",
3
- "version": "0.4.3",
3
+ "version": "0.5.1",
4
4
  "description": "Claude Code plugin for session status and analytics",
5
5
  "license": "MIT",
6
6
  "type": "module",