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
fix(cli): decision list states its total and how many rows it shows (#4355)
Raghav Chamadiya52a7145bf747
diff --git a/docs/reference/CLI_REFERENCE.md b/docs/reference/CLI_REFERENCE.mdindex 29ceb912d..d1d9af066 100644--- a/docs/reference/CLI_REFERENCE.md+++ b/docs/reference/CLI_REFERENCE.md@@ -1031,6 +1031,10 @@ Every subcommand takes `--format` (`table` default, or `json`) and an optional `| `--source` | `adr`, `cli`, `comment`, `commit`, `conventions`, `git_archaeology`, `inline_marker`, `llm_inferred`, `pr`, `session`, `all`. | `all` || `--proposed` | `--status proposed`. | off || `--stale-only` | Only stale. | off |+| `--limit` | Max rows listed. | `100` |+| `--all` | Every matching row; overrides `--limit`. | off |++- The table ends with `Showing N of M decisions` when rows were cut, else `M decisions.`; JSON carries `total` (rows matching the filters) and `truncated`.**Capture control**diff --git a/packages/cli/src/repowise/cli/commands/decision_cmd.py b/packages/cli/src/repowise/cli/commands/decision_cmd.pyindex ceb7597b4..426a39cb4 100644--- a/packages/cli/src/repowise/cli/commands/decision_cmd.py+++ b/packages/cli/src/repowise/cli/commands/decision_cmd.py@@ -554,6 +554,14 @@ async def _embed_decision()@click.option("--proposed", is_flag=True, default=False, help="Show only proposed decisions.")@click.option("--stale-only", is_flag=True, default=False, help="Show only stale decisions.")+ "--limit",+ type=click.IntRange(min=1),+ default=100,+ show_default=True,+ help="Max rows listed.",+)[email protected]("--all", "show_all", is_flag=True, default=False, help="List every matching row.")@format_option()def decision_list(path: str | None,@@ -561,6 +569,8 @@ def decision_list(source: str,proposed: bool,stale_only: bool,+ limit: int,+ show_all: bool,fmt: str,) -> None:"""List architectural decision records."""@@ -573,16 +583,34 @@ def decision_list())+ # Narrowed before the cut so --stale-only and the total cover every row,+ # not just the first page.decisions = _narrow(decisions, proposed=proposed, stale_only=stale_only)+ total = len(decisions)+ shown = decisions if show_all else decisions[:limit]if fmt == "json":- emit_json({"repo": str(repo_path), "decisions": [_listed_json(d) for d in decisions]})+ emit_json(+ {+ "repo": str(repo_path),+ "total": total,+ "truncated": len(shown) < total,+ "decisions": [_listed_json(d) for d in shown],+ }+ )return- if not decisions:+ if not shown:console.print("[dim]No decisions found.[/dim]")return- _print_decision_table(decisions)+ _print_decision_table(shown)+ if len(shown) < total:+ console.print(+ f"[dim]Showing {len(shown)} of {total} decisions; "+ "--limit N or --all lists more.[/dim]"+ )+ else:+ console.print(f"[dim]{total} decisions.[/dim]")def _narrow(decisions: list, *, proposed: bool, stale_only: bool) -> list:@@ -619,7 +647,9 @@ async def _query_decisions(repo_path: Path, *, status: str | None, source: str |status=status,source=source,include_proposed=True,- limit=100,+ # Every row: the command counts and narrows them before cutting a+ # page. Fine at a few thousand records; a COUNT query is the upgrade.+ limit=None,)@@ -635,6 +665,7 @@ _STATUS_COLORS = {def _print_decision_table(decisions: list) -> None:table = Table(title="Architectural Decisions")table.add_column("ID", style="dim", width=8)+ # Wraps rather than cuts: the title is the record's name.table.add_column("Title", max_width=40)table.add_column("Status")table.add_column("Source", style="dim")@@ -648,7 +679,7 @@ def _print_decision_table(decisions: list) -> None:created = d.created_at.strftime("%Y-%m-%d") if d.created_at else ""table.add_row(d.id[:8],- d.title[:40],+ d.title,f"[{color}]{d.status}[/{color}]",d.source,f"{d.confidence:.0%}",diff --git a/packages/core/src/repowise/core/persistence/crud/decisions.py b/packages/core/src/repowise/core/persistence/crud/decisions.pyindex 62edca3d5..6855da02c 100644--- a/packages/core/src/repowise/core/persistence/crud/decisions.py+++ b/packages/core/src/repowise/core/persistence/crud/decisions.py@@ -287,11 +287,11 @@ async def list_decisions(include_proposed: bool = True,accepted: bool | None = None,include_dismissed: bool = False,- limit: int = 100,+ limit: int | None = 100,offset: int = 0,sort: str = "priority",) -> list[DecisionRecord]:- """Return decision records with optional filters.+ """Return decision records with optional filters; ``limit=None`` returns every row.Dismissed records are tombstones and only show up when explicitly askedfor via ``status="dismissed"``.diff --git a/tests/unit/cli/test_decision_cmd.py b/tests/unit/cli/test_decision_cmd.pyindex f9721f7ae..12f73addf 100644--- a/tests/unit/cli/test_decision_cmd.py+++ b/tests/unit/cli/test_decision_cmd.py@@ -4,6 +4,7 @@ from __future__ import annotationsimport asyncioimport json+import refrom pathlib import Pathimport pytest@@ -353,6 +354,8 @@ def test_decision_list_help_lists_filters() -> None:assert "--source" in result.outputassert "--proposed" in result.outputassert "--stale-only" in result.output+ assert "--limit" in result.output+ assert "--all" in result.outputdef test_decision_list_empty_repo_prints_none_found(indexed_repo: Path) -> None:@@ -404,6 +407,57 @@ def test_decision_list_and_show_seeded_records(indexed_repo: Path) -> None:assert "use X" in shown.output+def _many_decisions(n: int, **extra) -> list[dict]:+ return [{"id": f"{i:032x}", "title": f"Decision {i}", **extra} for i in range(n)]+++def _list_json(repo: Path, *args: str) -> dict:+ result = CliRunner().invoke(cli, ["decision", "list", str(repo), *args, "--format", "json"])+ assert result.exit_code == 0, result.output+ return json.loads(result.output)+++def test_decision_list_says_how_many_rows_it_cut(indexed_repo: Path) -> None:+ _seed_wiki_db(indexed_repo, _many_decisions(105))++ table = CliRunner().invoke(cli, ["decision", "list", str(indexed_repo)])+ assert table.exit_code == 0, table.output+ assert "Showing 100 of 105 decisions" in table.output++ data = _list_json(indexed_repo)+ assert (data["total"], data["truncated"], len(data["decisions"])) == (105, True, 100)++ limited = _list_json(indexed_repo, "--limit", "3")+ assert (limited["total"], limited["truncated"], len(limited["decisions"])) == (105, True, 3)++ everything = CliRunner().invoke(cli, ["decision", "list", str(indexed_repo), "--all"])+ assert everything.exit_code == 0, everything.output+ assert "105 decisions." in everything.output+ assert "Showing" not in everything.output+++def test_stale_only_counts_stale_rows_past_the_first_page(indexed_repo: Path) -> None:+ # Fresh rows outrank on confidence, so the stale ones sort past row 100.+ rows = _many_decisions(100, confidence=0.9) + [+ {"id": f"{i:032x}", "title": f"Stale {i}", "confidence": 0.1, "staleness": 0.9}+ for i in range(100, 104)+ ]+ _seed_wiki_db(indexed_repo, rows)++ data = _list_json(indexed_repo, "--stale-only")+ assert (data["total"], data["truncated"], len(data["decisions"])) == (4, False, 4)+++def test_decision_list_shows_a_long_title_whole(indexed_repo: Path) -> None:+ title = "Backfill path mapping needs repo-tied evidence for deleted directories"+ _seed_wiki_db(indexed_repo, [{"id": "c" * 32, "title": title}])++ result = CliRunner().invoke(cli, ["decision", "list", str(indexed_repo)])+ assert result.exit_code == 0, result.output+ # The column wraps, so every word survives in order, with other cells+ # between wrapped lines; independent of width and box style.+ assert re.search(r"\b" + r"\b.*?\b".join(map(re.escape, title.split())), result.output, re.S)+def test_decision_confirm_promotes_proposed(indexed_repo: Path) -> None:_seed_wiki_db(indexed_repo,