ccstatusline-usage 2.0.40 → 2.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/ccstatusline.js +131 -194
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Session: [████░░░░░░░░░░░] 27.0% | Weekly: [██
|
|
|
40
40
|
Context: [███████░░░░░░░░] 103k/200k (51%)
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
These widgets are enabled by default. Just install and run!
|
|
44
44
|
|
|
45
45
|

|
|
46
46
|
|
package/dist/ccstatusline.js
CHANGED
|
@@ -32383,8 +32383,8 @@ var require_utils = __commonJS((exports) => {
|
|
|
32383
32383
|
}
|
|
32384
32384
|
return output;
|
|
32385
32385
|
};
|
|
32386
|
-
exports.basename = (
|
|
32387
|
-
const segs =
|
|
32386
|
+
exports.basename = (path6, { windows } = {}) => {
|
|
32387
|
+
const segs = path6.split(windows ? /[\\/]/ : "/");
|
|
32388
32388
|
const last = segs[segs.length - 1];
|
|
32389
32389
|
if (last === "") {
|
|
32390
32390
|
return segs[segs.length - 2];
|
|
@@ -51450,7 +51450,7 @@ import { execSync as execSync3 } from "child_process";
|
|
|
51450
51450
|
import * as fs5 from "fs";
|
|
51451
51451
|
import * as path4 from "path";
|
|
51452
51452
|
var __dirname = "/Users/peter/Documents/Code/ccstatusline-usage/src/utils";
|
|
51453
|
-
var PACKAGE_VERSION = "2.0.
|
|
51453
|
+
var PACKAGE_VERSION = "2.0.41";
|
|
51454
51454
|
function getPackageVersion() {
|
|
51455
51455
|
if (/^\d+\.\d+\.\d+/.test(PACKAGE_VERSION)) {
|
|
51456
51456
|
return PACKAGE_VERSION;
|
|
@@ -53812,83 +53812,8 @@ var CustomTextEditor = ({ widget, onComplete, onCancel }) => {
|
|
|
53812
53812
|
};
|
|
53813
53813
|
// src/widgets/CustomCommand.tsx
|
|
53814
53814
|
import { execSync as execSync7 } from "child_process";
|
|
53815
|
-
import * as fs6 from "fs";
|
|
53816
53815
|
var import_react30 = __toESM(require_react(), 1);
|
|
53817
|
-
import * as path5 from "path";
|
|
53818
53816
|
var jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
|
|
53819
|
-
function getPackageDir() {
|
|
53820
|
-
const scriptPaths = [
|
|
53821
|
-
process.argv[1],
|
|
53822
|
-
__require.main?.filename
|
|
53823
|
-
].filter(Boolean);
|
|
53824
|
-
for (const scriptPath of scriptPaths) {
|
|
53825
|
-
try {
|
|
53826
|
-
const realPath = fs6.realpathSync(scriptPath);
|
|
53827
|
-
let dir = path5.dirname(realPath);
|
|
53828
|
-
for (let i = 0;i < 10; i++) {
|
|
53829
|
-
const pkgJson = path5.join(dir, "package.json");
|
|
53830
|
-
if (fs6.existsSync(pkgJson)) {
|
|
53831
|
-
try {
|
|
53832
|
-
const pkg = JSON.parse(fs6.readFileSync(pkgJson, "utf8"));
|
|
53833
|
-
if (pkg.name === "ccstatusline-usage") {
|
|
53834
|
-
return dir;
|
|
53835
|
-
}
|
|
53836
|
-
} catch {}
|
|
53837
|
-
}
|
|
53838
|
-
const scriptsDir = path5.join(dir, "scripts");
|
|
53839
|
-
if (fs6.existsSync(path5.join(scriptsDir, "usage.sh"))) {
|
|
53840
|
-
return dir;
|
|
53841
|
-
}
|
|
53842
|
-
dir = path5.dirname(dir);
|
|
53843
|
-
}
|
|
53844
|
-
} catch {}
|
|
53845
|
-
}
|
|
53846
|
-
const home = process.env.HOME ?? "";
|
|
53847
|
-
const npxPaths = [
|
|
53848
|
-
path5.join(home, ".npm", "_npx"),
|
|
53849
|
-
path5.join(home, ".cache", "npm", "_npx"),
|
|
53850
|
-
path5.join(home, ".local", "share", "npm", "_npx")
|
|
53851
|
-
];
|
|
53852
|
-
for (const npxBase of npxPaths) {
|
|
53853
|
-
if (fs6.existsSync(npxBase)) {
|
|
53854
|
-
try {
|
|
53855
|
-
const entries = fs6.readdirSync(npxBase);
|
|
53856
|
-
for (const entry of entries) {
|
|
53857
|
-
const pkgDir = path5.join(npxBase, entry, "node_modules", "ccstatusline-usage");
|
|
53858
|
-
if (fs6.existsSync(path5.join(pkgDir, "scripts", "usage.sh"))) {
|
|
53859
|
-
return pkgDir;
|
|
53860
|
-
}
|
|
53861
|
-
}
|
|
53862
|
-
} catch {}
|
|
53863
|
-
}
|
|
53864
|
-
}
|
|
53865
|
-
const globalPaths = [
|
|
53866
|
-
"/usr/local/lib/node_modules/ccstatusline-usage",
|
|
53867
|
-
"/usr/lib/node_modules/ccstatusline-usage",
|
|
53868
|
-
path5.join(home, ".nvm", "versions", "node"),
|
|
53869
|
-
path5.join(home, "node_modules", "ccstatusline-usage"),
|
|
53870
|
-
path5.join(home, ".local", "lib", "node_modules", "ccstatusline-usage")
|
|
53871
|
-
];
|
|
53872
|
-
for (const globalPath of globalPaths) {
|
|
53873
|
-
if (globalPath.includes(".nvm")) {
|
|
53874
|
-
try {
|
|
53875
|
-
if (fs6.existsSync(globalPath)) {
|
|
53876
|
-
const versions2 = fs6.readdirSync(globalPath);
|
|
53877
|
-
for (const ver of versions2) {
|
|
53878
|
-
const pkgDir = path5.join(globalPath, ver, "lib", "node_modules", "ccstatusline-usage");
|
|
53879
|
-
if (fs6.existsSync(path5.join(pkgDir, "scripts", "usage.sh"))) {
|
|
53880
|
-
return pkgDir;
|
|
53881
|
-
}
|
|
53882
|
-
}
|
|
53883
|
-
}
|
|
53884
|
-
} catch {}
|
|
53885
|
-
} else if (fs6.existsSync(path5.join(globalPath, "scripts", "usage.sh"))) {
|
|
53886
|
-
return globalPath;
|
|
53887
|
-
}
|
|
53888
|
-
}
|
|
53889
|
-
return "";
|
|
53890
|
-
}
|
|
53891
|
-
var PKG_DIR = getPackageDir();
|
|
53892
53817
|
|
|
53893
53818
|
class CustomCommandWidget {
|
|
53894
53819
|
getDefaultColor() {
|
|
@@ -53901,11 +53826,9 @@ class CustomCommandWidget {
|
|
|
53901
53826
|
return "Custom Command";
|
|
53902
53827
|
}
|
|
53903
53828
|
getEditorDisplay(item) {
|
|
53904
|
-
const
|
|
53905
|
-
|
|
53906
|
-
|
|
53907
|
-
return `${this.getDisplayName()} (${truncatedCmd})`;
|
|
53908
|
-
})();
|
|
53829
|
+
const cmd = item.commandPath ?? "No command";
|
|
53830
|
+
const truncatedCmd = cmd.length > 20 ? `${cmd.substring(0, 17)}...` : cmd;
|
|
53831
|
+
const displayText = `${this.getDisplayName()} (${truncatedCmd})`;
|
|
53909
53832
|
const modifiers = [];
|
|
53910
53833
|
if (item.maxWidth) {
|
|
53911
53834
|
modifiers.push(`max:${item.maxWidth}`);
|
|
@@ -53927,17 +53850,6 @@ class CustomCommandWidget {
|
|
|
53927
53850
|
}
|
|
53928
53851
|
return null;
|
|
53929
53852
|
}
|
|
53930
|
-
resolveCommandPath(commandPath) {
|
|
53931
|
-
if (commandPath.startsWith("$PKG/") || commandPath.startsWith("$PACKAGE_DIR/")) {
|
|
53932
|
-
const relativePath = commandPath.replace(/^\$(PKG|PACKAGE_DIR)\//, "");
|
|
53933
|
-
const resolved = path5.join(PKG_DIR, relativePath);
|
|
53934
|
-
return resolved;
|
|
53935
|
-
}
|
|
53936
|
-
if (commandPath.startsWith("$HOME/")) {
|
|
53937
|
-
return commandPath.replace("$HOME", process.env.HOME ?? "~");
|
|
53938
|
-
}
|
|
53939
|
-
return commandPath;
|
|
53940
|
-
}
|
|
53941
53853
|
render(item, context, settings) {
|
|
53942
53854
|
if (context.isPreview) {
|
|
53943
53855
|
return item.commandPath ? `[cmd: ${item.commandPath.substring(0, 20)}${item.commandPath.length > 20 ? "..." : ""}]` : "[No command]";
|
|
@@ -53945,8 +53857,7 @@ class CustomCommandWidget {
|
|
|
53945
53857
|
try {
|
|
53946
53858
|
const timeout = item.timeout ?? 1000;
|
|
53947
53859
|
const jsonInput = JSON.stringify(context.data);
|
|
53948
|
-
|
|
53949
|
-
let output = execSync7(resolvedPath, {
|
|
53860
|
+
let output = execSync7(item.commandPath, {
|
|
53950
53861
|
encoding: "utf8",
|
|
53951
53862
|
input: jsonInput,
|
|
53952
53863
|
timeout,
|
|
@@ -54367,13 +54278,13 @@ class CurrentWorkingDirWidget {
|
|
|
54367
54278
|
supportsColors(item) {
|
|
54368
54279
|
return true;
|
|
54369
54280
|
}
|
|
54370
|
-
abbreviatePath(
|
|
54281
|
+
abbreviatePath(path5) {
|
|
54371
54282
|
const homeDir = os5.homedir();
|
|
54372
|
-
const useBackslash =
|
|
54283
|
+
const useBackslash = path5.includes("\\") && !path5.includes("/");
|
|
54373
54284
|
const sep = useBackslash ? "\\" : "/";
|
|
54374
|
-
let normalizedPath =
|
|
54375
|
-
if (
|
|
54376
|
-
normalizedPath = "~" +
|
|
54285
|
+
let normalizedPath = path5;
|
|
54286
|
+
if (path5.startsWith(homeDir)) {
|
|
54287
|
+
normalizedPath = "~" + path5.slice(homeDir.length);
|
|
54377
54288
|
}
|
|
54378
54289
|
const parts = normalizedPath.split(/[\\/]+/).filter((part) => part !== "");
|
|
54379
54290
|
const abbreviated = parts.map((part, index) => {
|
|
@@ -54487,14 +54398,11 @@ class ClaudeSessionIdWidget {
|
|
|
54487
54398
|
}
|
|
54488
54399
|
}
|
|
54489
54400
|
// src/widgets/ApiUsage.tsx
|
|
54490
|
-
import {
|
|
54491
|
-
|
|
54492
|
-
|
|
54493
|
-
|
|
54494
|
-
|
|
54495
|
-
import * as path6 from "path";
|
|
54496
|
-
var CACHE_FILE = path6.join(process.env.HOME ?? "", ".cache", "ccstatusline-api.json");
|
|
54497
|
-
var LOCK_FILE = path6.join(process.env.HOME ?? "", ".cache", "ccstatusline-api.lock");
|
|
54401
|
+
import { execSync as execSync8, spawnSync } from "child_process";
|
|
54402
|
+
import * as fs6 from "fs";
|
|
54403
|
+
import * as path5 from "path";
|
|
54404
|
+
var CACHE_FILE = path5.join(process.env.HOME ?? "", ".cache", "ccstatusline-api.json");
|
|
54405
|
+
var LOCK_FILE = path5.join(process.env.HOME ?? "", ".cache", "ccstatusline-api.lock");
|
|
54498
54406
|
var CACHE_MAX_AGE = 180;
|
|
54499
54407
|
var LOCK_MAX_AGE = 30;
|
|
54500
54408
|
var TOKEN_CACHE_MAX_AGE = 3600;
|
|
@@ -54519,8 +54427,8 @@ function getToken() {
|
|
|
54519
54427
|
}
|
|
54520
54428
|
return token;
|
|
54521
54429
|
} else {
|
|
54522
|
-
const credFile =
|
|
54523
|
-
const creds = JSON.parse(
|
|
54430
|
+
const credFile = path5.join(process.env.HOME ?? "", ".claude", ".credentials.json");
|
|
54431
|
+
const creds = JSON.parse(fs6.readFileSync(credFile, "utf8"));
|
|
54524
54432
|
const token = creds?.claudeAiOauth?.accessToken ?? null;
|
|
54525
54433
|
if (token) {
|
|
54526
54434
|
cachedToken = token;
|
|
@@ -54534,21 +54442,59 @@ function getToken() {
|
|
|
54534
54442
|
}
|
|
54535
54443
|
function readStaleCache() {
|
|
54536
54444
|
try {
|
|
54537
|
-
return JSON.parse(
|
|
54445
|
+
return JSON.parse(fs6.readFileSync(CACHE_FILE, "utf8"));
|
|
54538
54446
|
} catch {
|
|
54539
54447
|
return null;
|
|
54540
54448
|
}
|
|
54541
54449
|
}
|
|
54450
|
+
function fetchFromApi(token) {
|
|
54451
|
+
const script = `
|
|
54452
|
+
const https = require('https');
|
|
54453
|
+
const options = {
|
|
54454
|
+
hostname: 'api.anthropic.com',
|
|
54455
|
+
path: '/api/oauth/usage',
|
|
54456
|
+
method: 'GET',
|
|
54457
|
+
headers: {
|
|
54458
|
+
'Authorization': 'Bearer ' + process.env.TOKEN,
|
|
54459
|
+
'anthropic-beta': 'oauth-2025-04-20'
|
|
54460
|
+
},
|
|
54461
|
+
timeout: 5000
|
|
54462
|
+
};
|
|
54463
|
+
const req = https.request(options, (res) => {
|
|
54464
|
+
let data = '';
|
|
54465
|
+
res.on('data', chunk => data += chunk);
|
|
54466
|
+
res.on('end', () => {
|
|
54467
|
+
if (res.statusCode === 200) {
|
|
54468
|
+
process.stdout.write(data);
|
|
54469
|
+
} else {
|
|
54470
|
+
process.exit(1);
|
|
54471
|
+
}
|
|
54472
|
+
});
|
|
54473
|
+
});
|
|
54474
|
+
req.on('error', () => process.exit(1));
|
|
54475
|
+
req.on('timeout', () => { req.destroy(); process.exit(1); });
|
|
54476
|
+
req.end();
|
|
54477
|
+
`;
|
|
54478
|
+
const result = spawnSync("node", ["-e", script], {
|
|
54479
|
+
encoding: "utf8",
|
|
54480
|
+
timeout: 6000,
|
|
54481
|
+
env: { ...process.env, TOKEN: token }
|
|
54482
|
+
});
|
|
54483
|
+
if (result.error || result.status !== 0 || !result.stdout) {
|
|
54484
|
+
return null;
|
|
54485
|
+
}
|
|
54486
|
+
return result.stdout;
|
|
54487
|
+
}
|
|
54542
54488
|
function fetchApiData() {
|
|
54543
54489
|
const now = Math.floor(Date.now() / 1000);
|
|
54544
54490
|
if (cachedData && !cachedData.error && now - cacheTime < CACHE_MAX_AGE) {
|
|
54545
54491
|
return cachedData;
|
|
54546
54492
|
}
|
|
54547
54493
|
try {
|
|
54548
|
-
const stat =
|
|
54494
|
+
const stat = fs6.statSync(CACHE_FILE);
|
|
54549
54495
|
const fileAge = now - Math.floor(stat.mtimeMs / 1000);
|
|
54550
54496
|
if (fileAge < CACHE_MAX_AGE) {
|
|
54551
|
-
const fileData = JSON.parse(
|
|
54497
|
+
const fileData = JSON.parse(fs6.readFileSync(CACHE_FILE, "utf8"));
|
|
54552
54498
|
if (!fileData.error) {
|
|
54553
54499
|
cachedData = fileData;
|
|
54554
54500
|
cacheTime = now;
|
|
@@ -54557,7 +54503,7 @@ function fetchApiData() {
|
|
|
54557
54503
|
}
|
|
54558
54504
|
} catch {}
|
|
54559
54505
|
try {
|
|
54560
|
-
const lockStat =
|
|
54506
|
+
const lockStat = fs6.statSync(LOCK_FILE);
|
|
54561
54507
|
const lockAge = now - Math.floor(lockStat.mtimeMs / 1000);
|
|
54562
54508
|
if (lockAge < LOCK_MAX_AGE) {
|
|
54563
54509
|
const stale = readStaleCache();
|
|
@@ -54567,11 +54513,11 @@ function fetchApiData() {
|
|
|
54567
54513
|
}
|
|
54568
54514
|
} catch {}
|
|
54569
54515
|
try {
|
|
54570
|
-
const lockDir =
|
|
54571
|
-
if (!
|
|
54572
|
-
|
|
54516
|
+
const lockDir = path5.dirname(LOCK_FILE);
|
|
54517
|
+
if (!fs6.existsSync(lockDir)) {
|
|
54518
|
+
fs6.mkdirSync(lockDir, { recursive: true });
|
|
54573
54519
|
}
|
|
54574
|
-
|
|
54520
|
+
fs6.writeFileSync(LOCK_FILE, "");
|
|
54575
54521
|
} catch {}
|
|
54576
54522
|
const token = getToken();
|
|
54577
54523
|
if (!token) {
|
|
@@ -54581,23 +54527,14 @@ function fetchApiData() {
|
|
|
54581
54527
|
return { error: "no-credentials" };
|
|
54582
54528
|
}
|
|
54583
54529
|
try {
|
|
54584
|
-
const
|
|
54585
|
-
|
|
54586
|
-
"--max-time",
|
|
54587
|
-
"5",
|
|
54588
|
-
"https://api.anthropic.com/api/oauth/usage",
|
|
54589
|
-
"-H",
|
|
54590
|
-
`Authorization: Bearer ${token}`,
|
|
54591
|
-
"-H",
|
|
54592
|
-
"anthropic-beta: oauth-2025-04-20"
|
|
54593
|
-
], { encoding: "utf8", timeout: 6000 });
|
|
54594
|
-
if (curlResult.error || curlResult.status !== 0 || !curlResult.stdout) {
|
|
54530
|
+
const response = fetchFromApi(token);
|
|
54531
|
+
if (!response) {
|
|
54595
54532
|
const stale = readStaleCache();
|
|
54596
54533
|
if (stale && !stale.error)
|
|
54597
54534
|
return stale;
|
|
54598
54535
|
return { error: "api-error" };
|
|
54599
54536
|
}
|
|
54600
|
-
const data = JSON.parse(
|
|
54537
|
+
const data = JSON.parse(response);
|
|
54601
54538
|
const apiData = {};
|
|
54602
54539
|
if (data.five_hour) {
|
|
54603
54540
|
apiData.sessionUsage = data.five_hour.utilization;
|
|
@@ -54613,11 +54550,11 @@ function fetchApiData() {
|
|
|
54613
54550
|
return { error: "parse-error" };
|
|
54614
54551
|
}
|
|
54615
54552
|
try {
|
|
54616
|
-
const cacheDir =
|
|
54617
|
-
if (!
|
|
54618
|
-
|
|
54553
|
+
const cacheDir = path5.dirname(CACHE_FILE);
|
|
54554
|
+
if (!fs6.existsSync(cacheDir)) {
|
|
54555
|
+
fs6.mkdirSync(cacheDir, { recursive: true });
|
|
54619
54556
|
}
|
|
54620
|
-
|
|
54557
|
+
fs6.writeFileSync(CACHE_FILE, JSON.stringify(apiData));
|
|
54621
54558
|
} catch {}
|
|
54622
54559
|
cachedData = apiData;
|
|
54623
54560
|
cacheTime = now;
|
|
@@ -58639,42 +58576,42 @@ var StatusJSONSchema = exports_external.looseObject({
|
|
|
58639
58576
|
});
|
|
58640
58577
|
|
|
58641
58578
|
// src/utils/jsonl.ts
|
|
58642
|
-
import * as
|
|
58643
|
-
import
|
|
58579
|
+
import * as fs7 from "fs";
|
|
58580
|
+
import path7 from "node:path";
|
|
58644
58581
|
|
|
58645
58582
|
// node_modules/tinyglobby/dist/index.mjs
|
|
58646
|
-
import
|
|
58583
|
+
import path6, { posix } from "path";
|
|
58647
58584
|
|
|
58648
58585
|
// node_modules/fdir/dist/index.mjs
|
|
58649
58586
|
import { createRequire as createRequire2 } from "module";
|
|
58650
|
-
import { basename as basename2, dirname as
|
|
58587
|
+
import { basename as basename2, dirname as dirname3, normalize, relative, resolve as resolve2, sep } from "path";
|
|
58651
58588
|
import * as nativeFs from "fs";
|
|
58652
58589
|
var __require2 = /* @__PURE__ */ createRequire2(import.meta.url);
|
|
58653
|
-
function cleanPath(
|
|
58654
|
-
let normalized = normalize(
|
|
58590
|
+
function cleanPath(path6) {
|
|
58591
|
+
let normalized = normalize(path6);
|
|
58655
58592
|
if (normalized.length > 1 && normalized[normalized.length - 1] === sep)
|
|
58656
58593
|
normalized = normalized.substring(0, normalized.length - 1);
|
|
58657
58594
|
return normalized;
|
|
58658
58595
|
}
|
|
58659
58596
|
var SLASHES_REGEX = /[\\/]/g;
|
|
58660
|
-
function convertSlashes(
|
|
58661
|
-
return
|
|
58597
|
+
function convertSlashes(path6, separator) {
|
|
58598
|
+
return path6.replace(SLASHES_REGEX, separator);
|
|
58662
58599
|
}
|
|
58663
58600
|
var WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
58664
|
-
function isRootDirectory(
|
|
58665
|
-
return
|
|
58601
|
+
function isRootDirectory(path6) {
|
|
58602
|
+
return path6 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path6);
|
|
58666
58603
|
}
|
|
58667
|
-
function normalizePath(
|
|
58604
|
+
function normalizePath(path6, options) {
|
|
58668
58605
|
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
58669
|
-
const pathNeedsCleaning = process.platform === "win32" &&
|
|
58606
|
+
const pathNeedsCleaning = process.platform === "win32" && path6.includes("/") || path6.startsWith(".");
|
|
58670
58607
|
if (resolvePaths)
|
|
58671
|
-
|
|
58608
|
+
path6 = resolve2(path6);
|
|
58672
58609
|
if (normalizePath$1 || pathNeedsCleaning)
|
|
58673
|
-
|
|
58674
|
-
if (
|
|
58610
|
+
path6 = cleanPath(path6);
|
|
58611
|
+
if (path6 === ".")
|
|
58675
58612
|
return "";
|
|
58676
|
-
const needsSeperator =
|
|
58677
|
-
return convertSlashes(needsSeperator ?
|
|
58613
|
+
const needsSeperator = path6[path6.length - 1] !== pathSeparator;
|
|
58614
|
+
return convertSlashes(needsSeperator ? path6 + pathSeparator : path6, pathSeparator);
|
|
58678
58615
|
}
|
|
58679
58616
|
function joinPathWithBasePath(filename, directoryPath) {
|
|
58680
58617
|
return directoryPath + filename;
|
|
@@ -58714,9 +58651,9 @@ var pushDirectory = (directoryPath, paths) => {
|
|
|
58714
58651
|
paths.push(directoryPath || ".");
|
|
58715
58652
|
};
|
|
58716
58653
|
var pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
58717
|
-
const
|
|
58718
|
-
if (filters.every((filter) => filter(
|
|
58719
|
-
paths.push(
|
|
58654
|
+
const path6 = directoryPath || ".";
|
|
58655
|
+
if (filters.every((filter) => filter(path6, true)))
|
|
58656
|
+
paths.push(path6);
|
|
58720
58657
|
};
|
|
58721
58658
|
var empty$2 = () => {};
|
|
58722
58659
|
function build$6(root, options) {
|
|
@@ -58773,29 +58710,29 @@ var empty = () => {};
|
|
|
58773
58710
|
function build$3(options) {
|
|
58774
58711
|
return options.group ? groupFiles : empty;
|
|
58775
58712
|
}
|
|
58776
|
-
var resolveSymlinksAsync = function(
|
|
58777
|
-
const { queue, fs:
|
|
58713
|
+
var resolveSymlinksAsync = function(path6, state, callback$1) {
|
|
58714
|
+
const { queue, fs: fs7, options: { suppressErrors } } = state;
|
|
58778
58715
|
queue.enqueue();
|
|
58779
|
-
|
|
58716
|
+
fs7.realpath(path6, (error43, resolvedPath) => {
|
|
58780
58717
|
if (error43)
|
|
58781
58718
|
return queue.dequeue(suppressErrors ? null : error43, state);
|
|
58782
|
-
|
|
58719
|
+
fs7.stat(resolvedPath, (error$1, stat) => {
|
|
58783
58720
|
if (error$1)
|
|
58784
58721
|
return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
58785
|
-
if (stat.isDirectory() && isRecursive(
|
|
58722
|
+
if (stat.isDirectory() && isRecursive(path6, resolvedPath, state))
|
|
58786
58723
|
return queue.dequeue(null, state);
|
|
58787
58724
|
callback$1(stat, resolvedPath);
|
|
58788
58725
|
queue.dequeue(null, state);
|
|
58789
58726
|
});
|
|
58790
58727
|
});
|
|
58791
58728
|
};
|
|
58792
|
-
var resolveSymlinks = function(
|
|
58793
|
-
const { queue, fs:
|
|
58729
|
+
var resolveSymlinks = function(path6, state, callback$1) {
|
|
58730
|
+
const { queue, fs: fs7, options: { suppressErrors } } = state;
|
|
58794
58731
|
queue.enqueue();
|
|
58795
58732
|
try {
|
|
58796
|
-
const resolvedPath =
|
|
58797
|
-
const stat =
|
|
58798
|
-
if (stat.isDirectory() && isRecursive(
|
|
58733
|
+
const resolvedPath = fs7.realpathSync(path6);
|
|
58734
|
+
const stat = fs7.statSync(resolvedPath);
|
|
58735
|
+
if (stat.isDirectory() && isRecursive(path6, resolvedPath, state))
|
|
58799
58736
|
return;
|
|
58800
58737
|
callback$1(stat, resolvedPath);
|
|
58801
58738
|
} catch (e) {
|
|
@@ -58808,10 +58745,10 @@ function build$2(options, isSynchronous) {
|
|
|
58808
58745
|
return null;
|
|
58809
58746
|
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
58810
58747
|
}
|
|
58811
|
-
function isRecursive(
|
|
58748
|
+
function isRecursive(path6, resolved, state) {
|
|
58812
58749
|
if (state.options.useRealPaths)
|
|
58813
58750
|
return isRecursiveUsingRealPaths(resolved, state);
|
|
58814
|
-
let parent =
|
|
58751
|
+
let parent = dirname3(path6);
|
|
58815
58752
|
let depth = 1;
|
|
58816
58753
|
while (parent !== state.root && depth < 2) {
|
|
58817
58754
|
const resolvedPath = state.symlinks.get(parent);
|
|
@@ -58819,9 +58756,9 @@ function isRecursive(path7, resolved, state) {
|
|
|
58819
58756
|
if (isSameRoot)
|
|
58820
58757
|
depth++;
|
|
58821
58758
|
else
|
|
58822
|
-
parent =
|
|
58759
|
+
parent = dirname3(parent);
|
|
58823
58760
|
}
|
|
58824
|
-
state.symlinks.set(
|
|
58761
|
+
state.symlinks.set(path6, resolved);
|
|
58825
58762
|
return depth > 1;
|
|
58826
58763
|
}
|
|
58827
58764
|
function isRecursiveUsingRealPaths(resolved, state) {
|
|
@@ -58877,23 +58814,23 @@ var walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
|
58877
58814
|
state.queue.enqueue();
|
|
58878
58815
|
if (currentDepth < 0)
|
|
58879
58816
|
return state.queue.dequeue(null, state);
|
|
58880
|
-
const { fs:
|
|
58817
|
+
const { fs: fs7 } = state;
|
|
58881
58818
|
state.visited.push(crawlPath);
|
|
58882
58819
|
state.counts.directories++;
|
|
58883
|
-
|
|
58820
|
+
fs7.readdir(crawlPath || ".", readdirOpts, (error43, entries = []) => {
|
|
58884
58821
|
callback$1(entries, directoryPath, currentDepth);
|
|
58885
58822
|
state.queue.dequeue(state.options.suppressErrors ? null : error43, state);
|
|
58886
58823
|
});
|
|
58887
58824
|
};
|
|
58888
58825
|
var walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
58889
|
-
const { fs:
|
|
58826
|
+
const { fs: fs7 } = state;
|
|
58890
58827
|
if (currentDepth < 0)
|
|
58891
58828
|
return;
|
|
58892
58829
|
state.visited.push(crawlPath);
|
|
58893
58830
|
state.counts.directories++;
|
|
58894
58831
|
let entries = [];
|
|
58895
58832
|
try {
|
|
58896
|
-
entries =
|
|
58833
|
+
entries = fs7.readdirSync(crawlPath || ".", readdirOpts);
|
|
58897
58834
|
} catch (e) {
|
|
58898
58835
|
if (!state.options.suppressErrors)
|
|
58899
58836
|
throw e;
|
|
@@ -58999,23 +58936,23 @@ var Walker = class {
|
|
|
58999
58936
|
const filename = this.joinPath(entry.name, directoryPath);
|
|
59000
58937
|
this.pushFile(filename, files, this.state.counts, filters);
|
|
59001
58938
|
} else if (entry.isDirectory()) {
|
|
59002
|
-
let
|
|
59003
|
-
if (exclude && exclude(entry.name,
|
|
58939
|
+
let path6 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
58940
|
+
if (exclude && exclude(entry.name, path6))
|
|
59004
58941
|
continue;
|
|
59005
|
-
this.pushDirectory(
|
|
59006
|
-
this.walkDirectory(this.state,
|
|
58942
|
+
this.pushDirectory(path6, paths, filters);
|
|
58943
|
+
this.walkDirectory(this.state, path6, path6, depth - 1, this.walk);
|
|
59007
58944
|
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
59008
|
-
let
|
|
59009
|
-
this.resolveSymlink(
|
|
58945
|
+
let path6 = joinPathWithBasePath(entry.name, directoryPath);
|
|
58946
|
+
this.resolveSymlink(path6, this.state, (stat, resolvedPath) => {
|
|
59010
58947
|
if (stat.isDirectory()) {
|
|
59011
58948
|
resolvedPath = normalizePath(resolvedPath, this.state.options);
|
|
59012
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath :
|
|
58949
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path6 + pathSeparator))
|
|
59013
58950
|
return;
|
|
59014
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath :
|
|
58951
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path6 + pathSeparator, depth - 1, this.walk);
|
|
59015
58952
|
} else {
|
|
59016
|
-
resolvedPath = useRealPaths ? resolvedPath :
|
|
58953
|
+
resolvedPath = useRealPaths ? resolvedPath : path6;
|
|
59017
58954
|
const filename = basename2(resolvedPath);
|
|
59018
|
-
const directoryPath$1 = normalizePath(
|
|
58955
|
+
const directoryPath$1 = normalizePath(dirname3(resolvedPath), this.state.options);
|
|
59019
58956
|
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
59020
58957
|
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
59021
58958
|
}
|
|
@@ -59173,7 +59110,7 @@ var Builder = class {
|
|
|
59173
59110
|
isMatch = globFn(patterns, ...options);
|
|
59174
59111
|
this.globCache[patterns.join("\x00")] = isMatch;
|
|
59175
59112
|
}
|
|
59176
|
-
this.options.filters.push((
|
|
59113
|
+
this.options.filters.push((path6) => isMatch(path6));
|
|
59177
59114
|
return this;
|
|
59178
59115
|
}
|
|
59179
59116
|
};
|
|
@@ -59252,7 +59189,7 @@ function normalizePattern(pattern, expandDirectories, cwd2, props, isIgnore) {
|
|
|
59252
59189
|
if (!result.endsWith("*") && expandDirectories)
|
|
59253
59190
|
result += "/**";
|
|
59254
59191
|
const escapedCwd = escapePath(cwd2);
|
|
59255
|
-
if (
|
|
59192
|
+
if (path6.isAbsolute(result.replace(ESCAPING_BACKSLASHES, "")))
|
|
59256
59193
|
result = posix.relative(escapedCwd, result);
|
|
59257
59194
|
else
|
|
59258
59195
|
result = posix.normalize(result);
|
|
@@ -59289,7 +59226,7 @@ function normalizePattern(pattern, expandDirectories, cwd2, props, isIgnore) {
|
|
|
59289
59226
|
}
|
|
59290
59227
|
props.depthOffset = newCommonPath.length;
|
|
59291
59228
|
props.commonPath = newCommonPath;
|
|
59292
|
-
props.root = newCommonPath.length > 0 ?
|
|
59229
|
+
props.root = newCommonPath.length > 0 ? path6.posix.join(cwd2, ...newCommonPath) : cwd2;
|
|
59293
59230
|
}
|
|
59294
59231
|
return result;
|
|
59295
59232
|
}
|
|
@@ -59422,18 +59359,18 @@ function globSync(patternsOrOptions, options) {
|
|
|
59422
59359
|
...options,
|
|
59423
59360
|
patterns: patternsOrOptions
|
|
59424
59361
|
} : patternsOrOptions;
|
|
59425
|
-
const cwd2 = opts.cwd ?
|
|
59362
|
+
const cwd2 = opts.cwd ? path6.resolve(opts.cwd).replace(BACKSLASHES, "/") : process.cwd().replace(BACKSLASHES, "/");
|
|
59426
59363
|
return crawl(opts, cwd2, true);
|
|
59427
59364
|
}
|
|
59428
59365
|
|
|
59429
59366
|
// src/utils/jsonl.ts
|
|
59430
59367
|
import { promisify } from "util";
|
|
59431
|
-
var readFile4 = promisify(
|
|
59432
|
-
var
|
|
59433
|
-
var statSync5 =
|
|
59368
|
+
var readFile4 = promisify(fs7.readFile);
|
|
59369
|
+
var readFileSync5 = fs7.readFileSync;
|
|
59370
|
+
var statSync5 = fs7.statSync;
|
|
59434
59371
|
async function getSessionDuration(transcriptPath) {
|
|
59435
59372
|
try {
|
|
59436
|
-
if (!
|
|
59373
|
+
if (!fs7.existsSync(transcriptPath)) {
|
|
59437
59374
|
return null;
|
|
59438
59375
|
}
|
|
59439
59376
|
const content = await readFile4(transcriptPath, "utf-8");
|
|
@@ -59485,7 +59422,7 @@ async function getSessionDuration(transcriptPath) {
|
|
|
59485
59422
|
}
|
|
59486
59423
|
async function getTokenMetrics(transcriptPath) {
|
|
59487
59424
|
try {
|
|
59488
|
-
if (!
|
|
59425
|
+
if (!fs7.existsSync(transcriptPath)) {
|
|
59489
59426
|
return { inputTokens: 0, outputTokens: 0, cachedTokens: 0, totalTokens: 0, contextLength: 0 };
|
|
59490
59427
|
}
|
|
59491
59428
|
const content = await readFile4(transcriptPath, "utf-8");
|
|
@@ -59538,7 +59475,7 @@ function getBlockMetrics() {
|
|
|
59538
59475
|
function findMostRecentBlockStartTime(rootDir, sessionDurationHours = 5) {
|
|
59539
59476
|
const sessionDurationMs = sessionDurationHours * 60 * 60 * 1000;
|
|
59540
59477
|
const now = new Date;
|
|
59541
|
-
const pattern =
|
|
59478
|
+
const pattern = path7.posix.join(rootDir.replace(/\\/g, "/"), "projects", "**", "*.jsonl");
|
|
59542
59479
|
const files = globSync([pattern], {
|
|
59543
59480
|
absolute: true,
|
|
59544
59481
|
cwd: rootDir
|
|
@@ -59632,7 +59569,7 @@ function findMostRecentBlockStartTime(rootDir, sessionDurationHours = 5) {
|
|
|
59632
59569
|
function getAllTimestampsFromFile(filePath) {
|
|
59633
59570
|
const timestamps = [];
|
|
59634
59571
|
try {
|
|
59635
|
-
const content =
|
|
59572
|
+
const content = readFileSync5(filePath, "utf-8");
|
|
59636
59573
|
const lines = content.trim().split(`
|
|
59637
59574
|
`).filter((line) => line.length > 0);
|
|
59638
59575
|
for (const line of lines) {
|