clockwork-cli 0.4.0__py3-none-any.whl → 0.4.1__py3-none-any.whl
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.
- clockwork_cli/__init__.py +73 -7
- {clockwork_cli-0.4.0.dist-info → clockwork_cli-0.4.1.dist-info}/METADATA +1 -1
- clockwork_cli-0.4.1.dist-info/RECORD +8 -0
- clockwork_cli-0.4.0.dist-info/RECORD +0 -8
- {clockwork_cli-0.4.0.dist-info → clockwork_cli-0.4.1.dist-info}/WHEEL +0 -0
- {clockwork_cli-0.4.0.dist-info → clockwork_cli-0.4.1.dist-info}/entry_points.txt +0 -0
- {clockwork_cli-0.4.0.dist-info → clockwork_cli-0.4.1.dist-info}/licenses/LICENSE +0 -0
- {clockwork_cli-0.4.0.dist-info → clockwork_cli-0.4.1.dist-info}/top_level.txt +0 -0
clockwork_cli/__init__.py
CHANGED
|
@@ -47,7 +47,7 @@ Examples:
|
|
|
47
47
|
|
|
48
48
|
Data sources:
|
|
49
49
|
claude → ~/.claude/projects/<encoded-path>/*.jsonl
|
|
50
|
-
codex → $CODEX_HOME/sessions/**/rollout-*.jsonl (default ~/.codex/sessions)
|
|
50
|
+
codex → $CODEX_HOME/sessions/**/rollout-*.jsonl[.zst] (default ~/.codex/sessions)
|
|
51
51
|
|
|
52
52
|
Token usage (--tokens):
|
|
53
53
|
Both tools log per-response usage, counted differently, so clockwork
|
|
@@ -76,7 +76,7 @@ import hashlib
|
|
|
76
76
|
from datetime import datetime, timedelta, timezone
|
|
77
77
|
from collections import defaultdict
|
|
78
78
|
|
|
79
|
-
__version__ = "0.4.
|
|
79
|
+
__version__ = "0.4.1"
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
def _resolve_claude_dir():
|
|
@@ -626,13 +626,79 @@ def claude_list():
|
|
|
626
626
|
|
|
627
627
|
|
|
628
628
|
# --------------------------------------------------------------------------- #
|
|
629
|
-
# Codex backend ($CODEX_HOME/sessions/**/rollout-*.jsonl)
|
|
629
|
+
# Codex backend ($CODEX_HOME/sessions/**/rollout-*.jsonl[.zst])
|
|
630
630
|
# --------------------------------------------------------------------------- #
|
|
631
631
|
|
|
632
632
|
def _codex_files():
|
|
633
|
+
"""Every rollout under $CODEX_HOME/sessions, plain or zstd-compressed.
|
|
634
|
+
|
|
635
|
+
Newer Codex versions save finished rollouts as `rollout-*.jsonl.zst`.
|
|
636
|
+
If a rollout exists in both forms, the newer file wins so it is counted
|
|
637
|
+
once.
|
|
638
|
+
"""
|
|
633
639
|
codex_home = os.environ.get("CODEX_HOME", os.path.expanduser("~/.codex"))
|
|
634
|
-
|
|
635
|
-
|
|
640
|
+
root = os.path.join(codex_home, "sessions", "**")
|
|
641
|
+
found = {}
|
|
642
|
+
for pattern in ("rollout-*.jsonl", "rollout-*.jsonl.zst"):
|
|
643
|
+
for f in glob.glob(os.path.join(root, pattern), recursive=True):
|
|
644
|
+
key = f[:-4] if f.endswith(".zst") else f
|
|
645
|
+
prev = found.get(key)
|
|
646
|
+
if prev is None or _mtime(f) > _mtime(prev):
|
|
647
|
+
found[key] = f
|
|
648
|
+
return sorted(found.values())
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
def _mtime(path):
|
|
652
|
+
try:
|
|
653
|
+
return os.path.getmtime(path)
|
|
654
|
+
except OSError:
|
|
655
|
+
return 0
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
def _zstd_decompress(data):
|
|
659
|
+
"""Decompress zstd bytes with whatever is available.
|
|
660
|
+
|
|
661
|
+
Python 3.14 ships `compression.zstd`; otherwise try the `zstandard`
|
|
662
|
+
package, then the `zstd` command-line tool.
|
|
663
|
+
"""
|
|
664
|
+
try:
|
|
665
|
+
from compression import zstd
|
|
666
|
+
return zstd.decompress(data)
|
|
667
|
+
except ImportError:
|
|
668
|
+
pass
|
|
669
|
+
try:
|
|
670
|
+
import zstandard
|
|
671
|
+
return zstandard.ZstdDecompressor().decompressobj().decompress(data)
|
|
672
|
+
except ImportError:
|
|
673
|
+
pass
|
|
674
|
+
import subprocess
|
|
675
|
+
try:
|
|
676
|
+
return subprocess.run(["zstd", "-dc"], input=data, stdout=subprocess.PIPE,
|
|
677
|
+
stderr=subprocess.DEVNULL, check=True).stdout
|
|
678
|
+
except (OSError, subprocess.CalledProcessError) as e:
|
|
679
|
+
raise OSError("cannot decompress zstd file (needs Python 3.14+, "
|
|
680
|
+
"the zstandard package, or the zstd tool)") from e
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
_zstd_warned = False
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
def _open_log(path):
|
|
687
|
+
"""Open a JSONL log for text reading, decompressing `.zst` files."""
|
|
688
|
+
global _zstd_warned
|
|
689
|
+
if not path.endswith(".zst"):
|
|
690
|
+
return open(path, encoding="utf-8")
|
|
691
|
+
import io
|
|
692
|
+
with open(path, "rb") as fh:
|
|
693
|
+
raw = fh.read()
|
|
694
|
+
try:
|
|
695
|
+
data = _zstd_decompress(raw)
|
|
696
|
+
except OSError as e:
|
|
697
|
+
if not _zstd_warned:
|
|
698
|
+
_zstd_warned = True
|
|
699
|
+
print("clockwork: skipping .zst Codex logs: %s" % e, file=sys.stderr)
|
|
700
|
+
raise
|
|
701
|
+
return io.StringIO(data.decode("utf-8", errors="replace"))
|
|
636
702
|
|
|
637
703
|
|
|
638
704
|
_CODEX_TOKEN_KEYS = ("input_tokens", "cached_input_tokens",
|
|
@@ -710,7 +776,7 @@ def _codex_scan_file(path):
|
|
|
710
776
|
first_model = None
|
|
711
777
|
running = {k: 0 for k in _CODEX_TOKEN_KEYS}
|
|
712
778
|
try:
|
|
713
|
-
with
|
|
779
|
+
with _open_log(path) as fh:
|
|
714
780
|
for line in fh:
|
|
715
781
|
line = line.strip()
|
|
716
782
|
if not line:
|
|
@@ -812,7 +878,7 @@ def _codex_cwd_only(path):
|
|
|
812
878
|
the `session_meta` record carrying `cwd` is at the top of the rollout.
|
|
813
879
|
"""
|
|
814
880
|
try:
|
|
815
|
-
with
|
|
881
|
+
with _open_log(path) as fh:
|
|
816
882
|
for line in fh:
|
|
817
883
|
line = line.strip()
|
|
818
884
|
if not line:
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
clockwork_cli/__init__.py,sha256=WRSKoYRZAtL1kwyJeJnzLvI0Zv-e-9SC9WfQII8mVms,69130
|
|
2
|
+
clockwork_cli/__main__.py,sha256=HcXz3nL5ocmXEASzCOKbjM3Sj6czPe8sqJSXglAjBw0,39
|
|
3
|
+
clockwork_cli-0.4.1.dist-info/licenses/LICENSE,sha256=pz4uy4Ra9e-Ks0T7UFFi8rGL86-f29m2ZOB0WgixjLY,1068
|
|
4
|
+
clockwork_cli-0.4.1.dist-info/METADATA,sha256=h8KkoxESMfPz3QxSBQ0hEIwXvWPc2dbma3g7KEPwfng,18699
|
|
5
|
+
clockwork_cli-0.4.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
6
|
+
clockwork_cli-0.4.1.dist-info/entry_points.txt,sha256=wmiWdgLrHpNKK9wDwCOiX4zyLFx71_G5DzydSiu8DWs,49
|
|
7
|
+
clockwork_cli-0.4.1.dist-info/top_level.txt,sha256=g5lh3hqDChq8bNBmiN2Kze86weZTddLJspNABd-2ckg,14
|
|
8
|
+
clockwork_cli-0.4.1.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
clockwork_cli/__init__.py,sha256=FNZlwic6dPdVUWvhfWNiLlzkyRJKaTmRTIR6KaotdPc,67041
|
|
2
|
-
clockwork_cli/__main__.py,sha256=HcXz3nL5ocmXEASzCOKbjM3Sj6czPe8sqJSXglAjBw0,39
|
|
3
|
-
clockwork_cli-0.4.0.dist-info/licenses/LICENSE,sha256=pz4uy4Ra9e-Ks0T7UFFi8rGL86-f29m2ZOB0WgixjLY,1068
|
|
4
|
-
clockwork_cli-0.4.0.dist-info/METADATA,sha256=9O2honRVQao8H1Q3_zoiwxk3k_6G4-JhEVDLqmS-ZXY,18699
|
|
5
|
-
clockwork_cli-0.4.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
6
|
-
clockwork_cli-0.4.0.dist-info/entry_points.txt,sha256=wmiWdgLrHpNKK9wDwCOiX4zyLFx71_G5DzydSiu8DWs,49
|
|
7
|
-
clockwork_cli-0.4.0.dist-info/top_level.txt,sha256=g5lh3hqDChq8bNBmiN2Kze86weZTddLJspNABd-2ckg,14
|
|
8
|
-
clockwork_cli-0.4.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|