Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
feat(cli): show index storage footprint in status (#681)
Felix-Ayush053dcd923e1b
diff --git a/packages/cli/src/repowise/cli/commands/status_cmd.py b/packages/cli/src/repowise/cli/commands/status_cmd.pyindex a77e7b542..5385e407a 100644--- a/packages/cli/src/repowise/cli/commands/status_cmd.py+++ b/packages/cli/src/repowise/cli/commands/status_cmd.py@@ -2,6 +2,7 @@from __future__ import annotations+import contextlibfrom datetime import UTCfrom pathlib import Path@@ -17,12 +18,25 @@ from repowise.cli.helpers import (resolve_command_target,run_async,)+from repowise.cli.ui.brand import format_bytes# ---------------------------------------------------------------------------# Workspace status# ---------------------------------------------------------------------------+def _index_storage_bytes(repowise_dir: Path) -> int:+ """Return total on-disk size of a repo's ``.repowise/`` directory."""+ if not repowise_dir.is_dir():+ return 0+ total = 0+ for path in repowise_dir.rglob("*"):+ if path.is_file():+ with contextlib.suppress(OSError):+ total += path.stat().st_size+ return total++def _query_repo_counts(repo_path: Path) -> tuple[int, int]:"""Return ``(file_count, symbol_count)`` from a repo's DB."""@@ -249,6 +263,7 @@ def _workspace_status(target: CommandTarget) -> None:table.add_column("Files", justify="right")table.add_column("Symbols", justify="right")table.add_column("Docs", justify="right")+ table.add_column("Storage", justify="right")table.add_column("Indexed", style="dim")table.add_column("HEAD", style="dim")table.add_column("Status")@@ -264,12 +279,13 @@ def _workspace_status(target: CommandTarget) -> None:label += " [bold](primary)[/bold]"if not repowise_dir.exists():- table.add_row(label, "-", "-", "-", "-", "-", "[yellow]not indexed[/yellow]")+ table.add_row(label, "-", "-", "-", "-", "-", "-", "[yellow]not indexed[/yellow]")continuefile_count, symbol_count = _query_repo_counts(abs_path)indexed_ago = _format_relative_time(entry.indexed_at)page_count = _query_page_count(abs_path)+ storage_cell = format_bytes(_index_storage_bytes(repowise_dir))docs_state = load_state(abs_path)docs_enabled = docs_state.get("docs_enabled")@@ -305,6 +321,7 @@ def _workspace_status(target: CommandTarget) -> None:str(file_count),f"{symbol_count:,}",docs_cell,+ storage_cell,indexed_ago,head_short,status,@@ -390,6 +407,7 @@ def status_command(path: str | None, workspace: bool, no_workspace: bool) -> Nonstate_table.add_row("Provider", state.get("provider", "—") or "—")state_table.add_row("Model", state.get("model", "—") or "—")state_table.add_row("Total tokens", f"{state.get('total_tokens', 0):,}")+ state_table.add_row("Index storage", format_bytes(_index_storage_bytes(repowise_dir)))console.print(state_table)# Page counts from DBdiff --git a/packages/cli/src/repowise/cli/ui/__init__.py b/packages/cli/src/repowise/cli/ui/__init__.pyindex f5cf840b3..f9ba0a844 100644--- a/packages/cli/src/repowise/cli/ui/__init__.py+++ b/packages/cli/src/repowise/cli/ui/__init__.py@@ -14,6 +14,7 @@ from repowise.cli.ui.brand import (ERR,OK,WARN,+ format_bytes,format_elapsed,print_banner,print_phase_header,@@ -75,6 +76,7 @@ __all__ = ["build_analysis_summary_panel","build_completion_panel","build_contextual_next_steps",+ "format_bytes","format_elapsed","interactive_advanced_config","interactive_customize_offer",diff --git a/packages/cli/src/repowise/cli/ui/brand.py b/packages/cli/src/repowise/cli/ui/brand.pyindex 39bcfe7fd..08216ada5 100644--- a/packages/cli/src/repowise/cli/ui/brand.py+++ b/packages/cli/src/repowise/cli/ui/brand.py@@ -2,6 +2,8 @@from __future__ import annotations+import math+from rich.console import Consolefrom rich.markup import escapefrom rich.rule import Rule@@ -80,3 +82,19 @@ def format_elapsed(seconds: float) -> str:s = int(seconds) % 60return f"{m}m {s}s"return f"{seconds:.1f}s"+++def format_bytes(num_bytes: int) -> str:+ """Format a byte count as ``512 B``, ``1.5 KB``, ``1.0 MB``, etc."""+ if num_bytes < 0:+ return "—"+ if num_bytes == 0:+ return "0 B"+ units = ("B", "KB", "MB", "GB", "TB")+ exponent = min(int(math.floor(math.log(num_bytes, 1024))), len(units) - 1)+ value = num_bytes / (1024**exponent)+ if value >= 10 or exponent == 0:+ formatted = f"{value:.0f}"+ else:+ formatted = f"{value:.1f}"+ return f"{formatted} {units[exponent]}"diff --git a/tests/unit/cli/test_status_storage.py b/tests/unit/cli/test_status_storage.pynew file mode 100644index 000000000..4163cb754--- /dev/null+++ b/tests/unit/cli/test_status_storage.py@@ -0,0 +1,22 @@+"""Tests for index storage helpers used by ``repowise status``."""++from __future__ import annotations++from pathlib import Path++from repowise.cli.commands import status_cmd+++def test_index_storage_bytes_sums_repowise_files(tmp_path: Path) -> None:+ repowise = tmp_path / ".repowise"+ repowise.mkdir()+ (repowise / "wiki.db").write_bytes(b"x" * 100)+ nested = repowise / "lancedb" / "pages"+ nested.mkdir(parents=True)+ (nested / "chunk.lance").write_bytes(b"y" * 50)++ assert status_cmd._index_storage_bytes(repowise) == 150+++def test_index_storage_bytes_missing_dir() -> None:+ assert status_cmd._index_storage_bytes(Path("/no/such/repowise/dir")) == 0diff --git a/tests/unit/cli/test_ui_package.py b/tests/unit/cli/test_ui_package.pyindex bed64e1c9..05302b0b2 100644--- a/tests/unit/cli/test_ui_package.py+++ b/tests/unit/cli/test_ui_package.py@@ -38,6 +38,7 @@ def test_facade_reexports_public_surface() -> None:"build_analysis_summary_panel","build_completion_panel","build_contextual_next_steps",+ "format_bytes","format_elapsed","LARGE_REPO_FILE_THRESHOLD",# owl mascot additions (additive — everything above is the original surface)@@ -55,6 +56,14 @@ def test_format_elapsed_unchanged() -> None:assert ui.format_elapsed(125.0) == "2m 5s"+def test_format_bytes() -> None:+ assert ui.format_bytes(0) == "0 B"+ assert ui.format_bytes(512) == "512 B"+ assert ui.format_bytes(1536) == "1.5 KB"+ assert ui.format_bytes(1_048_576) == "1.0 MB"+ assert ui.format_bytes(-1) == "—"++def test_should_offer_fast_mode_threshold() -> None:assert ui.should_offer_fast_mode(None) is Falseassert ui.should_offer_fast_mode(RepoScanInfo(total_files=100)) is False