Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ Adding a new language has a dedicated recipe, see
- Add tests for new features and bug fixes
- Place tests in `tests/unit/` or `tests/integration/`
- Run the full suite with `uv run pytest`
- A test asserting on a `caplog` record needs `caplog.set_level(logging.INFO, logger="<the module's full logger name>")` (or the level you're asserting on) — setting the root logger's level is not enough when an ancestor logger (e.g. `repowise.core`, `repowise.server`) has its own level raised, since Python resolves the *effective* level from the nearest ancestor that has one set, not from root.

## Pull Request Guidelines

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/repowise/cli/commands/_tool_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def run(repo_path: Path, factory: Callable[[], Awaitable[dict]], tool_name: str)
from repowise.cli.helpers import silence_logs_for_machine_output
from repowise.cli.tool_bridge import call_tool

silence_logs_for_machine_output()
return call_tool(repo_path, factory, tool_name)
with silence_logs_for_machine_output():
return call_tool(repo_path, factory, tool_name)


#: MCP tool name -> the CLI command that now does the same thing.
Expand Down
386 changes: 193 additions & 193 deletions packages/cli/src/repowise/cli/commands/dead_code_cmd.py

Large diffs are not rendered by default.

166 changes: 83 additions & 83 deletions packages/cli/src/repowise/cli/commands/doctor_cmd/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import contextlib
import json

import click
Expand Down Expand Up @@ -61,96 +62,95 @@ def doctor_command(
"--repair is not supported with --format json (json mode is read-only)."
)

if fmt != "table":
silence_logs_for_machine_output()
silencer = silence_logs_for_machine_output() if fmt != "table" else contextlib.nullcontext()
with silencer:
status = err_console if fmt != "table" else console

status = err_console if fmt != "table" else console

target = resolve_command_target(
path=path,
workspace_flag=workspace,
no_workspace_flag=no_workspace,
)
target.notice(status, command="doctor")
target = resolve_command_target(
path=path,
workspace_flag=workspace,
no_workspace_flag=no_workspace,
)
target.notice(status, command="doctor")

if fmt == "table":
# Advisory CLI update check, printed once above the repo check table(s).
_print_cli_version_status()
if fmt == "table":
# Advisory CLI update check, printed once above the repo check table(s).
_print_cli_version_status()

if not target.is_workspace:
assert target.repo_path is not None
all_ok, checks = _run_repo_checks(target.repo_path, repair, fmt=fmt)
if fmt != "table":
payload = {"ok": all_ok, "checks": [c._asdict() for c in checks]}
click.echo(json.dumps(payload, indent=2))
if not all_ok:
raise SystemExit(1)
return

# Workspace mode — iterate over every entry, run workspace-level
# validation, and report a summary table at the end so the user knows
# which repos need attention.
assert target.ws_root is not None and target.ws_config is not None
ws_root = target.ws_root
ws_config = target.ws_config

ws_issues = _run_workspace_checks(ws_root, ws_config, repair=repair, fmt=fmt)

overall_ok = True
not_indexed: list[str] = []
all_checks: list[DoctorCheck] = []
for entry in ws_config.repos:
abs_path = (ws_root / entry.path).resolve()
if not abs_path.is_dir():
continue
if not (abs_path / ".repowise").is_dir():
not_indexed.append(entry.alias)
continue
if fmt == "table":
console.print()
console.print(
f"[bold]── {entry.alias}[/bold] "
f"[dim]({entry.path})[/dim]"
+ (
" [bold cyan](primary)[/bold cyan]"
if entry.alias == ws_config.default_repo
else ""
)
)
ok, checks = _run_repo_checks(abs_path, repair, fmt=fmt)
overall_ok = overall_ok and ok
all_checks.extend(DoctorCheck(f"{entry.alias}: {c.name}", c.ok, c.detail) for c in checks)

if not target.is_workspace:
assert target.repo_path is not None
all_ok, checks = _run_repo_checks(target.repo_path, repair, fmt=fmt)
if fmt != "table":
payload = {"ok": all_ok, "checks": [c._asdict() for c in checks]}
all_ok = overall_ok and not ws_issues and not not_indexed
payload = {
"ok": all_ok,
"checks": [c._asdict() for c in all_checks],
"workspace": {
"checked": True,
"issues": list(ws_issues),
"not_indexed": not_indexed,
},
}
click.echo(json.dumps(payload, indent=2))
if not all_ok:
raise SystemExit(1)
return

# Workspace mode — iterate over every entry, run workspace-level
# validation, and report a summary table at the end so the user knows
# which repos need attention.
assert target.ws_root is not None and target.ws_config is not None
ws_root = target.ws_root
ws_config = target.ws_config

ws_issues = _run_workspace_checks(ws_root, ws_config, repair=repair, fmt=fmt)

overall_ok = True
not_indexed: list[str] = []
all_checks: list[DoctorCheck] = []
for entry in ws_config.repos:
abs_path = (ws_root / entry.path).resolve()
if not abs_path.is_dir():
continue
if not (abs_path / ".repowise").is_dir():
not_indexed.append(entry.alias)
continue
if fmt == "table":
console.print()
return

console.print()
if not_indexed:
console.print(f"[yellow]Not indexed:[/yellow] {', '.join(not_indexed)}")
console.print(" Run [bold]repowise update --workspace[/bold] to index them.")
if ws_issues and not repair:
console.print(
f"[bold]── {entry.alias}[/bold] "
f"[dim]({entry.path})[/dim]"
+ (
" [bold cyan](primary)[/bold cyan]"
if entry.alias == ws_config.default_repo
else ""
)
f"[yellow]{len(ws_issues)} workspace-level issue(s); "
f"rerun with [bold]--repair[/bold] to attempt fixes.[/yellow]"
)
ok, checks = _run_repo_checks(abs_path, repair, fmt=fmt)
overall_ok = overall_ok and ok
all_checks.extend(DoctorCheck(f"{entry.alias}: {c.name}", c.ok, c.detail) for c in checks)

if fmt != "table":
all_ok = overall_ok and not ws_issues and not not_indexed
payload = {
"ok": all_ok,
"checks": [c._asdict() for c in all_checks],
"workspace": {
"checked": True,
"issues": list(ws_issues),
"not_indexed": not_indexed,
},
}
click.echo(json.dumps(payload, indent=2))
if not all_ok:
raise SystemExit(1)
return

console.print()
if not_indexed:
console.print(f"[yellow]Not indexed:[/yellow] {', '.join(not_indexed)}")
console.print(" Run [bold]repowise update --workspace[/bold] to index them.")
if ws_issues and not repair:
console.print(
f"[yellow]{len(ws_issues)} workspace-level issue(s); "
f"rerun with [bold]--repair[/bold] to attempt fixes.[/yellow]"
)

workspace_clean = not ws_issues and overall_ok and not not_indexed
if workspace_clean:
console.print("[bold green]Workspace healthy.[/bold green]")
elif overall_ok and not ws_issues:
console.print("[bold yellow]All indexed repos healthy; some repos unindexed.[/bold yellow]")
else:
console.print("[bold yellow]Some checks failed across the workspace.[/bold yellow]")
workspace_clean = not ws_issues and overall_ok and not not_indexed
if workspace_clean:
console.print("[bold green]Workspace healthy.[/bold green]")
elif overall_ok and not ws_issues:
console.print("[bold yellow]All indexed repos healthy; some repos unindexed.[/bold yellow]")
else:
console.print("[bold yellow]Some checks failed across the workspace.[/bold yellow]")
Loading
Loading