conduct-cli 0.4.11__tar.gz → 0.4.12__tar.gz
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.
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/PKG-INFO +1 -1
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/pyproject.toml +1 -1
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/src/conduct_cli/guard.py +19 -2
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/src/conduct_cli.egg-info/PKG-INFO +1 -1
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/README.md +0 -0
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/setup.cfg +0 -0
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/setup.py +0 -0
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/src/conduct_cli/__init__.py +0 -0
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/src/conduct_cli/api.py +0 -0
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/src/conduct_cli/guardmcp.py +0 -0
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/src/conduct_cli/main.py +0 -0
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/src/conduct_cli.egg-info/SOURCES.txt +0 -0
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/src/conduct_cli.egg-info/dependency_links.txt +0 -0
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/src/conduct_cli.egg-info/entry_points.txt +0 -0
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/src/conduct_cli.egg-info/requires.txt +0 -0
- {conduct_cli-0.4.11 → conduct_cli-0.4.12}/src/conduct_cli.egg-info/top_level.txt +0 -0
|
@@ -198,13 +198,30 @@ def _post_usage(session_id, tool_name, tokens_input, tokens_output, duration_ms)
|
|
|
198
198
|
)
|
|
199
199
|
|
|
200
200
|
|
|
201
|
+
def _tail_lines(path, n=200):
|
|
202
|
+
"""Read last n lines of a file efficiently without loading the whole file."""
|
|
203
|
+
size = path.stat().st_size
|
|
204
|
+
if size == 0:
|
|
205
|
+
return []
|
|
206
|
+
chunk = min(size, n * 300) # ~300 bytes per line estimate
|
|
207
|
+
with open(path, "rb") as f:
|
|
208
|
+
f.seek(max(0, size - chunk))
|
|
209
|
+
raw = f.read()
|
|
210
|
+
text = raw.decode("utf-8", errors="ignore")
|
|
211
|
+
lines = text.splitlines()
|
|
212
|
+
# If we didn't seek to start, first line may be partial — drop it
|
|
213
|
+
if size > chunk:
|
|
214
|
+
lines = lines[1:]
|
|
215
|
+
return lines
|
|
216
|
+
|
|
217
|
+
|
|
201
218
|
def _read_tokens_from_transcript(transcript_path, tool_use_id):
|
|
202
219
|
"""Read token counts from Claude Code transcript (matched by tool_use_id)."""
|
|
203
220
|
try:
|
|
204
221
|
path = Path(transcript_path)
|
|
205
222
|
if not path.exists() or not tool_use_id:
|
|
206
223
|
return 0, 0
|
|
207
|
-
lines = path
|
|
224
|
+
lines = _tail_lines(path)
|
|
208
225
|
for line in reversed(lines):
|
|
209
226
|
if not line.strip() or "tool_use" not in line:
|
|
210
227
|
continue
|
|
@@ -241,7 +258,7 @@ def _read_codex_tokens():
|
|
|
241
258
|
files = sorted(sessions_dir.rglob("*.jsonl"), key=lambda p: p.stat().st_mtime, reverse=True)
|
|
242
259
|
if not files:
|
|
243
260
|
return 0, 0
|
|
244
|
-
lines = files[0]
|
|
261
|
+
lines = _tail_lines(files[0])
|
|
245
262
|
for line in reversed(lines):
|
|
246
263
|
if "token_count" not in line:
|
|
247
264
|
continue
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|