ccstatusline-zh 2.2.12 → 2.2.13
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 +6 -4
- package/dist/ccstatusline.js +1241 -250
- package/package.json +2 -2
package/dist/ccstatusline.js
CHANGED
|
@@ -53962,13 +53962,6 @@ function resolvePrNoun(pr, context, deps) {
|
|
|
53962
53962
|
}
|
|
53963
53963
|
return "PR";
|
|
53964
53964
|
}
|
|
53965
|
-
function formatNoPrLabel(context, deps, noun) {
|
|
53966
|
-
const origin = deps.getRemoteInfo("origin", context);
|
|
53967
|
-
if (origin) {
|
|
53968
|
-
return `(no ${noun})`;
|
|
53969
|
-
}
|
|
53970
|
-
return `(无 ${noun})`;
|
|
53971
|
-
}
|
|
53972
53965
|
function buildDisplay(item, pr, showStatus, showTitle, noun) {
|
|
53973
53966
|
const linkText = item.rawValue ? `#${pr.number}` : `${noun} #${pr.number}`;
|
|
53974
53967
|
const parts = [renderOsc8Link(pr.url, linkText)];
|
|
@@ -54032,12 +54025,12 @@ class GitPrWidget {
|
|
|
54032
54025
|
return buildDisplay(item, PREVIEW_PR, showStatus, showTitle, resolvePrNoun(PREVIEW_PR, context, this.deps));
|
|
54033
54026
|
}
|
|
54034
54027
|
if (!this.deps.isInsideGitWorkTree(context)) {
|
|
54035
|
-
return hideNoGit ? null :
|
|
54028
|
+
return hideNoGit ? null : `(无 ${resolvePrNoun(null, context, this.deps)})`;
|
|
54036
54029
|
}
|
|
54037
54030
|
const cwd2 = this.deps.resolveGitCwd(context) ?? this.deps.getProcessCwd();
|
|
54038
54031
|
const prData = this.deps.fetchGitReviewData(cwd2);
|
|
54039
54032
|
if (!prData) {
|
|
54040
|
-
return hideNoGit ? null :
|
|
54033
|
+
return hideNoGit ? null : `(无 ${resolvePrNoun(null, context, this.deps)})`;
|
|
54041
54034
|
}
|
|
54042
54035
|
return buildDisplay(item, prData, showStatus, showTitle, resolvePrNoun(prData, context, this.deps));
|
|
54043
54036
|
}
|
|
@@ -54810,7 +54803,7 @@ class GitOriginOwnerRepoWidget {
|
|
|
54810
54803
|
getCustomKeybinds() {
|
|
54811
54804
|
return [
|
|
54812
54805
|
...getRemoteWidgetKeybinds(),
|
|
54813
|
-
{ key: "o", label: "(o)
|
|
54806
|
+
{ key: "o", label: "(o)Fork 时仅显示 owner", action: TOGGLE_OWNER_ONLY_ACTION }
|
|
54814
54807
|
];
|
|
54815
54808
|
}
|
|
54816
54809
|
supportsRawValue() {
|
|
@@ -55044,7 +55037,7 @@ class GitIsForkWidget {
|
|
|
55044
55037
|
}
|
|
55045
55038
|
getCustomKeybinds() {
|
|
55046
55039
|
return [
|
|
55047
|
-
{ key: "h", label: "(h)
|
|
55040
|
+
{ key: "h", label: "(h)非 Fork 时隐藏", action: TOGGLE_HIDE_ACTION }
|
|
55048
55041
|
];
|
|
55049
55042
|
}
|
|
55050
55043
|
supportsRawValue() {
|
|
@@ -55917,17 +55910,26 @@ function getContextConfig(modelIdentifier, contextWindowSize) {
|
|
|
55917
55910
|
var DEFAULT_CONTEXT_WINDOW_SIZE = 200000, USABLE_CONTEXT_RATIO = 0.8;
|
|
55918
55911
|
|
|
55919
55912
|
// src/utils/context-percentage.ts
|
|
55920
|
-
function
|
|
55913
|
+
function calculateContextPercentageMetrics(context) {
|
|
55921
55914
|
const contextWindowMetrics = getContextWindowMetrics(context.data);
|
|
55915
|
+
const modelIdentifier = getModelContextIdentifier(context.data?.model);
|
|
55916
|
+
const contextConfig = getContextConfig(modelIdentifier, contextWindowMetrics.windowSize);
|
|
55922
55917
|
if (contextWindowMetrics.usedPercentage !== null) {
|
|
55923
|
-
return
|
|
55918
|
+
return {
|
|
55919
|
+
usedPercentage: contextWindowMetrics.usedPercentage,
|
|
55920
|
+
windowSize: contextConfig.maxTokens
|
|
55921
|
+
};
|
|
55924
55922
|
}
|
|
55925
55923
|
if (!context.tokenMetrics) {
|
|
55926
|
-
return
|
|
55924
|
+
return null;
|
|
55927
55925
|
}
|
|
55928
|
-
|
|
55929
|
-
|
|
55930
|
-
|
|
55926
|
+
return {
|
|
55927
|
+
usedPercentage: Math.min(100, context.tokenMetrics.contextLength / contextConfig.maxTokens * 100),
|
|
55928
|
+
windowSize: contextConfig.maxTokens
|
|
55929
|
+
};
|
|
55930
|
+
}
|
|
55931
|
+
function calculateContextPercentage(context) {
|
|
55932
|
+
return calculateContextPercentageMetrics(context)?.usedPercentage ?? 0;
|
|
55931
55933
|
}
|
|
55932
55934
|
var init_context_percentage = () => {};
|
|
55933
55935
|
|
|
@@ -56034,7 +56036,7 @@ function getTerminalWidth() {
|
|
|
56034
56036
|
function canDetectTerminalWidth() {
|
|
56035
56037
|
return probeTerminalWidth() !== null;
|
|
56036
56038
|
}
|
|
56037
|
-
var __dirname = "/Users/bytedance/Documents/code/
|
|
56039
|
+
var __dirname = "/Users/bytedance/Documents/code/ai/ccstatusline-zh/src/utils", PACKAGE_VERSION = "2.2.13";
|
|
56038
56040
|
var init_terminal = () => {};
|
|
56039
56041
|
|
|
56040
56042
|
// src/utils/renderer.ts
|
|
@@ -56439,12 +56441,12 @@ function renderStatusLine(widgets, settings, context, preRenderedWidgets, preCal
|
|
|
56439
56441
|
let hasContentBefore = false;
|
|
56440
56442
|
for (let j = i - 1;j >= 0; j--) {
|
|
56441
56443
|
const prevWidget = widgets[j];
|
|
56442
|
-
if (prevWidget
|
|
56443
|
-
|
|
56444
|
-
|
|
56445
|
-
|
|
56446
|
-
|
|
56447
|
-
|
|
56444
|
+
if (!prevWidget)
|
|
56445
|
+
continue;
|
|
56446
|
+
if (prevWidget.type === "separator" || prevWidget.type === "flex-separator")
|
|
56447
|
+
continue;
|
|
56448
|
+
hasContentBefore = Boolean(preRenderedWidgets[j]?.content);
|
|
56449
|
+
break;
|
|
56448
56450
|
}
|
|
56449
56451
|
if (!hasContentBefore)
|
|
56450
56452
|
continue;
|
|
@@ -57025,11 +57027,21 @@ function isUsageProgressMode(mode) {
|
|
|
57025
57027
|
function isUsageSliderMode(mode) {
|
|
57026
57028
|
return mode === "slider" || mode === "slider-only";
|
|
57027
57029
|
}
|
|
57028
|
-
function makeSliderBar(percent, width = SLIDER_WIDTH) {
|
|
57030
|
+
function makeSliderBar(percent, width = SLIDER_WIDTH, options) {
|
|
57029
57031
|
const clamped = Math.max(0, Math.min(100, percent));
|
|
57030
57032
|
const filled = Math.round(clamped / 100 * width);
|
|
57031
|
-
const
|
|
57032
|
-
|
|
57033
|
+
const cursorPos = options?.cursorPercent !== undefined ? Math.min(Math.floor(Math.max(0, Math.min(100, options.cursorPercent)) / 100 * width), width - 1) : -1;
|
|
57034
|
+
let bar = "";
|
|
57035
|
+
for (let i = 0;i < width; i++) {
|
|
57036
|
+
if (i === cursorPos) {
|
|
57037
|
+
bar += "│";
|
|
57038
|
+
} else if (i < filled) {
|
|
57039
|
+
bar += "▓";
|
|
57040
|
+
} else {
|
|
57041
|
+
bar += "░";
|
|
57042
|
+
}
|
|
57043
|
+
}
|
|
57044
|
+
return bar;
|
|
57033
57045
|
}
|
|
57034
57046
|
function getUsageProgressBarWidth(mode) {
|
|
57035
57047
|
return mode === "progress" ? 32 : 16;
|
|
@@ -57040,6 +57052,12 @@ function isUsageInverted(item) {
|
|
|
57040
57052
|
function isUsageCompact(item) {
|
|
57041
57053
|
return isMetadataFlagEnabled(item, "compact");
|
|
57042
57054
|
}
|
|
57055
|
+
function isUsageCursorEnabled(item) {
|
|
57056
|
+
return isMetadataFlagEnabled(item, "cursor");
|
|
57057
|
+
}
|
|
57058
|
+
function toggleUsageCursor(item) {
|
|
57059
|
+
return toggleMetadataFlag(item, "cursor");
|
|
57060
|
+
}
|
|
57043
57061
|
function isUsageDateMode(item) {
|
|
57044
57062
|
return isMetadataFlagEnabled(item, "absolute");
|
|
57045
57063
|
}
|
|
@@ -57102,15 +57120,18 @@ function getUsageDisplayModifierText(item, options = {}) {
|
|
|
57102
57120
|
if (mode === "progress") {
|
|
57103
57121
|
modifiers.push("长进度条");
|
|
57104
57122
|
} else if (mode === "progress-short") {
|
|
57105
|
-
modifiers.push("
|
|
57123
|
+
modifiers.push("中进度条");
|
|
57106
57124
|
} else if (mode === "slider") {
|
|
57107
|
-
modifiers.push("
|
|
57125
|
+
modifiers.push("短进度条");
|
|
57108
57126
|
} else if (mode === "slider-only") {
|
|
57109
|
-
modifiers.push("
|
|
57127
|
+
modifiers.push("仅短进度条");
|
|
57110
57128
|
}
|
|
57111
57129
|
if (isUsageInverted(item)) {
|
|
57112
57130
|
modifiers.push("反转");
|
|
57113
57131
|
}
|
|
57132
|
+
if (isUsageCursorEnabled(item) && (isUsageProgressMode(mode) || isUsageSliderMode(mode))) {
|
|
57133
|
+
modifiers.push("时间游标");
|
|
57134
|
+
}
|
|
57114
57135
|
if (options.includeCompact && !isUsageProgressMode(mode) && isUsageCompact(item)) {
|
|
57115
57136
|
modifiers.push("紧凑");
|
|
57116
57137
|
}
|
|
@@ -57138,7 +57159,8 @@ function cycleUsageDisplayMode(item, disabledInProgressKeys = [], includeSlider
|
|
|
57138
57159
|
} else {
|
|
57139
57160
|
nextMode = currentMode === "time" ? "progress" : currentMode === "progress" ? "progress-short" : "time";
|
|
57140
57161
|
}
|
|
57141
|
-
const
|
|
57162
|
+
const keysToRemove = nextMode === "time" ? ["invert", "cursor"] : disabledInProgressKeys;
|
|
57163
|
+
const nextItem = removeMetadataKeys(item, keysToRemove);
|
|
57142
57164
|
const nextMetadata = {
|
|
57143
57165
|
...nextItem.metadata ?? {},
|
|
57144
57166
|
display: nextMode
|
|
@@ -57158,6 +57180,9 @@ function getUsagePercentCustomKeybinds(item) {
|
|
|
57158
57180
|
if (isUsageProgressMode(mode) || isUsageSliderMode(mode)) {
|
|
57159
57181
|
keybinds.push(INVERT_TOGGLE_KEYBIND);
|
|
57160
57182
|
}
|
|
57183
|
+
if (isUsageProgressMode(mode) || isUsageSliderMode(mode)) {
|
|
57184
|
+
keybinds.push(CURSOR_TOGGLE_KEYBIND);
|
|
57185
|
+
}
|
|
57161
57186
|
}
|
|
57162
57187
|
return keybinds;
|
|
57163
57188
|
}
|
|
@@ -57184,15 +57209,16 @@ function getUsageTimerCustomKeybinds(item, options = {}) {
|
|
|
57184
57209
|
}
|
|
57185
57210
|
return keybinds;
|
|
57186
57211
|
}
|
|
57187
|
-
var SLIDER_WIDTH = 10, PROGRESS_TOGGLE_KEYBIND, INVERT_TOGGLE_KEYBIND, COMPACT_TOGGLE_KEYBIND, DATE_TOGGLE_KEYBIND, HOUR_FORMAT_TOGGLE_KEYBIND, TIMEZONE_KEYBIND, LOCALE_KEYBIND;
|
|
57212
|
+
var SLIDER_WIDTH = 10, PROGRESS_TOGGLE_KEYBIND, INVERT_TOGGLE_KEYBIND, COMPACT_TOGGLE_KEYBIND, CURSOR_TOGGLE_KEYBIND, DATE_TOGGLE_KEYBIND, HOUR_FORMAT_TOGGLE_KEYBIND, TIMEZONE_KEYBIND, LOCALE_KEYBIND;
|
|
57188
57213
|
var init_usage_display = __esm(() => {
|
|
57189
57214
|
init_locales2();
|
|
57190
57215
|
PROGRESS_TOGGLE_KEYBIND = { key: "p", label: "(p)进度条切换", action: "toggle-progress" };
|
|
57191
57216
|
INVERT_TOGGLE_KEYBIND = { key: "v", label: "(v)反转填充", action: "toggle-invert" };
|
|
57192
57217
|
COMPACT_TOGGLE_KEYBIND = { key: "s", label: "(s)短时间", action: "toggle-compact" };
|
|
57218
|
+
CURSOR_TOGGLE_KEYBIND = { key: "t", label: "(t)时间游标", action: "toggle-cursor" };
|
|
57193
57219
|
DATE_TOGGLE_KEYBIND = { key: "t", label: "(t)时间戳", action: "toggle-date" };
|
|
57194
|
-
HOUR_FORMAT_TOGGLE_KEYBIND = { key: "h", label: "12/24 (h)
|
|
57195
|
-
TIMEZONE_KEYBIND = { key: "z", label: "
|
|
57220
|
+
HOUR_FORMAT_TOGGLE_KEYBIND = { key: "h", label: "12/24 小时(h)", action: "toggle-hour-format" };
|
|
57221
|
+
TIMEZONE_KEYBIND = { key: "z", label: "时区(z)", action: "edit-timezone" };
|
|
57196
57222
|
LOCALE_KEYBIND = { key: "l", label: "(l)地区", action: "edit-locale" };
|
|
57197
57223
|
});
|
|
57198
57224
|
|
|
@@ -57284,36 +57310,19 @@ class ContextPercentageWidget {
|
|
|
57284
57310
|
}
|
|
57285
57311
|
render(item, context, settings) {
|
|
57286
57312
|
const isInverse = isContextInverse(item);
|
|
57313
|
+
const label = isInverse ? "剩余: " : "已用: ";
|
|
57287
57314
|
const sliderMode = getContextSliderMode(item);
|
|
57288
|
-
const
|
|
57289
|
-
const
|
|
57290
|
-
const sliderLabel = "Ctx: ";
|
|
57291
|
-
if (context.isPreview) {
|
|
57292
|
-
const previewPercent = isInverse ? 90.7 : 9.3;
|
|
57293
|
-
const sliderResult = renderContextSlider(sliderMode, previewPercent);
|
|
57294
|
-
if (sliderResult !== null) {
|
|
57295
|
-
return formatRawOrLabeledValue(item, sliderLabel, sliderResult);
|
|
57296
|
-
}
|
|
57297
|
-
return formatRawOrLabeledValue(item, percentLabel, `${previewPercent.toFixed(1)}%`);
|
|
57298
|
-
}
|
|
57299
|
-
if (contextWindowMetrics.usedPercentage !== null) {
|
|
57300
|
-
const displayPercentage = isInverse ? 100 - contextWindowMetrics.usedPercentage : contextWindowMetrics.usedPercentage;
|
|
57315
|
+
const contextPercentageMetrics = calculateContextPercentageMetrics(context);
|
|
57316
|
+
const formatContextPercentage = (displayPercentage) => {
|
|
57301
57317
|
const sliderResult = renderContextSlider(sliderMode, displayPercentage);
|
|
57302
|
-
|
|
57303
|
-
|
|
57304
|
-
|
|
57305
|
-
return
|
|
57318
|
+
return formatRawOrLabeledValue(item, label, sliderResult ?? `${displayPercentage.toFixed(1)}%`);
|
|
57319
|
+
};
|
|
57320
|
+
if (context.isPreview) {
|
|
57321
|
+
return formatContextPercentage(isInverse ? 90.7 : 9.3);
|
|
57306
57322
|
}
|
|
57307
|
-
if (
|
|
57308
|
-
const
|
|
57309
|
-
|
|
57310
|
-
const usedPercentage = Math.min(100, context.tokenMetrics.contextLength / contextConfig.maxTokens * 100);
|
|
57311
|
-
const displayPercentage = isInverse ? 100 - usedPercentage : usedPercentage;
|
|
57312
|
-
const sliderResult = renderContextSlider(sliderMode, displayPercentage);
|
|
57313
|
-
if (sliderResult !== null) {
|
|
57314
|
-
return formatRawOrLabeledValue(item, sliderLabel, sliderResult);
|
|
57315
|
-
}
|
|
57316
|
-
return formatRawOrLabeledValue(item, percentLabel, `${displayPercentage.toFixed(1)}%`);
|
|
57323
|
+
if (contextPercentageMetrics !== null) {
|
|
57324
|
+
const displayPercentage = isInverse ? 100 - contextPercentageMetrics.usedPercentage : contextPercentageMetrics.usedPercentage;
|
|
57325
|
+
return formatContextPercentage(displayPercentage);
|
|
57317
57326
|
}
|
|
57318
57327
|
return null;
|
|
57319
57328
|
}
|
|
@@ -57331,6 +57340,7 @@ class ContextPercentageWidget {
|
|
|
57331
57340
|
}
|
|
57332
57341
|
}
|
|
57333
57342
|
var init_ContextPercentage = __esm(() => {
|
|
57343
|
+
init_context_percentage();
|
|
57334
57344
|
init_context_inverse();
|
|
57335
57345
|
init_context_slider();
|
|
57336
57346
|
});
|
|
@@ -57367,37 +57377,27 @@ class ContextPercentageUsableWidget {
|
|
|
57367
57377
|
}
|
|
57368
57378
|
render(item, context, settings) {
|
|
57369
57379
|
const isInverse = isContextInverse(item);
|
|
57380
|
+
const label = isInverse ? "剩余: " : "已用: ";
|
|
57370
57381
|
const sliderMode = getContextSliderMode(item);
|
|
57371
57382
|
const modelIdentifier = getModelContextIdentifier(context.data?.model);
|
|
57372
57383
|
const contextWindowMetrics = getContextWindowMetrics(context.data);
|
|
57373
57384
|
const contextConfig = getContextConfig(modelIdentifier, contextWindowMetrics.windowSize);
|
|
57374
|
-
const
|
|
57375
|
-
|
|
57385
|
+
const formatContextPercentage = (displayPercentage) => {
|
|
57386
|
+
const sliderResult = renderContextSlider(sliderMode, displayPercentage);
|
|
57387
|
+
return formatRawOrLabeledValue(item, label, sliderResult ?? `${displayPercentage.toFixed(1)}%`);
|
|
57388
|
+
};
|
|
57376
57389
|
if (context.isPreview) {
|
|
57377
|
-
|
|
57378
|
-
const sliderResult = renderContextSlider(sliderMode, previewPercent);
|
|
57379
|
-
if (sliderResult !== null) {
|
|
57380
|
-
return formatRawOrLabeledValue(item, sliderLabel, sliderResult);
|
|
57381
|
-
}
|
|
57382
|
-
return formatRawOrLabeledValue(item, percentLabel, `${previewPercent.toFixed(1)}%`);
|
|
57390
|
+
return formatContextPercentage(isInverse ? 88.4 : 11.6);
|
|
57383
57391
|
}
|
|
57384
57392
|
if (contextWindowMetrics.contextLengthTokens !== null) {
|
|
57385
57393
|
const usedPercentage = Math.min(100, contextWindowMetrics.contextLengthTokens / contextConfig.usableTokens * 100);
|
|
57386
57394
|
const displayPercentage = isInverse ? 100 - usedPercentage : usedPercentage;
|
|
57387
|
-
|
|
57388
|
-
if (sliderResult !== null) {
|
|
57389
|
-
return formatRawOrLabeledValue(item, sliderLabel, sliderResult);
|
|
57390
|
-
}
|
|
57391
|
-
return formatRawOrLabeledValue(item, percentLabel, `${displayPercentage.toFixed(1)}%`);
|
|
57395
|
+
return formatContextPercentage(displayPercentage);
|
|
57392
57396
|
}
|
|
57393
57397
|
if (context.tokenMetrics) {
|
|
57394
57398
|
const usedPercentage = Math.min(100, context.tokenMetrics.contextLength / contextConfig.usableTokens * 100);
|
|
57395
57399
|
const displayPercentage = isInverse ? 100 - usedPercentage : usedPercentage;
|
|
57396
|
-
|
|
57397
|
-
if (sliderResult !== null) {
|
|
57398
|
-
return formatRawOrLabeledValue(item, sliderLabel, sliderResult);
|
|
57399
|
-
}
|
|
57400
|
-
return formatRawOrLabeledValue(item, percentLabel, `${displayPercentage.toFixed(1)}%`);
|
|
57400
|
+
return formatContextPercentage(displayPercentage);
|
|
57401
57401
|
}
|
|
57402
57402
|
return null;
|
|
57403
57403
|
}
|
|
@@ -58087,18 +58087,18 @@ class CustomCommandWidget {
|
|
|
58087
58087
|
return "自定义";
|
|
58088
58088
|
}
|
|
58089
58089
|
getEditorDisplay(item) {
|
|
58090
|
-
const cmd = item.commandPath ?? "无命令";
|
|
58090
|
+
const cmd = item.commandPath ?? "[无命令]";
|
|
58091
58091
|
const truncatedCmd = cmd.length > 20 ? `${cmd.substring(0, 17)}...` : cmd;
|
|
58092
58092
|
const displayText = `${this.getDisplayName()} (${truncatedCmd})`;
|
|
58093
58093
|
const modifiers = [];
|
|
58094
58094
|
if (item.maxWidth) {
|
|
58095
|
-
modifiers.push(
|
|
58095
|
+
modifiers.push(`最大宽度:${item.maxWidth}`);
|
|
58096
58096
|
}
|
|
58097
58097
|
if (item.timeout && item.timeout !== 1000) {
|
|
58098
|
-
modifiers.push(
|
|
58098
|
+
modifiers.push(`超时:${item.timeout}ms`);
|
|
58099
58099
|
}
|
|
58100
58100
|
if (item.preserveColors) {
|
|
58101
|
-
modifiers.push("
|
|
58101
|
+
modifiers.push("保留颜色");
|
|
58102
58102
|
}
|
|
58103
58103
|
return {
|
|
58104
58104
|
displayText,
|
|
@@ -58113,7 +58113,7 @@ class CustomCommandWidget {
|
|
|
58113
58113
|
}
|
|
58114
58114
|
render(item, context, settings) {
|
|
58115
58115
|
if (context.isPreview) {
|
|
58116
|
-
return item.commandPath ? `[cmd: ${item.commandPath.substring(0, 20)}${item.commandPath.length > 20 ? "..." : ""}]` : "[
|
|
58116
|
+
return item.commandPath ? `[cmd: ${item.commandPath.substring(0, 20)}${item.commandPath.length > 20 ? "..." : ""}]` : "[No command]";
|
|
58117
58117
|
} else if (item.commandPath && context.data) {
|
|
58118
58118
|
try {
|
|
58119
58119
|
const timeout = item.timeout ?? 1000;
|
|
@@ -58253,7 +58253,7 @@ var import_react29, jsx_dev_runtime3, CustomCommandEditor = ({ widget, onComplet
|
|
|
58253
58253
|
children: [
|
|
58254
58254
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
58255
58255
|
children: [
|
|
58256
|
-
"
|
|
58256
|
+
"Enter command path:",
|
|
58257
58257
|
" ",
|
|
58258
58258
|
commandInput.slice(0, commandCursorPos),
|
|
58259
58259
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
@@ -58266,7 +58266,7 @@ var import_react29, jsx_dev_runtime3, CustomCommandEditor = ({ widget, onComplet
|
|
|
58266
58266
|
}, undefined, true, undefined, this),
|
|
58267
58267
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
58268
58268
|
dimColor: true,
|
|
58269
|
-
children: "←→
|
|
58269
|
+
children: "←→ move cursor, Enter save, ESC cancel"
|
|
58270
58270
|
}, undefined, false, undefined, this)
|
|
58271
58271
|
]
|
|
58272
58272
|
}, undefined, true, undefined, this);
|
|
@@ -58277,7 +58277,7 @@ var import_react29, jsx_dev_runtime3, CustomCommandEditor = ({ widget, onComplet
|
|
|
58277
58277
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
|
|
58278
58278
|
children: [
|
|
58279
58279
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
58280
|
-
children: "
|
|
58280
|
+
children: "Enter max width (blank for no limit): "
|
|
58281
58281
|
}, undefined, false, undefined, this),
|
|
58282
58282
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
58283
58283
|
children: widthInput
|
|
@@ -58291,7 +58291,7 @@ var import_react29, jsx_dev_runtime3, CustomCommandEditor = ({ widget, onComplet
|
|
|
58291
58291
|
}, undefined, true, undefined, this),
|
|
58292
58292
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
58293
58293
|
dimColor: true,
|
|
58294
|
-
children: "
|
|
58294
|
+
children: "Press Enter to save, ESC to cancel"
|
|
58295
58295
|
}, undefined, false, undefined, this)
|
|
58296
58296
|
]
|
|
58297
58297
|
}, undefined, true, undefined, this);
|
|
@@ -58302,7 +58302,7 @@ var import_react29, jsx_dev_runtime3, CustomCommandEditor = ({ widget, onComplet
|
|
|
58302
58302
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
|
|
58303
58303
|
children: [
|
|
58304
58304
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
58305
|
-
children: "
|
|
58305
|
+
children: "Enter timeout in milliseconds (default 1000): "
|
|
58306
58306
|
}, undefined, false, undefined, this),
|
|
58307
58307
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
58308
58308
|
children: timeoutInput
|
|
@@ -58316,13 +58316,13 @@ var import_react29, jsx_dev_runtime3, CustomCommandEditor = ({ widget, onComplet
|
|
|
58316
58316
|
}, undefined, true, undefined, this),
|
|
58317
58317
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
58318
58318
|
dimColor: true,
|
|
58319
|
-
children: "
|
|
58319
|
+
children: "Press Enter to save, ESC to cancel"
|
|
58320
58320
|
}, undefined, false, undefined, this)
|
|
58321
58321
|
]
|
|
58322
58322
|
}, undefined, true, undefined, this);
|
|
58323
58323
|
}
|
|
58324
58324
|
return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
58325
|
-
children: "
|
|
58325
|
+
children: "Unknown editor mode"
|
|
58326
58326
|
}, undefined, false, undefined, this);
|
|
58327
58327
|
};
|
|
58328
58328
|
var init_CustomCommand = __esm(async () => {
|
|
@@ -62865,6 +62865,12 @@ function getTranscriptThinkingEffort(transcriptPath) {
|
|
|
62865
62865
|
continue;
|
|
62866
62866
|
}
|
|
62867
62867
|
const visibleContent = getVisibleText(entry.message.content).trim();
|
|
62868
|
+
if (visibleContent.startsWith(EFFORT_STDOUT_PREFIX)) {
|
|
62869
|
+
const effortMatch = EFFORT_STDOUT_REGEX.exec(visibleContent);
|
|
62870
|
+
if (effortMatch) {
|
|
62871
|
+
return normalizeThinkingEffort(effortMatch[1]);
|
|
62872
|
+
}
|
|
62873
|
+
}
|
|
62868
62874
|
if (!visibleContent.startsWith(MODEL_STDOUT_PREFIX)) {
|
|
62869
62875
|
continue;
|
|
62870
62876
|
}
|
|
@@ -62876,13 +62882,14 @@ function getTranscriptThinkingEffort(transcriptPath) {
|
|
|
62876
62882
|
}
|
|
62877
62883
|
return;
|
|
62878
62884
|
}
|
|
62879
|
-
var KNOWN_THINKING_EFFORTS, KNOWN_THINKING_EFFORTS_SET, MODEL_STDOUT_PREFIX = "<local-command-stdout>Set model to ", MODEL_STDOUT_EFFORT_REGEX, UNKNOWN_EFFORT_PATTERN;
|
|
62885
|
+
var KNOWN_THINKING_EFFORTS, KNOWN_THINKING_EFFORTS_SET, MODEL_STDOUT_PREFIX = "<local-command-stdout>Set model to ", MODEL_STDOUT_EFFORT_REGEX, EFFORT_STDOUT_PREFIX = "<local-command-stdout>Set effort level to ", EFFORT_STDOUT_REGEX, UNKNOWN_EFFORT_PATTERN;
|
|
62880
62886
|
var init_jsonl_metadata = __esm(() => {
|
|
62881
62887
|
init_ansi();
|
|
62882
62888
|
init_jsonl_lines();
|
|
62883
62889
|
KNOWN_THINKING_EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
62884
62890
|
KNOWN_THINKING_EFFORTS_SET = new Set(KNOWN_THINKING_EFFORTS);
|
|
62885
62891
|
MODEL_STDOUT_EFFORT_REGEX = /^<local-command-stdout>Set model to[\s\S]*? with ([a-zA-Z0-9-]+) effort<\/local-command-stdout>$/i;
|
|
62892
|
+
EFFORT_STDOUT_REGEX = /^<local-command-stdout>Set effort level to ([a-zA-Z0-9-]+)\b/i;
|
|
62886
62893
|
UNKNOWN_EFFORT_PATTERN = /^(?=.*[a-z0-9])[a-z0-9-]{2,20}$/;
|
|
62887
62894
|
});
|
|
62888
62895
|
|
|
@@ -63199,9 +63206,9 @@ class CurrentWorkingDirWidget {
|
|
|
63199
63206
|
modifiers.push("~");
|
|
63200
63207
|
}
|
|
63201
63208
|
if (fishStyle) {
|
|
63202
|
-
modifiers.push("fish
|
|
63209
|
+
modifiers.push("fish 风格");
|
|
63203
63210
|
} else if (segments && segments > 0) {
|
|
63204
|
-
modifiers.push(
|
|
63211
|
+
modifiers.push(`段数: ${segments}`);
|
|
63205
63212
|
}
|
|
63206
63213
|
return {
|
|
63207
63214
|
displayText: this.getDisplayName(),
|
|
@@ -63276,7 +63283,7 @@ class CurrentWorkingDirWidget {
|
|
|
63276
63283
|
} else {
|
|
63277
63284
|
previewPath = "/Users/example/Documents/Projects/my-project";
|
|
63278
63285
|
}
|
|
63279
|
-
return item.rawValue ? previewPath :
|
|
63286
|
+
return item.rawValue ? previewPath : `cwd: ${previewPath}`;
|
|
63280
63287
|
}
|
|
63281
63288
|
const cwd2 = context.data?.cwd;
|
|
63282
63289
|
if (!cwd2)
|
|
@@ -63300,7 +63307,7 @@ class CurrentWorkingDirWidget {
|
|
|
63300
63307
|
}
|
|
63301
63308
|
}
|
|
63302
63309
|
}
|
|
63303
|
-
return item.rawValue ? displayPath :
|
|
63310
|
+
return item.rawValue ? displayPath : `cwd: ${displayPath}`;
|
|
63304
63311
|
}
|
|
63305
63312
|
getCustomKeybinds() {
|
|
63306
63313
|
return [
|
|
@@ -63398,7 +63405,7 @@ var import_react30, jsx_dev_runtime4, CurrentWorkingDirEditor = ({ widget, onCom
|
|
|
63398
63405
|
/* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
|
|
63399
63406
|
children: [
|
|
63400
63407
|
/* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
|
|
63401
|
-
children: "
|
|
63408
|
+
children: "Enter number of segments to display (blank for full path): "
|
|
63402
63409
|
}, undefined, false, undefined, this),
|
|
63403
63410
|
/* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
|
|
63404
63411
|
children: segmentsInput
|
|
@@ -63412,13 +63419,13 @@ var import_react30, jsx_dev_runtime4, CurrentWorkingDirEditor = ({ widget, onCom
|
|
|
63412
63419
|
}, undefined, true, undefined, this),
|
|
63413
63420
|
/* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
|
|
63414
63421
|
dimColor: true,
|
|
63415
|
-
children: "
|
|
63422
|
+
children: "Press Enter to save, ESC to cancel"
|
|
63416
63423
|
}, undefined, false, undefined, this)
|
|
63417
63424
|
]
|
|
63418
63425
|
}, undefined, true, undefined, this);
|
|
63419
63426
|
}
|
|
63420
63427
|
return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
|
|
63421
|
-
children: "
|
|
63428
|
+
children: "Unknown editor mode"
|
|
63422
63429
|
}, undefined, false, undefined, this);
|
|
63423
63430
|
};
|
|
63424
63431
|
var init_CurrentWorkingDir = __esm(async () => {
|
|
@@ -63464,141 +63471,785 @@ class ClaudeSessionIdWidget {
|
|
|
63464
63471
|
}
|
|
63465
63472
|
}
|
|
63466
63473
|
|
|
63467
|
-
// src/
|
|
63468
|
-
import
|
|
63474
|
+
// src/utils/jj.ts
|
|
63475
|
+
import { execFileSync as execFileSync4 } from "child_process";
|
|
63476
|
+
function runJjArgs(args, context, allowEmpty = false) {
|
|
63477
|
+
try {
|
|
63478
|
+
const cwd2 = resolveGitCwd(context);
|
|
63479
|
+
const output = execFileSync4("jj", args, {
|
|
63480
|
+
encoding: "utf8",
|
|
63481
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
63482
|
+
...cwd2 ? { cwd: cwd2 } : {}
|
|
63483
|
+
}).trimEnd();
|
|
63484
|
+
return allowEmpty || output.length > 0 ? output : null;
|
|
63485
|
+
} catch {
|
|
63486
|
+
return null;
|
|
63487
|
+
}
|
|
63488
|
+
}
|
|
63489
|
+
function isInsideJjRepo(context) {
|
|
63490
|
+
return runJjArgs(["root"], context) !== null;
|
|
63491
|
+
}
|
|
63492
|
+
function parseDiffStat(stat2) {
|
|
63493
|
+
const insertMatch = /(\d+)\s+insertions?/.exec(stat2);
|
|
63494
|
+
const deleteMatch = /(\d+)\s+deletions?/.exec(stat2);
|
|
63495
|
+
return {
|
|
63496
|
+
insertions: insertMatch?.[1] ? parseInt(insertMatch[1], 10) : 0,
|
|
63497
|
+
deletions: deleteMatch?.[1] ? parseInt(deleteMatch[1], 10) : 0
|
|
63498
|
+
};
|
|
63499
|
+
}
|
|
63500
|
+
function getJjChangeCounts(context) {
|
|
63501
|
+
return parseDiffStat(runJjArgs(["diff", "--stat"], context) ?? "");
|
|
63502
|
+
}
|
|
63503
|
+
var init_jj = __esm(() => {
|
|
63504
|
+
init_git();
|
|
63505
|
+
});
|
|
63469
63506
|
|
|
63470
|
-
|
|
63507
|
+
// src/widgets/JjBookmarks.ts
|
|
63508
|
+
class JjBookmarksWidget {
|
|
63471
63509
|
getDefaultColor() {
|
|
63472
|
-
return "
|
|
63510
|
+
return "magenta";
|
|
63473
63511
|
}
|
|
63474
63512
|
getDescription() {
|
|
63475
|
-
return "
|
|
63513
|
+
return "显示当前的 Jujutsu 书签";
|
|
63476
63514
|
}
|
|
63477
63515
|
getDisplayName() {
|
|
63478
|
-
return "
|
|
63516
|
+
return "JJ 书签";
|
|
63479
63517
|
}
|
|
63480
63518
|
getCategory() {
|
|
63481
|
-
return "
|
|
63519
|
+
return "Jujutsu";
|
|
63482
63520
|
}
|
|
63483
63521
|
getEditorDisplay(item) {
|
|
63484
|
-
|
|
63522
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63523
|
+
const modifiers = [];
|
|
63524
|
+
if (hideNoJj) {
|
|
63525
|
+
modifiers.push("隐藏「无 JJ」");
|
|
63526
|
+
}
|
|
63527
|
+
return {
|
|
63528
|
+
displayText: this.getDisplayName(),
|
|
63529
|
+
modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
|
|
63530
|
+
};
|
|
63485
63531
|
}
|
|
63486
|
-
|
|
63532
|
+
handleEditorAction(action, item) {
|
|
63533
|
+
if (action === "toggle-nojj") {
|
|
63534
|
+
const currentState = item.metadata?.hideNoJj === "true";
|
|
63535
|
+
return {
|
|
63536
|
+
...item,
|
|
63537
|
+
metadata: {
|
|
63538
|
+
...item.metadata,
|
|
63539
|
+
hideNoJj: (!currentState).toString()
|
|
63540
|
+
}
|
|
63541
|
+
};
|
|
63542
|
+
}
|
|
63543
|
+
return null;
|
|
63544
|
+
}
|
|
63545
|
+
render(item, context, _settings) {
|
|
63546
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63487
63547
|
if (context.isPreview) {
|
|
63488
|
-
return item.rawValue ? "
|
|
63548
|
+
return item.rawValue ? "main" : "\uD83D\uDD16 main";
|
|
63549
|
+
}
|
|
63550
|
+
if (!isInsideJjRepo(context)) {
|
|
63551
|
+
return hideNoJj ? null : "\uD83D\uDD16 无 JJ";
|
|
63552
|
+
}
|
|
63553
|
+
const bookmarks = this.getJjBookmarks(context);
|
|
63554
|
+
if (bookmarks) {
|
|
63555
|
+
return item.rawValue ? bookmarks : `\uD83D\uDD16 ${bookmarks}`;
|
|
63556
|
+
}
|
|
63557
|
+
return hideNoJj ? null : "\uD83D\uDD16 (none)";
|
|
63558
|
+
}
|
|
63559
|
+
getJjBookmarks(context) {
|
|
63560
|
+
const output = runJjArgs([
|
|
63561
|
+
"log",
|
|
63562
|
+
"--no-graph",
|
|
63563
|
+
"-r",
|
|
63564
|
+
"heads(::@ & bookmarks())",
|
|
63565
|
+
"--template",
|
|
63566
|
+
"bookmarks"
|
|
63567
|
+
], context);
|
|
63568
|
+
if (!output) {
|
|
63569
|
+
return null;
|
|
63489
63570
|
}
|
|
63490
|
-
|
|
63491
|
-
|
|
63492
|
-
const data = JSON.parse(content);
|
|
63493
|
-
const email3 = data.oauthAccount?.emailAddress;
|
|
63494
|
-
if (typeof email3 !== "string" || email3.length === 0) {
|
|
63495
|
-
return null;
|
|
63496
|
-
}
|
|
63497
|
-
return item.rawValue ? email3 : `账户: ${email3}`;
|
|
63498
|
-
} catch {
|
|
63571
|
+
const bookmarks = output.split(/\s+/).filter(Boolean);
|
|
63572
|
+
if (bookmarks.length === 0) {
|
|
63499
63573
|
return null;
|
|
63500
63574
|
}
|
|
63575
|
+
return bookmarks.join(", ");
|
|
63576
|
+
}
|
|
63577
|
+
getCustomKeybinds() {
|
|
63578
|
+
return [
|
|
63579
|
+
{ key: "h", label: "(h)隐藏「无 JJ」提示", action: "toggle-nojj" }
|
|
63580
|
+
];
|
|
63501
63581
|
}
|
|
63502
63582
|
supportsRawValue() {
|
|
63503
63583
|
return true;
|
|
63504
63584
|
}
|
|
63505
|
-
supportsColors(
|
|
63585
|
+
supportsColors() {
|
|
63506
63586
|
return true;
|
|
63507
63587
|
}
|
|
63508
63588
|
}
|
|
63509
|
-
var
|
|
63510
|
-
|
|
63589
|
+
var init_JjBookmarks = __esm(() => {
|
|
63590
|
+
init_jj();
|
|
63511
63591
|
});
|
|
63512
63592
|
|
|
63513
|
-
// src/
|
|
63514
|
-
|
|
63515
|
-
|
|
63516
|
-
return
|
|
63593
|
+
// src/widgets/JjWorkspace.ts
|
|
63594
|
+
class JjWorkspaceWidget {
|
|
63595
|
+
getDefaultColor() {
|
|
63596
|
+
return "blue";
|
|
63517
63597
|
}
|
|
63518
|
-
|
|
63519
|
-
|
|
63520
|
-
}
|
|
63521
|
-
function calculateInputSpeed(metrics) {
|
|
63522
|
-
if (metrics.totalDurationMs === 0) {
|
|
63523
|
-
return null;
|
|
63598
|
+
getDescription() {
|
|
63599
|
+
return "显示当前 Jujutsu 工作区名";
|
|
63524
63600
|
}
|
|
63525
|
-
|
|
63526
|
-
|
|
63527
|
-
}
|
|
63528
|
-
|
|
63529
|
-
|
|
63601
|
+
getDisplayName() {
|
|
63602
|
+
return "JJ 工作区";
|
|
63603
|
+
}
|
|
63604
|
+
getCategory() {
|
|
63605
|
+
return "Jujutsu";
|
|
63606
|
+
}
|
|
63607
|
+
getEditorDisplay(item) {
|
|
63608
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63609
|
+
const modifiers = [];
|
|
63610
|
+
if (hideNoJj) {
|
|
63611
|
+
modifiers.push("隐藏「无 JJ」");
|
|
63612
|
+
}
|
|
63613
|
+
return {
|
|
63614
|
+
displayText: this.getDisplayName(),
|
|
63615
|
+
modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
|
|
63616
|
+
};
|
|
63617
|
+
}
|
|
63618
|
+
handleEditorAction(action, item) {
|
|
63619
|
+
if (action === "toggle-nojj") {
|
|
63620
|
+
const currentState = item.metadata?.hideNoJj === "true";
|
|
63621
|
+
return {
|
|
63622
|
+
...item,
|
|
63623
|
+
metadata: {
|
|
63624
|
+
...item.metadata,
|
|
63625
|
+
hideNoJj: (!currentState).toString()
|
|
63626
|
+
}
|
|
63627
|
+
};
|
|
63628
|
+
}
|
|
63530
63629
|
return null;
|
|
63531
63630
|
}
|
|
63532
|
-
|
|
63533
|
-
|
|
63534
|
-
|
|
63535
|
-
|
|
63536
|
-
|
|
63537
|
-
|
|
63631
|
+
render(item, context, _settings) {
|
|
63632
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63633
|
+
if (context.isPreview) {
|
|
63634
|
+
return item.rawValue ? "default" : "◆ default";
|
|
63635
|
+
}
|
|
63636
|
+
if (!isInsideJjRepo(context)) {
|
|
63637
|
+
return hideNoJj ? null : "◆ 无 JJ";
|
|
63638
|
+
}
|
|
63639
|
+
const workspace = this.getJjWorkspace(context);
|
|
63640
|
+
if (workspace) {
|
|
63641
|
+
return item.rawValue ? workspace : `◆ ${workspace}`;
|
|
63642
|
+
}
|
|
63643
|
+
return hideNoJj ? null : "◆ 无 JJ";
|
|
63538
63644
|
}
|
|
63539
|
-
|
|
63540
|
-
const
|
|
63541
|
-
|
|
63645
|
+
getJjWorkspace(context) {
|
|
63646
|
+
const output = runJjArgs([
|
|
63647
|
+
"workspace",
|
|
63648
|
+
"list",
|
|
63649
|
+
"--template",
|
|
63650
|
+
CURRENT_WORKSPACE_TEMPLATE
|
|
63651
|
+
], context);
|
|
63652
|
+
if (!output) {
|
|
63653
|
+
return null;
|
|
63654
|
+
}
|
|
63655
|
+
return output.split(/\r?\n/).map((workspace) => workspace.trim()).find(Boolean) ?? null;
|
|
63656
|
+
}
|
|
63657
|
+
getCustomKeybinds() {
|
|
63658
|
+
return [
|
|
63659
|
+
{ key: "h", label: "(h)隐藏「无 JJ」提示", action: "toggle-nojj" }
|
|
63660
|
+
];
|
|
63661
|
+
}
|
|
63662
|
+
supportsRawValue() {
|
|
63663
|
+
return true;
|
|
63664
|
+
}
|
|
63665
|
+
supportsColors() {
|
|
63666
|
+
return true;
|
|
63542
63667
|
}
|
|
63543
|
-
return `${tokensPerSec.toFixed(1)} t/s`;
|
|
63544
63668
|
}
|
|
63669
|
+
var CURRENT_WORKSPACE_TEMPLATE = `if(target.current_working_copy(), name ++ "
|
|
63670
|
+
")`;
|
|
63671
|
+
var init_JjWorkspace = __esm(() => {
|
|
63672
|
+
init_jj();
|
|
63673
|
+
});
|
|
63545
63674
|
|
|
63546
|
-
// src/
|
|
63547
|
-
|
|
63548
|
-
|
|
63549
|
-
return
|
|
63675
|
+
// src/widgets/JjRootDir.ts
|
|
63676
|
+
class JjRootDirWidget {
|
|
63677
|
+
getDefaultColor() {
|
|
63678
|
+
return "cyan";
|
|
63550
63679
|
}
|
|
63551
|
-
|
|
63552
|
-
|
|
63553
|
-
return MIN_SPEED_WINDOW_SECONDS;
|
|
63680
|
+
getDescription() {
|
|
63681
|
+
return "显示 Jujutsu 仓库根目录名";
|
|
63554
63682
|
}
|
|
63555
|
-
|
|
63556
|
-
return
|
|
63683
|
+
getDisplayName() {
|
|
63684
|
+
return "JJ 根目录";
|
|
63557
63685
|
}
|
|
63558
|
-
|
|
63559
|
-
|
|
63560
|
-
function getWidgetSpeedWindowSeconds(item) {
|
|
63561
|
-
const metadataValue = item.metadata?.[SPEED_WINDOW_METADATA_KEY];
|
|
63562
|
-
if (!metadataValue) {
|
|
63563
|
-
return DEFAULT_SPEED_WINDOW_SECONDS;
|
|
63686
|
+
getCategory() {
|
|
63687
|
+
return "Jujutsu";
|
|
63564
63688
|
}
|
|
63565
|
-
|
|
63566
|
-
|
|
63567
|
-
|
|
63689
|
+
getEditorDisplay(item) {
|
|
63690
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63691
|
+
const modifiers = [];
|
|
63692
|
+
if (hideNoJj) {
|
|
63693
|
+
modifiers.push("隐藏「无 JJ」");
|
|
63694
|
+
}
|
|
63695
|
+
return {
|
|
63696
|
+
displayText: this.getDisplayName(),
|
|
63697
|
+
modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
|
|
63698
|
+
};
|
|
63568
63699
|
}
|
|
63569
|
-
|
|
63570
|
-
|
|
63571
|
-
|
|
63572
|
-
|
|
63573
|
-
|
|
63574
|
-
|
|
63575
|
-
|
|
63576
|
-
|
|
63577
|
-
|
|
63578
|
-
|
|
63579
|
-
[SPEED_WINDOW_METADATA_KEY]: clampSpeedWindowSeconds(seconds).toString()
|
|
63700
|
+
handleEditorAction(action, item) {
|
|
63701
|
+
if (action === "toggle-nojj") {
|
|
63702
|
+
const currentState = item.metadata?.hideNoJj === "true";
|
|
63703
|
+
return {
|
|
63704
|
+
...item,
|
|
63705
|
+
metadata: {
|
|
63706
|
+
...item.metadata,
|
|
63707
|
+
hideNoJj: (!currentState).toString()
|
|
63708
|
+
}
|
|
63709
|
+
};
|
|
63580
63710
|
}
|
|
63581
|
-
|
|
63582
|
-
}
|
|
63583
|
-
var SPEED_WINDOW_METADATA_KEY = "windowSeconds", DEFAULT_SPEED_WINDOW_SECONDS = 0, MIN_SPEED_WINDOW_SECONDS = 0, MAX_SPEED_WINDOW_SECONDS = 120;
|
|
63584
|
-
|
|
63585
|
-
// src/widgets/shared/speed-widget.tsx
|
|
63586
|
-
function getSpeedMetricsForWidget(item, context) {
|
|
63587
|
-
if (!isWidgetSpeedWindowEnabled(item)) {
|
|
63588
|
-
return context.speedMetrics ?? null;
|
|
63711
|
+
return null;
|
|
63589
63712
|
}
|
|
63590
|
-
|
|
63591
|
-
|
|
63592
|
-
|
|
63593
|
-
|
|
63594
|
-
|
|
63595
|
-
|
|
63713
|
+
render(item, context, _settings) {
|
|
63714
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63715
|
+
if (context.isPreview) {
|
|
63716
|
+
return "my-repo";
|
|
63717
|
+
}
|
|
63718
|
+
if (!isInsideJjRepo(context)) {
|
|
63719
|
+
return hideNoJj ? null : "无 JJ";
|
|
63720
|
+
}
|
|
63721
|
+
const rootDir = runJjArgs(["root"], context);
|
|
63722
|
+
if (rootDir) {
|
|
63723
|
+
return this.getRootDirName(rootDir);
|
|
63724
|
+
}
|
|
63725
|
+
return hideNoJj ? null : "无 JJ";
|
|
63596
63726
|
}
|
|
63597
|
-
|
|
63598
|
-
|
|
63727
|
+
getRootDirName(rootDir) {
|
|
63728
|
+
const trimmedRootDir = rootDir.replace(/[\\/]+$/, "");
|
|
63729
|
+
const normalizedRootDir = trimmedRootDir.length > 0 ? trimmedRootDir : rootDir;
|
|
63730
|
+
const parts = normalizedRootDir.split(/[\\/]/).filter(Boolean);
|
|
63731
|
+
const lastPart = parts[parts.length - 1];
|
|
63732
|
+
return lastPart && lastPart.length > 0 ? lastPart : normalizedRootDir;
|
|
63599
63733
|
}
|
|
63600
|
-
|
|
63601
|
-
|
|
63734
|
+
getCustomKeybinds() {
|
|
63735
|
+
return [
|
|
63736
|
+
{ key: "h", label: "(h)隐藏「无 JJ」提示", action: "toggle-nojj" }
|
|
63737
|
+
];
|
|
63738
|
+
}
|
|
63739
|
+
supportsRawValue() {
|
|
63740
|
+
return false;
|
|
63741
|
+
}
|
|
63742
|
+
supportsColors() {
|
|
63743
|
+
return true;
|
|
63744
|
+
}
|
|
63745
|
+
}
|
|
63746
|
+
var init_JjRootDir = __esm(() => {
|
|
63747
|
+
init_jj();
|
|
63748
|
+
});
|
|
63749
|
+
|
|
63750
|
+
// src/widgets/JjChanges.ts
|
|
63751
|
+
class JjChangesWidget {
|
|
63752
|
+
getDefaultColor() {
|
|
63753
|
+
return "yellow";
|
|
63754
|
+
}
|
|
63755
|
+
getDescription() {
|
|
63756
|
+
return "显示 Jujutsu 变更数(+新增, -删除)";
|
|
63757
|
+
}
|
|
63758
|
+
getDisplayName() {
|
|
63759
|
+
return "JJ 变更数";
|
|
63760
|
+
}
|
|
63761
|
+
getCategory() {
|
|
63762
|
+
return "Jujutsu";
|
|
63763
|
+
}
|
|
63764
|
+
getEditorDisplay(item) {
|
|
63765
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63766
|
+
const modifiers = [];
|
|
63767
|
+
if (hideNoJj) {
|
|
63768
|
+
modifiers.push("隐藏「无 JJ」");
|
|
63769
|
+
}
|
|
63770
|
+
return {
|
|
63771
|
+
displayText: this.getDisplayName(),
|
|
63772
|
+
modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
|
|
63773
|
+
};
|
|
63774
|
+
}
|
|
63775
|
+
handleEditorAction(action, item) {
|
|
63776
|
+
if (action === "toggle-nojj") {
|
|
63777
|
+
const currentState = item.metadata?.hideNoJj === "true";
|
|
63778
|
+
return {
|
|
63779
|
+
...item,
|
|
63780
|
+
metadata: {
|
|
63781
|
+
...item.metadata,
|
|
63782
|
+
hideNoJj: (!currentState).toString()
|
|
63783
|
+
}
|
|
63784
|
+
};
|
|
63785
|
+
}
|
|
63786
|
+
return null;
|
|
63787
|
+
}
|
|
63788
|
+
render(item, context, _settings) {
|
|
63789
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63790
|
+
if (context.isPreview) {
|
|
63791
|
+
return "(+42,-10)";
|
|
63792
|
+
}
|
|
63793
|
+
if (!isInsideJjRepo(context)) {
|
|
63794
|
+
return hideNoJj ? null : "(无 JJ)";
|
|
63795
|
+
}
|
|
63796
|
+
const changes = this.getJjChanges(context);
|
|
63797
|
+
if (changes) {
|
|
63798
|
+
return `(+${changes.insertions},-${changes.deletions})`;
|
|
63799
|
+
}
|
|
63800
|
+
return hideNoJj ? null : "(无 JJ)";
|
|
63801
|
+
}
|
|
63802
|
+
getJjChanges(context) {
|
|
63803
|
+
const stat2 = runJjArgs(["diff", "--stat"], context);
|
|
63804
|
+
let totalInsertions = 0;
|
|
63805
|
+
let totalDeletions = 0;
|
|
63806
|
+
if (stat2) {
|
|
63807
|
+
const lines = stat2.split(`
|
|
63808
|
+
`);
|
|
63809
|
+
const summaryLine = lines[lines.length - 1];
|
|
63810
|
+
if (summaryLine) {
|
|
63811
|
+
const insertMatch = /(\d+) insertion/.exec(summaryLine);
|
|
63812
|
+
const deleteMatch = /(\d+) deletion/.exec(summaryLine);
|
|
63813
|
+
totalInsertions += insertMatch?.[1] ? parseInt(insertMatch[1], 10) : 0;
|
|
63814
|
+
totalDeletions += deleteMatch?.[1] ? parseInt(deleteMatch[1], 10) : 0;
|
|
63815
|
+
}
|
|
63816
|
+
}
|
|
63817
|
+
return { insertions: totalInsertions, deletions: totalDeletions };
|
|
63818
|
+
}
|
|
63819
|
+
getCustomKeybinds() {
|
|
63820
|
+
return [
|
|
63821
|
+
{ key: "h", label: "(h)隐藏「无 JJ」提示", action: "toggle-nojj" }
|
|
63822
|
+
];
|
|
63823
|
+
}
|
|
63824
|
+
supportsRawValue() {
|
|
63825
|
+
return false;
|
|
63826
|
+
}
|
|
63827
|
+
supportsColors() {
|
|
63828
|
+
return true;
|
|
63829
|
+
}
|
|
63830
|
+
}
|
|
63831
|
+
var init_JjChanges = __esm(() => {
|
|
63832
|
+
init_jj();
|
|
63833
|
+
});
|
|
63834
|
+
|
|
63835
|
+
// src/widgets/JjInsertions.ts
|
|
63836
|
+
class JjInsertionsWidget {
|
|
63837
|
+
getDefaultColor() {
|
|
63838
|
+
return "green";
|
|
63839
|
+
}
|
|
63840
|
+
getDescription() {
|
|
63841
|
+
return "显示 Jujutsu 新增行数";
|
|
63842
|
+
}
|
|
63843
|
+
getDisplayName() {
|
|
63844
|
+
return "JJ 新增行数";
|
|
63845
|
+
}
|
|
63846
|
+
getCategory() {
|
|
63847
|
+
return "Jujutsu";
|
|
63848
|
+
}
|
|
63849
|
+
getEditorDisplay(item) {
|
|
63850
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63851
|
+
const modifiers = [];
|
|
63852
|
+
if (hideNoJj) {
|
|
63853
|
+
modifiers.push("隐藏「无 JJ」");
|
|
63854
|
+
}
|
|
63855
|
+
return {
|
|
63856
|
+
displayText: this.getDisplayName(),
|
|
63857
|
+
modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
|
|
63858
|
+
};
|
|
63859
|
+
}
|
|
63860
|
+
handleEditorAction(action, item) {
|
|
63861
|
+
if (action === "toggle-nojj") {
|
|
63862
|
+
const currentState = item.metadata?.hideNoJj === "true";
|
|
63863
|
+
return {
|
|
63864
|
+
...item,
|
|
63865
|
+
metadata: {
|
|
63866
|
+
...item.metadata,
|
|
63867
|
+
hideNoJj: (!currentState).toString()
|
|
63868
|
+
}
|
|
63869
|
+
};
|
|
63870
|
+
}
|
|
63871
|
+
return null;
|
|
63872
|
+
}
|
|
63873
|
+
render(item, context, _settings) {
|
|
63874
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63875
|
+
if (context.isPreview) {
|
|
63876
|
+
return "+42";
|
|
63877
|
+
}
|
|
63878
|
+
if (!isInsideJjRepo(context)) {
|
|
63879
|
+
return hideNoJj ? null : "(无 JJ)";
|
|
63880
|
+
}
|
|
63881
|
+
const changes = getJjChangeCounts(context);
|
|
63882
|
+
return `+${changes.insertions}`;
|
|
63883
|
+
}
|
|
63884
|
+
getCustomKeybinds() {
|
|
63885
|
+
return [
|
|
63886
|
+
{ key: "h", label: "(h)隐藏「无 JJ」提示", action: "toggle-nojj" }
|
|
63887
|
+
];
|
|
63888
|
+
}
|
|
63889
|
+
supportsRawValue() {
|
|
63890
|
+
return false;
|
|
63891
|
+
}
|
|
63892
|
+
supportsColors(item) {
|
|
63893
|
+
return true;
|
|
63894
|
+
}
|
|
63895
|
+
}
|
|
63896
|
+
var init_JjInsertions = __esm(() => {
|
|
63897
|
+
init_jj();
|
|
63898
|
+
});
|
|
63899
|
+
|
|
63900
|
+
// src/widgets/JjDeletions.ts
|
|
63901
|
+
class JjDeletionsWidget {
|
|
63902
|
+
getDefaultColor() {
|
|
63903
|
+
return "red";
|
|
63904
|
+
}
|
|
63905
|
+
getDescription() {
|
|
63906
|
+
return "显示 Jujutsu 删除行数";
|
|
63907
|
+
}
|
|
63908
|
+
getDisplayName() {
|
|
63909
|
+
return "JJ 删除行数";
|
|
63910
|
+
}
|
|
63911
|
+
getCategory() {
|
|
63912
|
+
return "Jujutsu";
|
|
63913
|
+
}
|
|
63914
|
+
getEditorDisplay(item) {
|
|
63915
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63916
|
+
const modifiers = [];
|
|
63917
|
+
if (hideNoJj) {
|
|
63918
|
+
modifiers.push("隐藏「无 JJ」");
|
|
63919
|
+
}
|
|
63920
|
+
return {
|
|
63921
|
+
displayText: this.getDisplayName(),
|
|
63922
|
+
modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
|
|
63923
|
+
};
|
|
63924
|
+
}
|
|
63925
|
+
handleEditorAction(action, item) {
|
|
63926
|
+
if (action === "toggle-nojj") {
|
|
63927
|
+
const currentState = item.metadata?.hideNoJj === "true";
|
|
63928
|
+
return {
|
|
63929
|
+
...item,
|
|
63930
|
+
metadata: {
|
|
63931
|
+
...item.metadata,
|
|
63932
|
+
hideNoJj: (!currentState).toString()
|
|
63933
|
+
}
|
|
63934
|
+
};
|
|
63935
|
+
}
|
|
63936
|
+
return null;
|
|
63937
|
+
}
|
|
63938
|
+
render(item, context, _settings) {
|
|
63939
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63940
|
+
if (context.isPreview) {
|
|
63941
|
+
return "-10";
|
|
63942
|
+
}
|
|
63943
|
+
if (!isInsideJjRepo(context)) {
|
|
63944
|
+
return hideNoJj ? null : "(无 JJ)";
|
|
63945
|
+
}
|
|
63946
|
+
const changes = getJjChangeCounts(context);
|
|
63947
|
+
return `-${changes.deletions}`;
|
|
63948
|
+
}
|
|
63949
|
+
getCustomKeybinds() {
|
|
63950
|
+
return [
|
|
63951
|
+
{ key: "h", label: "(h)隐藏「无 JJ」提示", action: "toggle-nojj" }
|
|
63952
|
+
];
|
|
63953
|
+
}
|
|
63954
|
+
supportsRawValue() {
|
|
63955
|
+
return false;
|
|
63956
|
+
}
|
|
63957
|
+
supportsColors(item) {
|
|
63958
|
+
return true;
|
|
63959
|
+
}
|
|
63960
|
+
}
|
|
63961
|
+
var init_JjDeletions = __esm(() => {
|
|
63962
|
+
init_jj();
|
|
63963
|
+
});
|
|
63964
|
+
|
|
63965
|
+
// src/widgets/JjDescription.ts
|
|
63966
|
+
class JjDescriptionWidget {
|
|
63967
|
+
getDefaultColor() {
|
|
63968
|
+
return "white";
|
|
63969
|
+
}
|
|
63970
|
+
getDescription() {
|
|
63971
|
+
return "显示当前 Jujutsu 变更描述";
|
|
63972
|
+
}
|
|
63973
|
+
getDisplayName() {
|
|
63974
|
+
return "JJ 变更描述";
|
|
63975
|
+
}
|
|
63976
|
+
getCategory() {
|
|
63977
|
+
return "Jujutsu";
|
|
63978
|
+
}
|
|
63979
|
+
getEditorDisplay(item) {
|
|
63980
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
63981
|
+
const modifiers = [];
|
|
63982
|
+
if (hideNoJj) {
|
|
63983
|
+
modifiers.push("隐藏「无 JJ」");
|
|
63984
|
+
}
|
|
63985
|
+
return {
|
|
63986
|
+
displayText: this.getDisplayName(),
|
|
63987
|
+
modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
|
|
63988
|
+
};
|
|
63989
|
+
}
|
|
63990
|
+
handleEditorAction(action, item) {
|
|
63991
|
+
if (action === "toggle-nojj") {
|
|
63992
|
+
const currentState = item.metadata?.hideNoJj === "true";
|
|
63993
|
+
return {
|
|
63994
|
+
...item,
|
|
63995
|
+
metadata: {
|
|
63996
|
+
...item.metadata,
|
|
63997
|
+
hideNoJj: (!currentState).toString()
|
|
63998
|
+
}
|
|
63999
|
+
};
|
|
64000
|
+
}
|
|
64001
|
+
return null;
|
|
64002
|
+
}
|
|
64003
|
+
render(item, context, _settings) {
|
|
64004
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
64005
|
+
if (context.isPreview) {
|
|
64006
|
+
return "(无描述)";
|
|
64007
|
+
}
|
|
64008
|
+
if (!isInsideJjRepo(context)) {
|
|
64009
|
+
return hideNoJj ? null : "无 JJ";
|
|
64010
|
+
}
|
|
64011
|
+
const description = runJjArgs([
|
|
64012
|
+
"log",
|
|
64013
|
+
"--no-graph",
|
|
64014
|
+
"-r",
|
|
64015
|
+
"@",
|
|
64016
|
+
"-T",
|
|
64017
|
+
"description.first_line()"
|
|
64018
|
+
], context, true);
|
|
64019
|
+
if (description === null) {
|
|
64020
|
+
return hideNoJj ? null : "无 JJ";
|
|
64021
|
+
}
|
|
64022
|
+
return description.length > 0 ? description : "(无描述)";
|
|
64023
|
+
}
|
|
64024
|
+
getCustomKeybinds() {
|
|
64025
|
+
return [
|
|
64026
|
+
{ key: "h", label: "(h)隐藏「无 JJ」提示", action: "toggle-nojj" }
|
|
64027
|
+
];
|
|
64028
|
+
}
|
|
64029
|
+
supportsRawValue() {
|
|
64030
|
+
return false;
|
|
64031
|
+
}
|
|
64032
|
+
supportsColors(item) {
|
|
64033
|
+
return true;
|
|
64034
|
+
}
|
|
64035
|
+
}
|
|
64036
|
+
var init_JjDescription = __esm(() => {
|
|
64037
|
+
init_jj();
|
|
64038
|
+
});
|
|
64039
|
+
|
|
64040
|
+
// src/widgets/JjRevision.ts
|
|
64041
|
+
class JjRevisionWidget {
|
|
64042
|
+
getDefaultColor() {
|
|
64043
|
+
return "green";
|
|
64044
|
+
}
|
|
64045
|
+
getDescription() {
|
|
64046
|
+
return "显示当前 Jujutsu 变更 ID(短)";
|
|
64047
|
+
}
|
|
64048
|
+
getDisplayName() {
|
|
64049
|
+
return "JJ 修订";
|
|
64050
|
+
}
|
|
64051
|
+
getCategory() {
|
|
64052
|
+
return "Jujutsu";
|
|
64053
|
+
}
|
|
64054
|
+
getEditorDisplay(item) {
|
|
64055
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
64056
|
+
const modifiers = [];
|
|
64057
|
+
if (hideNoJj) {
|
|
64058
|
+
modifiers.push("隐藏「无 JJ」");
|
|
64059
|
+
}
|
|
64060
|
+
return {
|
|
64061
|
+
displayText: this.getDisplayName(),
|
|
64062
|
+
modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
|
|
64063
|
+
};
|
|
64064
|
+
}
|
|
64065
|
+
handleEditorAction(action, item) {
|
|
64066
|
+
if (action === "toggle-nojj") {
|
|
64067
|
+
const currentState = item.metadata?.hideNoJj === "true";
|
|
64068
|
+
return {
|
|
64069
|
+
...item,
|
|
64070
|
+
metadata: {
|
|
64071
|
+
...item.metadata,
|
|
64072
|
+
hideNoJj: (!currentState).toString()
|
|
64073
|
+
}
|
|
64074
|
+
};
|
|
64075
|
+
}
|
|
64076
|
+
return null;
|
|
64077
|
+
}
|
|
64078
|
+
render(item, context, _settings) {
|
|
64079
|
+
const hideNoJj = item.metadata?.hideNoJj === "true";
|
|
64080
|
+
if (context.isPreview) {
|
|
64081
|
+
return item.rawValue ? "kkmpptxz" : " kkmpptxz";
|
|
64082
|
+
}
|
|
64083
|
+
if (!isInsideJjRepo(context)) {
|
|
64084
|
+
return hideNoJj ? null : " no jj";
|
|
64085
|
+
}
|
|
64086
|
+
const changeId = this.getJjRevision(context);
|
|
64087
|
+
if (changeId) {
|
|
64088
|
+
return item.rawValue ? changeId : ` ${changeId}`;
|
|
64089
|
+
}
|
|
64090
|
+
return hideNoJj ? null : " no jj";
|
|
64091
|
+
}
|
|
64092
|
+
getJjRevision(context) {
|
|
64093
|
+
return runJjArgs([
|
|
64094
|
+
"log",
|
|
64095
|
+
"--no-graph",
|
|
64096
|
+
"-r",
|
|
64097
|
+
"@",
|
|
64098
|
+
"-T",
|
|
64099
|
+
"change_id.shortest()"
|
|
64100
|
+
], context);
|
|
64101
|
+
}
|
|
64102
|
+
getCustomKeybinds() {
|
|
64103
|
+
return [
|
|
64104
|
+
{ key: "h", label: "(h)隐藏「无 JJ」提示", action: "toggle-nojj" }
|
|
64105
|
+
];
|
|
64106
|
+
}
|
|
64107
|
+
supportsRawValue() {
|
|
64108
|
+
return true;
|
|
64109
|
+
}
|
|
64110
|
+
supportsColors() {
|
|
64111
|
+
return true;
|
|
64112
|
+
}
|
|
64113
|
+
}
|
|
64114
|
+
var init_JjRevision = __esm(() => {
|
|
64115
|
+
init_jj();
|
|
64116
|
+
});
|
|
64117
|
+
|
|
64118
|
+
// src/widgets/ClaudeAccountEmail.ts
|
|
64119
|
+
import * as fs8 from "fs";
|
|
64120
|
+
|
|
64121
|
+
class ClaudeAccountEmailWidget {
|
|
64122
|
+
getDefaultColor() {
|
|
64123
|
+
return "blue";
|
|
64124
|
+
}
|
|
64125
|
+
getDescription() {
|
|
64126
|
+
return "显示当前已登录的 Claude 账户邮箱";
|
|
64127
|
+
}
|
|
64128
|
+
getDisplayName() {
|
|
64129
|
+
return "Claude 账户邮箱";
|
|
64130
|
+
}
|
|
64131
|
+
getCategory() {
|
|
64132
|
+
return "会话";
|
|
64133
|
+
}
|
|
64134
|
+
getEditorDisplay(item) {
|
|
64135
|
+
return { displayText: this.getDisplayName() };
|
|
64136
|
+
}
|
|
64137
|
+
render(item, context, settings) {
|
|
64138
|
+
if (context.isPreview) {
|
|
64139
|
+
return item.rawValue ? "you@example.com" : "账户: you@example.com";
|
|
64140
|
+
}
|
|
64141
|
+
try {
|
|
64142
|
+
const content = fs8.readFileSync(getClaudeJsonPath(), "utf-8");
|
|
64143
|
+
const data = JSON.parse(content);
|
|
64144
|
+
const email3 = data.oauthAccount?.emailAddress;
|
|
64145
|
+
if (typeof email3 !== "string" || email3.length === 0) {
|
|
64146
|
+
return null;
|
|
64147
|
+
}
|
|
64148
|
+
return item.rawValue ? email3 : `账户: ${email3}`;
|
|
64149
|
+
} catch {
|
|
64150
|
+
return null;
|
|
64151
|
+
}
|
|
64152
|
+
}
|
|
64153
|
+
supportsRawValue() {
|
|
64154
|
+
return true;
|
|
64155
|
+
}
|
|
64156
|
+
supportsColors(item) {
|
|
64157
|
+
return true;
|
|
64158
|
+
}
|
|
64159
|
+
}
|
|
64160
|
+
var init_ClaudeAccountEmail = __esm(async () => {
|
|
64161
|
+
await init_claude_settings();
|
|
64162
|
+
});
|
|
64163
|
+
|
|
64164
|
+
// src/utils/speed-metrics.ts
|
|
64165
|
+
function calculateOutputSpeed(metrics) {
|
|
64166
|
+
if (metrics.totalDurationMs === 0) {
|
|
64167
|
+
return null;
|
|
64168
|
+
}
|
|
64169
|
+
const seconds = metrics.totalDurationMs / 1000;
|
|
64170
|
+
return metrics.outputTokens / seconds;
|
|
64171
|
+
}
|
|
64172
|
+
function calculateInputSpeed(metrics) {
|
|
64173
|
+
if (metrics.totalDurationMs === 0) {
|
|
64174
|
+
return null;
|
|
64175
|
+
}
|
|
64176
|
+
const seconds = metrics.totalDurationMs / 1000;
|
|
64177
|
+
return metrics.inputTokens / seconds;
|
|
64178
|
+
}
|
|
64179
|
+
function calculateTotalSpeed(metrics) {
|
|
64180
|
+
if (metrics.totalDurationMs === 0) {
|
|
64181
|
+
return null;
|
|
64182
|
+
}
|
|
64183
|
+
const seconds = metrics.totalDurationMs / 1000;
|
|
64184
|
+
return metrics.totalTokens / seconds;
|
|
64185
|
+
}
|
|
64186
|
+
function formatSpeed(tokensPerSec) {
|
|
64187
|
+
if (tokensPerSec === null) {
|
|
64188
|
+
return "—";
|
|
64189
|
+
}
|
|
64190
|
+
if (tokensPerSec >= 1000) {
|
|
64191
|
+
const kValue = tokensPerSec / 1000;
|
|
64192
|
+
return `${kValue.toFixed(1)}k t/s`;
|
|
64193
|
+
}
|
|
64194
|
+
return `${tokensPerSec.toFixed(1)} t/s`;
|
|
64195
|
+
}
|
|
64196
|
+
|
|
64197
|
+
// src/utils/speed-window.ts
|
|
64198
|
+
function clampSpeedWindowSeconds(value) {
|
|
64199
|
+
if (!Number.isFinite(value)) {
|
|
64200
|
+
return DEFAULT_SPEED_WINDOW_SECONDS;
|
|
64201
|
+
}
|
|
64202
|
+
const normalized = Math.trunc(value);
|
|
64203
|
+
if (normalized < MIN_SPEED_WINDOW_SECONDS) {
|
|
64204
|
+
return MIN_SPEED_WINDOW_SECONDS;
|
|
64205
|
+
}
|
|
64206
|
+
if (normalized > MAX_SPEED_WINDOW_SECONDS) {
|
|
64207
|
+
return MAX_SPEED_WINDOW_SECONDS;
|
|
64208
|
+
}
|
|
64209
|
+
return normalized;
|
|
64210
|
+
}
|
|
64211
|
+
function getWidgetSpeedWindowSeconds(item) {
|
|
64212
|
+
const metadataValue = item.metadata?.[SPEED_WINDOW_METADATA_KEY];
|
|
64213
|
+
if (!metadataValue) {
|
|
64214
|
+
return DEFAULT_SPEED_WINDOW_SECONDS;
|
|
64215
|
+
}
|
|
64216
|
+
const parsed = Number.parseInt(metadataValue, 10);
|
|
64217
|
+
if (!Number.isFinite(parsed)) {
|
|
64218
|
+
return DEFAULT_SPEED_WINDOW_SECONDS;
|
|
64219
|
+
}
|
|
64220
|
+
return clampSpeedWindowSeconds(parsed);
|
|
64221
|
+
}
|
|
64222
|
+
function isWidgetSpeedWindowEnabled(item) {
|
|
64223
|
+
return getWidgetSpeedWindowSeconds(item) > 0;
|
|
64224
|
+
}
|
|
64225
|
+
function withWidgetSpeedWindowSeconds(item, seconds) {
|
|
64226
|
+
return {
|
|
64227
|
+
...item,
|
|
64228
|
+
metadata: {
|
|
64229
|
+
...item.metadata ?? {},
|
|
64230
|
+
[SPEED_WINDOW_METADATA_KEY]: clampSpeedWindowSeconds(seconds).toString()
|
|
64231
|
+
}
|
|
64232
|
+
};
|
|
64233
|
+
}
|
|
64234
|
+
var SPEED_WINDOW_METADATA_KEY = "windowSeconds", DEFAULT_SPEED_WINDOW_SECONDS = 0, MIN_SPEED_WINDOW_SECONDS = 0, MAX_SPEED_WINDOW_SECONDS = 120;
|
|
64235
|
+
|
|
64236
|
+
// src/widgets/shared/speed-widget.tsx
|
|
64237
|
+
function getSpeedMetricsForWidget(item, context) {
|
|
64238
|
+
if (!isWidgetSpeedWindowEnabled(item)) {
|
|
64239
|
+
return context.speedMetrics ?? null;
|
|
64240
|
+
}
|
|
64241
|
+
const windowSeconds = getWidgetSpeedWindowSeconds(item);
|
|
64242
|
+
return context.windowedSpeedMetrics?.[windowSeconds.toString()] ?? null;
|
|
64243
|
+
}
|
|
64244
|
+
function calculateSpeed(kind, metrics) {
|
|
64245
|
+
if (kind === "input") {
|
|
64246
|
+
return calculateInputSpeed(metrics);
|
|
64247
|
+
}
|
|
64248
|
+
if (kind === "output") {
|
|
64249
|
+
return calculateOutputSpeed(metrics);
|
|
64250
|
+
}
|
|
64251
|
+
return calculateTotalSpeed(metrics);
|
|
64252
|
+
}
|
|
63602
64253
|
function getSpeedWidgetDisplayName(kind) {
|
|
63603
64254
|
return SPEED_WIDGET_CONFIG[kind].displayName;
|
|
63604
64255
|
}
|
|
@@ -63979,6 +64630,24 @@ class SessionNameWidget {
|
|
|
63979
64630
|
}
|
|
63980
64631
|
var init_SessionName = () => {};
|
|
63981
64632
|
|
|
64633
|
+
// src/widgets/shared/progress-bar.ts
|
|
64634
|
+
function makeTimerProgressBar2(percent, width, options) {
|
|
64635
|
+
const clampedPercent = Math.max(0, Math.min(100, percent));
|
|
64636
|
+
const filledWidth = Math.round(clampedPercent / 100 * width);
|
|
64637
|
+
const cursorPos = options?.cursorPercent !== undefined ? Math.min(Math.floor(Math.max(0, Math.min(100, options.cursorPercent)) / 100 * width), width - 1) : -1;
|
|
64638
|
+
let bar = "";
|
|
64639
|
+
for (let i = 0;i < width; i++) {
|
|
64640
|
+
if (i === cursorPos) {
|
|
64641
|
+
bar += "│";
|
|
64642
|
+
} else if (i < filledWidth) {
|
|
64643
|
+
bar += "█";
|
|
64644
|
+
} else {
|
|
64645
|
+
bar += "░";
|
|
64646
|
+
}
|
|
64647
|
+
}
|
|
64648
|
+
return bar;
|
|
64649
|
+
}
|
|
64650
|
+
|
|
63982
64651
|
// src/widgets/SessionUsage.ts
|
|
63983
64652
|
class SessionUsageWidget {
|
|
63984
64653
|
getDefaultColor() {
|
|
@@ -64006,21 +64675,26 @@ class SessionUsageWidget {
|
|
|
64006
64675
|
if (action === "toggle-invert") {
|
|
64007
64676
|
return toggleUsageInverted(item);
|
|
64008
64677
|
}
|
|
64678
|
+
if (action === "toggle-cursor") {
|
|
64679
|
+
return toggleUsageCursor(item);
|
|
64680
|
+
}
|
|
64009
64681
|
return null;
|
|
64010
64682
|
}
|
|
64011
64683
|
render(item, context, settings) {
|
|
64012
64684
|
const displayMode = getUsageDisplayMode(item);
|
|
64013
64685
|
const inverted = isUsageInverted(item);
|
|
64686
|
+
const showCursor = isUsageCursorEnabled(item);
|
|
64014
64687
|
if (context.isPreview) {
|
|
64015
64688
|
const previewPercent = 20;
|
|
64016
64689
|
const renderedPercent2 = inverted ? 100 - previewPercent : previewPercent;
|
|
64017
64690
|
if (isUsageProgressMode(displayMode)) {
|
|
64018
64691
|
const width = getUsageProgressBarWidth(displayMode);
|
|
64019
|
-
const
|
|
64692
|
+
const progressBar = makeTimerProgressBar2(renderedPercent2, width, showCursor ? { cursorPercent: 50 } : undefined);
|
|
64693
|
+
const progressDisplay = `[${progressBar}] ${renderedPercent2.toFixed(1)}%`;
|
|
64020
64694
|
return formatRawOrLabeledValue(item, "会话: ", progressDisplay);
|
|
64021
64695
|
}
|
|
64022
64696
|
if (isUsageSliderMode(displayMode)) {
|
|
64023
|
-
const slider = makeSliderBar(renderedPercent2);
|
|
64697
|
+
const slider = makeSliderBar(renderedPercent2, undefined, showCursor ? { cursorPercent: 50 } : undefined);
|
|
64024
64698
|
const sliderDisplay = displayMode === "slider" ? `${slider} ${renderedPercent2.toFixed(1)}%` : slider;
|
|
64025
64699
|
return formatRawOrLabeledValue(item, "会话: ", sliderDisplay);
|
|
64026
64700
|
}
|
|
@@ -64033,13 +64707,21 @@ class SessionUsageWidget {
|
|
|
64033
64707
|
return null;
|
|
64034
64708
|
const percent = Math.max(0, Math.min(100, data.sessionUsage));
|
|
64035
64709
|
const renderedPercent = inverted ? 100 - percent : percent;
|
|
64710
|
+
const getCursorOptions = () => {
|
|
64711
|
+
if (!showCursor) {
|
|
64712
|
+
return;
|
|
64713
|
+
}
|
|
64714
|
+
const window2 = resolveUsageWindowWithFallback(data, context.blockMetrics);
|
|
64715
|
+
return window2 ? { cursorPercent: window2.elapsedPercent } : undefined;
|
|
64716
|
+
};
|
|
64036
64717
|
if (isUsageProgressMode(displayMode)) {
|
|
64037
64718
|
const width = getUsageProgressBarWidth(displayMode);
|
|
64038
|
-
const
|
|
64719
|
+
const progressBar = makeTimerProgressBar2(renderedPercent, width, getCursorOptions());
|
|
64720
|
+
const progressDisplay = `[${progressBar}] ${renderedPercent.toFixed(1)}%`;
|
|
64039
64721
|
return formatRawOrLabeledValue(item, "会话: ", progressDisplay);
|
|
64040
64722
|
}
|
|
64041
64723
|
if (isUsageSliderMode(displayMode)) {
|
|
64042
|
-
const slider = makeSliderBar(renderedPercent);
|
|
64724
|
+
const slider = makeSliderBar(renderedPercent, undefined, getCursorOptions());
|
|
64043
64725
|
const sliderDisplay = displayMode === "slider" ? `${slider} ${renderedPercent.toFixed(1)}%` : slider;
|
|
64044
64726
|
return formatRawOrLabeledValue(item, "会话: ", sliderDisplay);
|
|
64045
64727
|
}
|
|
@@ -64087,21 +64769,26 @@ class WeeklyUsageWidget {
|
|
|
64087
64769
|
if (action === "toggle-invert") {
|
|
64088
64770
|
return toggleUsageInverted(item);
|
|
64089
64771
|
}
|
|
64772
|
+
if (action === "toggle-cursor") {
|
|
64773
|
+
return toggleUsageCursor(item);
|
|
64774
|
+
}
|
|
64090
64775
|
return null;
|
|
64091
64776
|
}
|
|
64092
64777
|
render(item, context, settings) {
|
|
64093
64778
|
const displayMode = getUsageDisplayMode(item);
|
|
64094
64779
|
const inverted = isUsageInverted(item);
|
|
64780
|
+
const showCursor = isUsageCursorEnabled(item);
|
|
64095
64781
|
if (context.isPreview) {
|
|
64096
64782
|
const previewPercent = 12;
|
|
64097
64783
|
const renderedPercent2 = inverted ? 100 - previewPercent : previewPercent;
|
|
64098
64784
|
if (isUsageProgressMode(displayMode)) {
|
|
64099
64785
|
const width = getUsageProgressBarWidth(displayMode);
|
|
64100
|
-
const
|
|
64786
|
+
const progressBar = makeTimerProgressBar2(renderedPercent2, width, showCursor ? { cursorPercent: 50 } : undefined);
|
|
64787
|
+
const progressDisplay = `[${progressBar}] ${renderedPercent2.toFixed(1)}%`;
|
|
64101
64788
|
return formatRawOrLabeledValue(item, "周用量: ", progressDisplay);
|
|
64102
64789
|
}
|
|
64103
64790
|
if (isUsageSliderMode(displayMode)) {
|
|
64104
|
-
const slider = makeSliderBar(renderedPercent2);
|
|
64791
|
+
const slider = makeSliderBar(renderedPercent2, undefined, showCursor ? { cursorPercent: 50 } : undefined);
|
|
64105
64792
|
const sliderDisplay = displayMode === "slider" ? `${slider} ${renderedPercent2.toFixed(1)}%` : slider;
|
|
64106
64793
|
return formatRawOrLabeledValue(item, "周用量: ", sliderDisplay);
|
|
64107
64794
|
}
|
|
@@ -64114,13 +64801,21 @@ class WeeklyUsageWidget {
|
|
|
64114
64801
|
return null;
|
|
64115
64802
|
const percent = Math.max(0, Math.min(100, data.weeklyUsage));
|
|
64116
64803
|
const renderedPercent = inverted ? 100 - percent : percent;
|
|
64804
|
+
const getCursorOptions = () => {
|
|
64805
|
+
if (!showCursor) {
|
|
64806
|
+
return;
|
|
64807
|
+
}
|
|
64808
|
+
const window2 = resolveWeeklyUsageWindow(data);
|
|
64809
|
+
return window2 ? { cursorPercent: window2.elapsedPercent } : undefined;
|
|
64810
|
+
};
|
|
64117
64811
|
if (isUsageProgressMode(displayMode)) {
|
|
64118
64812
|
const width = getUsageProgressBarWidth(displayMode);
|
|
64119
|
-
const
|
|
64813
|
+
const progressBar = makeTimerProgressBar2(renderedPercent, width, getCursorOptions());
|
|
64814
|
+
const progressDisplay = `[${progressBar}] ${renderedPercent.toFixed(1)}%`;
|
|
64120
64815
|
return formatRawOrLabeledValue(item, "周用量: ", progressDisplay);
|
|
64121
64816
|
}
|
|
64122
64817
|
if (isUsageSliderMode(displayMode)) {
|
|
64123
|
-
const slider = makeSliderBar(renderedPercent);
|
|
64818
|
+
const slider = makeSliderBar(renderedPercent, undefined, getCursorOptions());
|
|
64124
64819
|
const sliderDisplay = displayMode === "slider" ? `${slider} ${renderedPercent.toFixed(1)}%` : slider;
|
|
64125
64820
|
return formatRawOrLabeledValue(item, "周用量: ", sliderDisplay);
|
|
64126
64821
|
}
|
|
@@ -64593,7 +65288,7 @@ var init_timezone_editor = __esm(async () => {
|
|
|
64593
65288
|
});
|
|
64594
65289
|
|
|
64595
65290
|
// src/widgets/BlockResetTimer.ts
|
|
64596
|
-
function
|
|
65291
|
+
function makeTimerProgressBar3(percent, width) {
|
|
64597
65292
|
const clampedPercent = Math.max(0, Math.min(100, percent));
|
|
64598
65293
|
const filledWidth = Math.floor(clampedPercent / 100 * width);
|
|
64599
65294
|
const emptyWidth = width - filledWidth;
|
|
@@ -64646,7 +65341,7 @@ class BlockResetTimerWidget {
|
|
|
64646
65341
|
const previewPercent = inverted ? 90 : 10;
|
|
64647
65342
|
if (isUsageProgressMode(displayMode)) {
|
|
64648
65343
|
const barWidth = getUsageProgressBarWidth(displayMode);
|
|
64649
|
-
const progressBar =
|
|
65344
|
+
const progressBar = makeTimerProgressBar3(previewPercent, barWidth);
|
|
64650
65345
|
return formatRawOrLabeledValue(item, "重置 ", `[${progressBar}] ${previewPercent.toFixed(1)}%`);
|
|
64651
65346
|
}
|
|
64652
65347
|
if (dateMode) {
|
|
@@ -64666,7 +65361,7 @@ class BlockResetTimerWidget {
|
|
|
64666
65361
|
if (isUsageProgressMode(displayMode)) {
|
|
64667
65362
|
const barWidth = getUsageProgressBarWidth(displayMode);
|
|
64668
65363
|
const percent = inverted ? window2.remainingPercent : window2.elapsedPercent;
|
|
64669
|
-
const progressBar =
|
|
65364
|
+
const progressBar = makeTimerProgressBar3(percent, barWidth);
|
|
64670
65365
|
const percentage = percent.toFixed(1);
|
|
64671
65366
|
return formatRawOrLabeledValue(item, "重置 ", `[${progressBar}] ${percentage}%`);
|
|
64672
65367
|
}
|
|
@@ -64716,7 +65411,7 @@ var init_BlockResetTimer = __esm(async () => {
|
|
|
64716
65411
|
});
|
|
64717
65412
|
|
|
64718
65413
|
// src/widgets/WeeklyResetTimer.ts
|
|
64719
|
-
function
|
|
65414
|
+
function makeTimerProgressBar4(percent, width) {
|
|
64720
65415
|
const clampedPercent = Math.max(0, Math.min(100, percent));
|
|
64721
65416
|
const filledWidth = Math.floor(clampedPercent / 100 * width);
|
|
64722
65417
|
const emptyWidth = width - filledWidth;
|
|
@@ -64735,7 +65430,7 @@ function getWeeklyResetModifierText(item) {
|
|
|
64735
65430
|
if (displayMode === "progress") {
|
|
64736
65431
|
modifiers.push("长进度条");
|
|
64737
65432
|
} else if (displayMode === "progress-short") {
|
|
64738
|
-
modifiers.push("
|
|
65433
|
+
modifiers.push("中进度条");
|
|
64739
65434
|
}
|
|
64740
65435
|
if (isUsageInverted(item)) {
|
|
64741
65436
|
modifiers.push("反转");
|
|
@@ -64814,7 +65509,7 @@ class WeeklyResetTimerWidget {
|
|
|
64814
65509
|
const previewPercent = inverted ? 90 : 10;
|
|
64815
65510
|
if (isUsageProgressMode(displayMode)) {
|
|
64816
65511
|
const barWidth = getUsageProgressBarWidth(displayMode);
|
|
64817
|
-
const progressBar =
|
|
65512
|
+
const progressBar = makeTimerProgressBar4(previewPercent, barWidth);
|
|
64818
65513
|
return formatRawOrLabeledValue(item, "周重置 ", `[${progressBar}] ${previewPercent.toFixed(1)}%`);
|
|
64819
65514
|
}
|
|
64820
65515
|
if (dateMode) {
|
|
@@ -64834,7 +65529,7 @@ class WeeklyResetTimerWidget {
|
|
|
64834
65529
|
if (isUsageProgressMode(displayMode)) {
|
|
64835
65530
|
const barWidth = getUsageProgressBarWidth(displayMode);
|
|
64836
65531
|
const percent = inverted ? window2.remainingPercent : window2.elapsedPercent;
|
|
64837
|
-
const progressBar =
|
|
65532
|
+
const progressBar = makeTimerProgressBar4(percent, barWidth);
|
|
64838
65533
|
const percentage = percent.toFixed(1);
|
|
64839
65534
|
return formatRawOrLabeledValue(item, "周重置 ", `[${progressBar}] ${percentage}%`);
|
|
64840
65535
|
}
|
|
@@ -64917,11 +65612,11 @@ class ContextBarWidget {
|
|
|
64917
65612
|
const mode = getDisplayMode(item);
|
|
64918
65613
|
const modifiers = [];
|
|
64919
65614
|
if (mode === "progress-short") {
|
|
64920
|
-
modifiers.push("
|
|
65615
|
+
modifiers.push("中进度条");
|
|
64921
65616
|
} else if (mode === "slider") {
|
|
64922
|
-
modifiers.push("
|
|
65617
|
+
modifiers.push("短进度条");
|
|
64923
65618
|
} else if (mode === "slider-only") {
|
|
64924
|
-
modifiers.push("
|
|
65619
|
+
modifiers.push("仅短进度条");
|
|
64925
65620
|
}
|
|
64926
65621
|
return {
|
|
64927
65622
|
displayText: this.getDisplayName(),
|
|
@@ -65259,7 +65954,7 @@ class SkillsWidget {
|
|
|
65259
65954
|
if (this.getMode(item) === "list") {
|
|
65260
65955
|
const limit = parseListLimit(item);
|
|
65261
65956
|
if (limit > 0) {
|
|
65262
|
-
modifiers.push(
|
|
65957
|
+
modifiers.push(`数量限制: ${limit}`);
|
|
65263
65958
|
}
|
|
65264
65959
|
}
|
|
65265
65960
|
if (this.isHideWhenEmptyEnabled(item)) {
|
|
@@ -65358,7 +66053,7 @@ var import_react35, jsx_dev_runtime9, MODES, MODE_LABELS, HIDE_WHEN_EMPTY_KEY =
|
|
|
65358
66053
|
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
65359
66054
|
children: [
|
|
65360
66055
|
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
65361
|
-
children: "
|
|
66056
|
+
children: "Enter max skills to show (0 for unlimited): "
|
|
65362
66057
|
}, undefined, false, undefined, this),
|
|
65363
66058
|
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
65364
66059
|
children: limitInput
|
|
@@ -65372,13 +66067,13 @@ var import_react35, jsx_dev_runtime9, MODES, MODE_LABELS, HIDE_WHEN_EMPTY_KEY =
|
|
|
65372
66067
|
}, undefined, true, undefined, this),
|
|
65373
66068
|
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
65374
66069
|
dimColor: true,
|
|
65375
|
-
children: "
|
|
66070
|
+
children: "Press Enter to save, ESC to cancel"
|
|
65376
66071
|
}, undefined, false, undefined, this)
|
|
65377
66072
|
]
|
|
65378
66073
|
}, undefined, true, undefined, this);
|
|
65379
66074
|
}
|
|
65380
66075
|
return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
65381
|
-
children: "
|
|
66076
|
+
children: "Unknown editor mode"
|
|
65382
66077
|
}, undefined, false, undefined, this);
|
|
65383
66078
|
};
|
|
65384
66079
|
var init_Skills = __esm(async () => {
|
|
@@ -65391,6 +66086,13 @@ var init_Skills = __esm(async () => {
|
|
|
65391
66086
|
});
|
|
65392
66087
|
|
|
65393
66088
|
// src/widgets/ThinkingEffort.ts
|
|
66089
|
+
function resolveThinkingEffortFromStatusJson(context) {
|
|
66090
|
+
const effort = context.data?.effort;
|
|
66091
|
+
if (!effort || !("level" in effort)) {
|
|
66092
|
+
return;
|
|
66093
|
+
}
|
|
66094
|
+
return typeof effort.level === "string" ? normalizeThinkingEffort(effort.level) : null;
|
|
66095
|
+
}
|
|
65394
66096
|
function resolveThinkingEffortFromSettings() {
|
|
65395
66097
|
try {
|
|
65396
66098
|
const settings = loadClaudeSettingsSync({ logErrors: false });
|
|
@@ -65399,6 +66101,10 @@ function resolveThinkingEffortFromSettings() {
|
|
|
65399
66101
|
return;
|
|
65400
66102
|
}
|
|
65401
66103
|
function resolveThinkingEffort(context) {
|
|
66104
|
+
const statusEffort = resolveThinkingEffortFromStatusJson(context);
|
|
66105
|
+
if (statusEffort !== undefined) {
|
|
66106
|
+
return statusEffort;
|
|
66107
|
+
}
|
|
65402
66108
|
return getTranscriptThinkingEffort(context.data?.transcript_path) ?? resolveThinkingEffortFromSettings() ?? null;
|
|
65403
66109
|
}
|
|
65404
66110
|
function formatEffort(resolved) {
|
|
@@ -65697,6 +66403,149 @@ class GitWorktreeOriginalBranchWidget {
|
|
|
65697
66403
|
}
|
|
65698
66404
|
}
|
|
65699
66405
|
|
|
66406
|
+
// src/widgets/CompactionCounter.ts
|
|
66407
|
+
function getFormat2(item) {
|
|
66408
|
+
const format = item.metadata?.format;
|
|
66409
|
+
return FORMATS2.includes(format ?? "") ? format : DEFAULT_FORMAT2;
|
|
66410
|
+
}
|
|
66411
|
+
function removeNerdFont(item) {
|
|
66412
|
+
const { [NERD_FONT_METADATA_KEY2]: removedNerdFont, ...restMetadata } = item.metadata ?? {};
|
|
66413
|
+
return {
|
|
66414
|
+
...item,
|
|
66415
|
+
metadata: Object.keys(restMetadata).length > 0 ? restMetadata : undefined
|
|
66416
|
+
};
|
|
66417
|
+
}
|
|
66418
|
+
function setFormat2(item, format) {
|
|
66419
|
+
if (format === DEFAULT_FORMAT2) {
|
|
66420
|
+
const { format: removedFormat, ...restMetadata2 } = item.metadata ?? {};
|
|
66421
|
+
return {
|
|
66422
|
+
...item,
|
|
66423
|
+
metadata: Object.keys(restMetadata2).length > 0 ? restMetadata2 : undefined
|
|
66424
|
+
};
|
|
66425
|
+
}
|
|
66426
|
+
const { [NERD_FONT_METADATA_KEY2]: removedNerdFont, ...restMetadata } = item.metadata ?? {};
|
|
66427
|
+
return {
|
|
66428
|
+
...item,
|
|
66429
|
+
metadata: {
|
|
66430
|
+
...restMetadata,
|
|
66431
|
+
format
|
|
66432
|
+
}
|
|
66433
|
+
};
|
|
66434
|
+
}
|
|
66435
|
+
function isNerdFontEnabled2(item) {
|
|
66436
|
+
return item.metadata?.[NERD_FONT_METADATA_KEY2] === "true" && getFormat2(item) === DEFAULT_FORMAT2;
|
|
66437
|
+
}
|
|
66438
|
+
function isHideZeroEnabled(item) {
|
|
66439
|
+
return item.metadata?.[HIDE_ZERO_METADATA_KEY] === "true";
|
|
66440
|
+
}
|
|
66441
|
+
function toggleHideZero(item) {
|
|
66442
|
+
return {
|
|
66443
|
+
...item,
|
|
66444
|
+
metadata: {
|
|
66445
|
+
...item.metadata ?? {},
|
|
66446
|
+
[HIDE_ZERO_METADATA_KEY]: (!isHideZeroEnabled(item)).toString()
|
|
66447
|
+
}
|
|
66448
|
+
};
|
|
66449
|
+
}
|
|
66450
|
+
function toggleNerdFont2(item) {
|
|
66451
|
+
if (getFormat2(item) !== DEFAULT_FORMAT2) {
|
|
66452
|
+
return removeNerdFont(item);
|
|
66453
|
+
}
|
|
66454
|
+
if (!isNerdFontEnabled2(item)) {
|
|
66455
|
+
return {
|
|
66456
|
+
...item,
|
|
66457
|
+
metadata: {
|
|
66458
|
+
...item.metadata ?? {},
|
|
66459
|
+
[NERD_FONT_METADATA_KEY2]: "true"
|
|
66460
|
+
}
|
|
66461
|
+
};
|
|
66462
|
+
}
|
|
66463
|
+
return removeNerdFont(item);
|
|
66464
|
+
}
|
|
66465
|
+
function formatCount(count, format, icon) {
|
|
66466
|
+
switch (format) {
|
|
66467
|
+
case "icon-space-number":
|
|
66468
|
+
return `${icon} ${count}`;
|
|
66469
|
+
case "text-and-number":
|
|
66470
|
+
return `压缩次数: ${count}`;
|
|
66471
|
+
case "number":
|
|
66472
|
+
return String(count);
|
|
66473
|
+
}
|
|
66474
|
+
}
|
|
66475
|
+
|
|
66476
|
+
class CompactionCounterWidget {
|
|
66477
|
+
getDefaultColor() {
|
|
66478
|
+
return "yellow";
|
|
66479
|
+
}
|
|
66480
|
+
getDescription() {
|
|
66481
|
+
return "统计当前会话中上下文压缩(compaction)发生的次数";
|
|
66482
|
+
}
|
|
66483
|
+
getDisplayName() {
|
|
66484
|
+
return "压缩计数";
|
|
66485
|
+
}
|
|
66486
|
+
getCategory() {
|
|
66487
|
+
return "上下文";
|
|
66488
|
+
}
|
|
66489
|
+
getEditorDisplay(item) {
|
|
66490
|
+
const modifiers = [getFormat2(item)];
|
|
66491
|
+
if (isNerdFontEnabled2(item)) {
|
|
66492
|
+
modifiers.push("Nerd 字体");
|
|
66493
|
+
}
|
|
66494
|
+
if (isHideZeroEnabled(item)) {
|
|
66495
|
+
modifiers.push("零时隐藏");
|
|
66496
|
+
}
|
|
66497
|
+
return {
|
|
66498
|
+
displayText: "压缩计数",
|
|
66499
|
+
modifierText: `(${modifiers.join(", ")})`
|
|
66500
|
+
};
|
|
66501
|
+
}
|
|
66502
|
+
handleEditorAction(action, item) {
|
|
66503
|
+
if (action === CYCLE_FORMAT_ACTION2) {
|
|
66504
|
+
const currentFormat = getFormat2(item);
|
|
66505
|
+
const nextFormat = FORMATS2[(FORMATS2.indexOf(currentFormat) + 1) % FORMATS2.length] ?? DEFAULT_FORMAT2;
|
|
66506
|
+
return setFormat2(item, nextFormat);
|
|
66507
|
+
}
|
|
66508
|
+
if (action === TOGGLE_HIDE_ZERO_ACTION) {
|
|
66509
|
+
return toggleHideZero(item);
|
|
66510
|
+
}
|
|
66511
|
+
if (action === TOGGLE_NERD_FONT_ACTION2) {
|
|
66512
|
+
return toggleNerdFont2(item);
|
|
66513
|
+
}
|
|
66514
|
+
return null;
|
|
66515
|
+
}
|
|
66516
|
+
render(item, context, settings) {
|
|
66517
|
+
const format = getFormat2(item);
|
|
66518
|
+
const icon = isNerdFontEnabled2(item) ? COMPACTION_NERD_FONT_ICON : COMPACTION_ICON;
|
|
66519
|
+
if (context.isPreview) {
|
|
66520
|
+
return formatCount(2, format, icon);
|
|
66521
|
+
}
|
|
66522
|
+
const count = context.compactionData?.count ?? 0;
|
|
66523
|
+
if (count === 0 && isHideZeroEnabled(item))
|
|
66524
|
+
return null;
|
|
66525
|
+
return formatCount(count, format, icon);
|
|
66526
|
+
}
|
|
66527
|
+
getCustomKeybinds(item) {
|
|
66528
|
+
const keybinds = [
|
|
66529
|
+
{ key: "f", label: "(f)格式切换", action: CYCLE_FORMAT_ACTION2 }
|
|
66530
|
+
];
|
|
66531
|
+
if (item === undefined || getFormat2(item) === DEFAULT_FORMAT2) {
|
|
66532
|
+
keybinds.push({ key: "n", label: "(n)Nerd 字体", action: TOGGLE_NERD_FONT_ACTION2 });
|
|
66533
|
+
}
|
|
66534
|
+
keybinds.push({ key: "h", label: "(h)零时隐藏", action: TOGGLE_HIDE_ZERO_ACTION });
|
|
66535
|
+
return keybinds;
|
|
66536
|
+
}
|
|
66537
|
+
supportsRawValue() {
|
|
66538
|
+
return false;
|
|
66539
|
+
}
|
|
66540
|
+
supportsColors(item) {
|
|
66541
|
+
return true;
|
|
66542
|
+
}
|
|
66543
|
+
}
|
|
66544
|
+
var COMPACTION_ICON = "↻", COMPACTION_NERD_FONT_ICON = "", FORMATS2, DEFAULT_FORMAT2 = "icon-space-number", CYCLE_FORMAT_ACTION2 = "cycle-format", TOGGLE_HIDE_ZERO_ACTION = "toggle-hide-zero", TOGGLE_NERD_FONT_ACTION2 = "toggle-nerd-font", HIDE_ZERO_METADATA_KEY = "hideZero", NERD_FONT_METADATA_KEY2 = "nerdFont";
|
|
66545
|
+
var init_CompactionCounter = __esm(() => {
|
|
66546
|
+
FORMATS2 = ["icon-space-number", "text-and-number", "number"];
|
|
66547
|
+
});
|
|
66548
|
+
|
|
65700
66549
|
// src/widgets/index.ts
|
|
65701
66550
|
var init_widgets = __esm(async () => {
|
|
65702
66551
|
init_GitBranch();
|
|
@@ -65727,9 +66576,18 @@ var init_widgets = __esm(async () => {
|
|
|
65727
66576
|
init_ContextPercentage();
|
|
65728
66577
|
init_ContextPercentageUsable();
|
|
65729
66578
|
init_TerminalWidth();
|
|
66579
|
+
init_JjBookmarks();
|
|
66580
|
+
init_JjWorkspace();
|
|
66581
|
+
init_JjRootDir();
|
|
66582
|
+
init_JjChanges();
|
|
66583
|
+
init_JjInsertions();
|
|
66584
|
+
init_JjDeletions();
|
|
66585
|
+
init_JjDescription();
|
|
66586
|
+
init_JjRevision();
|
|
65730
66587
|
init_FreeMemory();
|
|
65731
66588
|
init_SessionName();
|
|
65732
66589
|
init_VimMode();
|
|
66590
|
+
init_CompactionCounter();
|
|
65733
66591
|
await __promiseAll([
|
|
65734
66592
|
init_TokensInput(),
|
|
65735
66593
|
init_TokensOutput(),
|
|
@@ -65789,6 +66647,14 @@ var init_widget_manifest = __esm(async () => {
|
|
|
65789
66647
|
{ type: "git-upstream-repo", create: () => new GitUpstreamRepoWidget },
|
|
65790
66648
|
{ type: "git-upstream-owner-repo", create: () => new GitUpstreamOwnerRepoWidget },
|
|
65791
66649
|
{ type: "git-is-fork", create: () => new GitIsForkWidget },
|
|
66650
|
+
{ type: "jj-bookmarks", create: () => new JjBookmarksWidget },
|
|
66651
|
+
{ type: "jj-workspace", create: () => new JjWorkspaceWidget },
|
|
66652
|
+
{ type: "jj-root-dir", create: () => new JjRootDirWidget },
|
|
66653
|
+
{ type: "jj-changes", create: () => new JjChangesWidget },
|
|
66654
|
+
{ type: "jj-insertions", create: () => new JjInsertionsWidget },
|
|
66655
|
+
{ type: "jj-deletions", create: () => new JjDeletionsWidget },
|
|
66656
|
+
{ type: "jj-description", create: () => new JjDescriptionWidget },
|
|
66657
|
+
{ type: "jj-revision", create: () => new JjRevisionWidget },
|
|
65792
66658
|
{ type: "current-working-dir", create: () => new CurrentWorkingDirWidget },
|
|
65793
66659
|
{ type: "tokens-input", create: () => new TokensInputWidget },
|
|
65794
66660
|
{ type: "tokens-output", create: () => new TokensOutputWidget },
|
|
@@ -65825,7 +66691,8 @@ var init_widget_manifest = __esm(async () => {
|
|
|
65825
66691
|
{ type: "worktree-mode", create: () => new GitWorktreeModeWidget },
|
|
65826
66692
|
{ type: "worktree-name", create: () => new GitWorktreeNameWidget },
|
|
65827
66693
|
{ type: "worktree-branch", create: () => new GitWorktreeBranchWidget },
|
|
65828
|
-
{ type: "worktree-original-branch", create: () => new GitWorktreeOriginalBranchWidget }
|
|
66694
|
+
{ type: "worktree-original-branch", create: () => new GitWorktreeOriginalBranchWidget },
|
|
66695
|
+
{ type: "compaction-counter", create: () => new CompactionCounterWidget }
|
|
65829
66696
|
];
|
|
65830
66697
|
LAYOUT_WIDGET_MANIFEST = [
|
|
65831
66698
|
{
|
|
@@ -70498,7 +71365,7 @@ var PowerlineSeparatorEditor = ({
|
|
|
70498
71365
|
newInvertBgs[selectedIndex] = isLeftFacing;
|
|
70499
71366
|
}
|
|
70500
71367
|
updateSeparators(newSeparators, mode === "separator" ? newInvertBgs : undefined);
|
|
70501
|
-
} else if (
|
|
71368
|
+
} else if (input === "a" || input === "A") {
|
|
70502
71369
|
const newSeparators = [...separators];
|
|
70503
71370
|
const newInvertBgs = mode === "separator" ? [...invertBgs] : [];
|
|
70504
71371
|
const defaultChar = presetSeparators[0]?.char ?? "";
|
|
@@ -70518,7 +71385,7 @@ var PowerlineSeparatorEditor = ({
|
|
|
70518
71385
|
updateSeparators(newSeparators, newInvertBgs);
|
|
70519
71386
|
setSelectedIndex(selectedIndex + 1);
|
|
70520
71387
|
}
|
|
70521
|
-
} else if (
|
|
71388
|
+
} else if (input === "i" || input === "I") {
|
|
70522
71389
|
const newSeparators = [...separators];
|
|
70523
71390
|
const newInvertBgs = mode === "separator" ? [...invertBgs] : [];
|
|
70524
71391
|
const defaultChar = presetSeparators[0]?.char ?? "";
|
|
@@ -70570,7 +71437,6 @@ var PowerlineSeparatorEditor = ({
|
|
|
70570
71437
|
return "Powerline 结束端帽配置";
|
|
70571
71438
|
}
|
|
70572
71439
|
};
|
|
70573
|
-
const canAdd = mode === "separator" || separators.length < 3;
|
|
70574
71440
|
const canDelete = mode !== "separator" || separators.length > 1;
|
|
70575
71441
|
return /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Box_default, {
|
|
70576
71442
|
flexDirection: "column",
|
|
@@ -70622,7 +71488,7 @@ var PowerlineSeparatorEditor = ({
|
|
|
70622
71488
|
/* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Box_default, {
|
|
70623
71489
|
children: /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Text, {
|
|
70624
71490
|
dimColor: true,
|
|
70625
|
-
children: `↑↓ 选择,← →
|
|
71491
|
+
children: `↑↓ 选择,← → 切换,(a)添加,(i)插入${canDelete ? ",(d)删除" : ""},(c)清除,(h)十六进制${mode === "separator" ? ",(t)反转切换" : ""},ESC 返回`
|
|
70626
71492
|
}, undefined, false, undefined, this)
|
|
70627
71493
|
}, undefined, false, undefined, this),
|
|
70628
71494
|
/* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Box_default, {
|
|
@@ -70878,9 +71744,9 @@ function getSeparatorDisplay(powerlineConfig) {
|
|
|
70878
71744
|
];
|
|
70879
71745
|
const preset = presets.find((item) => item.char === sep2);
|
|
70880
71746
|
if (preset) {
|
|
70881
|
-
return preset.name
|
|
71747
|
+
return `${preset.char} - ${preset.name}`;
|
|
70882
71748
|
}
|
|
70883
|
-
return
|
|
71749
|
+
return `${sep2} - 自定义`;
|
|
70884
71750
|
}
|
|
70885
71751
|
function getCapDisplay(powerlineConfig, type) {
|
|
70886
71752
|
const caps = type === "start" ? powerlineConfig.startCaps : powerlineConfig.endCaps;
|
|
@@ -70907,9 +71773,9 @@ function getCapDisplay(powerlineConfig, type) {
|
|
|
70907
71773
|
];
|
|
70908
71774
|
const preset = presets.find((item) => item.char === cap);
|
|
70909
71775
|
if (preset) {
|
|
70910
|
-
return preset.name
|
|
71776
|
+
return `${preset.char} - ${preset.name}`;
|
|
70911
71777
|
}
|
|
70912
|
-
return
|
|
71778
|
+
return `${cap} - 自定义`;
|
|
70913
71779
|
}
|
|
70914
71780
|
function getThemeDisplay(powerlineConfig) {
|
|
70915
71781
|
const theme = powerlineConfig.theme;
|
|
@@ -71396,21 +72262,21 @@ function getRefreshInputValue(interval) {
|
|
|
71396
72262
|
}
|
|
71397
72263
|
function getRefreshIntervalSublabel(interval, supported) {
|
|
71398
72264
|
if (!supported) {
|
|
71399
|
-
return "
|
|
72265
|
+
return "(需要 Claude Code ≥ 2.1.97)";
|
|
71400
72266
|
}
|
|
71401
72267
|
if (interval === null) {
|
|
71402
|
-
return "
|
|
72268
|
+
return "(未设置)";
|
|
71403
72269
|
}
|
|
71404
|
-
return
|
|
72270
|
+
return `(${interval} 秒)`;
|
|
71405
72271
|
}
|
|
71406
72272
|
function buildConfigureStatusLineItems(refreshInterval, supportsRefreshInterval) {
|
|
71407
72273
|
return [
|
|
71408
72274
|
{
|
|
71409
|
-
label: "\uD83D\uDD04
|
|
72275
|
+
label: "\uD83D\uDD04 刷新间隔",
|
|
71410
72276
|
sublabel: getRefreshIntervalSublabel(refreshInterval, supportsRefreshInterval),
|
|
71411
72277
|
value: "refreshInterval",
|
|
71412
72278
|
disabled: !supportsRefreshInterval,
|
|
71413
|
-
description: supportsRefreshInterval ? "
|
|
72279
|
+
description: supportsRefreshInterval ? "Claude Code 重新运行状态栏命令的频率。输入秒数 (1-60),留空即移除。" : "本设置需要 Claude Code 2.1.97 或更高版本。请升级 Claude Code 后再使用。"
|
|
71414
72280
|
}
|
|
71415
72281
|
];
|
|
71416
72282
|
}
|
|
@@ -71420,13 +72286,13 @@ function validateRefreshIntervalInput(value) {
|
|
|
71420
72286
|
}
|
|
71421
72287
|
const parsed = parseInt(value, 10);
|
|
71422
72288
|
if (isNaN(parsed)) {
|
|
71423
|
-
return "
|
|
72289
|
+
return "请输入有效数字";
|
|
71424
72290
|
}
|
|
71425
72291
|
if (parsed < 1) {
|
|
71426
|
-
return
|
|
72292
|
+
return `最小间隔为 1 秒(输入了 ${parsed} 秒)`;
|
|
71427
72293
|
}
|
|
71428
72294
|
if (parsed > 60) {
|
|
71429
|
-
return
|
|
72295
|
+
return `最大间隔为 60 秒(输入了 ${parsed} 秒)`;
|
|
71430
72296
|
}
|
|
71431
72297
|
return null;
|
|
71432
72298
|
}
|
|
@@ -71482,11 +72348,11 @@ var RefreshIntervalMenu = ({
|
|
|
71482
72348
|
children: [
|
|
71483
72349
|
/* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Text, {
|
|
71484
72350
|
bold: true,
|
|
71485
|
-
children: "
|
|
72351
|
+
children: "配置状态行"
|
|
71486
72352
|
}, undefined, false, undefined, this),
|
|
71487
72353
|
/* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Text, {
|
|
71488
72354
|
color: "white",
|
|
71489
|
-
children: "
|
|
72355
|
+
children: "配置 Claude Code 状态行设置"
|
|
71490
72356
|
}, undefined, false, undefined, this),
|
|
71491
72357
|
editingRefreshInterval ? /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Box_default, {
|
|
71492
72358
|
marginTop: 1,
|
|
@@ -71494,10 +72360,10 @@ var RefreshIntervalMenu = ({
|
|
|
71494
72360
|
children: [
|
|
71495
72361
|
/* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Text, {
|
|
71496
72362
|
children: [
|
|
71497
|
-
"
|
|
72363
|
+
"输入刷新间隔(秒,1-60):",
|
|
71498
72364
|
" ",
|
|
71499
72365
|
refreshInput,
|
|
71500
|
-
refreshInput.length > 0 ? "
|
|
72366
|
+
refreshInput.length > 0 ? " 秒" : ""
|
|
71501
72367
|
]
|
|
71502
72368
|
}, undefined, true, undefined, this),
|
|
71503
72369
|
validationError ? /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Text, {
|
|
@@ -71505,7 +72371,7 @@ var RefreshIntervalMenu = ({
|
|
|
71505
72371
|
children: validationError
|
|
71506
72372
|
}, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Text, {
|
|
71507
72373
|
dimColor: true,
|
|
71508
|
-
children: "
|
|
72374
|
+
children: "按 Enter 确认,ESC 取消。留空即移除。"
|
|
71509
72375
|
}, undefined, false, undefined, this)
|
|
71510
72376
|
]
|
|
71511
72377
|
}, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(List, {
|
|
@@ -72476,6 +73342,7 @@ var StatusJSONSchema = exports_external.looseObject({
|
|
|
72476
73342
|
}).optional(),
|
|
72477
73343
|
version: exports_external.string().optional(),
|
|
72478
73344
|
output_style: exports_external.object({ name: exports_external.string().optional() }).optional(),
|
|
73345
|
+
effort: exports_external.object({ level: exports_external.string().nullable().optional() }).nullable().optional(),
|
|
72479
73346
|
cost: exports_external.object({
|
|
72480
73347
|
total_cost_usd: CoercedNumberSchema.optional(),
|
|
72481
73348
|
total_duration_ms: CoercedNumberSchema.optional(),
|
|
@@ -72516,6 +73383,115 @@ var StatusJSONSchema = exports_external.looseObject({
|
|
|
72516
73383
|
// src/ccstatusline.ts
|
|
72517
73384
|
init_ansi();
|
|
72518
73385
|
init_colors();
|
|
73386
|
+
|
|
73387
|
+
// src/utils/compaction.ts
|
|
73388
|
+
init_zod();
|
|
73389
|
+
import * as crypto from "crypto";
|
|
73390
|
+
import * as fs13 from "fs";
|
|
73391
|
+
import * as os13 from "os";
|
|
73392
|
+
import * as path10 from "path";
|
|
73393
|
+
var DEFAULT_DROP_THRESHOLD = 2;
|
|
73394
|
+
var FRESH_PREV_CTX_PCT = -1;
|
|
73395
|
+
var MAX_CACHE_FILE_BYTES = 4096;
|
|
73396
|
+
var SESSION_ID_HASH_HEX_LEN = 32;
|
|
73397
|
+
var FRESH = { count: 0, prevCtxPct: FRESH_PREV_CTX_PCT };
|
|
73398
|
+
var CompactionStateSchema = exports_external.object({
|
|
73399
|
+
count: exports_external.number().int().nonnegative().default(0),
|
|
73400
|
+
prevCtxPct: exports_external.number().default(FRESH_PREV_CTX_PCT),
|
|
73401
|
+
prevWindowSize: exports_external.number().positive().nullable().optional()
|
|
73402
|
+
});
|
|
73403
|
+
function normalizeWindowSize(value) {
|
|
73404
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
73405
|
+
return null;
|
|
73406
|
+
}
|
|
73407
|
+
return value;
|
|
73408
|
+
}
|
|
73409
|
+
function normalizeOptions(options) {
|
|
73410
|
+
if (typeof options === "number") {
|
|
73411
|
+
return { dropThreshold: options, windowSize: null };
|
|
73412
|
+
}
|
|
73413
|
+
const dropThreshold = typeof options.dropThreshold === "number" && Number.isFinite(options.dropThreshold) ? options.dropThreshold : DEFAULT_DROP_THRESHOLD;
|
|
73414
|
+
return { dropThreshold, windowSize: options.windowSize ?? null };
|
|
73415
|
+
}
|
|
73416
|
+
function detectCompaction(currentCtxPct, state, options = DEFAULT_DROP_THRESHOLD) {
|
|
73417
|
+
if (!Number.isFinite(currentCtxPct) || currentCtxPct < 0) {
|
|
73418
|
+
return state;
|
|
73419
|
+
}
|
|
73420
|
+
const { dropThreshold, windowSize } = normalizeOptions(options);
|
|
73421
|
+
const currentWindowSize = normalizeWindowSize(windowSize);
|
|
73422
|
+
const prevWindowSize = normalizeWindowSize(state.prevWindowSize);
|
|
73423
|
+
let { count } = state;
|
|
73424
|
+
const { prevCtxPct } = state;
|
|
73425
|
+
const hasKnownWindowChange = currentWindowSize !== null && prevWindowSize !== null && currentWindowSize !== prevWindowSize;
|
|
73426
|
+
const isLearningWindowSize = currentWindowSize !== null && prevWindowSize === null && prevCtxPct >= 0;
|
|
73427
|
+
if (!hasKnownWindowChange && !isLearningWindowSize && prevCtxPct >= 0 && currentCtxPct < prevCtxPct - dropThreshold) {
|
|
73428
|
+
count += 1;
|
|
73429
|
+
}
|
|
73430
|
+
return {
|
|
73431
|
+
count,
|
|
73432
|
+
prevCtxPct: currentCtxPct,
|
|
73433
|
+
...currentWindowSize !== null ? { prevWindowSize: currentWindowSize } : {}
|
|
73434
|
+
};
|
|
73435
|
+
}
|
|
73436
|
+
function getCacheDir2() {
|
|
73437
|
+
return path10.join(os13.homedir(), ".cache", "ccstatusline", "compaction");
|
|
73438
|
+
}
|
|
73439
|
+
function sanitizeSessionId(sessionId) {
|
|
73440
|
+
const sanitized = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
73441
|
+
if (!sanitized || sanitized !== sessionId) {
|
|
73442
|
+
return crypto.createHash("sha256").update(sessionId).digest("hex").slice(0, SESSION_ID_HASH_HEX_LEN);
|
|
73443
|
+
}
|
|
73444
|
+
return sanitized;
|
|
73445
|
+
}
|
|
73446
|
+
function getStatePath(sessionId) {
|
|
73447
|
+
return path10.join(getCacheDir2(), `compaction-${sanitizeSessionId(sessionId)}.json`);
|
|
73448
|
+
}
|
|
73449
|
+
function loadCompactionState(sessionId) {
|
|
73450
|
+
const statePath = getStatePath(sessionId);
|
|
73451
|
+
let fd = null;
|
|
73452
|
+
try {
|
|
73453
|
+
fd = fs13.openSync(statePath, fs13.constants.O_RDONLY | fs13.constants.O_NOFOLLOW);
|
|
73454
|
+
const stats = fs13.fstatSync(fd);
|
|
73455
|
+
if (!stats.isFile() || stats.size > MAX_CACHE_FILE_BYTES) {
|
|
73456
|
+
return FRESH;
|
|
73457
|
+
}
|
|
73458
|
+
const raw = JSON.parse(fs13.readFileSync(fd, "utf-8"));
|
|
73459
|
+
const result2 = CompactionStateSchema.safeParse(raw);
|
|
73460
|
+
return result2.success ? result2.data : FRESH;
|
|
73461
|
+
} catch {
|
|
73462
|
+
return FRESH;
|
|
73463
|
+
} finally {
|
|
73464
|
+
if (fd !== null) {
|
|
73465
|
+
try {
|
|
73466
|
+
fs13.closeSync(fd);
|
|
73467
|
+
} catch {}
|
|
73468
|
+
}
|
|
73469
|
+
}
|
|
73470
|
+
}
|
|
73471
|
+
function saveCompactionState(sessionId, state) {
|
|
73472
|
+
let tmpPath = null;
|
|
73473
|
+
try {
|
|
73474
|
+
const dir = getCacheDir2();
|
|
73475
|
+
if (!fs13.existsSync(dir)) {
|
|
73476
|
+
fs13.mkdirSync(dir, { recursive: true });
|
|
73477
|
+
}
|
|
73478
|
+
const targetPath = getStatePath(sessionId);
|
|
73479
|
+
tmpPath = `${targetPath}.tmp.${process.pid}.${crypto.randomBytes(4).toString("hex")}`;
|
|
73480
|
+
fs13.writeFileSync(tmpPath, JSON.stringify(state) + `
|
|
73481
|
+
`);
|
|
73482
|
+
fs13.renameSync(tmpPath, targetPath);
|
|
73483
|
+
tmpPath = null;
|
|
73484
|
+
} catch {
|
|
73485
|
+
if (tmpPath !== null) {
|
|
73486
|
+
try {
|
|
73487
|
+
fs13.unlinkSync(tmpPath);
|
|
73488
|
+
} catch {}
|
|
73489
|
+
}
|
|
73490
|
+
}
|
|
73491
|
+
}
|
|
73492
|
+
|
|
73493
|
+
// src/ccstatusline.ts
|
|
73494
|
+
init_context_percentage();
|
|
72519
73495
|
await __promiseAll([
|
|
72520
73496
|
init_config(),
|
|
72521
73497
|
init_jsonl()
|
|
@@ -72523,23 +73499,23 @@ await __promiseAll([
|
|
|
72523
73499
|
await init_renderer2();
|
|
72524
73500
|
|
|
72525
73501
|
// src/utils/skills.ts
|
|
72526
|
-
import * as
|
|
72527
|
-
import * as
|
|
72528
|
-
import * as
|
|
73502
|
+
import * as fs14 from "fs";
|
|
73503
|
+
import * as os14 from "os";
|
|
73504
|
+
import * as path11 from "path";
|
|
72529
73505
|
var EMPTY = { totalInvocations: 0, uniqueSkills: [], lastSkill: null };
|
|
72530
73506
|
function getSkillsDir() {
|
|
72531
|
-
return
|
|
73507
|
+
return path11.join(os14.homedir(), ".cache", "ccstatusline", "skills");
|
|
72532
73508
|
}
|
|
72533
73509
|
function getSkillsFilePath(sessionId) {
|
|
72534
|
-
return
|
|
73510
|
+
return path11.join(getSkillsDir(), `skills-${sessionId}.jsonl`);
|
|
72535
73511
|
}
|
|
72536
73512
|
function getSkillsMetrics(sessionId) {
|
|
72537
73513
|
const filePath = getSkillsFilePath(sessionId);
|
|
72538
|
-
if (!
|
|
73514
|
+
if (!fs14.existsSync(filePath)) {
|
|
72539
73515
|
return EMPTY;
|
|
72540
73516
|
}
|
|
72541
73517
|
try {
|
|
72542
|
-
const invocations =
|
|
73518
|
+
const invocations = fs14.readFileSync(filePath, "utf-8").trim().split(`
|
|
72543
73519
|
`).filter((line) => line.trim()).map((line) => {
|
|
72544
73520
|
try {
|
|
72545
73521
|
return JSON.parse(line);
|
|
@@ -72645,8 +73621,8 @@ async function ensureWindowsUtf8CodePage() {
|
|
|
72645
73621
|
return;
|
|
72646
73622
|
}
|
|
72647
73623
|
try {
|
|
72648
|
-
const { execFileSync:
|
|
72649
|
-
|
|
73624
|
+
const { execFileSync: execFileSync5 } = await import("child_process");
|
|
73625
|
+
execFileSync5("chcp.com", ["65001"], { stdio: "ignore" });
|
|
72650
73626
|
} catch {}
|
|
72651
73627
|
}
|
|
72652
73628
|
async function renderMultipleLines(data) {
|
|
@@ -72688,6 +73664,20 @@ async function renderMultipleLines(data) {
|
|
|
72688
73664
|
if (data.session_id) {
|
|
72689
73665
|
skillsMetrics = getSkillsMetrics(data.session_id);
|
|
72690
73666
|
}
|
|
73667
|
+
let compactionCount = 0;
|
|
73668
|
+
const hasCompactionWidget = lines.some((line) => line.some((item) => item.type === "compaction-counter"));
|
|
73669
|
+
if (hasCompactionWidget && data.session_id) {
|
|
73670
|
+
const prevState = loadCompactionState(data.session_id);
|
|
73671
|
+
compactionCount = prevState.count;
|
|
73672
|
+
const contextPercentageMetrics = calculateContextPercentageMetrics({ data, tokenMetrics });
|
|
73673
|
+
if (contextPercentageMetrics !== null) {
|
|
73674
|
+
const newState = detectCompaction(contextPercentageMetrics.usedPercentage, prevState, { windowSize: contextPercentageMetrics.windowSize });
|
|
73675
|
+
if (newState.count !== prevState.count || newState.prevCtxPct !== prevState.prevCtxPct || newState.prevWindowSize !== prevState.prevWindowSize) {
|
|
73676
|
+
saveCompactionState(data.session_id, newState);
|
|
73677
|
+
}
|
|
73678
|
+
compactionCount = newState.count;
|
|
73679
|
+
}
|
|
73680
|
+
}
|
|
72691
73681
|
const context = {
|
|
72692
73682
|
data,
|
|
72693
73683
|
tokenMetrics,
|
|
@@ -72696,6 +73686,7 @@ async function renderMultipleLines(data) {
|
|
|
72696
73686
|
usageData,
|
|
72697
73687
|
sessionDuration,
|
|
72698
73688
|
skillsMetrics,
|
|
73689
|
+
compactionData: hasCompactionWidget ? { count: compactionCount } : null,
|
|
72699
73690
|
isPreview: false,
|
|
72700
73691
|
minimalist: settings.minimalistMode
|
|
72701
73692
|
};
|
|
@@ -72782,16 +73773,16 @@ async function handleHook() {
|
|
|
72782
73773
|
return;
|
|
72783
73774
|
}
|
|
72784
73775
|
const filePath = getSkillsFilePath(sessionId);
|
|
72785
|
-
const
|
|
72786
|
-
const
|
|
72787
|
-
|
|
73776
|
+
const fs15 = await import("fs");
|
|
73777
|
+
const path12 = await import("path");
|
|
73778
|
+
fs15.mkdirSync(path12.dirname(filePath), { recursive: true });
|
|
72788
73779
|
const entry = JSON.stringify({
|
|
72789
73780
|
timestamp: new Date().toISOString(),
|
|
72790
73781
|
session_id: sessionId,
|
|
72791
73782
|
skill: skillName,
|
|
72792
73783
|
source: data.hook_event_name
|
|
72793
73784
|
});
|
|
72794
|
-
|
|
73785
|
+
fs15.appendFileSync(filePath, entry + `
|
|
72795
73786
|
`);
|
|
72796
73787
|
} catch {}
|
|
72797
73788
|
console.log("{}");
|