cctally 1.61.0 → 1.63.0
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/CHANGELOG.md +15 -0
- package/bin/_cctally_cache.py +156 -6
- package/bin/_cctally_config.py +26 -0
- package/bin/_cctally_dashboard.py +670 -162
- package/bin/_cctally_db.py +27 -1
- package/bin/_cctally_parser.py +15 -0
- package/bin/_cctally_statusline.py +9 -1
- package/bin/_cctally_tui.py +74 -9
- package/bin/_cctally_weekrefs.py +9 -0
- package/bin/_lib_aggregators.py +98 -71
- package/bin/_lib_cache_report.py +455 -67
- package/bin/_lib_pricing.py +31 -4
- package/bin/_lib_snapshot_cache.py +869 -60
- package/bin/_lib_statusline.py +25 -13
- package/package.json +1 -1
package/bin/_lib_statusline.py
CHANGED
|
@@ -54,6 +54,7 @@ class StatuslineArgs:
|
|
|
54
54
|
context_low_threshold: int
|
|
55
55
|
context_medium_threshold: int
|
|
56
56
|
cctally_extensions: bool
|
|
57
|
+
usage_only: bool
|
|
57
58
|
color: bool # ANSI on/off after auto-detect resolved
|
|
58
59
|
display_tz_name: str # IANA name; resolved upstream via
|
|
59
60
|
# get_display_tz_pref(cfg) — defaults to
|
|
@@ -372,6 +373,8 @@ def resolve_cctally_extensions(
|
|
|
372
373
|
inp: StatuslineInput,
|
|
373
374
|
now: datetime,
|
|
374
375
|
inj: StatuslineInjections,
|
|
376
|
+
*,
|
|
377
|
+
include_countdowns: bool = True,
|
|
375
378
|
) -> Optional[str]:
|
|
376
379
|
"""Segment 5 — cctally-only `5h X% (...) · 7d Y% (...)`.
|
|
377
380
|
|
|
@@ -411,12 +414,12 @@ def resolve_cctally_extensions(
|
|
|
411
414
|
parts = []
|
|
412
415
|
if five_pct is not None:
|
|
413
416
|
s = f"5h {int(round(five_pct))}%"
|
|
414
|
-
if five_resets is not None:
|
|
417
|
+
if include_countdowns and five_resets is not None:
|
|
415
418
|
s += f" ({_fmt_countdown(five_resets - now_epoch)})"
|
|
416
419
|
parts.append(s)
|
|
417
420
|
if seven_pct is not None:
|
|
418
421
|
s = f"7d {int(round(seven_pct))}%"
|
|
419
|
-
if seven_resets is not None:
|
|
422
|
+
if include_countdowns and seven_resets is not None:
|
|
420
423
|
s += f" ({_fmt_countdown(seven_resets - now_epoch)})"
|
|
421
424
|
parts.append(s)
|
|
422
425
|
return " · ".join(parts)
|
|
@@ -443,6 +446,19 @@ def _wrap_color(text: str, color: Optional[str], enable: bool) -> str:
|
|
|
443
446
|
_PERCENT_INT_RE = re.compile(r"(\d+)%")
|
|
444
447
|
|
|
445
448
|
|
|
449
|
+
def _colorize_usage_segment(ext: str, args: StatuslineArgs) -> str:
|
|
450
|
+
"""Color a 5h/7d usage segment using the cctally percent bands."""
|
|
451
|
+
nums = [int(x) for x in _PERCENT_INT_RE.findall(ext)]
|
|
452
|
+
mx = max(nums) if nums else 0
|
|
453
|
+
if mx < 60:
|
|
454
|
+
color = "green"
|
|
455
|
+
elif mx < 85:
|
|
456
|
+
color = "yellow"
|
|
457
|
+
else:
|
|
458
|
+
color = "red"
|
|
459
|
+
return _wrap_color(ext, color, args.color)
|
|
460
|
+
|
|
461
|
+
|
|
446
462
|
def render_statusline(
|
|
447
463
|
inp: StatuslineInput,
|
|
448
464
|
args: StatuslineArgs,
|
|
@@ -453,6 +469,12 @@ def render_statusline(
|
|
|
453
469
|
None segments (currently only segment 5). See spec §1 for the exact
|
|
454
470
|
layout and §3 for the data flow.
|
|
455
471
|
"""
|
|
472
|
+
if args.usage_only:
|
|
473
|
+
ext = resolve_cctally_extensions(
|
|
474
|
+
inp, now, inj, include_countdowns=False
|
|
475
|
+
)
|
|
476
|
+
return "" if ext is None else _colorize_usage_segment(ext, args)
|
|
477
|
+
|
|
456
478
|
seg1 = resolve_model_segment(inp)
|
|
457
479
|
|
|
458
480
|
# Segment 2: 💰 ... session / ... today / ... block (Xh Ym left)
|
|
@@ -486,17 +508,7 @@ def render_statusline(
|
|
|
486
508
|
if args.cctally_extensions:
|
|
487
509
|
ext = resolve_cctally_extensions(inp, now, inj)
|
|
488
510
|
if ext is not None:
|
|
489
|
-
|
|
490
|
-
# <60 green, <85 yellow, >=85 red.
|
|
491
|
-
nums = [int(x) for x in _PERCENT_INT_RE.findall(ext)]
|
|
492
|
-
mx = max(nums) if nums else 0
|
|
493
|
-
if mx < 60:
|
|
494
|
-
color = "green"
|
|
495
|
-
elif mx < 85:
|
|
496
|
-
color = "yellow"
|
|
497
|
-
else:
|
|
498
|
-
color = "red"
|
|
499
|
-
seg5 = _wrap_color(ext, color, args.color)
|
|
511
|
+
seg5 = _colorize_usage_segment(ext, args)
|
|
500
512
|
|
|
501
513
|
segs = [seg1, seg2, seg3, seg4]
|
|
502
514
|
if seg5 is not None:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cctally",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.63.0",
|
|
4
4
|
"description": "Claude Code usage tracker and local dashboard for Pro/Max subscription limits - weekly cost-per-percent trend, quota forecasts, threshold alerts. ccusage-compatible.",
|
|
5
5
|
"homepage": "https://github.com/omrikais/cctally",
|
|
6
6
|
"repository": {
|