Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(progress): clean up init progress rendering (#151)
Raghav Chamadiya055f91b32fd1
diff --git a/packages/cli/src/repowise/cli/ui.py b/packages/cli/src/repowise/cli/ui.pyindex 2d42ac918..7c25db73d 100644--- a/packages/cli/src/repowise/cli/ui.py+++ b/packages/cli/src/repowise/cli/ui.py@@ -1187,11 +1187,25 @@ class RichProgressCallback:style = style_map.get(level, "")# Insight lines (indented with →) get special formattingif text.lstrip().startswith("→"):- self._progress.console.print(f" [dim]{text}[/dim]")+ line = f" [dim]{text}[/dim]"elif style:- self._progress.console.print(f" [{style}]{text}[/{style}]")+ line = f" [{style}]{text}[/{style}]"else:- self._progress.console.print(f" {text}")+ line = f" {text}"++ # Print under the Live lock so the line lands cleanly above the+ # progress region instead of interleaving with still-rendering+ # spinners (issue: phase summary lines interleaved with bars).+ live = getattr(self._progress, "live", None)+ if live is not None:+ try:+ with live._lock:+ self._progress.console.print(line)+ self._progress.refresh()+ return+ except Exception:+ pass+ self._progress.console.print(line)def set_cost(self, total_cost: float) -> None:"""Update the live cost display on all active progress tasks."""diff --git a/packages/core/src/repowise/core/analysis/dead_code/analyzer.py b/packages/core/src/repowise/core/analysis/dead_code/analyzer.pyindex 908d06bae..89021af8f 100644--- a/packages/core/src/repowise/core/analysis/dead_code/analyzer.py+++ b/packages/core/src/repowise/core/analysis/dead_code/analyzer.py@@ -64,8 +64,19 @@ class DeadCodeAnalyzer:parsed_files or {}) | find_dynamic_edge_files(graph)- def analyze(self, config: dict | None = None) -> DeadCodeReport:- """Full analysis. Returns report with all findings."""+ def analyze(+ self,+ config: dict | None = None,+ *,+ on_step: Any | None = None,+ ) -> DeadCodeReport:+ """Full analysis. Returns report with all findings.++ *on_step* is an optional callable invoked with a stage name after+ each detector finishes (``unreachable_files``, ``unused_exports``,+ ``unused_internals``, ``zombie_packages``). Used by the CLI to+ advance per-stage progress; safe to pass ``None``.+ """cfg = config or {}findings: list[DeadCodeFindingData] = []@@ -74,15 +85,23 @@ class DeadCodeAnalyzer:if cfg.get("detect_unreachable_files", True):findings.extend(self._detect_unreachable_files(dynamic_patterns, whitelist))+ if on_step:+ on_step("unreachable_files")if cfg.get("detect_unused_exports", True):findings.extend(self._detect_unused_exports(dynamic_patterns, whitelist))+ if on_step:+ on_step("unused_exports")if cfg.get("detect_unused_internals", True):findings.extend(self._detect_unused_internals(dynamic_patterns, whitelist))+ if on_step:+ on_step("unused_internals")if cfg.get("detect_zombie_packages", True):findings.extend(self._detect_zombie_packages(whitelist))+ if on_step:+ on_step("zombie_packages")min_conf = cfg.get("min_confidence", 0.4)findings = [f for f in findings if f.confidence >= min_conf]diff --git a/packages/core/src/repowise/core/analysis/decision_extractor.py b/packages/core/src/repowise/core/analysis/decision_extractor.pyindex 2148c8cc3..75809f673 100644--- a/packages/core/src/repowise/core/analysis/decision_extractor.py+++ b/packages/core/src/repowise/core/analysis/decision_extractor.py@@ -722,8 +722,15 @@ class DecisionExtractor:# Main entry point# ------------------------------------------------------------------- async def extract_all(self) -> DecisionExtractionReport:- """Run all capture sources in parallel. LLM failures are caught per-source."""+ async def extract_all(+ self, *, on_step: Any | None = None+ ) -> DecisionExtractionReport:+ """Run all capture sources in parallel. LLM failures are caught per-source.++ *on_step* is an optional callable invoked with the source name as+ each sub-extractor finishes (``inline_marker``, ``git_archaeology``,+ ``readme_mining``). Used by the CLI to surface per-source progress.+ """async def _safe_inline() -> list[ExtractedDecision]:try:@@ -734,6 +741,9 @@ class DecisionExtractor:except Exception as exc:logger.warning("decision_extractor.inline_markers_failed", error=str(exc))return []+ finally:+ if on_step:+ on_step("inline_marker")async def _safe_git() -> list[ExtractedDecision]:try:@@ -744,6 +754,9 @@ class DecisionExtractor:except Exception as exc:logger.warning("decision_extractor.git_archaeology_failed", error=str(exc))return []+ finally:+ if on_step:+ on_step("git_archaeology")async def _safe_readme() -> list[ExtractedDecision]:try:@@ -754,6 +767,9 @@ class DecisionExtractor:except Exception as exc:logger.warning("decision_extractor.readme_mining_failed", error=str(exc))return []+ finally:+ if on_step:+ on_step("readme_mining")logger.info("decision_extractor.extract_all_start")inline, git_decisions, readme_decisions = await asyncio.gather(diff --git a/packages/core/src/repowise/core/pipeline/orchestrator.py b/packages/core/src/repowise/core/pipeline/orchestrator.pyindex f2f5c83df..10f0b5ce6 100644--- a/packages/core/src/repowise/core/pipeline/orchestrator.py+++ b/packages/core/src/repowise/core/pipeline/orchestrator.py@@ -667,13 +667,21 @@ async def _run_dead_code_analysis(try:from repowise.core.analysis.dead_code import DeadCodeAnalyzer+ # Four detectors run sequentially inside analyze(); drive a+ # determinate bar so users see progress instead of "0".+ _DEAD_CODE_STEPS = 4if progress:- progress.on_phase_start("dead_code", None)+ progress.on_phase_start("dead_code", _DEAD_CODE_STEPS)analyzer = DeadCodeAnalyzer(graph_builder.graph(), git_meta_map, parsed_files=graph_builder._parsed_files)- report = analyzer.analyze()++ def _step(_stage: str) -> None:+ if progress:+ progress.on_item_done("dead_code")++ report = await asyncio.to_thread(analyzer.analyze, None, on_step=_step)if progress:unreachable = sum(1 for f in report.findings if f.kind.value == "unreachable_file")@@ -706,8 +714,11 @@ async def _run_decision_extraction(try:from repowise.core.analysis.decision_extractor import DecisionExtractor+ # Three sources run concurrently inside extract_all(); drive a+ # determinate bar so users see live progress.+ _DECISION_STEPS = 3if progress:- progress.on_phase_start("decisions", None)+ progress.on_phase_start("decisions", _DECISION_STEPS)extractor = DecisionExtractor(repo_path=repo_path,@@ -716,8 +727,14 @@ async def _run_decision_extraction(git_meta_map=git_meta_map,parsed_files=parsed_files,)++ def _decision_step(_source: str) -> None:+ if progress:+ progress.on_item_done("decisions")+report = await asyncio.wait_for(- extractor.extract_all(), timeout=DECISION_EXTRACTION_TIMEOUT_SECS+ extractor.extract_all(on_step=_decision_step),+ timeout=DECISION_EXTRACTION_TIMEOUT_SECS,)if progress: