Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

feat(cli): add --verbose/-v to health (#943)

Loi Nguyena80b831fbf91
diff --git a/docs/CLI_REFERENCE.md b/docs/CLI_REFERENCE.md
index 573a69c87..e3a420662 100644
--- a/docs/CLI_REFERENCE.md
+++ b/docs/CLI_REFERENCE.md
@@ -461,6 +461,7 @@ Compute per-file code-health scores from 25 deterministic markers (McCabe comple
| `--safe-only` | Documented no-op placeholder for a future confidence filter; has no effect today |
| `--repo` | In workspace mode, target a specific repo (defaults to primary) |
| `--no-workspace` | Force single-repo mode |
+| `--verbose`, `-v` | Show debug logs from the analysis pipeline |
```bash
repowise health # KPIs + lowest-scoring files
diff --git a/packages/cli/src/repowise/cli/commands/health_cmd/command.py b/packages/cli/src/repowise/cli/commands/health_cmd/command.py
index e144a8f85..ad3b085e3 100644
--- a/packages/cli/src/repowise/cli/commands/health_cmd/command.py
+++ b/packages/cli/src/repowise/cli/commands/health_cmd/command.py
@@ -13,6 +13,7 @@ from pathlib import Path
import click
from rich.table import Table
+from repowise.cli._setup import configure_cli_logging
from repowise.cli.helpers import (
console,
err_console,
@@ -105,6 +106,13 @@ from .trends import _render_trend
default=False,
help="Print a ready-to-paste health badge (Markdown) for this repo's README.",
)
+ "--verbose",
+ "-v",
+ is_flag=True,
+ default=False,
+ help="Show debug logs from the pipeline.",
+)
def health_command(
path: str | None,
file_filter: str | None,
@@ -117,12 +125,15 @@ def health_command(
module_filter: str | None,
trend_view: bool,
badge_view: bool,
+ verbose: bool,
) -> None:
"""Compute code-health scores from markers (CCN, nesting, brain-method).
Runs in-process — no LLM, no network. Re-uses the repowise ingestion
parser, graph builder, and git indexer.
"""
+ configure_cli_logging(verbose=verbose)
+
from pathlib import Path as PathlibPath
from repowise.core.analysis.health import HealthAnalyzer
diff --git a/tests/unit/cli/test_health_cmd_logging.py b/tests/unit/cli/test_health_cmd_logging.py
new file mode 100644
index 000000000..9a8468917
--- /dev/null
+++ b/tests/unit/cli/test_health_cmd_logging.py
@@ -0,0 +1,38 @@
+"""Tests for logging setup at the ``health`` command boundary."""
+
+from __future__ import annotations
+
+import click
+import pytest
+from click.testing import CliRunner
+
+from repowise.cli.commands.health_cmd import command as health_cmd
+from repowise.cli.main import cli
+
+
+ ("extra_args", "expected_verbose"),
+ [([], False), (["--verbose"], True)],
+)
+def test_health_configures_logging_before_target_resolution(
+ monkeypatch: pytest.MonkeyPatch,
+ extra_args: list[str],
+ expected_verbose: bool,
+) -> None:
+ events: list[tuple[str, bool | None]] = []
+
+ def fake_configure_cli_logging(*, verbose: bool = False) -> None:
+ events.append(("logging", verbose))
+
+ def fake_resolve_command_target(**_kwargs: object) -> None:
+ events.append(("target", None))
+ raise click.ClickException("stop after target resolution")
+
+ monkeypatch.setattr(health_cmd, "configure_cli_logging", fake_configure_cli_logging)
+ monkeypatch.setattr(health_cmd, "resolve_command_target", fake_resolve_command_target)
+
+ result = CliRunner().invoke(cli, ["health", *extra_args])
+
+ assert result.exit_code == 1
+ assert "stop after target resolution" in result.output
+ assert events == [("logging", expected_verbose), ("target", None)]