claude-scope 0.4.2 → 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.
- package/dist/claude-scope.cjs +94 -11
- package/package.json +1 -1
package/dist/claude-scope.cjs
CHANGED
|
@@ -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,10 +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 red = "\x1B[31m";
|
|
444
|
-
var gray = "\x1B[90m";
|
|
445
|
-
|
|
446
519
|
// src/ui/theme/default-theme.ts
|
|
447
520
|
var DEFAULT_THEME = {
|
|
448
521
|
context: {
|
|
@@ -1238,6 +1311,9 @@ var PokerWidget = class extends StdinDataWidget {
|
|
|
1238
1311
|
holeCards = [];
|
|
1239
1312
|
boardCards = [];
|
|
1240
1313
|
handResult = null;
|
|
1314
|
+
lastUpdateTimestamp = 0;
|
|
1315
|
+
THROTTLE_MS = 5e3;
|
|
1316
|
+
// 5 seconds
|
|
1241
1317
|
constructor() {
|
|
1242
1318
|
super();
|
|
1243
1319
|
}
|
|
@@ -1246,6 +1322,10 @@ var PokerWidget = class extends StdinDataWidget {
|
|
|
1246
1322
|
*/
|
|
1247
1323
|
async update(data) {
|
|
1248
1324
|
await super.update(data);
|
|
1325
|
+
const now = Date.now();
|
|
1326
|
+
if (now - this.lastUpdateTimestamp < this.THROTTLE_MS) {
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1249
1329
|
const deck = new Deck();
|
|
1250
1330
|
const hole = [deck.deal(), deck.deal()];
|
|
1251
1331
|
const board = [deck.deal(), deck.deal(), deck.deal(), deck.deal(), deck.deal()];
|
|
@@ -1270,6 +1350,7 @@ var PokerWidget = class extends StdinDataWidget {
|
|
|
1270
1350
|
participatingIndices: result.participatingCards
|
|
1271
1351
|
};
|
|
1272
1352
|
}
|
|
1353
|
+
this.lastUpdateTimestamp = now;
|
|
1273
1354
|
}
|
|
1274
1355
|
/**
|
|
1275
1356
|
* Format card with appropriate color (red for ♥♦, gray for ♠♣)
|
|
@@ -1280,23 +1361,24 @@ var PokerWidget = class extends StdinDataWidget {
|
|
|
1280
1361
|
}
|
|
1281
1362
|
/**
|
|
1282
1363
|
* Format card based on participation in best hand
|
|
1283
|
-
* Participating cards:
|
|
1284
|
-
* Non-participating cards:
|
|
1364
|
+
* Participating cards: (K♠) with color + BOLD
|
|
1365
|
+
* Non-participating cards: K♠ with color, no brackets
|
|
1285
1366
|
*/
|
|
1286
1367
|
formatCardByParticipation(cardData, isParticipating) {
|
|
1368
|
+
const color = isRedSuit(cardData.card.suit) ? red : gray;
|
|
1369
|
+
const cardText = formatCard(cardData.card);
|
|
1287
1370
|
if (isParticipating) {
|
|
1288
|
-
return
|
|
1371
|
+
return `${color}${bold}(${cardText})${reset} `;
|
|
1289
1372
|
} else {
|
|
1290
|
-
|
|
1291
|
-
return ` ${plainText} `;
|
|
1373
|
+
return `${color}${cardText}${reset} `;
|
|
1292
1374
|
}
|
|
1293
1375
|
}
|
|
1294
1376
|
renderWithData(_data, _context) {
|
|
1295
1377
|
const participatingSet = new Set(this.handResult?.participatingIndices || []);
|
|
1296
1378
|
const handStr = this.holeCards.map((hc, idx) => this.formatCardByParticipation(hc, participatingSet.has(idx))).join("");
|
|
1297
1379
|
const boardStr = this.boardCards.map((bc, idx) => this.formatCardByParticipation(bc, participatingSet.has(idx + 2))).join("");
|
|
1298
|
-
const handLabel = colorize("Hand:",
|
|
1299
|
-
const boardLabel = colorize("Board:",
|
|
1380
|
+
const handLabel = colorize("Hand:", lightGray);
|
|
1381
|
+
const boardLabel = colorize("Board:", lightGray);
|
|
1300
1382
|
return `${handLabel} ${handStr} | ${boardLabel} ${boardStr} \u2192 ${this.handResult?.text}`;
|
|
1301
1383
|
}
|
|
1302
1384
|
};
|
|
@@ -1502,6 +1584,7 @@ async function main() {
|
|
|
1502
1584
|
await registry.register(new LinesWidget());
|
|
1503
1585
|
await registry.register(new DurationWidget());
|
|
1504
1586
|
await registry.register(new GitWidget());
|
|
1587
|
+
await registry.register(new GitTagWidget());
|
|
1505
1588
|
await registry.register(new GitChangesWidget());
|
|
1506
1589
|
await registry.register(new ConfigCountWidget());
|
|
1507
1590
|
await registry.register(new PokerWidget());
|