claude-scope 0.3.0 → 0.3.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 +39 -19
- package/package.json +1 -1
package/dist/claude-scope.cjs
CHANGED
|
@@ -118,12 +118,6 @@ var COST_THRESHOLDS = {
|
|
|
118
118
|
/** Above this value, show no decimal places ($123) */
|
|
119
119
|
LARGE: 100
|
|
120
120
|
};
|
|
121
|
-
var CONTEXT_THRESHOLDS = {
|
|
122
|
-
/** Below this: green (low usage) */
|
|
123
|
-
LOW_MEDIUM: 50,
|
|
124
|
-
/** Below this: yellow (medium usage), above: red (high usage) */
|
|
125
|
-
MEDIUM_HIGH: 80
|
|
126
|
-
};
|
|
127
121
|
var DEFAULTS = {
|
|
128
122
|
/** Default separator between widgets */
|
|
129
123
|
SEPARATOR: " ",
|
|
@@ -441,20 +435,26 @@ function progressBar(percent, width = DEFAULTS.PROGRESS_BAR_WIDTH) {
|
|
|
441
435
|
const empty = width - filled;
|
|
442
436
|
return "\u2588".repeat(filled) + "\u2591".repeat(empty);
|
|
443
437
|
}
|
|
444
|
-
function getContextColor(percent) {
|
|
445
|
-
const clampedPercent = Math.max(0, Math.min(100, percent));
|
|
446
|
-
if (clampedPercent < CONTEXT_THRESHOLDS.LOW_MEDIUM) {
|
|
447
|
-
return ANSI_COLORS.GREEN;
|
|
448
|
-
} else if (clampedPercent < CONTEXT_THRESHOLDS.MEDIUM_HIGH) {
|
|
449
|
-
return ANSI_COLORS.YELLOW;
|
|
450
|
-
} else {
|
|
451
|
-
return ANSI_COLORS.RED;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
438
|
function colorize(text, color) {
|
|
455
439
|
return `${color}${text}${ANSI_COLORS.RESET}`;
|
|
456
440
|
}
|
|
457
441
|
|
|
442
|
+
// src/ui/utils/colors.ts
|
|
443
|
+
var gray = "\x1B[90m";
|
|
444
|
+
|
|
445
|
+
// src/ui/theme/default-theme.ts
|
|
446
|
+
var DEFAULT_THEME = {
|
|
447
|
+
context: {
|
|
448
|
+
low: gray,
|
|
449
|
+
medium: gray,
|
|
450
|
+
high: gray
|
|
451
|
+
},
|
|
452
|
+
lines: {
|
|
453
|
+
added: gray,
|
|
454
|
+
removed: gray
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
|
|
458
458
|
// src/widgets/context-widget.ts
|
|
459
459
|
var ContextWidget = class extends StdinDataWidget {
|
|
460
460
|
id = "context";
|
|
@@ -466,15 +466,30 @@ var ContextWidget = class extends StdinDataWidget {
|
|
|
466
466
|
0
|
|
467
467
|
// First line
|
|
468
468
|
);
|
|
469
|
+
colors;
|
|
470
|
+
constructor(colors) {
|
|
471
|
+
super();
|
|
472
|
+
this.colors = colors ?? DEFAULT_THEME.context;
|
|
473
|
+
}
|
|
469
474
|
renderWithData(data, context) {
|
|
470
475
|
const { current_usage, context_window_size } = data.context_window;
|
|
471
476
|
if (!current_usage) return null;
|
|
472
477
|
const used = current_usage.input_tokens + current_usage.cache_creation_input_tokens + current_usage.cache_read_input_tokens + current_usage.output_tokens;
|
|
473
478
|
const percent = Math.round(used / context_window_size * 100);
|
|
474
479
|
const bar = progressBar(percent, DEFAULTS.PROGRESS_BAR_WIDTH);
|
|
475
|
-
const color = getContextColor(percent);
|
|
480
|
+
const color = this.getContextColor(percent);
|
|
476
481
|
return colorize(`[${bar}] ${percent}%`, color);
|
|
477
482
|
}
|
|
483
|
+
getContextColor(percent) {
|
|
484
|
+
const clampedPercent = Math.max(0, Math.min(100, percent));
|
|
485
|
+
if (clampedPercent < 50) {
|
|
486
|
+
return this.colors.low;
|
|
487
|
+
} else if (clampedPercent < 80) {
|
|
488
|
+
return this.colors.medium;
|
|
489
|
+
} else {
|
|
490
|
+
return this.colors.high;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
478
493
|
};
|
|
479
494
|
|
|
480
495
|
// src/widgets/cost-widget.ts
|
|
@@ -505,11 +520,16 @@ var LinesWidget = class extends StdinDataWidget {
|
|
|
505
520
|
0
|
|
506
521
|
// First line
|
|
507
522
|
);
|
|
523
|
+
colors;
|
|
524
|
+
constructor(colors) {
|
|
525
|
+
super();
|
|
526
|
+
this.colors = colors ?? DEFAULT_THEME.lines;
|
|
527
|
+
}
|
|
508
528
|
renderWithData(data, context) {
|
|
509
529
|
const added = data.cost?.total_lines_added ?? 0;
|
|
510
530
|
const removed = data.cost?.total_lines_removed ?? 0;
|
|
511
|
-
const addedStr = colorize(`+${added}`,
|
|
512
|
-
const removedStr = colorize(`-${removed}`,
|
|
531
|
+
const addedStr = colorize(`+${added}`, this.colors.added);
|
|
532
|
+
const removedStr = colorize(`-${removed}`, this.colors.removed);
|
|
513
533
|
return `${addedStr}/${removedStr}`;
|
|
514
534
|
}
|
|
515
535
|
};
|