claude-scope 0.8.44 → 0.8.45
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/claude-scope.cjs +210 -268
- package/package.json +1 -1
package/dist/claude-scope.cjs
CHANGED
|
@@ -1553,7 +1553,7 @@ var init_theme = __esm({
|
|
|
1553
1553
|
});
|
|
1554
1554
|
|
|
1555
1555
|
// src/constants.ts
|
|
1556
|
-
var TIME, DEFAULTS,
|
|
1556
|
+
var TIME, DEFAULTS, DEMO_DATA;
|
|
1557
1557
|
var init_constants = __esm({
|
|
1558
1558
|
"src/constants.ts"() {
|
|
1559
1559
|
"use strict";
|
|
@@ -1567,19 +1567,7 @@ var init_constants = __esm({
|
|
|
1567
1567
|
};
|
|
1568
1568
|
DEFAULTS = {
|
|
1569
1569
|
/** Default separator between widgets */
|
|
1570
|
-
SEPARATOR: " "
|
|
1571
|
-
/** Default width for progress bars in characters */
|
|
1572
|
-
PROGRESS_BAR_WIDTH: 20
|
|
1573
|
-
};
|
|
1574
|
-
ANSI_COLORS = {
|
|
1575
|
-
/** Green color */
|
|
1576
|
-
GREEN: "\x1B[32m",
|
|
1577
|
-
/** Yellow color */
|
|
1578
|
-
YELLOW: "\x1B[33m",
|
|
1579
|
-
/** Red color */
|
|
1580
|
-
RED: "\x1B[31m",
|
|
1581
|
-
/** Reset color */
|
|
1582
|
-
RESET: "\x1B[0m"
|
|
1570
|
+
SEPARATOR: " "
|
|
1583
1571
|
};
|
|
1584
1572
|
DEMO_DATA = {
|
|
1585
1573
|
/** Demo session cost in USD */
|
|
@@ -1607,7 +1595,6 @@ var init_constants = __esm({
|
|
|
1607
1595
|
/** Demo cache read tokens */
|
|
1608
1596
|
CACHE_READ_TOKENS: 15e3
|
|
1609
1597
|
};
|
|
1610
|
-
DEFAULT_PROGRESS_BAR_WIDTH = DEFAULTS.PROGRESS_BAR_WIDTH;
|
|
1611
1598
|
}
|
|
1612
1599
|
});
|
|
1613
1600
|
|
|
@@ -1902,6 +1889,22 @@ var init_mock_transcript_provider = __esm({
|
|
|
1902
1889
|
}
|
|
1903
1890
|
});
|
|
1904
1891
|
|
|
1892
|
+
// src/core/widget-types.ts
|
|
1893
|
+
function createWidgetMetadata(name, description, version = "1.0.0", author = "claude-scope", line = 0) {
|
|
1894
|
+
return {
|
|
1895
|
+
name,
|
|
1896
|
+
description,
|
|
1897
|
+
version,
|
|
1898
|
+
author,
|
|
1899
|
+
line
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
1902
|
+
var init_widget_types = __esm({
|
|
1903
|
+
"src/core/widget-types.ts"() {
|
|
1904
|
+
"use strict";
|
|
1905
|
+
}
|
|
1906
|
+
});
|
|
1907
|
+
|
|
1905
1908
|
// src/widgets/core/stdin-data-widget.ts
|
|
1906
1909
|
var StdinDataWidget;
|
|
1907
1910
|
var init_stdin_data_widget = __esm({
|
|
@@ -1916,6 +1919,10 @@ var init_stdin_data_widget = __esm({
|
|
|
1916
1919
|
* Widget enabled state
|
|
1917
1920
|
*/
|
|
1918
1921
|
enabled = true;
|
|
1922
|
+
/**
|
|
1923
|
+
* Line override for dynamic positioning
|
|
1924
|
+
*/
|
|
1925
|
+
_lineOverride;
|
|
1919
1926
|
/**
|
|
1920
1927
|
* Initialize widget with context
|
|
1921
1928
|
* @param context - Widget initialization context
|
|
@@ -1962,6 +1969,20 @@ var init_stdin_data_widget = __esm({
|
|
|
1962
1969
|
}
|
|
1963
1970
|
return this.renderWithData(this.data, context);
|
|
1964
1971
|
}
|
|
1972
|
+
/**
|
|
1973
|
+
* Set line override for dynamic positioning
|
|
1974
|
+
* @param line - Line number to position widget on
|
|
1975
|
+
*/
|
|
1976
|
+
setLine(line) {
|
|
1977
|
+
this._lineOverride = line;
|
|
1978
|
+
}
|
|
1979
|
+
/**
|
|
1980
|
+
* Get effective line number (override or metadata default)
|
|
1981
|
+
* @returns Line number for widget positioning
|
|
1982
|
+
*/
|
|
1983
|
+
getLine() {
|
|
1984
|
+
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
1985
|
+
}
|
|
1965
1986
|
};
|
|
1966
1987
|
}
|
|
1967
1988
|
});
|
|
@@ -2276,25 +2297,25 @@ var ActiveToolsWidget;
|
|
|
2276
2297
|
var init_active_tools_widget = __esm({
|
|
2277
2298
|
"src/widgets/active-tools/active-tools-widget.ts"() {
|
|
2278
2299
|
"use strict";
|
|
2300
|
+
init_widget_types();
|
|
2279
2301
|
init_stdin_data_widget();
|
|
2280
2302
|
init_styles();
|
|
2281
2303
|
ActiveToolsWidget = class extends StdinDataWidget {
|
|
2282
|
-
constructor(
|
|
2304
|
+
constructor(colors2, transcriptProvider) {
|
|
2283
2305
|
super();
|
|
2284
|
-
this.
|
|
2306
|
+
this.colors = colors2;
|
|
2285
2307
|
this.transcriptProvider = transcriptProvider;
|
|
2286
2308
|
}
|
|
2287
2309
|
id = "active-tools";
|
|
2288
|
-
metadata =
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2310
|
+
metadata = createWidgetMetadata(
|
|
2311
|
+
"Active Tools",
|
|
2312
|
+
"Active tools display from transcript",
|
|
2313
|
+
"1.0.0",
|
|
2314
|
+
"claude-scope",
|
|
2315
|
+
2
|
|
2294
2316
|
// Display on third line (0-indexed)
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
_lineOverride;
|
|
2317
|
+
);
|
|
2318
|
+
styleFn = activeToolsStyles.balanced;
|
|
2298
2319
|
tools = [];
|
|
2299
2320
|
renderData;
|
|
2300
2321
|
/**
|
|
@@ -2302,13 +2323,10 @@ var init_active_tools_widget = __esm({
|
|
|
2302
2323
|
* @param style - Style to use for rendering
|
|
2303
2324
|
*/
|
|
2304
2325
|
setStyle(style) {
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
}
|
|
2310
|
-
getLine() {
|
|
2311
|
-
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
2326
|
+
const fn = activeToolsStyles[style];
|
|
2327
|
+
if (fn) {
|
|
2328
|
+
this.styleFn = fn;
|
|
2329
|
+
}
|
|
2312
2330
|
}
|
|
2313
2331
|
/**
|
|
2314
2332
|
* Aggregate completed tools by name and sort by count (descending)
|
|
@@ -2363,11 +2381,7 @@ var init_active_tools_widget = __esm({
|
|
|
2363
2381
|
if (!this.renderData || this.tools.length === 0) {
|
|
2364
2382
|
return null;
|
|
2365
2383
|
}
|
|
2366
|
-
|
|
2367
|
-
if (!styleFn) {
|
|
2368
|
-
return null;
|
|
2369
|
-
}
|
|
2370
|
-
return styleFn(this.renderData, this.theme);
|
|
2384
|
+
return this.styleFn(this.renderData, this.colors);
|
|
2371
2385
|
}
|
|
2372
2386
|
/**
|
|
2373
2387
|
* Check if widget should render
|
|
@@ -2397,29 +2411,53 @@ var init_active_tools = __esm({
|
|
|
2397
2411
|
}
|
|
2398
2412
|
});
|
|
2399
2413
|
|
|
2400
|
-
// src/
|
|
2401
|
-
function
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
};
|
|
2414
|
+
// src/providers/jsonl-reader.ts
|
|
2415
|
+
async function readJsonlLines(filePath, options = {}) {
|
|
2416
|
+
if (!(0, import_node_fs.existsSync)(filePath)) {
|
|
2417
|
+
return [];
|
|
2418
|
+
}
|
|
2419
|
+
const lines = [];
|
|
2420
|
+
const fileStream = (0, import_node_fs.createReadStream)(filePath, {
|
|
2421
|
+
encoding: options.encoding ?? "utf-8"
|
|
2422
|
+
});
|
|
2423
|
+
const rl = (0, import_node_readline.createInterface)({
|
|
2424
|
+
input: fileStream,
|
|
2425
|
+
crlfDelay: Infinity
|
|
2426
|
+
});
|
|
2427
|
+
try {
|
|
2428
|
+
for await (const line of rl) {
|
|
2429
|
+
const trimmed = line.trim();
|
|
2430
|
+
if (trimmed) {
|
|
2431
|
+
lines.push(trimmed);
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
return lines;
|
|
2435
|
+
} catch {
|
|
2436
|
+
return [];
|
|
2437
|
+
} finally {
|
|
2438
|
+
rl.close();
|
|
2439
|
+
fileStream.destroy();
|
|
2440
|
+
}
|
|
2409
2441
|
}
|
|
2410
|
-
var
|
|
2411
|
-
|
|
2442
|
+
var import_node_fs, import_node_readline;
|
|
2443
|
+
var init_jsonl_reader = __esm({
|
|
2444
|
+
"src/providers/jsonl-reader.ts"() {
|
|
2412
2445
|
"use strict";
|
|
2446
|
+
import_node_fs = require("node:fs");
|
|
2447
|
+
import_node_readline = require("node:readline");
|
|
2413
2448
|
}
|
|
2414
2449
|
});
|
|
2415
2450
|
|
|
2416
2451
|
// src/providers/usage-parser.ts
|
|
2417
|
-
|
|
2452
|
+
function hasRealUsage(usage) {
|
|
2453
|
+
if (!usage) return false;
|
|
2454
|
+
return (usage.input_tokens ?? 0) > 0 || (usage.output_tokens ?? 0) > 0 || (usage.cache_read_input_tokens ?? 0) > 0 || (usage.cache_creation_input_tokens ?? 0) > 0;
|
|
2455
|
+
}
|
|
2456
|
+
var UsageParser;
|
|
2418
2457
|
var init_usage_parser = __esm({
|
|
2419
2458
|
"src/providers/usage-parser.ts"() {
|
|
2420
2459
|
"use strict";
|
|
2421
|
-
|
|
2422
|
-
import_readline = require("readline");
|
|
2460
|
+
init_jsonl_reader();
|
|
2423
2461
|
UsageParser = class {
|
|
2424
2462
|
/**
|
|
2425
2463
|
* Parse the last assistant message with usage data from transcript
|
|
@@ -2429,11 +2467,11 @@ var init_usage_parser = __esm({
|
|
|
2429
2467
|
* @returns ContextUsage or null if not found
|
|
2430
2468
|
*/
|
|
2431
2469
|
async parseLastUsage(transcriptPath) {
|
|
2432
|
-
if (!(0, import_fs.existsSync)(transcriptPath)) {
|
|
2433
|
-
return null;
|
|
2434
|
-
}
|
|
2435
2470
|
try {
|
|
2436
|
-
const lines = await
|
|
2471
|
+
const lines = await readJsonlLines(transcriptPath);
|
|
2472
|
+
if (lines.length === 0) {
|
|
2473
|
+
return null;
|
|
2474
|
+
}
|
|
2437
2475
|
let mostRecentUsage = null;
|
|
2438
2476
|
let mostRecentTimestamp = null;
|
|
2439
2477
|
let hasAnyTimestamp = false;
|
|
@@ -2470,27 +2508,6 @@ var init_usage_parser = __esm({
|
|
|
2470
2508
|
}
|
|
2471
2509
|
return null;
|
|
2472
2510
|
}
|
|
2473
|
-
/**
|
|
2474
|
-
* Read all lines from transcript file
|
|
2475
|
-
*/
|
|
2476
|
-
async readAllLines(transcriptPath) {
|
|
2477
|
-
const lines = [];
|
|
2478
|
-
try {
|
|
2479
|
-
const fileStream = (0, import_fs.createReadStream)(transcriptPath, { encoding: "utf-8" });
|
|
2480
|
-
const rl = (0, import_readline.createInterface)({
|
|
2481
|
-
input: fileStream,
|
|
2482
|
-
crlfDelay: Infinity
|
|
2483
|
-
});
|
|
2484
|
-
for await (const line of rl) {
|
|
2485
|
-
if (line.trim()) {
|
|
2486
|
-
lines.push(line);
|
|
2487
|
-
}
|
|
2488
|
-
}
|
|
2489
|
-
} catch {
|
|
2490
|
-
return [];
|
|
2491
|
-
}
|
|
2492
|
-
return lines;
|
|
2493
|
-
}
|
|
2494
2511
|
/**
|
|
2495
2512
|
* Parse cumulative cache tokens from all assistant messages in transcript
|
|
2496
2513
|
*
|
|
@@ -2502,11 +2519,11 @@ var init_usage_parser = __esm({
|
|
|
2502
2519
|
* @returns Object with cumulative cacheRead and cacheCreation, or null if not found
|
|
2503
2520
|
*/
|
|
2504
2521
|
async parseCumulativeCache(transcriptPath) {
|
|
2505
|
-
if (!(0, import_fs.existsSync)(transcriptPath)) {
|
|
2506
|
-
return null;
|
|
2507
|
-
}
|
|
2508
2522
|
try {
|
|
2509
|
-
const lines = await
|
|
2523
|
+
const lines = await readJsonlLines(transcriptPath);
|
|
2524
|
+
if (lines.length === 0) {
|
|
2525
|
+
return null;
|
|
2526
|
+
}
|
|
2510
2527
|
const cacheEntries = [];
|
|
2511
2528
|
for (const line of lines) {
|
|
2512
2529
|
const entry = this.parseLineForCache(line);
|
|
@@ -2621,11 +2638,11 @@ var init_usage_parser = __esm({
|
|
|
2621
2638
|
});
|
|
2622
2639
|
|
|
2623
2640
|
// src/storage/cache-manager.ts
|
|
2624
|
-
var
|
|
2641
|
+
var import_node_fs2, import_node_os2, import_node_path2, DEFAULT_CACHE_PATH, DEFAULT_EXPIRY_MS, CacheManager;
|
|
2625
2642
|
var init_cache_manager = __esm({
|
|
2626
2643
|
"src/storage/cache-manager.ts"() {
|
|
2627
2644
|
"use strict";
|
|
2628
|
-
|
|
2645
|
+
import_node_fs2 = require("node:fs");
|
|
2629
2646
|
import_node_os2 = require("node:os");
|
|
2630
2647
|
import_node_path2 = require("node:path");
|
|
2631
2648
|
DEFAULT_CACHE_PATH = `${(0, import_node_os2.homedir)()}/.config/claude-scope/cache.json`;
|
|
@@ -2698,11 +2715,11 @@ var init_cache_manager = __esm({
|
|
|
2698
2715
|
* Load cache from file
|
|
2699
2716
|
*/
|
|
2700
2717
|
loadCache() {
|
|
2701
|
-
if (!(0,
|
|
2718
|
+
if (!(0, import_node_fs2.existsSync)(this.cachePath)) {
|
|
2702
2719
|
return { sessions: {}, version: 1 };
|
|
2703
2720
|
}
|
|
2704
2721
|
try {
|
|
2705
|
-
const content = (0,
|
|
2722
|
+
const content = (0, import_node_fs2.readFileSync)(this.cachePath, "utf-8");
|
|
2706
2723
|
return JSON.parse(content);
|
|
2707
2724
|
} catch {
|
|
2708
2725
|
return { sessions: {}, version: 1 };
|
|
@@ -2713,7 +2730,7 @@ var init_cache_manager = __esm({
|
|
|
2713
2730
|
*/
|
|
2714
2731
|
saveCache(cache) {
|
|
2715
2732
|
try {
|
|
2716
|
-
(0,
|
|
2733
|
+
(0, import_node_fs2.writeFileSync)(this.cachePath, JSON.stringify(cache, null, 2), "utf-8");
|
|
2717
2734
|
} catch {
|
|
2718
2735
|
}
|
|
2719
2736
|
}
|
|
@@ -2723,8 +2740,8 @@ var init_cache_manager = __esm({
|
|
|
2723
2740
|
ensureCacheDir() {
|
|
2724
2741
|
try {
|
|
2725
2742
|
const dir = (0, import_node_path2.dirname)(this.cachePath);
|
|
2726
|
-
if (!(0,
|
|
2727
|
-
(0,
|
|
2743
|
+
if (!(0, import_node_fs2.existsSync)(dir)) {
|
|
2744
|
+
(0, import_node_fs2.mkdirSync)(dir, { recursive: true });
|
|
2728
2745
|
}
|
|
2729
2746
|
} catch {
|
|
2730
2747
|
}
|
|
@@ -2756,9 +2773,6 @@ function formatDuration(ms) {
|
|
|
2756
2773
|
function formatCostUSD(usd) {
|
|
2757
2774
|
return `$${usd.toFixed(2)}`;
|
|
2758
2775
|
}
|
|
2759
|
-
function colorize2(text, color) {
|
|
2760
|
-
return `${color}${text}${ANSI_COLORS.RESET}`;
|
|
2761
|
-
}
|
|
2762
2776
|
function formatK(n) {
|
|
2763
2777
|
const absN = Math.abs(n);
|
|
2764
2778
|
if (absN < 1e3) {
|
|
@@ -2887,9 +2901,8 @@ var init_cache_metrics_widget = __esm({
|
|
|
2887
2901
|
2
|
|
2888
2902
|
// Third line
|
|
2889
2903
|
);
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
style = "balanced";
|
|
2904
|
+
colors;
|
|
2905
|
+
styleFn = cacheMetricsStyles.balanced;
|
|
2893
2906
|
renderData;
|
|
2894
2907
|
cacheManager;
|
|
2895
2908
|
usageParser;
|
|
@@ -2898,9 +2911,9 @@ var init_cache_metrics_widget = __esm({
|
|
|
2898
2911
|
// Cache parsed usage within render cycle
|
|
2899
2912
|
cachedCumulativeCache;
|
|
2900
2913
|
// Cumulative cache for session
|
|
2901
|
-
constructor(
|
|
2914
|
+
constructor(colors2) {
|
|
2902
2915
|
super();
|
|
2903
|
-
this.
|
|
2916
|
+
this.colors = colors2 ?? DEFAULT_THEME;
|
|
2904
2917
|
this.cacheManager = new CacheManager();
|
|
2905
2918
|
this.usageParser = new UsageParser();
|
|
2906
2919
|
}
|
|
@@ -2908,13 +2921,10 @@ var init_cache_metrics_widget = __esm({
|
|
|
2908
2921
|
* Set display style
|
|
2909
2922
|
*/
|
|
2910
2923
|
setStyle(style) {
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
}
|
|
2916
|
-
getLine() {
|
|
2917
|
-
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
2924
|
+
const fn = cacheMetricsStyles[style];
|
|
2925
|
+
if (fn) {
|
|
2926
|
+
this.styleFn = fn;
|
|
2927
|
+
}
|
|
2918
2928
|
}
|
|
2919
2929
|
/**
|
|
2920
2930
|
* Calculate cache metrics from context usage data
|
|
@@ -2964,8 +2974,7 @@ var init_cache_metrics_widget = __esm({
|
|
|
2964
2974
|
this.lastSessionId = sessionId;
|
|
2965
2975
|
const usage = data.context_window?.current_usage;
|
|
2966
2976
|
if (usage && !sessionChanged && sessionId) {
|
|
2967
|
-
|
|
2968
|
-
if (hasAnyTokens) {
|
|
2977
|
+
if (hasRealUsage(usage)) {
|
|
2969
2978
|
this.cacheManager.setCachedUsage(sessionId, {
|
|
2970
2979
|
input_tokens: usage.input_tokens,
|
|
2971
2980
|
output_tokens: usage.output_tokens,
|
|
@@ -2974,9 +2983,8 @@ var init_cache_metrics_widget = __esm({
|
|
|
2974
2983
|
});
|
|
2975
2984
|
}
|
|
2976
2985
|
}
|
|
2977
|
-
const hasRealUsage = usage && ((usage.input_tokens ?? 0) > 0 || (usage.output_tokens ?? 0) > 0 || (usage.cache_read_input_tokens ?? 0) > 0 || (usage.cache_creation_input_tokens ?? 0) > 0);
|
|
2978
2986
|
const transcriptPath = data.transcript_path;
|
|
2979
|
-
if (!usage
|
|
2987
|
+
if (!hasRealUsage(usage)) {
|
|
2980
2988
|
if (transcriptPath) {
|
|
2981
2989
|
this.cachedUsage = await this.usageParser.parseLastUsage(transcriptPath);
|
|
2982
2990
|
}
|
|
@@ -2992,8 +3000,7 @@ var init_cache_metrics_widget = __esm({
|
|
|
2992
3000
|
*/
|
|
2993
3001
|
renderWithData(data, _context) {
|
|
2994
3002
|
let usage = data.context_window?.current_usage;
|
|
2995
|
-
|
|
2996
|
-
if ((!usage || !hasRealUsage) && this.cachedUsage) {
|
|
3003
|
+
if (!hasRealUsage(usage) && this.cachedUsage) {
|
|
2997
3004
|
usage = this.cachedUsage;
|
|
2998
3005
|
}
|
|
2999
3006
|
if (!usage && data.session_id) {
|
|
@@ -3008,11 +3015,7 @@ var init_cache_metrics_widget = __esm({
|
|
|
3008
3015
|
return null;
|
|
3009
3016
|
}
|
|
3010
3017
|
this.renderData = metrics;
|
|
3011
|
-
|
|
3012
|
-
if (!styleFn) {
|
|
3013
|
-
return null;
|
|
3014
|
-
}
|
|
3015
|
-
return styleFn(this.renderData, this.theme);
|
|
3018
|
+
return this.styleFn(this.renderData, this.colors);
|
|
3016
3019
|
}
|
|
3017
3020
|
/**
|
|
3018
3021
|
* Widget is always enabled (shows zeros when no data)
|
|
@@ -3350,13 +3353,13 @@ var init_config_count_widget = __esm({
|
|
|
3350
3353
|
);
|
|
3351
3354
|
configProvider;
|
|
3352
3355
|
configs;
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
_lineOverride;
|
|
3356
|
+
colors;
|
|
3357
|
+
enabled = true;
|
|
3356
3358
|
styleFn = configCountStyles.balanced;
|
|
3357
|
-
|
|
3359
|
+
_lineOverride;
|
|
3360
|
+
constructor(configProvider, colors2) {
|
|
3358
3361
|
this.configProvider = configProvider ?? new ConfigProvider();
|
|
3359
|
-
this.
|
|
3362
|
+
this.colors = colors2 ?? DEFAULT_THEME;
|
|
3360
3363
|
}
|
|
3361
3364
|
setStyle(style = DEFAULT_WIDGET_STYLE) {
|
|
3362
3365
|
const fn = configCountStyles[style];
|
|
@@ -3364,20 +3367,14 @@ var init_config_count_widget = __esm({
|
|
|
3364
3367
|
this.styleFn = fn;
|
|
3365
3368
|
}
|
|
3366
3369
|
}
|
|
3367
|
-
|
|
3368
|
-
this.
|
|
3369
|
-
}
|
|
3370
|
-
getLine() {
|
|
3371
|
-
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
3372
|
-
}
|
|
3373
|
-
async initialize() {
|
|
3370
|
+
async initialize(context) {
|
|
3371
|
+
this.enabled = context.config?.enabled !== false;
|
|
3374
3372
|
}
|
|
3375
3373
|
async update(data) {
|
|
3376
|
-
this.cwd = data.cwd;
|
|
3377
3374
|
this.configs = await this.configProvider.getConfigs({ cwd: data.cwd });
|
|
3378
3375
|
}
|
|
3379
3376
|
isEnabled() {
|
|
3380
|
-
if (!this.configs) {
|
|
3377
|
+
if (!this.enabled || !this.configs) {
|
|
3381
3378
|
return false;
|
|
3382
3379
|
}
|
|
3383
3380
|
const { claudeMdCount, rulesCount, mcpCount, hooksCount } = this.configs;
|
|
@@ -3392,12 +3389,15 @@ var init_config_count_widget = __esm({
|
|
|
3392
3389
|
claudeMdCount,
|
|
3393
3390
|
rulesCount,
|
|
3394
3391
|
mcpCount,
|
|
3395
|
-
hooksCount
|
|
3396
|
-
colors: this.themeColors
|
|
3392
|
+
hooksCount
|
|
3397
3393
|
};
|
|
3398
|
-
return this.styleFn(renderData, this.
|
|
3394
|
+
return this.styleFn(renderData, this.colors);
|
|
3399
3395
|
}
|
|
3400
|
-
|
|
3396
|
+
setLine(line) {
|
|
3397
|
+
this._lineOverride = line;
|
|
3398
|
+
}
|
|
3399
|
+
getLine() {
|
|
3400
|
+
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
3401
3401
|
}
|
|
3402
3402
|
};
|
|
3403
3403
|
}
|
|
@@ -3493,6 +3493,7 @@ var ContextWidget;
|
|
|
3493
3493
|
var init_context_widget = __esm({
|
|
3494
3494
|
"src/widgets/context-widget.ts"() {
|
|
3495
3495
|
"use strict";
|
|
3496
|
+
init_style_types();
|
|
3496
3497
|
init_widget_types();
|
|
3497
3498
|
init_usage_parser();
|
|
3498
3499
|
init_cache_manager();
|
|
@@ -3510,7 +3511,6 @@ var init_context_widget = __esm({
|
|
|
3510
3511
|
// First line
|
|
3511
3512
|
);
|
|
3512
3513
|
colors;
|
|
3513
|
-
_lineOverride;
|
|
3514
3514
|
styleFn = contextStyles.balanced;
|
|
3515
3515
|
cacheManager;
|
|
3516
3516
|
usageParser;
|
|
@@ -3523,18 +3523,12 @@ var init_context_widget = __esm({
|
|
|
3523
3523
|
this.cacheManager = new CacheManager();
|
|
3524
3524
|
this.usageParser = new UsageParser();
|
|
3525
3525
|
}
|
|
3526
|
-
setStyle(style =
|
|
3526
|
+
setStyle(style = DEFAULT_WIDGET_STYLE) {
|
|
3527
3527
|
const fn = contextStyles[style];
|
|
3528
3528
|
if (fn) {
|
|
3529
3529
|
this.styleFn = fn;
|
|
3530
3530
|
}
|
|
3531
3531
|
}
|
|
3532
|
-
setLine(line) {
|
|
3533
|
-
this._lineOverride = line;
|
|
3534
|
-
}
|
|
3535
|
-
getLine() {
|
|
3536
|
-
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
3537
|
-
}
|
|
3538
3532
|
/**
|
|
3539
3533
|
* Update widget with new data, storing valid values in cache
|
|
3540
3534
|
*/
|
|
@@ -3549,8 +3543,7 @@ var init_context_widget = __esm({
|
|
|
3549
3543
|
this.lastSessionId = sessionId;
|
|
3550
3544
|
const { current_usage } = contextWindow;
|
|
3551
3545
|
if (current_usage && !sessionChanged && sessionId) {
|
|
3552
|
-
|
|
3553
|
-
if (hasAnyTokens) {
|
|
3546
|
+
if (hasRealUsage(current_usage)) {
|
|
3554
3547
|
this.cacheManager.setCachedUsage(sessionId, {
|
|
3555
3548
|
input_tokens: current_usage.input_tokens,
|
|
3556
3549
|
output_tokens: current_usage.output_tokens,
|
|
@@ -3559,8 +3552,7 @@ var init_context_widget = __esm({
|
|
|
3559
3552
|
});
|
|
3560
3553
|
}
|
|
3561
3554
|
}
|
|
3562
|
-
|
|
3563
|
-
if (!current_usage || !hasRealUsage) {
|
|
3555
|
+
if (!hasRealUsage(current_usage)) {
|
|
3564
3556
|
const transcriptPath = data.transcript_path;
|
|
3565
3557
|
if (transcriptPath) {
|
|
3566
3558
|
this.cachedUsage = await this.usageParser.parseLastUsage(transcriptPath);
|
|
@@ -3584,8 +3576,7 @@ var init_context_widget = __esm({
|
|
|
3584
3576
|
return this.styleFn(renderData2, this.colors.context);
|
|
3585
3577
|
}
|
|
3586
3578
|
let usage = current_usage;
|
|
3587
|
-
|
|
3588
|
-
if ((!usage || !hasRealUsage) && this.cachedUsage) {
|
|
3579
|
+
if (!hasRealUsage(usage) && this.cachedUsage) {
|
|
3589
3580
|
usage = this.cachedUsage;
|
|
3590
3581
|
}
|
|
3591
3582
|
if (!usage && data.session_id) {
|
|
@@ -3666,6 +3657,7 @@ var CostWidget;
|
|
|
3666
3657
|
var init_cost_widget = __esm({
|
|
3667
3658
|
"src/widgets/cost-widget.ts"() {
|
|
3668
3659
|
"use strict";
|
|
3660
|
+
init_style_types();
|
|
3669
3661
|
init_widget_types();
|
|
3670
3662
|
init_theme();
|
|
3671
3663
|
init_stdin_data_widget();
|
|
@@ -3681,24 +3673,17 @@ var init_cost_widget = __esm({
|
|
|
3681
3673
|
// First line
|
|
3682
3674
|
);
|
|
3683
3675
|
colors;
|
|
3684
|
-
_lineOverride;
|
|
3685
3676
|
styleFn = costStyles.balanced;
|
|
3686
3677
|
constructor(colors2) {
|
|
3687
3678
|
super();
|
|
3688
3679
|
this.colors = colors2 ?? DEFAULT_THEME;
|
|
3689
3680
|
}
|
|
3690
|
-
setStyle(style =
|
|
3681
|
+
setStyle(style = DEFAULT_WIDGET_STYLE) {
|
|
3691
3682
|
const fn = costStyles[style];
|
|
3692
3683
|
if (fn) {
|
|
3693
3684
|
this.styleFn = fn;
|
|
3694
3685
|
}
|
|
3695
3686
|
}
|
|
3696
|
-
setLine(line) {
|
|
3697
|
-
this._lineOverride = line;
|
|
3698
|
-
}
|
|
3699
|
-
getLine() {
|
|
3700
|
-
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
3701
|
-
}
|
|
3702
3687
|
renderWithData(data, _context) {
|
|
3703
3688
|
if (!data.cost || data.cost.total_cost_usd === void 0) return null;
|
|
3704
3689
|
if (data.cost.total_cost_usd === 0) return null;
|
|
@@ -3905,6 +3890,7 @@ var DevServerWidget;
|
|
|
3905
3890
|
var init_dev_server_widget = __esm({
|
|
3906
3891
|
"src/widgets/dev-server/dev-server-widget.ts"() {
|
|
3907
3892
|
"use strict";
|
|
3893
|
+
init_style_types();
|
|
3908
3894
|
init_widget_types();
|
|
3909
3895
|
init_theme();
|
|
3910
3896
|
init_port_detector();
|
|
@@ -3935,7 +3921,7 @@ var init_dev_server_widget = __esm({
|
|
|
3935
3921
|
* Set display style
|
|
3936
3922
|
* @param style - Style to use for rendering
|
|
3937
3923
|
*/
|
|
3938
|
-
setStyle(style =
|
|
3924
|
+
setStyle(style = DEFAULT_WIDGET_STYLE) {
|
|
3939
3925
|
const fn = devServerStyles[style];
|
|
3940
3926
|
if (fn) {
|
|
3941
3927
|
this.styleFn = fn;
|
|
@@ -3976,11 +3962,6 @@ var init_dev_server_widget = __esm({
|
|
|
3976
3962
|
isEnabled() {
|
|
3977
3963
|
return this.enabled;
|
|
3978
3964
|
}
|
|
3979
|
-
/**
|
|
3980
|
-
* Cleanup resources
|
|
3981
|
-
*/
|
|
3982
|
-
async cleanup() {
|
|
3983
|
-
}
|
|
3984
3965
|
/**
|
|
3985
3966
|
* Render widget output
|
|
3986
3967
|
* @param context - Render context
|
|
@@ -4096,6 +4077,7 @@ var init_docker_widget = __esm({
|
|
|
4096
4077
|
"use strict";
|
|
4097
4078
|
import_node_child_process3 = require("node:child_process");
|
|
4098
4079
|
import_node_util3 = require("node:util");
|
|
4080
|
+
init_style_types();
|
|
4099
4081
|
init_widget_types();
|
|
4100
4082
|
init_theme();
|
|
4101
4083
|
init_styles7();
|
|
@@ -4119,7 +4101,7 @@ var init_docker_widget = __esm({
|
|
|
4119
4101
|
constructor(colors2) {
|
|
4120
4102
|
this.colors = colors2 ?? DEFAULT_THEME;
|
|
4121
4103
|
}
|
|
4122
|
-
setStyle(style =
|
|
4104
|
+
setStyle(style = DEFAULT_WIDGET_STYLE) {
|
|
4123
4105
|
const fn = dockerStyles[style];
|
|
4124
4106
|
if (fn) {
|
|
4125
4107
|
this.styleFn = fn;
|
|
@@ -4139,8 +4121,6 @@ var init_docker_widget = __esm({
|
|
|
4139
4121
|
isEnabled() {
|
|
4140
4122
|
return this.enabled;
|
|
4141
4123
|
}
|
|
4142
|
-
async cleanup() {
|
|
4143
|
-
}
|
|
4144
4124
|
async render(_context) {
|
|
4145
4125
|
if (!this.enabled) {
|
|
4146
4126
|
return null;
|
|
@@ -4279,6 +4259,7 @@ var DurationWidget;
|
|
|
4279
4259
|
var init_duration_widget = __esm({
|
|
4280
4260
|
"src/widgets/duration-widget.ts"() {
|
|
4281
4261
|
"use strict";
|
|
4262
|
+
init_style_types();
|
|
4282
4263
|
init_widget_types();
|
|
4283
4264
|
init_theme();
|
|
4284
4265
|
init_stdin_data_widget();
|
|
@@ -4294,24 +4275,17 @@ var init_duration_widget = __esm({
|
|
|
4294
4275
|
// First line
|
|
4295
4276
|
);
|
|
4296
4277
|
colors;
|
|
4297
|
-
_lineOverride;
|
|
4298
4278
|
styleFn = durationStyles.balanced;
|
|
4299
4279
|
constructor(colors2) {
|
|
4300
4280
|
super();
|
|
4301
4281
|
this.colors = colors2 ?? DEFAULT_THEME;
|
|
4302
4282
|
}
|
|
4303
|
-
setStyle(style =
|
|
4283
|
+
setStyle(style = DEFAULT_WIDGET_STYLE) {
|
|
4304
4284
|
const fn = durationStyles[style];
|
|
4305
4285
|
if (fn) {
|
|
4306
4286
|
this.styleFn = fn;
|
|
4307
4287
|
}
|
|
4308
4288
|
}
|
|
4309
|
-
setLine(line) {
|
|
4310
|
-
this._lineOverride = line;
|
|
4311
|
-
}
|
|
4312
|
-
getLine() {
|
|
4313
|
-
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
4314
|
-
}
|
|
4315
4289
|
renderWithData(data, _context) {
|
|
4316
4290
|
if (!data.cost || data.cost.total_duration_ms === void 0) return null;
|
|
4317
4291
|
if (data.cost.total_duration_ms === 0) return null;
|
|
@@ -4436,6 +4410,7 @@ var GitTagWidget;
|
|
|
4436
4410
|
var init_git_tag_widget = __esm({
|
|
4437
4411
|
"src/widgets/git/git-tag-widget.ts"() {
|
|
4438
4412
|
"use strict";
|
|
4413
|
+
init_style_types();
|
|
4439
4414
|
init_widget_types();
|
|
4440
4415
|
init_git_provider();
|
|
4441
4416
|
init_theme();
|
|
@@ -4467,7 +4442,7 @@ var init_git_tag_widget = __esm({
|
|
|
4467
4442
|
this.gitFactory = gitFactory || createGit;
|
|
4468
4443
|
this.colors = colors2 ?? DEFAULT_THEME;
|
|
4469
4444
|
}
|
|
4470
|
-
setStyle(style =
|
|
4445
|
+
setStyle(style = DEFAULT_WIDGET_STYLE) {
|
|
4471
4446
|
const fn = gitTagStyles[style];
|
|
4472
4447
|
if (fn) {
|
|
4473
4448
|
this.styleFn = fn;
|
|
@@ -4503,8 +4478,6 @@ var init_git_tag_widget = __esm({
|
|
|
4503
4478
|
isEnabled() {
|
|
4504
4479
|
return this.enabled;
|
|
4505
4480
|
}
|
|
4506
|
-
async cleanup() {
|
|
4507
|
-
}
|
|
4508
4481
|
};
|
|
4509
4482
|
}
|
|
4510
4483
|
});
|
|
@@ -4610,6 +4583,7 @@ var GitWidget;
|
|
|
4610
4583
|
var init_git_widget = __esm({
|
|
4611
4584
|
"src/widgets/git/git-widget.ts"() {
|
|
4612
4585
|
"use strict";
|
|
4586
|
+
init_style_types();
|
|
4613
4587
|
init_widget_types();
|
|
4614
4588
|
init_git_provider();
|
|
4615
4589
|
init_theme();
|
|
@@ -4641,7 +4615,7 @@ var init_git_widget = __esm({
|
|
|
4641
4615
|
this.gitFactory = gitFactory || createGit;
|
|
4642
4616
|
this.colors = colors2 ?? DEFAULT_THEME;
|
|
4643
4617
|
}
|
|
4644
|
-
setStyle(style =
|
|
4618
|
+
setStyle(style = DEFAULT_WIDGET_STYLE) {
|
|
4645
4619
|
const fn = gitStyles[style];
|
|
4646
4620
|
if (fn) {
|
|
4647
4621
|
this.styleFn = fn;
|
|
@@ -4697,8 +4671,6 @@ var init_git_widget = __esm({
|
|
|
4697
4671
|
isEnabled() {
|
|
4698
4672
|
return this.enabled;
|
|
4699
4673
|
}
|
|
4700
|
-
async cleanup() {
|
|
4701
|
-
}
|
|
4702
4674
|
};
|
|
4703
4675
|
}
|
|
4704
4676
|
});
|
|
@@ -4762,6 +4734,7 @@ var LinesWidget;
|
|
|
4762
4734
|
var init_lines_widget = __esm({
|
|
4763
4735
|
"src/widgets/lines-widget.ts"() {
|
|
4764
4736
|
"use strict";
|
|
4737
|
+
init_style_types();
|
|
4765
4738
|
init_widget_types();
|
|
4766
4739
|
init_theme();
|
|
4767
4740
|
init_stdin_data_widget();
|
|
@@ -4777,24 +4750,17 @@ var init_lines_widget = __esm({
|
|
|
4777
4750
|
// First line
|
|
4778
4751
|
);
|
|
4779
4752
|
colors;
|
|
4780
|
-
_lineOverride;
|
|
4781
4753
|
styleFn = linesStyles.balanced;
|
|
4782
4754
|
constructor(colors2) {
|
|
4783
4755
|
super();
|
|
4784
4756
|
this.colors = colors2 ?? DEFAULT_THEME;
|
|
4785
4757
|
}
|
|
4786
|
-
setStyle(style =
|
|
4758
|
+
setStyle(style = DEFAULT_WIDGET_STYLE) {
|
|
4787
4759
|
const fn = linesStyles[style];
|
|
4788
4760
|
if (fn) {
|
|
4789
4761
|
this.styleFn = fn;
|
|
4790
4762
|
}
|
|
4791
4763
|
}
|
|
4792
|
-
setLine(line) {
|
|
4793
|
-
this._lineOverride = line;
|
|
4794
|
-
}
|
|
4795
|
-
getLine() {
|
|
4796
|
-
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
4797
|
-
}
|
|
4798
4764
|
renderWithData(data, _context) {
|
|
4799
4765
|
const added = data.cost?.total_lines_added ?? 0;
|
|
4800
4766
|
const removed = data.cost?.total_lines_removed ?? 0;
|
|
@@ -4863,6 +4829,7 @@ var ModelWidget;
|
|
|
4863
4829
|
var init_model_widget = __esm({
|
|
4864
4830
|
"src/widgets/model-widget.ts"() {
|
|
4865
4831
|
"use strict";
|
|
4832
|
+
init_style_types();
|
|
4866
4833
|
init_widget_types();
|
|
4867
4834
|
init_theme();
|
|
4868
4835
|
init_stdin_data_widget();
|
|
@@ -4878,24 +4845,17 @@ var init_model_widget = __esm({
|
|
|
4878
4845
|
// First line
|
|
4879
4846
|
);
|
|
4880
4847
|
colors;
|
|
4881
|
-
_lineOverride;
|
|
4882
4848
|
styleFn = modelStyles.balanced;
|
|
4883
4849
|
constructor(colors2) {
|
|
4884
4850
|
super();
|
|
4885
4851
|
this.colors = colors2 ?? DEFAULT_THEME;
|
|
4886
4852
|
}
|
|
4887
|
-
setStyle(style =
|
|
4853
|
+
setStyle(style = DEFAULT_WIDGET_STYLE) {
|
|
4888
4854
|
const fn = modelStyles[style];
|
|
4889
4855
|
if (fn) {
|
|
4890
4856
|
this.styleFn = fn;
|
|
4891
4857
|
}
|
|
4892
4858
|
}
|
|
4893
|
-
setLine(line) {
|
|
4894
|
-
this._lineOverride = line;
|
|
4895
|
-
}
|
|
4896
|
-
getLine() {
|
|
4897
|
-
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
4898
|
-
}
|
|
4899
4859
|
renderWithData(data, _context) {
|
|
4900
4860
|
if (!data.model) {
|
|
4901
4861
|
return null;
|
|
@@ -26443,8 +26403,7 @@ init_renderer();
|
|
|
26443
26403
|
init_widget_registry();
|
|
26444
26404
|
|
|
26445
26405
|
// src/providers/transcript-provider.ts
|
|
26446
|
-
|
|
26447
|
-
var import_node_readline = require("node:readline");
|
|
26406
|
+
init_jsonl_reader();
|
|
26448
26407
|
var TranscriptProvider = class {
|
|
26449
26408
|
MAX_TOOLS = 20;
|
|
26450
26409
|
/**
|
|
@@ -26453,29 +26412,17 @@ var TranscriptProvider = class {
|
|
|
26453
26412
|
* @returns Array of tool entries, limited to last 20
|
|
26454
26413
|
*/
|
|
26455
26414
|
async parseTools(transcriptPath) {
|
|
26456
|
-
|
|
26457
|
-
return [];
|
|
26458
|
-
}
|
|
26415
|
+
const lines = await readJsonlLines(transcriptPath);
|
|
26459
26416
|
const toolMap = /* @__PURE__ */ new Map();
|
|
26460
|
-
|
|
26461
|
-
|
|
26462
|
-
|
|
26463
|
-
|
|
26464
|
-
|
|
26465
|
-
});
|
|
26466
|
-
for await (const line of rl) {
|
|
26467
|
-
if (!line.trim()) continue;
|
|
26468
|
-
try {
|
|
26469
|
-
const entry = JSON.parse(line);
|
|
26470
|
-
this.processLine(entry, toolMap);
|
|
26471
|
-
} catch {
|
|
26472
|
-
}
|
|
26417
|
+
for (const line of lines) {
|
|
26418
|
+
try {
|
|
26419
|
+
const entry = JSON.parse(line);
|
|
26420
|
+
this.processLine(entry, toolMap);
|
|
26421
|
+
} catch {
|
|
26473
26422
|
}
|
|
26474
|
-
const tools = Array.from(toolMap.values());
|
|
26475
|
-
return tools.slice(-this.MAX_TOOLS);
|
|
26476
|
-
} catch {
|
|
26477
|
-
return [];
|
|
26478
26423
|
}
|
|
26424
|
+
const tools = Array.from(toolMap.values());
|
|
26425
|
+
return tools.slice(-this.MAX_TOOLS);
|
|
26479
26426
|
}
|
|
26480
26427
|
/**
|
|
26481
26428
|
* Process a single transcript line and update tool map
|
|
@@ -26556,6 +26503,7 @@ init_lines_widget();
|
|
|
26556
26503
|
init_model_widget();
|
|
26557
26504
|
|
|
26558
26505
|
// src/widgets/sysmon-widget.ts
|
|
26506
|
+
init_style_types();
|
|
26559
26507
|
init_widget_types();
|
|
26560
26508
|
init_theme();
|
|
26561
26509
|
|
|
@@ -26626,9 +26574,9 @@ var SysmonWidget = class {
|
|
|
26626
26574
|
);
|
|
26627
26575
|
colors;
|
|
26628
26576
|
provider;
|
|
26629
|
-
_lineOverride;
|
|
26630
26577
|
styleFn = sysmonStyles.balanced;
|
|
26631
26578
|
enabled = true;
|
|
26579
|
+
_lineOverride;
|
|
26632
26580
|
constructor(colors2, provider) {
|
|
26633
26581
|
this.colors = colors2 ?? DEFAULT_THEME;
|
|
26634
26582
|
this.provider = provider ?? null;
|
|
@@ -26651,9 +26599,7 @@ var SysmonWidget = class {
|
|
|
26651
26599
|
isEnabled() {
|
|
26652
26600
|
return this.enabled && this.provider !== null;
|
|
26653
26601
|
}
|
|
26654
|
-
|
|
26655
|
-
}
|
|
26656
|
-
setStyle(style = "balanced") {
|
|
26602
|
+
setStyle(style = DEFAULT_WIDGET_STYLE) {
|
|
26657
26603
|
const fn = sysmonStyles[style];
|
|
26658
26604
|
if (fn) {
|
|
26659
26605
|
this.styleFn = fn;
|
|
@@ -26663,7 +26609,7 @@ var SysmonWidget = class {
|
|
|
26663
26609
|
this._lineOverride = line;
|
|
26664
26610
|
}
|
|
26665
26611
|
getLine() {
|
|
26666
|
-
return this._lineOverride ?? this.metadata.line ??
|
|
26612
|
+
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
26667
26613
|
}
|
|
26668
26614
|
};
|
|
26669
26615
|
|
|
@@ -26778,13 +26724,10 @@ async function loadSystemInformation() {
|
|
|
26778
26724
|
}
|
|
26779
26725
|
}
|
|
26780
26726
|
var NETWORK_STATS_FILE = "/tmp/claude-scope-network-stats.json";
|
|
26781
|
-
function
|
|
26727
|
+
async function loadNetworkStats() {
|
|
26782
26728
|
try {
|
|
26783
|
-
const fs2 =
|
|
26784
|
-
|
|
26785
|
-
return /* @__PURE__ */ new Map();
|
|
26786
|
-
}
|
|
26787
|
-
const text = fs2.readFileSync(NETWORK_STATS_FILE, "utf-8");
|
|
26729
|
+
const fs2 = await import("node:fs/promises");
|
|
26730
|
+
const text = await fs2.readFile(NETWORK_STATS_FILE, "utf-8");
|
|
26788
26731
|
const data = JSON.parse(text);
|
|
26789
26732
|
if (Date.now() - data.lastUpdate > 5 * 60 * 1e3) {
|
|
26790
26733
|
return /* @__PURE__ */ new Map();
|
|
@@ -26799,34 +26742,50 @@ function loadNetworkStatsSync() {
|
|
|
26799
26742
|
return /* @__PURE__ */ new Map();
|
|
26800
26743
|
}
|
|
26801
26744
|
}
|
|
26802
|
-
|
|
26803
|
-
|
|
26804
|
-
|
|
26805
|
-
|
|
26806
|
-
|
|
26807
|
-
|
|
26808
|
-
};
|
|
26809
|
-
fs2.writeFileSync(NETWORK_STATS_FILE, JSON.stringify(data), "utf-8");
|
|
26810
|
-
} catch {
|
|
26745
|
+
var pendingSave = null;
|
|
26746
|
+
var pendingSaveData = null;
|
|
26747
|
+
async function saveNetworkStats(stats) {
|
|
26748
|
+
pendingSaveData = stats;
|
|
26749
|
+
if (pendingSave) {
|
|
26750
|
+
return;
|
|
26811
26751
|
}
|
|
26752
|
+
pendingSave = (async () => {
|
|
26753
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
26754
|
+
if (!pendingSaveData) {
|
|
26755
|
+
pendingSave = null;
|
|
26756
|
+
return;
|
|
26757
|
+
}
|
|
26758
|
+
try {
|
|
26759
|
+
const fs2 = await import("node:fs/promises");
|
|
26760
|
+
const data = {
|
|
26761
|
+
stats: Object.fromEntries(pendingSaveData),
|
|
26762
|
+
lastUpdate: Date.now()
|
|
26763
|
+
};
|
|
26764
|
+
await fs2.writeFile(NETWORK_STATS_FILE, JSON.stringify(data), "utf-8");
|
|
26765
|
+
} catch {
|
|
26766
|
+
} finally {
|
|
26767
|
+
pendingSave = null;
|
|
26768
|
+
pendingSaveData = null;
|
|
26769
|
+
}
|
|
26770
|
+
})();
|
|
26812
26771
|
}
|
|
26813
26772
|
var SystemProvider = class {
|
|
26814
26773
|
intervalId;
|
|
26815
|
-
lastNetworkStats;
|
|
26774
|
+
lastNetworkStats = /* @__PURE__ */ new Map();
|
|
26816
26775
|
lastErrorTime = 0;
|
|
26817
26776
|
ERROR_LOG_INTERVAL = 6e4;
|
|
26818
26777
|
// 1 minute
|
|
26819
26778
|
initialized = false;
|
|
26820
|
-
|
|
26821
|
-
constructor() {
|
|
26822
|
-
this.lastNetworkStats = loadNetworkStatsSync();
|
|
26823
|
-
this.statsLoaded = true;
|
|
26824
|
-
}
|
|
26779
|
+
networkStatsLoaded = false;
|
|
26825
26780
|
async ensureInitialized() {
|
|
26826
26781
|
if (!this.initialized) {
|
|
26827
26782
|
await loadSystemInformation();
|
|
26828
26783
|
this.initialized = true;
|
|
26829
26784
|
}
|
|
26785
|
+
if (!this.networkStatsLoaded) {
|
|
26786
|
+
this.lastNetworkStats = await loadNetworkStats();
|
|
26787
|
+
this.networkStatsLoaded = true;
|
|
26788
|
+
}
|
|
26830
26789
|
}
|
|
26831
26790
|
async getMetrics() {
|
|
26832
26791
|
await this.ensureInitialized();
|
|
@@ -26851,7 +26810,7 @@ var SystemProvider = class {
|
|
|
26851
26810
|
const diskTotalGB = mainFs.size / 1024 / 1024 / 1024;
|
|
26852
26811
|
const diskPercent = Math.round(mainFs.use);
|
|
26853
26812
|
const iface = Array.isArray(net) && net.length > 0 ? net[0] : net;
|
|
26854
|
-
const networkSpeed = this.calculateNetworkSpeed(iface);
|
|
26813
|
+
const networkSpeed = await this.calculateNetworkSpeed(iface);
|
|
26855
26814
|
return {
|
|
26856
26815
|
cpu: { percent: cpuPercent },
|
|
26857
26816
|
memory: {
|
|
@@ -26891,7 +26850,7 @@ var SystemProvider = class {
|
|
|
26891
26850
|
this.intervalId = void 0;
|
|
26892
26851
|
}
|
|
26893
26852
|
}
|
|
26894
|
-
calculateNetworkSpeed(iface) {
|
|
26853
|
+
async calculateNetworkSpeed(iface) {
|
|
26895
26854
|
if (!iface || iface.iface === void 0) {
|
|
26896
26855
|
return { rxSec: 0, txSec: 0 };
|
|
26897
26856
|
}
|
|
@@ -26904,7 +26863,7 @@ var SystemProvider = class {
|
|
|
26904
26863
|
tx: iface.tx_bytes,
|
|
26905
26864
|
time: now
|
|
26906
26865
|
});
|
|
26907
|
-
|
|
26866
|
+
saveNetworkStats(this.lastNetworkStats);
|
|
26908
26867
|
return { rxSec: 0, txSec: 0 };
|
|
26909
26868
|
}
|
|
26910
26869
|
const timeDiff = Math.max(0.1, (now - last.time) / 1e3);
|
|
@@ -26917,7 +26876,7 @@ var SystemProvider = class {
|
|
|
26917
26876
|
tx: iface.tx_bytes,
|
|
26918
26877
|
time: now
|
|
26919
26878
|
});
|
|
26920
|
-
|
|
26879
|
+
saveNetworkStats(this.lastNetworkStats);
|
|
26921
26880
|
return {
|
|
26922
26881
|
rxSec: Math.max(0, Number(rx_sec.toFixed(2))),
|
|
26923
26882
|
txSec: Math.max(0, Number(tx_sec.toFixed(2)))
|
|
@@ -26964,19 +26923,12 @@ var EmptyLineWidget = class extends StdinDataWidget {
|
|
|
26964
26923
|
5
|
|
26965
26924
|
// Sixth line (0-indexed)
|
|
26966
26925
|
);
|
|
26967
|
-
_lineOverride;
|
|
26968
26926
|
/**
|
|
26969
26927
|
* All styles return the same value (Braille Pattern Blank).
|
|
26970
26928
|
* This method exists for API consistency with other widgets.
|
|
26971
26929
|
*/
|
|
26972
26930
|
setStyle(_style) {
|
|
26973
26931
|
}
|
|
26974
|
-
setLine(line) {
|
|
26975
|
-
this._lineOverride = line;
|
|
26976
|
-
}
|
|
26977
|
-
getLine() {
|
|
26978
|
-
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
26979
|
-
}
|
|
26980
26932
|
/**
|
|
26981
26933
|
* Return Braille Pattern Blank to create a visible empty separator line.
|
|
26982
26934
|
* U+2800 occupies cell width but appears blank, ensuring the line renders.
|
|
@@ -27222,7 +27174,6 @@ function getStraightFlushHighCard(cards, suit) {
|
|
|
27222
27174
|
return getStraightHighCard(suitCards);
|
|
27223
27175
|
}
|
|
27224
27176
|
function getStraightFlushIndices(cards, highCard, suit) {
|
|
27225
|
-
const _suitCards = cards.filter((c) => c.suit === suit);
|
|
27226
27177
|
const suitCardIndices = [];
|
|
27227
27178
|
const indexMap = /* @__PURE__ */ new Map();
|
|
27228
27179
|
for (let i = 0; i < cards.length; i++) {
|
|
@@ -27434,7 +27385,6 @@ function evaluateHand(hole, board) {
|
|
|
27434
27385
|
|
|
27435
27386
|
// src/widgets/poker/styles.ts
|
|
27436
27387
|
init_colors();
|
|
27437
|
-
init_formatters();
|
|
27438
27388
|
var HAND_ABBREVIATIONS = {
|
|
27439
27389
|
"Royal Flush": "RF",
|
|
27440
27390
|
"Straight Flush": "SF",
|
|
@@ -27493,7 +27443,7 @@ function formatHandResult(handResult, colors2) {
|
|
|
27493
27443
|
const playerParticipates = handResult.participatingIndices.some((idx) => idx < 2);
|
|
27494
27444
|
const resultText = !playerParticipates ? `Nothing \u{1F0CF}` : `${handResult.name}! ${handResult.emoji}`;
|
|
27495
27445
|
if (!colors2) return resultText;
|
|
27496
|
-
return
|
|
27446
|
+
return colorize(resultText, colors2.result);
|
|
27497
27447
|
}
|
|
27498
27448
|
function getHandAbbreviation(handResult) {
|
|
27499
27449
|
if (!handResult) {
|
|
@@ -27508,8 +27458,8 @@ function balancedStyle2(data, colors2) {
|
|
|
27508
27458
|
const handStr = holeCards.map((hc, idx) => formatCardByParticipation(hc, participatingSet.has(idx))).join("");
|
|
27509
27459
|
const boardStr = boardCards.map((bc, idx) => formatCardByParticipation(bc, participatingSet.has(idx + 2))).join("");
|
|
27510
27460
|
const labelColor = colors2?.participating ?? lightGray;
|
|
27511
|
-
const handLabel =
|
|
27512
|
-
const boardLabel =
|
|
27461
|
+
const handLabel = colorize("Hand:", labelColor);
|
|
27462
|
+
const boardLabel = colorize("Board:", labelColor);
|
|
27513
27463
|
return `${handLabel} ${handStr}| ${boardLabel} ${boardStr}\u2192 ${formatHandResult(handResult, colors2)}`;
|
|
27514
27464
|
}
|
|
27515
27465
|
var pokerStyles = {
|
|
@@ -27524,7 +27474,7 @@ var pokerStyles = {
|
|
|
27524
27474
|
const abbreviation = getHandAbbreviation(handResult);
|
|
27525
27475
|
const result2 = `${handStr}| ${boardStr}\u2192 ${abbreviation}`;
|
|
27526
27476
|
if (!colors2) return result2;
|
|
27527
|
-
return
|
|
27477
|
+
return colorize(result2, colors2.result);
|
|
27528
27478
|
},
|
|
27529
27479
|
emoji: (data, colors2) => {
|
|
27530
27480
|
const { holeCards, boardCards, handResult } = data;
|
|
@@ -27532,8 +27482,8 @@ var pokerStyles = {
|
|
|
27532
27482
|
const handStr = holeCards.map((hc, idx) => formatCardEmojiByParticipation(hc, participatingSet.has(idx))).join("");
|
|
27533
27483
|
const boardStr = boardCards.map((bc, idx) => formatCardEmojiByParticipation(bc, participatingSet.has(idx + 2))).join("");
|
|
27534
27484
|
const labelColor = colors2?.participating ?? lightGray;
|
|
27535
|
-
const handLabel =
|
|
27536
|
-
const boardLabel =
|
|
27485
|
+
const handLabel = colorize("Hand:", labelColor);
|
|
27486
|
+
const boardLabel = colorize("Board:", labelColor);
|
|
27537
27487
|
return `${handLabel} ${handStr}| ${boardLabel} ${boardStr}\u2192 ${formatHandResult(handResult, colors2)}`;
|
|
27538
27488
|
}
|
|
27539
27489
|
};
|
|
@@ -27556,7 +27506,6 @@ var PokerWidget = class extends StdinDataWidget {
|
|
|
27556
27506
|
THROTTLE_MS = 5e3;
|
|
27557
27507
|
// 5 seconds
|
|
27558
27508
|
colors;
|
|
27559
|
-
_lineOverride;
|
|
27560
27509
|
styleFn = pokerStyles.balanced;
|
|
27561
27510
|
setStyle(style = DEFAULT_WIDGET_STYLE) {
|
|
27562
27511
|
const fn = pokerStyles[style];
|
|
@@ -27564,12 +27513,6 @@ var PokerWidget = class extends StdinDataWidget {
|
|
|
27564
27513
|
this.styleFn = fn;
|
|
27565
27514
|
}
|
|
27566
27515
|
}
|
|
27567
|
-
setLine(line) {
|
|
27568
|
-
this._lineOverride = line;
|
|
27569
|
-
}
|
|
27570
|
-
getLine() {
|
|
27571
|
-
return this._lineOverride ?? this.metadata.line ?? 0;
|
|
27572
|
-
}
|
|
27573
27516
|
constructor(colors2) {
|
|
27574
27517
|
super();
|
|
27575
27518
|
this.colors = colors2 ?? DEFAULT_THEME;
|
|
@@ -27613,7 +27556,6 @@ var PokerWidget = class extends StdinDataWidget {
|
|
|
27613
27556
|
* Format card with appropriate color (red for ♥♦, gray for ♠♣)
|
|
27614
27557
|
*/
|
|
27615
27558
|
formatCardColor(card) {
|
|
27616
|
-
const _color = isRedSuit(card.suit) ? "red" : "gray";
|
|
27617
27559
|
return formatCard(card);
|
|
27618
27560
|
}
|
|
27619
27561
|
renderWithData(_data, _context) {
|