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(init): progress you can read, a checklist of every step with counts, time and what comes next (#4251)
Raghav Chamadiya2a83d55a1eaf
diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/_finish.py b/packages/cli/src/repowise/cli/commands/init_cmd/_finish.pyindex 0f12d4137..d78728990 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/_finish.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/_finish.py@@ -6,8 +6,6 @@ import sysfrom pathlib import Pathfrom typing import Any-from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn-from repowise.cli.commands._index_outcome import record_index_outcome, refresh_read_snapshotsfrom repowise.cli.editor_setup import register_editor_clients, write_editor_project_filesfrom repowise.cli.helpers import (@@ -22,14 +20,7 @@ from repowise.cli.helpers import (save_state,)from repowise.cli.state_persistence import build_kg_state, save_knowledge_graph_json-from repowise.cli.ui import (- BRAND_STYLE,- OK,- OWL_SPINNER,- MaybeCountColumn,- RichProgressCallback,- print_phase_header,-)+from repowise.cli.ui import OK, RichProgressCallback, make_progress, print_stagefrom repowise.core.analysis.health import HEALTH_ANALYZER_VERSIONfrom repowise.core.analysis.security_scan import SECURITY_SCANNER_VERSIONfrom repowise.core.decision_lanes import record_decision_lanes@@ -51,36 +42,25 @@ from .reporting import show_completiondef persist_index(run: InitRun) -> None:- """Save to the database and build the search index."""- print_phase_header(- console,- run.total_phases,- run.total_phases,- "Persistence",- "Saving to database and building search index",- )+ """Save to the database and build the search index, then bank agent savings."""+ print_stage(console, "persistence", run.total_phases)- # The index run's columns, minus cost.recorder = run.recorder- with Progress(- SpinnerColumn(spinner_name=OWL_SPINNER, style=BRAND_STYLE),- TextColumn("[progress.description]{task.description}"),- BarColumn(),- MaybeCountColumn(),- TimeElapsedColumn(),- console=console,- ) as persist_bar:- persist_callback = recorder.rebind(RichProgressCallback(persist_bar, console))+ with make_progress(console) as persist_bar:+ steps = RichProgressCallback(persist_bar, console)+ persist_callback = recorder.rebind(steps)# Indeterminate, announced so the stage is never silent.persist_callback.on_phase_start("persist", None)run_async(persist_result(run.result, run.repo_path, persist_callback, recorder.table))persist_callback.on_phase_done("persist")- # Persistence has its own callback; fold its warnings into the run record.- run.run_warnings.extend(persist_callback.warnings)- # Read last: every stage writes into the one table.- recorder.table.stop("run")- run.phase_timings = recorder.timings- console.print(f" [{OK}]✓[/] Database updated")+ # Persistence has its own callback; fold its warnings into the run record.+ run.run_warnings.extend(persist_callback.warnings)+ # Read last: every stage writes into the one table.+ recorder.table.stop("run")+ run.phase_timings = recorder.timings+ with steps.step("savings"):+ catch_up_savings(run.repo_path)+ save_run_config(run)def catch_up_savings(repo_path: Path) -> None:@@ -379,7 +359,7 @@ def _record_init_outcome(run: InitRun) -> None:)-def _write_editor_files(run: InitRun) -> list[Path]:+def _write_editor_files(run: InitRun, steps: RichProgressCallback) -> list[Path]:"""Read views, project editor files and the coverage hook; returns the files written.Runs after state is saved so the guidance reads the final index_scope.@@ -387,14 +367,19 @@ def _write_editor_files(run: InitRun) -> list[Path]:repo_path = run.repo_patheditor_setup = run.opts.editor_setup# Before the editor files, which quote Fix first from these views.- refresh_read_snapshots(repo_path)- files_written = write_editor_project_files(- console,- repo_path,- options=run.editor_options,- no_editor_setup=not editor_setup,- )- if editor_setup:+ with steps.step("views"):+ refresh_read_snapshots(repo_path)+ if not editor_setup:+ return write_editor_project_files(+ console, repo_path, options=run.editor_options, no_editor_setup=True+ )+ with steps.step("editor_files"):+ files_written = write_editor_project_files(+ console,+ repo_path,+ options=run.editor_options,+ no_editor_setup=False,+ )from repowise.cli.commands.augment_cmd.coverage_reingest import sync_repo_hooksync_repo_hook(repo_path, console)@@ -402,10 +387,15 @@ def _write_editor_files(run: InitRun) -> list[Path]:def complete_setup(run: InitRun) -> None:- """Editor files, hook offers, then the completion panel."""+ """State, read views and editor files, hook offers, then the completion panel."""opts = run.optsrepo_path = run.repo_path- files_written = _write_editor_files(run)+ # The prompts below cannot run under a live display, so it closes first.+ with make_progress(console) as tail_bar:+ steps = RichProgressCallback(tail_bar, console)+ with steps.step("state"):+ write_run_state(run)+ files_written = _write_editor_files(run, steps)_record_init_outcome(run)offer_hook_install(diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/_generate.py b/packages/cli/src/repowise/cli/commands/init_cmd/_generate.pyindex dedbc154b..51e4dddaa 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/_generate.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/_generate.py@@ -10,7 +10,7 @@ from rich.table import Tablefrom repowise.cli.cost_gate import spend_phrasefrom repowise.cli.helpers import console, load_config, warn-from repowise.cli.ui import BRAND, VALUE, print_phase_header+from repowise.cli.ui import BRAND, VALUE, print_stagefrom repowise.cli.ui.mode_names import INDEX_ONLYfrom repowise.core.generation.styles import DEFAULT_STYLE@@ -111,11 +111,10 @@ def _run_deterministic_generation_phase(embedder = template_run_embedder(embedder_name_resolved, embedder_was_requested)- print_phase_header(+ print_stage(console,- 3,+ "generation",total_phases,- "Generation","Building documentation from code (no model, no cost)",)# Both knobs only reach a model: templates are English and unstyled, so say@@ -159,6 +158,7 @@ def _run_deterministic_generation_phase(verbose=True,timings=timings,warnings=warnings,+ total_phases=total_phases,)return embedder@@ -260,11 +260,10 @@ def _run_generation_phase("""from repowise.core.generation import GenerationConfig- print_phase_header(+ print_stage(console,- 3,+ "generation",total_phases,- "Generation",f"Writing documentation with {provider.provider_name} / {provider.model_name}",)@@ -330,6 +329,7 @@ def _run_generation_phase(test_run=test_run,timings=timings,warnings=warnings,+ total_phases=total_phases,)return False, Falsediff --git a/packages/cli/src/repowise/cli/commands/init_cmd/_ingest.py b/packages/cli/src/repowise/cli/commands/init_cmd/_ingest.pyindex a47227e8e..952058ff5 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/_ingest.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/_ingest.py@@ -5,16 +5,8 @@ from __future__ import annotationsfrom pathlib import Pathfrom typing import Any-from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn-from repowise.cli.helpers import console, load_state, run_async-from repowise.cli.ui import (- BRAND_STYLE,- OK,- OWL_SPINNER,- MaybeCountColumn,- RichProgressCallback,-)+from repowise.cli.ui import RichProgressCallback, make_progressfrom ._options import InitRunfrom .persistence import build_resume_controller@@ -54,18 +46,8 @@ def _index_vector_store(run: InitRun) -> Any:return candidate if store_has_semantic_vectors(candidate) else None-def _index_columns(with_cost: bool) -> list[Any]:- columns: list[Any] = [- SpinnerColumn(spinner_name=OWL_SPINNER, style=BRAND_STYLE),- TextColumn("[progress.description]{task.description}"),- BarColumn(),- MaybeCountColumn(),- TimeElapsedColumn(),- ]- # Cost column only when a model can be called.- if with_cost:- columns.append(TextColumn("[" + OK + "]${task.fields[cost]:.3f}[/]"))- return columns+#: What the long-step line tells a user to run after Ctrl-C.+RESUME_COMMAND = "repowise init --resume"async def _index_with_resume(@@ -143,7 +125,10 @@ def index_repository(run: InitRun) -> None:)index_vector_store = _index_vector_store(run)- with Progress(*_index_columns(llm_client is not None), console=console) as progress_bar:+ # Cost column only when a model can be called.+ with make_progress(+ console, cost=llm_client is not None, resume_command=RESUME_COMMAND+ ) as progress_bar:rich_callback = RichProgressCallback(progress_bar, console, total_phases=run.total_phases)callback = PhaseTimingRecorder(rich_callback)# Whole-run total: phases nest and overlap, so their sum can exceed it.diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/command.py b/packages/cli/src/repowise/cli/commands/init_cmd/command.pyindex 55f12a2d0..2fd5cb3a3 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/command.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/command.py@@ -27,13 +27,10 @@ from repowise.core.update_lock import init_in_progressfrom ._exit import exit_interruptedfrom ._finish import (- catch_up_savings,complete_setup,exit_with_gaps,persist_index,register_clients,- save_run_config,- write_run_state,)from ._generate import (_generate,@@ -62,7 +59,6 @@ from ._questions import (_offer_fast_mode,)from ._seed import delegate_to_seeded_update-from .reporting import show_analysis_summaryfrom .workspace import _workspace_init__all__ = [@@ -510,16 +506,12 @@ def _run_single_repo(opts: InitOptions, repo_path: Any, start: float) -> None:if run.run_warnings:run.gaps.append(f"{len(run.run_warnings):,} warning(s) while indexing (see above)")- show_analysis_summary(run.result)if _generate(run):return# A declined cost gate or a missing provider persists like index-only.run.effective_index_only = run.opts.index_only or run.cost_declined or run.no_providerpersist_index(run)- catch_up_savings(run.repo_path)- save_run_config(run)register_clients(run)- write_run_state(run)complete_setup(run)exit_with_gaps(run)diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/generation.py b/packages/cli/src/repowise/cli/commands/init_cmd/generation.pyindex 1495159d4..05a03f45a 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/generation.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/generation.py@@ -17,8 +17,6 @@ from collections import Counterfrom pathlib import Pathfrom typing import Any-from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn-# The cost-gate helpers moved to ``repowise.cli.cost_gate`` so ``init`` and# ``generate`` share one gate. Re-exported here for the callers that still# import them from this module (init's command + workspace flows).@@ -39,12 +37,11 @@ from repowise.cli.providers import (flush_cost_tracker,)from repowise.cli.ui import (- BRAND_STYLE,OK,OWL_SPINNER,WARN,- MaybeCountColumn,RichProgressCallback,+ make_progress,)from repowise.core.generation.models import (STUB_FALLBACK_ERROR,@@ -267,6 +264,7 @@ def run_repo_generation(test_run: bool = False,timings: Any | None = None,warnings: list[str] | None = None,+ total_phases: int | None = None,) -> list[Any]:"""Generate wiki pages for one repo and enrich its knowledge graph.@@ -301,7 +299,13 @@ def run_repo_generation(# on ``result``. Only a caller whose embedder matches# ``embedder_name_resolved`` may pre-set it.vector_store: Any = getattr(result, "vector_store", None)- if vector_store is None:+ if vector_store is None and verbose:+ # Opening the store can take seconds on a large index; say so.+ with make_progress(console) as store_bar:+ steps = RichProgressCallback(store_bar, console)+ with steps.step("vector_store"):+ vector_store = build_vector_store(repo_path, embedder_impl)+ elif vector_store is None:vector_store = build_vector_store(repo_path, embedder_impl)result.vector_store = vector_store@@ -316,21 +320,10 @@ def run_repo_generation(if verbose and not deterministic:console.print(- " [dim](each generated page is saved as it completes; safe to Ctrl-C, "+ " [dim](each generated page is saved as it completes: safe to Ctrl-C, ""then run 'repowise init --resume' to pick up where it stopped)[/dim]")- # No cost column on a deterministic run: it would sit at $0.000 for the- # whole run, which reads as an unanswered question rather than an answer.- columns: list[Any] = [- SpinnerColumn(spinner_name=OWL_SPINNER, style=BRAND_STYLE),- TextColumn("[progress.description]{task.description}"),- BarColumn(),- MaybeCountColumn(),- TimeElapsedColumn(),- ]- if not deterministic:- columns.append(TextColumn("[" + OK + "]${task.fields[cost]:.3f}[/]"))# Filled by a resumed run with the pages it skipped because they already# exist. Persistence needs them: they are absent from ``generated_pages``,@@ -347,8 +340,19 @@ def run_repo_generation(result.generation_scope = generation_scopegeneration_stats: dict[str, int] = {}- with Progress(*columns, console=console) as gen_progress:- gen_callback: Any = RichProgressCallback(gen_progress, console)+ # No cost column on a deterministic run: it would sit at $0.000 for the+ # whole run, which reads as an unanswered question rather than an answer.+ # ``total_phases`` comes only from single-repo init, whose resume this is.+ from ._ingest import RESUME_COMMAND++ with make_progress(+ console,+ cost=not deterministic,+ resume_command=RESUME_COMMAND if total_phases is not None else None,+ ) as gen_progress:+ gen_callback: Any = RichProgressCallback(+ gen_progress, console, total_phases=total_phases, stage="generation"+ )if timings is not None:gen_callback = PhaseTimingRecorder(gen_callback, timings)generated_pages = run_async(@@ -460,8 +464,6 @@ def run_repo_generation(" [dim]Run [bold]repowise init --resume[/bold] to generate the pages that ""failed, without re-spending on the ones that succeeded.[/dim]\n")- elif verbose:- console.print(f" [{OK}]✓[/] Generated [bold]{written_count}[/bold] pages")# KG enrichment is layer naming and the guided tour, both pure prompting.# A deterministic run has no model to ask, and the skeleton's structuraldiff --git a/packages/cli/src/repowise/cli/commands/init_cmd/reporting.py b/packages/cli/src/repowise/cli/commands/init_cmd/reporting.pyindex 6c7c95017..3b6078f15 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/reporting.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/reporting.py@@ -21,65 +21,11 @@ from repowise.cli.ui import (build_status_notes,format_elapsed,keyless_upgrade_note,- print_analysis_summary,print_files_written,)from repowise.cli.ui.mode_names import TITLE_WORKSPACE, completion_title, pages, scope_line-def show_analysis_summary(result: Any) -> None:- """Render the analysis-complete interstitial shown before generation."""- _graph = result.graph_builder.graph()- _dc_unreachable_pre = sum(- 1- for f in (result.dead_code_report.findings if result.dead_code_report else [])- if f.kind.value == "unreachable_file"- )- _dc_unused_pre = sum(- 1- for f in (result.dead_code_report.findings if result.dead_code_report else [])- if f.kind.value == "unused_export"- )- _dc_lines_pre = result.dead_code_report.deletable_lines if result.dead_code_report else 0- _n_decisions_pre = (- sum(result.decision_report.by_source.values()) if result.decision_report else 0- )- _lang_dist = result.repo_structure.root_language_distribution- _lang_summary = ""- if _lang_dist:- _top = sorted(_lang_dist.items(), key=lambda x: -x[1])[:4]- _lang_summary = ", ".join(f"{lang} {pct:.0%}" for lang, pct in _top)- if len(_lang_dist) > 4:- _lang_summary += f" +{len(_lang_dist) - 4} more"-- # Community count (best-effort)- _community_count = 0- try:- if hasattr(result.graph_builder, "communities"):- _community_count = len(result.graph_builder.communities())- except Exception:- pass-- console.print()- print_analysis_summary(- console,- file_count=result.file_count,- symbol_count=result.symbol_count,- graph_nodes=_graph.number_of_nodes(),- graph_edges=_graph.number_of_edges(),- dead_unreachable=_dc_unreachable_pre,- dead_unused=_dc_unused_pre,- dead_lines=_dc_lines_pre,- decision_count=_n_decisions_pre,- git_files=result.git_summary.files_indexed if result.git_summary else 0,- hotspot_count=result.git_summary.hotspots- if result.git_summary and hasattr(result.git_summary, "hotspots")- else 0,- community_count=_community_count,- lang_summary=_lang_summary,- )--def _render_defect_accuracy(result: Any) -> None:"""Print a one-line "does the score find the bugs?" validation callout.@@ -203,10 +149,8 @@ def show_completion(else:_lang_summary_final = str(len(result.languages))- # What the run found, in both modes. A full run — the recommended path —- # used to report none of this in its closing panel: file count, symbols,- # languages and graph size appeared once in the "Analysis Complete"- # interstitial, minutes and one cost prompt earlier.+ # What the run found, in both modes: this panel is the one place a run+ # reports file count, symbols, languages and graph size._index_rows: list[tuple[str, str]] = [("Scope", scope_line(_scope)),("Files indexed", f"{result.file_count:,}"),diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/workspace.py b/packages/cli/src/repowise/cli/commands/init_cmd/workspace.pyindex 37cd62a45..9d0c0b1f8 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/workspace.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/workspace.py@@ -17,8 +17,6 @@ from datetime import UTC, datetimefrom pathlib import Pathfrom typing import Any-from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn-from repowise.cli._setup import setup_logging_silencefrom repowise.cli.cost_gate import spend_phrasefrom repowise.cli.editor_integrations.defaults import (@@ -54,13 +52,10 @@ from repowise.cli.providers import (from repowise.cli.state_persistence import build_kg_state, save_knowledge_graph_jsonfrom repowise.cli.ui import (BRAND,- BRAND_STYLE,ERR,OK,- OWL_SPINNER,VALUE,WARN,- MaybeCountColumn,RichProgressCallback,interactive_advanced_config,interactive_mode_select,@@ -68,6 +63,7 @@ from repowise.cli.ui import (interactive_provider_config_select,interactive_repo_select,load_dotenv,+ make_progress,print_banner,)from repowise.cli.ui.mode_names import pages@@ -428,14 +424,7 @@ def _index_repo(repo: Any, ctx: _WorkspaceCtx, repo_provider: Any) -> _RepoIndexfrom repowise.core.pipeline import PhaseTimingRecorder, run_pipelinefrom repowise.core.pipeline.modes import OrchestratorMode- with Progress(- SpinnerColumn(spinner_name=OWL_SPINNER, style=BRAND_STYLE),- TextColumn("[progress.description]{task.description}"),- BarColumn(),- MaybeCountColumn(),- TimeElapsedColumn(),- console=console,- ) as progress_bar:+ with make_progress(console) as progress_bar:callback = PhaseTimingRecorder(RichProgressCallback(progress_bar, console))_prev_state = load_state(repo.path)@@ -567,13 +556,7 @@ def _persist_repo_index(repo_path: Path, index: _RepoIndex) -> list[str]:"""Persist to the repo-local DB; returns the persist phase's warnings."""persist_warnings: list[str] = []callback = index.callback- with Progress(- SpinnerColumn(),- TextColumn("[progress.description]{task.description}"),- TimeElapsedColumn(),- console=console,- transient=True,- ) as persist_bar:+ with make_progress(console, transient=True) as persist_bar:persist_callback = callback.rebind(RichProgressCallback(persist_bar, console))persist_callback.on_phase_start("persist", None)try:diff --git a/packages/cli/src/repowise/cli/commands/reindex_cmd.py b/packages/cli/src/repowise/cli/commands/reindex_cmd.pyindex 5f15e2abc..8de7c7d65 100644--- a/packages/cli/src/repowise/cli/commands/reindex_cmd.py+++ b/packages/cli/src/repowise/cli/commands/reindex_cmd.py@@ -3,7 +3,6 @@from __future__ import annotationsimport click-from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumnfrom repowise.cli.helpers import (console,@@ -13,7 +12,7 @@ from repowise.cli.helpers import (run_async,warn,)-from repowise.cli.ui import BRAND_STYLE, OWL_SPINNER+from repowise.cli.ui import make_progress_PROVIDER_FAILURE_CIRCUIT_SLICES = 2_INPUT_TOO_LONG_RETRIES = 4@@ -114,15 +113,8 @@ async def _reindex(repo_path, embedder_name: str, batch_size: int) -> None:consecutive_provider_failures = 0provider_circuit_error: Exception | None = None- with Progress(- SpinnerColumn(spinner_name=OWL_SPINNER, style=BRAND_STYLE),- TextColumn("[progress.description]{task.description}"),- BarColumn(),- TextColumn("{task.completed}/{task.total}"),- TimeElapsedColumn(),- console=console,- ) as progress:- task = progress.add_task("Indexing pages...", total=total)+ with make_progress(console) as progress:+ task = progress.add_task("Indexing pages...", total=total, unit="pages")warned = 0diff --git a/packages/cli/src/repowise/cli/commands/update_cmd/page_generation.py b/packages/cli/src/repowise/cli/commands/update_cmd/page_generation.pyindex 5f99c94a6..f6f7328e6 100644--- a/packages/cli/src/repowise/cli/commands/update_cmd/page_generation.py+++ b/packages/cli/src/repowise/cli/commands/update_cmd/page_generation.py@@ -6,11 +6,11 @@ from collections.abc import Callablefrom contextlib import nullcontextfrom typing import Any-from repowise.cli.helpers import run_async+from repowise.cli.helpers import console, run_async+from repowise.cli.ui import make_progressfrom repowise.core.pipeline import timedfrom .options import DocsPass, UpdateOptions, UpdateRun-from .reporting import make_generation_progressdef _generation_warning_handler(@@ -123,10 +123,11 @@ def generate_pages(opts: UpdateOptions, run: UpdateRun, docs: DocsPass) -> None:finally:await checkpointer.close()- with make_generation_progress() if run.emitter is None else nullcontext() as gen_progress:+ gen_bar = make_progress(console, cost=True) if run.emitter is None else nullcontext()+ with gen_bar as gen_progress:progress.bar = gen_progressprogress.task = (- gen_progress.add_task("Generating pages...", total=None, cost=0.0)+ gen_progress.add_task("Generating pages...", total=None, cost=0.0, unit="pages")if gen_progress is not Noneelse None)diff --git a/packages/cli/src/repowise/cli/commands/update_cmd/reporting.py b/packages/cli/src/repowise/cli/commands/update_cmd/reporting.pyindex e3872c6aa..23ca19279 100644--- a/packages/cli/src/repowise/cli/commands/update_cmd/reporting.py+++ b/packages/cli/src/repowise/cli/commands/update_cmd/reporting.py@@ -14,13 +14,9 @@ import sysfrom typing import Anyimport click-from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumnfrom repowise.cli.helpers import consolefrom repowise.cli.ui import (- BRAND_STYLE,- OWL_SPINNER,- MaybeCountColumn,build_completion_panel,format_elapsed,)@@ -109,21 +105,6 @@ def render_cascade_budget_warning(console.print()-def make_generation_progress() -> Progress:- """Build the live page-generation progress bar (owl spinner + running cost),- matching the columns ``init`` uses for its generation phase.- """- return Progress(- SpinnerColumn(spinner_name=OWL_SPINNER, style=BRAND_STYLE),- TextColumn("[progress.description]{task.description}"),- BarColumn(),- MaybeCountColumn(),- TimeElapsedColumn(),- TextColumn("[green]${task.fields[cost]:.3f}[/green]"),- console=console,- )--# ---------------------------------------------------------------------------# Machine-readable progress (--progress json)# ---------------------------------------------------------------------------diff --git a/packages/cli/src/repowise/cli/commands/upgrade_flow.py b/packages/cli/src/repowise/cli/commands/upgrade_flow.pyindex 28a3e74fc..58b579e4d 100644--- a/packages/cli/src/repowise/cli/commands/upgrade_flow.py+++ b/packages/cli/src/repowise/cli/commands/upgrade_flow.py@@ -520,29 +520,13 @@ async def _generate_upgrade_pages(``inputs`` is (parsed_files, source_map, graph_builder, repo_structure,git_meta_map)."""- from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn-from repowise.cli.commands.init_cmd._generation_persist import (run_generation_with_persistence,)- from repowise.cli.ui import (- BRAND_STYLE,- OK,- OWL_SPINNER,- MaybeCountColumn,- RichProgressCallback,- )+ from repowise.cli.ui import RichProgressCallback, make_progressparsed_files, source_map, graph_builder, repo_structure, git_meta_map = inputs- with Progress(- SpinnerColumn(spinner_name=OWL_SPINNER, style=BRAND_STYLE),- TextColumn("[progress.description]{task.description}"),- BarColumn(),- MaybeCountColumn(),- TimeElapsedColumn(),- TextColumn(f"[{OK}]${{task.fields[cost]:.3f}}[/]"),- console=console,- ) as upgrade_progress:+ with make_progress(console, cost=True) as upgrade_progress:gen_callback = RichProgressCallback(upgrade_progress, console)return await run_generation_with_persistence(repo_path=repo_path,diff --git a/packages/cli/src/repowise/cli/ui/__init__.py b/packages/cli/src/repowise/cli/ui/__init__.pyindex e8d3cb8c2..e709918e1 100644--- a/packages/cli/src/repowise/cli/ui/__init__.py+++ b/packages/cli/src/repowise/cli/ui/__init__.py@@ -33,7 +33,7 @@ _LAZY: dict[str, str] = {"THINKING_FRAMES": "mascot","VALUE": "brand","WARN": "brand",- "MaybeCountColumn": "progress",+ "MaybeCountColumn": "progress_display","ProviderSelection": "provider_selection","RepoScanInfo": "repo_scanner","RichProgressCallback": "progress",@@ -56,15 +56,16 @@ _LAZY: dict[str, str] = {"interactive_repo_select": "workspace_selection","key_value_table": "brand","load_dotenv": "env_persistence",+ "make_progress": "progress_display","mini": "mascot","model_call_count": "subscription",- "print_analysis_summary": "result_panels","print_banner": "brand","print_files_written": "result_panels","print_index_only_intro": "mode_selection","print_phase_header": "brand","print_scan_summary": "repo_scanner","print_section": "brand",+ "print_stage": "progress","prompt_file_page_volume": "mode_selection","prompt_wiki_style": "mode_selection","quick_repo_scan": "repo_scanner",diff --git a/packages/cli/src/repowise/cli/ui/checklist.py b/packages/cli/src/repowise/cli/ui/checklist.pynew file mode 100644index 000000000..dc1acb605--- /dev/null+++ b/packages/cli/src/repowise/cli/ui/checklist.py@@ -0,0 +1,123 @@+"""How a pipeline step reads in the terminal: done, running, or still to come.++Pure formatting, no live display: :mod:`repowise.cli.ui.progress_display`+draws the running rows and :class:`~repowise.cli.ui.progress.RichProgressCallback`+prints a done row as each step finishes. Every glyph and style a step state+uses is in :data:`STATE_MARKS`, so a theme swaps them in one place. Each state+carries a glyph as well as a colour, so it still reads with colour off.+"""++from __future__ import annotations++from dataclasses import dataclass++from rich.markup import escape++from repowise.cli.ui.brand import DIM, OK, format_elapsed++DONE = "done"+PENDING = "pending"++#: state -> (glyph, style). The running state is the live spinner row.+STATE_MARKS: dict[str, tuple[str, str]] = {+ DONE: ("✓", OK),+ PENDING: ("○", DIM),+}++#: A step running longer than this gets the long-step line.+LONG_STEP_SECONDS = 10.0++# A rate measured over less than this is mostly startup cost, and a step of a+# handful of coarse items (three drift checks, five decision sources) has no+# rate at all: its last item can take longer than the rest together. No+# estimate is better than a wrong one.+_MIN_RATE_SECONDS = 3.0+_MIN_TOTAL_ITEMS = 20+_MIN_DONE_ITEMS = 5++_SUBSTEP_PREFIX = "↳"+++def split_label(raw: str) -> tuple[str, int]:+ """``" ↳ Resolving imports"`` -> ``("Resolving imports", 1)``; trailing ``…`` dropped."""+ text = raw.strip()+ depth = 0+ if text.startswith(_SUBSTEP_PREFIX):+ depth = 1+ text = text[len(_SUBSTEP_PREFIX) :].strip()+ return text.rstrip("…").rstrip(), depth+++def count_text(completed: float, total: float | None, unit: str) -> str:+ """``"1,204/2,938 files"``, or ``"1,204 files"`` with no total; empty with no unit."""+ if not unit:+ return ""+ done = int(completed)+ if total:+ return f"{done:,}/{int(total):,} {unit}"+ return f"{done:,} {unit}"+++def time_left(completed: float, total: float | None, elapsed: float | None) -> float | None:+ """Seconds left at the rate measured so far, or None when there is no honest estimate.++ Needs a known total of many items, several of them finished, and a few+ seconds of measured rate. A step with an unknown total never gets one.+ """+ if not total or not elapsed or completed >= total:+ return None+ if total < _MIN_TOTAL_ITEMS or completed < _MIN_DONE_ITEMS or elapsed < _MIN_RATE_SECONDS:+ return None+ return elapsed / completed * (total - completed)+++def format_time_left(seconds: float) -> str:+ """``"about 40s left"``, ``"about 3m left"``. Coarse on purpose: it is an estimate."""+ if seconds < 60:+ return f"about {max(5, round(seconds / 5) * 5)}s left"+ return f"about {round(seconds / 60)}m left"+++def format_running(seconds: float | None) -> str:+ """Whole seconds while a step runs (``"12s"``, ``"1m 05s"``): tenths would flicker."""+ whole = int(seconds or 0)+ if whole >= 60:+ return f"{whole // 60}m {whole % 60:02d}s"+ return f"{whole}s"+++@dataclass(frozen=True)+class FinishedStep:+ """What a done row reports about one step."""++ label: str+ completed: float = 0+ total: float | None = None+ unit: str = ""+ elapsed: float | None = None+++def done_line(step: FinishedStep) -> str:+ """The markup line a finished step leaves behind: `` ✓ Parsing files · 30 files · 0.4s``."""+ label, depth = split_label(step.label)+ glyph, style = STATE_MARKS[DONE]+ indent = " " * (depth + 1)+ amount = step.total or step.completed+ count = count_text(amount, None, step.unit) if amount else ""+ facts = [f for f in (count, format_elapsed(step.elapsed or 0.0)) if f]+ tail = f" [{DIM}]· {' · '.join(facts)}[/]" if facts else ""+ return f"{indent}[{style}]{glyph}[/] {escape(label)}{tail}"+++def long_step_line(resume_command: str) -> str:+ """Shown under a step that has run past :data:`LONG_STEP_SECONDS`."""+ return (+ f" [{DIM}]Long step. Safe to Ctrl-C: [bold]{escape(resume_command)}[/bold] "+ "continues where it stopped.[/]"+ )+++def upcoming_line(titles: list[str]) -> str:+ """The stages still to run, e.g. `` ○ Next: Analysis · Generation · Persistence``."""+ glyph, style = STATE_MARKS[PENDING]+ return f" [{style}]{glyph} Next: {escape(' · '.join(titles))}[/]"diff --git a/packages/cli/src/repowise/cli/ui/progress.py b/packages/cli/src/repowise/cli/ui/progress.pyindex db4e80cf0..27688a9c2 100644--- a/packages/cli/src/repowise/cli/ui/progress.py+++ b/packages/cli/src/repowise/cli/ui/progress.py@@ -1,15 +1,14 @@-"""Rich progress column + the core ProgressCallback adapter."""+"""The core ProgressCallback adapter that drives the live progress display."""from __future__ import annotationsimport contextlib-from collections.abc import Callable+from collections.abc import Callable, Iteratorfrom typing import Anyfrom rich.console import Console-from rich.progress import ProgressColumn, Task-from rich.text import Text+from repowise.cli.ui import checklistfrom repowise.cli.ui.brand import ERR, WARN, print_phase_headerfrom repowise.core.redaction import redact_secrets@@ -18,9 +17,10 @@ from repowise.core.redaction import redact_secrets# size or a "this may take a while" tip._DEGRADING_LEVELS = frozenset({"warning", "error"})-# Top-level stage → (phase number, title, subtitle). The pipeline announces the-# stage; how it is numbered and worded is the screen's business, and the screen-# is the only side that knows generation and persistence follow.+# Top-level stage -> (title, subtitle), in run order. The pipeline announces+# ingestion and analysis itself; the CLI opens generation and persistence.+# Numbering is the screen's business, and the screen is the only side that+# knows which stages follow.## The keys are spelled out rather than imported from# ``repowise.core.pipeline.progress``: that module's package eagerly imports the@@ -28,41 +28,46 @@ _DEGRADING_LEVELS = frozenset({"warning", "error"})# function body, and paying ~170ms of pipeline import on ``repowise --help`` or# on each post-commit hook run to read two string constants is a bad trade.# ``test_init_ux`` pins these against the core constants so they cannot drift.-_STAGE_HEADERS: dict[str, tuple[int, str, str]] = {+_STAGES: dict[str, tuple[str, str]] = {"ingestion": (- 1,"Ingestion","Walking the tree, parsing files, building the dependency graph",),- "analysis": (2, "Analysis", "Dead code, code health, architectural decisions"),+ "analysis": ("Analysis", "Dead code, code health, architectural decisions"),+ "generation": ("Generation", ""),+ "persistence": ("Persistence", "Saving to database and building search index"),}-class MaybeCountColumn(ProgressColumn):- """Progress column that shows ``completed/total`` when total is known,- or just ``completed`` when total is ``None`` (indeterminate phase).+def stage_order(total_phases: int) -> list[str]:+ """The stages a run of ``total_phases`` goes through; fast mode skips generation."""+ stages = list(_STAGES)+ return stages if total_phases >= len(stages) else [s for s in stages if s != "generation"]- This prevents the ugly ``1214/None`` display that appears for phases- like file traversal and dead-code detection whose total is not known- upfront.- """- def render(self, task: Task) -> Text:- if task.total is None or task.total == 0:- return Text(str(int(task.completed)), style="progress.download")- return Text(- f"{int(task.completed)}/{int(task.total)}",- style="progress.download",- )+def _order_with(stage: str, total_phases: int) -> list[str]:+ # A caller that opens a stage its count leaves out still gets a header.+ order = stage_order(total_phases)+ return order if stage in order else list(_STAGES)+++def print_stage(console: Console, stage: str, total_phases: int, subtitle: str = "") -> None:+ """The numbered rule that opens ``stage``, e.g. ``Phase 4 of 4 · Persistence``."""+ title, default_subtitle = _STAGES[stage]+ num = min(_order_with(stage, total_phases).index(stage) + 1, total_phases)+ print_phase_header(console, num, total_phases, title, subtitle or default_subtitle)-# ----------------------------------------------------------------------------# Rich progress callback — implements core ProgressCallback protocol-# ---------------------------------------------------------------------------+def upcoming_stages(stage: str, total_phases: int) -> list[str]:+ """Titles of the stages after ``stage``."""+ order = _order_with(stage, total_phases)+ return [_STAGES[s][0] for s in order[order.index(stage) + 1 :]]+# Every phase the pipeline emits needs an entry here: the fallback prints the# raw internal id (``knowledge_graph.skeleton...``) beside proper sentences.# ``…`` throughout, matching the CLI-authored status lines these interleave with.+# A leading ``↳`` marks a sub-step of the phase above it._PHASE_LABELS: dict[str, str] = {"traverse": "Scanning & filtering files…","parse": "Parsing files…",@@ -72,6 +77,27 @@ _PHASE_LABELS: dict[str, str] = {"graph.heritage": " ↳ Resolving inheritance","graph.calls": " ↳ Resolving call edges","graph.type_refs": " ↳ Resolving type references",+ "graph.member_reads": " ↳ Resolving member reads",+ "graph.same_package": " ↳ Linking same-package files",+ "graph.same_namespace": " ↳ Linking same-namespace files",+ "graph.same_namespace_php": " ↳ Linking same-namespace PHP files",+ "graph.spec_mirrors": " ↳ Linking specs to their sources",+ "graph.header_pairs": " ↳ Pairing headers with sources",+ "graph.partials": " ↳ Linking partial classes",+ "graph.same_module": " ↳ Linking same-module files",+ "graph.compile_order": " ↳ Reading compile order",+ "graph.go_interfaces": " ↳ Resolving Go interfaces",+ "graph.dispatch": " ↳ Resolving dynamic dispatch",+ "graph.ts_index": " ↳ Indexing TypeScript and JavaScript modules",+ "graph.jvm_index": " ↳ Indexing Java and Kotlin packages",+ "graph.dotnet_index": " ↳ Indexing .NET projects",+ "graph.go_index": " ↳ Indexing Go packages",+ "graph.rust_targets": " ↳ Reading Rust crate targets",+ "graph.cpp_index": " ↳ Indexing C and C++ includes",+ "graph.swift_entry": " ↳ Finding Swift entry points",+ "graph.composer_files": " ↳ Reading Composer autoload rules",+ "graph.dart_shells": " ↳ Indexing Dart packages",+ "graph.godot_project": " ↳ Reading the Godot project","dynamic_hints": " ↳ Wiring dynamic hints","graph.metrics": " ↳ Computing graph metrics (PageRank, betweenness)","graph.communities": " ↳ Detecting communities",@@ -83,31 +109,83 @@ _PHASE_LABELS: dict[str, str] = {"health": "Scoring code health…","decisions": "Extracting decisions…","doc_drift": "Checking documentation drift…",+ "checkpoint.index": "Saving a resume checkpoint…",+ "checkpoint.analysis": "Saving a resume checkpoint…","knowledge_graph.skeleton": "Building the knowledge graph…","knowledge_graph.enrich": " ↳ Naming layers and building the tour","generation": "Generating pages…",- "generation.llm": " ↳ Writing pages that need the model",- "onboarding": "Curating onboarding docs…",+ "generation.llm": " ↳ Writing overview and subsystem pages",+ "onboarding": " ↳ Curating onboarding docs",+ "embedding": "Embedding pages for semantic search…",+ "vector_store": "Opening the search index…","persist": "Saving to the database…",+ "savings": "Recovering token savings from agent history…",+ "state": "Writing index state…",+ "views": "Refreshing agent views…",+ "editor_files": "Writing editor files…",+}++# What a phase counts, so every number on screen has a unit. A phase missing+# here shows its count bare while running and no count once done.+_PHASE_UNITS: dict[str, str] = {+ "traverse": "files",+ "parse": "files",+ "graph.imports": "files",+ "graph.heritage": "files",+ "graph.calls": "files",+ "graph.type_refs": "files",+ "graph.metrics": "algorithms",+ "graph.communities": "algorithms",+ "git": "files",+ "co_change": "commits",+ "dead_code": "checks",+ "health": "checks",+ "doc_drift": "checks",+ "decisions": "sources",+ "generation": "pages",+ "generation.llm": "pages",+ "onboarding": "pages",+ "embedding": "pages",}+# A step whose work is split across live rows: its done row counts its parts+# too, so the step reports one total. Generation draws free and paid pages as+# separate bars (one bar of mostly free pages reads as frozen on the paid ones).+_PHASE_PARTS: dict[str, tuple[str, ...]] = {"generation": ("generation.llm",)}++# Steps whose announced total is an upper bound (a page may gate-skip), so the+# done row counts the items actually finished rather than the total.+_ESTIMATED_TOTALS = frozenset({"generation", "generation.llm", "onboarding"})+class RichProgressCallback:"""Adapter that implements ``repowise.core.pipeline.ProgressCallback``- using a Rich ``Progress`` instance for terminal display.+ on the live display from :func:`repowise.cli.ui.progress_display.make_progress`.++ A running step is a live row; when it finishes, its done row is printed+ above the display, so the steps read top to bottom as a checklist.Usage::- from rich.progress import Progress- with Progress(...) as progress_bar:+ with make_progress(console) as progress_bar:callback = RichProgressCallback(progress_bar, console)result = run_async(run_pipeline(..., progress=callback))"""- def __init__(self, progress: Any, console: Console, *, total_phases: int | None = None) -> None:+ def __init__(+ self,+ progress: Any,+ console: Console,+ *,+ total_phases: int | None = None,+ stage: str | None = None,+ ) -> None:self._progress = progressself._console = consoleself._tasks: dict[str, Any] = {}+ self._done: set[str] = set()+ # Items each finished step reported in its done row.+ self._done_counts: dict[str, float] = {}# Every warning this callback rendered, in order. Printing is enough# for a human watching, but agent-driven mode is the primary path and# nobody is watching there: a run that degraded and a run that did not@@ -123,6 +201,14 @@ class RichProgressCallback:# numbers its phases. The workspace flow prints its own per-repo header# and would otherwise draw a "Phase 1 of 4" rule for every repo.self._total_phases = total_phases+ if stage is not None:+ self._show_upcoming(stage)++ def _show_upcoming(self, stage: str) -> None:+ if self._total_phases is None or stage not in _STAGES:+ return+ if hasattr(self._progress, "upcoming"):+ self._progress.upcoming = upcoming_stages(stage, self._total_phases)def _print_above_live(self, emit: Callable[[], None]) -> None:"""Run *emit* outside the Live region so its output lands cleanly@@ -148,48 +234,98 @@ class RichProgressCallback:ever saw read "Phase 3 of 4"."""total = self._total_phases- meta = _STAGE_HEADERS.get(stage)- if total is None or meta is None:+ if total is None or stage not in _STAGES:return- num, title, subtitle = meta- self._print_above_live(- lambda: print_phase_header(self._progress.console, num, total, title, subtitle)- )+ self._show_upcoming(stage)+ self._print_above_live(lambda: print_stage(self._progress.console, stage, total))def on_phase_start(self, phase: str, total: int | None) -> None:label = _PHASE_LABELS.get(phase, f"{phase}…")+ self._done.discard(phase)+ self._done_counts.pop(phase, None)# If phase already has a task, update its total and make visibleif phase in self._tasks:self._progress.update(self._tasks[phase], total=total, visible=True)else:- self._tasks[phase] = self._progress.add_task(label, total=total, visible=True, cost=0.0)+ self._tasks[phase] = self._progress.add_task(+ label,+ total=total,+ visible=True,+ cost=0.0,+ unit=_PHASE_UNITS.get(phase, ""),+ detail="",+ )def on_item_done(self, phase: str) -> None:if phase in self._tasks:self._progress.advance(self._tasks[phase])+ def on_item_label(self, phase: str, label: str) -> None:+ """Show the item ``phase`` is on, e.g. the file being parsed."""+ task_id = self._tasks.get(phase)+ if task_id is not None:+ with contextlib.suppress(Exception):+ self._progress.update(task_id, detail=label)+def on_phase_done(self, phase: str) -> None:- """Mark a phase task as fully complete and hide it from the live- display, so the phase-summary lines that follow aren't interleaved- with stale progress bars (issue: phantom/duplicated progress bars).+ """Hide the finished step's live row and print its done row above the display.++ Hiding keeps phase-summary lines that follow from interleaving with stale+ progress bars (issue: phantom/duplicated progress bars). A phase reported+ done twice prints once."""task_id = self._tasks.get(phase)- if task_id is None:+ if task_id is None or phase in self._done:return+ self._done.add(phase)try:task = next((t for t in self._progress.tasks if t.id == task_id), None)+ finished = task.completed if task is not None else 0if task is not None and task.total is not None:self._progress.update(task_id, completed=task.total, visible=False)else:self._progress.update(task_id, visible=False)except Exception:- pass+ return+ if task is None:+ return+ count = finished if phase in _ESTIMATED_TOTALS else (task.total or finished)+ count += sum(self._done_counts.get(p, 0) for p in _PHASE_PARTS.get(phase, ()))+ self._done_counts[phase] = count+ line = checklist.done_line(+ checklist.FinishedStep(+ label=str(task.description),+ completed=count,+ total=None,+ unit=str(task.fields.get("unit", "")),+ elapsed=task.elapsed,+ )+ )+ self._print_above_live(lambda: self._progress.console.print(line, highlight=False))++ def on_phase_failed(self, phase: str) -> None:+ """Hide a step that did not finish, with no done row: its warning says why."""+ task_id = self._tasks.get(phase)+ if task_id is not None:+ with contextlib.suppress(Exception):+ self._progress.update(task_id, visible=False)++ @contextlib.contextmanager+ def step(self, phase: str) -> Iterator[None]:+ """Run a block as one labelled step. A step that raises gets no done row."""+ self.on_phase_start(phase, None)+ try:+ yield+ except BaseException:+ self.on_phase_failed(phase)+ raise+ self.on_phase_done(phase)def on_message(self, level: str, text: str) -> None:# ``info`` is deliberately unstyled. It carries neutral facts ("Scanned# 12,431 files", "Languages: …"), and rendering those in the same green- # as "✓ Database updated" made green mean "the pipeline said something"- # rather than "this succeeded".+ # as a done row made green mean "the pipeline said something" rather+ # than "this succeeded".## ``notice`` is rendered with the warning style so it stays visible, but# it is not a degradation: size-skip lines and progress tips arediff --git a/packages/cli/src/repowise/cli/ui/progress_display.py b/packages/cli/src/repowise/cli/ui/progress_display.pynew file mode 100644index 000000000..7708e675d--- /dev/null+++ b/packages/cli/src/repowise/cli/ui/progress_display.py@@ -0,0 +1,130 @@+"""The one live progress display every pipeline command draws.++:func:`make_progress` is the factory. The running rows are Rich tasks, one per+step, with a count and unit, the time the step has run, the time left when it+can be measured, and the item it is on. Under them sit the long-step line and+the stages still to come. Finished steps leave the live region: the callback+prints their done row above it (see :mod:`repowise.cli.ui.checklist`).+"""++from __future__ import annotations++from collections.abc import Iterable+from typing import Any++from rich.console import Console, RenderableType+from rich.progress import BarColumn, Progress, ProgressColumn, SpinnerColumn, Task, TextColumn+from rich.text import Text++from repowise.cli.ui import checklist+from repowise.cli.ui.brand import BRAND_STYLE, DIM, OK+from repowise.cli.ui.mascot import OWL_SPINNER++# The item a step is on is a path; keep its tail, which is the part that changes.+_DETAIL_WIDTH = 36+++class MaybeCountColumn(ProgressColumn):+ """``completed/total unit``, or ``completed unit`` when the total is unknown.++ Never ``1214/None``: traversal and dead-code detection start without one.+ A step with no unit shows ``completed/total`` when it has a total, else nothing.+ """++ def render(self, task: Task) -> Text:+ unit = task.fields.get("unit", "")+ total = task.total if task.total else None+ text = checklist.count_text(task.completed, total, unit)+ if not text and total:+ text = f"{int(task.completed):,}/{int(total):,}"+ return Text(text, style="progress.download")+++class RunningTimeColumn(ProgressColumn):+ """How long the step has run, in whole seconds."""++ def render(self, task: Task) -> Text:+ return Text(checklist.format_running(task.elapsed), style="progress.elapsed")+++class TimeLeftColumn(ProgressColumn):+ """Time left, only when the step has a total and a measured rate."""++ def render(self, task: Task) -> Text:+ left = checklist.time_left(task.completed, task.total, task.elapsed)+ if left is None or task.finished:+ return Text("")+ return Text(checklist.format_time_left(left), style=DIM)+++class DetailColumn(ProgressColumn):+ """The item the step is on, e.g. the file being parsed."""++ def render(self, task: Task) -> Text:+ detail = str(task.fields.get("detail") or "")+ if len(detail) > _DETAIL_WIDTH:+ detail = "…" + detail[-(_DETAIL_WIDTH - 1) :]+ return Text(detail, style=DIM, overflow="ellipsis", no_wrap=True)+++class ChecklistProgress(Progress):+ """A Rich ``Progress`` that also draws the long-step line and what comes next."""++ def __init__(self, *columns: Any, resume_command: str | None = None, **kwargs: Any) -> None:+ # Set before Progress.__init__, which renders once while building its Live.+ #: Stage titles still to run, set by whoever knows the run's stages.+ self.upcoming: list[str] = []+ # Only steps that really resume set this; the line promises it.+ self.resume_command = resume_command+ self._closing = False+ super().__init__(*columns, **kwargs)++ def get_renderables(self) -> Iterable[RenderableType]:+ # The final frame stays on screen and is the only frame a pipe gets.+ # Every finished step already left its done row, so it draws nothing:+ # a step cut short by Ctrl-C must not stay behind with a time left.+ if self._closing:+ return+ running = [t for t in self.tasks if t.visible and not t.finished]+ yield self.make_tasks_table(running)+ if self.resume_command and any(+ (t.elapsed or 0.0) >= checklist.LONG_STEP_SECONDS for t in running+ ):+ yield Text.from_markup(checklist.long_step_line(self.resume_command))+ if self.upcoming:+ yield Text.from_markup(checklist.upcoming_line(self.upcoming))++ def stop(self) -> None:+ self._closing = True+ super().stop()+++def make_progress(+ console: Console,+ *,+ cost: bool = False,+ transient: bool = False,+ resume_command: str | None = None,+) -> ChecklistProgress:+ """Build the progress display. ``cost`` adds the running spend column.++ ``resume_command`` is the command that picks up an interrupted run; pass it+ only where Ctrl-C really is safe, since the long-step line says so.+ """+ columns: list[Any] = [+ SpinnerColumn(spinner_name=OWL_SPINNER, style=BRAND_STYLE),+ TextColumn("[progress.description]{task.description}"),+ BarColumn(bar_width=24),+ MaybeCountColumn(),+ RunningTimeColumn(),+ TimeLeftColumn(),+ DetailColumn(),+ ]+ if cost:+ columns.append(TextColumn("[" + OK + "]${task.fields[cost]:.3f}[/]"))+ return ChecklistProgress(+ *columns,+ console=console,+ transient=transient,+ resume_command=resume_command,+ )diff --git a/packages/cli/src/repowise/cli/ui/result_panels.py b/packages/cli/src/repowise/cli/ui/result_panels.pyindex d9fe8fe7f..b0deabed0 100644--- a/packages/cli/src/repowise/cli/ui/result_panels.py+++ b/packages/cli/src/repowise/cli/ui/result_panels.py@@ -1,10 +1,10 @@-"""Analysis readout, completion panel, and the notes that sit beside it.+"""Completion panel, and the notes that sit beside it.One panel per run, and it is the last thing printed. Everything else on these-screens is a readout — the analysis interstitial, the MCP note, the list of-files init wrote into the working tree — and readouts get a section heading and-vertical rhythm rather than a border, because a border means "a discrete object-you act on" and none of them is.+screens is a readout — the MCP note, the list of files init wrote into the+working tree — and readouts get a section heading and vertical rhythm rather+than a border, because a border means "a discrete object you act on" and none+of them is.The completion panel carries **two** commands. It used to carry up to seven,assembled from every signal the run produced: the dashboard, the mode's upgrade@@ -25,64 +25,10 @@ from rich.console import Console, Groupfrom rich.panel import Panelfrom rich.text import Text-from repowise.cli.ui.brand import BRAND, DIM, VALUE, key_value_table, print_section+from repowise.cli.ui.brand import BRAND, DIM, VALUE, key_value_tablefrom repowise.cli.ui.mascot import EYES_HAPPY, mini-def print_analysis_summary(- console: Console,- *,- file_count: int,- symbol_count: int,- graph_nodes: int,- graph_edges: int,- dead_unreachable: int = 0,- dead_unused: int = 0,- dead_lines: int = 0,- decision_count: int = 0,- git_files: int = 0,- hotspot_count: int = 0,- community_count: int = 0,- lang_summary: str = "",-) -> None:- """Print the analysis-complete readout shown before generation."""- # The headline is printed rather than passed as the blurb: ``print_section``- # dims its blurb, and a bold count inside a dim wrapper renders bold *and*- # dim, which is quieter than the plain bold it replaced.- print_section(console, "Analysis complete")- headline = (- f"[bold]{file_count:,}[/bold] files · [bold]{symbol_count:,}[/bold] symbols"- + (f" · [bold]{community_count}[/bold] communities" if community_count else "")- )- console.print(f" {headline}")- if lang_summary:- console.print(f" [dim]{lang_summary}[/dim]")- console.print()-- rows: list[tuple[str, str]] = [- ("Graph", f"{graph_nodes:,} nodes · {graph_edges:,} edges"),- ]- if git_files:- rows.append(- (- "Git",- f"{git_files:,} files indexed"- + (f" · {hotspot_count} hotspots" if hotspot_count else ""),- )- )- if dead_unreachable or dead_unused:- rows.append(- (- "Dead code",- f"{dead_unreachable} unreachable · {dead_unused} unused exports"- + (f" · ~{dead_lines:,} lines" if dead_lines else ""),- )- )- if decision_count:- rows.append(("Decisions", f"{decision_count} extracted"))- console.print(key_value_table(rows, label_width=11))--def build_completion_panel(title: str,metrics: list[tuple[str, str]],diff --git a/packages/core/src/repowise/core/analysis/health/duplication/isolation.py b/packages/core/src/repowise/core/analysis/health/duplication/isolation.pyindex 80d318a8e..63ec8ab2f 100644--- a/packages/core/src/repowise/core/analysis/health/duplication/isolation.py+++ b/packages/core/src/repowise/core/analysis/health/duplication/isolation.py@@ -55,6 +55,9 @@ def _worker() -> None:"""Run in a fresh interpreter and return only the compact report."""try:+ from repowise.core.worker_logging import quiet_worker_logs++ quiet_worker_logs()parsed_files = [_ParsedFile(_FileInfo(*file_info)) for file_info in files]report = detect_clones(parsed_files,diff --git a/packages/core/src/repowise/core/generation/page_generator/core.py b/packages/core/src/repowise/core/generation/page_generator/core.pyindex 20fe7ee6d..8d0ea1986 100644--- a/packages/core/src/repowise/core/generation/page_generator/core.py+++ b/packages/core/src/repowise/core/generation/page_generator/core.py@@ -257,6 +257,7 @@ class PageGenerator(PerTypeGenerationMixin, StructuralRenderMixin):timings: Any | None = None,on_warning: Callable[[str], None] | None = None,persisted_page_ids: set[str] | None = None,+ on_embed: Callable[[int, bool], None] | None = None,) -> list[GeneratedPage]:"""Generate all wiki pages for a repository.@@ -285,6 +286,9 @@ class PageGenerator(PerTypeGenerationMixin, StructuralRenderMixin):``timings`` is the run's shared ``PhaseTimings`` table. Generationrecords its per-level and checkpoint spans into it so they reportbeside the top-level phases; None disables those spans.++ ``on_embed(count, finished)`` brackets each batched embed of ``count``+ pages, so a display can show embedding as its own step."""from .orchestrate import run_generate_all@@ -323,6 +327,7 @@ class PageGenerator(PerTypeGenerationMixin, StructuralRenderMixin):timings=timings,on_warning=on_warning,persisted_page_ids=persisted_page_ids,+ on_embed=on_embed,)# ------------------------------------------------------------------diff --git a/packages/core/src/repowise/core/generation/page_generator/orchestrate.py b/packages/core/src/repowise/core/generation/page_generator/orchestrate.pyindex 15efe0747..6a773ac17 100644--- a/packages/core/src/repowise/core/generation/page_generator/orchestrate.py+++ b/packages/core/src/repowise/core/generation/page_generator/orchestrate.py@@ -113,6 +113,7 @@ class _GenerationRun:timings: Any | None = None,on_warning: Callable[[str], None] | None = None,persisted_page_ids: set[str] | None = None,+ on_embed: Callable[[int, bool], None] | None = None,) -> None:self.gen = genself.config = gen._config@@ -149,6 +150,7 @@ class _GenerationRun:self.on_total_known = on_total_knownself.on_subphase = on_subphaseself.on_warning = on_warning+ self.on_embed = on_embedself.git_meta_map = git_meta_mapself.resume = resumeself.repo_path = repo_path@@ -750,9 +752,13 @@ class _GenerationRun:# swallow here hid a 300k-token request rejection that silently lost# every file-page embedding on init (`repowise reindex` repairs).if embed_items and self.vector_store is not None:+ if self.on_embed is not None:+ self.on_embed(len(embed_items), False)with timed(self.timings, "generation.embed"):try:await self.vector_store.embed_batch(embed_items)+ if self.on_embed is not None:+ self.on_embed(len(embed_items), True)except Exception as e:self.gen.embed_failed_pages += len(embed_items)log.warning(diff --git a/packages/core/src/repowise/core/ingestion/graph/_betweenness.py b/packages/core/src/repowise/core/ingestion/graph/_betweenness.pyindex dab58b0b7..d0d576935 100644--- a/packages/core/src/repowise/core/ingestion/graph/_betweenness.py+++ b/packages/core/src/repowise/core/ingestion/graph/_betweenness.py@@ -87,6 +87,9 @@ _WORKER_GRAPH: nx.DiGraph | None = Nonedef _init_worker(n: int, edges: list[tuple[int, int]], directed: bool) -> None:"""Pool initializer: build the (attribute-free) int-labeled graph once."""global _WORKER_GRAPH+ from repowise.core.worker_logging import quiet_worker_logs++ quiet_worker_logs()g: nx.DiGraph = nx.DiGraph() if directed else nx.Graph()g.add_nodes_from(range(n))g.add_edges_from(edges)diff --git a/packages/core/src/repowise/core/pipeline/_run/analysis.py b/packages/core/src/repowise/core/pipeline/_run/analysis.pyindex ce5a67b0c..72b7da3c8 100644--- a/packages/core/src/repowise/core/pipeline/_run/analysis.py+++ b/packages/core/src/repowise/core/pipeline/_run/analysis.py@@ -230,6 +230,7 @@ def _build_kg_skeleton(run: PipelineRun, build_skeleton: Any, new_fingerprint: srepo_path=run.repo_path,)run.knowledge_graph_result.fingerprint = new_fingerprint+ _phase_done(progress, "knowledge_graph.skeleton")if progress:kg = run.knowledge_graph_resultprogress.on_message(diff --git a/packages/core/src/repowise/core/pipeline/phases/generation.py b/packages/core/src/repowise/core/pipeline/phases/generation.pyindex f611a5d57..aeb5e83ac 100644--- a/packages/core/src/repowise/core/pipeline/phases/generation.py+++ b/packages/core/src/repowise/core/pipeline/phases/generation.py@@ -14,7 +14,7 @@ import structlogfrom repowise.core.cost_estimator.estimator import STRUCTURAL_PAGE_TYPESfrom repowise.core.generation.models import count_stub_fallbacks-from repowise.core.pipeline.progress import ProgressCallback+from repowise.core.pipeline.progress import ProgressCallback, emit_item, emit_phase_failedfrom ._common import TEST_RUN_FILE_LIMIT, _phase_done, limit_to_top_pagerank@@ -27,6 +27,53 @@ logger = structlog.get_logger(__name__)_FREE_PAGE_TYPES = STRUCTURAL_PAGE_TYPES+class _GenerationDisplay:+ """What generation shows beyond its page bars: the page it is on, and embedding.++ Embedding is its own step on screen, but only when the vectors carry+ signal: the keyless embedder's would read as semantic search that is off.+ """++ def __init__(self, progress: Any, vector_store: Any, on_page_ready: Any | None) -> None:+ from repowise.core.providers.embedding import store_has_semantic_vectors++ self._progress = progress+ self._on_page_ready = on_page_ready+ self._show_embedding = progress is not None and store_has_semantic_vectors(vector_store)+ self._embedded = 0+ # Batches started minus batches finished: a failed batch never finishes.+ self._open = 0+ self._started = False++ def on_embed(self, count: int, finished: bool) -> None:+ if not self._show_embedding:+ return+ if not finished:+ self._started = True+ self._open += 1+ self._progress.on_phase_start("embedding", self._embedded + count)+ return+ self._open -= 1+ self._embedded += count+ for _ in range(count):+ self._progress.on_item_done("embedding")++ def page_ready(self, page: Any) -> None:+ if self._progress is not None:+ phase = "generation" if page.page_type in _FREE_PAGE_TYPES else "generation.llm"+ emit_item(self._progress, phase, page.target_path)+ if self._on_page_ready is not None:+ self._on_page_ready(page)++ def close_embedding(self) -> None:+ if not self._started:+ return+ if self._open == 0:+ _phase_done(self._progress, "embedding")+ else:+ emit_phase_failed(self._progress, "embedding")++async def run_generation(*,repo_path: Path,@@ -185,6 +232,8 @@ async def run_generation(if progress:progress.on_message("warning", text)+ display = _GenerationDisplay(progress, vector_store, on_page_ready)+generator = PageGenerator(llm_client,assembler,@@ -214,7 +263,7 @@ async def run_generation(dead_code_report=dead_code_report,decision_report=decision_report,external_systems=external_systems,- on_page_ready=on_page_ready,+ on_page_ready=display.page_ready,kg_modules=kg_modules,kg_data=kg_data,only_page_ids=only_page_ids,@@ -222,6 +271,7 @@ async def run_generation(timings=getattr(progress, "table", None),on_warning=on_warning,persisted_page_ids=persisted_page_ids,+ on_embed=display.on_embed,)if stats_out is not None:stats_out["embed_failed_pages"] = generator.embed_failed_pages@@ -237,8 +287,8 @@ async def run_generation()selection_out["omitted"] = max(0, selection_out["eligible"] - selection_out["generated"])- # Onboarding summary — count generated slots and surface which ones- # were gated out so the user can see the curated collection's state.+ # Which onboarding slots were made goes to the log; the screen has the+ # onboarding row's page count.onboarding_generated = [p for p in generated_pages if p.page_type == "onboarding"]promoted_present = {p.metadata.get("onboarding_slot")@@ -246,34 +296,17 @@ async def run_generation(if p.metadata.get("onboarding_slot")and p.page_type in ("repo_overview", "architecture_diagram")}- if progress:- if onboarding_generated or promoted_present:- # Imported here, not at module scope: importing the onboarding- # package registers every subkind, and this module is on the CLI's- # import path where that cost buys nothing.- from repowise.core.generation.onboarding.slots import ONBOARDING_ORDER-- slots_made = sorted(- {p.metadata.get("subkind", "?") for p in onboarding_generated} | promoted_present- )- progress.on_message(- "info",- # Derived rather than written down: the denominator was a- # literal 8 and went stale the first time a slot was added.- f"Onboarding: {len(slots_made)}/{len(ONBOARDING_ORDER)} slots"- f" — {', '.join(slots_made)}",- )- # Placeholders left behind by a failed provider call are in this list- # like any other page, and the run reports them as failures a line- # later. Counting the list here made the two lines disagree.- progress.on_message(- "info",- f"Generated {len(generated_pages) - count_stub_fallbacks(generated_pages)} pages",- )- # Surface the FAQ-weighted budget tilt when session demand shaped it- # (silent on fresh repos with no history — nothing to weight yet).+ slots_made = sorted(+ {p.metadata.get("subkind", "?") for p in onboarding_generated} | promoted_present+ )+ logger.info(+ "generation_done",+ pages=len(generated_pages) - count_stub_fallbacks(generated_pages),+ onboarding_slots=slots_made,+ )_phase_done(progress, "onboarding")_phase_done(progress, "generation.llm")_phase_done(progress, "generation")+ display.close_embedding()return generated_pagesdiff --git a/packages/core/src/repowise/core/pipeline/phases/ingestion.py b/packages/core/src/repowise/core/pipeline/phases/ingestion.pyindex 0024b0d19..a6d84d9f2 100644--- a/packages/core/src/repowise/core/pipeline/phases/ingestion.py+++ b/packages/core/src/repowise/core/pipeline/phases/ingestion.py@@ -18,7 +18,7 @@ from typing import Anyimport structlog-from repowise.core.pipeline.progress import ProgressCallback, emit_warning+from repowise.core.pipeline.progress import ProgressCallback, emit_item, emit_warningfrom ._common import _phase_done@@ -86,37 +86,42 @@ def _report_query_compilation_failures(stats: Any, progress: ProgressCallback |return-async def _timed_step(- label: str,- fn: Any,+async def _run_concurrent_steps(+ phase: str,+ steps: list[tuple[str, Any]],progress: ProgressCallback | None,-) -> Any:- """Run *fn* in a worker thread and emit a per-step completion line.-- Used to make ``asyncio.gather`` of multiple graph-algorithm calls- legible: without this, four concurrent thread-bound computations- (e.g. PageRank + betweenness + symbol PageRank + symbol betweenness)- appear in the CLI as one opaque several-minute spinner, so the user- has no signal as to which step is the bottleneck. With it, each algo- prints ` ↳ <label> ✓ (Xs)` as it finishes — completion order- surfaces the relative cost without changing the underlying execution.+) -> None:+ """Run each ``(label, fn)`` in a worker thread at once, as one counted phase.++ The running row's count advances as each finishes and its current item+ names the ones still running, so a long kernel (symbol betweenness on a+ big repo) is visibly the one holding the step. Per-step times go to the+ log rather than the screen: one done row per phase, no extra lines."""- t0 = time.monotonic()- try:- result = await asyncio.to_thread(fn)- except Exception as exc:- if progress is not None:- progress.on_message(- "warning",- f" ↳ {label} failed after {time.monotonic() - t0:.1f}s: {exc}",- )- raise- if progress is not None:- progress.on_message(- "info",- f" ↳ {label} ✓ ({time.monotonic() - t0:.1f}s)",- )- return result+ running = [label for label, _ in steps]+ if progress:+ progress.on_phase_start(phase, len(steps))+ emit_item(progress, phase, ", ".join(running))++ async def _one(label: str, fn: Any) -> None:+ t0 = time.monotonic()+ try:+ await asyncio.to_thread(fn)+ except Exception as exc:+ if progress is not None:+ progress.on_message(+ "warning",+ f" {label} failed after {time.monotonic() - t0:.1f}s: {exc}",+ )+ raise+ logger.info("graph_step_done", step=label, seconds=round(time.monotonic() - t0, 1))+ running.remove(label)+ if progress:+ progress.on_item_done(phase)+ emit_item(progress, phase, ", ".join(running))++ await asyncio.gather(*(_one(label, fn) for label, fn in steps))+ _phase_done(progress, phase)# Traversal skip counters, in report order: (stat attribute, how to describe it).@@ -320,6 +325,9 @@ def _parse_one(path_and_fi_and_bytes: tuple) -> Any:try:if _WORKER_PARSER is None:from repowise.core.ingestion import ASTParser+ from repowise.core.worker_logging import quiet_worker_logs++ quiet_worker_logs()_WORKER_PARSER = ASTParser()return _WORKER_PARSER.parse_file(fi, source)@@ -508,9 +516,16 @@ async def _parse_in_pool(# until the last file is done, which on large repos looked like a hang# at ``0/N``. Done-callbacks keep gather's ordered results intact.if progress is not None:- _parse_tick = lambda _fut: progress.on_item_done("parse") # noqa: E731- for fut in tasks:- fut.add_done_callback(_parse_tick)++ def _parse_tick(path: str) -> Any:+ def _tick(_fut: Any) -> None:+ progress.on_item_done("parse")+ emit_item(progress, "parse", path)++ return _tick++ for fut, (_idx, (fi, _src), _h) in zip(tasks, to_parse, strict=True):+ fut.add_done_callback(_parse_tick(fi.path))return await asyncio.gather(*tasks, return_exceptions=True)@@ -527,6 +542,7 @@ async def _parse_in_process(to_parse: list[tuple], progress: ProgressCallback |parse_results.append((fi.abs_path, str(exc)))if progress:progress.on_item_done("parse")+ emit_item(progress, "parse", fi.path)if i % 50 == 49:await asyncio.sleep(0)return parse_results@@ -705,7 +721,7 @@ async def _build_graph(# because on a small repo the build is over in under a second.progress.on_message("notice",- "Graph build can take several minutes on a first run. Safe to Ctrl-C — "+ "Graph build can take several minutes on a first run. Safe to Ctrl-C: ""re-run 'repowise init --resume' to continue where it stopped.",)await asyncio.to_thread(graph_builder.build, progress)@@ -774,26 +790,27 @@ async def _prime_graph_metrics(graph_builder: Any, progress: ProgressCallback |Otherwise they run lazily inside persist and generation behind opaquebars. Within a phase the kernels overlap via ``asyncio.gather`` so- betweenness (the dominant cost) runs alongside the rest, and each is- wrapped in ``_timed_step`` so its completion line names the bottleneck.+ betweenness (the dominant cost) runs alongside the rest, and the+ running row names the kernels still going, so it names the bottleneck."""- if progress:- progress.on_phase_start("graph.metrics", None)- await asyncio.gather(- _timed_step("PageRank", graph_builder.pagerank, progress),- _timed_step("betweenness centrality", graph_builder.betweenness_centrality, progress),- _timed_step("symbol PageRank", graph_builder.symbol_pagerank, progress),- _timed_step("symbol betweenness", graph_builder.symbol_betweenness_centrality, progress),+ await _run_concurrent_steps(+ "graph.metrics",+ [+ ("PageRank", graph_builder.pagerank),+ ("betweenness centrality", graph_builder.betweenness_centrality),+ ("symbol PageRank", graph_builder.symbol_pagerank),+ ("symbol betweenness", graph_builder.symbol_betweenness_centrality),+ ],+ progress,)- _phase_done(progress, "graph.metrics")-- if progress:- progress.on_phase_start("graph.communities", None)- await asyncio.gather(- _timed_step("community detection", graph_builder.community_detection, progress),- _timed_step("symbol communities", graph_builder.symbol_communities, progress),+ await _run_concurrent_steps(+ "graph.communities",+ [+ ("community detection", graph_builder.community_detection),+ ("symbol communities", graph_builder.symbol_communities),+ ],+ progress,)- _phase_done(progress, "graph.communities")async def _run_ingestion(diff --git a/packages/core/src/repowise/core/pipeline/progress.py b/packages/core/src/repowise/core/pipeline/progress.pyindex 9d45efd81..2f60b2c58 100644--- a/packages/core/src/repowise/core/pipeline/progress.py+++ b/packages/core/src/repowise/core/pipeline/progress.py@@ -35,6 +35,37 @@ def emit_stage(progress: Any, stage: str) -> None:fn(stage)+def emit_item(progress: Any, phase: str, label: str) -> None:+ """Name the item ``phase`` just finished (a file path, a page), for a display.++ Optional like :func:`emit_stage`: headless callbacks never grew+ ``on_item_label``. Never raises.+ """+ if progress is None:+ return+ fn = getattr(progress, "on_item_label", None)+ if fn is None:+ return+ try:+ fn(phase, label)+ except Exception: # a display callback must never break the pipeline+ logger.debug("progress_item_emit_failed", phase=phase, exc_info=True)+++def emit_phase_failed(progress: Any, phase: str) -> None:+ """Close ``phase`` on screen without marking it done; its warning says why.++ Optional like :func:`emit_stage`. Never raises.+ """+ fn = getattr(progress, "on_phase_failed", None)+ if fn is None:+ return+ try:+ fn(phase)+ except Exception: # a display callback must never break the pipeline+ logger.debug("progress_phase_failed_emit_failed", phase=phase, exc_info=True)++def emit_warning(progress: Any, text: str) -> None:"""Report a degradation on the one channel a default run actually shows.diff --git a/packages/core/src/repowise/core/pipeline/resume/controller.py b/packages/core/src/repowise/core/pipeline/resume/controller.pyindex f2141de9b..c775913db 100644--- a/packages/core/src/repowise/core/pipeline/resume/controller.py+++ b/packages/core/src/repowise/core/pipeline/resume/controller.py@@ -27,7 +27,7 @@ import structlogfrom ..persist import persist_analysis, persist_git, persist_ingestion, persist_symbol_analysisfrom ..phase_timing import timed-from ..progress import emit_warning+from ..progress import emit_phase_failed, emit_warningfrom .ledger import ResumeLedgerfrom .phases import RESUME_PHASE_ORDER, ResumePhasefrom .rehydrate import (@@ -41,6 +41,21 @@ from .rehydrate import (logger = structlog.get_logger(__name__)+# A checkpoint write is a step of its own on screen: on a large repo it is+# the longest stretch between two pipeline phases. A failed write gets no done+# row (``emit_phase_failed``); its warning says what happened instead.+def _show_start(progress: Any | None, phase: str) -> None:+ start = getattr(progress, "on_phase_start", None)+ if start is not None:+ start(phase, None)+++def _show_done(progress: Any | None, phase: str) -> None:+ done = getattr(progress, "on_phase_done", None)+ if done is not None:+ done(phase)++class ResumeController:"""Coordinates skip/persist/rehydrate for one pipeline run."""@@ -169,9 +184,10 @@ class ResumeController:source_map=source_map or {},)await self._ledger.mark_started(ResumePhase.INDEX)+ _show_start(progress, "checkpoint.index")try:- # No progress phase covers this write, and on a large repo it runs- # for minutes; without its own timing it is missing from the totals.+ # On a large repo this write runs for minutes; without its own+ # timing it is missing from the totals.with timed(getattr(progress, "table", None), "persist.checkpoint"):async with get_session(self._sf) as session:await persist_ingestion(view, session, self._repo_id)@@ -187,7 +203,9 @@ class ResumeController:f"Index checkpoint not saved ({exc}); ""a resumed run will have to recompute it.",)+ emit_phase_failed(progress, "checkpoint.index")return+ _show_done(progress, "checkpoint.index")self._index_persisted = Trueawait self._ledger.mark_completed(ResumePhase.INDEX)logger.info("resume_checkpoint_index", repo_id=self._repo_id)@@ -225,6 +243,7 @@ class ResumeController:vector_store=vector_store,)await self._ledger.mark_started(ResumePhase.ANALYSIS)+ _show_start(progress, "checkpoint.analysis")try:async with get_session(self._sf) as session:await persist_symbol_analysis(session, self._repo_id, parsed_files)@@ -236,7 +255,9 @@ class ResumeController:f"Analysis checkpoint not saved ({exc}); ""a resumed run will have to recompute dead code, health and decisions.",)+ emit_phase_failed(progress, "checkpoint.analysis")return+ _show_done(progress, "checkpoint.analysis")extraction_completed = decision_report is not Nonedecisions_count = (len(getattr(decision_report, "decisions", []) or []) if extraction_completed else 0diff --git a/packages/core/src/repowise/core/worker_logging.py b/packages/core/src/repowise/core/worker_logging.pynew file mode 100644index 000000000..2301dd775--- /dev/null+++ b/packages/core/src/repowise/core/worker_logging.py@@ -0,0 +1,20 @@+"""Logging inside spawned worker processes."""++from __future__ import annotations++import logging+++def quiet_worker_logs() -> None:+ """Drop a worker's log lines below ERROR. Call once at worker start.++ A spawn child starts with structlog's defaults, which print every level to+ stdout. The parent CLI's filter does not cross the process boundary, so a+ worker's debug lines landed in the middle of the parent's progress display.+ """+ import structlog++ structlog.configure(+ wrapper_class=structlog.make_filtering_bound_logger(logging.ERROR),+ cache_logger_on_first_use=False,+ )diff --git a/tests/unit/cli/test_full_upgrade_progress.py b/tests/unit/cli/test_full_upgrade_progress.pyindex ad540d4cf..3fa904835 100644--- a/tests/unit/cli/test_full_upgrade_progress.py+++ b/tests/unit/cli/test_full_upgrade_progress.py@@ -51,8 +51,8 @@ def test_full_upgrade_passes_a_real_progress_callback() -> None:assert "RichProgressCallback" in src, ("the full upgrade must attach a live progress bar, not progress=None")- # The callback is wired to the same rich Progress init uses.- assert "Progress(" in src+ # The callback is wired to the same progress display init uses.+ assert "make_progress(" in srcdef test_full_upgrade_estimate_names_structural_pages() -> None:diff --git a/tests/unit/cli/test_init_failure_reporting.py b/tests/unit/cli/test_init_failure_reporting.pyindex 13858ac5c..b56434bd0 100644--- a/tests/unit/cli/test_init_failure_reporting.py+++ b/tests/unit/cli/test_init_failure_reporting.py@@ -182,7 +182,7 @@ def test_recorded_cost_includes_the_knowledge_graph_enrichment(tmp_path, monkeyp@pytest.mark.parametrize("verbose_flag", [True, False])def test_run_repo_generation_zero_failures(tmp_path, monkeypatch, verbose_flag):- """When no pages fail, run_repo_generation prints success summary only when verbose, stays silent otherwise."""+ """A clean run prints nothing here: the "Generating pages" done row carries the count."""jobs_dir = tmp_path / ".repowise" / "jobs"jobs_dir.mkdir(parents=True, exist_ok=True)@@ -236,10 +236,7 @@ def test_run_repo_generation_zero_failures(tmp_path, monkeypatch, verbose_flag):output = "\n".join(printed_lines)assert "failed" not in outputassert "The documentation is incomplete" not in output- if verbose_flag:- assert "Generated [bold]1[/bold] pages" in output- else:- assert output.strip() == ""+ assert "Generated" not in outputdef test_show_completion_panel_with_failures(monkeypatch):@@ -463,7 +460,7 @@ class TestStubsAreNotCountedTwice:def test_a_clean_run_is_unaffected(self, tmp_path, monkeypatch):output = self._run(tmp_path, monkeypatch, [_page("module_page:a")], [])- assert "Generated [bold]1[/bold] pages" in output+ assert "Generated" not in outputassert "failed" not in outputdiff --git a/tests/unit/cli/test_init_ux.py b/tests/unit/cli/test_init_ux.pyindex 543a7c3ad..52a04c4c4 100644--- a/tests/unit/cli/test_init_ux.py+++ b/tests/unit/cli/test_init_ux.py@@ -99,9 +99,10 @@ def test_stage_header_keys_match_the_core_stage_constants() -> None:"""progress.py spells the keys out rather than importing them, to keep thepipeline package off the CLI's import path. This is what stops that frombecoming a silent drift."""- from repowise.cli.ui.progress import _STAGE_HEADERS+ from repowise.cli.ui.progress import _STAGES, stage_order- assert set(_STAGE_HEADERS) == {STAGE_INGESTION, STAGE_ANALYSIS}+ assert stage_order(4)[:2] == [STAGE_INGESTION, STAGE_ANALYSIS]+ assert set(_STAGES) == set(stage_order(4))def test_the_progress_module_does_not_drag_in_the_pipeline_package() -> None:diff --git a/tests/unit/cli/test_progress_checklist.py b/tests/unit/cli/test_progress_checklist.pynew file mode 100644index 000000000..1c0467b2a--- /dev/null+++ b/tests/unit/cli/test_progress_checklist.py@@ -0,0 +1,312 @@+"""The phase checklist: done rows, running rows, what is next, and the one factory."""++from __future__ import annotations++import io++import pytest+from rich.console import Console+from rich.progress import TextColumn++from repowise.cli.ui import checklist+from repowise.cli.ui.progress import RichProgressCallback, print_stage, upcoming_stages+from repowise.cli.ui.progress_display import ChecklistProgress, make_progress+++class _Clock:+ def __init__(self) -> None:+ self.now = 1000.0++ def __call__(self) -> float:+ return self.now+++def _console(*, terminal: bool) -> tuple[Console, io.StringIO]:+ buf = io.StringIO()+ console = Console(file=buf, width=120, force_terminal=terminal, color_system=None)+ return console, buf+++def _render(progress: ChecklistProgress, width: int = 160) -> str:+ console = Console(file=io.StringIO(), width=width, color_system=None)+ with console.capture() as cap:+ console.print(progress.get_renderable())+ return cap.get()+++# --- renderer ----------------------------------------------------------------+++def test_a_substep_label_keeps_its_depth_and_drops_the_ellipsis() -> None:+ assert checklist.split_label(" ↳ Resolving imports") == ("Resolving imports", 1)+ assert checklist.split_label("Parsing files…") == ("Parsing files", 0)+++def test_every_count_carries_its_unit() -> None:+ assert checklist.count_text(1204, 2938, "files") == "1,204/2,938 files"+ assert checklist.count_text(50, None, "files") == "50 files"+ assert checklist.count_text(3, 9, "") == ""+++ ("completed", "total", "elapsed"),+ [+ (5, None, 30.0), # no total: nothing to measure against+ (0, 100, 30.0), # nothing finished yet: no rate+ (5, 100, 1.0), # too early: the rate is mostly startup+ (2, 3, 30.0), # three coarse items have no rate+ (3, 100, 30.0), # too few finished+ (100, 100, 30.0), # finished+ ],+)+def test_no_time_left_without_an_honest_estimate(completed, total, elapsed) -> None:+ assert checklist.time_left(completed, total, elapsed) is None+++def test_time_left_follows_the_measured_rate() -> None:+ assert checklist.time_left(25, 100, 10.0) == pytest.approx(30.0)+ assert checklist.format_time_left(30.0) == "about 30s left"+ assert checklist.format_time_left(200.0) == "about 3m left"+++def test_running_time_is_whole_seconds() -> None:+ assert checklist.format_running(12.7) == "12s"+ assert checklist.format_running(65.2) == "1m 05s"+ assert checklist.format_running(None) == "0s"+++def test_a_done_row_names_the_step_its_count_and_its_time() -> None:+ line = checklist.done_line(+ checklist.FinishedStep("Parsing files…", completed=30, total=30, unit="files", elapsed=0.42)+ )+ plain = Console().render_str(line).plain+ assert plain == " ✓ Parsing files · 30 files · 0.4s"+++def test_a_substep_done_row_is_indented_and_a_unitless_step_shows_only_its_time() -> None:+ line = checklist.done_line(checklist.FinishedStep(" ↳ Detecting communities", elapsed=1.5))+ assert Console().render_str(line).plain == " ✓ Detecting communities · 1.5s"+++def test_pending_and_done_states_carry_a_glyph_not_only_a_colour() -> None:+ assert Console().render_str(checklist.upcoming_line(["Analysis", "Persistence"])).plain == (+ " ○ Next: Analysis · Persistence"+ )+ assert checklist.STATE_MARKS[checklist.DONE][0] == "✓"+++def test_no_em_dashes_in_checklist_copy() -> None:+ texts = [+ checklist.long_step_line("repowise init --resume"),+ checklist.upcoming_line(["Analysis"]),+ checklist.done_line(checklist.FinishedStep("Parsing files…", 1, 1, "files", 1.0)),+ ]+ assert not any("—" in t for t in texts)+++# --- factory -----------------------------------------------------------------+++def test_the_factory_adds_the_cost_column_only_when_asked_and_keeps_its_placeholder() -> None:+ """Lesson #1571: the format placeholder must reach Rich literally."""+ console, _ = _console(terminal=False)+ plain = make_progress(console)+ priced = make_progress(console, cost=True)+ formats = [c.text_format for c in priced.columns if isinstance(c, TextColumn)]+ assert any("${task.fields[cost]:.3f}" in f for f in formats)+ assert len(priced.columns) == len(plain.columns) + 1+++def test_a_running_row_shows_count_unit_time_left_and_the_current_item() -> None:+ console, _ = _console(terminal=False)+ progress = make_progress(console)+ clock = _Clock()+ progress.get_time = clock+ task = progress.add_task("Parsing files…", total=100, unit="files", detail="", cost=0.0)+ progress.start_task(task)+ clock.now += 10.0+ progress.update(task, completed=25, detail="src/app/routing.py")++ out = _render(progress)+ assert "25/100 files" in out+ assert "10s" in out+ assert "about 30s left" in out+ assert "src/app/routing.py" in out+++def test_the_long_step_line_needs_a_resume_command_and_ten_seconds() -> None:+ console, _ = _console(terminal=False)+ for resume, wait, shown in (+ ("repowise init --resume", 11.0, True),+ ("repowise init --resume", 5.0, False),+ (None, 60.0, False),+ ):+ progress = make_progress(console, resume_command=resume)+ clock = _Clock()+ progress.get_time = clock+ progress.add_task("Parsing files…", total=None, unit="files", detail="", cost=0.0)+ clock.now += wait+ assert ("Safe to Ctrl-C" in _render(progress)) is shown+++def test_the_final_frame_is_empty() -> None:+ """A step cut short by Ctrl-C must not stay on screen with a time left."""+ console, _ = _console(terminal=False)+ progress = make_progress(console, resume_command="repowise init --resume")+ progress.upcoming = ["Analysis"]+ progress.add_task("Scoring code health…", total=100, unit="checks", detail="", cost=0.0)+ assert "Next: Analysis" in _render(progress)+ progress.start()+ progress.stop()+ assert _render(progress).strip() == ""+++# --- callback ----------------------------------------------------------------+++def test_a_finished_step_leaves_one_done_row_and_its_live_row_goes() -> None:+ console, buf = _console(terminal=False)+ with make_progress(console) as bar:+ callback = RichProgressCallback(bar, console)+ callback.on_phase_start("parse", 2)+ callback.on_item_done("parse")+ callback.on_item_done("parse")+ callback.on_phase_done("parse")+ callback.on_phase_done("parse")+ assert not [t for t in bar.tasks if t.visible]++ out = buf.getvalue()+ assert out.count("✓ Parsing files · 2 files") == 1+++def test_a_piped_run_stays_line_based() -> None:+ """No live frames, no pending hints: only the lines a log can keep."""+ console, buf = _console(terminal=False)+ with make_progress(console, resume_command="repowise init --resume") as bar:+ callback = RichProgressCallback(bar, console, total_phases=4, stage="ingestion")+ callback.on_phase_start("traverse", None)+ callback.on_item_label("traverse", "a.py")+ callback.on_phase_done("traverse")+ callback.on_phase_start("git", 5)++ out = buf.getvalue()+ assert "✓ Scanning & filtering files" in out+ assert "Next:" not in out+ assert "Safe to Ctrl-C" not in out+ assert "\x1b[" not in out+++def test_a_step_that_raises_gets_no_done_row() -> None:+ console, buf = _console(terminal=False)+ with make_progress(console) as bar:+ callback = RichProgressCallback(bar, console)+ with pytest.raises(RuntimeError), callback.step("state"):+ raise RuntimeError("disk full")+ with callback.step("views"):+ pass++ out = buf.getvalue()+ assert "Writing index state" not in out+ assert "✓ Refreshing agent views" in out+++def test_the_current_item_lands_on_the_running_row() -> None:+ console, _ = _console(terminal=False)+ bar = make_progress(console)+ callback = RichProgressCallback(bar, console)+ callback.on_phase_start("parse", 3)+ callback.on_item_label("parse", "pkg/mod.py")+ callback.on_item_label("unknown", "ignored.py")+ assert bar.tasks[0].fields["detail"] == "pkg/mod.py"+++def test_each_stage_shows_the_stages_after_it() -> None:+ assert upcoming_stages("ingestion", 4) == ["Analysis", "Generation", "Persistence"]+ assert upcoming_stages("analysis", 3) == ["Persistence"]+ assert upcoming_stages("persistence", 4) == []++ console, _ = _console(terminal=False)+ bar = make_progress(console)+ RichProgressCallback(bar, console, total_phases=4, stage="generation")+ assert bar.upcoming == ["Persistence"]+++def test_fast_mode_numbers_persistence_as_phase_three() -> None:+ console, buf = _console(terminal=False)+ print_stage(console, "persistence", 3)+ assert "Phase 3 of 3" in buf.getvalue()+ assert "Persistence" in buf.getvalue()+++def test_a_failed_step_is_hidden_without_a_done_row() -> None:+ from repowise.core.pipeline.progress import emit_phase_failed++ console, buf = _console(terminal=False)+ with make_progress(console) as bar:+ callback = RichProgressCallback(bar, console)+ callback.on_phase_start("checkpoint.index", None)+ emit_phase_failed(callback, "checkpoint.index")+ assert not [t for t in bar.tasks if t.visible]+ assert "Saving a resume checkpoint" not in buf.getvalue()+ emit_phase_failed(None, "checkpoint.index") # headless: a no-op+++def test_concurrent_graph_steps_fold_into_one_row_and_name_what_still_runs() -> None:+ """Graph metrics run several kernels at once: no per-kernel lines, one done row."""+ import asyncio+ import threading++ from repowise.core.pipeline.phases.ingestion import _run_concurrent_steps++ console, buf = _console(terminal=False)+ release = threading.Event()+ seen: list[str] = []+ with make_progress(console) as bar:+ callback = RichProgressCallback(bar, console)++ def fast() -> None:+ pass++ def slow() -> None:+ release.wait(5)++ async def run() -> None:+ job = asyncio.ensure_future(+ _run_concurrent_steps(+ "graph.metrics", [("PageRank", fast), ("symbol betweenness", slow)], callback+ )+ )+ for _ in range(200):+ await asyncio.sleep(0.01)+ if bar.tasks and bar.tasks[0].completed == 1:+ break+ seen.append(str(bar.tasks[0].fields["detail"]))+ release.set()+ await job++ asyncio.run(run())++ assert seen == ["symbol betweenness"]+ lines = [ln for ln in buf.getvalue().splitlines() if ln.strip()]+ assert len(lines) == 1+ assert lines[0].startswith(" ✓ Computing graph metrics (PageRank, betweenness) · 2 algorithms · ")+++def test_generation_done_row_counts_pages_made_including_its_paid_tier() -> None:+ """Announced totals are upper bounds (a page may gate-skip): count what was made."""+ console, buf = _console(terminal=False)+ with make_progress(console) as bar:+ callback = RichProgressCallback(bar, console)+ callback.on_phase_start("generation", 130)+ callback.on_phase_start("generation.llm", 7)+ callback.on_phase_start("onboarding", 6)+ for phase, n in (("generation", 126), ("generation.llm", 6), ("onboarding", 4)):+ for _ in range(n):+ callback.on_item_done(phase)+ for phase in ("onboarding", "generation.llm", "generation"):+ callback.on_phase_done(phase)++ lines = [ln for ln in buf.getvalue().splitlines() if ln.strip()]+ assert lines[0].startswith(" ✓ Curating onboarding docs · 4 pages")+ assert lines[1].startswith(" ✓ Writing overview and subsystem pages · 6 pages")+ assert lines[2].startswith(" ✓ Generating pages · 132 pages")diff --git a/tests/unit/cli/test_ui_package.py b/tests/unit/cli/test_ui_package.pyindex e5a73fe02..363e4999a 100644--- a/tests/unit/cli/test_ui_package.py+++ b/tests/unit/cli/test_ui_package.py@@ -38,7 +38,6 @@ def test_facade_reexports_public_surface() -> None:"print_scan_summary","print_index_only_intro","quick_repo_scan",- "print_analysis_summary","build_completion_panel","build_contextual_next_steps","build_status_notes",diff --git a/tests/unit/generation/test_run_level_cancellation.py b/tests/unit/generation/test_run_level_cancellation.pyindex 70057f53b..639583440 100644--- a/tests/unit/generation/test_run_level_cancellation.py+++ b/tests/unit/generation/test_run_level_cancellation.py@@ -51,6 +51,7 @@ def _fake_run(max_concurrency: int = 1) -> SimpleNamespace:job_id=None,on_page_done=None,on_page_ready=None,+ on_embed=None,vector_store=None,completed_page_summaries={},timings=None,diff --git a/tests/unit/generation/test_run_level_embed_gating.py b/tests/unit/generation/test_run_level_embed_gating.pyindex 982db25e1..93e48bc7d 100644--- a/tests/unit/generation/test_run_level_embed_gating.py+++ b/tests/unit/generation/test_run_level_embed_gating.py@@ -57,6 +57,7 @@ def _fake_run(store) -> SimpleNamespace:job_id=None,on_page_done=None,on_page_ready=None,+ on_embed=None,vector_store=store,completed_page_summaries={},timings=None,@@ -124,3 +125,97 @@ def test_a_failed_embed_is_counted_on_the_generator() -> None:assert gen.embed_failed_pages == 1assert warnings and "Embedding failed for 1 page(s)" in warnings[0]+++def test_each_embed_batch_is_bracketed_for_the_display() -> None:+ """Embedding is its own step on screen: start before the batch, done after."""+ calls: list[tuple[int, bool]] = []++ async def _go():+ async def fresh():+ return _page("fresh.py")++ async def other():+ return _page("other.py")++ run = _fake_run(_RecordingStore(persists=False))+ run.on_embed = lambda count, finished: calls.append((count, finished))+ await _GenerationRun.run_level(run, [("p1", fresh()), ("p2", other())], level=2)++ asyncio.run(_go())+ assert calls == [(2, False), (2, True)]+++def test_a_failed_embed_batch_is_never_reported_finished() -> None:+ calls: list[tuple[int, bool]] = []++ async def _go():+ async def fresh():+ return _page("fresh.py")++ run = _fake_run(_FailingStore())+ run.gen = SimpleNamespace(embed_failed_pages=0)+ run.on_warning = lambda _text: None+ run.on_embed = lambda count, finished: calls.append((count, finished))+ await _GenerationRun.run_level(run, [("p1", fresh())], level=2)++ asyncio.run(_go())+ assert calls == [(1, False)]+++class _Phases:+ def __init__(self) -> None:+ self.events: list[tuple] = []++ def on_phase_start(self, phase, total):+ self.events.append(("start", phase, total))++ def on_item_done(self, phase):+ self.events.append(("item", phase))++ def on_phase_done(self, phase):+ self.events.append(("done", phase))++ def on_phase_failed(self, phase):+ self.events.append(("failed", phase))+++class _Embedder:+ pass+++def _display(store):+ from repowise.core.pipeline.phases.generation import _GenerationDisplay++ progress = _Phases()+ return progress, _GenerationDisplay(progress, store, None)+++def test_embedding_shows_as_its_own_step_with_a_real_embedder() -> None:+ progress, display = _display(SimpleNamespace(_embedder=_Embedder()))+ display.on_embed(2, False)+ display.on_embed(2, True)+ display.close_embedding()+ assert progress.events == [+ ("start", "embedding", 2),+ ("item", "embedding"),+ ("item", "embedding"),+ ("done", "embedding"),+ ]+++def test_a_failed_embed_closes_the_step_without_a_done_row() -> None:+ progress, display = _display(SimpleNamespace(_embedder=_Embedder()))+ display.on_embed(3, False)+ display.close_embedding()+ assert progress.events[-1] == ("failed", "embedding")+++def test_the_keyless_embedder_gets_no_embedding_step() -> None:+ from repowise.core.providers.embedding import KeylessEmbedder++ progress, display = _display(SimpleNamespace(_embedder=KeylessEmbedder()))+ display.on_embed(2, False)+ display.on_embed(2, True)+ display.close_embedding()+ assert progress.events == []diff --git a/tests/unit/generation/test_run_level_stub_fallback.py b/tests/unit/generation/test_run_level_stub_fallback.pyindex ad024e603..473d09e75 100644--- a/tests/unit/generation/test_run_level_stub_fallback.py+++ b/tests/unit/generation/test_run_level_stub_fallback.py@@ -87,6 +87,7 @@ def _run_level() -> tuple[list[GeneratedPage], _RecordingJobSystem, _RecordingStjob_id="job-1",on_page_done=None,on_page_ready=None,+ on_embed=None,vector_store=store,completed_page_summaries={},timings=None,@@ -150,6 +151,7 @@ def test_the_streaming_sink_receives_the_sanitized_page() -> None:job_id=None,on_page_done=None,on_page_ready=lambda page: seen.append(page.content),+ on_embed=None,vector_store=_RecordingStore(),completed_page_summaries={},timings=None,diff --git a/tests/unit/pipeline/test_resume.py b/tests/unit/pipeline/test_resume.pyindex d3874fb16..84c8386be 100644--- a/tests/unit/pipeline/test_resume.py+++ b/tests/unit/pipeline/test_resume.py@@ -233,10 +233,17 @@ async def test_rehydrate_analysis_returns_empty_views_when_none_persisted(sf):class _RecordingProgress:def __init__(self) -> None:self.messages: list[tuple[str, str]] = []+ self.phases: list[tuple[str, str]] = []def on_message(self, level: str, text: str) -> None:self.messages.append((level, text))+ def on_phase_start(self, phase: str, total: int | None) -> None:+ self.phases.append(("start", phase))++ def on_phase_done(self, phase: str) -> None:+ self.phases.append(("done", phase))+async def test_a_failed_index_checkpoint_is_reported(sf, monkeypatch):"""The CLI promises "indexed work so far has been saved — run --resume".@@ -267,6 +274,8 @@ async def test_a_failed_index_checkpoint_is_reported(sf, monkeypatch):level, text = progress.messages[0]assert level == "warning"assert "database is locked" in text+ # A failed write must not leave a done row behind.+ assert ("done", "checkpoint.index") not in progress.phases# And it must not claim the index is on disk when it is not.assert await ctrl.can_skip(ResumePhase.INDEX) is False@@ -300,7 +309,7 @@ async def test_a_successful_checkpoint_says_nothing(sf, monkeypatch):async def test_index_checkpoint_is_timed(sf, monkeypatch):- """The checkpoint write runs outside every progress phase, so it times itself."""+ """The checkpoint write times itself and shows as its own step."""from repowise.core.pipeline.phase_timing import PhaseTimingRecorderrepo_id = await _make_repo(sf)@@ -320,6 +329,7 @@ async def test_index_checkpoint_is_timed(sf, monkeypatch):)assert "persist.checkpoint" in recorder.timings+ assert recorder._inner.phases == [("start", "checkpoint.index"), ("done", "checkpoint.index")]async def test_failed_symbol_analysis_reconciliation_keeps_analysis_retryable(sf, monkeypatch):