()
| 296 | |
| 297 | |
| 298 | def warn_stale_worktrees() -> None: |
| 299 | try: |
| 300 | n = count_stale_worktrees() |
| 301 | except KeyboardInterrupt: |
| 302 | import _thread |
| 303 | |
| 304 | _thread.interrupt_main() |
| 305 | raise |
| 306 | except OSError as exc: |
| 307 | # Don't crash the stop hook on a directory-scan failure, but do |
| 308 | # surface the descriptive error so it isn't silently swallowed. |
| 309 | print(f"warn_stale_worktrees: {exc}", file=sys.stderr) |
| 310 | return |
| 311 | if n > STALE_WORKTREE_THRESHOLD: |
| 312 | print( |
| 313 | f"Note: {n} stale agent worktrees in .claude/worktrees/, " |
| 314 | "run `bash clean-worktrees` to reclaim space", |
| 315 | file=sys.stderr, |
| 316 | ) |
| 317 | |
| 318 | |
| 319 | def _fmt_seconds(seconds: float) -> str: |
no test coverage detected