ccstatusline-usage 2.0.31 → 2.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ccstatusline.js +283 -68
- package/package.json +1 -1
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 = (path7, { windows } = {}) => {
|
|
32387
|
+
const segs = path7.split(windows ? /[\\/]/ : "/");
|
|
32388
32388
|
const last = segs[segs.length - 1];
|
|
32389
32389
|
if (last === "") {
|
|
32390
32390
|
return segs[segs.length - 2];
|
|
@@ -50982,18 +50982,18 @@ var SettingsSchema = exports_external.object({
|
|
|
50982
50982
|
version: exports_external.number().default(CURRENT_VERSION),
|
|
50983
50983
|
lines: exports_external.array(exports_external.array(WidgetItemSchema)).min(1).default([
|
|
50984
50984
|
[
|
|
50985
|
-
{ id: "session-usage", type: "
|
|
50985
|
+
{ id: "session-usage", type: "session-usage", color: "brightBlue" },
|
|
50986
50986
|
{ id: "sep1", type: "separator" },
|
|
50987
|
-
{ id: "weekly-usage", type: "
|
|
50987
|
+
{ id: "weekly-usage", type: "weekly-usage", color: "brightBlue" },
|
|
50988
50988
|
{ id: "sep2", type: "separator" },
|
|
50989
|
-
{ id: "reset-timer", type: "
|
|
50989
|
+
{ id: "reset-timer", type: "reset-timer", color: "brightBlue" },
|
|
50990
50990
|
{ id: "sep3", type: "separator" },
|
|
50991
50991
|
{ id: "model", type: "model", color: "magenta" },
|
|
50992
50992
|
{ id: "sep4", type: "separator" },
|
|
50993
50993
|
{ id: "session-id", type: "claude-session-id", color: "cyan" }
|
|
50994
50994
|
],
|
|
50995
50995
|
[
|
|
50996
|
-
{ id: "context-
|
|
50996
|
+
{ id: "context-bar", type: "context-bar", color: "blue" }
|
|
50997
50997
|
],
|
|
50998
50998
|
[]
|
|
50999
50999
|
]),
|
|
@@ -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.33";
|
|
51454
51454
|
function getPackageVersion() {
|
|
51455
51455
|
if (/^\d+\.\d+\.\d+/.test(PACKAGE_VERSION)) {
|
|
51456
51456
|
return PACKAGE_VERSION;
|
|
@@ -54486,6 +54486,217 @@ class ClaudeSessionIdWidget {
|
|
|
54486
54486
|
return true;
|
|
54487
54487
|
}
|
|
54488
54488
|
}
|
|
54489
|
+
// src/widgets/ApiUsage.tsx
|
|
54490
|
+
import { execSync as execSync8 } from "child_process";
|
|
54491
|
+
import * as fs7 from "fs";
|
|
54492
|
+
import * as path6 from "path";
|
|
54493
|
+
var CACHE_FILE = path6.join(process.env.HOME ?? "", ".cache", "ccstatusline-api.json");
|
|
54494
|
+
var CACHE_MAX_AGE = 180;
|
|
54495
|
+
var cachedData = null;
|
|
54496
|
+
var cacheTime = 0;
|
|
54497
|
+
function getToken() {
|
|
54498
|
+
try {
|
|
54499
|
+
const isMac = process.platform === "darwin";
|
|
54500
|
+
if (isMac) {
|
|
54501
|
+
const result = execSync8('security find-generic-password -s "Claude Code-credentials" -w 2>/dev/null', { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
54502
|
+
const parsed = JSON.parse(result);
|
|
54503
|
+
return parsed?.claudeAiOauth?.accessToken ?? null;
|
|
54504
|
+
} else {
|
|
54505
|
+
const credFile = path6.join(process.env.HOME ?? "", ".claude", ".credentials.json");
|
|
54506
|
+
if (fs7.existsSync(credFile)) {
|
|
54507
|
+
const creds = JSON.parse(fs7.readFileSync(credFile, "utf8"));
|
|
54508
|
+
return creds?.claudeAiOauth?.accessToken ?? null;
|
|
54509
|
+
}
|
|
54510
|
+
}
|
|
54511
|
+
} catch {}
|
|
54512
|
+
return null;
|
|
54513
|
+
}
|
|
54514
|
+
function fetchApiData() {
|
|
54515
|
+
const now = Math.floor(Date.now() / 1000);
|
|
54516
|
+
if (cachedData && now - cacheTime < CACHE_MAX_AGE) {
|
|
54517
|
+
return cachedData;
|
|
54518
|
+
}
|
|
54519
|
+
try {
|
|
54520
|
+
if (fs7.existsSync(CACHE_FILE)) {
|
|
54521
|
+
const stat = fs7.statSync(CACHE_FILE);
|
|
54522
|
+
const fileAge = now - Math.floor(stat.mtimeMs / 1000);
|
|
54523
|
+
if (fileAge < CACHE_MAX_AGE) {
|
|
54524
|
+
cachedData = JSON.parse(fs7.readFileSync(CACHE_FILE, "utf8"));
|
|
54525
|
+
cacheTime = now;
|
|
54526
|
+
return cachedData;
|
|
54527
|
+
}
|
|
54528
|
+
}
|
|
54529
|
+
} catch {}
|
|
54530
|
+
const token = getToken();
|
|
54531
|
+
if (!token)
|
|
54532
|
+
return null;
|
|
54533
|
+
try {
|
|
54534
|
+
const result = execSync8(`curl -s --max-time 5 "https://api.anthropic.com/api/oauth/usage" -H "Authorization: Bearer ${token}" -H "anthropic-beta: oauth-2025-04-20"`, { encoding: "utf8", timeout: 5000, stdio: ["pipe", "pipe", "pipe"] });
|
|
54535
|
+
const data = JSON.parse(result);
|
|
54536
|
+
let apiData = {};
|
|
54537
|
+
if (data.five_hour) {
|
|
54538
|
+
apiData.sessionUsage = data.five_hour.utilization;
|
|
54539
|
+
apiData.sessionResetAt = data.five_hour.reset_at;
|
|
54540
|
+
}
|
|
54541
|
+
if (data.seven_day) {
|
|
54542
|
+
apiData.weeklyUsage = data.seven_day.utilization;
|
|
54543
|
+
}
|
|
54544
|
+
try {
|
|
54545
|
+
const cacheDir = path6.dirname(CACHE_FILE);
|
|
54546
|
+
if (!fs7.existsSync(cacheDir)) {
|
|
54547
|
+
fs7.mkdirSync(cacheDir, { recursive: true });
|
|
54548
|
+
}
|
|
54549
|
+
fs7.writeFileSync(CACHE_FILE, JSON.stringify(apiData));
|
|
54550
|
+
} catch {}
|
|
54551
|
+
cachedData = apiData;
|
|
54552
|
+
cacheTime = now;
|
|
54553
|
+
return apiData;
|
|
54554
|
+
} catch {
|
|
54555
|
+
return null;
|
|
54556
|
+
}
|
|
54557
|
+
}
|
|
54558
|
+
function makeProgressBar(percent, width = 15) {
|
|
54559
|
+
const filled = Math.round(percent / 100 * width);
|
|
54560
|
+
const empty = width - filled;
|
|
54561
|
+
return "[" + "█".repeat(filled) + "░".repeat(empty) + "]";
|
|
54562
|
+
}
|
|
54563
|
+
|
|
54564
|
+
class SessionUsageWidget {
|
|
54565
|
+
getDefaultColor() {
|
|
54566
|
+
return "brightBlue";
|
|
54567
|
+
}
|
|
54568
|
+
getDescription() {
|
|
54569
|
+
return "Shows daily/session API usage percentage";
|
|
54570
|
+
}
|
|
54571
|
+
getDisplayName() {
|
|
54572
|
+
return "Session Usage";
|
|
54573
|
+
}
|
|
54574
|
+
getEditorDisplay() {
|
|
54575
|
+
return { displayText: this.getDisplayName() };
|
|
54576
|
+
}
|
|
54577
|
+
render(item, context) {
|
|
54578
|
+
if (context.isPreview)
|
|
54579
|
+
return "Session: [███░░░░░░░░░░░░] 20%";
|
|
54580
|
+
const data = fetchApiData();
|
|
54581
|
+
if (!data || data.sessionUsage === undefined) {
|
|
54582
|
+
return null;
|
|
54583
|
+
}
|
|
54584
|
+
const percent = data.sessionUsage;
|
|
54585
|
+
return `Session: ${makeProgressBar(percent)} ${percent.toFixed(1)}%`;
|
|
54586
|
+
}
|
|
54587
|
+
supportsRawValue() {
|
|
54588
|
+
return false;
|
|
54589
|
+
}
|
|
54590
|
+
supportsColors() {
|
|
54591
|
+
return true;
|
|
54592
|
+
}
|
|
54593
|
+
}
|
|
54594
|
+
|
|
54595
|
+
class WeeklyUsageWidget {
|
|
54596
|
+
getDefaultColor() {
|
|
54597
|
+
return "brightBlue";
|
|
54598
|
+
}
|
|
54599
|
+
getDescription() {
|
|
54600
|
+
return "Shows weekly API usage percentage";
|
|
54601
|
+
}
|
|
54602
|
+
getDisplayName() {
|
|
54603
|
+
return "Weekly Usage";
|
|
54604
|
+
}
|
|
54605
|
+
getEditorDisplay() {
|
|
54606
|
+
return { displayText: this.getDisplayName() };
|
|
54607
|
+
}
|
|
54608
|
+
render(item, context) {
|
|
54609
|
+
if (context.isPreview)
|
|
54610
|
+
return "Weekly: [██░░░░░░░░░░░░░] 12%";
|
|
54611
|
+
const data = fetchApiData();
|
|
54612
|
+
if (!data || data.weeklyUsage === undefined) {
|
|
54613
|
+
return null;
|
|
54614
|
+
}
|
|
54615
|
+
const percent = data.weeklyUsage;
|
|
54616
|
+
return `Weekly: ${makeProgressBar(percent)} ${percent.toFixed(1)}%`;
|
|
54617
|
+
}
|
|
54618
|
+
supportsRawValue() {
|
|
54619
|
+
return false;
|
|
54620
|
+
}
|
|
54621
|
+
supportsColors() {
|
|
54622
|
+
return true;
|
|
54623
|
+
}
|
|
54624
|
+
}
|
|
54625
|
+
|
|
54626
|
+
class ResetTimerWidget {
|
|
54627
|
+
getDefaultColor() {
|
|
54628
|
+
return "brightBlue";
|
|
54629
|
+
}
|
|
54630
|
+
getDescription() {
|
|
54631
|
+
return "Shows time until daily limit reset";
|
|
54632
|
+
}
|
|
54633
|
+
getDisplayName() {
|
|
54634
|
+
return "Reset Timer";
|
|
54635
|
+
}
|
|
54636
|
+
getEditorDisplay() {
|
|
54637
|
+
return { displayText: this.getDisplayName() };
|
|
54638
|
+
}
|
|
54639
|
+
render(item, context) {
|
|
54640
|
+
if (context.isPreview)
|
|
54641
|
+
return "4:30 hr";
|
|
54642
|
+
const data = fetchApiData();
|
|
54643
|
+
if (!data || !data.sessionResetAt) {
|
|
54644
|
+
return null;
|
|
54645
|
+
}
|
|
54646
|
+
try {
|
|
54647
|
+
const resetTime = new Date(data.sessionResetAt).getTime();
|
|
54648
|
+
const now = Date.now();
|
|
54649
|
+
const diffMs = resetTime - now;
|
|
54650
|
+
if (diffMs <= 0)
|
|
54651
|
+
return "0:00 hr";
|
|
54652
|
+
const hours = Math.floor(diffMs / (1000 * 60 * 60));
|
|
54653
|
+
const minutes = Math.floor(diffMs % (1000 * 60 * 60) / (1000 * 60));
|
|
54654
|
+
return `${hours}:${minutes.toString().padStart(2, "0")} hr`;
|
|
54655
|
+
} catch {
|
|
54656
|
+
return null;
|
|
54657
|
+
}
|
|
54658
|
+
}
|
|
54659
|
+
supportsRawValue() {
|
|
54660
|
+
return false;
|
|
54661
|
+
}
|
|
54662
|
+
supportsColors() {
|
|
54663
|
+
return true;
|
|
54664
|
+
}
|
|
54665
|
+
}
|
|
54666
|
+
|
|
54667
|
+
class ContextBarWidget {
|
|
54668
|
+
getDefaultColor() {
|
|
54669
|
+
return "blue";
|
|
54670
|
+
}
|
|
54671
|
+
getDescription() {
|
|
54672
|
+
return "Shows context usage as a progress bar";
|
|
54673
|
+
}
|
|
54674
|
+
getDisplayName() {
|
|
54675
|
+
return "Context Bar";
|
|
54676
|
+
}
|
|
54677
|
+
getEditorDisplay() {
|
|
54678
|
+
return { displayText: this.getDisplayName() };
|
|
54679
|
+
}
|
|
54680
|
+
render(item, context) {
|
|
54681
|
+
if (context.isPreview)
|
|
54682
|
+
return "Context: [████░░░░░░░░░░░] 50k/200k (25%)";
|
|
54683
|
+
const cw = context.data?.context_window;
|
|
54684
|
+
if (!cw)
|
|
54685
|
+
return null;
|
|
54686
|
+
const total = cw.context_window_size ?? 200000;
|
|
54687
|
+
const used = cw.current_usage ?? 0;
|
|
54688
|
+
const percent = total > 0 ? used / total * 100 : 0;
|
|
54689
|
+
const usedK = Math.round(used / 1000);
|
|
54690
|
+
const totalK = Math.round(total / 1000);
|
|
54691
|
+
return `Context: ${makeProgressBar(percent)} ${usedK}k/${totalK}k (${Math.round(percent)}%)`;
|
|
54692
|
+
}
|
|
54693
|
+
supportsRawValue() {
|
|
54694
|
+
return false;
|
|
54695
|
+
}
|
|
54696
|
+
supportsColors() {
|
|
54697
|
+
return true;
|
|
54698
|
+
}
|
|
54699
|
+
}
|
|
54489
54700
|
// src/utils/widgets.ts
|
|
54490
54701
|
var widgetRegistry = new Map([
|
|
54491
54702
|
["model", new ModelWidget],
|
|
@@ -54508,7 +54719,11 @@ var widgetRegistry = new Map([
|
|
|
54508
54719
|
["version", new VersionWidget],
|
|
54509
54720
|
["custom-text", new CustomTextWidget],
|
|
54510
54721
|
["custom-command", new CustomCommandWidget],
|
|
54511
|
-
["claude-session-id", new ClaudeSessionIdWidget]
|
|
54722
|
+
["claude-session-id", new ClaudeSessionIdWidget],
|
|
54723
|
+
["session-usage", new SessionUsageWidget],
|
|
54724
|
+
["weekly-usage", new WeeklyUsageWidget],
|
|
54725
|
+
["reset-timer", new ResetTimerWidget],
|
|
54726
|
+
["context-bar", new ContextBarWidget]
|
|
54512
54727
|
]);
|
|
54513
54728
|
function getWidget(type) {
|
|
54514
54729
|
return widgetRegistry.get(type) ?? null;
|
|
@@ -58327,42 +58542,42 @@ var StatusJSONSchema = exports_external.looseObject({
|
|
|
58327
58542
|
});
|
|
58328
58543
|
|
|
58329
58544
|
// src/utils/jsonl.ts
|
|
58330
|
-
import * as
|
|
58331
|
-
import
|
|
58545
|
+
import * as fs8 from "fs";
|
|
58546
|
+
import path8 from "node:path";
|
|
58332
58547
|
|
|
58333
58548
|
// node_modules/tinyglobby/dist/index.mjs
|
|
58334
|
-
import
|
|
58549
|
+
import path7, { posix } from "path";
|
|
58335
58550
|
|
|
58336
58551
|
// node_modules/fdir/dist/index.mjs
|
|
58337
58552
|
import { createRequire as createRequire2 } from "module";
|
|
58338
|
-
import { basename as basename2, dirname as
|
|
58553
|
+
import { basename as basename2, dirname as dirname4, normalize, relative, resolve as resolve2, sep } from "path";
|
|
58339
58554
|
import * as nativeFs from "fs";
|
|
58340
58555
|
var __require2 = /* @__PURE__ */ createRequire2(import.meta.url);
|
|
58341
|
-
function cleanPath(
|
|
58342
|
-
let normalized = normalize(
|
|
58556
|
+
function cleanPath(path7) {
|
|
58557
|
+
let normalized = normalize(path7);
|
|
58343
58558
|
if (normalized.length > 1 && normalized[normalized.length - 1] === sep)
|
|
58344
58559
|
normalized = normalized.substring(0, normalized.length - 1);
|
|
58345
58560
|
return normalized;
|
|
58346
58561
|
}
|
|
58347
58562
|
var SLASHES_REGEX = /[\\/]/g;
|
|
58348
|
-
function convertSlashes(
|
|
58349
|
-
return
|
|
58563
|
+
function convertSlashes(path7, separator) {
|
|
58564
|
+
return path7.replace(SLASHES_REGEX, separator);
|
|
58350
58565
|
}
|
|
58351
58566
|
var WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
58352
|
-
function isRootDirectory(
|
|
58353
|
-
return
|
|
58567
|
+
function isRootDirectory(path7) {
|
|
58568
|
+
return path7 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path7);
|
|
58354
58569
|
}
|
|
58355
|
-
function normalizePath(
|
|
58570
|
+
function normalizePath(path7, options) {
|
|
58356
58571
|
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
58357
|
-
const pathNeedsCleaning = process.platform === "win32" &&
|
|
58572
|
+
const pathNeedsCleaning = process.platform === "win32" && path7.includes("/") || path7.startsWith(".");
|
|
58358
58573
|
if (resolvePaths)
|
|
58359
|
-
|
|
58574
|
+
path7 = resolve2(path7);
|
|
58360
58575
|
if (normalizePath$1 || pathNeedsCleaning)
|
|
58361
|
-
|
|
58362
|
-
if (
|
|
58576
|
+
path7 = cleanPath(path7);
|
|
58577
|
+
if (path7 === ".")
|
|
58363
58578
|
return "";
|
|
58364
|
-
const needsSeperator =
|
|
58365
|
-
return convertSlashes(needsSeperator ?
|
|
58579
|
+
const needsSeperator = path7[path7.length - 1] !== pathSeparator;
|
|
58580
|
+
return convertSlashes(needsSeperator ? path7 + pathSeparator : path7, pathSeparator);
|
|
58366
58581
|
}
|
|
58367
58582
|
function joinPathWithBasePath(filename, directoryPath) {
|
|
58368
58583
|
return directoryPath + filename;
|
|
@@ -58402,9 +58617,9 @@ var pushDirectory = (directoryPath, paths) => {
|
|
|
58402
58617
|
paths.push(directoryPath || ".");
|
|
58403
58618
|
};
|
|
58404
58619
|
var pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
58405
|
-
const
|
|
58406
|
-
if (filters.every((filter) => filter(
|
|
58407
|
-
paths.push(
|
|
58620
|
+
const path7 = directoryPath || ".";
|
|
58621
|
+
if (filters.every((filter) => filter(path7, true)))
|
|
58622
|
+
paths.push(path7);
|
|
58408
58623
|
};
|
|
58409
58624
|
var empty$2 = () => {};
|
|
58410
58625
|
function build$6(root, options) {
|
|
@@ -58461,29 +58676,29 @@ var empty = () => {};
|
|
|
58461
58676
|
function build$3(options) {
|
|
58462
58677
|
return options.group ? groupFiles : empty;
|
|
58463
58678
|
}
|
|
58464
|
-
var resolveSymlinksAsync = function(
|
|
58465
|
-
const { queue, fs:
|
|
58679
|
+
var resolveSymlinksAsync = function(path7, state, callback$1) {
|
|
58680
|
+
const { queue, fs: fs8, options: { suppressErrors } } = state;
|
|
58466
58681
|
queue.enqueue();
|
|
58467
|
-
|
|
58682
|
+
fs8.realpath(path7, (error43, resolvedPath) => {
|
|
58468
58683
|
if (error43)
|
|
58469
58684
|
return queue.dequeue(suppressErrors ? null : error43, state);
|
|
58470
|
-
|
|
58685
|
+
fs8.stat(resolvedPath, (error$1, stat) => {
|
|
58471
58686
|
if (error$1)
|
|
58472
58687
|
return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
58473
|
-
if (stat.isDirectory() && isRecursive(
|
|
58688
|
+
if (stat.isDirectory() && isRecursive(path7, resolvedPath, state))
|
|
58474
58689
|
return queue.dequeue(null, state);
|
|
58475
58690
|
callback$1(stat, resolvedPath);
|
|
58476
58691
|
queue.dequeue(null, state);
|
|
58477
58692
|
});
|
|
58478
58693
|
});
|
|
58479
58694
|
};
|
|
58480
|
-
var resolveSymlinks = function(
|
|
58481
|
-
const { queue, fs:
|
|
58695
|
+
var resolveSymlinks = function(path7, state, callback$1) {
|
|
58696
|
+
const { queue, fs: fs8, options: { suppressErrors } } = state;
|
|
58482
58697
|
queue.enqueue();
|
|
58483
58698
|
try {
|
|
58484
|
-
const resolvedPath =
|
|
58485
|
-
const stat =
|
|
58486
|
-
if (stat.isDirectory() && isRecursive(
|
|
58699
|
+
const resolvedPath = fs8.realpathSync(path7);
|
|
58700
|
+
const stat = fs8.statSync(resolvedPath);
|
|
58701
|
+
if (stat.isDirectory() && isRecursive(path7, resolvedPath, state))
|
|
58487
58702
|
return;
|
|
58488
58703
|
callback$1(stat, resolvedPath);
|
|
58489
58704
|
} catch (e) {
|
|
@@ -58496,10 +58711,10 @@ function build$2(options, isSynchronous) {
|
|
|
58496
58711
|
return null;
|
|
58497
58712
|
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
58498
58713
|
}
|
|
58499
|
-
function isRecursive(
|
|
58714
|
+
function isRecursive(path7, resolved, state) {
|
|
58500
58715
|
if (state.options.useRealPaths)
|
|
58501
58716
|
return isRecursiveUsingRealPaths(resolved, state);
|
|
58502
|
-
let parent =
|
|
58717
|
+
let parent = dirname4(path7);
|
|
58503
58718
|
let depth = 1;
|
|
58504
58719
|
while (parent !== state.root && depth < 2) {
|
|
58505
58720
|
const resolvedPath = state.symlinks.get(parent);
|
|
@@ -58507,9 +58722,9 @@ function isRecursive(path6, resolved, state) {
|
|
|
58507
58722
|
if (isSameRoot)
|
|
58508
58723
|
depth++;
|
|
58509
58724
|
else
|
|
58510
|
-
parent =
|
|
58725
|
+
parent = dirname4(parent);
|
|
58511
58726
|
}
|
|
58512
|
-
state.symlinks.set(
|
|
58727
|
+
state.symlinks.set(path7, resolved);
|
|
58513
58728
|
return depth > 1;
|
|
58514
58729
|
}
|
|
58515
58730
|
function isRecursiveUsingRealPaths(resolved, state) {
|
|
@@ -58565,23 +58780,23 @@ var walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
|
58565
58780
|
state.queue.enqueue();
|
|
58566
58781
|
if (currentDepth < 0)
|
|
58567
58782
|
return state.queue.dequeue(null, state);
|
|
58568
|
-
const { fs:
|
|
58783
|
+
const { fs: fs8 } = state;
|
|
58569
58784
|
state.visited.push(crawlPath);
|
|
58570
58785
|
state.counts.directories++;
|
|
58571
|
-
|
|
58786
|
+
fs8.readdir(crawlPath || ".", readdirOpts, (error43, entries = []) => {
|
|
58572
58787
|
callback$1(entries, directoryPath, currentDepth);
|
|
58573
58788
|
state.queue.dequeue(state.options.suppressErrors ? null : error43, state);
|
|
58574
58789
|
});
|
|
58575
58790
|
};
|
|
58576
58791
|
var walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
58577
|
-
const { fs:
|
|
58792
|
+
const { fs: fs8 } = state;
|
|
58578
58793
|
if (currentDepth < 0)
|
|
58579
58794
|
return;
|
|
58580
58795
|
state.visited.push(crawlPath);
|
|
58581
58796
|
state.counts.directories++;
|
|
58582
58797
|
let entries = [];
|
|
58583
58798
|
try {
|
|
58584
|
-
entries =
|
|
58799
|
+
entries = fs8.readdirSync(crawlPath || ".", readdirOpts);
|
|
58585
58800
|
} catch (e) {
|
|
58586
58801
|
if (!state.options.suppressErrors)
|
|
58587
58802
|
throw e;
|
|
@@ -58687,23 +58902,23 @@ var Walker = class {
|
|
|
58687
58902
|
const filename = this.joinPath(entry.name, directoryPath);
|
|
58688
58903
|
this.pushFile(filename, files, this.state.counts, filters);
|
|
58689
58904
|
} else if (entry.isDirectory()) {
|
|
58690
|
-
let
|
|
58691
|
-
if (exclude && exclude(entry.name,
|
|
58905
|
+
let path7 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
58906
|
+
if (exclude && exclude(entry.name, path7))
|
|
58692
58907
|
continue;
|
|
58693
|
-
this.pushDirectory(
|
|
58694
|
-
this.walkDirectory(this.state,
|
|
58908
|
+
this.pushDirectory(path7, paths, filters);
|
|
58909
|
+
this.walkDirectory(this.state, path7, path7, depth - 1, this.walk);
|
|
58695
58910
|
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
58696
|
-
let
|
|
58697
|
-
this.resolveSymlink(
|
|
58911
|
+
let path7 = joinPathWithBasePath(entry.name, directoryPath);
|
|
58912
|
+
this.resolveSymlink(path7, this.state, (stat, resolvedPath) => {
|
|
58698
58913
|
if (stat.isDirectory()) {
|
|
58699
58914
|
resolvedPath = normalizePath(resolvedPath, this.state.options);
|
|
58700
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath :
|
|
58915
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path7 + pathSeparator))
|
|
58701
58916
|
return;
|
|
58702
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath :
|
|
58917
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path7 + pathSeparator, depth - 1, this.walk);
|
|
58703
58918
|
} else {
|
|
58704
|
-
resolvedPath = useRealPaths ? resolvedPath :
|
|
58919
|
+
resolvedPath = useRealPaths ? resolvedPath : path7;
|
|
58705
58920
|
const filename = basename2(resolvedPath);
|
|
58706
|
-
const directoryPath$1 = normalizePath(
|
|
58921
|
+
const directoryPath$1 = normalizePath(dirname4(resolvedPath), this.state.options);
|
|
58707
58922
|
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
58708
58923
|
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
58709
58924
|
}
|
|
@@ -58861,7 +59076,7 @@ var Builder = class {
|
|
|
58861
59076
|
isMatch = globFn(patterns, ...options);
|
|
58862
59077
|
this.globCache[patterns.join("\x00")] = isMatch;
|
|
58863
59078
|
}
|
|
58864
|
-
this.options.filters.push((
|
|
59079
|
+
this.options.filters.push((path7) => isMatch(path7));
|
|
58865
59080
|
return this;
|
|
58866
59081
|
}
|
|
58867
59082
|
};
|
|
@@ -58940,7 +59155,7 @@ function normalizePattern(pattern, expandDirectories, cwd2, props, isIgnore) {
|
|
|
58940
59155
|
if (!result.endsWith("*") && expandDirectories)
|
|
58941
59156
|
result += "/**";
|
|
58942
59157
|
const escapedCwd = escapePath(cwd2);
|
|
58943
|
-
if (
|
|
59158
|
+
if (path7.isAbsolute(result.replace(ESCAPING_BACKSLASHES, "")))
|
|
58944
59159
|
result = posix.relative(escapedCwd, result);
|
|
58945
59160
|
else
|
|
58946
59161
|
result = posix.normalize(result);
|
|
@@ -58977,7 +59192,7 @@ function normalizePattern(pattern, expandDirectories, cwd2, props, isIgnore) {
|
|
|
58977
59192
|
}
|
|
58978
59193
|
props.depthOffset = newCommonPath.length;
|
|
58979
59194
|
props.commonPath = newCommonPath;
|
|
58980
|
-
props.root = newCommonPath.length > 0 ?
|
|
59195
|
+
props.root = newCommonPath.length > 0 ? path7.posix.join(cwd2, ...newCommonPath) : cwd2;
|
|
58981
59196
|
}
|
|
58982
59197
|
return result;
|
|
58983
59198
|
}
|
|
@@ -59110,18 +59325,18 @@ function globSync(patternsOrOptions, options) {
|
|
|
59110
59325
|
...options,
|
|
59111
59326
|
patterns: patternsOrOptions
|
|
59112
59327
|
} : patternsOrOptions;
|
|
59113
|
-
const cwd2 = opts.cwd ?
|
|
59328
|
+
const cwd2 = opts.cwd ? path7.resolve(opts.cwd).replace(BACKSLASHES, "/") : process.cwd().replace(BACKSLASHES, "/");
|
|
59114
59329
|
return crawl(opts, cwd2, true);
|
|
59115
59330
|
}
|
|
59116
59331
|
|
|
59117
59332
|
// src/utils/jsonl.ts
|
|
59118
59333
|
import { promisify } from "util";
|
|
59119
|
-
var readFile4 = promisify(
|
|
59120
|
-
var
|
|
59121
|
-
var
|
|
59334
|
+
var readFile4 = promisify(fs8.readFile);
|
|
59335
|
+
var readFileSync6 = fs8.readFileSync;
|
|
59336
|
+
var statSync5 = fs8.statSync;
|
|
59122
59337
|
async function getSessionDuration(transcriptPath) {
|
|
59123
59338
|
try {
|
|
59124
|
-
if (!
|
|
59339
|
+
if (!fs8.existsSync(transcriptPath)) {
|
|
59125
59340
|
return null;
|
|
59126
59341
|
}
|
|
59127
59342
|
const content = await readFile4(transcriptPath, "utf-8");
|
|
@@ -59173,7 +59388,7 @@ async function getSessionDuration(transcriptPath) {
|
|
|
59173
59388
|
}
|
|
59174
59389
|
async function getTokenMetrics(transcriptPath) {
|
|
59175
59390
|
try {
|
|
59176
|
-
if (!
|
|
59391
|
+
if (!fs8.existsSync(transcriptPath)) {
|
|
59177
59392
|
return { inputTokens: 0, outputTokens: 0, cachedTokens: 0, totalTokens: 0, contextLength: 0 };
|
|
59178
59393
|
}
|
|
59179
59394
|
const content = await readFile4(transcriptPath, "utf-8");
|
|
@@ -59226,7 +59441,7 @@ function getBlockMetrics() {
|
|
|
59226
59441
|
function findMostRecentBlockStartTime(rootDir, sessionDurationHours = 5) {
|
|
59227
59442
|
const sessionDurationMs = sessionDurationHours * 60 * 60 * 1000;
|
|
59228
59443
|
const now = new Date;
|
|
59229
|
-
const pattern =
|
|
59444
|
+
const pattern = path8.posix.join(rootDir.replace(/\\/g, "/"), "projects", "**", "*.jsonl");
|
|
59230
59445
|
const files = globSync([pattern], {
|
|
59231
59446
|
absolute: true,
|
|
59232
59447
|
cwd: rootDir
|
|
@@ -59234,7 +59449,7 @@ function findMostRecentBlockStartTime(rootDir, sessionDurationHours = 5) {
|
|
|
59234
59449
|
if (files.length === 0)
|
|
59235
59450
|
return null;
|
|
59236
59451
|
const filesWithStats = files.map((file2) => {
|
|
59237
|
-
const stats =
|
|
59452
|
+
const stats = statSync5(file2);
|
|
59238
59453
|
return { file: file2, mtime: stats.mtime };
|
|
59239
59454
|
});
|
|
59240
59455
|
filesWithStats.sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
|
|
@@ -59320,7 +59535,7 @@ function findMostRecentBlockStartTime(rootDir, sessionDurationHours = 5) {
|
|
|
59320
59535
|
function getAllTimestampsFromFile(filePath) {
|
|
59321
59536
|
const timestamps = [];
|
|
59322
59537
|
try {
|
|
59323
|
-
const content =
|
|
59538
|
+
const content = readFileSync6(filePath, "utf-8");
|
|
59324
59539
|
const lines = content.trim().split(`
|
|
59325
59540
|
`).filter((line) => line.length > 0);
|
|
59326
59541
|
for (const line of lines) {
|