copilot-statusline 0.1.13 → 0.1.14
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/README.md +1 -1
- package/dist/copilot-statusline.js +7 -87
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -276,7 +276,7 @@ Copilot CLI spawns your status line command on every state change, passing sessi
|
|
|
276
276
|
|--------|------|-------------|
|
|
277
277
|
| Context Length | `context-length` | Context window size |
|
|
278
278
|
| Context % | `context-percentage` | Percentage of context window used or remaining |
|
|
279
|
-
| Context %
|
|
279
|
+
| Context % | `context-percentage` | Live context % from Copilot (`current_context_used_percentage`) |
|
|
280
280
|
| Context Bar | `context-bar` | Visual progress bar for context usage |
|
|
281
281
|
| Remaining Tokens | `remaining-tokens` | Absolute remaining context tokens |
|
|
282
282
|
|
|
@@ -52913,7 +52913,7 @@ import { execSync as execSync3 } from "child_process";
|
|
|
52913
52913
|
import * as fs5 from "fs";
|
|
52914
52914
|
import * as path4 from "path";
|
|
52915
52915
|
var __dirname = "/Users/ts/workspace/active/statusline/copilot_statusline/src/utils";
|
|
52916
|
-
var PACKAGE_VERSION = "0.1.
|
|
52916
|
+
var PACKAGE_VERSION = "0.1.14";
|
|
52917
52917
|
function getPackageVersion() {
|
|
52918
52918
|
if (/^\d+\.\d+\.\d+/.test(PACKAGE_VERSION)) {
|
|
52919
52919
|
return PACKAGE_VERSION;
|
|
@@ -54075,18 +54075,13 @@ function getContextWindowMetrics(data) {
|
|
|
54075
54075
|
const empty = {
|
|
54076
54076
|
windowSize: null,
|
|
54077
54077
|
displayedContextLimit: null,
|
|
54078
|
-
usedTokens: null,
|
|
54079
|
-
contextLengthTokens: null,
|
|
54080
54078
|
currentContextTokens: null,
|
|
54081
54079
|
currentContextUsedPercentage: null,
|
|
54082
|
-
usedPercentage: null,
|
|
54083
|
-
remainingPercentage: null,
|
|
54084
54080
|
totalInputTokens: null,
|
|
54085
54081
|
totalOutputTokens: null,
|
|
54086
54082
|
cachedTokens: null,
|
|
54087
54083
|
totalTokens: null,
|
|
54088
54084
|
reasoningTokens: null,
|
|
54089
|
-
remainingTokens: null,
|
|
54090
54085
|
lastCallInputTokens: null,
|
|
54091
54086
|
lastCallOutputTokens: null,
|
|
54092
54087
|
cacheReadTokens: null,
|
|
@@ -54107,45 +54102,20 @@ function getContextWindowMetrics(data) {
|
|
|
54107
54102
|
const totalOutputTokens = toFiniteNonNegativeNumber(contextWindow.total_output_tokens);
|
|
54108
54103
|
const cacheReadTokens = toFiniteNonNegativeNumber(contextWindow.total_cache_read_tokens);
|
|
54109
54104
|
const cacheWriteTokens = toFiniteNonNegativeNumber(contextWindow.total_cache_write_tokens);
|
|
54110
|
-
const remainingTokens = toFiniteNonNegativeNumber(contextWindow.remaining_tokens);
|
|
54111
54105
|
const lastCallInputTokens = toFiniteNonNegativeNumber(contextWindow.last_call_input_tokens);
|
|
54112
54106
|
const lastCallOutputTokens = toFiniteNonNegativeNumber(contextWindow.last_call_output_tokens);
|
|
54113
54107
|
const cachedTokens = cacheReadTokens !== null || cacheWriteTokens !== null ? (cacheReadTokens ?? 0) + (cacheWriteTokens ?? 0) : null;
|
|
54114
|
-
|
|
54115
|
-
let contextLengthTokens = null;
|
|
54116
|
-
if (contextWindow.current_usage && typeof contextWindow.current_usage === "object") {
|
|
54117
|
-
const usage = contextWindow.current_usage;
|
|
54118
|
-
const inputTokens = toFiniteNonNegativeNumber(usage.input_tokens) ?? 0;
|
|
54119
|
-
const outputTokens = toFiniteNonNegativeNumber(usage.output_tokens) ?? 0;
|
|
54120
|
-
const cacheCreationTokens = toFiniteNonNegativeNumber(usage.cache_creation_input_tokens) ?? 0;
|
|
54121
|
-
const cacheReadInputTokens = toFiniteNonNegativeNumber(usage.cache_read_input_tokens) ?? 0;
|
|
54122
|
-
currentUsageTotalTokens = inputTokens + outputTokens + cacheCreationTokens + cacheReadInputTokens;
|
|
54123
|
-
contextLengthTokens = inputTokens + cacheCreationTokens + cacheReadInputTokens;
|
|
54124
|
-
}
|
|
54125
|
-
const rawUsedPercentage = toFiniteNonNegativeNumber(contextWindow.used_percentage);
|
|
54126
|
-
const rawRemainingPercentage = toFiniteNonNegativeNumber(contextWindow.remaining_percentage);
|
|
54127
|
-
const usedTokensFromRemaining = windowSize !== null && remainingTokens !== null ? windowSize - remainingTokens : null;
|
|
54128
|
-
const usedTokensFromPercentage = rawUsedPercentage !== null && windowSize !== null ? rawUsedPercentage / 100 * windowSize : null;
|
|
54129
|
-
const usedTokens = usedTokensFromRemaining ?? usedTokensFromPercentage ?? currentUsageTotalTokens;
|
|
54130
|
-
const usedPercentage = rawUsedPercentage !== null ? clampPercentage(rawUsedPercentage) : usedTokens !== null && windowSize !== null && windowSize > 0 ? clampPercentage(usedTokens / windowSize * 100) : null;
|
|
54131
|
-
const remainingPercentage = rawRemainingPercentage !== null ? clampPercentage(rawRemainingPercentage) : usedPercentage !== null ? 100 - usedPercentage : null;
|
|
54132
|
-
const totalTokens = currentUsageTotalTokens ?? toFiniteNonNegativeNumber(contextWindow.total_tokens) ?? (totalInputTokens !== null && totalOutputTokens !== null ? totalInputTokens + totalOutputTokens : null);
|
|
54133
|
-
const contextLengthFromAuthoritative = usedTokensFromRemaining ?? usedTokensFromPercentage;
|
|
54108
|
+
const totalTokens = toFiniteNonNegativeNumber(contextWindow.total_tokens) ?? (totalInputTokens !== null && totalOutputTokens !== null ? totalInputTokens + totalOutputTokens : null);
|
|
54134
54109
|
return {
|
|
54135
54110
|
windowSize,
|
|
54136
54111
|
displayedContextLimit,
|
|
54137
|
-
usedTokens,
|
|
54138
|
-
contextLengthTokens: contextLengthFromAuthoritative ?? contextLengthTokens ?? usedTokens,
|
|
54139
54112
|
currentContextTokens,
|
|
54140
54113
|
currentContextUsedPercentage,
|
|
54141
|
-
usedPercentage,
|
|
54142
|
-
remainingPercentage,
|
|
54143
54114
|
totalInputTokens,
|
|
54144
54115
|
totalOutputTokens,
|
|
54145
54116
|
cachedTokens,
|
|
54146
54117
|
totalTokens,
|
|
54147
54118
|
reasoningTokens,
|
|
54148
|
-
remainingTokens,
|
|
54149
54119
|
lastCallInputTokens,
|
|
54150
54120
|
lastCallOutputTokens,
|
|
54151
54121
|
cacheReadTokens,
|
|
@@ -54490,55 +54460,6 @@ class ContextPercentageWidget {
|
|
|
54490
54460
|
return true;
|
|
54491
54461
|
}
|
|
54492
54462
|
}
|
|
54493
|
-
// src/widgets/ContextPercentageUsable.ts
|
|
54494
|
-
class ContextPercentageUsableWidget {
|
|
54495
|
-
getDefaultColor() {
|
|
54496
|
-
return "blue";
|
|
54497
|
-
}
|
|
54498
|
-
getDescription() {
|
|
54499
|
-
return "Shows percentage of usable context (current_context_tokens / displayed_context_limit)";
|
|
54500
|
-
}
|
|
54501
|
-
getDisplayName() {
|
|
54502
|
-
return "Context % (Usable)";
|
|
54503
|
-
}
|
|
54504
|
-
getCategory() {
|
|
54505
|
-
return "Context";
|
|
54506
|
-
}
|
|
54507
|
-
getEditorDisplay(item) {
|
|
54508
|
-
return {
|
|
54509
|
-
displayText: this.getDisplayName(),
|
|
54510
|
-
modifierText: getContextInverseModifierText(item)
|
|
54511
|
-
};
|
|
54512
|
-
}
|
|
54513
|
-
handleEditorAction(action, item) {
|
|
54514
|
-
return handleContextInverseAction(action, item);
|
|
54515
|
-
}
|
|
54516
|
-
render(item, context, settings) {
|
|
54517
|
-
const isInverse = isContextInverse(item);
|
|
54518
|
-
if (context.isPreview) {
|
|
54519
|
-
const previewValue = isInverse ? "88.4%" : "11.6%";
|
|
54520
|
-
return formatRawOrLabeledValue(item, "Usable: ", previewValue);
|
|
54521
|
-
}
|
|
54522
|
-
const metrics = getContextWindowMetrics(context.data);
|
|
54523
|
-
if (metrics.currentContextTokens !== null && metrics.displayedContextLimit !== null && metrics.displayedContextLimit > 0) {
|
|
54524
|
-
const usablePercent = Math.min(100, metrics.currentContextTokens / metrics.displayedContextLimit * 100);
|
|
54525
|
-
const displayPercentage = isInverse ? 100 - usablePercent : usablePercent;
|
|
54526
|
-
return formatRawOrLabeledValue(item, "Usable: ", `${displayPercentage.toFixed(1)}%`);
|
|
54527
|
-
}
|
|
54528
|
-
return null;
|
|
54529
|
-
}
|
|
54530
|
-
getCustomKeybinds() {
|
|
54531
|
-
return [
|
|
54532
|
-
{ key: "u", label: "(u)sed/remaining", action: "toggle-inverse" }
|
|
54533
|
-
];
|
|
54534
|
-
}
|
|
54535
|
-
supportsRawValue() {
|
|
54536
|
-
return true;
|
|
54537
|
-
}
|
|
54538
|
-
supportsColors(item) {
|
|
54539
|
-
return true;
|
|
54540
|
-
}
|
|
54541
|
-
}
|
|
54542
54463
|
// src/utils/progress-bar.ts
|
|
54543
54464
|
var PROGRESS_BAR_FG_RESTORE = "\x1B[0;999;0q";
|
|
54544
54465
|
function makeUsageProgressBar(percent, width = 15, powerlineMode = false) {
|
|
@@ -54606,11 +54527,11 @@ class ContextBarWidget {
|
|
|
54606
54527
|
const contextWindowMetrics = getContextWindowMetrics(context.data);
|
|
54607
54528
|
const total = contextWindowMetrics.displayedContextLimit ?? contextWindowMetrics.windowSize;
|
|
54608
54529
|
const used = contextWindowMetrics.currentContextTokens;
|
|
54609
|
-
|
|
54530
|
+
const upstreamPct = contextWindowMetrics.currentContextUsedPercentage;
|
|
54531
|
+
if (used === null || total === null || total <= 0 || upstreamPct === null) {
|
|
54610
54532
|
return null;
|
|
54611
54533
|
}
|
|
54612
|
-
const
|
|
54613
|
-
const clampedPercent = Math.max(0, Math.min(100, percent));
|
|
54534
|
+
const clampedPercent = Math.max(0, Math.min(100, upstreamPct));
|
|
54614
54535
|
const usedK = Math.round(used / 1000);
|
|
54615
54536
|
const totalK = Math.round(total / 1000);
|
|
54616
54537
|
const display = `${makeUsageProgressBar(clampedPercent, barWidth, powerlineMode)} ${usedK}k/${totalK}k (${Math.round(clampedPercent)}%)`;
|
|
@@ -58218,7 +58139,6 @@ var WIDGET_MANIFEST = [
|
|
|
58218
58139
|
{ type: "context-length", create: () => new ContextLengthWidget },
|
|
58219
58140
|
{ type: "context-window", create: () => new ContextWindowWidget },
|
|
58220
58141
|
{ type: "context-percentage", create: () => new ContextPercentageWidget },
|
|
58221
|
-
{ type: "context-percentage-usable", create: () => new ContextPercentageUsableWidget },
|
|
58222
58142
|
{ type: "context-bar", create: () => new ContextBarWidget },
|
|
58223
58143
|
{ type: "session-clock", create: () => new SessionClockWidget },
|
|
58224
58144
|
{ type: "premium-requests", create: () => new PremiumRequestsWidget },
|
|
@@ -62107,8 +62027,8 @@ function advanceGlobalPowerlineThemeIndex(currentIndex, entries) {
|
|
|
62107
62027
|
// src/utils/context-percentage.ts
|
|
62108
62028
|
function calculateContextPercentage(context) {
|
|
62109
62029
|
const contextWindowMetrics = getContextWindowMetrics(context.data);
|
|
62110
|
-
if (contextWindowMetrics.
|
|
62111
|
-
return contextWindowMetrics.
|
|
62030
|
+
if (contextWindowMetrics.currentContextUsedPercentage !== null) {
|
|
62031
|
+
return contextWindowMetrics.currentContextUsedPercentage;
|
|
62112
62032
|
}
|
|
62113
62033
|
return 0;
|
|
62114
62034
|
}
|
package/package.json
CHANGED