Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(cli): skip every agent CLI sign-in probe while network checks are off (#4706)
Raghav Chamadiyae9e5698ac321
diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/_provider.py b/packages/cli/src/repowise/cli/commands/init_cmd/_provider.pyindex 4705be644..f8f849fb7 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/_provider.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/_provider.py@@ -99,10 +99,6 @@ def note_subscription_cli(run: InitRun) -> None:def _wants_subscription_note(run: InitRun) -> bool:"""A scripted run nobody picked a provider for, and no model writes."""- from repowise.core.platform.telemetry import network_disabled-- if network_disabled(): # the probe spawns third-party CLIs that phone home- return Falsechosen = run.is_interactive or run.opts.provider_name or run.config.get("provider")return not chosen and bool(run.opts.index_only or run.no_provider)diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/reporting.py b/packages/cli/src/repowise/cli/commands/init_cmd/reporting.pyindex ec073d7c2..80894670d 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/reporting.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/reporting.py@@ -322,10 +322,6 @@ def _model_upgrade(repo_path: Path) -> ModelUpgrade:def _signed_in_agent() -> tuple[str, str] | None:"""``(provider id, source line)`` for the first signed-in agent CLI worth offering."""- from repowise.core.platform.telemetry import network_disabled-- if network_disabled(): # the probe spawns third-party CLIs that phone home- return Nonefrom repowise.cli.ui.subscription import logged_in_agent_providersfrom repowise.core.agents.identity import identity_for_providerdiff --git a/packages/cli/src/repowise/cli/ui/plan_screen/state.py b/packages/cli/src/repowise/cli/ui/plan_screen/state.pyindex b04f15235..85ca84de1 100644--- a/packages/cli/src/repowise/cli/ui/plan_screen/state.py+++ b/packages/cli/src/repowise/cli/ui/plan_screen/state.py@@ -152,9 +152,12 @@ def build_offer(detected: dict[str, str], prefer: tuple[str, ...], shape: RunSha"""from repowise.core.providers.llm.specs import PROVIDER_SPECS- if not detected:+ # An agent CLI whose sign-in was not confirmed (offer=False) stays pickable+ # by hand but is never the default this line names.+ names = [p for p, how in detected.items() if getattr(how, "offer", True)]+ if not names:return ModelOffer()- name = next((p for p in prefer if p in detected), next(iter(detected)))+ name = next((p for p in prefer if p in names), names[0])runtime = "openai" if name == "openai_compatible" else namespec = PROVIDER_SPECS.get(runtime)model = spec.default_model if spec is not None else ""diff --git a/packages/cli/src/repowise/cli/ui/subscription.py b/packages/cli/src/repowise/cli/ui/subscription.pyindex 6d85a855e..badc8a535 100644--- a/packages/cli/src/repowise/cli/ui/subscription.py+++ b/packages/cli/src/repowise/cli/ui/subscription.py@@ -18,6 +18,7 @@ from concurrent.futures import ThreadPoolExecutorfrom dataclasses import dataclassfrom repowise.core.agents.identity import CLAUDE_CODE, CODEX, OPENCODE, identity_for_provider+from repowise.core.platform.telemetry import network_disabledfrom repowise.core.providers.llm.specs import PROVIDER_SPECS#: Agent-CLI providers, in picker order.@@ -145,6 +146,10 @@ def agent_cli_auth(name: str) -> CliAuth | None:probe = _AUTH_PROBES.get(agent.slug)if probe is None:return None+ if network_disabled():+ # The probe runs a third-party CLI that may phone home. Installed stays+ # pickable by hand, but is never recommended on an unchecked sign-in.+ return CliAuth("sign-in not checked while network checks are off", offer=False)args, parse = probetry:# DEVNULL: an inherited Windows console stdin can block until the timeout.diff --git a/tests/unit/cli/test_init_finish_findings.py b/tests/unit/cli/test_init_finish_findings.pyindex f1a12f1e2..9101b894b 100644--- a/tests/unit/cli/test_init_finish_findings.py+++ b/tests/unit/cli/test_init_finish_findings.py@@ -128,8 +128,11 @@ def test_a_signed_in_cli_comes_first(monkeypatch, tmp_path):def test_no_cli_is_probed_with_the_network_off(monkeypatch, tmp_path, var):monkeypatch.setenv(var, "1")monkeypatch.setattr(- "repowise.cli.ui.subscription.logged_in_agent_providers",- lambda: pytest.fail("probed an agent CLI"),+ "repowise.core.agents.identity.AgentIdentity.which", lambda self: self.executable+ )+ monkeypatch.setattr(+ "repowise.cli.ui.subscription.subprocess.run",+ lambda *a, **k: pytest.fail("probed an agent CLI"),)monkeypatch.setattr(reporting, "_keyed_provider", lambda _repo: None)assert reporting._model_upgrade(tmp_path) == ModelUpgrade("repowise generate")diff --git a/tests/unit/cli/test_init_plan_screen.py b/tests/unit/cli/test_init_plan_screen.pyindex 0d1ac559d..45c98cf06 100644--- a/tests/unit/cli/test_init_plan_screen.py+++ b/tests/unit/cli/test_init_plan_screen.py@@ -28,7 +28,7 @@ from repowise.cli.ui.plan_screen import (render_plan,)from repowise.cli.ui.repo_scanner import RepoScanInfo-from repowise.cli.ui.subscription import SubscriptionContext+from repowise.cli.ui.subscription import CliAuth, SubscriptionContext_SCAN = RepoScanInfo(total_files=50, language_counts={"Python": 30}, total_commits=400)_OUTSIDE = ("Global repowise MCP entry (Claude Code) now points at /old, will point here: /new",)@@ -84,6 +84,15 @@ def test_a_logged_in_claude_code_is_offered_with_quota_and_time(monkeypatch: Anyassert "$0.00" not in out+def test_an_unconfirmed_agent_cli_is_never_the_offered_default() -> None:+ unchecked = CliAuth("sign-in not checked", offer=False)+ assert build_offer({"claude_cli": unchecked}, ("claude_cli",), RunShape(_SCAN)).price is None+ offer = build_offer(+ {"claude_cli": unchecked, "openai": "OPENAI_API_KEY"}, ("claude_cli",), RunShape(_SCAN)+ )+ assert offer.price is not None and offer.price.provider == "openai"++def test_a_chosen_model_changes_the_plan_and_the_m_key() -> None:offer = build_offer({"openai": "OPENAI_API_KEY"}, (), RunShape(_SCAN))assert offer.price is not Nonediff --git a/tests/unit/cli/test_subscription_providers.py b/tests/unit/cli/test_subscription_providers.pyindex 3837a0622..3dbbfc35f 100644--- a/tests/unit/cli/test_subscription_providers.py+++ b/tests/unit/cli/test_subscription_providers.py@@ -184,12 +184,30 @@ def test_note_spawns_no_agent_cli_when_network_is_off(monkeypatch: Any, var: strdef _boom(*args: Any, **kwargs: Any) -> None:raise AssertionError("agent CLI probed with an off switch set")- monkeypatch.setattr(subscription, "logged_in_agent_providers", _boom)monkeypatch.setattr(subscription.subprocess, "run", _boom)monkeypatch.setenv(var, "1")assert _note(monkeypatch, _run()) == ""[email protected]("var", ["REPOWISE_OFFLINE", "DO_NOT_TRACK", "REPOWISE_TELEMETRY_DISABLED"])+def test_every_probe_caller_spawns_no_agent_cli_when_network_is_off(+ monkeypatch: Any, var: str+) -> None:+ from repowise.core.agents.identity import AgentIdentity++ def _boom(*args: Any, **kwargs: Any) -> None:+ raise AssertionError("agent CLI probed with an off switch set")++ monkeypatch.setattr(AgentIdentity, "which", lambda self: self.executable)+ monkeypatch.setattr(subscription.subprocess, "run", _boom)+ monkeypatch.setenv(var, "1")+ found = subscription.logged_in_agent_providers()+ # Installed CLIs stay pickable by hand, but nothing offers them unchecked.+ assert "claude_cli" in found+ assert not [auth for auth in found.values() if auth.offer]+ assert subscription.ready_agent_providers() == ()++def test_note_is_quiet_without_a_logged_in_cli(monkeypatch: Any) -> None:_logged_in(monkeypatch)assert _note(monkeypatch, _run()) == ""