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): honor REPOWISE_MODEL environment variable in provider resolution (#2276)
Mohd Quamar Tyagi70063f75bcdd
diff --git a/packages/cli/src/repowise/cli/helpers.py b/packages/cli/src/repowise/cli/helpers.pyindex 2786d0736..55bd28ddc 100644--- a/packages/cli/src/repowise/cli/helpers.py+++ b/packages/cli/src/repowise/cli/helpers.py@@ -938,8 +938,8 @@ def resolve_provider("""Resolve a provider instance from CLI flags or environment variables.Resolution order:- 1. Explicit ``--provider`` flag- 2. ``REPOWISE_PROVIDER`` env var+ 1. Explicit ``--provider`` / ``--model`` flag+ 2. ``REPOWISE_PROVIDER`` / ``REPOWISE_MODEL`` env var3. ``.repowise/config.yaml`` (written by ``repowise init``)4. Auto-detect from API key env vars"""@@ -966,6 +966,9 @@ def resolve_provider(if provider_name is None and cfg.get("provider"):provider_name = cfg["provider"]+ if model is None:+ model = (os.environ.get("REPOWISE_MODEL") or "").strip() or None+# Honor the config model regardless of how the provider was resolved (#416).if model is None and cfg.get("model"):model = cfg["model"]diff --git a/tests/unit/cli/test_helpers.py b/tests/unit/cli/test_helpers.pyindex 41328b57d..43effce16 100644--- a/tests/unit/cli/test_helpers.py+++ b/tests/unit/cli/test_helpers.py@@ -677,6 +677,30 @@ class TestResolveProviderConfigModel:assert resolve_provider("openrouter", "anthropic/claude-opus-4", repo_path=tmp_path)assert captured["kwargs"].get("model") == "anthropic/claude-opus-4"+ def test_env_model_used_when_set(self, monkeypatch, tmp_path):+ captured = self._capture(monkeypatch, tmp_path, {})+ monkeypatch.setenv("REPOWISE_PROVIDER", "openrouter")+ monkeypatch.setenv("REPOWISE_MODEL", "anthropic/claude-sonnet-5")++ assert resolve_provider(None, None, repo_path=tmp_path) == "provider"+ assert captured["kwargs"].get("model") == "anthropic/claude-sonnet-5"++ def test_env_model_overrides_config_model(self, monkeypatch, tmp_path):+ captured = self._capture(monkeypatch, tmp_path, {"model": "google/gemini-3.1"})+ monkeypatch.setenv("REPOWISE_PROVIDER", "openrouter")+ monkeypatch.setenv("REPOWISE_MODEL", "anthropic/claude-opus-5")++ assert resolve_provider(None, None, repo_path=tmp_path) == "provider"+ assert captured["kwargs"].get("model") == "anthropic/claude-opus-5"++ def test_explicit_model_flag_overrides_env_model(self, monkeypatch, tmp_path):+ captured = self._capture(monkeypatch, tmp_path, {"model": "google/gemini-3.1"})+ monkeypatch.setenv("REPOWISE_PROVIDER", "openrouter")+ monkeypatch.setenv("REPOWISE_MODEL", "anthropic/claude-opus-5")++ assert resolve_provider("openrouter", "openai/gpt-5.6-luna", repo_path=tmp_path) == "provider"+ assert captured["kwargs"].get("model") == "openai/gpt-5.6-luna"+# ---------------------------------------------------------------------------# Update queued / pending markers — coalescing primitives that prevent the