prune_judge_sessions.py¶
scripts/prune_judge_sessions.py
Remove the CLI session transcripts the acceptance grader's judge calls leave behind.
main
int prune_judge_sessions.main()
Prune the named directory, or this checkout's session directory.
scripts/prune_judge_sessions.py:63
Source · 11 lines
def main() -> int:
"""@brief Entry point. @return 0."""
target = Path(sys.argv[1]) if len(sys.argv) > 1 else session_dir(Path.cwd().resolve())
if not target.is_dir():
print(f"no session directory at {target}; nothing to prune")
return 0
removed, freed = prune(target)
print(f"removed {removed} judge transcript(s), {freed / 1e9:.2f} GB, from {target}")
return 0
Activity · 7 steps
Flows
prune
tuple[int, int] prune_judge_sessions.prune(Path directory)
Remove every judge transcript directly under a directory.
scripts/prune_judge_sessions.py:46
Source · 13 lines
def prune(directory: Path) -> tuple[int, int]:
"""@brief Prune. @return (removed, freed)."""
removed = freed = 0
for path in directory.glob("*.jsonl"):
with path.open("rb") as handle:
head = handle.read(_HEAD_BYTES)
if _JUDGE_MARK in head:
freed += path.stat().st_size
path.unlink()
removed += 1
return removed, freed
Activity · 9 steps
Flows
session_dir
Path prune_judge_sessions.session_dir(Path cwd)
The CLI's session directory for a working directory.
scripts/prune_judge_sessions.py:36
Source · 5 lines
def session_dir(cwd: Path) -> Path:
"""@brief Session dir for a cwd. @return The path."""
return Path.home() / ".claude" / "projects" / re.sub(r"[^A-Za-z0-9]", "-", str(cwd))