ccstatusline-zh 2.2.31 → 2.2.33
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 +15 -7
- package/dist/{ccstatusline-dry98q5v.js → ccstatusline-3tcnryv5.js} +9441 -9148
- package/dist/{ccstatusline-s1q4ap7d.js → ccstatusline-rdsx5ab1.js} +16 -12
- package/dist/ccstatusline.js +43 -26
- package/dist/{hooks-b93hd1qn.js → hooks-q322knq1.js} +2 -2
- package/dist/{index-yeg5hhcp.js → index-d0c2je2n.js} +760 -912
- package/package.json +3 -3
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
// src/utils/powerline-theme-index.ts
|
|
2
|
-
function
|
|
2
|
+
function assignPowerlineThemeSlots(widgets, startSlot = 0, isShown = () => true) {
|
|
3
3
|
let previousVisibleWidget = null;
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
if (
|
|
4
|
+
let nextSlot = startSlot;
|
|
5
|
+
const slots = widgets.map((widget, index) => {
|
|
6
|
+
if (widget.type === "separator" || widget.type === "flex-separator") {
|
|
7
7
|
previousVisibleWidget = null;
|
|
8
|
-
|
|
8
|
+
return null;
|
|
9
9
|
}
|
|
10
|
-
if (!
|
|
11
|
-
|
|
10
|
+
if (!isShown(index)) {
|
|
11
|
+
return null;
|
|
12
12
|
}
|
|
13
13
|
if (!previousVisibleWidget?.merge) {
|
|
14
|
-
|
|
14
|
+
nextSlot++;
|
|
15
15
|
}
|
|
16
|
-
previousVisibleWidget =
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
previousVisibleWidget = widget;
|
|
17
|
+
return nextSlot - 1;
|
|
18
|
+
});
|
|
19
|
+
return { slots, nextSlot };
|
|
20
|
+
}
|
|
21
|
+
function countPowerlineThemeSlots(entries) {
|
|
22
|
+
return assignPowerlineThemeSlots(entries.map((entry) => entry.widget), 0, (index) => Boolean(entries[index]?.content)).nextSlot;
|
|
19
23
|
}
|
|
20
24
|
function advanceGlobalPowerlineThemeIndex(currentIndex, entries) {
|
|
21
25
|
return currentIndex + countPowerlineThemeSlots(entries);
|
|
@@ -60,4 +64,4 @@ function advanceGlobalSeparatorIndex(currentIndex, widgets, preRenderedWidgets)
|
|
|
60
64
|
return currentIndex + countSeparatorSlots(widgets, preRenderedWidgets);
|
|
61
65
|
}
|
|
62
66
|
|
|
63
|
-
export { advanceGlobalPowerlineThemeIndex, advanceGlobalSeparatorIndex };
|
|
67
|
+
export { assignPowerlineThemeSlots, advanceGlobalPowerlineThemeIndex, advanceGlobalSeparatorIndex };
|
package/dist/ccstatusline.js
CHANGED
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
ZERO_COMPACTION_STATS,
|
|
14
14
|
getPackageVersion,
|
|
15
15
|
getTerminalWidth,
|
|
16
|
+
resolveExecutable,
|
|
17
|
+
sanitizeTerminalText,
|
|
16
18
|
GIT_REVIEW_REFRESH_FLAG,
|
|
17
19
|
refreshGitReviewCacheFromCli,
|
|
18
20
|
buildConfigWarningBadge,
|
|
@@ -30,11 +32,11 @@ import {
|
|
|
30
32
|
initConfigPath,
|
|
31
33
|
loadSettings,
|
|
32
34
|
saveSettings
|
|
33
|
-
} from "./ccstatusline-
|
|
35
|
+
} from "./ccstatusline-3tcnryv5.js";
|
|
34
36
|
import {
|
|
35
37
|
advanceGlobalPowerlineThemeIndex,
|
|
36
38
|
advanceGlobalSeparatorIndex
|
|
37
|
-
} from "./ccstatusline-
|
|
39
|
+
} from "./ccstatusline-rdsx5ab1.js";
|
|
38
40
|
|
|
39
41
|
// src/types/StatusJSON.ts
|
|
40
42
|
var CoercedNumberSchema = preprocess((value) => {
|
|
@@ -67,9 +69,9 @@ var StatusJSONSchema = looseObject({
|
|
|
67
69
|
workspace: object({
|
|
68
70
|
current_dir: string().optional(),
|
|
69
71
|
project_dir: string().optional()
|
|
70
|
-
}).optional(),
|
|
71
|
-
version: string().optional(),
|
|
72
|
-
output_style: object({ name: string().optional() }).optional(),
|
|
72
|
+
}).nullable().optional(),
|
|
73
|
+
version: string().nullable().optional(),
|
|
74
|
+
output_style: object({ name: string().optional() }).nullable().optional(),
|
|
73
75
|
effort: object({ level: string().nullable().optional() }).nullable().optional(),
|
|
74
76
|
cost: object({
|
|
75
77
|
total_cost_usd: CoercedNumberSchema.optional(),
|
|
@@ -77,7 +79,7 @@ var StatusJSONSchema = looseObject({
|
|
|
77
79
|
total_api_duration_ms: CoercedNumberSchema.optional(),
|
|
78
80
|
total_lines_added: CoercedNumberSchema.optional(),
|
|
79
81
|
total_lines_removed: CoercedNumberSchema.optional()
|
|
80
|
-
}).optional(),
|
|
82
|
+
}).nullable().optional(),
|
|
81
83
|
context_window: object({
|
|
82
84
|
context_window_size: CoercedNumberSchema.nullable().optional(),
|
|
83
85
|
total_input_tokens: CoercedNumberSchema.nullable().optional(),
|
|
@@ -111,23 +113,27 @@ var StatusJSONSchema = looseObject({
|
|
|
111
113
|
});
|
|
112
114
|
|
|
113
115
|
// src/utils/hook-handler.ts
|
|
114
|
-
import * as fs2 from "fs";
|
|
115
|
-
import * as path2 from "path";
|
|
116
|
+
import * as fs2 from "node:fs";
|
|
117
|
+
import * as path2 from "node:path";
|
|
116
118
|
|
|
117
119
|
// src/utils/skills.ts
|
|
118
|
-
import * as fs from "fs";
|
|
119
|
-
import * as os from "os";
|
|
120
|
-
import * as path from "path";
|
|
120
|
+
import * as fs from "node:fs";
|
|
121
|
+
import * as os from "node:os";
|
|
122
|
+
import * as path from "node:path";
|
|
121
123
|
var EMPTY = { totalInvocations: 0, uniqueSkills: [], lastSkill: null };
|
|
122
124
|
function getSkillsDir() {
|
|
123
125
|
return path.join(os.homedir(), ".cache", "ccstatusline", "skills");
|
|
124
126
|
}
|
|
127
|
+
var SAFE_SESSION_ID = /^[A-Za-z0-9_-]+$/;
|
|
125
128
|
function getSkillsFilePath(sessionId) {
|
|
129
|
+
if (!SAFE_SESSION_ID.test(sessionId)) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
126
132
|
return path.join(getSkillsDir(), `skills-${sessionId}.jsonl`);
|
|
127
133
|
}
|
|
128
134
|
function getSkillsMetrics(sessionId) {
|
|
129
135
|
const filePath = getSkillsFilePath(sessionId);
|
|
130
|
-
if (!fs.existsSync(filePath)) {
|
|
136
|
+
if (!filePath || !fs.existsSync(filePath)) {
|
|
131
137
|
return EMPTY;
|
|
132
138
|
}
|
|
133
139
|
try {
|
|
@@ -185,6 +191,9 @@ function handleHookInput(input) {
|
|
|
185
191
|
return;
|
|
186
192
|
}
|
|
187
193
|
const filePath = getSkillsFilePath(sessionId);
|
|
194
|
+
if (!filePath) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
188
197
|
fs2.mkdirSync(path2.dirname(filePath), { recursive: true });
|
|
189
198
|
const entry = JSON.stringify({
|
|
190
199
|
timestamp: new Date().toISOString(),
|
|
@@ -206,7 +215,8 @@ var BASE_USAGE_WIDGET_TYPES = [
|
|
|
206
215
|
"weekly-reset-timer",
|
|
207
216
|
"extra-usage-utilization",
|
|
208
217
|
"extra-usage-remaining",
|
|
209
|
-
"extra-usage-used"
|
|
218
|
+
"extra-usage-used",
|
|
219
|
+
"extra-usage-daily-budget"
|
|
210
220
|
];
|
|
211
221
|
var USAGE_WIDGET_TYPES = new Set([
|
|
212
222
|
...BASE_USAGE_WIDGET_TYPES,
|
|
@@ -244,6 +254,11 @@ var USAGE_WIDGET_REQUIREMENTS = {
|
|
|
244
254
|
"extra-usage-used": [
|
|
245
255
|
{ field: "extraUsageEnabled" },
|
|
246
256
|
{ field: "extraUsageUsed" }
|
|
257
|
+
],
|
|
258
|
+
"extra-usage-daily-budget": [
|
|
259
|
+
{ field: "extraUsageEnabled" },
|
|
260
|
+
{ field: "extraUsageLimit" },
|
|
261
|
+
{ field: "extraUsageUsed" }
|
|
247
262
|
]
|
|
248
263
|
};
|
|
249
264
|
var USAGE_CURSOR_REQUIREMENTS = {
|
|
@@ -363,6 +378,17 @@ async function prefetchUsageDataIfNeeded(lines, data) {
|
|
|
363
378
|
return mergeUsageData(rateLimitsData, apiData);
|
|
364
379
|
}
|
|
365
380
|
|
|
381
|
+
// src/utils/windows-code-page.ts
|
|
382
|
+
import { execFileSync } from "node:child_process";
|
|
383
|
+
function ensureWindowsUtf8CodePage(platform = process.platform) {
|
|
384
|
+
if (platform !== "win32") {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
try {
|
|
388
|
+
execFileSync(resolveExecutable("chcp.com"), ["65001"], { stdio: "ignore", windowsHide: true });
|
|
389
|
+
} catch {}
|
|
390
|
+
}
|
|
391
|
+
|
|
366
392
|
// src/ccstatusline.ts
|
|
367
393
|
function hasSessionDurationInStatusJson(data) {
|
|
368
394
|
const durationMs = data.cost?.total_duration_ms;
|
|
@@ -390,15 +416,6 @@ async function readStdin() {
|
|
|
390
416
|
return null;
|
|
391
417
|
}
|
|
392
418
|
}
|
|
393
|
-
async function ensureWindowsUtf8CodePage() {
|
|
394
|
-
if (process.platform !== "win32") {
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
try {
|
|
398
|
-
const { execFileSync } = await import("child_process");
|
|
399
|
-
execFileSync("chcp.com", ["65001"], { stdio: "ignore", windowsHide: true });
|
|
400
|
-
} catch {}
|
|
401
|
-
}
|
|
402
419
|
async function renderMultipleLines(data) {
|
|
403
420
|
const settings = await loadSettings();
|
|
404
421
|
const configError = getConfigLoadError();
|
|
@@ -489,7 +506,7 @@ async function renderMultipleLines(data) {
|
|
|
489
506
|
line = `${buildConfigWarningBadge(settings.colorLevel)} | ${line}`;
|
|
490
507
|
configBadgePrepended = true;
|
|
491
508
|
}
|
|
492
|
-
let outputLine = line.replace(/ /g, " ");
|
|
509
|
+
let outputLine = sanitizeTerminalText(line).replace(/ /g, " ");
|
|
493
510
|
outputLine = "\x1B[0m" + outputLine;
|
|
494
511
|
console.log(outputLine);
|
|
495
512
|
globalSeparatorIndex = advanceGlobalSeparatorIndex(globalSeparatorIndex, lineItems, preRenderedWidgets);
|
|
@@ -506,7 +523,7 @@ async function renderMultipleLines(data) {
|
|
|
506
523
|
console.log("\x1B[0m" + buildConfigWarningBadge(settings.colorLevel).replace(/ /g, " "));
|
|
507
524
|
}
|
|
508
525
|
if (settings.updatemessage?.message && settings.updatemessage.message.trim() !== "" && settings.updatemessage.remaining && settings.updatemessage.remaining > 0) {
|
|
509
|
-
console.log(settings.updatemessage.message);
|
|
526
|
+
console.log(sanitizeTerminalText(settings.updatemessage.message));
|
|
510
527
|
const newRemaining = settings.updatemessage.remaining - 1;
|
|
511
528
|
if (newRemaining <= 0) {
|
|
512
529
|
const { updatemessage, ...newSettings } = settings;
|
|
@@ -566,7 +583,7 @@ async function main() {
|
|
|
566
583
|
return;
|
|
567
584
|
}
|
|
568
585
|
if (!process.stdin.isTTY) {
|
|
569
|
-
|
|
586
|
+
ensureWindowsUtf8CodePage();
|
|
570
587
|
const input = await readStdin();
|
|
571
588
|
if (input && input.trim() !== "") {
|
|
572
589
|
try {
|
|
@@ -590,7 +607,7 @@ async function main() {
|
|
|
590
607
|
const { updatemessage, ...newSettings } = settings;
|
|
591
608
|
await saveSettings(newSettings);
|
|
592
609
|
}
|
|
593
|
-
const { runTUI } = await import("./index-
|
|
610
|
+
const { runTUI } = await import("./index-d0c2je2n.js");
|
|
594
611
|
runTUI();
|
|
595
612
|
}
|
|
596
613
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
saveClaudeSettings,
|
|
4
4
|
getExistingStatusLine,
|
|
5
5
|
getWidget
|
|
6
|
-
} from "./ccstatusline-
|
|
6
|
+
} from "./ccstatusline-3tcnryv5.js";
|
|
7
7
|
|
|
8
8
|
// src/utils/hooks.ts
|
|
9
9
|
var HOOK_TAG = "ccstatusline-managed";
|
|
@@ -70,7 +70,7 @@ async function syncWidgetHooks(settings) {
|
|
|
70
70
|
const hooks = claudeSettings.hooks ?? {};
|
|
71
71
|
stripManagedHooks(hooks);
|
|
72
72
|
const statusCommand = await getExistingStatusLine();
|
|
73
|
-
if (!statusCommand) {
|
|
73
|
+
if (!statusCommand?.includes("ccstatusline")) {
|
|
74
74
|
claudeSettings.hooks = Object.keys(hooks).length > 0 ? hooks : undefined;
|
|
75
75
|
await saveClaudeSettings(claudeSettings);
|
|
76
76
|
return;
|