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): clearer labels in risk, dead-code, whats-new and the generation report (#4197)

Raghav Chamadiya9e6c0130ef89
diff --git a/docs/layers/DEAD_CODE.md b/docs/layers/DEAD_CODE.md
index 02ef603bf..42da74c57 100644
--- a/docs/layers/DEAD_CODE.md
+++ b/docs/layers/DEAD_CODE.md
@@ -25,7 +25,7 @@ repowise dead-code --kind unused_export --format json
unreachable_file src/legacy/parser.ts 100% ✗ 212 File has no importers (in_degree=0)
unreachable_file config/feature_flags.py 40% ✗ 31 File has no importers (in_degree=0)
-Cleanup-candidate lines: 14 (high 2, medium 1 confidence)
+Cleanup-candidate lines: 14 · findings by confidence: high 2, medium 1
```
From an agent, `get_dead_code()` or `get_dead_code(tier="high", safe_only=True)`.
diff --git a/packages/cli/src/repowise/cli/commands/dead_code_cmd.py b/packages/cli/src/repowise/cli/commands/dead_code_cmd.py
index 4392acda2..562e1ccc2 100644
--- a/packages/cli/src/repowise/cli/commands/dead_code_cmd.py
+++ b/packages/cli/src/repowise/cli/commands/dead_code_cmd.py
@@ -377,7 +377,7 @@ def dead_code_command(
)
console.print(
f"\nCleanup-candidate lines: [bold]{report.deletable_lines:,}[/bold]"
- + (f" ({tiers} confidence)" if tiers else "")
+ + (f" · findings by confidence: {tiers}" if tiers else "")
)
if report.hidden_below_threshold:
console.print(
diff --git a/packages/cli/src/repowise/cli/commands/risk_cmd/change_render.py b/packages/cli/src/repowise/cli/commands/risk_cmd/change_render.py
index 767e25097..a26734580 100644
--- a/packages/cli/src/repowise/cli/commands/risk_cmd/change_render.py
+++ b/packages/cli/src/repowise/cli/commands/risk_cmd/change_render.py
@@ -122,8 +122,11 @@ def _print_change_facts(result: ChangeRiskResult) -> None:
features, request_excludes = result.features, result.request_excludes
if result.working_tree:
console.print(" [dim]Scoring your uncommitted changes, not the last commit.[/dim]")
+ # A range's subject is its head commit's; its fix flag covers every commit.
+ is_range = ".." in features.ref
if features.subject:
- console.print(f" [dim]{features.subject}[/dim]")
+ head = "Head commit: " if is_range else ""
+ console.print(f" [dim]{head}{features.subject}[/dim]")
if request_excludes:
console.print(f" [dim]Excluding {len(request_excludes)} pattern(s).[/dim]")
console.print(
@@ -131,7 +134,11 @@ def _print_change_facts(result: ChangeRiskResult) -> None:
f"{features.nd} dirs · {features.ns} subsystems · "
f"entropy {features.entropy:.2f} · author exp "
f"{'unknown' if features.exp is None else features.exp}"
- + (" [magenta](fix)[/magenta]" if features.is_fix else "")
+ + (
+ f" [magenta]({'range contains a fix' if is_range else 'fix'})[/magenta]"
+ if features.is_fix
+ else ""
+ )
)
diff --git a/packages/cli/src/repowise/cli/whats_new.py b/packages/cli/src/repowise/cli/whats_new.py
index d3a0de0c5..bcf0286ca 100644
--- a/packages/cli/src/repowise/cli/whats_new.py
+++ b/packages/cli/src/repowise/cli/whats_new.py
@@ -26,7 +26,11 @@ from repowise.core.upgrade.changelog import (
entries_between,
parse_changelog,
)
-from repowise.core.upgrade.release import BUNDLED_CHANGELOG_PATH, load_release_stats
+from repowise.core.upgrade.release import (
+ BUNDLED_CHANGELOG_PATH,
+ is_newer_version,
+ load_release_stats,
+)
from .helpers import user_global_dir
from .update_check import windows_upgrade_caveat
@@ -90,6 +94,11 @@ def read_last_seen_version() -> str | None:
def write_last_seen_version(version: str) -> None:
+ """Record *version* as seen; never lowers the marker, so an older install
+ cannot make the next upgrade re-show releases already read."""
+ previous = read_last_seen_version()
+ if previous and is_newer_version(previous, version):
+ return
with contextlib.suppress(Exception): # best-effort marker
(user_global_dir() / _LAST_SEEN_FILENAME).write_text(version, encoding="utf-8")
diff --git a/packages/core/src/repowise/core/generation/report.py b/packages/core/src/repowise/core/generation/report.py
index f53c64d4c..ddea18035 100644
--- a/packages/core/src/repowise/core/generation/report.py
+++ b/packages/core/src/repowise/core/generation/report.py
@@ -486,7 +486,7 @@ def render_generation_checks(report: GenerationReport, console: object) -> None:
questions_text = report.question_block_summary()
if report.questions_missing:
questions_text = f"[yellow]{questions_text}[/yellow]"
- table.add_row("Question-shaped text", questions_text)
+ table.add_row("Pages with question text", questions_text)
frames = report.opening_frames
frames_text = frames.summary_line()
diff --git a/tests/unit/cli/test_change_render_range.py b/tests/unit/cli/test_change_render_range.py
new file mode 100644
index 000000000..23954efcd
--- /dev/null
+++ b/tests/unit/cli/test_change_render_range.py
@@ -0,0 +1,46 @@
+"""A range names its head commit's subject and says its fix flag covers the range."""
+
+from __future__ import annotations
+
+from types import SimpleNamespace
+
+import pytest
+from rich.console import Console
+
+from repowise.cli.commands.risk_cmd import change_render
+
+
+def _facts(monkeypatch, ref: str, *, is_fix: bool = True) -> str:
+ console = Console(record=True, width=200)
+ monkeypatch.setattr(change_render, "console", console)
+ features = SimpleNamespace(
+ ref=ref, subject="fix: the parser", is_fix=is_fix,
+ la=10, ld=2, nf=3, nd=1, ns=1, entropy=0.5, exp=40,
+ ) # fmt: skip
+ result = SimpleNamespace(features=features, request_excludes=(), working_tree=False)
+ change_render._print_change_facts(result)
+ return console.export_text()
+
+
[email protected]("ref", ["a..b", "a...b"])
+def test_range_labels_head_commit_and_range_fix(monkeypatch, ref):
+ out = _facts(monkeypatch, ref)
+
+ assert "Head commit: fix: the parser" in out
+ assert "(range contains a fix)" in out
+
+
+def test_single_commit_keeps_plain_subject_and_fix(monkeypatch):
+ out = _facts(monkeypatch, "abc123")
+
+ assert "Head commit:" not in out
+ assert "fix: the parser" in out
+ assert "(fix)" in out
+ assert "range contains" not in out
+
+
+def test_range_without_fix_has_no_tag(monkeypatch):
+ out = _facts(monkeypatch, "a..b", is_fix=False)
+
+ assert "Head commit: fix: the parser" in out
+ assert "(range contains a fix)" not in out
diff --git a/tests/unit/cli/test_dead_code_stored.py b/tests/unit/cli/test_dead_code_stored.py
index 060d35d20..02cdbfb89 100644
--- a/tests/unit/cli/test_dead_code_stored.py
+++ b/tests/unit/cli/test_dead_code_stored.py
@@ -195,3 +195,14 @@ def test_safe_only_rereads_a_stored_safe_flag_through_the_gate(indexed_repo, mon
out = _md(indexed_repo, "--safe-only")
assert "gone/settings.py" not in out
assert "1 finding(s), none deletion-ready" in out
+
+
+def test_footer_names_the_tier_counts_as_findings(indexed_repo, monkeypatch):
+ monkeypatch.setattr(dead_code_cmd, "_analyze_live", None)
+
+ result = CliRunner().invoke(dead_code_command, [str(indexed_repo), "--no-workspace"])
+
+ assert result.exit_code == 0, result.output
+ assert "Cleanup-candidate lines:" in result.output
+ assert "findings by confidence: high 1" in result.output
+ assert "confidence)" not in result.output
diff --git a/tests/unit/generation/test_question_block_report.py b/tests/unit/generation/test_question_block_report.py
index 94c65608e..ae1c9adde 100644
--- a/tests/unit/generation/test_question_block_report.py
+++ b/tests/unit/generation/test_question_block_report.py
@@ -99,4 +99,4 @@ def test_the_check_prints_even_when_it_measured_nothing():
buffer = StringIO()
render_generation_checks(GenerationReport.from_pages([]), Console(file=buffer, width=100))
- assert "Question-shaped text" in buffer.getvalue()
+ assert "Pages with question text" in buffer.getvalue()
diff --git a/tests/unit/upgrade/test_whats_new.py b/tests/unit/upgrade/test_whats_new.py
index dd2dbc43e..937bf57ce 100644
--- a/tests/unit/upgrade/test_whats_new.py
+++ b/tests/unit/upgrade/test_whats_new.py
@@ -55,6 +55,30 @@ def test_last_seen_roundtrip(monkeypatch, tmp_path):
assert wn.read_last_seen_version() is None
wn.write_last_seen_version("0.21.0")
assert wn.read_last_seen_version() == "0.21.0"
+ # An older install never lowers the marker; a newer one raises it.
+ wn.write_last_seen_version("0.20.0")
+ assert wn.read_last_seen_version() == "0.21.0"
+ wn.write_last_seen_version("0.22.0")
+ assert wn.read_last_seen_version() == "0.22.0"
+
+
+def test_last_seen_equal_or_suffixed_version_keeps_the_number(monkeypatch, tmp_path):
+ _redirect_global_dir(monkeypatch, tmp_path)
+ wn.write_last_seen_version("0.22.0")
+ wn.write_last_seen_version("0.22.0")
+ assert wn.read_last_seen_version() == "0.22.0"
+ # A pre-release or dev build of the same number compares equal, never lower.
+ wn.write_last_seen_version("0.22.0rc1")
+ assert wn.read_last_seen_version() == "0.22.0rc1"
+ wn.write_last_seen_version("0.21.9.dev1")
+ assert wn.read_last_seen_version() == "0.22.0rc1"
+
+
+def test_last_seen_unparsable_marker_is_replaced(monkeypatch, tmp_path):
+ _redirect_global_dir(monkeypatch, tmp_path)
+ wn.write_last_seen_version("not-a-version")
+ wn.write_last_seen_version("0.20.0")
+ assert wn.read_last_seen_version() == "0.20.0"
def test_render_whats_new_returns_false_when_nothing_new():