Skip to content

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

refactor(cli): split update_cmd monolith into a package (#476)

Raghav Chamadiya9938494a17d7
diff --git a/packages/cli/src/repowise/cli/commands/update_cmd/__init__.py b/packages/cli/src/repowise/cli/commands/update_cmd/__init__.py
new file mode 100644
index 000000000..fc322f5d0
--- /dev/null
+++ b/packages/cli/src/repowise/cli/commands/update_cmd/__init__.py
@@ -0,0 +1,47 @@
+"""``repowise update`` command package.
+
+Split out of a single 1400-line module into focused submodules (mirroring
+``init_cmd``). The public ``update_command`` plus the helpers other modules and
+the test-suite import are re-exported here so ``repowise.cli.commands.update_cmd``
+remains a stable import surface.
+"""
+
+from __future__ import annotations
+
+from .command import update_command
+from .incremental import (
+ _build_filtered_changed_paths,
+ _build_repo_graph,
+ _build_update_vector_store,
+ _rebuild_graph_and_git,
+ _run_partial_analysis,
+)
+from .mode import _infer_legacy_docs_enabled, _resolve_index_only_mode
+from .persistence import (
+ _git_metadata_to_dict,
+ _persist_incremental_commits,
+ _persist_index_only_update,
+ _persist_partial_health,
+ _run_full_health_rescore,
+)
+from .reporting import _render_update_report
+from .workspace import _refresh_workspace_editor_project_files, _workspace_update
+
+__all__ = [
+ "_build_filtered_changed_paths",
+ "_build_repo_graph",
+ "_build_update_vector_store",
+ "_git_metadata_to_dict",
+ "_infer_legacy_docs_enabled",
+ "_persist_incremental_commits",
+ "_persist_index_only_update",
+ "_persist_partial_health",
+ "_rebuild_graph_and_git",
+ "_refresh_workspace_editor_project_files",
+ "_render_update_report",
+ "_resolve_index_only_mode",
+ "_run_full_health_rescore",
+ "_run_partial_analysis",
+ "_workspace_update",
+ "update_command",
+]
diff --git a/packages/cli/src/repowise/cli/commands/update_cmd.py b/packages/cli/src/repowise/cli/commands/update_cmd/command.py
similarity index 61%
rename from packages/cli/src/repowise/cli/commands/update_cmd.py
rename to packages/cli/src/repowise/cli/commands/update_cmd/command.py
index a084323c5..ffdb53f64 100644
--- a/packages/cli/src/repowise/cli/commands/update_cmd.py
+++ b/packages/cli/src/repowise/cli/commands/update_cmd/command.py
@@ -1,15 +1,19 @@
-"""``repowise update`` — incremental wiki regeneration for changed files."""
+"""``repowise update`` — incremental wiki regeneration for changed files.
+
+This module holds the Click command + single-repo orchestration. The standalone
+helpers it relies on live in sibling modules: mode resolution (:mod:`.mode`),
+core delegators (:mod:`.incremental`), persistence + re-score
+(:mod:`.persistence`), the workspace flow (:mod:`.workspace`), and report
+rendering (:mod:`.reporting`).
+"""
from __future__ import annotations
import time
-from pathlib import Path
-from typing import Any
import click
from repowise.cli.helpers import (
- CommandTarget,
acquire_update_lock,
clear_update_pending,
clear_update_queued,
@@ -32,597 +36,20 @@ from repowise.cli.helpers import (
)
from repowise.core.reasoning import REASONING_MODES
-# ---------------------------------------------------------------------------
-# Mode resolution
-# ---------------------------------------------------------------------------
-
-
-def _infer_legacy_docs_enabled(state: dict) -> bool:
- """Infer ``docs_enabled`` for state files written before the field existed.
-
- Pre-migration ``init`` only wrote ``provider`` / ``model`` to state when
- docs were generated; index-only init wrote nothing past ``last_sync_commit``.
- So absence of both fields is a reliable signal that the original run was
- index-only and we should default new updates to index-only too — this
- avoids surprising those users with a full LLM regen on first upgrade.
- Full-init users keep the old default (full mode) because their state
- has ``provider`` and ``model`` populated.
- """
- if state.get("provider") or state.get("model"):
- return True
- return False
-
-
-def _build_update_vector_store(repo_path: Any, cfg: dict) -> Any | None:
- """Build the shared page/decision vector store for the update path.
-
- Phase-2 follow-up + Phase-3 requirement: ``repowise update`` historically
- upserted decisions *without* a vector store, so semantic dedup, decision
- search visibility, and supersession detection were all off on incremental
- runs. We mirror ``init``'s store construction (LanceDB at
- ``.repowise/lancedb`` so previously-embedded decisions are matchable; the
- in-memory store is a degraded fallback that only sees this run's vectors).
- Returns ``None`` on any failure — the decision upsert still works without it.
- """
- try:
- from repowise.cli.providers import build_embedder, build_vector_store, resolve_embedder
-
- embedder = build_embedder(resolve_embedder(cfg.get("embedder")))
- return build_vector_store(repo_path, embedder)
- except Exception:
- return None
-
-
-def _resolve_index_only_mode(
- *,
- index_only: bool,
- docs_flag: bool | None,
- state: dict,
-) -> bool:
- """Decide whether this update should skip LLM regeneration.
-
- Priority: explicit ``--index-only`` flag > ``--docs/--no-docs`` >
- ``state.docs_enabled`` > inferred default from legacy state shape.
- Encapsulated as a pure function so the post-commit hook does the right
- thing without needing any extra knobs at install time.
- """
- if index_only:
- return True
- if docs_flag is False:
- return True
- if docs_flag is True:
- return False
- # No explicit override — read state, falling back to a shape-based
- # inference for state files predating the docs_enabled field.
- if "docs_enabled" in state:
- return state["docs_enabled"] is False
- return _infer_legacy_docs_enabled(state) is False
-
-
-async def _persist_partial_health(session: Any, repo_id: str, report: Any) -> None:
- """Upsert health findings + metrics for the changed-files subset.
-
- Delegates to :mod:`repowise.core.pipeline.incremental` — the logic moved
- to core so workspace updates can reuse the incremental path.
- """
- from repowise.core.pipeline.incremental import persist_partial_health
-
- await persist_partial_health(session, repo_id, report)
-
-
-async def _persist_incremental_commits(session: Any, repo_id: str, repo_path: Any) -> None:
- """Capture + upsert ``git_commits`` rows for commits new since the last index.
-
- Delegates to :mod:`repowise.core.pipeline.incremental`.
- """
- from repowise.core.pipeline.incremental import persist_incremental_commits
-
- await persist_incremental_commits(session, repo_id, repo_path)
-
-
-# ---------------------------------------------------------------------------
-# Workspace update flow
-# ---------------------------------------------------------------------------
-
-
-def _workspace_update(
- target: CommandTarget,
- *,
- dry_run: bool = False,
- agents_md: bool | None = None,
-) -> None:
- """Update stale repos in a workspace.
-
- Takes a resolved :class:`CommandTarget` so the caller has full control
- over how the workspace was located (auto-detected vs explicit flag).
- """
- from repowise.core.workspace import check_repo_staleness, update_workspace
-
- ws_root = target.ws_root
- ws_config = target.ws_config
- repo_alias = target.repo_filter
- if ws_root is None or ws_config is None:
- # Defensive: callers should always pass a workspace-mode target,
- # but guard against misuse so the error message is clear.
- raise click.ClickException("_workspace_update called without a workspace target.")
-
- # Show staleness summary first
- console.print(f"[bold]repowise update[/bold] — workspace: {ws_root.name}")
- console.print()
-
- stale_count = 0
- for entry in ws_config.repos:
- if repo_alias and entry.alias != repo_alias:
- continue
- abs_path = (ws_root / entry.path).resolve()
- stored = entry.last_commit_at_index
- is_stale, head, behind = check_repo_staleness(abs_path, stored)
- status = (
- f"[yellow]{behind} new commit(s)[/yellow]" if is_stale else "[green]up to date[/green]"
- )
- if not (abs_path / ".repowise").is_dir():
- status = "[dim]not indexed[/dim]"
- console.print(f" {entry.alias:<20} {status}")
- if is_stale:
- stale_count += 1
-
- console.print()
-
- if stale_count == 0:
- console.print("[green]All repos are up to date.[/green]")
- if not dry_run:
- _refresh_workspace_editor_project_files(
- ws_root=ws_root,
- ws_config=ws_config,
- repo_filter=repo_alias,
- agents_md=agents_md,
- )
- return
-
- if dry_run:
- console.print(f"[yellow]Dry run — {stale_count} repo(s) would be updated.[/yellow]")
- return
-
- # Run the updates
- def _on_start(alias: str) -> None:
- console.print(f" Updating [bold]{alias}[/bold]...")
-
- def _on_done(result: RepoUpdateResult) -> None:
- if result.error:
- console.print(f" [red]\u2717 {result.alias}: {result.error}[/red]")
- elif result.skipped_reason == "in_flight":
- # Surface skipped-because-in-flight as a yellow note rather than
- # a silent skip. Single-flight is the noise-fix path, so the
- # user benefits from seeing it actually trigger.
- console.print(
- f" [yellow]\u21bb {result.alias}: another update is already "
- "in flight; this commit was queued for it to pick up.[/yellow]"
- )
- elif result.updated:
- console.print(
- f" [green]\u2713[/green] {result.alias}: "
- f"{result.file_count} files, {result.symbol_count:,} symbols"
- )
-
- from repowise.core.workspace import RepoUpdateResult
-
- results = run_async(
- update_workspace(
- ws_root,
- ws_config,
- repo_filter=repo_alias,
- dry_run=False,
- on_repo_start=_on_start,
- on_repo_done=_on_done,
- )
- )
-
- # Backfill the distill rewrite-hook verdict for members that were just
- # indexed for the first time (e.g. added with --no-index) — they would
- # otherwise default to enabled despite a workspace-wide decline at init.
- from repowise.cli.commands.workspace_cmd import inherit_workspace_distill_verdict
-
- for entry in ws_config.repos:
- if repo_alias and entry.alias != repo_alias:
- continue
- inherit_workspace_distill_verdict((ws_root / entry.path).resolve())
-
- # Summary
- updated = sum(1 for r in results if r.updated)
- errors = sum(1 for r in results if r.error)
- skipped = sum(1 for r in results if r.skipped_reason)
- console.print()
- console.print(
- f"[bold]Done:[/bold] {updated} updated, {skipped} skipped"
- + (f", {errors} errors" if errors else "")
- )
- _refresh_workspace_editor_project_files(
- ws_root=ws_root,
- ws_config=ws_config,
- repo_filter=repo_alias,
- agents_md=agents_md,
- )
-
-
-def _refresh_workspace_editor_project_files(
- *,
- ws_root: Path,
- ws_config: Any,
- repo_filter: str | None,
- agents_md: bool | None,
-) -> None:
- """Refresh workspace repo editor files for explicit per-run overrides."""
-
- if agents_md is None:
- return
-
- from repowise.cli.editor_integrations.defaults import get_default_project_file_overrides
- from repowise.cli.editor_setup import EditorSetupOptions, refresh_editor_project_files
-
- options = EditorSetupOptions(
- project_file_overrides=get_default_project_file_overrides(agents_md=agents_md),
- )
- for entry in ws_config.repos:
- if repo_filter and entry.alias != repo_filter:
- continue
- repo_path = (ws_root / entry.path).resolve()
- if not (repo_path / ".repowise").is_dir():
- continue
- try:
- refresh_editor_project_files(console, repo_path, options=options)
- except Exception as exc:
- console.print(
- f" [yellow]{entry.alias}: editor project-file refresh skipped: {exc}[/yellow]"
- )
-
-
-# ---------------------------------------------------------------------------
-# Single-repo update — phase helpers (called by update_command)
-# ---------------------------------------------------------------------------
-
-
-def _build_filtered_changed_paths(file_diffs: list, exclude_patterns: list[str]) -> list[str]:
- """Extract paths from file_diffs, filtering out excluded patterns."""
- from repowise.core.pipeline.incremental import build_filtered_changed_paths
-
- return build_filtered_changed_paths(file_diffs, exclude_patterns)
-
-
-def _build_repo_graph(
- repo_path: Any,
- exclude_patterns: list[str],
- *,
- collect_sources: bool = False,
- include_submodules: bool = False,
- include_nested_repos: bool = False,
-) -> tuple[list, dict[str, bytes], Any, Any, int]:
- """Traverse + parse the repo and build the graph (+ framework-aware edges).
-
- Delegates to :mod:`repowise.core.pipeline.incremental` — the logic moved
- to core so workspace updates can reuse the incremental path. Shared by
- the incremental rebuild path (:func:`_rebuild_graph_and_git`) and the
- config-triggered re-score path (:func:`_run_full_health_rescore`).
- """
- from repowise.core.pipeline.incremental import build_repo_graph
-
- return build_repo_graph(
- repo_path,
- exclude_patterns,
- collect_sources=collect_sources,
- include_submodules=include_submodules,
- include_nested_repos=include_nested_repos,
- log=console.print,
- )
-
-
-def _rebuild_graph_and_git(
- repo_path: Any,
- file_diffs: list,
- cfg: dict,
- exclude_patterns: list[str],
- git_tier: str | None = None,
- include_submodules: bool = False,
- include_nested_repos: bool = False,
-) -> tuple[list, dict[str, bytes], Any, Any, int, dict[str, dict]]:
- """Re-traverse + parse the repo, rebuild the graph (+ framework edges), and
- re-index git metadata for the changed files.
-
- ``git_tier`` is the persisted ``state.json:git_tier`` value: a fast-mode
- (ESSENTIAL) repo must not pay per-file blame on every update for signals
- its index never had. Unknown/missing values fall back to FULL, matching
- the historical behavior for legacy state files.
-
- ``include_submodules`` / ``include_nested_repos`` are likewise read from
- state.json: a repo indexed with ``init --include-submodules`` must not
- silently drop its submodule files on every incremental update. Missing
- keys fall back to False (legacy behavior).
-
- Delegates to :mod:`repowise.core.pipeline.incremental` — the logic moved
- to core so workspace updates can reuse the incremental path.
-
- Returns ``(parsed_files, source_map, graph_builder, repo_structure,
- file_count, git_meta_map)``.
- """
- from repowise.core.pipeline.incremental import rebuild_graph_and_git
-
- return run_async(
- rebuild_graph_and_git(
- repo_path,
- file_diffs,
- cfg,
- exclude_patterns,
- git_tier=git_tier,
- include_submodules=include_submodules,
- include_nested_repos=include_nested_repos,
- log=console.print,
- )
- )
-
-
-def _run_partial_analysis(
- repo_path: Any,
- graph_builder: Any,
- git_meta_map: dict,
- parsed_files: list,
- file_diffs: list,
-) -> tuple[Any, Any]:
- """Run partial code-health + dead-code analysis for the changed files.
-
- Delegates to :mod:`repowise.core.pipeline.incremental` — the logic moved
- to core so workspace updates can reuse the incremental path.
-
- Returns ``(partial_health_report, dead_code_report)`` — either may be
- ``None`` if its analysis failed (both are best-effort).
- """
- from repowise.core.pipeline.incremental import run_partial_analysis
-
- return run_partial_analysis(
- repo_path,
- graph_builder,
- git_meta_map,
- parsed_files,
- file_diffs,
- log=console.print,
- )
-
-
-def _persist_index_only_update(
- repo_path: Any,
- graph_builder: Any,
- git_meta_map: dict,
- dead_code_report: Any,
- partial_health_report: Any,
- state: dict,
- head: str | None,
- start: float,
- changed_paths: list[str],
- file_diffs: list | None = None,
-) -> None:
- """Persist the index-only update (graph + git + dead-code + health), save
- state, and print the completion line. No LLM regeneration.
-
- DB persistence delegates to :mod:`repowise.core.pipeline.incremental`;
- state-file updates and console reporting stay here.
- """
- from repowise.core.pipeline.incremental import persist_incremental_index
-
- run_async(
- persist_incremental_index(
- repo_path,
- graph_builder,
- git_meta_map,
- dead_code_report,
- partial_health_report,
- changed_paths,
- file_diffs=file_diffs,
- log=console.print,
- )
- )
- from repowise.cli.helpers import config_fingerprint
-
- save_state(
- repo_path,
- {**state, "last_sync_commit": head, "config_fingerprint": config_fingerprint(repo_path)},
- )
- elapsed = time.monotonic() - start
- console.print(
- f"[green]Index-only update complete[/green] in {elapsed:.1f}s — "
- "graph + git + dead-code refreshed; LLM pages unchanged."
- )
-
-
-def _render_update_report(
- generated_pages: list,
- affected: Any,
- new_decision_markers: list,
- elapsed: float,
-) -> None:
- """Render the incremental-update generation report (with a plain fallback)."""
- try:
- from repowise.core.generation.report import GenerationReport, render_report
-
- report = GenerationReport.from_pages(
- generated_pages,
- stale_count=len(affected.decay_only),
- decisions_count=len(new_decision_markers),
- elapsed=elapsed,
- )
- render_report(report, console)
- except Exception:
- # Fallback to simple message if report fails
- console.print(
- f"[bold green]Updated {len(generated_pages)} pages in {elapsed:.1f}s[/bold green]"
- )
-
-
-def _git_metadata_to_dict(gm: Any) -> dict[str, Any]:
- """Convert a GitMetadata ORM row to the dict format HealthAnalyzer expects."""
- return {
- "file_path": gm.file_path,
- "commit_count_total": gm.commit_count_total,
- "commit_count_90d": gm.commit_count_90d,
- "commit_count_30d": gm.commit_count_30d,
- "first_commit_at": gm.first_commit_at,
- "last_commit_at": gm.last_commit_at,
- "primary_owner_name": gm.primary_owner_name,
- "primary_owner_email": gm.primary_owner_email,
- "primary_owner_commit_pct": gm.primary_owner_commit_pct,
- "top_authors_json": gm.top_authors_json,
- "significant_commits_json": gm.significant_commits_json,
- "co_change_partners_json": gm.co_change_partners_json,
- "commit_categories_json": gm.commit_categories_json,
- "is_hotspot": gm.is_hotspot,
- "is_stable": gm.is_stable,
- "churn_percentile": gm.churn_percentile,
- "age_days": gm.age_days,
- "commit_count_capped": gm.commit_count_capped,
- "lines_added_90d": gm.lines_added_90d,
- "lines_deleted_90d": gm.lines_deleted_90d,
- "avg_commit_size": gm.avg_commit_size,
- "recent_owner_name": gm.recent_owner_name,
- "recent_owner_commit_pct": gm.recent_owner_commit_pct,
- "bus_factor": gm.bus_factor,
- "contributor_count": gm.contributor_count,
- "original_path": gm.original_path,
- "merge_commit_count_90d": gm.merge_commit_count_90d,
- "temporal_hotspot_score": gm.temporal_hotspot_score,
- "prior_defect_count": gm.prior_defect_count,
- "change_entropy": gm.change_entropy,
- "change_entropy_pct": gm.change_entropy_pct,
- }
-
-
-def _run_full_health_rescore(
- repo_path: Any,
- exclude_patterns: list[str],
- state: dict,
- head: str | None,
- curr_fingerprint: str,
-) -> None:
- """Rebuild graph and re-run full health analysis when config changed.
-
- Uses save_health_metrics / save_health_findings (full replace, not upsert)
- so rows for newly-excluded files are removed. Loads GitMetadata from the DB
- (so biomarkers keep accurate churn/ownership/co-change data) and removes
- excluded rows both from the DB and the analyzer input.
- """
- import time
-
- start = time.monotonic()
-
- import pathspec
-
- # Share the rebuild path with the incremental update so both produce the
- # same graph (same parser, same framework-aware synthetic edges).
- parsed_files, _source_map, graph_builder, _repo_structure, _file_count = _build_repo_graph(
- repo_path,
- exclude_patterns,
- include_submodules=bool(state.get("include_submodules", False)),
- include_nested_repos=bool(state.get("include_nested_repos", False)),
- )
-
- # Fan-out metric precompute (mirrors _rebuild_graph_and_git) — the
- # rescore persists graph nodes too, which reads every metric.
- try:
- run_async(graph_builder.compute_metrics_parallel())
- except Exception:
- pass # metrics fall back to lazy computation
-
- exclude_spec = (
- pathspec.PathSpec.from_lines("gitwildmatch", exclude_patterns) if exclude_patterns else None
- )
-
- async def _rescore() -> None:
- from sqlalchemy import delete, select
-
- from repowise.cli.helpers import get_db_url_for_repo
- from repowise.core.analysis.health import HealthAnalyzer
- from repowise.core.analysis.health.config import HealthConfig
- from repowise.core.persistence import (
- create_engine,
- create_session_factory,
- get_session,
- init_db,
- upsert_repository,
- )
- from repowise.core.persistence.crud import save_health_findings, save_health_metrics
- from repowise.core.persistence.models import GitMetadata
- from repowise.core.pipeline.persist import persist_graph_nodes
-
- url = get_db_url_for_repo(repo_path)
- engine = create_engine(url)
- await init_db(engine)
- sf = create_session_factory(engine)
-
- async with get_session(sf) as session:
- repo = await upsert_repository(session, name=repo_path.name, local_path=str(repo_path))
- repo_id = repo.id
-
- gm_result = await session.execute(
- select(GitMetadata).where(GitMetadata.repository_id == repo_id)
- )
- git_rows = list(gm_result.scalars().all())
- excluded_git_paths = [
- gm.file_path
- for gm in git_rows
- if exclude_spec is not None and exclude_spec.match_file(gm.file_path)
- ]
- if excluded_git_paths:
- await session.execute(
- delete(GitMetadata).where(
- GitMetadata.repository_id == repo_id,
- GitMetadata.file_path.in_(excluded_git_paths),
- )
- )
- await session.flush()
-
- git_meta_map = {
- gm.file_path: _git_metadata_to_dict(gm)
- for gm in git_rows
- if exclude_spec is None or not exclude_spec.match_file(gm.file_path)
- }
-
- analyzer = HealthAnalyzer(
- graph_builder.graph(),
- git_meta_map=git_meta_map,
- parsed_files=parsed_files,
- duplication_cache_dir=Path(repo_path) / ".repowise",
- )
- hcfg = HealthConfig.load(repo_path)
- analyzer_config = (
- hcfg.to_analyzer_config([pf.file_info.path for pf in parsed_files])
- if (hcfg.disabled_biomarkers or hcfg.rules)
- else None
- )
- report = analyzer.analyze(analyzer_config)
-
- console.print(
- f"Health re-score: [cyan]{len(parsed_files)} files[/cyan], "
- f"[yellow]{len(report.findings)} findings[/yellow]"
- )
-
- await save_health_metrics(session, repo_id, report.metrics or [])
- await save_health_findings(session, repo_id, list(report.findings or []))
- await persist_graph_nodes(session, repo_id, graph_builder)
-
- try:
- run_async(_rescore())
- except Exception as exc:
- # Return without advancing the fingerprint so the next update retries.
- console.print(f"[yellow]Health re-score failed: {exc}[/yellow]")
- return
-
- save_state(
- repo_path,
- {**state, "last_sync_commit": head, "config_fingerprint": curr_fingerprint},
- )
- elapsed = time.monotonic() - start
- console.print(f"[green]Config-triggered health re-score complete[/green] in {elapsed:.1f}s")
-
-
-# ---------------------------------------------------------------------------
-# CLI command
-# ---------------------------------------------------------------------------
+from .incremental import (
+ _build_update_vector_store,
+ _rebuild_graph_and_git,
+ _run_partial_analysis,
+)
+from .mode import _infer_legacy_docs_enabled, _resolve_index_only_mode
+from .persistence import (
+ _persist_incremental_commits,
+ _persist_index_only_update,
+ _persist_partial_health,
+ _run_full_health_rescore,
+)
+from .reporting import _render_update_report
+from .workspace import _workspace_update
@click.command("update")
diff --git a/packages/cli/src/repowise/cli/commands/update_cmd/incremental.py b/packages/cli/src/repowise/cli/commands/update_cmd/incremental.py
new file mode 100644
index 000000000..2170d473a
--- /dev/null
+++ b/packages/cli/src/repowise/cli/commands/update_cmd/incremental.py
@@ -0,0 +1,137 @@
+"""Thin CLI delegators to :mod:`repowise.core.pipeline.incremental`.
+
+These wrap the core incremental rebuild/analysis helpers so the update flow
+(and the config-triggered re-score path) share one traverse/parse/build step,
+routing core log output through the CLI ``console``.
+"""
+
+from __future__ import annotations
+
+from typing import Any
+
+from repowise.cli.helpers import console, run_async
+
+
+def _build_update_vector_store(repo_path: Any, cfg: dict) -> Any | None:
+ """Build the shared page/decision vector store for the update path.
+
+ Phase-2 follow-up + Phase-3 requirement: ``repowise update`` historically
+ upserted decisions *without* a vector store, so semantic dedup, decision
+ search visibility, and supersession detection were all off on incremental
+ runs. We mirror ``init``'s store construction (LanceDB at
+ ``.repowise/lancedb`` so previously-embedded decisions are matchable; the
+ in-memory store is a degraded fallback that only sees this run's vectors).
+ Returns ``None`` on any failure — the decision upsert still works without it.
+ """
+ try:
+ from repowise.cli.providers import build_embedder, build_vector_store, resolve_embedder
+
+ embedder = build_embedder(resolve_embedder(cfg.get("embedder")))
+ return build_vector_store(repo_path, embedder)
+ except Exception:
+ return None
+
+
+def _build_filtered_changed_paths(file_diffs: list, exclude_patterns: list[str]) -> list[str]:
+ """Extract paths from file_diffs, filtering out excluded patterns."""
+ from repowise.core.pipeline.incremental import build_filtered_changed_paths
+
+ return build_filtered_changed_paths(file_diffs, exclude_patterns)
+
+
+def _build_repo_graph(
+ repo_path: Any,
+ exclude_patterns: list[str],
+ *,
+ collect_sources: bool = False,
+ include_submodules: bool = False,
+ include_nested_repos: bool = False,
+) -> tuple[list, dict[str, bytes], Any, Any, int]:
+ """Traverse + parse the repo and build the graph (+ framework-aware edges).
+
+ Delegates to :mod:`repowise.core.pipeline.incremental` — the logic moved
+ to core so workspace updates can reuse the incremental path. Shared by
+ the incremental rebuild path (:func:`_rebuild_graph_and_git`) and the
+ config-triggered re-score path (:func:`_run_full_health_rescore`).
+ """
+ from repowise.core.pipeline.incremental import build_repo_graph
+
+ return build_repo_graph(
+ repo_path,
+ exclude_patterns,
+ collect_sources=collect_sources,
+ include_submodules=include_submodules,
+ include_nested_repos=include_nested_repos,
+ log=console.print,
+ )
+
+
+def _rebuild_graph_and_git(
+ repo_path: Any,
+ file_diffs: list,
+ cfg: dict,
+ exclude_patterns: list[str],
+ git_tier: str | None = None,
+ include_submodules: bool = False,
+ include_nested_repos: bool = False,
+) -> tuple[list, dict[str, bytes], Any, Any, int, dict[str, dict]]:
+ """Re-traverse + parse the repo, rebuild the graph (+ framework edges), and
+ re-index git metadata for the changed files.
+
+ ``git_tier`` is the persisted ``state.json:git_tier`` value: a fast-mode
+ (ESSENTIAL) repo must not pay per-file blame on every update for signals
+ its index never had. Unknown/missing values fall back to FULL, matching
+ the historical behavior for legacy state files.
+
+ ``include_submodules`` / ``include_nested_repos`` are likewise read from
+ state.json: a repo indexed with ``init --include-submodules`` must not
+ silently drop its submodule files on every incremental update. Missing
+ keys fall back to False (legacy behavior).
+
+ Delegates to :mod:`repowise.core.pipeline.incremental` — the logic moved
+ to core so workspace updates can reuse the incremental path.
+
+ Returns ``(parsed_files, source_map, graph_builder, repo_structure,
+ file_count, git_meta_map)``.
+ """
+ from repowise.core.pipeline.incremental import rebuild_graph_and_git
+
+ return run_async(
+ rebuild_graph_and_git(
+ repo_path,
+ file_diffs,
+ cfg,
+ exclude_patterns,
+ git_tier=git_tier,
+ include_submodules=include_submodules,
+ include_nested_repos=include_nested_repos,
+ log=console.print,
+ )
+ )
+
+
+def _run_partial_analysis(
+ repo_path: Any,
+ graph_builder: Any,
+ git_meta_map: dict,
+ parsed_files: list,
+ file_diffs: list,
+) -> tuple[Any, Any]:
+ """Run partial code-health + dead-code analysis for the changed files.
+
+ Delegates to :mod:`repowise.core.pipeline.incremental` — the logic moved
+ to core so workspace updates can reuse the incremental path.
+
+ Returns ``(partial_health_report, dead_code_report)`` — either may be
+ ``None`` if its analysis failed (both are best-effort).
+ """
+ from repowise.core.pipeline.incremental import run_partial_analysis
+
+ return run_partial_analysis(
+ repo_path,
+ graph_builder,
+ git_meta_map,
+ parsed_files,
+ file_diffs,
+ log=console.print,
+ )
diff --git a/packages/cli/src/repowise/cli/commands/update_cmd/mode.py b/packages/cli/src/repowise/cli/commands/update_cmd/mode.py
new file mode 100644
index 000000000..4a0e6fa31
--- /dev/null
+++ b/packages/cli/src/repowise/cli/commands/update_cmd/mode.py
@@ -0,0 +1,45 @@
+"""``repowise update`` mode resolution — index-only vs full LLM regeneration."""
+
+from __future__ import annotations
+
+
+def _infer_legacy_docs_enabled(state: dict) -> bool:
+ """Infer ``docs_enabled`` for state files written before the field existed.
+
+ Pre-migration ``init`` only wrote ``provider`` / ``model`` to state when
+ docs were generated; index-only init wrote nothing past ``last_sync_commit``.
+ So absence of both fields is a reliable signal that the original run was
+ index-only and we should default new updates to index-only too — this
+ avoids surprising those users with a full LLM regen on first upgrade.
+ Full-init users keep the old default (full mode) because their state
+ has ``provider`` and ``model`` populated.
+ """
+ if state.get("provider") or state.get("model"):
+ return True
+ return False
+
+
+def _resolve_index_only_mode(
+ *,
+ index_only: bool,
+ docs_flag: bool | None,
+ state: dict,
+) -> bool:
+ """Decide whether this update should skip LLM regeneration.
+
+ Priority: explicit ``--index-only`` flag > ``--docs/--no-docs`` >
+ ``state.docs_enabled`` > inferred default from legacy state shape.
+ Encapsulated as a pure function so the post-commit hook does the right
+ thing without needing any extra knobs at install time.
+ """
+ if index_only:
+ return True
+ if docs_flag is False:
+ return True
+ if docs_flag is True:
+ return False
+ # No explicit override — read state, falling back to a shape-based
+ # inference for state files predating the docs_enabled field.
+ if "docs_enabled" in state:
+ return state["docs_enabled"] is False
+ return _infer_legacy_docs_enabled(state) is False
diff --git a/packages/cli/src/repowise/cli/commands/update_cmd/persistence.py b/packages/cli/src/repowise/cli/commands/update_cmd/persistence.py
new file mode 100644
index 000000000..974fde7ee
--- /dev/null
+++ b/packages/cli/src/repowise/cli/commands/update_cmd/persistence.py
@@ -0,0 +1,248 @@
+"""Persistence + health-rescore helpers for ``repowise update``.
+
+Holds the index-only persistence path, the config-triggered full health
+re-score, and the small ORM->dict adapter. DB writes delegate to
+:mod:`repowise.core.pipeline.incremental` / ``repowise.core.persistence``;
+state-file updates and console reporting stay here.
+"""
+
+from __future__ import annotations
+
+import time
+from pathlib import Path
+from typing import Any
+
+from repowise.cli.helpers import console, run_async, save_state
+
+from .incremental import _build_repo_graph
+
+
+async def _persist_partial_health(session: Any, repo_id: str, report: Any) -> None:
+ """Upsert health findings + metrics for the changed-files subset.
+
+ Delegates to :mod:`repowise.core.pipeline.incremental` — the logic moved
+ to core so workspace updates can reuse the incremental path.
+ """
+ from repowise.core.pipeline.incremental import persist_partial_health
+
+ await persist_partial_health(session, repo_id, report)
+
+
+async def _persist_incremental_commits(session: Any, repo_id: str, repo_path: Any) -> None:
+ """Capture + upsert ``git_commits`` rows for commits new since the last index.
+
+ Delegates to :mod:`repowise.core.pipeline.incremental`.
+ """
+ from repowise.core.pipeline.incremental import persist_incremental_commits
+
+ await persist_incremental_commits(session, repo_id, repo_path)
+
+
+def _persist_index_only_update(
+ repo_path: Any,
+ graph_builder: Any,
+ git_meta_map: dict,
+ dead_code_report: Any,
+ partial_health_report: Any,
+ state: dict,
+ head: str | None,
+ start: float,
+ changed_paths: list[str],
+ file_diffs: list | None = None,
+) -> None:
+ """Persist the index-only update (graph + git + dead-code + health), save
+ state, and print the completion line. No LLM regeneration.
+
+ DB persistence delegates to :mod:`repowise.core.pipeline.incremental`;
+ state-file updates and console reporting stay here.
+ """
+ from repowise.core.pipeline.incremental import persist_incremental_index
+
+ run_async(
+ persist_incremental_index(
+ repo_path,
+ graph_builder,
+ git_meta_map,
+ dead_code_report,
+ partial_health_report,
+ changed_paths,
+ file_diffs=file_diffs,
+ log=console.print,
+ )
+ )
+ from repowise.cli.helpers import config_fingerprint
+
+ save_state(
+ repo_path,
+ {**state, "last_sync_commit": head, "config_fingerprint": config_fingerprint(repo_path)},
+ )
+ elapsed = time.monotonic() - start
+ console.print(
+ f"[green]Index-only update complete[/green] in {elapsed:.1f}s — "
+ "graph + git + dead-code refreshed; LLM pages unchanged."
+ )
+
+
+def _git_metadata_to_dict(gm: Any) -> dict[str, Any]:
+ """Convert a GitMetadata ORM row to the dict format HealthAnalyzer expects."""
+ return {
+ "file_path": gm.file_path,
+ "commit_count_total": gm.commit_count_total,
+ "commit_count_90d": gm.commit_count_90d,
+ "commit_count_30d": gm.commit_count_30d,
+ "first_commit_at": gm.first_commit_at,
+ "last_commit_at": gm.last_commit_at,
+ "primary_owner_name": gm.primary_owner_name,
+ "primary_owner_email": gm.primary_owner_email,
+ "primary_owner_commit_pct": gm.primary_owner_commit_pct,
+ "top_authors_json": gm.top_authors_json,
+ "significant_commits_json": gm.significant_commits_json,
+ "co_change_partners_json": gm.co_change_partners_json,
+ "commit_categories_json": gm.commit_categories_json,
+ "is_hotspot": gm.is_hotspot,
+ "is_stable": gm.is_stable,
+ "churn_percentile": gm.churn_percentile,
+ "age_days": gm.age_days,
+ "commit_count_capped": gm.commit_count_capped,
+ "lines_added_90d": gm.lines_added_90d,
+ "lines_deleted_90d": gm.lines_deleted_90d,
+ "avg_commit_size": gm.avg_commit_size,
+ "recent_owner_name": gm.recent_owner_name,
+ "recent_owner_commit_pct": gm.recent_owner_commit_pct,
+ "bus_factor": gm.bus_factor,
+ "contributor_count": gm.contributor_count,
+ "original_path": gm.original_path,
+ "merge_commit_count_90d": gm.merge_commit_count_90d,
+ "temporal_hotspot_score": gm.temporal_hotspot_score,
+ "prior_defect_count": gm.prior_defect_count,
+ "change_entropy": gm.change_entropy,
+ "change_entropy_pct": gm.change_entropy_pct,
+ }
+
+
+def _run_full_health_rescore(
+ repo_path: Any,
+ exclude_patterns: list[str],
+ state: dict,
+ head: str | None,
+ curr_fingerprint: str,
+) -> None:
+ """Rebuild graph and re-run full health analysis when config changed.
+
+ Uses save_health_metrics / save_health_findings (full replace, not upsert)
+ so rows for newly-excluded files are removed. Loads GitMetadata from the DB
+ (so biomarkers keep accurate churn/ownership/co-change data) and removes
+ excluded rows both from the DB and the analyzer input.
+ """
+ import time
+
+ start = time.monotonic()
+
+ import pathspec
+
+ # Share the rebuild path with the incremental update so both produce the
+ # same graph (same parser, same framework-aware synthetic edges).
+ parsed_files, _source_map, graph_builder, _repo_structure, _file_count = _build_repo_graph(
+ repo_path,
+ exclude_patterns,
+ include_submodules=bool(state.get("include_submodules", False)),
+ include_nested_repos=bool(state.get("include_nested_repos", False)),
+ )
+
+ # Fan-out metric precompute (mirrors _rebuild_graph_and_git) — the
+ # rescore persists graph nodes too, which reads every metric.
+ try:
+ run_async(graph_builder.compute_metrics_parallel())
+ except Exception:
+ pass # metrics fall back to lazy computation
+
+ exclude_spec = (
+ pathspec.PathSpec.from_lines("gitwildmatch", exclude_patterns) if exclude_patterns else None
+ )
+
+ async def _rescore() -> None:
+ from sqlalchemy import delete, select
+
+ from repowise.cli.helpers import get_db_url_for_repo
+ from repowise.core.analysis.health import HealthAnalyzer
+ from repowise.core.analysis.health.config import HealthConfig
+ from repowise.core.persistence import (
+ create_engine,
+ create_session_factory,
+ get_session,
+ init_db,
+ upsert_repository,
+ )
+ from repowise.core.persistence.crud import save_health_findings, save_health_metrics
+ from repowise.core.persistence.models import GitMetadata
+ from repowise.core.pipeline.persist import persist_graph_nodes
+
+ url = get_db_url_for_repo(repo_path)
+ engine = create_engine(url)
+ await init_db(engine)
+ sf = create_session_factory(engine)
+
+ async with get_session(sf) as session:
+ repo = await upsert_repository(session, name=repo_path.name, local_path=str(repo_path))
+ repo_id = repo.id
+
+ gm_result = await session.execute(
+ select(GitMetadata).where(GitMetadata.repository_id == repo_id)
+ )
+ git_rows = list(gm_result.scalars().all())
+ excluded_git_paths = [
+ gm.file_path
+ for gm in git_rows
+ if exclude_spec is not None and exclude_spec.match_file(gm.file_path)
+ ]
+ if excluded_git_paths:
+ await session.execute(
+ delete(GitMetadata).where(
+ GitMetadata.repository_id == repo_id,
+ GitMetadata.file_path.in_(excluded_git_paths),
+ )
+ )
+ await session.flush()
+
+ git_meta_map = {
+ gm.file_path: _git_metadata_to_dict(gm)
+ for gm in git_rows
+ if exclude_spec is None or not exclude_spec.match_file(gm.file_path)
+ }
+
+ analyzer = HealthAnalyzer(
+ graph_builder.graph(),
+ git_meta_map=git_meta_map,
+ parsed_files=parsed_files,
+ duplication_cache_dir=Path(repo_path) / ".repowise",
+ )
+ hcfg = HealthConfig.load(repo_path)
+ analyzer_config = (
+ hcfg.to_analyzer_config([pf.file_info.path for pf in parsed_files])
+ if (hcfg.disabled_biomarkers or hcfg.rules)
+ else None
+ )
+ report = analyzer.analyze(analyzer_config)
+
+ console.print(
+ f"Health re-score: [cyan]{len(parsed_files)} files[/cyan], "
+ f"[yellow]{len(report.findings)} findings[/yellow]"
+ )
+
+ await save_health_metrics(session, repo_id, report.metrics or [])
+ await save_health_findings(session, repo_id, list(report.findings or []))
+ await persist_graph_nodes(session, repo_id, graph_builder)
+
+ try:
+ run_async(_rescore())
+ except Exception as exc:
+ # Return without advancing the fingerprint so the next update retries.
+ console.print(f"[yellow]Health re-score failed: {exc}[/yellow]")
+ return
+
+ save_state(
+ repo_path,
+ {**state, "last_sync_commit": head, "config_fingerprint": curr_fingerprint},
+ )
+ elapsed = time.monotonic() - start
+ console.print(f"[green]Config-triggered health re-score complete[/green] in {elapsed:.1f}s")
diff --git a/packages/cli/src/repowise/cli/commands/update_cmd/reporting.py b/packages/cli/src/repowise/cli/commands/update_cmd/reporting.py
new file mode 100644
index 000000000..5f4929683
--- /dev/null
+++ b/packages/cli/src/repowise/cli/commands/update_cmd/reporting.py
@@ -0,0 +1,36 @@
+"""Console rendering for ``repowise update``.
+
+Pure presentation: takes finished generation data and prints the incremental
+update report. No persistence or generation work happens here. The richer
+panel/summary helpers added in the UX pass land here next to this report.
+"""
+
+from __future__ import annotations
+
+from typing import Any
+
+from repowise.cli.helpers import console
+
+
+def _render_update_report(
+ generated_pages: list,
+ affected: Any,
+ new_decision_markers: list,
+ elapsed: float,
+) -> None:
+ """Render the incremental-update generation report (with a plain fallback)."""
+ try:
+ from repowise.core.generation.report import GenerationReport, render_report
+
+ report = GenerationReport.from_pages(
+ generated_pages,
+ stale_count=len(affected.decay_only),
+ decisions_count=len(new_decision_markers),
+ elapsed=elapsed,
+ )
+ render_report(report, console)
+ except Exception:
+ # Fallback to simple message if report fails
+ console.print(
+ f"[bold green]Updated {len(generated_pages)} pages in {elapsed:.1f}s[/bold green]"
+ )
diff --git a/packages/cli/src/repowise/cli/commands/update_cmd/workspace.py b/packages/cli/src/repowise/cli/commands/update_cmd/workspace.py
new file mode 100644
index 000000000..7b5aa2059
--- /dev/null
+++ b/packages/cli/src/repowise/cli/commands/update_cmd/workspace.py
@@ -0,0 +1,161 @@
+"""``repowise update`` workspace flow \u2014 update stale repos in a workspace."""
+
+from __future__ import annotations
+
+from pathlib import Path
+from typing import Any
+
+import click
+
+from repowise.cli.helpers import CommandTarget, console, run_async
+
+
+def _workspace_update(
+ target: CommandTarget,
+ *,
+ dry_run: bool = False,
+ agents_md: bool | None = None,
+) -> None:
+ """Update stale repos in a workspace.
+
+ Takes a resolved :class:`CommandTarget` so the caller has full control
+ over how the workspace was located (auto-detected vs explicit flag).
+ """
+ from repowise.core.workspace import check_repo_staleness, update_workspace
+
+ ws_root = target.ws_root
+ ws_config = target.ws_config
+ repo_alias = target.repo_filter
+ if ws_root is None or ws_config is None:
+ # Defensive: callers should always pass a workspace-mode target,
+ # but guard against misuse so the error message is clear.
+ raise click.ClickException("_workspace_update called without a workspace target.")
+
+ # Show staleness summary first
+ console.print(f"[bold]repowise update[/bold] \u2014 workspace: {ws_root.name}")
+ console.print()
+
+ stale_count = 0
+ for entry in ws_config.repos:
+ if repo_alias and entry.alias != repo_alias:
+ continue
+ abs_path = (ws_root / entry.path).resolve()
+ stored = entry.last_commit_at_index
+ is_stale, head, behind = check_repo_staleness(abs_path, stored)
+ status = (
+ f"[yellow]{behind} new commit(s)[/yellow]" if is_stale else "[green]up to date[/green]"
+ )
+ if not (abs_path / ".repowise").is_dir():
+ status = "[dim]not indexed[/dim]"
+ console.print(f" {entry.alias:<20} {status}")
+ if is_stale:
+ stale_count += 1
+
+ console.print()
+
+ if stale_count == 0:
+ console.print("[green]All repos are up to date.[/green]")
+ if not dry_run:
+ _refresh_workspace_editor_project_files(
+ ws_root=ws_root,
+ ws_config=ws_config,
+ repo_filter=repo_alias,
+ agents_md=agents_md,
+ )
+ return
+
+ if dry_run:
+ console.print(f"[yellow]Dry run \u2014 {stale_count} repo(s) would be updated.[/yellow]")
+ return
+
+ # Run the updates
+ def _on_start(alias: str) -> None:
+ console.print(f" Updating [bold]{alias}[/bold]...")
+
+ def _on_done(result: RepoUpdateResult) -> None:
+ if result.error:
+ console.print(f" [red]\u2717 {result.alias}: {result.error}[/red]")
+ elif result.skipped_reason == "in_flight":
+ # Surface skipped-because-in-flight as a yellow note rather than
+ # a silent skip. Single-flight is the noise-fix path, so the
+ # user benefits from seeing it actually trigger.
+ console.print(
+ f" [yellow]\u21bb {result.alias}: another update is already "
+ "in flight; this commit was queued for it to pick up.[/yellow]"
+ )
+ elif result.updated:
+ console.print(
+ f" [green]\u2713[/green] {result.alias}: "
+ f"{result.file_count} files, {result.symbol_count:,} symbols"
+ )
+
+ from repowise.core.workspace import RepoUpdateResult
+
+ results = run_async(
+ update_workspace(
+ ws_root,
+ ws_config,
+ repo_filter=repo_alias,
+ dry_run=False,
+ on_repo_start=_on_start,
+ on_repo_done=_on_done,
+ )
+ )
+
+ # Backfill the distill rewrite-hook verdict for members that were just
+ # indexed for the first time (e.g. added with --no-index) \u2014 they would
+ # otherwise default to enabled despite a workspace-wide decline at init.
+ from repowise.cli.commands.workspace_cmd import inherit_workspace_distill_verdict
+
+ for entry in ws_config.repos:
+ if repo_alias and entry.alias != repo_alias:
+ continue
+ inherit_workspace_distill_verdict((ws_root / entry.path).resolve())
+
+ # Summary
+ updated = sum(1 for r in results if r.updated)
+ errors = sum(1 for r in results if r.error)
+ skipped = sum(1 for r in results if r.skipped_reason)
+ console.print()
+ console.print(
+ f"[bold]Done:[/bold] {updated} updated, {skipped} skipped"
+ + (f", {errors} errors" if errors else "")
+ )
+ _refresh_workspace_editor_project_files(
+ ws_root=ws_root,
+ ws_config=ws_config,
+ repo_filter=repo_alias,
+ agents_md=agents_md,
+ )
+
+
+def _refresh_workspace_editor_project_files(
+ *,
+ ws_root: Path,
+ ws_config: Any,
+ repo_filter: str | None,
+ agents_md: bool | None,
+) -> None:
+ """Refresh workspace repo editor files for explicit per-run overrides."""
+
+ if agents_md is None:
+ return
+
+ from repowise.cli.editor_integrations.defaults import get_default_project_file_overrides
+ from repowise.cli.editor_setup import EditorSetupOptions, refresh_editor_project_files
+
+ options = EditorSetupOptions(
+ project_file_overrides=get_default_project_file_overrides(agents_md=agents_md),
+ )
+ for entry in ws_config.repos:
+ if repo_filter and entry.alias != repo_filter:
+ continue
+ repo_path = (ws_root / entry.path).resolve()
+ if not (repo_path / ".repowise").is_dir():
+ continue
+ try:
+ refresh_editor_project_files(console, repo_path, options=options)
+ except Exception as exc:
+ console.print(
+ f" [yellow]{entry.alias}: editor project-file refresh skipped: {exc}[/yellow]"
+ )
diff --git a/tests/unit/cli/test_commands.py b/tests/unit/cli/test_commands.py
index 1e3dd3665..a45a7590f 100644
--- a/tests/unit/cli/test_commands.py
+++ b/tests/unit/cli/test_commands.py
@@ -221,7 +221,9 @@ class TestRescoreFailureFingerprint:
coro.close() # avoid 'coroutine never awaited' warning
raise RuntimeError("db down")
- monkeypatch.setattr(update_cmd, "run_async", _boom)
+ # _run_full_health_rescore now lives in update_cmd.persistence, which
+ # is where it looks up run_async — patch the name there.
+ monkeypatch.setattr(update_cmd.persistence, "run_async", _boom)
(tmp_path / "f.py").write_text("x = 1\n", encoding="utf-8")
update_cmd._run_full_health_rescore(
@@ -260,7 +262,9 @@ class TestBuildRepoGraph:
def print(self, *args, **kwargs):
printed.append(" ".join(str(a) for a in args))
- monkeypatch.setattr(update_cmd, "console", _FakeConsole())
+ # _build_repo_graph now lives in update_cmd.incremental, which is where
+ # it looks up console — patch the name there.
+ monkeypatch.setattr(update_cmd.incremental, "console", _FakeConsole())
parsed_files, _src, _gb, _struct, _count = update_cmd._build_repo_graph(tmp_path, [])
diff --git a/tests/unit/cli/test_workspace_autodetect_e2e.py b/tests/unit/cli/test_workspace_autodetect_e2e.py
index 15d198e99..9e49e6eec 100644
--- a/tests/unit/cli/test_workspace_autodetect_e2e.py
+++ b/tests/unit/cli/test_workspace_autodetect_e2e.py
@@ -58,7 +58,7 @@ def test_update_from_workspace_root_does_not_create_stray_repowise(
called["agents_md"] = agents_md
monkeypatch.setattr(
- "repowise.cli.commands.update_cmd._workspace_update",
+ "repowise.cli.commands.update_cmd.command._workspace_update",
_fake_workspace_update,
)
@@ -82,7 +82,7 @@ def test_update_from_child_repo_stays_single(tmp_path: Path, monkeypatch):
called["workspace"] = True
monkeypatch.setattr(
- "repowise.cli.commands.update_cmd._workspace_update",
+ "repowise.cli.commands.update_cmd.command._workspace_update",
_fake_workspace_update,
)
@@ -91,7 +91,7 @@ def test_update_from_child_repo_stays_single(tmp_path: Path, monkeypatch):
# the heavy imports by making get_head_commit return the same SHA so
# the "Already up to date" branch fires.
monkeypatch.setattr(
- "repowise.cli.commands.update_cmd.get_head_commit",
+ "repowise.cli.commands.update_cmd.command.get_head_commit",
lambda _p: "abc123",
)