claude-scope 0.8.38 → 0.8.41
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 +76 -38
- package/package.json +1 -1
package/dist/claude-scope.cjs
CHANGED
|
@@ -2602,6 +2602,9 @@ var init_usage_parser = __esm({
|
|
|
2602
2602
|
if (typeof usage.input_tokens !== "number" || typeof usage.output_tokens !== "number") {
|
|
2603
2603
|
return null;
|
|
2604
2604
|
}
|
|
2605
|
+
if (usage.input_tokens === 0 && usage.output_tokens === 0) {
|
|
2606
|
+
return null;
|
|
2607
|
+
}
|
|
2605
2608
|
return {
|
|
2606
2609
|
input_tokens: usage.input_tokens,
|
|
2607
2610
|
output_tokens: usage.output_tokens,
|
|
@@ -2953,16 +2956,17 @@ var init_cache_metrics_widget = __esm({
|
|
|
2953
2956
|
*/
|
|
2954
2957
|
async update(data) {
|
|
2955
2958
|
await super.update(data);
|
|
2956
|
-
const
|
|
2959
|
+
const sessionId = data.session_id;
|
|
2960
|
+
const sessionChanged = this.lastSessionId && this.lastSessionId !== sessionId;
|
|
2957
2961
|
if (sessionChanged) {
|
|
2958
2962
|
this.renderData = void 0;
|
|
2959
2963
|
}
|
|
2960
|
-
this.lastSessionId =
|
|
2964
|
+
this.lastSessionId = sessionId;
|
|
2961
2965
|
const usage = data.context_window?.current_usage;
|
|
2962
|
-
if (usage && !sessionChanged) {
|
|
2966
|
+
if (usage && !sessionChanged && sessionId) {
|
|
2963
2967
|
const hasAnyTokens = (usage.input_tokens ?? 0) > 0 || (usage.output_tokens ?? 0) > 0 || (usage.cache_creation_input_tokens ?? 0) > 0 || (usage.cache_read_input_tokens ?? 0) > 0;
|
|
2964
2968
|
if (hasAnyTokens) {
|
|
2965
|
-
this.cacheManager.setCachedUsage(
|
|
2969
|
+
this.cacheManager.setCachedUsage(sessionId, {
|
|
2966
2970
|
input_tokens: usage.input_tokens,
|
|
2967
2971
|
output_tokens: usage.output_tokens,
|
|
2968
2972
|
cache_creation_input_tokens: usage.cache_creation_input_tokens,
|
|
@@ -2971,12 +2975,17 @@ var init_cache_metrics_widget = __esm({
|
|
|
2971
2975
|
}
|
|
2972
2976
|
}
|
|
2973
2977
|
const hasRealUsage = usage && ((usage.input_tokens ?? 0) > 0 || (usage.output_tokens ?? 0) > 0 || (usage.cache_read_input_tokens ?? 0) > 0 || (usage.cache_creation_input_tokens ?? 0) > 0);
|
|
2978
|
+
const transcriptPath = data.transcript_path;
|
|
2974
2979
|
if (!usage || !hasRealUsage) {
|
|
2975
|
-
|
|
2980
|
+
if (transcriptPath) {
|
|
2981
|
+
this.cachedUsage = await this.usageParser.parseLastUsage(transcriptPath);
|
|
2982
|
+
}
|
|
2976
2983
|
} else {
|
|
2977
2984
|
this.cachedUsage = void 0;
|
|
2978
2985
|
}
|
|
2979
|
-
|
|
2986
|
+
if (transcriptPath) {
|
|
2987
|
+
this.cachedCumulativeCache = await this.usageParser.parseCumulativeCache(transcriptPath);
|
|
2988
|
+
}
|
|
2980
2989
|
}
|
|
2981
2990
|
/**
|
|
2982
2991
|
* Render the cache metrics display
|
|
@@ -2987,14 +2996,14 @@ var init_cache_metrics_widget = __esm({
|
|
|
2987
2996
|
if ((!usage || !hasRealUsage) && this.cachedUsage) {
|
|
2988
2997
|
usage = this.cachedUsage;
|
|
2989
2998
|
}
|
|
2990
|
-
if (!usage) {
|
|
2999
|
+
if (!usage && data.session_id) {
|
|
2991
3000
|
const cached = this.cacheManager.getCachedUsage(data.session_id);
|
|
2992
3001
|
if (cached) {
|
|
2993
3002
|
usage = cached.usage;
|
|
2994
3003
|
}
|
|
2995
3004
|
}
|
|
2996
3005
|
const cumulativeCacheToUse = this.cachedCumulativeCache;
|
|
2997
|
-
const metrics = this.calculateMetrics(usage, cumulativeCacheToUse);
|
|
3006
|
+
const metrics = this.calculateMetrics(usage || null, cumulativeCacheToUse || null);
|
|
2998
3007
|
if (!metrics) {
|
|
2999
3008
|
return null;
|
|
3000
3009
|
}
|
|
@@ -3531,13 +3540,18 @@ var init_context_widget = __esm({
|
|
|
3531
3540
|
*/
|
|
3532
3541
|
async update(data) {
|
|
3533
3542
|
await super.update(data);
|
|
3534
|
-
const
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3543
|
+
const contextWindow = data.context_window;
|
|
3544
|
+
if (!contextWindow) {
|
|
3545
|
+
return;
|
|
3546
|
+
}
|
|
3547
|
+
const sessionId = data.session_id;
|
|
3548
|
+
const sessionChanged = this.lastSessionId && this.lastSessionId !== sessionId;
|
|
3549
|
+
this.lastSessionId = sessionId;
|
|
3550
|
+
const { current_usage } = contextWindow;
|
|
3551
|
+
if (current_usage && !sessionChanged && sessionId) {
|
|
3538
3552
|
const hasAnyTokens = (current_usage.input_tokens ?? 0) > 0 || (current_usage.output_tokens ?? 0) > 0 || (current_usage.cache_creation_input_tokens ?? 0) > 0 || (current_usage.cache_read_input_tokens ?? 0) > 0;
|
|
3539
3553
|
if (hasAnyTokens) {
|
|
3540
|
-
this.cacheManager.setCachedUsage(
|
|
3554
|
+
this.cacheManager.setCachedUsage(sessionId, {
|
|
3541
3555
|
input_tokens: current_usage.input_tokens,
|
|
3542
3556
|
output_tokens: current_usage.output_tokens,
|
|
3543
3557
|
cache_creation_input_tokens: current_usage.cache_creation_input_tokens,
|
|
@@ -3547,37 +3561,53 @@ var init_context_widget = __esm({
|
|
|
3547
3561
|
}
|
|
3548
3562
|
const hasRealUsage = current_usage && ((current_usage.input_tokens ?? 0) > 0 || (current_usage.output_tokens ?? 0) > 0 || (current_usage.cache_read_input_tokens ?? 0) > 0 || (current_usage.cache_creation_input_tokens ?? 0) > 0);
|
|
3549
3563
|
if (!current_usage || !hasRealUsage) {
|
|
3550
|
-
|
|
3564
|
+
const transcriptPath = data.transcript_path;
|
|
3565
|
+
if (transcriptPath) {
|
|
3566
|
+
this.cachedUsage = await this.usageParser.parseLastUsage(transcriptPath);
|
|
3567
|
+
}
|
|
3551
3568
|
} else {
|
|
3552
3569
|
this.cachedUsage = void 0;
|
|
3553
3570
|
}
|
|
3554
3571
|
}
|
|
3555
3572
|
renderWithData(data, _context) {
|
|
3556
|
-
const
|
|
3573
|
+
const contextWindow = data.context_window || {};
|
|
3574
|
+
const current_usage = contextWindow.current_usage;
|
|
3575
|
+
const context_window_size = contextWindow.context_window_size;
|
|
3576
|
+
const used_percentage = contextWindow.used_percentage;
|
|
3577
|
+
if (used_percentage !== void 0) {
|
|
3578
|
+
const renderData2 = {
|
|
3579
|
+
used: 0,
|
|
3580
|
+
// Will be calculated from percentage
|
|
3581
|
+
contextWindowSize: context_window_size || 2e5,
|
|
3582
|
+
percent: Math.round(used_percentage)
|
|
3583
|
+
};
|
|
3584
|
+
return this.styleFn(renderData2, this.colors.context);
|
|
3585
|
+
}
|
|
3557
3586
|
let usage = current_usage;
|
|
3558
3587
|
const hasRealUsage = usage && ((usage.input_tokens ?? 0) > 0 || (usage.output_tokens ?? 0) > 0 || (usage.cache_read_input_tokens ?? 0) > 0 || (usage.cache_creation_input_tokens ?? 0) > 0);
|
|
3559
3588
|
if ((!usage || !hasRealUsage) && this.cachedUsage) {
|
|
3560
3589
|
usage = this.cachedUsage;
|
|
3561
3590
|
}
|
|
3562
|
-
if (!usage) {
|
|
3591
|
+
if (!usage && data.session_id) {
|
|
3563
3592
|
const cached = this.cacheManager.getCachedUsage(data.session_id);
|
|
3564
3593
|
if (cached) {
|
|
3565
3594
|
usage = cached.usage;
|
|
3566
3595
|
}
|
|
3567
3596
|
}
|
|
3597
|
+
const ctxSize = context_window_size || 2e5;
|
|
3568
3598
|
if (!usage) {
|
|
3569
3599
|
const renderData2 = {
|
|
3570
3600
|
used: 0,
|
|
3571
|
-
contextWindowSize:
|
|
3601
|
+
contextWindowSize: ctxSize,
|
|
3572
3602
|
percent: 0
|
|
3573
3603
|
};
|
|
3574
3604
|
return this.styleFn(renderData2, this.colors.context);
|
|
3575
3605
|
}
|
|
3576
|
-
const used = usage.input_tokens + usage.cache_creation_input_tokens + usage.cache_read_input_tokens;
|
|
3577
|
-
const percent = Math.round(used /
|
|
3606
|
+
const used = (usage.input_tokens || 0) + (usage.cache_creation_input_tokens || 0) + (usage.cache_read_input_tokens || 0);
|
|
3607
|
+
const percent = Math.round(used / ctxSize * 100);
|
|
3578
3608
|
const renderData = {
|
|
3579
3609
|
used,
|
|
3580
|
-
contextWindowSize:
|
|
3610
|
+
contextWindowSize: ctxSize,
|
|
3581
3611
|
percent
|
|
3582
3612
|
};
|
|
3583
3613
|
return this.styleFn(renderData, this.colors.context);
|
|
@@ -3937,7 +3967,7 @@ var init_dev_server_widget = __esm({
|
|
|
3937
3967
|
* @param data - Stdin data from Claude Code
|
|
3938
3968
|
*/
|
|
3939
3969
|
async update(data) {
|
|
3940
|
-
this.cwd = data.cwd;
|
|
3970
|
+
this.cwd = data.cwd || null;
|
|
3941
3971
|
}
|
|
3942
3972
|
/**
|
|
3943
3973
|
* Check if widget is enabled
|
|
@@ -4465,7 +4495,7 @@ var init_git_tag_widget = __esm({
|
|
|
4465
4495
|
}
|
|
4466
4496
|
}
|
|
4467
4497
|
async update(data) {
|
|
4468
|
-
if (data.cwd !== this.cwd) {
|
|
4498
|
+
if (data.cwd && data.cwd !== this.cwd) {
|
|
4469
4499
|
this.cwd = data.cwd;
|
|
4470
4500
|
this.git = this.gitFactory(data.cwd);
|
|
4471
4501
|
}
|
|
@@ -4659,7 +4689,7 @@ var init_git_widget = __esm({
|
|
|
4659
4689
|
}
|
|
4660
4690
|
}
|
|
4661
4691
|
async update(data) {
|
|
4662
|
-
if (data.cwd !== this.cwd) {
|
|
4692
|
+
if (data.cwd && data.cwd !== this.cwd) {
|
|
4663
4693
|
this.cwd = data.cwd;
|
|
4664
4694
|
this.git = this.gitFactory(data.cwd);
|
|
4665
4695
|
}
|
|
@@ -4867,6 +4897,9 @@ var init_model_widget = __esm({
|
|
|
4867
4897
|
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
4868
4898
|
}
|
|
4869
4899
|
renderWithData(data, _context) {
|
|
4900
|
+
if (!data.model) {
|
|
4901
|
+
return null;
|
|
4902
|
+
}
|
|
4870
4903
|
const renderData = {
|
|
4871
4904
|
displayName: data.model.display_name,
|
|
4872
4905
|
id: data.model.id
|
|
@@ -4912,7 +4945,9 @@ function createDemoData() {
|
|
|
4912
4945
|
output_tokens: DEMO_DATA.CURRENT_OUTPUT_TOKENS,
|
|
4913
4946
|
cache_creation_input_tokens: DEMO_DATA.CACHE_CREATION_TOKENS,
|
|
4914
4947
|
cache_read_input_tokens: DEMO_DATA.CACHE_READ_TOKENS
|
|
4915
|
-
}
|
|
4948
|
+
},
|
|
4949
|
+
used_percentage: 37.5,
|
|
4950
|
+
remaining_percentage: 62.5
|
|
4916
4951
|
}
|
|
4917
4952
|
};
|
|
4918
4953
|
}
|
|
@@ -27743,6 +27778,15 @@ var ContextUsageSchema = object({
|
|
|
27743
27778
|
cache_creation_input_tokens: number(),
|
|
27744
27779
|
cache_read_input_tokens: number()
|
|
27745
27780
|
});
|
|
27781
|
+
var ContextWindowSchema = object({
|
|
27782
|
+
total_input_tokens: optional(number()),
|
|
27783
|
+
total_output_tokens: optional(number()),
|
|
27784
|
+
context_window_size: optional(number()),
|
|
27785
|
+
current_usage: nullable(ContextUsageSchema),
|
|
27786
|
+
// Pre-calculated percentages from Claude Code (available in newer versions)
|
|
27787
|
+
used_percentage: optional(number()),
|
|
27788
|
+
remaining_percentage: optional(number())
|
|
27789
|
+
});
|
|
27746
27790
|
var CostInfoSchema = object({
|
|
27747
27791
|
total_cost_usd: optional(number()),
|
|
27748
27792
|
total_duration_ms: optional(number()),
|
|
@@ -27750,12 +27794,6 @@ var CostInfoSchema = object({
|
|
|
27750
27794
|
total_lines_added: optional(number()),
|
|
27751
27795
|
total_lines_removed: optional(number())
|
|
27752
27796
|
});
|
|
27753
|
-
var ContextWindowSchema = object({
|
|
27754
|
-
total_input_tokens: number(),
|
|
27755
|
-
total_output_tokens: number(),
|
|
27756
|
-
context_window_size: number(),
|
|
27757
|
-
current_usage: nullable(ContextUsageSchema)
|
|
27758
|
-
});
|
|
27759
27797
|
var ModelInfoSchema = object({
|
|
27760
27798
|
id: string(),
|
|
27761
27799
|
display_name: string()
|
|
@@ -27769,15 +27807,15 @@ var OutputStyleSchema = object({
|
|
|
27769
27807
|
});
|
|
27770
27808
|
var StdinDataSchema = object({
|
|
27771
27809
|
hook_event_name: optional(literal("Status")),
|
|
27772
|
-
session_id: string(),
|
|
27773
|
-
transcript_path: string(),
|
|
27774
|
-
cwd: string(),
|
|
27775
|
-
model: ModelInfoSchema,
|
|
27776
|
-
workspace: WorkspaceSchema,
|
|
27777
|
-
version: string(),
|
|
27778
|
-
output_style: OutputStyleSchema,
|
|
27810
|
+
session_id: optional(string()),
|
|
27811
|
+
transcript_path: optional(string()),
|
|
27812
|
+
cwd: optional(string()),
|
|
27813
|
+
model: optional(ModelInfoSchema),
|
|
27814
|
+
workspace: optional(WorkspaceSchema),
|
|
27815
|
+
version: optional(string()),
|
|
27816
|
+
output_style: optional(OutputStyleSchema),
|
|
27779
27817
|
cost: optional(CostInfoSchema),
|
|
27780
|
-
context_window: ContextWindowSchema
|
|
27818
|
+
context_window: optional(ContextWindowSchema)
|
|
27781
27819
|
});
|
|
27782
27820
|
|
|
27783
27821
|
// src/data/stdin-provider.ts
|