ccstatusline-zh 2.2.18 → 2.2.19
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 +3 -2
- package/dist/ccstatusline.js +670 -382
- package/package.json +1 -1
package/dist/ccstatusline.js
CHANGED
|
@@ -53061,6 +53061,7 @@ var init_Settings = __esm(() => {
|
|
|
53061
53061
|
overrideBackgroundColor: exports_external.string().optional(),
|
|
53062
53062
|
overrideForegroundColor: exports_external.string().optional(),
|
|
53063
53063
|
globalBold: exports_external.boolean().default(false),
|
|
53064
|
+
gitCacheTtlSeconds: exports_external.number().min(0).max(60).default(5),
|
|
53064
53065
|
minimalistMode: exports_external.boolean().default(false),
|
|
53065
53066
|
powerline: PowerlineConfigSchema.default({
|
|
53066
53067
|
enabled: false,
|
|
@@ -53518,6 +53519,175 @@ class OutputStyleWidget {
|
|
|
53518
53519
|
|
|
53519
53520
|
// src/utils/git.ts
|
|
53520
53521
|
import { execFileSync } from "child_process";
|
|
53522
|
+
import { createHash } from "node:crypto";
|
|
53523
|
+
import * as fs2 from "node:fs";
|
|
53524
|
+
import * as os3 from "node:os";
|
|
53525
|
+
import * as path from "node:path";
|
|
53526
|
+
function getCacheDir() {
|
|
53527
|
+
return path.join(os3.homedir(), ".cache", "ccstatusline");
|
|
53528
|
+
}
|
|
53529
|
+
function getCachePath(gitDir) {
|
|
53530
|
+
const repoHash = createHash("sha256").update(gitDir).digest("hex").slice(0, 16);
|
|
53531
|
+
return path.join(getCacheDir(), "git-cache", `git-${repoHash}.json`);
|
|
53532
|
+
}
|
|
53533
|
+
function getMtimeMs(filePath) {
|
|
53534
|
+
try {
|
|
53535
|
+
return fs2.statSync(filePath).mtimeMs;
|
|
53536
|
+
} catch {
|
|
53537
|
+
return null;
|
|
53538
|
+
}
|
|
53539
|
+
}
|
|
53540
|
+
function normalizeDirectory(candidate) {
|
|
53541
|
+
try {
|
|
53542
|
+
const resolved = path.resolve(candidate);
|
|
53543
|
+
const stats = fs2.statSync(resolved);
|
|
53544
|
+
return stats.isDirectory() ? resolved : path.dirname(resolved);
|
|
53545
|
+
} catch {
|
|
53546
|
+
return null;
|
|
53547
|
+
}
|
|
53548
|
+
}
|
|
53549
|
+
function readGitDirFile(gitFilePath) {
|
|
53550
|
+
try {
|
|
53551
|
+
const content = fs2.readFileSync(gitFilePath, "utf-8").trim();
|
|
53552
|
+
const match = /^gitdir:\s*(.+)$/i.exec(content);
|
|
53553
|
+
if (!match?.[1]) {
|
|
53554
|
+
return null;
|
|
53555
|
+
}
|
|
53556
|
+
return path.resolve(path.dirname(gitFilePath), match[1]);
|
|
53557
|
+
} catch {
|
|
53558
|
+
return null;
|
|
53559
|
+
}
|
|
53560
|
+
}
|
|
53561
|
+
function discoverGitDir(startDir) {
|
|
53562
|
+
let current = startDir;
|
|
53563
|
+
for (;; ) {
|
|
53564
|
+
const gitPath = path.join(current, ".git");
|
|
53565
|
+
try {
|
|
53566
|
+
const stats = fs2.statSync(gitPath);
|
|
53567
|
+
if (stats.isDirectory()) {
|
|
53568
|
+
return gitPath;
|
|
53569
|
+
}
|
|
53570
|
+
if (stats.isFile()) {
|
|
53571
|
+
return readGitDirFile(gitPath);
|
|
53572
|
+
}
|
|
53573
|
+
} catch {}
|
|
53574
|
+
const parent = path.dirname(current);
|
|
53575
|
+
if (parent === current) {
|
|
53576
|
+
return null;
|
|
53577
|
+
}
|
|
53578
|
+
current = parent;
|
|
53579
|
+
}
|
|
53580
|
+
}
|
|
53581
|
+
function getGitRepoMetadata(cwd2) {
|
|
53582
|
+
if (!cwd2) {
|
|
53583
|
+
return null;
|
|
53584
|
+
}
|
|
53585
|
+
const startDir = normalizeDirectory(cwd2);
|
|
53586
|
+
if (!startDir) {
|
|
53587
|
+
return null;
|
|
53588
|
+
}
|
|
53589
|
+
const gitDir = discoverGitDir(startDir);
|
|
53590
|
+
if (!gitDir) {
|
|
53591
|
+
return null;
|
|
53592
|
+
}
|
|
53593
|
+
return {
|
|
53594
|
+
cachePath: getCachePath(gitDir),
|
|
53595
|
+
headMtimeMs: getMtimeMs(path.join(gitDir, "HEAD")),
|
|
53596
|
+
indexMtimeMs: getMtimeMs(path.join(gitDir, "index"))
|
|
53597
|
+
};
|
|
53598
|
+
}
|
|
53599
|
+
function getGitCacheTtlMs(context) {
|
|
53600
|
+
const ttlSeconds = context.gitCacheTtlSeconds;
|
|
53601
|
+
if (typeof ttlSeconds !== "number" || !Number.isFinite(ttlSeconds)) {
|
|
53602
|
+
return DEFAULT_GIT_CACHE_TTL_SECONDS * 1000;
|
|
53603
|
+
}
|
|
53604
|
+
return Math.min(60, Math.max(0, ttlSeconds)) * 1000;
|
|
53605
|
+
}
|
|
53606
|
+
function isCacheEntry(value) {
|
|
53607
|
+
if (typeof value !== "object" || value === null) {
|
|
53608
|
+
return false;
|
|
53609
|
+
}
|
|
53610
|
+
const entry = value;
|
|
53611
|
+
return (typeof entry.output === "string" || entry.output === null) && typeof entry.createdAt === "number" && (typeof entry.headMtimeMs === "number" || entry.headMtimeMs === null) && (typeof entry.indexMtimeMs === "number" || entry.indexMtimeMs === null);
|
|
53612
|
+
}
|
|
53613
|
+
function isCacheEntryFresh(entry, metadata, ttlMs, now2) {
|
|
53614
|
+
if (metadata) {
|
|
53615
|
+
if (entry.headMtimeMs !== metadata.headMtimeMs || entry.indexMtimeMs !== metadata.indexMtimeMs) {
|
|
53616
|
+
return false;
|
|
53617
|
+
}
|
|
53618
|
+
}
|
|
53619
|
+
return ttlMs === 0 || now2 - entry.createdAt <= ttlMs;
|
|
53620
|
+
}
|
|
53621
|
+
function readPersistentCache(cachePath) {
|
|
53622
|
+
try {
|
|
53623
|
+
const parsed = JSON.parse(fs2.readFileSync(cachePath, "utf-8"));
|
|
53624
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
53625
|
+
return null;
|
|
53626
|
+
}
|
|
53627
|
+
const data = parsed;
|
|
53628
|
+
if (data.version !== GIT_CACHE_SCHEMA_VERSION || typeof data.cwd !== "string" && data.cwd !== null || typeof data.entries !== "object" || data.entries === null) {
|
|
53629
|
+
return null;
|
|
53630
|
+
}
|
|
53631
|
+
const entries = {};
|
|
53632
|
+
for (const [key, value] of Object.entries(data.entries)) {
|
|
53633
|
+
if (isCacheEntry(value)) {
|
|
53634
|
+
entries[key] = value;
|
|
53635
|
+
}
|
|
53636
|
+
}
|
|
53637
|
+
return {
|
|
53638
|
+
version: GIT_CACHE_SCHEMA_VERSION,
|
|
53639
|
+
cwd: data.cwd,
|
|
53640
|
+
entries
|
|
53641
|
+
};
|
|
53642
|
+
} catch {
|
|
53643
|
+
return null;
|
|
53644
|
+
}
|
|
53645
|
+
}
|
|
53646
|
+
function writePersistentCache(cachePath, cache3) {
|
|
53647
|
+
try {
|
|
53648
|
+
const cacheDir = path.dirname(cachePath);
|
|
53649
|
+
fs2.mkdirSync(cacheDir, { recursive: true });
|
|
53650
|
+
const tempPath = `${cachePath}.${process.pid}.${Date.now()}.tmp`;
|
|
53651
|
+
fs2.writeFileSync(tempPath, JSON.stringify(cache3), "utf-8");
|
|
53652
|
+
fs2.renameSync(tempPath, cachePath);
|
|
53653
|
+
} catch {}
|
|
53654
|
+
}
|
|
53655
|
+
function readPersistentCacheEntry(metadata, cacheKey, cwd2, ttlMs, now2) {
|
|
53656
|
+
if (!metadata) {
|
|
53657
|
+
return null;
|
|
53658
|
+
}
|
|
53659
|
+
const cache3 = readPersistentCache(metadata.cachePath);
|
|
53660
|
+
if (cache3?.cwd !== (cwd2 ?? null)) {
|
|
53661
|
+
return null;
|
|
53662
|
+
}
|
|
53663
|
+
const entry = cache3.entries[cacheKey];
|
|
53664
|
+
if (!entry || !isCacheEntryFresh(entry, metadata, ttlMs, now2)) {
|
|
53665
|
+
return null;
|
|
53666
|
+
}
|
|
53667
|
+
return entry;
|
|
53668
|
+
}
|
|
53669
|
+
function writePersistentCacheEntry(metadata, cacheKey, cwd2, entry) {
|
|
53670
|
+
if (!metadata) {
|
|
53671
|
+
return;
|
|
53672
|
+
}
|
|
53673
|
+
const cacheCwd = cwd2 ?? null;
|
|
53674
|
+
const existingCache = readPersistentCache(metadata.cachePath);
|
|
53675
|
+
const cache3 = existingCache?.cwd === cacheCwd ? existingCache : {
|
|
53676
|
+
version: GIT_CACHE_SCHEMA_VERSION,
|
|
53677
|
+
cwd: cacheCwd,
|
|
53678
|
+
entries: {}
|
|
53679
|
+
};
|
|
53680
|
+
cache3.entries[cacheKey] = entry;
|
|
53681
|
+
writePersistentCache(metadata.cachePath, cache3);
|
|
53682
|
+
}
|
|
53683
|
+
function createCacheEntry(output, metadata, now2) {
|
|
53684
|
+
return {
|
|
53685
|
+
output,
|
|
53686
|
+
createdAt: now2,
|
|
53687
|
+
headMtimeMs: metadata?.headMtimeMs ?? null,
|
|
53688
|
+
indexMtimeMs: metadata?.indexMtimeMs ?? null
|
|
53689
|
+
};
|
|
53690
|
+
}
|
|
53521
53691
|
function resolveGitCwd(context) {
|
|
53522
53692
|
const candidates = [
|
|
53523
53693
|
context.data?.cwd,
|
|
@@ -53538,22 +53708,37 @@ function runGit(command, context) {
|
|
|
53538
53708
|
function runGitArgs(args, context, cacheCommand) {
|
|
53539
53709
|
const cwd2 = resolveGitCwd(context);
|
|
53540
53710
|
const cacheToken = cacheCommand ?? args.join("\x00");
|
|
53541
|
-
const
|
|
53542
|
-
|
|
53543
|
-
|
|
53711
|
+
const memoryCacheKey = `${cacheToken}|${cwd2 ?? ""}`;
|
|
53712
|
+
const persistentCacheKey = cacheToken;
|
|
53713
|
+
const metadata = getGitRepoMetadata(cwd2);
|
|
53714
|
+
const ttlMs = getGitCacheTtlMs(context);
|
|
53715
|
+
const now2 = Date.now();
|
|
53716
|
+
const memoryEntry = gitCommandCache.get(memoryCacheKey);
|
|
53717
|
+
if (memoryEntry && isCacheEntryFresh(memoryEntry, metadata, ttlMs, now2)) {
|
|
53718
|
+
return memoryEntry.output;
|
|
53719
|
+
}
|
|
53720
|
+
const persistentEntry = readPersistentCacheEntry(metadata, persistentCacheKey, cwd2, ttlMs, now2);
|
|
53721
|
+
if (persistentEntry) {
|
|
53722
|
+
gitCommandCache.set(memoryCacheKey, persistentEntry);
|
|
53723
|
+
return persistentEntry.output;
|
|
53544
53724
|
}
|
|
53545
53725
|
try {
|
|
53546
53726
|
const output = execFileSync("git", args, {
|
|
53547
53727
|
encoding: "utf8",
|
|
53548
53728
|
stdio: ["pipe", "pipe", "ignore"],
|
|
53549
53729
|
env: { ...process.env, GIT_OPTIONAL_LOCKS: "0" },
|
|
53730
|
+
windowsHide: true,
|
|
53550
53731
|
...cwd2 ? { cwd: cwd2 } : {}
|
|
53551
53732
|
}).trimEnd();
|
|
53552
53733
|
const result2 = output.length > 0 ? output : null;
|
|
53553
|
-
|
|
53734
|
+
const entry = createCacheEntry(result2, metadata, now2);
|
|
53735
|
+
gitCommandCache.set(memoryCacheKey, entry);
|
|
53736
|
+
writePersistentCacheEntry(metadata, persistentCacheKey, cwd2, entry);
|
|
53554
53737
|
return result2;
|
|
53555
53738
|
} catch {
|
|
53556
|
-
|
|
53739
|
+
const entry = createCacheEntry(null, metadata, now2);
|
|
53740
|
+
gitCommandCache.set(memoryCacheKey, entry);
|
|
53741
|
+
writePersistentCacheEntry(metadata, persistentCacheKey, cwd2, entry);
|
|
53557
53742
|
return null;
|
|
53558
53743
|
}
|
|
53559
53744
|
}
|
|
@@ -53659,13 +53844,13 @@ function getGitConflictCount(context) {
|
|
|
53659
53844
|
`).map((line) => {
|
|
53660
53845
|
const parts = line.split(/\s+/).slice(3);
|
|
53661
53846
|
return parts.join(" ");
|
|
53662
|
-
}).filter((
|
|
53847
|
+
}).filter((path2) => path2.length > 0));
|
|
53663
53848
|
return files.size;
|
|
53664
53849
|
}
|
|
53665
53850
|
function getGitShortSha(context) {
|
|
53666
53851
|
return runGit("rev-parse --short HEAD", context);
|
|
53667
53852
|
}
|
|
53668
|
-
var gitCommandCache;
|
|
53853
|
+
var DEFAULT_GIT_CACHE_TTL_SECONDS = 5, GIT_CACHE_SCHEMA_VERSION = 1, gitCommandCache;
|
|
53669
53854
|
var init_git = __esm(() => {
|
|
53670
53855
|
gitCommandCache = new Map;
|
|
53671
53856
|
});
|
|
@@ -53783,8 +53968,8 @@ function renderOsc8Link(url2, text) {
|
|
|
53783
53968
|
function encodeGitRefForUrlPath(ref) {
|
|
53784
53969
|
return ref.split("/").map((segment) => encodeURIComponent(segment)).join("/");
|
|
53785
53970
|
}
|
|
53786
|
-
function encodeFilePathForUri(
|
|
53787
|
-
return
|
|
53971
|
+
function encodeFilePathForUri(path2) {
|
|
53972
|
+
return path2.replace(/\\/g, "/").split("/").map((segment) => encodeURIComponent(segment)).join("/");
|
|
53788
53973
|
}
|
|
53789
53974
|
function buildIdeFileUrl(filePath, ideLinkMode) {
|
|
53790
53975
|
const normalizedPath = filePath.replace(/\\/g, "/");
|
|
@@ -54439,19 +54624,19 @@ var init_GitRootDir = __esm(() => {
|
|
|
54439
54624
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
54440
54625
|
import {
|
|
54441
54626
|
existsSync as existsSync2,
|
|
54442
|
-
mkdirSync,
|
|
54443
|
-
readFileSync as
|
|
54444
|
-
statSync,
|
|
54445
|
-
writeFileSync
|
|
54627
|
+
mkdirSync as mkdirSync2,
|
|
54628
|
+
readFileSync as readFileSync3,
|
|
54629
|
+
statSync as statSync2,
|
|
54630
|
+
writeFileSync as writeFileSync2
|
|
54446
54631
|
} from "fs";
|
|
54447
|
-
import { createHash } from "node:crypto";
|
|
54448
|
-
import
|
|
54449
|
-
import
|
|
54450
|
-
function
|
|
54451
|
-
return
|
|
54632
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
54633
|
+
import os4 from "node:os";
|
|
54634
|
+
import path2 from "node:path";
|
|
54635
|
+
function getCacheDir2(deps) {
|
|
54636
|
+
return path2.join(deps.getHomedir(), ".cache", "ccstatusline");
|
|
54452
54637
|
}
|
|
54453
54638
|
function getGitReviewCacheDir(deps) {
|
|
54454
|
-
return
|
|
54639
|
+
return path2.join(getCacheDir2(deps), "git-review");
|
|
54455
54640
|
}
|
|
54456
54641
|
function runGitForCache(args, cwd2, deps) {
|
|
54457
54642
|
try {
|
|
@@ -54459,7 +54644,8 @@ function runGitForCache(args, cwd2, deps) {
|
|
|
54459
54644
|
encoding: "utf8",
|
|
54460
54645
|
stdio: ["pipe", "pipe", "ignore"],
|
|
54461
54646
|
cwd: cwd2,
|
|
54462
|
-
timeout: CLI_TIMEOUT
|
|
54647
|
+
timeout: CLI_TIMEOUT,
|
|
54648
|
+
windowsHide: true
|
|
54463
54649
|
}).trim();
|
|
54464
54650
|
} catch {
|
|
54465
54651
|
return "";
|
|
@@ -54480,9 +54666,9 @@ function getCacheRef(cwd2, deps) {
|
|
|
54480
54666
|
}
|
|
54481
54667
|
return "unknown";
|
|
54482
54668
|
}
|
|
54483
|
-
function
|
|
54484
|
-
const hash2 =
|
|
54485
|
-
return
|
|
54669
|
+
function getCachePath2(cwd2, ref, deps) {
|
|
54670
|
+
const hash2 = createHash2("sha256").update(cwd2).update("\x00").update(ref).digest("hex").slice(0, 16);
|
|
54671
|
+
return path2.join(getGitReviewCacheDir(deps), `git-review-${hash2}.json`);
|
|
54486
54672
|
}
|
|
54487
54673
|
function readCache(cachePath, deps) {
|
|
54488
54674
|
try {
|
|
@@ -54562,7 +54748,8 @@ function isCliAvailable(cli, deps) {
|
|
|
54562
54748
|
try {
|
|
54563
54749
|
deps.execFileSync(cli, ["--version"], {
|
|
54564
54750
|
stdio: ["pipe", "pipe", "ignore"],
|
|
54565
|
-
timeout: CLI_TIMEOUT
|
|
54751
|
+
timeout: CLI_TIMEOUT,
|
|
54752
|
+
windowsHide: true
|
|
54566
54753
|
});
|
|
54567
54754
|
return true;
|
|
54568
54755
|
} catch {
|
|
@@ -54573,7 +54760,8 @@ function isCliAuthedForHost(cli, host, deps) {
|
|
|
54573
54760
|
try {
|
|
54574
54761
|
deps.execFileSync(cli, ["auth", "status", "--hostname", host], {
|
|
54575
54762
|
stdio: ["pipe", "pipe", "ignore"],
|
|
54576
|
-
timeout: CLI_TIMEOUT
|
|
54763
|
+
timeout: CLI_TIMEOUT,
|
|
54764
|
+
windowsHide: true
|
|
54577
54765
|
});
|
|
54578
54766
|
return true;
|
|
54579
54767
|
} catch {
|
|
@@ -54605,7 +54793,8 @@ function fetchFromGh(cwd2, repoRef, deps) {
|
|
|
54605
54793
|
encoding: "utf8",
|
|
54606
54794
|
stdio: ["pipe", "pipe", "ignore"],
|
|
54607
54795
|
cwd: cwd2,
|
|
54608
|
-
timeout: CLI_TIMEOUT
|
|
54796
|
+
timeout: CLI_TIMEOUT,
|
|
54797
|
+
windowsHide: true
|
|
54609
54798
|
}).trim();
|
|
54610
54799
|
if (output.length === 0) {
|
|
54611
54800
|
return null;
|
|
@@ -54637,7 +54826,8 @@ function fetchFromGlab(cwd2, repoRef, deps) {
|
|
|
54637
54826
|
encoding: "utf8",
|
|
54638
54827
|
stdio: ["pipe", "pipe", "ignore"],
|
|
54639
54828
|
cwd: cwd2,
|
|
54640
|
-
timeout: CLI_TIMEOUT
|
|
54829
|
+
timeout: CLI_TIMEOUT,
|
|
54830
|
+
windowsHide: true
|
|
54641
54831
|
}).trim();
|
|
54642
54832
|
if (output.length === 0) {
|
|
54643
54833
|
return null;
|
|
@@ -54669,7 +54859,7 @@ function fetchFromProvider(provider, cwd2, repoRef, deps) {
|
|
|
54669
54859
|
return null;
|
|
54670
54860
|
}
|
|
54671
54861
|
function fetchGitReviewData(cwd2, deps = DEFAULT_GIT_REVIEW_CACHE_DEPS) {
|
|
54672
|
-
const cachePath =
|
|
54862
|
+
const cachePath = getCachePath2(cwd2, getCacheRef(cwd2, deps), deps);
|
|
54673
54863
|
const cached2 = readCache(cachePath, deps);
|
|
54674
54864
|
if (cached2 !== "miss") {
|
|
54675
54865
|
return cached2;
|
|
@@ -54715,11 +54905,11 @@ var init_git_review_cache = __esm(() => {
|
|
|
54715
54905
|
DEFAULT_GIT_REVIEW_CACHE_DEPS = {
|
|
54716
54906
|
execFileSync: execFileSync2,
|
|
54717
54907
|
existsSync: existsSync2,
|
|
54718
|
-
mkdirSync,
|
|
54719
|
-
readFileSync:
|
|
54720
|
-
statSync,
|
|
54721
|
-
writeFileSync,
|
|
54722
|
-
getHomedir:
|
|
54908
|
+
mkdirSync: mkdirSync2,
|
|
54909
|
+
readFileSync: readFileSync3,
|
|
54910
|
+
statSync: statSync2,
|
|
54911
|
+
writeFileSync: writeFileSync2,
|
|
54912
|
+
getHomedir: os4.homedir,
|
|
54723
54913
|
now: Date.now
|
|
54724
54914
|
};
|
|
54725
54915
|
});
|
|
@@ -56714,20 +56904,20 @@ var init_context_percentage = () => {};
|
|
|
56714
56904
|
|
|
56715
56905
|
// src/utils/terminal.ts
|
|
56716
56906
|
import { execSync } from "child_process";
|
|
56717
|
-
import * as
|
|
56718
|
-
import * as
|
|
56907
|
+
import * as fs3 from "fs";
|
|
56908
|
+
import * as path3 from "path";
|
|
56719
56909
|
function getPackageVersion() {
|
|
56720
56910
|
if (/^\d+\.\d+\.\d+/.test(PACKAGE_VERSION)) {
|
|
56721
56911
|
return PACKAGE_VERSION;
|
|
56722
56912
|
}
|
|
56723
56913
|
const possiblePaths = [
|
|
56724
|
-
|
|
56725
|
-
|
|
56914
|
+
path3.join(__dirname, "..", "..", "package.json"),
|
|
56915
|
+
path3.join(__dirname, "..", "package.json")
|
|
56726
56916
|
];
|
|
56727
56917
|
for (const packageJsonPath of possiblePaths) {
|
|
56728
56918
|
try {
|
|
56729
|
-
if (
|
|
56730
|
-
const packageJson = JSON.parse(
|
|
56919
|
+
if (fs3.existsSync(packageJsonPath)) {
|
|
56920
|
+
const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
|
|
56731
56921
|
return packageJson.version ?? "";
|
|
56732
56922
|
}
|
|
56733
56923
|
} catch {}
|
|
@@ -56735,6 +56925,13 @@ function getPackageVersion() {
|
|
|
56735
56925
|
return "";
|
|
56736
56926
|
}
|
|
56737
56927
|
function probeTerminalWidth() {
|
|
56928
|
+
const overrideRaw = process.env.CCSTATUSLINE_WIDTH;
|
|
56929
|
+
if (overrideRaw) {
|
|
56930
|
+
const override = parsePositiveInteger(overrideRaw);
|
|
56931
|
+
if (override !== null) {
|
|
56932
|
+
return override;
|
|
56933
|
+
}
|
|
56934
|
+
}
|
|
56738
56935
|
if (process.platform === "win32") {
|
|
56739
56936
|
return null;
|
|
56740
56937
|
}
|
|
@@ -56757,7 +56954,8 @@ function probeTerminalWidth() {
|
|
|
56757
56954
|
try {
|
|
56758
56955
|
const width = execSync("tput cols 2>/dev/null", {
|
|
56759
56956
|
encoding: "utf8",
|
|
56760
|
-
stdio: ["pipe", "pipe", "ignore"]
|
|
56957
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
56958
|
+
windowsHide: true
|
|
56761
56959
|
}).trim();
|
|
56762
56960
|
return parsePositiveInteger(width);
|
|
56763
56961
|
} catch {}
|
|
@@ -56775,7 +56973,8 @@ function getParentProcessId(pid) {
|
|
|
56775
56973
|
const parentPidOutput = execSync(`ps -o ppid= -p ${pid}`, {
|
|
56776
56974
|
encoding: "utf8",
|
|
56777
56975
|
stdio: ["pipe", "pipe", "ignore"],
|
|
56778
|
-
shell: "/bin/sh"
|
|
56976
|
+
shell: "/bin/sh",
|
|
56977
|
+
windowsHide: true
|
|
56779
56978
|
}).trim();
|
|
56780
56979
|
return parsePositiveInteger(parentPidOutput);
|
|
56781
56980
|
} catch {
|
|
@@ -56787,7 +56986,8 @@ function getTTYForProcess(pid) {
|
|
|
56787
56986
|
const tty2 = execSync(`ps -o tty= -p ${pid}`, {
|
|
56788
56987
|
encoding: "utf8",
|
|
56789
56988
|
stdio: ["pipe", "pipe", "ignore"],
|
|
56790
|
-
shell: "/bin/sh"
|
|
56989
|
+
shell: "/bin/sh",
|
|
56990
|
+
windowsHide: true
|
|
56791
56991
|
}).replace(/\s+/g, "");
|
|
56792
56992
|
if (!tty2 || tty2 === "??" || tty2 === "?") {
|
|
56793
56993
|
return null;
|
|
@@ -56809,7 +57009,8 @@ function getWidthForTTY(tty2) {
|
|
|
56809
57009
|
const width = execSync(`${cmd} 2>/dev/null | awk '{print $2}'`, {
|
|
56810
57010
|
encoding: "utf8",
|
|
56811
57011
|
stdio: ["pipe", "pipe", "ignore"],
|
|
56812
|
-
shell: "/bin/sh"
|
|
57012
|
+
shell: "/bin/sh",
|
|
57013
|
+
windowsHide: true
|
|
56813
57014
|
}).trim();
|
|
56814
57015
|
const parsed = parsePositiveInteger(width);
|
|
56815
57016
|
if (parsed !== null) {
|
|
@@ -56825,7 +57026,7 @@ function getTerminalWidth() {
|
|
|
56825
57026
|
function canDetectTerminalWidth() {
|
|
56826
57027
|
return probeTerminalWidth() !== null;
|
|
56827
57028
|
}
|
|
56828
|
-
var __dirname = "/Users/bytedance/Documents/code/ai/ccstatusline-zh/src/utils", PACKAGE_VERSION = "2.2.
|
|
57029
|
+
var __dirname = "/Users/bytedance/Documents/code/ai/ccstatusline-zh/src/utils", PACKAGE_VERSION = "2.2.19";
|
|
56829
57030
|
var init_terminal = () => {};
|
|
56830
57031
|
|
|
56831
57032
|
// src/utils/renderer.ts
|
|
@@ -58912,7 +59113,8 @@ class CustomCommandWidget {
|
|
|
58912
59113
|
input: jsonInput,
|
|
58913
59114
|
timeout,
|
|
58914
59115
|
stdio: ["pipe", "pipe", "ignore"],
|
|
58915
|
-
env: process.env
|
|
59116
|
+
env: process.env,
|
|
59117
|
+
windowsHide: true
|
|
58916
59118
|
}).trim();
|
|
58917
59119
|
if (!item.preserveColors) {
|
|
58918
59120
|
output = getVisibleText(output);
|
|
@@ -59579,7 +59781,7 @@ var require_has_flag = __commonJS((exports, module) => {
|
|
|
59579
59781
|
|
|
59580
59782
|
// node_modules/supports-color/index.js
|
|
59581
59783
|
var require_supports_color = __commonJS((exports, module) => {
|
|
59582
|
-
var
|
|
59784
|
+
var os5 = __require("os");
|
|
59583
59785
|
var tty2 = __require("tty");
|
|
59584
59786
|
var hasFlag2 = require_has_flag();
|
|
59585
59787
|
var { env: env3 } = process;
|
|
@@ -59636,7 +59838,7 @@ var require_supports_color = __commonJS((exports, module) => {
|
|
|
59636
59838
|
return min2;
|
|
59637
59839
|
}
|
|
59638
59840
|
if (process.platform === "win32") {
|
|
59639
|
-
const osRelease =
|
|
59841
|
+
const osRelease = os5.release().split(".");
|
|
59640
59842
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
59641
59843
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
59642
59844
|
}
|
|
@@ -59984,7 +60186,7 @@ var init_dist4 = __esm(() => {
|
|
|
59984
60186
|
|
|
59985
60187
|
// node_modules/https-proxy-agent/dist/parse-proxy-response.js
|
|
59986
60188
|
function parseProxyResponse(socket) {
|
|
59987
|
-
return new Promise((
|
|
60189
|
+
return new Promise((resolve2, reject2) => {
|
|
59988
60190
|
let buffersLength = 0;
|
|
59989
60191
|
const buffers = [];
|
|
59990
60192
|
function read() {
|
|
@@ -60053,7 +60255,7 @@ function parseProxyResponse(socket) {
|
|
|
60053
60255
|
}
|
|
60054
60256
|
debug("got proxy server response: %o %o", firstLine, headers);
|
|
60055
60257
|
cleanup();
|
|
60056
|
-
|
|
60258
|
+
resolve2({
|
|
60057
60259
|
connect: {
|
|
60058
60260
|
statusCode,
|
|
60059
60261
|
statusText,
|
|
@@ -60193,10 +60395,10 @@ var init_usage_types = __esm(() => {
|
|
|
60193
60395
|
|
|
60194
60396
|
// src/utils/usage-fetch.ts
|
|
60195
60397
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
60196
|
-
import * as
|
|
60398
|
+
import * as fs4 from "fs";
|
|
60197
60399
|
import * as https from "https";
|
|
60198
|
-
import * as
|
|
60199
|
-
import * as
|
|
60400
|
+
import * as os5 from "os";
|
|
60401
|
+
import * as path4 from "path";
|
|
60200
60402
|
function getUsageApiBucketUtilization(bucket) {
|
|
60201
60403
|
return bucket === null ? 0 : bucket?.utilization ?? undefined;
|
|
60202
60404
|
}
|
|
@@ -60255,8 +60457,8 @@ function parseUsageApiResponse(rawJson) {
|
|
|
60255
60457
|
};
|
|
60256
60458
|
}
|
|
60257
60459
|
function ensureCacheDirExists() {
|
|
60258
|
-
if (!
|
|
60259
|
-
|
|
60460
|
+
if (!fs4.existsSync(CACHE_DIR)) {
|
|
60461
|
+
fs4.mkdirSync(CACHE_DIR, { recursive: true });
|
|
60260
60462
|
}
|
|
60261
60463
|
}
|
|
60262
60464
|
function setCachedUsageError(error51, now2, maxAge = LOCK_MAX_AGE) {
|
|
@@ -60358,7 +60560,7 @@ function parseMacKeychainCredentialCandidates(rawDump, servicePrefix = MACOS_USA
|
|
|
60358
60560
|
}
|
|
60359
60561
|
function readMacKeychainSecret(service) {
|
|
60360
60562
|
try {
|
|
60361
|
-
return execFileSync3("security", ["find-generic-password", "-s", service, "-w"], { encoding: "utf8", stdio: ["pipe", "pipe", "ignore"] }).trim();
|
|
60563
|
+
return execFileSync3("security", ["find-generic-password", "-s", service, "-w"], { encoding: "utf8", stdio: ["pipe", "pipe", "ignore"], windowsHide: true }).trim();
|
|
60362
60564
|
} catch {
|
|
60363
60565
|
return null;
|
|
60364
60566
|
}
|
|
@@ -60372,7 +60574,8 @@ function listMacKeychainCredentialCandidates() {
|
|
|
60372
60574
|
const rawDump = execFileSync3("security", ["dump-keychain"], {
|
|
60373
60575
|
encoding: "utf8",
|
|
60374
60576
|
maxBuffer: MACOS_SECURITY_DUMP_MAX_BUFFER,
|
|
60375
|
-
stdio: ["pipe", "pipe", "ignore"]
|
|
60577
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
60578
|
+
windowsHide: true
|
|
60376
60579
|
});
|
|
60377
60580
|
return parseMacKeychainCredentialCandidates(rawDump);
|
|
60378
60581
|
} catch {
|
|
@@ -60391,8 +60594,8 @@ function readUsageTokenFromMacKeychainCandidates() {
|
|
|
60391
60594
|
}
|
|
60392
60595
|
function readUsageTokenFromCredentialsFile() {
|
|
60393
60596
|
try {
|
|
60394
|
-
const credFile =
|
|
60395
|
-
return parseUsageAccessToken(
|
|
60597
|
+
const credFile = path4.join(getClaudeConfigDir(), ".credentials.json");
|
|
60598
|
+
return parseUsageAccessToken(fs4.readFileSync(credFile, "utf8"));
|
|
60396
60599
|
} catch {
|
|
60397
60600
|
return null;
|
|
60398
60601
|
}
|
|
@@ -60405,7 +60608,7 @@ function getUsageToken() {
|
|
|
60405
60608
|
}
|
|
60406
60609
|
function readStaleUsageCache() {
|
|
60407
60610
|
try {
|
|
60408
|
-
return parseCachedUsageData(
|
|
60611
|
+
return parseCachedUsageData(fs4.readFileSync(CACHE_FILE, "utf8"));
|
|
60409
60612
|
} catch {
|
|
60410
60613
|
return null;
|
|
60411
60614
|
}
|
|
@@ -60413,13 +60616,13 @@ function readStaleUsageCache() {
|
|
|
60413
60616
|
function writeUsageLock(blockedUntil, error51) {
|
|
60414
60617
|
try {
|
|
60415
60618
|
ensureCacheDirExists();
|
|
60416
|
-
|
|
60619
|
+
fs4.writeFileSync(LOCK_FILE, JSON.stringify({ blockedUntil, error: error51 }));
|
|
60417
60620
|
} catch {}
|
|
60418
60621
|
}
|
|
60419
60622
|
function readActiveUsageLock(now2) {
|
|
60420
60623
|
let hasValidJsonLock = false;
|
|
60421
60624
|
try {
|
|
60422
|
-
const parsed = parseJsonWithSchema(
|
|
60625
|
+
const parsed = parseJsonWithSchema(fs4.readFileSync(LOCK_FILE, "utf8"), UsageLockSchema);
|
|
60423
60626
|
if (parsed) {
|
|
60424
60627
|
hasValidJsonLock = true;
|
|
60425
60628
|
if (parsed.blockedUntil > now2) {
|
|
@@ -60435,7 +60638,7 @@ function readActiveUsageLock(now2) {
|
|
|
60435
60638
|
return null;
|
|
60436
60639
|
}
|
|
60437
60640
|
try {
|
|
60438
|
-
const lockStat =
|
|
60641
|
+
const lockStat = fs4.statSync(LOCK_FILE);
|
|
60439
60642
|
const lockMtime = Math.floor(lockStat.mtimeMs / 1000);
|
|
60440
60643
|
const blockedUntil = lockMtime + LOCK_MAX_AGE;
|
|
60441
60644
|
if (blockedUntil > now2) {
|
|
@@ -60490,14 +60693,14 @@ function getUsageApiRequestOptions(token) {
|
|
|
60490
60693
|
}
|
|
60491
60694
|
}
|
|
60492
60695
|
async function fetchFromUsageApi(token) {
|
|
60493
|
-
return new Promise((
|
|
60696
|
+
return new Promise((resolve2) => {
|
|
60494
60697
|
let settled = false;
|
|
60495
60698
|
const finish = (value) => {
|
|
60496
60699
|
if (settled) {
|
|
60497
60700
|
return;
|
|
60498
60701
|
}
|
|
60499
60702
|
settled = true;
|
|
60500
|
-
|
|
60703
|
+
resolve2(value);
|
|
60501
60704
|
};
|
|
60502
60705
|
const requestOptions = getUsageApiRequestOptions(token);
|
|
60503
60706
|
if (!requestOptions) {
|
|
@@ -60548,10 +60751,10 @@ async function fetchUsageData(options = {}) {
|
|
|
60548
60751
|
}
|
|
60549
60752
|
}
|
|
60550
60753
|
try {
|
|
60551
|
-
const stat =
|
|
60754
|
+
const stat = fs4.statSync(CACHE_FILE);
|
|
60552
60755
|
const fileAge = now2 - Math.floor(stat.mtimeMs / 1000);
|
|
60553
60756
|
if (fileAge < CACHE_MAX_AGE) {
|
|
60554
|
-
const fileData = parseCachedUsageData(
|
|
60757
|
+
const fileData = parseCachedUsageData(fs4.readFileSync(CACHE_FILE, "utf8"));
|
|
60555
60758
|
if (fileData && !fileData.error && hasRequiredUsageFields(fileData, requiredFields)) {
|
|
60556
60759
|
return cacheUsageData(fileData, now2);
|
|
60557
60760
|
}
|
|
@@ -60586,7 +60789,7 @@ async function fetchUsageData(options = {}) {
|
|
|
60586
60789
|
}
|
|
60587
60790
|
try {
|
|
60588
60791
|
ensureCacheDirExists();
|
|
60589
|
-
|
|
60792
|
+
fs4.writeFileSync(CACHE_FILE, JSON.stringify(usageData));
|
|
60590
60793
|
} catch {}
|
|
60591
60794
|
return cacheUsageData(usageData, now2);
|
|
60592
60795
|
} catch {
|
|
@@ -60600,9 +60803,9 @@ var init_usage_fetch = __esm(async () => {
|
|
|
60600
60803
|
init_zod();
|
|
60601
60804
|
init_usage_types();
|
|
60602
60805
|
await init_claude_settings();
|
|
60603
|
-
CACHE_DIR =
|
|
60604
|
-
CACHE_FILE =
|
|
60605
|
-
LOCK_FILE =
|
|
60806
|
+
CACHE_DIR = path4.join(os5.homedir(), ".cache", "ccstatusline");
|
|
60807
|
+
CACHE_FILE = path4.join(CACHE_DIR, "usage.json");
|
|
60808
|
+
LOCK_FILE = path4.join(CACHE_DIR, "usage.lock");
|
|
60606
60809
|
MACOS_SECURITY_DUMP_MAX_BUFFER = 8 * 1024 * 1024;
|
|
60607
60810
|
EXTRA_USAGE_DETAIL_FIELDS = new Set([
|
|
60608
60811
|
"extraUsageLimit",
|
|
@@ -60651,31 +60854,31 @@ var init_usage_fetch = __esm(async () => {
|
|
|
60651
60854
|
|
|
60652
60855
|
// node_modules/fdir/dist/index.mjs
|
|
60653
60856
|
import { createRequire as createRequire2 } from "module";
|
|
60654
|
-
import { basename, dirname, normalize, relative, resolve, sep } from "path";
|
|
60857
|
+
import { basename, dirname as dirname2, normalize, relative, resolve as resolve2, sep } from "path";
|
|
60655
60858
|
import * as nativeFs from "fs";
|
|
60656
|
-
function cleanPath(
|
|
60657
|
-
let normalized = normalize(
|
|
60859
|
+
function cleanPath(path5) {
|
|
60860
|
+
let normalized = normalize(path5);
|
|
60658
60861
|
if (normalized.length > 1 && normalized[normalized.length - 1] === sep)
|
|
60659
60862
|
normalized = normalized.substring(0, normalized.length - 1);
|
|
60660
60863
|
return normalized;
|
|
60661
60864
|
}
|
|
60662
|
-
function convertSlashes(
|
|
60663
|
-
return
|
|
60865
|
+
function convertSlashes(path5, separator) {
|
|
60866
|
+
return path5.replace(SLASHES_REGEX, separator);
|
|
60664
60867
|
}
|
|
60665
|
-
function isRootDirectory(
|
|
60666
|
-
return
|
|
60868
|
+
function isRootDirectory(path5) {
|
|
60869
|
+
return path5 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path5);
|
|
60667
60870
|
}
|
|
60668
|
-
function normalizePath(
|
|
60871
|
+
function normalizePath(path5, options) {
|
|
60669
60872
|
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
60670
|
-
const pathNeedsCleaning = process.platform === "win32" &&
|
|
60873
|
+
const pathNeedsCleaning = process.platform === "win32" && path5.includes("/") || path5.startsWith(".");
|
|
60671
60874
|
if (resolvePaths)
|
|
60672
|
-
|
|
60875
|
+
path5 = resolve2(path5);
|
|
60673
60876
|
if (normalizePath$1 || pathNeedsCleaning)
|
|
60674
|
-
|
|
60675
|
-
if (
|
|
60877
|
+
path5 = cleanPath(path5);
|
|
60878
|
+
if (path5 === ".")
|
|
60676
60879
|
return "";
|
|
60677
|
-
const needsSeperator =
|
|
60678
|
-
return convertSlashes(needsSeperator ?
|
|
60880
|
+
const needsSeperator = path5[path5.length - 1] !== pathSeparator;
|
|
60881
|
+
return convertSlashes(needsSeperator ? path5 + pathSeparator : path5, pathSeparator);
|
|
60679
60882
|
}
|
|
60680
60883
|
function joinPathWithBasePath(filename, directoryPath) {
|
|
60681
60884
|
return directoryPath + filename;
|
|
@@ -60741,10 +60944,10 @@ function build$2(options, isSynchronous) {
|
|
|
60741
60944
|
return null;
|
|
60742
60945
|
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
60743
60946
|
}
|
|
60744
|
-
function isRecursive(
|
|
60947
|
+
function isRecursive(path5, resolved, state) {
|
|
60745
60948
|
if (state.options.useRealPaths)
|
|
60746
60949
|
return isRecursiveUsingRealPaths(resolved, state);
|
|
60747
|
-
let parent =
|
|
60950
|
+
let parent = dirname2(path5);
|
|
60748
60951
|
let depth = 1;
|
|
60749
60952
|
while (parent !== state.root && depth < 2) {
|
|
60750
60953
|
const resolvedPath = state.symlinks.get(parent);
|
|
@@ -60752,9 +60955,9 @@ function isRecursive(path4, resolved, state) {
|
|
|
60752
60955
|
if (isSameRoot)
|
|
60753
60956
|
depth++;
|
|
60754
60957
|
else
|
|
60755
|
-
parent =
|
|
60958
|
+
parent = dirname2(parent);
|
|
60756
60959
|
}
|
|
60757
|
-
state.symlinks.set(
|
|
60960
|
+
state.symlinks.set(path5, resolved);
|
|
60758
60961
|
return depth > 1;
|
|
60759
60962
|
}
|
|
60760
60963
|
function isRecursiveUsingRealPaths(resolved, state) {
|
|
@@ -60800,9 +61003,9 @@ function sync(root, options) {
|
|
|
60800
61003
|
var __require2, SLASHES_REGEX, WINDOWS_ROOT_DIR_REGEX, pushDirectory = (directoryPath, paths) => {
|
|
60801
61004
|
paths.push(directoryPath || ".");
|
|
60802
61005
|
}, pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
60803
|
-
const
|
|
60804
|
-
if (filters.every((filter2) => filter2(
|
|
60805
|
-
paths.push(
|
|
61006
|
+
const path5 = directoryPath || ".";
|
|
61007
|
+
if (filters.every((filter2) => filter2(path5, true)))
|
|
61008
|
+
paths.push(path5);
|
|
60806
61009
|
}, empty$2 = () => {}, pushFileFilterAndCount = (filename, _paths, counts, filters) => {
|
|
60807
61010
|
if (filters.every((filter2) => filter2(filename, false)))
|
|
60808
61011
|
counts.files++;
|
|
@@ -60823,28 +61026,28 @@ var __require2, SLASHES_REGEX, WINDOWS_ROOT_DIR_REGEX, pushDirectory = (director
|
|
|
60823
61026
|
files,
|
|
60824
61027
|
dir: directory
|
|
60825
61028
|
});
|
|
60826
|
-
}, empty = () => {}, resolveSymlinksAsync = function(
|
|
60827
|
-
const { queue, fs:
|
|
61029
|
+
}, empty = () => {}, resolveSymlinksAsync = function(path5, state, callback$1) {
|
|
61030
|
+
const { queue, fs: fs5, options: { suppressErrors } } = state;
|
|
60828
61031
|
queue.enqueue();
|
|
60829
|
-
|
|
61032
|
+
fs5.realpath(path5, (error51, resolvedPath) => {
|
|
60830
61033
|
if (error51)
|
|
60831
61034
|
return queue.dequeue(suppressErrors ? null : error51, state);
|
|
60832
|
-
|
|
61035
|
+
fs5.stat(resolvedPath, (error$1, stat) => {
|
|
60833
61036
|
if (error$1)
|
|
60834
61037
|
return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
60835
|
-
if (stat.isDirectory() && isRecursive(
|
|
61038
|
+
if (stat.isDirectory() && isRecursive(path5, resolvedPath, state))
|
|
60836
61039
|
return queue.dequeue(null, state);
|
|
60837
61040
|
callback$1(stat, resolvedPath);
|
|
60838
61041
|
queue.dequeue(null, state);
|
|
60839
61042
|
});
|
|
60840
61043
|
});
|
|
60841
|
-
}, resolveSymlinks = function(
|
|
60842
|
-
const { queue, fs:
|
|
61044
|
+
}, resolveSymlinks = function(path5, state, callback$1) {
|
|
61045
|
+
const { queue, fs: fs5, options: { suppressErrors } } = state;
|
|
60843
61046
|
queue.enqueue();
|
|
60844
61047
|
try {
|
|
60845
|
-
const resolvedPath =
|
|
60846
|
-
const stat =
|
|
60847
|
-
if (stat.isDirectory() && isRecursive(
|
|
61048
|
+
const resolvedPath = fs5.realpathSync(path5);
|
|
61049
|
+
const stat = fs5.statSync(resolvedPath);
|
|
61050
|
+
if (stat.isDirectory() && isRecursive(path5, resolvedPath, state))
|
|
60848
61051
|
return;
|
|
60849
61052
|
callback$1(stat, resolvedPath);
|
|
60850
61053
|
} catch (e) {
|
|
@@ -60875,22 +61078,22 @@ var __require2, SLASHES_REGEX, WINDOWS_ROOT_DIR_REGEX, pushDirectory = (director
|
|
|
60875
61078
|
state.queue.enqueue();
|
|
60876
61079
|
if (currentDepth < 0)
|
|
60877
61080
|
return state.queue.dequeue(null, state);
|
|
60878
|
-
const { fs:
|
|
61081
|
+
const { fs: fs5 } = state;
|
|
60879
61082
|
state.visited.push(crawlPath);
|
|
60880
61083
|
state.counts.directories++;
|
|
60881
|
-
|
|
61084
|
+
fs5.readdir(crawlPath || ".", readdirOpts, (error51, entries = []) => {
|
|
60882
61085
|
callback$1(entries, directoryPath, currentDepth);
|
|
60883
61086
|
state.queue.dequeue(state.options.suppressErrors ? null : error51, state);
|
|
60884
61087
|
});
|
|
60885
61088
|
}, walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
60886
|
-
const { fs:
|
|
61089
|
+
const { fs: fs5 } = state;
|
|
60887
61090
|
if (currentDepth < 0)
|
|
60888
61091
|
return;
|
|
60889
61092
|
state.visited.push(crawlPath);
|
|
60890
61093
|
state.counts.directories++;
|
|
60891
61094
|
let entries = [];
|
|
60892
61095
|
try {
|
|
60893
|
-
entries =
|
|
61096
|
+
entries = fs5.readdirSync(crawlPath || ".", readdirOpts);
|
|
60894
61097
|
} catch (e) {
|
|
60895
61098
|
if (!state.options.suppressErrors)
|
|
60896
61099
|
throw e;
|
|
@@ -60989,23 +61192,23 @@ var __require2, SLASHES_REGEX, WINDOWS_ROOT_DIR_REGEX, pushDirectory = (director
|
|
|
60989
61192
|
const filename = this.joinPath(entry.name, directoryPath);
|
|
60990
61193
|
this.pushFile(filename, files, this.state.counts, filters);
|
|
60991
61194
|
} else if (entry.isDirectory()) {
|
|
60992
|
-
let
|
|
60993
|
-
if (exclude && exclude(entry.name,
|
|
61195
|
+
let path5 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
61196
|
+
if (exclude && exclude(entry.name, path5))
|
|
60994
61197
|
continue;
|
|
60995
|
-
this.pushDirectory(
|
|
60996
|
-
this.walkDirectory(this.state,
|
|
61198
|
+
this.pushDirectory(path5, paths, filters);
|
|
61199
|
+
this.walkDirectory(this.state, path5, path5, depth - 1, this.walk);
|
|
60997
61200
|
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
60998
|
-
let
|
|
60999
|
-
this.resolveSymlink(
|
|
61201
|
+
let path5 = joinPathWithBasePath(entry.name, directoryPath);
|
|
61202
|
+
this.resolveSymlink(path5, this.state, (stat, resolvedPath) => {
|
|
61000
61203
|
if (stat.isDirectory()) {
|
|
61001
61204
|
resolvedPath = normalizePath(resolvedPath, this.state.options);
|
|
61002
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath :
|
|
61205
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path5 + pathSeparator))
|
|
61003
61206
|
return;
|
|
61004
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath :
|
|
61207
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path5 + pathSeparator, depth - 1, this.walk);
|
|
61005
61208
|
} else {
|
|
61006
|
-
resolvedPath = useRealPaths ? resolvedPath :
|
|
61209
|
+
resolvedPath = useRealPaths ? resolvedPath : path5;
|
|
61007
61210
|
const filename = basename(resolvedPath);
|
|
61008
|
-
const directoryPath$1 = normalizePath(
|
|
61211
|
+
const directoryPath$1 = normalizePath(dirname2(resolvedPath), this.state.options);
|
|
61009
61212
|
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
61010
61213
|
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
61011
61214
|
}
|
|
@@ -61139,7 +61342,7 @@ var __require2, SLASHES_REGEX, WINDOWS_ROOT_DIR_REGEX, pushDirectory = (director
|
|
|
61139
61342
|
isMatch2 = globFn(patterns, ...options);
|
|
61140
61343
|
this.globCache[patterns.join("\x00")] = isMatch2;
|
|
61141
61344
|
}
|
|
61142
|
-
this.options.filters.push((
|
|
61345
|
+
this.options.filters.push((path5) => isMatch2(path5));
|
|
61143
61346
|
return this;
|
|
61144
61347
|
}
|
|
61145
61348
|
};
|
|
@@ -61352,8 +61555,8 @@ var require_utils = __commonJS((exports) => {
|
|
|
61352
61555
|
}
|
|
61353
61556
|
return output;
|
|
61354
61557
|
};
|
|
61355
|
-
exports.basename = (
|
|
61356
|
-
const segs =
|
|
61558
|
+
exports.basename = (path5, { windows } = {}) => {
|
|
61559
|
+
const segs = path5.split(windows ? /[\\/]/ : "/");
|
|
61357
61560
|
const last2 = segs[segs.length - 1];
|
|
61358
61561
|
if (last2 === "") {
|
|
61359
61562
|
return segs[segs.length - 2];
|
|
@@ -62834,8 +63037,8 @@ var require_picomatch2 = __commonJS((exports, module) => {
|
|
|
62834
63037
|
});
|
|
62835
63038
|
|
|
62836
63039
|
// node_modules/tinyglobby/dist/index.mjs
|
|
62837
|
-
import { readdir, readdirSync, realpath, realpathSync, stat, statSync as
|
|
62838
|
-
import { isAbsolute, posix, resolve as
|
|
63040
|
+
import { readdir, readdirSync, realpath, realpathSync, stat, statSync as statSync4 } from "fs";
|
|
63041
|
+
import { isAbsolute, posix, resolve as resolve3 } from "path";
|
|
62839
63042
|
import { fileURLToPath } from "url";
|
|
62840
63043
|
function getPartialMatcher(patterns, options = {}) {
|
|
62841
63044
|
const patternsCount = patterns.length;
|
|
@@ -62907,10 +63110,10 @@ function buildRelative(cwd2, root) {
|
|
|
62907
63110
|
return p[p.length - 1] === "/" && result2 !== "" ? `${result2}/` : result2 || ".";
|
|
62908
63111
|
};
|
|
62909
63112
|
}
|
|
62910
|
-
function splitPattern(
|
|
63113
|
+
function splitPattern(path5) {
|
|
62911
63114
|
var _result$parts;
|
|
62912
|
-
const result2 = import_picomatch.default.scan(
|
|
62913
|
-
return ((_result$parts = result2.parts) === null || _result$parts === undefined ? undefined : _result$parts.length) ? result2.parts : [
|
|
63115
|
+
const result2 = import_picomatch.default.scan(path5, splitPatternOptions);
|
|
63116
|
+
return ((_result$parts = result2.parts) === null || _result$parts === undefined ? undefined : _result$parts.length) ? result2.parts : [path5];
|
|
62914
63117
|
}
|
|
62915
63118
|
function isDynamicPattern(pattern, options) {
|
|
62916
63119
|
if ((options === null || options === undefined ? undefined : options.caseSensitiveMatch) === false)
|
|
@@ -63026,14 +63229,14 @@ function buildCrawler(options, patterns) {
|
|
|
63026
63229
|
maxDepth = Math.round(options.deep - props.depthOffset);
|
|
63027
63230
|
const crawler = new Builder({
|
|
63028
63231
|
filters: [debug3 ? (p, isDirectory) => {
|
|
63029
|
-
const
|
|
63030
|
-
const matches2 = matcher(
|
|
63232
|
+
const path5 = format(p, isDirectory);
|
|
63233
|
+
const matches2 = matcher(path5) && !ignore(path5);
|
|
63031
63234
|
if (matches2)
|
|
63032
|
-
log(`matched ${
|
|
63235
|
+
log(`matched ${path5}`);
|
|
63033
63236
|
return matches2;
|
|
63034
63237
|
} : (p, isDirectory) => {
|
|
63035
|
-
const
|
|
63036
|
-
return matcher(
|
|
63238
|
+
const path5 = format(p, isDirectory);
|
|
63239
|
+
return matcher(path5) && !ignore(path5);
|
|
63037
63240
|
}],
|
|
63038
63241
|
exclude: debug3 ? (_, p) => {
|
|
63039
63242
|
const skipped = excludePredicate(_, p);
|
|
@@ -63070,7 +63273,7 @@ function getOptions2(options) {
|
|
|
63070
63273
|
...defaultOptions,
|
|
63071
63274
|
...options
|
|
63072
63275
|
};
|
|
63073
|
-
opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) :
|
|
63276
|
+
opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve3(opts.cwd)).replace(BACKSLASHES, "/");
|
|
63074
63277
|
opts.ignore = ensureStringArray(opts.ignore);
|
|
63075
63278
|
opts.fs && (opts.fs = {
|
|
63076
63279
|
readdir: opts.fs.readdir || readdir,
|
|
@@ -63078,7 +63281,7 @@ function getOptions2(options) {
|
|
|
63078
63281
|
realpath: opts.fs.realpath || realpath,
|
|
63079
63282
|
realpathSync: opts.fs.realpathSync || realpathSync,
|
|
63080
63283
|
stat: opts.fs.stat || stat,
|
|
63081
|
-
statSync: opts.fs.statSync ||
|
|
63284
|
+
statSync: opts.fs.statSync || statSync4
|
|
63082
63285
|
});
|
|
63083
63286
|
if (opts.debug)
|
|
63084
63287
|
log("globbing with options:", opts);
|
|
@@ -63097,7 +63300,7 @@ function globSync(globInput, options) {
|
|
|
63097
63300
|
const [crawler, relative2] = getCrawler(globInput, options);
|
|
63098
63301
|
return crawler ? formatPaths(crawler.sync(), relative2) : [];
|
|
63099
63302
|
}
|
|
63100
|
-
var import_picomatch, isReadonlyArray, BACKSLASHES, isWin, ONLY_PARENT_DIRECTORIES, WIN32_ROOT_DIR, isRoot, splitPatternOptions, POSIX_UNESCAPED_GLOB_SYMBOLS, WIN32_UNESCAPED_GLOB_SYMBOLS, escapePosixPath = (
|
|
63303
|
+
var import_picomatch, isReadonlyArray, BACKSLASHES, isWin, ONLY_PARENT_DIRECTORIES, WIN32_ROOT_DIR, isRoot, splitPatternOptions, POSIX_UNESCAPED_GLOB_SYMBOLS, WIN32_UNESCAPED_GLOB_SYMBOLS, escapePosixPath = (path5) => path5.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&"), escapeWin32Path = (path5) => path5.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&"), escapePath, PARENT_DIRECTORY, ESCAPING_BACKSLASHES, defaultOptions;
|
|
63101
63304
|
var init_dist7 = __esm(() => {
|
|
63102
63305
|
init_dist6();
|
|
63103
63306
|
import_picomatch = __toESM(require_picomatch2(), 1);
|
|
@@ -63124,7 +63327,7 @@ var init_dist7 = __esm(() => {
|
|
|
63124
63327
|
});
|
|
63125
63328
|
|
|
63126
63329
|
// src/utils/jsonl-lines.ts
|
|
63127
|
-
import * as
|
|
63330
|
+
import * as fs5 from "fs";
|
|
63128
63331
|
import { promisify } from "util";
|
|
63129
63332
|
function splitJsonlContent(content) {
|
|
63130
63333
|
return content.trim().split(`
|
|
@@ -63135,7 +63338,7 @@ async function readJsonlLines(filePath) {
|
|
|
63135
63338
|
return splitJsonlContent(content);
|
|
63136
63339
|
}
|
|
63137
63340
|
function readJsonlLinesSync(filePath) {
|
|
63138
|
-
const content =
|
|
63341
|
+
const content = readFileSync7(filePath, "utf-8");
|
|
63139
63342
|
return splitJsonlContent(content);
|
|
63140
63343
|
}
|
|
63141
63344
|
function parseJsonlLine(line) {
|
|
@@ -63145,15 +63348,15 @@ function parseJsonlLine(line) {
|
|
|
63145
63348
|
return null;
|
|
63146
63349
|
}
|
|
63147
63350
|
}
|
|
63148
|
-
var readFile2,
|
|
63351
|
+
var readFile2, readFileSync7;
|
|
63149
63352
|
var init_jsonl_lines = __esm(() => {
|
|
63150
|
-
readFile2 = promisify(
|
|
63151
|
-
|
|
63353
|
+
readFile2 = promisify(fs5.readFile);
|
|
63354
|
+
readFileSync7 = fs5.readFileSync;
|
|
63152
63355
|
});
|
|
63153
63356
|
|
|
63154
63357
|
// src/utils/jsonl-blocks.ts
|
|
63155
|
-
import * as
|
|
63156
|
-
import
|
|
63358
|
+
import * as fs6 from "fs";
|
|
63359
|
+
import path5 from "node:path";
|
|
63157
63360
|
function getBlockMetrics() {
|
|
63158
63361
|
const claudeDir = getClaudeConfigDir();
|
|
63159
63362
|
if (!claudeDir)
|
|
@@ -63167,7 +63370,7 @@ function getBlockMetrics() {
|
|
|
63167
63370
|
function findMostRecentBlockStartTime(rootDir, sessionDurationHours = 5) {
|
|
63168
63371
|
const sessionDurationMs = sessionDurationHours * 60 * 60 * 1000;
|
|
63169
63372
|
const now2 = new Date;
|
|
63170
|
-
const pattern =
|
|
63373
|
+
const pattern = path5.posix.join(rootDir.replace(/\\/g, "/"), "projects", "**", "*.jsonl");
|
|
63171
63374
|
const files = globSync([pattern], {
|
|
63172
63375
|
absolute: true,
|
|
63173
63376
|
cwd: rootDir
|
|
@@ -63175,7 +63378,7 @@ function findMostRecentBlockStartTime(rootDir, sessionDurationHours = 5) {
|
|
|
63175
63378
|
if (files.length === 0)
|
|
63176
63379
|
return null;
|
|
63177
63380
|
const filesWithStats = files.map((file2) => {
|
|
63178
|
-
const stats =
|
|
63381
|
+
const stats = statSync6(file2);
|
|
63179
63382
|
return { file: file2, mtime: stats.mtime };
|
|
63180
63383
|
});
|
|
63181
63384
|
filesWithStats.sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
|
|
@@ -63293,26 +63496,26 @@ function floorToHour(timestamp) {
|
|
|
63293
63496
|
floored.setUTCMinutes(0, 0, 0);
|
|
63294
63497
|
return floored;
|
|
63295
63498
|
}
|
|
63296
|
-
var
|
|
63499
|
+
var statSync6;
|
|
63297
63500
|
var init_jsonl_blocks = __esm(async () => {
|
|
63298
63501
|
init_dist7();
|
|
63299
63502
|
init_jsonl_lines();
|
|
63300
63503
|
await init_claude_settings();
|
|
63301
|
-
|
|
63504
|
+
statSync6 = fs6.statSync;
|
|
63302
63505
|
});
|
|
63303
63506
|
|
|
63304
63507
|
// src/utils/jsonl-cache.ts
|
|
63305
|
-
import * as
|
|
63306
|
-
import { createHash as
|
|
63307
|
-
import
|
|
63308
|
-
import
|
|
63508
|
+
import * as fs7 from "fs";
|
|
63509
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
63510
|
+
import os6 from "node:os";
|
|
63511
|
+
import path6 from "node:path";
|
|
63309
63512
|
function normalizeConfigDir(configDir) {
|
|
63310
|
-
return
|
|
63513
|
+
return path6.resolve(configDir);
|
|
63311
63514
|
}
|
|
63312
63515
|
function getBlockCachePath(configDir = getClaudeConfigDir()) {
|
|
63313
63516
|
const normalizedConfigDir = normalizeConfigDir(configDir);
|
|
63314
|
-
const configHash =
|
|
63315
|
-
return
|
|
63517
|
+
const configHash = createHash3("sha256").update(normalizedConfigDir).digest("hex").slice(0, 16);
|
|
63518
|
+
return path6.join(os6.homedir(), ".cache", "ccstatusline", `block-cache-${configHash}.json`);
|
|
63316
63519
|
}
|
|
63317
63520
|
function readBlockCache(expectedConfigDir) {
|
|
63318
63521
|
try {
|
|
@@ -63321,7 +63524,7 @@ function readBlockCache(expectedConfigDir) {
|
|
|
63321
63524
|
if (!existsSync6(cachePath)) {
|
|
63322
63525
|
return null;
|
|
63323
63526
|
}
|
|
63324
|
-
const content =
|
|
63527
|
+
const content = readFileSync9(cachePath, "utf-8");
|
|
63325
63528
|
const cache3 = JSON.parse(content);
|
|
63326
63529
|
if (typeof cache3.startTime !== "string") {
|
|
63327
63530
|
return null;
|
|
@@ -63347,15 +63550,15 @@ function writeBlockCache(startTime, configDir = getClaudeConfigDir()) {
|
|
|
63347
63550
|
try {
|
|
63348
63551
|
const normalizedConfigDir = normalizeConfigDir(configDir);
|
|
63349
63552
|
const cachePath = getBlockCachePath(normalizedConfigDir);
|
|
63350
|
-
const cacheDir =
|
|
63553
|
+
const cacheDir = path6.dirname(cachePath);
|
|
63351
63554
|
if (!existsSync6(cacheDir)) {
|
|
63352
|
-
|
|
63555
|
+
mkdirSync5(cacheDir, { recursive: true });
|
|
63353
63556
|
}
|
|
63354
63557
|
const cache3 = {
|
|
63355
63558
|
startTime: startTime.toISOString(),
|
|
63356
63559
|
configDir: normalizedConfigDir
|
|
63357
63560
|
};
|
|
63358
|
-
|
|
63561
|
+
writeFileSync5(cachePath, JSON.stringify(cache3), "utf-8");
|
|
63359
63562
|
} catch {}
|
|
63360
63563
|
}
|
|
63361
63564
|
function getCachedBlockMetrics(sessionDurationHours = 5) {
|
|
@@ -63378,21 +63581,21 @@ function getCachedBlockMetrics(sessionDurationHours = 5) {
|
|
|
63378
63581
|
}
|
|
63379
63582
|
return metrics;
|
|
63380
63583
|
}
|
|
63381
|
-
var
|
|
63584
|
+
var readFileSync9, writeFileSync5, mkdirSync5, existsSync6;
|
|
63382
63585
|
var init_jsonl_cache = __esm(async () => {
|
|
63383
63586
|
await __promiseAll([
|
|
63384
63587
|
init_claude_settings(),
|
|
63385
63588
|
init_jsonl_blocks()
|
|
63386
63589
|
]);
|
|
63387
|
-
|
|
63388
|
-
|
|
63389
|
-
|
|
63390
|
-
existsSync6 =
|
|
63590
|
+
readFileSync9 = fs7.readFileSync;
|
|
63591
|
+
writeFileSync5 = fs7.writeFileSync;
|
|
63592
|
+
mkdirSync5 = fs7.mkdirSync;
|
|
63593
|
+
existsSync6 = fs7.existsSync;
|
|
63391
63594
|
});
|
|
63392
63595
|
|
|
63393
63596
|
// src/utils/jsonl-metrics.ts
|
|
63394
|
-
import * as
|
|
63395
|
-
import
|
|
63597
|
+
import * as fs8 from "fs";
|
|
63598
|
+
import path7 from "node:path";
|
|
63396
63599
|
function collectAgentIds(value, agentIds) {
|
|
63397
63600
|
if (!value || typeof value !== "object") {
|
|
63398
63601
|
return;
|
|
@@ -63424,7 +63627,7 @@ function getReferencedSubagentIds(lines) {
|
|
|
63424
63627
|
}
|
|
63425
63628
|
async function getSessionDuration(transcriptPath) {
|
|
63426
63629
|
try {
|
|
63427
|
-
if (!
|
|
63630
|
+
if (!fs8.existsSync(transcriptPath)) {
|
|
63428
63631
|
return null;
|
|
63429
63632
|
}
|
|
63430
63633
|
const lines = await readJsonlLines(transcriptPath);
|
|
@@ -63474,7 +63677,7 @@ async function getSessionDuration(transcriptPath) {
|
|
|
63474
63677
|
}
|
|
63475
63678
|
async function getTokenMetrics(transcriptPath) {
|
|
63476
63679
|
try {
|
|
63477
|
-
if (!
|
|
63680
|
+
if (!fs8.existsSync(transcriptPath)) {
|
|
63478
63681
|
return { inputTokens: 0, outputTokens: 0, cachedTokens: 0, totalTokens: 0, contextLength: 0 };
|
|
63479
63682
|
}
|
|
63480
63683
|
const lines = await readJsonlLines(transcriptPath);
|
|
@@ -63688,20 +63891,20 @@ function getSubagentTranscriptPaths(transcriptPath, referencedAgentIds) {
|
|
|
63688
63891
|
if (referencedAgentIds.size === 0) {
|
|
63689
63892
|
return [];
|
|
63690
63893
|
}
|
|
63691
|
-
const transcriptDir =
|
|
63692
|
-
const transcriptStem =
|
|
63894
|
+
const transcriptDir = path7.dirname(transcriptPath);
|
|
63895
|
+
const transcriptStem = path7.parse(transcriptPath).name;
|
|
63693
63896
|
const candidateDirs = [
|
|
63694
|
-
|
|
63695
|
-
|
|
63897
|
+
path7.join(transcriptDir, "subagents"),
|
|
63898
|
+
path7.join(transcriptDir, transcriptStem, "subagents")
|
|
63696
63899
|
];
|
|
63697
63900
|
const seenPaths = new Set;
|
|
63698
63901
|
const matchedPaths = [];
|
|
63699
63902
|
for (const subagentsDir of candidateDirs) {
|
|
63700
|
-
if (!
|
|
63903
|
+
if (!fs8.existsSync(subagentsDir)) {
|
|
63701
63904
|
continue;
|
|
63702
63905
|
}
|
|
63703
63906
|
try {
|
|
63704
|
-
const dirEntries =
|
|
63907
|
+
const dirEntries = fs8.readdirSync(subagentsDir, { withFileTypes: true });
|
|
63705
63908
|
for (const entry of dirEntries) {
|
|
63706
63909
|
if (!entry.isFile()) {
|
|
63707
63910
|
continue;
|
|
@@ -63713,7 +63916,7 @@ function getSubagentTranscriptPaths(transcriptPath, referencedAgentIds) {
|
|
|
63713
63916
|
if (!referencedAgentIds.has(match[1])) {
|
|
63714
63917
|
continue;
|
|
63715
63918
|
}
|
|
63716
|
-
const fullPath =
|
|
63919
|
+
const fullPath = path7.join(subagentsDir, entry.name);
|
|
63717
63920
|
if (seenPaths.has(fullPath)) {
|
|
63718
63921
|
continue;
|
|
63719
63922
|
}
|
|
@@ -63730,7 +63933,7 @@ async function getSpeedMetricsCollection(transcriptPath, options = {}) {
|
|
|
63730
63933
|
const normalizedWindows = Array.from(new Set((options.windowSeconds ?? []).map((window2) => normalizeWindowSeconds(window2)).filter((window2) => window2 !== null)));
|
|
63731
63934
|
const emptyWindowedMetrics = buildEmptyWindowedMetrics(normalizedWindows);
|
|
63732
63935
|
try {
|
|
63733
|
-
if (!
|
|
63936
|
+
if (!fs8.existsSync(transcriptPath)) {
|
|
63734
63937
|
return {
|
|
63735
63938
|
sessionAverage: createEmptySpeedMetrics(),
|
|
63736
63939
|
windowed: emptyWindowedMetrics
|
|
@@ -64131,7 +64334,7 @@ var init_BlockTimer = __esm(async () => {
|
|
|
64131
64334
|
});
|
|
64132
64335
|
|
|
64133
64336
|
// src/widgets/CurrentWorkingDir.tsx
|
|
64134
|
-
import * as
|
|
64337
|
+
import * as os7 from "node:os";
|
|
64135
64338
|
|
|
64136
64339
|
class CurrentWorkingDirWidget {
|
|
64137
64340
|
getDefaultColor() {
|
|
@@ -64276,27 +64479,27 @@ class CurrentWorkingDirWidget {
|
|
|
64276
64479
|
supportsColors(item) {
|
|
64277
64480
|
return true;
|
|
64278
64481
|
}
|
|
64279
|
-
abbreviateHomeDir(
|
|
64280
|
-
const homeDir =
|
|
64281
|
-
if (
|
|
64482
|
+
abbreviateHomeDir(path8) {
|
|
64483
|
+
const homeDir = os7.homedir();
|
|
64484
|
+
if (path8 === homeDir) {
|
|
64282
64485
|
return "~";
|
|
64283
64486
|
}
|
|
64284
|
-
if (
|
|
64285
|
-
const boundaryChar =
|
|
64487
|
+
if (path8.startsWith(homeDir)) {
|
|
64488
|
+
const boundaryChar = path8[homeDir.length];
|
|
64286
64489
|
if (boundaryChar !== "/" && boundaryChar !== "\\") {
|
|
64287
|
-
return
|
|
64490
|
+
return path8;
|
|
64288
64491
|
}
|
|
64289
|
-
return "~" +
|
|
64492
|
+
return "~" + path8.slice(homeDir.length);
|
|
64290
64493
|
}
|
|
64291
|
-
return
|
|
64494
|
+
return path8;
|
|
64292
64495
|
}
|
|
64293
|
-
abbreviatePath(
|
|
64294
|
-
const homeDir =
|
|
64295
|
-
const useBackslash =
|
|
64496
|
+
abbreviatePath(path8) {
|
|
64497
|
+
const homeDir = os7.homedir();
|
|
64498
|
+
const useBackslash = path8.includes("\\") && !path8.includes("/");
|
|
64296
64499
|
const sep2 = useBackslash ? "\\" : "/";
|
|
64297
|
-
let normalizedPath =
|
|
64298
|
-
if (
|
|
64299
|
-
normalizedPath = "~" +
|
|
64500
|
+
let normalizedPath = path8;
|
|
64501
|
+
if (path8.startsWith(homeDir)) {
|
|
64502
|
+
normalizedPath = "~" + path8.slice(homeDir.length);
|
|
64300
64503
|
}
|
|
64301
64504
|
const parts = normalizedPath.split(/[\\/]+/).filter((part) => part !== "");
|
|
64302
64505
|
const abbreviated = parts.map((part, index) => {
|
|
@@ -64428,6 +64631,7 @@ function runJjArgs(args, context, allowEmpty = false) {
|
|
|
64428
64631
|
const output = execFileSync4("jj", args, {
|
|
64429
64632
|
encoding: "utf8",
|
|
64430
64633
|
stdio: ["pipe", "pipe", "ignore"],
|
|
64634
|
+
windowsHide: true,
|
|
64431
64635
|
...cwd2 ? { cwd: cwd2 } : {}
|
|
64432
64636
|
}).trimEnd();
|
|
64433
64637
|
return allowEmpty || output.length > 0 ? output : null;
|
|
@@ -65065,7 +65269,7 @@ var init_JjRevision = __esm(() => {
|
|
|
65065
65269
|
});
|
|
65066
65270
|
|
|
65067
65271
|
// src/widgets/ClaudeAccountEmail.ts
|
|
65068
|
-
import * as
|
|
65272
|
+
import * as fs9 from "fs";
|
|
65069
65273
|
|
|
65070
65274
|
class ClaudeAccountEmailWidget {
|
|
65071
65275
|
getDefaultColor() {
|
|
@@ -65088,7 +65292,7 @@ class ClaudeAccountEmailWidget {
|
|
|
65088
65292
|
return item.rawValue ? "you@example.com" : "账户: you@example.com";
|
|
65089
65293
|
}
|
|
65090
65294
|
try {
|
|
65091
|
-
const content =
|
|
65295
|
+
const content = fs9.readFileSync(getClaudeJsonPath(), "utf-8");
|
|
65092
65296
|
const data = JSON.parse(content);
|
|
65093
65297
|
const email3 = data.oauthAccount?.emailAddress;
|
|
65094
65298
|
if (typeof email3 !== "string" || email3.length === 0) {
|
|
@@ -65442,7 +65646,7 @@ var init_TotalSpeed = __esm(async () => {
|
|
|
65442
65646
|
|
|
65443
65647
|
// src/widgets/FreeMemory.ts
|
|
65444
65648
|
import { execSync as execSync3 } from "child_process";
|
|
65445
|
-
import
|
|
65649
|
+
import os8 from "os";
|
|
65446
65650
|
function formatBytes(bytes) {
|
|
65447
65651
|
const GB = 1024 ** 3;
|
|
65448
65652
|
const MB = 1024 ** 2;
|
|
@@ -65457,7 +65661,7 @@ function formatBytes(bytes) {
|
|
|
65457
65661
|
}
|
|
65458
65662
|
function getUsedMemoryMacOS() {
|
|
65459
65663
|
try {
|
|
65460
|
-
const output = execSync3("vm_stat", { encoding: "utf8" });
|
|
65664
|
+
const output = execSync3("vm_stat", { encoding: "utf8", windowsHide: true });
|
|
65461
65665
|
const lines = output.split(`
|
|
65462
65666
|
`);
|
|
65463
65667
|
const firstLine = lines[0];
|
|
@@ -65506,12 +65710,12 @@ class FreeMemoryWidget {
|
|
|
65506
65710
|
if (context.isPreview) {
|
|
65507
65711
|
return item.rawValue ? "12.4G/16.0G" : "内存: 12.4G/16.0G";
|
|
65508
65712
|
}
|
|
65509
|
-
const total =
|
|
65713
|
+
const total = os8.totalmem();
|
|
65510
65714
|
let used;
|
|
65511
|
-
if (
|
|
65512
|
-
used = getUsedMemoryMacOS() ?? total -
|
|
65715
|
+
if (os8.platform() === "darwin") {
|
|
65716
|
+
used = getUsedMemoryMacOS() ?? total - os8.freemem();
|
|
65513
65717
|
} else {
|
|
65514
|
-
used = total -
|
|
65718
|
+
used = total - os8.freemem();
|
|
65515
65719
|
}
|
|
65516
65720
|
const value = `${formatBytes(used)}/${formatBytes(total)}`;
|
|
65517
65721
|
return item.rawValue ? value : `内存: ${value}`;
|
|
@@ -65526,7 +65730,7 @@ class FreeMemoryWidget {
|
|
|
65526
65730
|
var init_FreeMemory = () => {};
|
|
65527
65731
|
|
|
65528
65732
|
// src/widgets/SessionName.ts
|
|
65529
|
-
import * as
|
|
65733
|
+
import * as fs10 from "fs";
|
|
65530
65734
|
|
|
65531
65735
|
class SessionNameWidget {
|
|
65532
65736
|
getDefaultColor() {
|
|
@@ -65553,7 +65757,7 @@ class SessionNameWidget {
|
|
|
65553
65757
|
return null;
|
|
65554
65758
|
}
|
|
65555
65759
|
try {
|
|
65556
|
-
const content =
|
|
65760
|
+
const content = fs10.readFileSync(transcriptPath, "utf-8");
|
|
65557
65761
|
const lines = content.split(`
|
|
65558
65762
|
`);
|
|
65559
65763
|
for (let i = lines.length - 1;i >= 0; i--) {
|
|
@@ -68337,11 +68541,11 @@ var init_hooks = __esm(async () => {
|
|
|
68337
68541
|
});
|
|
68338
68542
|
|
|
68339
68543
|
// src/utils/config.ts
|
|
68340
|
-
import * as
|
|
68341
|
-
import * as
|
|
68342
|
-
import * as
|
|
68544
|
+
import * as fs11 from "fs";
|
|
68545
|
+
import * as os9 from "os";
|
|
68546
|
+
import * as path8 from "path";
|
|
68343
68547
|
function initConfigPath(filePath) {
|
|
68344
|
-
settingsPath = filePath ?
|
|
68548
|
+
settingsPath = filePath ? path8.resolve(filePath) : DEFAULT_SETTINGS_PATH;
|
|
68345
68549
|
}
|
|
68346
68550
|
function getConfigPath() {
|
|
68347
68551
|
return settingsPath;
|
|
@@ -68350,13 +68554,13 @@ function isCustomConfigPath() {
|
|
|
68350
68554
|
return settingsPath !== DEFAULT_SETTINGS_PATH;
|
|
68351
68555
|
}
|
|
68352
68556
|
function getSettingsPaths() {
|
|
68353
|
-
const configDir =
|
|
68354
|
-
const parsedPath =
|
|
68557
|
+
const configDir = path8.dirname(settingsPath);
|
|
68558
|
+
const parsedPath = path8.parse(settingsPath);
|
|
68355
68559
|
const backupBaseName = parsedPath.ext ? `${parsedPath.name}.bak` : `${parsedPath.base}.bak`;
|
|
68356
68560
|
return {
|
|
68357
68561
|
configDir,
|
|
68358
68562
|
settingsPath,
|
|
68359
|
-
settingsBackupPath:
|
|
68563
|
+
settingsBackupPath: path8.join(configDir, backupBaseName)
|
|
68360
68564
|
};
|
|
68361
68565
|
}
|
|
68362
68566
|
async function writeSettingsJson(settings, paths) {
|
|
@@ -68365,7 +68569,7 @@ async function writeSettingsJson(settings, paths) {
|
|
|
68365
68569
|
}
|
|
68366
68570
|
async function backupBadSettings(paths) {
|
|
68367
68571
|
try {
|
|
68368
|
-
if (
|
|
68572
|
+
if (fs11.existsSync(paths.settingsPath)) {
|
|
68369
68573
|
const content = await readFile3(paths.settingsPath, "utf-8");
|
|
68370
68574
|
await writeFile(paths.settingsBackupPath, content, "utf-8");
|
|
68371
68575
|
console.error(`Bad settings backed up to ${paths.settingsBackupPath}`);
|
|
@@ -68395,7 +68599,7 @@ async function recoverWithDefaults(paths) {
|
|
|
68395
68599
|
async function loadSettings() {
|
|
68396
68600
|
const paths = getSettingsPaths();
|
|
68397
68601
|
try {
|
|
68398
|
-
if (!
|
|
68602
|
+
if (!fs11.existsSync(paths.settingsPath))
|
|
68399
68603
|
return await writeDefaultSettings(paths);
|
|
68400
68604
|
const content = await readFile3(paths.settingsPath, "utf-8");
|
|
68401
68605
|
let rawData;
|
|
@@ -68446,7 +68650,7 @@ async function saveSettings(settings) {
|
|
|
68446
68650
|
}
|
|
68447
68651
|
async function saveInstallationMetadata(metadata) {
|
|
68448
68652
|
const paths = getSettingsPaths();
|
|
68449
|
-
if (!metadata && !
|
|
68653
|
+
if (!metadata && !fs11.existsSync(paths.settingsPath)) {
|
|
68450
68654
|
return;
|
|
68451
68655
|
}
|
|
68452
68656
|
const settings = await loadSettings();
|
|
@@ -68466,18 +68670,18 @@ var init_config = __esm(async () => {
|
|
|
68466
68670
|
init_Settings();
|
|
68467
68671
|
init_migrations();
|
|
68468
68672
|
await init_widgets2();
|
|
68469
|
-
readFile3 =
|
|
68470
|
-
writeFile =
|
|
68471
|
-
mkdir =
|
|
68472
|
-
DEFAULT_SETTINGS_PATH =
|
|
68673
|
+
readFile3 = fs11.promises.readFile;
|
|
68674
|
+
writeFile = fs11.promises.writeFile;
|
|
68675
|
+
mkdir = fs11.promises.mkdir;
|
|
68676
|
+
DEFAULT_SETTINGS_PATH = path8.join(os9.homedir(), ".config", "ccstatusline", "settings.json");
|
|
68473
68677
|
settingsPath = DEFAULT_SETTINGS_PATH;
|
|
68474
68678
|
});
|
|
68475
68679
|
|
|
68476
68680
|
// src/utils/claude-settings.ts
|
|
68477
68681
|
import { execSync as execSync4 } from "child_process";
|
|
68478
|
-
import * as
|
|
68479
|
-
import * as
|
|
68480
|
-
import * as
|
|
68682
|
+
import * as fs12 from "fs";
|
|
68683
|
+
import * as os10 from "os";
|
|
68684
|
+
import * as path9 from "path";
|
|
68481
68685
|
function isKnownCommand(command) {
|
|
68482
68686
|
const prefixes = [CCSTATUSLINE_COMMANDS.AUTO_NPX, CCSTATUSLINE_COMMANDS.AUTO_BUNX, CCSTATUSLINE_COMMANDS.GLOBAL];
|
|
68483
68687
|
return prefixes.some((prefix) => command === prefix || command.startsWith(`${prefix} --config `)) || /(?:^|[\s"'\\/])ccstatusline\.ts(?=$|[\s"'])/.test(command);
|
|
@@ -68501,9 +68705,9 @@ function getClaudeConfigDir() {
|
|
|
68501
68705
|
const envConfigDir = process.env.CLAUDE_CONFIG_DIR;
|
|
68502
68706
|
if (envConfigDir) {
|
|
68503
68707
|
try {
|
|
68504
|
-
const resolvedPath =
|
|
68505
|
-
if (
|
|
68506
|
-
const stats =
|
|
68708
|
+
const resolvedPath = path9.resolve(envConfigDir);
|
|
68709
|
+
if (fs12.existsSync(resolvedPath)) {
|
|
68710
|
+
const stats = fs12.statSync(resolvedPath);
|
|
68507
68711
|
if (stats.isDirectory()) {
|
|
68508
68712
|
return resolvedPath;
|
|
68509
68713
|
}
|
|
@@ -68512,24 +68716,24 @@ function getClaudeConfigDir() {
|
|
|
68512
68716
|
}
|
|
68513
68717
|
} catch {}
|
|
68514
68718
|
}
|
|
68515
|
-
return
|
|
68719
|
+
return path9.join(os10.homedir(), ".claude");
|
|
68516
68720
|
}
|
|
68517
68721
|
function getClaudeJsonPath() {
|
|
68518
68722
|
const configDir = getClaudeConfigDir();
|
|
68519
68723
|
const envConfigDir = process.env.CLAUDE_CONFIG_DIR;
|
|
68520
|
-
if (envConfigDir && configDir ===
|
|
68521
|
-
return
|
|
68724
|
+
if (envConfigDir && configDir === path9.resolve(envConfigDir)) {
|
|
68725
|
+
return path9.join(configDir, ".claude.json");
|
|
68522
68726
|
}
|
|
68523
|
-
return
|
|
68727
|
+
return path9.join(path9.dirname(configDir), ".claude.json");
|
|
68524
68728
|
}
|
|
68525
68729
|
function getClaudeSettingsPath() {
|
|
68526
|
-
return
|
|
68730
|
+
return path9.join(getClaudeConfigDir(), "settings.json");
|
|
68527
68731
|
}
|
|
68528
68732
|
async function backupClaudeSettings(suffix = ".bak") {
|
|
68529
68733
|
const settingsPath2 = getClaudeSettingsPath();
|
|
68530
68734
|
const backupPath = settingsPath2 + suffix;
|
|
68531
68735
|
try {
|
|
68532
|
-
if (
|
|
68736
|
+
if (fs12.existsSync(settingsPath2)) {
|
|
68533
68737
|
const content = await readFile4(settingsPath2, "utf-8");
|
|
68534
68738
|
await writeFile2(backupPath, content, "utf-8");
|
|
68535
68739
|
return backupPath;
|
|
@@ -68542,11 +68746,11 @@ async function backupClaudeSettings(suffix = ".bak") {
|
|
|
68542
68746
|
function loadClaudeSettingsSync(options = {}) {
|
|
68543
68747
|
const { logErrors = true } = options;
|
|
68544
68748
|
const settingsPath2 = getClaudeSettingsPath();
|
|
68545
|
-
if (!
|
|
68749
|
+
if (!fs12.existsSync(settingsPath2)) {
|
|
68546
68750
|
return {};
|
|
68547
68751
|
}
|
|
68548
68752
|
try {
|
|
68549
|
-
const content =
|
|
68753
|
+
const content = fs12.readFileSync(settingsPath2, "utf-8");
|
|
68550
68754
|
return JSON.parse(content);
|
|
68551
68755
|
} catch (error51) {
|
|
68552
68756
|
if (logErrors) {
|
|
@@ -68558,7 +68762,7 @@ function loadClaudeSettingsSync(options = {}) {
|
|
|
68558
68762
|
async function loadClaudeSettings(options = {}) {
|
|
68559
68763
|
const { logErrors = true } = options;
|
|
68560
68764
|
const settingsPath2 = getClaudeSettingsPath();
|
|
68561
|
-
if (!
|
|
68765
|
+
if (!fs12.existsSync(settingsPath2)) {
|
|
68562
68766
|
return {};
|
|
68563
68767
|
}
|
|
68564
68768
|
try {
|
|
@@ -68573,7 +68777,7 @@ async function loadClaudeSettings(options = {}) {
|
|
|
68573
68777
|
}
|
|
68574
68778
|
async function saveClaudeSettings(settings) {
|
|
68575
68779
|
const settingsPath2 = getClaudeSettingsPath();
|
|
68576
|
-
const dir =
|
|
68780
|
+
const dir = path9.dirname(settingsPath2);
|
|
68577
68781
|
await backupClaudeSettings();
|
|
68578
68782
|
await mkdir2(dir, { recursive: true });
|
|
68579
68783
|
await writeFile2(settingsPath2, JSON.stringify(settings, null, 2), "utf-8");
|
|
@@ -68591,7 +68795,7 @@ async function isInstalled() {
|
|
|
68591
68795
|
function isExecutableAvailable(executable) {
|
|
68592
68796
|
try {
|
|
68593
68797
|
const command = process.platform === "win32" ? `where ${executable}` : `which ${executable}`;
|
|
68594
|
-
execSync4(command, { stdio: "ignore" });
|
|
68798
|
+
execSync4(command, { stdio: "ignore", windowsHide: true });
|
|
68595
68799
|
return true;
|
|
68596
68800
|
} catch {
|
|
68597
68801
|
return false;
|
|
@@ -68619,7 +68823,12 @@ function getPackageCommandAvailability() {
|
|
|
68619
68823
|
}
|
|
68620
68824
|
function getClaudeCodeVersion() {
|
|
68621
68825
|
try {
|
|
68622
|
-
const output = execSync4("claude --version", {
|
|
68826
|
+
const output = execSync4("claude --version", {
|
|
68827
|
+
encoding: "utf-8",
|
|
68828
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
68829
|
+
timeout: 5000,
|
|
68830
|
+
windowsHide: true
|
|
68831
|
+
}).trim();
|
|
68623
68832
|
const match = /^(\d+\.\d+\.\d+)/.exec(output);
|
|
68624
68833
|
return match?.[1] ?? null;
|
|
68625
68834
|
} catch {
|
|
@@ -68706,7 +68915,7 @@ function classifyInstallation(command, metadata) {
|
|
|
68706
68915
|
}
|
|
68707
68916
|
async function loadSavedSettingsForHookSync() {
|
|
68708
68917
|
const configPath = getConfigPath();
|
|
68709
|
-
if (!
|
|
68918
|
+
if (!fs12.existsSync(configPath)) {
|
|
68710
68919
|
return null;
|
|
68711
68920
|
}
|
|
68712
68921
|
try {
|
|
@@ -68807,19 +69016,19 @@ async function setRefreshInterval(interval) {
|
|
|
68807
69016
|
}
|
|
68808
69017
|
function getVoiceConfigCandidatePathsByPriority(cwd2) {
|
|
68809
69018
|
const userDir = getClaudeConfigDir();
|
|
68810
|
-
const projectDir =
|
|
69019
|
+
const projectDir = path9.join(cwd2, ".claude");
|
|
68811
69020
|
const candidates = [
|
|
68812
|
-
|
|
68813
|
-
|
|
68814
|
-
|
|
68815
|
-
|
|
69021
|
+
path9.join(projectDir, "settings.local.json"),
|
|
69022
|
+
path9.join(projectDir, "settings.json"),
|
|
69023
|
+
path9.join(userDir, "settings.local.json"),
|
|
69024
|
+
path9.join(userDir, "settings.json")
|
|
68816
69025
|
];
|
|
68817
69026
|
return Array.from(new Set(candidates));
|
|
68818
69027
|
}
|
|
68819
69028
|
function tryReadVoiceLayer(filePath) {
|
|
68820
69029
|
let content;
|
|
68821
69030
|
try {
|
|
68822
|
-
content =
|
|
69031
|
+
content = fs12.readFileSync(filePath, "utf-8");
|
|
68823
69032
|
} catch (error51) {
|
|
68824
69033
|
const isMissing = error51.code === "ENOENT";
|
|
68825
69034
|
return { fileExisted: !isMissing, enabled: undefined };
|
|
@@ -68854,9 +69063,9 @@ var init_claude_settings = __esm(async () => {
|
|
|
68854
69063
|
init_zod();
|
|
68855
69064
|
init_Settings();
|
|
68856
69065
|
await init_config();
|
|
68857
|
-
readFile4 =
|
|
68858
|
-
writeFile2 =
|
|
68859
|
-
mkdir2 =
|
|
69066
|
+
readFile4 = fs12.promises.readFile;
|
|
69067
|
+
writeFile2 = fs12.promises.writeFile;
|
|
69068
|
+
mkdir2 = fs12.promises.mkdir;
|
|
68860
69069
|
CCSTATUSLINE_COMMANDS = {
|
|
68861
69070
|
AUTO_NPX: "npx -y ccstatusline-zh@latest",
|
|
68862
69071
|
AUTO_BUNX: "bunx -y ccstatusline-zh@latest",
|
|
@@ -69458,7 +69667,7 @@ await init_config();
|
|
|
69458
69667
|
|
|
69459
69668
|
// src/utils/global-command-resolution.ts
|
|
69460
69669
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
69461
|
-
import * as
|
|
69670
|
+
import * as path10 from "path";
|
|
69462
69671
|
|
|
69463
69672
|
// src/utils/package-manager-executable.ts
|
|
69464
69673
|
function getPackageManagerExecutable(packageManager, platform2 = process.platform) {
|
|
@@ -69485,11 +69694,19 @@ function isTransientBunxStatusLinePath(filePath) {
|
|
|
69485
69694
|
return /(?:^|\/)bunx-[^/]*ccstatusline-zh@[^/]+\/node_modules\/\.bin\/ccstatusline-zh(?:\.(?:cmd|ps1))?$/i.test(normalized);
|
|
69486
69695
|
}
|
|
69487
69696
|
function getPersistentCommandResolutionPaths(paths) {
|
|
69488
|
-
return paths.filter((
|
|
69697
|
+
return paths.filter((path11) => !isTransientBunxStatusLinePath(path11));
|
|
69489
69698
|
}
|
|
69490
69699
|
function getCommandResolutionPaths(command, { platform: platform2 = process.platform } = {}) {
|
|
69491
69700
|
try {
|
|
69492
|
-
const output = platform2 === "win32" ? execFileSync5("where", [command], {
|
|
69701
|
+
const output = platform2 === "win32" ? execFileSync5("where", [command], {
|
|
69702
|
+
encoding: "utf-8",
|
|
69703
|
+
timeout: COMMAND_LOOKUP_TIMEOUT_MS,
|
|
69704
|
+
windowsHide: true
|
|
69705
|
+
}) : execFileSync5("which", ["-a", command], {
|
|
69706
|
+
encoding: "utf-8",
|
|
69707
|
+
timeout: COMMAND_LOOKUP_TIMEOUT_MS,
|
|
69708
|
+
windowsHide: true
|
|
69709
|
+
});
|
|
69493
69710
|
return splitCommandOutput(output);
|
|
69494
69711
|
} catch {
|
|
69495
69712
|
return [];
|
|
@@ -69499,12 +69716,13 @@ function getNpmGlobalBinDir(platform2) {
|
|
|
69499
69716
|
try {
|
|
69500
69717
|
const prefix = execFileSync5(getPackageManagerExecutable("npm", platform2), ["prefix", "-g"], {
|
|
69501
69718
|
encoding: "utf-8",
|
|
69502
|
-
timeout: COMMAND_LOOKUP_TIMEOUT_MS
|
|
69719
|
+
timeout: COMMAND_LOOKUP_TIMEOUT_MS,
|
|
69720
|
+
windowsHide: true
|
|
69503
69721
|
}).trim();
|
|
69504
69722
|
if (!prefix) {
|
|
69505
69723
|
return null;
|
|
69506
69724
|
}
|
|
69507
|
-
return platform2 === "win32" || /^[a-z]:[\\/]/i.test(prefix) ? prefix :
|
|
69725
|
+
return platform2 === "win32" || /^[a-z]:[\\/]/i.test(prefix) ? prefix : path10.join(prefix, "bin");
|
|
69508
69726
|
} catch {
|
|
69509
69727
|
return null;
|
|
69510
69728
|
}
|
|
@@ -69513,7 +69731,8 @@ function getBunGlobalBinDir() {
|
|
|
69513
69731
|
try {
|
|
69514
69732
|
const binDir = execFileSync5("bun", ["pm", "bin", "-g"], {
|
|
69515
69733
|
encoding: "utf-8",
|
|
69516
|
-
timeout: COMMAND_LOOKUP_TIMEOUT_MS
|
|
69734
|
+
timeout: COMMAND_LOOKUP_TIMEOUT_MS,
|
|
69735
|
+
windowsHide: true
|
|
69517
69736
|
}).trim();
|
|
69518
69737
|
return binDir || null;
|
|
69519
69738
|
} catch {
|
|
@@ -69607,7 +69826,7 @@ import {
|
|
|
69607
69826
|
execFile,
|
|
69608
69827
|
execFileSync as execFileSync6
|
|
69609
69828
|
} from "child_process";
|
|
69610
|
-
import * as
|
|
69829
|
+
import * as fs13 from "fs";
|
|
69611
69830
|
var GLOBAL_PACKAGE_TIMEOUT_MS = 120000;
|
|
69612
69831
|
var VERSION_LOOKUP_TIMEOUT_MS = 5000;
|
|
69613
69832
|
var WINDOWS_SHIM_EXTENSIONS = [
|
|
@@ -69656,7 +69875,7 @@ function getBinaryPathCandidates(binDir, platform2) {
|
|
|
69656
69875
|
return extensions.map((extension) => appendPathSegment(binDir, `ccstatusline-zh${extension}`));
|
|
69657
69876
|
}
|
|
69658
69877
|
function hasBinaryOnDisk(binDir, platform2) {
|
|
69659
|
-
return getBinaryPathCandidates(binDir, platform2).some((candidate) => getFilesystemPathVariants(candidate).some((variant) =>
|
|
69878
|
+
return getBinaryPathCandidates(binDir, platform2).some((candidate) => getFilesystemPathVariants(candidate).some((variant) => fs13.existsSync(variant)));
|
|
69660
69879
|
}
|
|
69661
69880
|
function hasResolvedBinaryInDir(resolvedPaths, binDir) {
|
|
69662
69881
|
return resolvedPaths.some((resolvedPath) => isPathInsideDir(resolvedPath, binDir));
|
|
@@ -69689,10 +69908,10 @@ function formatPathList2(paths) {
|
|
|
69689
69908
|
function readPackageVersion(packageJsonPath) {
|
|
69690
69909
|
for (const variant of getFilesystemPathVariants(packageJsonPath)) {
|
|
69691
69910
|
try {
|
|
69692
|
-
if (!
|
|
69911
|
+
if (!fs13.existsSync(variant)) {
|
|
69693
69912
|
continue;
|
|
69694
69913
|
}
|
|
69695
|
-
const packageJson = JSON.parse(
|
|
69914
|
+
const packageJson = JSON.parse(fs13.readFileSync(variant, "utf-8"));
|
|
69696
69915
|
return typeof packageJson.version === "string" ? packageJson.version : null;
|
|
69697
69916
|
} catch {
|
|
69698
69917
|
return null;
|
|
@@ -69704,7 +69923,8 @@ function getNpmGlobalPackageVersion(platform2) {
|
|
|
69704
69923
|
try {
|
|
69705
69924
|
const rootDir = execFileSync6(getPackageManagerExecutable("npm", platform2), ["root", "-g"], {
|
|
69706
69925
|
encoding: "utf-8",
|
|
69707
|
-
timeout: VERSION_LOOKUP_TIMEOUT_MS
|
|
69926
|
+
timeout: VERSION_LOOKUP_TIMEOUT_MS,
|
|
69927
|
+
windowsHide: true
|
|
69708
69928
|
}).trim();
|
|
69709
69929
|
return rootDir ? readPackageVersion(appendPathSegment(appendPathSegment(rootDir, "ccstatusline-zh"), "package.json")) : null;
|
|
69710
69930
|
} catch {
|
|
@@ -69810,20 +70030,20 @@ function inspectGlobalPackageInstallations({
|
|
|
69810
70030
|
function runGlobalPackageUninstall(packageManager, { platform: platform2 = process.platform } = {}) {
|
|
69811
70031
|
const executable = getPackageManagerExecutable(packageManager, platform2);
|
|
69812
70032
|
const args = packageManager === "npm" ? ["uninstall", "-g", "ccstatusline-zh"] : ["remove", "-g", "ccstatusline-zh"];
|
|
69813
|
-
return new Promise((
|
|
69814
|
-
execFile(executable, args, { timeout: GLOBAL_PACKAGE_TIMEOUT_MS }, (error51) => {
|
|
70033
|
+
return new Promise((resolve6, reject2) => {
|
|
70034
|
+
execFile(executable, args, { timeout: GLOBAL_PACKAGE_TIMEOUT_MS, windowsHide: true }, (error51) => {
|
|
69815
70035
|
if (error51) {
|
|
69816
70036
|
reject2(error51 instanceof Error ? error51 : new Error("全局卸载命令执行失败"));
|
|
69817
70037
|
return;
|
|
69818
70038
|
}
|
|
69819
|
-
|
|
70039
|
+
resolve6();
|
|
69820
70040
|
});
|
|
69821
70041
|
});
|
|
69822
70042
|
}
|
|
69823
70043
|
|
|
69824
70044
|
// src/utils/open-url.ts
|
|
69825
70045
|
import { spawnSync } from "child_process";
|
|
69826
|
-
import * as
|
|
70046
|
+
import * as os11 from "os";
|
|
69827
70047
|
function runOpenCommand(command, args) {
|
|
69828
70048
|
const result2 = spawnSync(command, args, {
|
|
69829
70049
|
stdio: "ignore",
|
|
@@ -69882,7 +70102,7 @@ function openExternalUrl(url2) {
|
|
|
69882
70102
|
error: "Only http(s) URLs are supported"
|
|
69883
70103
|
};
|
|
69884
70104
|
}
|
|
69885
|
-
const platform3 =
|
|
70105
|
+
const platform3 = os11.platform();
|
|
69886
70106
|
const plans = PLATFORM_OPEN_PLANS[platform3];
|
|
69887
70107
|
if (!plans) {
|
|
69888
70108
|
return {
|
|
@@ -69910,9 +70130,9 @@ function openExternalUrl(url2) {
|
|
|
69910
70130
|
|
|
69911
70131
|
// src/utils/powerline.ts
|
|
69912
70132
|
import { execSync as execSync5 } from "child_process";
|
|
69913
|
-
import * as
|
|
69914
|
-
import * as
|
|
69915
|
-
import * as
|
|
70133
|
+
import * as fs14 from "fs";
|
|
70134
|
+
import * as os12 from "os";
|
|
70135
|
+
import * as path11 from "path";
|
|
69916
70136
|
var fontsInstalledThisSession = false;
|
|
69917
70137
|
function checkPowerlineFonts() {
|
|
69918
70138
|
if (process.env.DEBUG_FONT_INSTALL === "1" && !fontsInstalledThisSession) {
|
|
@@ -69928,24 +70148,24 @@ function checkPowerlineFonts() {
|
|
|
69928
70148
|
leftArrow: "",
|
|
69929
70149
|
leftThinArrow: ""
|
|
69930
70150
|
};
|
|
69931
|
-
const platform4 =
|
|
70151
|
+
const platform4 = os12.platform();
|
|
69932
70152
|
let fontPaths = [];
|
|
69933
70153
|
if (platform4 === "darwin") {
|
|
69934
70154
|
fontPaths = [
|
|
69935
|
-
|
|
70155
|
+
path11.join(os12.homedir(), "Library", "Fonts"),
|
|
69936
70156
|
"/Library/Fonts",
|
|
69937
70157
|
"/System/Library/Fonts"
|
|
69938
70158
|
];
|
|
69939
70159
|
} else if (platform4 === "linux") {
|
|
69940
70160
|
fontPaths = [
|
|
69941
|
-
|
|
69942
|
-
|
|
70161
|
+
path11.join(os12.homedir(), ".local", "share", "fonts"),
|
|
70162
|
+
path11.join(os12.homedir(), ".fonts"),
|
|
69943
70163
|
"/usr/share/fonts",
|
|
69944
70164
|
"/usr/local/share/fonts"
|
|
69945
70165
|
];
|
|
69946
70166
|
} else if (platform4 === "win32") {
|
|
69947
70167
|
fontPaths = [
|
|
69948
|
-
|
|
70168
|
+
path11.join(os12.homedir(), "AppData", "Local", "Microsoft", "Windows", "Fonts"),
|
|
69949
70169
|
"C:\\Windows\\Fonts"
|
|
69950
70170
|
];
|
|
69951
70171
|
}
|
|
@@ -69961,9 +70181,9 @@ function checkPowerlineFonts() {
|
|
|
69961
70181
|
/fira.*code.*nerd/i
|
|
69962
70182
|
];
|
|
69963
70183
|
for (const fontPath of fontPaths) {
|
|
69964
|
-
if (
|
|
70184
|
+
if (fs14.existsSync(fontPath)) {
|
|
69965
70185
|
try {
|
|
69966
|
-
const files =
|
|
70186
|
+
const files = fs14.readdirSync(fontPath);
|
|
69967
70187
|
for (const file2 of files) {
|
|
69968
70188
|
for (const pattern of powerlineFontPatterns) {
|
|
69969
70189
|
if (pattern.test(file2)) {
|
|
@@ -69998,13 +70218,16 @@ async function checkPowerlineFontsAsync() {
|
|
|
69998
70218
|
if (quickCheck.installed) {
|
|
69999
70219
|
return quickCheck;
|
|
70000
70220
|
}
|
|
70001
|
-
const platform4 =
|
|
70221
|
+
const platform4 = os12.platform();
|
|
70002
70222
|
if (platform4 === "linux" || platform4 === "darwin") {
|
|
70003
70223
|
try {
|
|
70004
70224
|
const { exec: exec2 } = await import("child_process");
|
|
70005
70225
|
const { promisify: promisify2 } = await import("util");
|
|
70006
70226
|
const execAsync = promisify2(exec2);
|
|
70007
|
-
const { stdout } = await execAsync("fc-list 2>/dev/null | grep -i powerline", {
|
|
70227
|
+
const { stdout } = await execAsync("fc-list 2>/dev/null | grep -i powerline", {
|
|
70228
|
+
encoding: "utf8",
|
|
70229
|
+
windowsHide: true
|
|
70230
|
+
});
|
|
70008
70231
|
if (stdout.trim()) {
|
|
70009
70232
|
return {
|
|
70010
70233
|
installed: true,
|
|
@@ -70021,46 +70244,49 @@ async function checkPowerlineFontsAsync() {
|
|
|
70021
70244
|
async function installPowerlineFonts() {
|
|
70022
70245
|
await Promise.resolve();
|
|
70023
70246
|
try {
|
|
70024
|
-
const platform4 =
|
|
70247
|
+
const platform4 = os12.platform();
|
|
70025
70248
|
let fontDir;
|
|
70026
70249
|
if (platform4 === "darwin") {
|
|
70027
|
-
fontDir =
|
|
70250
|
+
fontDir = path11.join(os12.homedir(), "Library", "Fonts");
|
|
70028
70251
|
} else if (platform4 === "linux") {
|
|
70029
|
-
fontDir =
|
|
70252
|
+
fontDir = path11.join(os12.homedir(), ".local", "share", "fonts");
|
|
70030
70253
|
} else if (platform4 === "win32") {
|
|
70031
|
-
fontDir =
|
|
70254
|
+
fontDir = path11.join(os12.homedir(), "AppData", "Local", "Microsoft", "Windows", "Fonts");
|
|
70032
70255
|
} else {
|
|
70033
70256
|
return {
|
|
70034
70257
|
success: false,
|
|
70035
70258
|
message: "Unsupported platform for font installation"
|
|
70036
70259
|
};
|
|
70037
70260
|
}
|
|
70038
|
-
if (!
|
|
70039
|
-
|
|
70261
|
+
if (!fs14.existsSync(fontDir)) {
|
|
70262
|
+
fs14.mkdirSync(fontDir, { recursive: true });
|
|
70040
70263
|
}
|
|
70041
|
-
const tempDir =
|
|
70264
|
+
const tempDir = path11.join(os12.tmpdir(), `ccstatusline-powerline-fonts-${Date.now()}`);
|
|
70042
70265
|
try {
|
|
70043
|
-
if (
|
|
70044
|
-
|
|
70266
|
+
if (fs14.existsSync(tempDir)) {
|
|
70267
|
+
fs14.rmSync(tempDir, { recursive: true, force: true });
|
|
70045
70268
|
}
|
|
70046
70269
|
execSync5(`git clone --depth=1 https://github.com/powerline/fonts.git "${tempDir}"`, {
|
|
70047
70270
|
stdio: "pipe",
|
|
70048
|
-
encoding: "utf8"
|
|
70271
|
+
encoding: "utf8",
|
|
70272
|
+
windowsHide: true
|
|
70049
70273
|
});
|
|
70050
70274
|
if (platform4 === "darwin" || platform4 === "linux") {
|
|
70051
|
-
const installScript =
|
|
70052
|
-
if (
|
|
70053
|
-
|
|
70275
|
+
const installScript = path11.join(tempDir, "install.sh");
|
|
70276
|
+
if (fs14.existsSync(installScript)) {
|
|
70277
|
+
fs14.chmodSync(installScript, 493);
|
|
70054
70278
|
execSync5(`cd "${tempDir}" && ./install.sh`, {
|
|
70055
70279
|
stdio: "pipe",
|
|
70056
70280
|
encoding: "utf8",
|
|
70057
|
-
shell: "/bin/bash"
|
|
70281
|
+
shell: "/bin/bash",
|
|
70282
|
+
windowsHide: true
|
|
70058
70283
|
});
|
|
70059
70284
|
if (platform4 === "linux") {
|
|
70060
70285
|
try {
|
|
70061
70286
|
execSync5("fc-cache -f -v", {
|
|
70062
70287
|
stdio: "pipe",
|
|
70063
|
-
encoding: "utf8"
|
|
70288
|
+
encoding: "utf8",
|
|
70289
|
+
windowsHide: true
|
|
70064
70290
|
});
|
|
70065
70291
|
} catch {}
|
|
70066
70292
|
}
|
|
@@ -70076,10 +70302,10 @@ async function installPowerlineFonts() {
|
|
|
70076
70302
|
}
|
|
70077
70303
|
} else {
|
|
70078
70304
|
let findFontFiles = function(dir) {
|
|
70079
|
-
const files =
|
|
70305
|
+
const files = fs14.readdirSync(dir);
|
|
70080
70306
|
for (const file2 of files) {
|
|
70081
|
-
const filePath =
|
|
70082
|
-
const stat2 =
|
|
70307
|
+
const filePath = path11.join(dir, file2);
|
|
70308
|
+
const stat2 = fs14.statSync(filePath);
|
|
70083
70309
|
if (stat2.isDirectory() && !file2.startsWith(".")) {
|
|
70084
70310
|
findFontFiles(filePath);
|
|
70085
70311
|
} else if (file2.endsWith(".ttf") || file2.endsWith(".otf")) {
|
|
@@ -70093,10 +70319,10 @@ async function installPowerlineFonts() {
|
|
|
70093
70319
|
findFontFiles(tempDir);
|
|
70094
70320
|
let installedCount = 0;
|
|
70095
70321
|
for (const fontFile of fontFiles) {
|
|
70096
|
-
const fileName =
|
|
70097
|
-
const destPath =
|
|
70322
|
+
const fileName = path11.basename(fontFile);
|
|
70323
|
+
const destPath = path11.join(fontDir, fileName);
|
|
70098
70324
|
try {
|
|
70099
|
-
|
|
70325
|
+
fs14.copyFileSync(fontFile, destPath);
|
|
70100
70326
|
installedCount++;
|
|
70101
70327
|
} catch {}
|
|
70102
70328
|
}
|
|
@@ -70114,9 +70340,9 @@ async function installPowerlineFonts() {
|
|
|
70114
70340
|
message: "Platform-specific installation not implemented"
|
|
70115
70341
|
};
|
|
70116
70342
|
} finally {
|
|
70117
|
-
if (
|
|
70343
|
+
if (fs14.existsSync(tempDir)) {
|
|
70118
70344
|
try {
|
|
70119
|
-
|
|
70345
|
+
fs14.rmSync(tempDir, { recursive: true, force: true });
|
|
70120
70346
|
} catch {}
|
|
70121
70347
|
}
|
|
70122
70348
|
}
|
|
@@ -70282,7 +70508,7 @@ async function checkForUpdates({
|
|
|
70282
70508
|
}
|
|
70283
70509
|
}
|
|
70284
70510
|
function fetchLatestNpmVersion(timeoutMs = DEFAULT_REGISTRY_TIMEOUT_MS) {
|
|
70285
|
-
return new Promise((
|
|
70511
|
+
return new Promise((resolve6, reject2) => {
|
|
70286
70512
|
const request3 = https2.request(NPM_REGISTRY_LATEST_URL, {
|
|
70287
70513
|
headers: {
|
|
70288
70514
|
Accept: "application/json",
|
|
@@ -70306,7 +70532,7 @@ function fetchLatestNpmVersion(timeoutMs = DEFAULT_REGISTRY_TIMEOUT_MS) {
|
|
|
70306
70532
|
reject2(new Error("npm 仓库响应中未包含版本号"));
|
|
70307
70533
|
return;
|
|
70308
70534
|
}
|
|
70309
|
-
|
|
70535
|
+
resolve6(parsed.version);
|
|
70310
70536
|
} catch (error51) {
|
|
70311
70537
|
reject2(error51 instanceof Error ? error51 : new Error(String(error51)));
|
|
70312
70538
|
}
|
|
@@ -70322,13 +70548,13 @@ function fetchLatestNpmVersion(timeoutMs = DEFAULT_REGISTRY_TIMEOUT_MS) {
|
|
|
70322
70548
|
function runGlobalPackageInstall(packageManager, version2, { platform: platform4 = process.platform } = {}) {
|
|
70323
70549
|
const executable = getPackageManagerExecutable(packageManager, platform4);
|
|
70324
70550
|
const args = packageManager === "npm" ? ["install", "-g", `ccstatusline-zh@${version2}`] : ["add", "-g", `ccstatusline-zh@${version2}`];
|
|
70325
|
-
return new Promise((
|
|
70326
|
-
execFile2(executable, args, { timeout: GLOBAL_UPDATE_TIMEOUT_MS }, (error51) => {
|
|
70551
|
+
return new Promise((resolve6, reject2) => {
|
|
70552
|
+
execFile2(executable, args, { timeout: GLOBAL_UPDATE_TIMEOUT_MS, windowsHide: true }, (error51) => {
|
|
70327
70553
|
if (error51) {
|
|
70328
70554
|
reject2(error51 instanceof Error ? error51 : new Error("全局更新命令执行失败"));
|
|
70329
70555
|
return;
|
|
70330
70556
|
}
|
|
70331
|
-
|
|
70557
|
+
resolve6();
|
|
70332
70558
|
});
|
|
70333
70559
|
});
|
|
70334
70560
|
}
|
|
@@ -71967,15 +72193,15 @@ function getPinnedDescription(currentVersion) {
|
|
|
71967
72193
|
}
|
|
71968
72194
|
function getStyleItems(currentVersion) {
|
|
71969
72195
|
return [
|
|
71970
|
-
{
|
|
71971
|
-
label: "自动更新",
|
|
71972
|
-
value: "auto-update",
|
|
71973
|
-
description: AUTO_UPDATE_DESCRIPTION
|
|
71974
|
-
},
|
|
71975
72196
|
{
|
|
71976
72197
|
label: "固定全局安装",
|
|
71977
72198
|
value: "pinned",
|
|
71978
72199
|
description: getPinnedDescription(currentVersion)
|
|
72200
|
+
},
|
|
72201
|
+
{
|
|
72202
|
+
label: "自动更新",
|
|
72203
|
+
value: "auto-update",
|
|
72204
|
+
description: AUTO_UPDATE_DESCRIPTION
|
|
71979
72205
|
}
|
|
71980
72206
|
];
|
|
71981
72207
|
}
|
|
@@ -72045,7 +72271,7 @@ var InstallMenu = ({
|
|
|
72045
72271
|
initialPackageSelection = 0
|
|
72046
72272
|
}) => {
|
|
72047
72273
|
const [step, setStep] = import_react41.useState("style");
|
|
72048
|
-
const [updateStyle, setUpdateStyle] = import_react41.useState("
|
|
72274
|
+
const [updateStyle, setUpdateStyle] = import_react41.useState("pinned");
|
|
72049
72275
|
use_input_default((_, key) => {
|
|
72050
72276
|
if (key.escape) {
|
|
72051
72277
|
if (step === "manager") {
|
|
@@ -73670,7 +73896,7 @@ var UninstallMenu = ({
|
|
|
73670
73896
|
// src/tui/components/PowerlineSetup.tsx
|
|
73671
73897
|
await init_build2();
|
|
73672
73898
|
var import_react46 = __toESM(require_react(), 1);
|
|
73673
|
-
import * as
|
|
73899
|
+
import * as os13 from "os";
|
|
73674
73900
|
|
|
73675
73901
|
// src/utils/powerline-settings.ts
|
|
73676
73902
|
init_colors();
|
|
@@ -74438,7 +74664,7 @@ var PowerlineSetup = ({
|
|
|
74438
74664
|
}, undefined, false, undefined, this)
|
|
74439
74665
|
]
|
|
74440
74666
|
}, undefined, true, undefined, this),
|
|
74441
|
-
|
|
74667
|
+
os13.platform() === "darwin" && /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(jsx_dev_runtime21.Fragment, {
|
|
74442
74668
|
children: [
|
|
74443
74669
|
/* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Text, {
|
|
74444
74670
|
dimColor: true,
|
|
@@ -74454,7 +74680,7 @@ var PowerlineSetup = ({
|
|
|
74454
74680
|
}, undefined, false, undefined, this)
|
|
74455
74681
|
]
|
|
74456
74682
|
}, undefined, true, undefined, this),
|
|
74457
|
-
|
|
74683
|
+
os13.platform() === "linux" && /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(jsx_dev_runtime21.Fragment, {
|
|
74458
74684
|
children: [
|
|
74459
74685
|
/* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Text, {
|
|
74460
74686
|
dimColor: true,
|
|
@@ -74470,7 +74696,7 @@ var PowerlineSetup = ({
|
|
|
74470
74696
|
}, undefined, false, undefined, this)
|
|
74471
74697
|
]
|
|
74472
74698
|
}, undefined, true, undefined, this),
|
|
74473
|
-
|
|
74699
|
+
os13.platform() === "win32" && /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(jsx_dev_runtime21.Fragment, {
|
|
74474
74700
|
children: [
|
|
74475
74701
|
/* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Text, {
|
|
74476
74702
|
dimColor: true,
|
|
@@ -74747,7 +74973,10 @@ function getRefreshIntervalSublabel(interval, supported) {
|
|
|
74747
74973
|
}
|
|
74748
74974
|
return `(${interval} 秒)`;
|
|
74749
74975
|
}
|
|
74750
|
-
function
|
|
74976
|
+
function getGitCacheTtlSublabel(ttlSeconds) {
|
|
74977
|
+
return ttlSeconds === 0 ? "(仅 mtime)" : `(${ttlSeconds} 秒)`;
|
|
74978
|
+
}
|
|
74979
|
+
function buildConfigureStatusLineItems(refreshInterval, supportsRefreshInterval, gitCacheTtlSeconds) {
|
|
74751
74980
|
return [
|
|
74752
74981
|
{
|
|
74753
74982
|
label: "\uD83D\uDD04 刷新间隔",
|
|
@@ -74755,6 +74984,13 @@ function buildConfigureStatusLineItems(refreshInterval, supportsRefreshInterval)
|
|
|
74755
74984
|
value: "refreshInterval",
|
|
74756
74985
|
disabled: !supportsRefreshInterval,
|
|
74757
74986
|
description: supportsRefreshInterval ? "Claude Code 重新运行状态栏命令的频率。输入秒数 (1-60),留空即移除。" : "本设置需要 Claude Code 2.1.97 或更高版本。请升级 Claude Code 后再使用。"
|
|
74987
|
+
},
|
|
74988
|
+
{
|
|
74989
|
+
label: "\uD83E\uDDEE Git 缓存 TTL",
|
|
74990
|
+
sublabel: getGitCacheTtlSublabel(gitCacheTtlSeconds),
|
|
74991
|
+
value: "gitCacheTtl",
|
|
74992
|
+
description: `Git 组件子进程输出在 .git/HEAD 与 .git/index 未变动期间可复用的时长。输入 0-60 秒;
|
|
74993
|
+
填 0 关闭按时长过期,缓存输出会一直复用,直到这些 git 元数据 mtime 发生变化。`
|
|
74758
74994
|
}
|
|
74759
74995
|
];
|
|
74760
74996
|
}
|
|
@@ -74774,14 +75010,31 @@ function validateRefreshIntervalInput(value) {
|
|
|
74774
75010
|
}
|
|
74775
75011
|
return null;
|
|
74776
75012
|
}
|
|
75013
|
+
function validateGitCacheTtlInput(value) {
|
|
75014
|
+
const parsed = parseInt(value, 10);
|
|
75015
|
+
if (value === "" || isNaN(parsed)) {
|
|
75016
|
+
return "请输入有效数字";
|
|
75017
|
+
}
|
|
75018
|
+
if (parsed < 0) {
|
|
75019
|
+
return `Git 缓存 TTL 最小为 0 秒(输入了 ${parsed} 秒)`;
|
|
75020
|
+
}
|
|
75021
|
+
if (parsed > 60) {
|
|
75022
|
+
return `Git 缓存 TTL 最大为 60 秒(输入了 ${parsed} 秒)`;
|
|
75023
|
+
}
|
|
75024
|
+
return null;
|
|
75025
|
+
}
|
|
74777
75026
|
var RefreshIntervalMenu = ({
|
|
74778
75027
|
currentInterval,
|
|
74779
75028
|
supportsRefreshInterval,
|
|
75029
|
+
gitCacheTtlSeconds,
|
|
74780
75030
|
onUpdate,
|
|
75031
|
+
onGitCacheTtlUpdate,
|
|
74781
75032
|
onBack
|
|
74782
75033
|
}) => {
|
|
74783
75034
|
const [editingRefreshInterval, setEditingRefreshInterval] = import_react47.useState(false);
|
|
75035
|
+
const [editingGitCacheTtl, setEditingGitCacheTtl] = import_react47.useState(false);
|
|
74784
75036
|
const [refreshInput, setRefreshInput] = import_react47.useState(() => getRefreshInputValue(currentInterval));
|
|
75037
|
+
const [gitCacheTtlInput, setGitCacheTtlInput] = import_react47.useState(() => String(gitCacheTtlSeconds));
|
|
74785
75038
|
const [validationError, setValidationError] = import_react47.useState(null);
|
|
74786
75039
|
use_input_default((input, key) => {
|
|
74787
75040
|
if (editingRefreshInterval) {
|
|
@@ -74817,6 +75070,33 @@ var RefreshIntervalMenu = ({
|
|
|
74817
75070
|
}
|
|
74818
75071
|
return;
|
|
74819
75072
|
}
|
|
75073
|
+
if (editingGitCacheTtl) {
|
|
75074
|
+
if (key.return) {
|
|
75075
|
+
const error51 = validateGitCacheTtlInput(gitCacheTtlInput);
|
|
75076
|
+
if (error51) {
|
|
75077
|
+
setValidationError(error51);
|
|
75078
|
+
} else {
|
|
75079
|
+
const value = parseInt(gitCacheTtlInput, 10);
|
|
75080
|
+
onGitCacheTtlUpdate(value);
|
|
75081
|
+
setEditingGitCacheTtl(false);
|
|
75082
|
+
setValidationError(null);
|
|
75083
|
+
}
|
|
75084
|
+
} else if (key.escape) {
|
|
75085
|
+
setGitCacheTtlInput(String(gitCacheTtlSeconds));
|
|
75086
|
+
setEditingGitCacheTtl(false);
|
|
75087
|
+
setValidationError(null);
|
|
75088
|
+
} else if (key.backspace) {
|
|
75089
|
+
setGitCacheTtlInput(gitCacheTtlInput.slice(0, -1));
|
|
75090
|
+
setValidationError(null);
|
|
75091
|
+
} else if (key.delete) {} else if (shouldInsertInput(input, key) && /\d/.test(input)) {
|
|
75092
|
+
const newValue = gitCacheTtlInput + input;
|
|
75093
|
+
if (newValue.length <= 2) {
|
|
75094
|
+
setGitCacheTtlInput(newValue);
|
|
75095
|
+
setValidationError(null);
|
|
75096
|
+
}
|
|
75097
|
+
}
|
|
75098
|
+
return;
|
|
75099
|
+
}
|
|
74820
75100
|
if (key.escape) {
|
|
74821
75101
|
onBack();
|
|
74822
75102
|
}
|
|
@@ -74852,16 +75132,53 @@ var RefreshIntervalMenu = ({
|
|
|
74852
75132
|
children: "按 Enter 确认,ESC 取消。留空即移除。"
|
|
74853
75133
|
}, undefined, false, undefined, this)
|
|
74854
75134
|
]
|
|
75135
|
+
}, undefined, true, undefined, this) : editingGitCacheTtl ? /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Box_default, {
|
|
75136
|
+
marginTop: 1,
|
|
75137
|
+
flexDirection: "column",
|
|
75138
|
+
children: [
|
|
75139
|
+
/* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
|
|
75140
|
+
children: [
|
|
75141
|
+
"输入 Git 缓存 TTL(秒,0-60):",
|
|
75142
|
+
" ",
|
|
75143
|
+
gitCacheTtlInput,
|
|
75144
|
+
gitCacheTtlInput.length > 0 ? " 秒" : ""
|
|
75145
|
+
]
|
|
75146
|
+
}, undefined, true, undefined, this),
|
|
75147
|
+
/* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
|
|
75148
|
+
children: " "
|
|
75149
|
+
}, undefined, false, undefined, this),
|
|
75150
|
+
/* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
|
|
75151
|
+
dimColor: true,
|
|
75152
|
+
wrap: "wrap",
|
|
75153
|
+
children: "此设置影响 Git 组件多快能察觉到未暂存和未跟踪的工作区改动。"
|
|
75154
|
+
}, undefined, false, undefined, this),
|
|
75155
|
+
validationError ? /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
|
|
75156
|
+
color: "red",
|
|
75157
|
+
children: validationError
|
|
75158
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
|
|
75159
|
+
dimColor: true,
|
|
75160
|
+
children: "填 0 关闭按时长过期;缓存有效性仅依据 .git/HEAD 和 .git/index 的 mtime。"
|
|
75161
|
+
}, undefined, false, undefined, this),
|
|
75162
|
+
/* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
|
|
75163
|
+
dimColor: true,
|
|
75164
|
+
children: "按 Enter 确认,ESC 取消。"
|
|
75165
|
+
}, undefined, false, undefined, this)
|
|
75166
|
+
]
|
|
74855
75167
|
}, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(List, {
|
|
74856
75168
|
marginTop: 1,
|
|
74857
|
-
items: buildConfigureStatusLineItems(currentInterval, supportsRefreshInterval),
|
|
75169
|
+
items: buildConfigureStatusLineItems(currentInterval, supportsRefreshInterval, gitCacheTtlSeconds),
|
|
74858
75170
|
onSelect: (value) => {
|
|
74859
75171
|
if (value === "back") {
|
|
74860
75172
|
onBack();
|
|
74861
75173
|
return;
|
|
74862
75174
|
}
|
|
74863
|
-
|
|
74864
|
-
|
|
75175
|
+
if (value === "refreshInterval") {
|
|
75176
|
+
setRefreshInput(getRefreshInputValue(currentInterval));
|
|
75177
|
+
setEditingRefreshInterval(true);
|
|
75178
|
+
return;
|
|
75179
|
+
}
|
|
75180
|
+
setGitCacheTtlInput(String(gitCacheTtlSeconds));
|
|
75181
|
+
setEditingGitCacheTtl(true);
|
|
74865
75182
|
},
|
|
74866
75183
|
showBackButton: true
|
|
74867
75184
|
}, undefined, false, undefined, this)
|
|
@@ -74912,6 +75229,7 @@ var renderSingleLine = (widgets, terminalWidth, settings, lineIndex, globalSepar
|
|
|
74912
75229
|
terminalWidth,
|
|
74913
75230
|
isPreview: true,
|
|
74914
75231
|
minimalist: settings.minimalistMode,
|
|
75232
|
+
gitCacheTtlSeconds: settings.gitCacheTtlSeconds,
|
|
74915
75233
|
lineIndex,
|
|
74916
75234
|
globalSeparatorIndex,
|
|
74917
75235
|
globalPowerlineThemeIndex
|
|
@@ -74928,7 +75246,12 @@ var StatusLinePreview = ({ lines, terminalWidth, settings, onTruncationChange })
|
|
|
74928
75246
|
const { renderedLines, anyTruncated } = import_react48.default.useMemo(() => {
|
|
74929
75247
|
if (!settings)
|
|
74930
75248
|
return { renderedLines: [], anyTruncated: false };
|
|
74931
|
-
const preRenderedLines = preRenderAllWidgets(lines, settings, {
|
|
75249
|
+
const preRenderedLines = preRenderAllWidgets(lines, settings, {
|
|
75250
|
+
terminalWidth,
|
|
75251
|
+
isPreview: true,
|
|
75252
|
+
minimalist: settings.minimalistMode,
|
|
75253
|
+
gitCacheTtlSeconds: settings.gitCacheTtlSeconds
|
|
75254
|
+
});
|
|
74932
75255
|
const preCalculatedMaxWidths = calculateMaxWidthsFromPreRendered(preRenderedLines, settings);
|
|
74933
75256
|
let globalSeparatorIndex = 0;
|
|
74934
75257
|
let globalPowerlineThemeIndex = 0;
|
|
@@ -76462,30 +76785,7 @@ ${GITHUB_REPO_URL}`,
|
|
|
76462
76785
|
screen === "refreshInterval" && /* @__PURE__ */ jsx_dev_runtime27.jsxDEV(RefreshIntervalMenu, {
|
|
76463
76786
|
currentInterval: currentRefreshInterval,
|
|
76464
76787
|
supportsRefreshInterval,
|
|
76465
|
-
|
|
76466
|
-
const previous = currentRefreshInterval;
|
|
76467
|
-
setCurrentRefreshInterval(interval);
|
|
76468
|
-
setRefreshInterval(interval).then(() => {
|
|
76469
|
-
setFlashMessage({
|
|
76470
|
-
text: "✓ Refresh interval updated",
|
|
76471
|
-
color: "green"
|
|
76472
|
-
});
|
|
76473
|
-
}).catch(() => {
|
|
76474
|
-
setCurrentRefreshInterval(previous);
|
|
76475
|
-
setFlashMessage({
|
|
76476
|
-
text: "✗ Failed to save refresh interval",
|
|
76477
|
-
color: "red"
|
|
76478
|
-
});
|
|
76479
|
-
});
|
|
76480
|
-
setScreen("main");
|
|
76481
|
-
},
|
|
76482
|
-
onBack: () => {
|
|
76483
|
-
setScreen("main");
|
|
76484
|
-
}
|
|
76485
|
-
}, undefined, false, undefined, this),
|
|
76486
|
-
screen === "refreshInterval" && /* @__PURE__ */ jsx_dev_runtime27.jsxDEV(RefreshIntervalMenu, {
|
|
76487
|
-
currentInterval: currentRefreshInterval,
|
|
76488
|
-
supportsRefreshInterval,
|
|
76788
|
+
gitCacheTtlSeconds: settings.gitCacheTtlSeconds,
|
|
76489
76789
|
onUpdate: (interval) => {
|
|
76490
76790
|
const previous = currentRefreshInterval;
|
|
76491
76791
|
setCurrentRefreshInterval(interval);
|
|
@@ -76503,27 +76803,14 @@ ${GITHUB_REPO_URL}`,
|
|
|
76503
76803
|
});
|
|
76504
76804
|
setScreen("main");
|
|
76505
76805
|
},
|
|
76506
|
-
|
|
76507
|
-
|
|
76508
|
-
|
|
76509
|
-
|
|
76510
|
-
|
|
76511
|
-
|
|
76512
|
-
|
|
76513
|
-
|
|
76514
|
-
const previous = currentRefreshInterval;
|
|
76515
|
-
setCurrentRefreshInterval(interval);
|
|
76516
|
-
setRefreshInterval(interval).then(() => {
|
|
76517
|
-
setFlashMessage({
|
|
76518
|
-
text: "✓ 刷新间隔已更新",
|
|
76519
|
-
color: "green"
|
|
76520
|
-
});
|
|
76521
|
-
}).catch(() => {
|
|
76522
|
-
setCurrentRefreshInterval(previous);
|
|
76523
|
-
setFlashMessage({
|
|
76524
|
-
text: "✗ 保存刷新间隔失败",
|
|
76525
|
-
color: "red"
|
|
76526
|
-
});
|
|
76806
|
+
onGitCacheTtlUpdate: (ttlSeconds) => {
|
|
76807
|
+
setSettings({
|
|
76808
|
+
...settings,
|
|
76809
|
+
gitCacheTtlSeconds: ttlSeconds
|
|
76810
|
+
});
|
|
76811
|
+
setFlashMessage({
|
|
76812
|
+
text: "✓ Git 缓存 TTL 已更新",
|
|
76813
|
+
color: "green"
|
|
76527
76814
|
});
|
|
76528
76815
|
setScreen("main");
|
|
76529
76816
|
},
|
|
@@ -76649,9 +76936,9 @@ init_colors();
|
|
|
76649
76936
|
// src/utils/compaction.ts
|
|
76650
76937
|
init_zod();
|
|
76651
76938
|
import * as crypto from "crypto";
|
|
76652
|
-
import * as
|
|
76653
|
-
import * as
|
|
76654
|
-
import * as
|
|
76939
|
+
import * as fs15 from "fs";
|
|
76940
|
+
import * as os14 from "os";
|
|
76941
|
+
import * as path12 from "path";
|
|
76655
76942
|
var DEFAULT_DROP_THRESHOLD = 2;
|
|
76656
76943
|
var FRESH_PREV_CTX_PCT = -1;
|
|
76657
76944
|
var MAX_CACHE_FILE_BYTES = 4096;
|
|
@@ -76695,8 +76982,8 @@ function detectCompaction(currentCtxPct, state, options = DEFAULT_DROP_THRESHOLD
|
|
|
76695
76982
|
...currentWindowSize !== null ? { prevWindowSize: currentWindowSize } : {}
|
|
76696
76983
|
};
|
|
76697
76984
|
}
|
|
76698
|
-
function
|
|
76699
|
-
return
|
|
76985
|
+
function getCacheDir3() {
|
|
76986
|
+
return path12.join(os14.homedir(), ".cache", "ccstatusline", "compaction");
|
|
76700
76987
|
}
|
|
76701
76988
|
function sanitizeSessionId(sessionId) {
|
|
76702
76989
|
const sanitized = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
@@ -76706,18 +76993,18 @@ function sanitizeSessionId(sessionId) {
|
|
|
76706
76993
|
return sanitized;
|
|
76707
76994
|
}
|
|
76708
76995
|
function getStatePath(sessionId) {
|
|
76709
|
-
return
|
|
76996
|
+
return path12.join(getCacheDir3(), `compaction-${sanitizeSessionId(sessionId)}.json`);
|
|
76710
76997
|
}
|
|
76711
76998
|
function loadCompactionState(sessionId) {
|
|
76712
76999
|
const statePath = getStatePath(sessionId);
|
|
76713
77000
|
let fd = null;
|
|
76714
77001
|
try {
|
|
76715
|
-
fd =
|
|
76716
|
-
const stats =
|
|
77002
|
+
fd = fs15.openSync(statePath, fs15.constants.O_RDONLY | fs15.constants.O_NOFOLLOW);
|
|
77003
|
+
const stats = fs15.fstatSync(fd);
|
|
76717
77004
|
if (!stats.isFile() || stats.size > MAX_CACHE_FILE_BYTES) {
|
|
76718
77005
|
return FRESH;
|
|
76719
77006
|
}
|
|
76720
|
-
const raw = JSON.parse(
|
|
77007
|
+
const raw = JSON.parse(fs15.readFileSync(fd, "utf-8"));
|
|
76721
77008
|
const result2 = CompactionStateSchema.safeParse(raw);
|
|
76722
77009
|
return result2.success ? result2.data : FRESH;
|
|
76723
77010
|
} catch {
|
|
@@ -76725,7 +77012,7 @@ function loadCompactionState(sessionId) {
|
|
|
76725
77012
|
} finally {
|
|
76726
77013
|
if (fd !== null) {
|
|
76727
77014
|
try {
|
|
76728
|
-
|
|
77015
|
+
fs15.closeSync(fd);
|
|
76729
77016
|
} catch {}
|
|
76730
77017
|
}
|
|
76731
77018
|
}
|
|
@@ -76733,20 +77020,20 @@ function loadCompactionState(sessionId) {
|
|
|
76733
77020
|
function saveCompactionState(sessionId, state) {
|
|
76734
77021
|
let tmpPath = null;
|
|
76735
77022
|
try {
|
|
76736
|
-
const dir =
|
|
76737
|
-
if (!
|
|
76738
|
-
|
|
77023
|
+
const dir = getCacheDir3();
|
|
77024
|
+
if (!fs15.existsSync(dir)) {
|
|
77025
|
+
fs15.mkdirSync(dir, { recursive: true });
|
|
76739
77026
|
}
|
|
76740
77027
|
const targetPath = getStatePath(sessionId);
|
|
76741
77028
|
tmpPath = `${targetPath}.tmp.${process.pid}.${crypto.randomBytes(4).toString("hex")}`;
|
|
76742
|
-
|
|
77029
|
+
fs15.writeFileSync(tmpPath, JSON.stringify(state) + `
|
|
76743
77030
|
`);
|
|
76744
|
-
|
|
77031
|
+
fs15.renameSync(tmpPath, targetPath);
|
|
76745
77032
|
tmpPath = null;
|
|
76746
77033
|
} catch {
|
|
76747
77034
|
if (tmpPath !== null) {
|
|
76748
77035
|
try {
|
|
76749
|
-
|
|
77036
|
+
fs15.unlinkSync(tmpPath);
|
|
76750
77037
|
} catch {}
|
|
76751
77038
|
}
|
|
76752
77039
|
}
|
|
@@ -76761,23 +77048,23 @@ await __promiseAll([
|
|
|
76761
77048
|
await init_renderer2();
|
|
76762
77049
|
|
|
76763
77050
|
// src/utils/skills.ts
|
|
76764
|
-
import * as
|
|
76765
|
-
import * as
|
|
76766
|
-
import * as
|
|
77051
|
+
import * as fs16 from "fs";
|
|
77052
|
+
import * as os15 from "os";
|
|
77053
|
+
import * as path13 from "path";
|
|
76767
77054
|
var EMPTY = { totalInvocations: 0, uniqueSkills: [], lastSkill: null };
|
|
76768
77055
|
function getSkillsDir() {
|
|
76769
|
-
return
|
|
77056
|
+
return path13.join(os15.homedir(), ".cache", "ccstatusline", "skills");
|
|
76770
77057
|
}
|
|
76771
77058
|
function getSkillsFilePath(sessionId) {
|
|
76772
|
-
return
|
|
77059
|
+
return path13.join(getSkillsDir(), `skills-${sessionId}.jsonl`);
|
|
76773
77060
|
}
|
|
76774
77061
|
function getSkillsMetrics(sessionId) {
|
|
76775
77062
|
const filePath = getSkillsFilePath(sessionId);
|
|
76776
|
-
if (!
|
|
77063
|
+
if (!fs16.existsSync(filePath)) {
|
|
76777
77064
|
return EMPTY;
|
|
76778
77065
|
}
|
|
76779
77066
|
try {
|
|
76780
|
-
const invocations =
|
|
77067
|
+
const invocations = fs16.readFileSync(filePath, "utf-8").trim().split(`
|
|
76781
77068
|
`).filter((line) => line.trim()).map((line) => {
|
|
76782
77069
|
try {
|
|
76783
77070
|
return JSON.parse(line);
|
|
@@ -76998,7 +77285,7 @@ async function ensureWindowsUtf8CodePage() {
|
|
|
76998
77285
|
}
|
|
76999
77286
|
try {
|
|
77000
77287
|
const { execFileSync: execFileSync7 } = await import("child_process");
|
|
77001
|
-
execFileSync7("chcp.com", ["65001"], { stdio: "ignore" });
|
|
77288
|
+
execFileSync7("chcp.com", ["65001"], { stdio: "ignore", windowsHide: true });
|
|
77002
77289
|
} catch {}
|
|
77003
77290
|
}
|
|
77004
77291
|
async function renderMultipleLines(data) {
|
|
@@ -77064,7 +77351,8 @@ async function renderMultipleLines(data) {
|
|
|
77064
77351
|
skillsMetrics,
|
|
77065
77352
|
compactionData: hasCompactionWidget ? { count: compactionCount } : null,
|
|
77066
77353
|
isPreview: false,
|
|
77067
|
-
minimalist: settings.minimalistMode
|
|
77354
|
+
minimalist: settings.minimalistMode,
|
|
77355
|
+
gitCacheTtlSeconds: settings.gitCacheTtlSeconds
|
|
77068
77356
|
};
|
|
77069
77357
|
const preRenderedLines = preRenderAllWidgets(lines, settings, context);
|
|
77070
77358
|
const preCalculatedMaxWidths = calculateMaxWidthsFromPreRendered(preRenderedLines, settings);
|
|
@@ -77149,16 +77437,16 @@ async function handleHook() {
|
|
|
77149
77437
|
return;
|
|
77150
77438
|
}
|
|
77151
77439
|
const filePath = getSkillsFilePath(sessionId);
|
|
77152
|
-
const
|
|
77153
|
-
const
|
|
77154
|
-
|
|
77440
|
+
const fs17 = await import("fs");
|
|
77441
|
+
const path14 = await import("path");
|
|
77442
|
+
fs17.mkdirSync(path14.dirname(filePath), { recursive: true });
|
|
77155
77443
|
const entry = JSON.stringify({
|
|
77156
77444
|
timestamp: new Date().toISOString(),
|
|
77157
77445
|
session_id: sessionId,
|
|
77158
77446
|
skill: skillName,
|
|
77159
77447
|
source: data.hook_event_name
|
|
77160
77448
|
});
|
|
77161
|
-
|
|
77449
|
+
fs17.appendFileSync(filePath, entry + `
|
|
77162
77450
|
`);
|
|
77163
77451
|
} catch {}
|
|
77164
77452
|
console.log("{}");
|