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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: conduct-cli
3
- Version: 0.4.11
3
+ Version: 0.4.12
4
4
  Summary: CLI for Conduct AI — install agents, manage projects, run tests
5
5
  Author-email: Conduct AI <hello@conductai.ai>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "conduct-cli"
7
- version = "0.4.11"
7
+ version = "0.4.12"
8
8
  description = "CLI for Conduct AI — install agents, manage projects, run tests"
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -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.read_text(encoding="utf-8", errors="ignore").splitlines()
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].read_text(encoding="utf-8", errors="ignore").splitlines()
261
+ lines = _tail_lines(files[0])
245
262
  for line in reversed(lines):
246
263
  if "token_count" not in line:
247
264
  continue
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: conduct-cli
3
- Version: 0.4.11
3
+ Version: 0.4.12
4
4
  Summary: CLI for Conduct AI — install agents, manage projects, run tests
5
5
  Author-email: Conduct AI <hello@conductai.ai>
6
6
  License: MIT
File without changes
File without changes
File without changes