|
15 | 15 | import sys |
16 | 16 | from datetime import datetime, timezone |
17 | 17 |
|
18 | | -BUDDY_FACE = "\u25d5\u203f\u25d5" # ◕‿◕ |
| 18 | +# --- lib import bootstrap --- |
| 19 | +# statusLine entry script: sys.path insertion here is intentional so |
| 20 | +# lib/* imports work when Claude Code invokes `python codingbuddy-hud.py`. |
| 21 | +_LIB_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "lib") |
| 22 | +if _LIB_DIR not in sys.path: |
| 23 | + sys.path.insert(0, _LIB_DIR) |
| 24 | + |
| 25 | +# === test_hud.py compatibility re-exports — DO NOT REMOVE without coordinated test update === |
| 26 | +from hud_buddy import BUDDY_FACE # canonical SSoT via tiny_actor_presets |
| 27 | +from hud_rate_limits import format_rate_limits |
| 28 | +from hud_version import get_fresh_version as _get_fresh_version # backcompat alias |
19 | 29 |
|
20 | 30 | # Agent eye glyphs from .ai-rules agent definitions. |
21 | 31 | AGENT_GLYPHS = { |
@@ -303,25 +313,6 @@ def resolve_model_label(stdin_data: dict) -> tuple: |
303 | 313 | return (model_id, display_name) |
304 | 314 |
|
305 | 315 |
|
306 | | -def format_rate_limits(stdin_data: dict) -> str: |
307 | | - """Format rate-limit info if present. Returns '' when absent.""" |
308 | | - rl = stdin_data.get("rate_limits") |
309 | | - if not rl: |
310 | | - return "" |
311 | | - parts = [] |
312 | | - five = rl.get("five_hour") |
313 | | - if five: |
314 | | - pct = five.get("used_percentage", 0) |
315 | | - parts.append(f"5h:{pct:.0f}%") |
316 | | - seven = rl.get("seven_day") |
317 | | - if seven: |
318 | | - pct = seven.get("used_percentage", 0) |
319 | | - parts.append(f"7d:{pct:.0f}%") |
320 | | - if not parts: |
321 | | - return "" |
322 | | - return "RL:" + ",".join(parts) |
323 | | - |
324 | | - |
325 | 316 | def format_worktree(stdin_data: dict) -> str: |
326 | 317 | """Format worktree name if present. Returns '' when absent.""" |
327 | 318 | wt = stdin_data.get("worktree") |
@@ -395,28 +386,6 @@ def format_badge_line(agent: str, focus: str, blocker_count) -> str: |
395 | 386 | return " ".join(badges) |
396 | 387 |
|
397 | 388 |
|
398 | | -def _get_fresh_version(hud_state: dict, *, plugins_file: str = "") -> str: |
399 | | - """Return the most current plugin version. |
400 | | -
|
401 | | - Prefers installed_plugins.json (authoritative after updates) |
402 | | - over the hud-state snapshot written at session start. |
403 | | - Pass *plugins_file* explicitly for testing. |
404 | | - """ |
405 | | - try: |
406 | | - lib_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "lib") |
407 | | - if lib_dir not in sys.path: |
408 | | - sys.path.insert(0, lib_dir) |
409 | | - from hud_helpers import read_installed_version |
410 | | - |
411 | | - kwargs = {"plugins_file": plugins_file} if plugins_file else {} |
412 | | - fresh = read_installed_version(**kwargs) |
413 | | - if fresh: |
414 | | - return fresh |
415 | | - except Exception: |
416 | | - pass |
417 | | - return hud_state.get("version", "") |
418 | | - |
419 | | - |
420 | 389 | def format_status_line( |
421 | 390 | stdin_data: dict, |
422 | 391 | hud_state: dict, |
|
0 commit comments