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(init): --no-prose makes no model calls, even with an API key set (#4239)
Raghav Chamadiya75a006cf24d0
diff --git a/docs/reference/CLI_REFERENCE.md b/docs/reference/CLI_REFERENCE.mdindex 7d60eb6f6..52011afc2 100644--- a/docs/reference/CLI_REFERENCE.md+++ b/docs/reference/CLI_REFERENCE.md@@ -159,7 +159,7 @@ All three reach the indexing knobs; the LLM-only knobs appear only when model-wr| `--provider` | LLM provider: `anthropic`, `openai`, `openrouter`, `gemini`, `deepseek`, `kimi`, `ollama`, `litellm`, `codex_cli`, `opencode`, `edenai`, `mock` || `--model` | Model name override (e.g., `claude-sonnet-4-6`) || `--embedder` | Embedder for semantic search: `gemini`, `openai`, `openrouter`, `ollama`, `edenai`, `mock` (default: auto-detect) |-| `--prose` / `--no-prose` | The single knob over LLM spend. The file, symbol, cycle (SCC), API and infra pages are rendered from structure either way, with no key and no cost. The model-written set is the subsystem (concept) tree plus the repo overview, the architecture diagram, and the onboarding collection: `--prose` writes those as model prose and needs a key; `--no-prose` leaves them as structural stubs, so the whole wiki is keyless and free. Default: prose when a key is available. Full-text search works either way; semantic search needs an embedder. Fill or refill that prose later with [`repowise generate`](#repowise-generate-path). |+| `--prose` / `--no-prose` | The single knob over LLM spend. The file, symbol, cycle (SCC), API and infra pages are rendered from structure either way, with no key and no cost. The model-written set is the subsystem (concept) tree plus the repo overview, the architecture diagram, and the onboarding collection: `--prose` writes those as model prose and needs a key; `--no-prose` leaves them as structural stubs, so the whole wiki is keyless and free. Default: prose when a key is available. Full-text search works either way; semantic search needs an embedder. `--no-prose` makes no model calls even when a key is set, so decision extraction from PRs, commit history and comments waits for a model run. Fill or refill that prose, and add those decisions, later with [`repowise generate`](#repowise-generate-path). || `--index-only` | Deprecated hidden alias for `--no-prose`. || `--docs` | Deprecated hidden alias: `--docs llm` == `--prose`, `--docs deterministic` == `--no-prose`. Prefer `--prose` / `--no-prose`. || `--mode` | Pipeline depth: `standard` (default) or `fast` (graph + essential-git only, no per-file blame/co-change, no LLM docs, for very large repos; upgrade later with `update --full`) |diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/_ingest.py b/packages/cli/src/repowise/cli/commands/init_cmd/_ingest.pyindex 183a413ef..c1fd2c2c7 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/_ingest.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/_ingest.py@@ -21,6 +21,19 @@ from ._options import InitRunfrom .persistence import build_resume_controller+def structural_generation_config(index_only: bool) -> Any:+ """A deterministic config for a structural run, so the pipeline knows no model was chosen.++ The pipeline generates no pages here (the CLI renders them afterwards); the+ config only tells decision reporting why the model-only sources did not run.+ """+ if not index_only:+ return None+ from repowise.core.generation.models import GenerationConfig++ return GenerationConfig(deterministic=True)++def _index_vector_store(run: InitRun) -> Any:"""Generation's vector store, built early so analysis can dedup decisions against it.@@ -100,6 +113,7 @@ async def _index_with_resume(),# Only local init describes the user's own environment.derive_environment_facts=True,+ generation_config=structural_generation_config(opts.index_only),)finally:if engine is not None:@@ -112,9 +126,8 @@ def index_repository(run: InitRun) -> bool:# Fast mode skips generation, so it has three phases.run.total_phases = 3 if opts.run_mode == "fast" else 4# None on a dry run: analysis would call it before generation's dry-run exit.- llm_client = None- if not opts.dry_run:- llm_client = run.provider if not opts.index_only else run.decision_provider+ # A structural run never resolved one (see ``_resolve_provider_stage``).+ llm_client = None if opts.dry_run else run.providerfrom repowise.core.pipeline import PhaseTimingRecorder, run_pipelinefrom repowise.core.pipeline.modes import OrchestratorModediff --git a/packages/cli/src/repowise/cli/commands/init_cmd/_options.py b/packages/cli/src/repowise/cli/commands/init_cmd/_options.pyindex 8ac650914..1b8c48ab3 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/_options.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/_options.py@@ -90,7 +90,6 @@ class InitRun:prior_docs_mode: str | None = Nonefirst_index: bool = Falseprovider: Any = None- decision_provider: Any = None# Set when a full run found no provider at all and fell back to the# template renderer. Treated exactly like ``--index-only`` from the# generation phase onward.diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/_prepare.py b/packages/cli/src/repowise/cli/commands/init_cmd/_prepare.pyindex 23cdd30bb..26d5e149d 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/_prepare.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/_prepare.py@@ -26,7 +26,6 @@ from repowise.cli.helpers import (load_config,load_state,resolve_max_file_pages,- resolve_provider,resolve_reasoning,)from repowise.cli.providers import resolve_embedder@@ -36,7 +35,7 @@ from repowise.core.docs_mode import resolve_docs_modefrom repowise.core.generation.styles import resolve_stylefrom ._options import InitOptions, InitRun-from ._provider import announce_index_only, decision_key_in_env, resolve_docs_provider+from ._provider import announce_index_only, resolve_docs_providerfrom ._questions import _ask_questionsfrom .persistence import effective_run_mode_for_resume@@ -189,20 +188,19 @@ def _confirm_wiki_overwrite(run: InitRun) -> bool:return True-def _resolve_decision_provider(run: InitRun) -> None:- """Index-only: a decision-extraction provider when one is named or keyed."""- opts = run.opts- try:- if opts.provider_name or decision_key_in_env():- run.decision_provider = resolve_provider(opts.provider_name, opts.model, run.repo_path)- except Exception:- pass--def _resolve_provider_stage(run: InitRun) -> None:- """Which model this run calls: none, a decision extractor, or the docs model."""+ """Which model this run calls: none for a structural run, else the docs model.++ The one gate for ``--no-prose`` (and ``--mode fast``): no provider is+ resolved, so nothing later in the run can call a model, whatever keys the+ environment or stored config holds.+ """if run.opts.index_only:- _resolve_decision_provider(run)+ if run.opts.provider_name:+ console.print(+ f"[dim]--provider {run.opts.provider_name} is not used: this run "+ "builds from code and makes no model calls.[/dim]"+ )announce_index_only(run)else:resolve_docs_provider(run)diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/_provider.py b/packages/cli/src/repowise/cli/commands/init_cmd/_provider.pyindex e51a56660..879cb0366 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/_provider.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/_provider.py@@ -2,7 +2,6 @@from __future__ import annotations-import osimport sysfrom typing import Any@@ -15,32 +14,14 @@ from repowise.cli.ui import OK, OWL_SPINNER, VALUE, WARN, print_index_only_introfrom ._options import InitRun-# Keys whose presence lets an index-only run pick a decision-extraction-# provider without a --provider flag.-_DECISION_KEY_VARS = (- "GEMINI_API_KEY",- "GOOGLE_API_KEY",- "OPENAI_API_KEY",- "ANTHROPIC_API_KEY",-)---def decision_key_in_env() -> bool:- """Whether the environment holds a key a decision provider can use."""- return any(os.environ.get(k) for k in _DECISION_KEY_VARS)-def announce_index_only(run: InitRun) -> None:"""Tell the user this run builds the wiki from structure."""if run.is_interactive:- print_index_only_intro(console, has_provider=run.decision_provider is not None)+ print_index_only_intro(console)returnconsole.print(f"[bold]repowise index-only[/bold] — {run.repo_path}")console.print("Building the wiki from structure [dim]— no model, no spend.[/dim]")- if run.decision_provider:- console.print(- f"Decision extraction provider: [{VALUE}]{run.decision_provider.provider_name}[/]"- )def _resolve_or_fall_back(run: InitRun) -> None:diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/_questions.py b/packages/cli/src/repowise/cli/commands/init_cmd/_questions.pyindex 9334ac9fc..b450229fe 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/_questions.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/_questions.py@@ -66,11 +66,7 @@ def _ask_mode(run: InitRun) -> None:def _ask_provider(run: InitRun) -> None:- """Provider selection, only when docs will be generated.-- Index-only runs auto-detect a decision-extraction provider later without- prompting.- """+ """Provider selection, only when docs will be generated."""opts = run.optsselection = interactive_provider_config_select(console,diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/command.py b/packages/cli/src/repowise/cli/commands/init_cmd/command.pyindex 5aa1a7734..7ce234916 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/command.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/command.py@@ -47,7 +47,6 @@ from ._prepare import (_editor_options,_interactive_gate,_prepare_single_repo,- _resolve_decision_provider,_resolve_provider_stage,_resolve_settings,_start_run,@@ -77,7 +76,6 @@ __all__ = ["_prepare_single_repo","_print_structural_plan","_render_template_wiki",- "_resolve_decision_provider","_resolve_provider_stage","_resolve_settings","_run_deterministic_generation_phase",@@ -196,10 +194,11 @@ def _run_workspace_init(opts: InitOptions, scan: Any) -> None:default=None,help=("Write the subsystem (concept) pages as model prose (needs a key), or "- "render the whole wiki from structure with no model and no spend. Every "- "other page is structural either way. Default: prose when a key is "- "available. With --no-prose, an explicit --provider or API key still "- "enables model-based decision extraction. Use --mode fast for no wiki at all."+ "render the whole wiki from structure. Every other page is structural "+ "either way. Default: prose when a key is available. --no-prose makes no "+ "model calls, whatever keys are set: it skips the written subsystem pages "+ "and model decision extraction from PRs, commit history and code comments. "+ "Run repowise generate later to add both. Use --mode fast for no wiki at all."),)@click.option(diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/workspace.py b/packages/cli/src/repowise/cli/commands/init_cmd/workspace.pyindex 4b3d5e664..6579d9bce 100644--- a/packages/cli/src/repowise/cli/commands/init_cmd/workspace.py+++ b/packages/cli/src/repowise/cli/commands/init_cmd/workspace.py@@ -68,6 +68,7 @@ from repowise.cli.ui import (from repowise.core.docs_mode import docs_mode_state_fieldsfrom repowise.core.generation.styles import DEFAULT_STYLE+from ._ingest import structural_generation_configfrom ._interactive import offer_distill_rewrite_hook, offer_hook_installfrom .generation import (CostGateDeclined,@@ -439,6 +440,7 @@ def _index_repo(repo: Any, ctx: _WorkspaceCtx, repo_provider: Any) -> _RepoIndexprogress=callback,existing_kg_fingerprint=_prev_kg_fp,derive_environment_facts=True,+ generation_config=structural_generation_config(ctx.index_only),))console.print(f" [{OK}]✓[/] {result.file_count:,} files, {result.symbol_count:,} symbols")diff --git a/packages/cli/src/repowise/cli/ui/mode_selection.py b/packages/cli/src/repowise/cli/ui/mode_selection.pyindex c9eace500..19b0fe239 100644--- a/packages/cli/src/repowise/cli/ui/mode_selection.py+++ b/packages/cli/src/repowise/cli/ui/mode_selection.py@@ -665,7 +665,7 @@ def _resolve_embedder_from_env() -> str:return global_config_embedder() or "mock"-def print_index_only_intro(console: Console, has_provider: bool = False) -> None:+def print_index_only_intro(console: Console) -> None:"""Show what index-only mode will do before starting.A forecast, so no border — nothing here is a thing to act on, and it used to@@ -680,21 +680,18 @@ def print_index_only_intro(console: Console, has_provider: bool = False) -> None" [dim]•[/dim] Build dependency graph (PageRank, communities)"," [dim]•[/dim] Index git history (hotspots, ownership, co-changes)"," [dim]•[/dim] Detect dead code",- " [dim]•[/dim] Extract architectural decisions",+ " [dim]•[/dim] Extract architectural decisions without a model"," [dim]•[/dim] Render the wiki from structure: file, module, layer and"," cycle pages, the architecture diagram, the repo overview, API and"," infra pages, and the onboarding collection"," [dim]•[/dim] Set up MCP server for AI assistants",]- if has_provider:- lines.append(- " [dim]•[/dim] [dim]Decision extraction enhanced (provider key detected)[/dim]"- )for line in lines:console.print(line)console.print()console.print(- " [dim]The subsystem pages read as stubs. Add a key and run "- "[bold]repowise generate[/bold] to write them as prose.[/dim]"+ " [dim]The subsystem pages read as stubs, and decisions from PRs, commit "+ "history and comments wait for a model. Add a key and run "+ "[bold]repowise generate[/bold] to add both.[/dim]")console.print()diff --git a/packages/core/src/repowise/core/pipeline/_run/analysis.py b/packages/core/src/repowise/core/pipeline/_run/analysis.pyindex 695d1a331..0f7de0b0f 100644--- a/packages/core/src/repowise/core/pipeline/_run/analysis.py+++ b/packages/core/src/repowise/core/pipeline/_run/analysis.py@@ -16,6 +16,7 @@ from repowise.core.pipeline.phases._common import (_phase_done,limit_to_top_pagerank,)+from repowise.core.pipeline.phases.analysis import STRUCTURAL_RUN_REASONfrom repowise.core.pipeline.progress import STAGE_ANALYSIS, emit_stagefrom repowise.core.pipeline.resume import ResumePhase@@ -71,6 +72,12 @@ async def _rehydrate_analysis(run: PipelineRun) -> bool:return True+def _no_model_reason(run: PipelineRun) -> str | None:+ """Why a deterministic run has no model, for its skipped decision sources."""+ config = run.generation_config+ return STRUCTURAL_RUN_REASON if config is not None and config.deterministic else None++async def _backfill_decisions(run: PipelineRun) -> None:"""Run decision extraction alone when a resumed analysis never finished it."""if run.progress:@@ -86,6 +93,7 @@ async def _backfill_decisions(run: PipelineRun) -> None:parsed_files=run.parsed_files,source_map=run.source_map,progress=run.progress,+ no_model_reason=_no_model_reason(run),)if run.decision_report is not None:run.gen_decision_report = run.decision_report@@ -131,6 +139,7 @@ async def _compute_analysis(run: PipelineRun) -> None:parsed_files=run.parsed_files,source_map=run.source_map,progress=progress,+ no_model_reason=_no_model_reason(run),),_orch._run_doc_drift_analysis(run.source_map,diff --git a/packages/core/src/repowise/core/pipeline/phases/analysis.py b/packages/core/src/repowise/core/pipeline/phases/analysis.pyindex 968a61ad5..860a6ce77 100644--- a/packages/core/src/repowise/core/pipeline/phases/analysis.py+++ b/packages/core/src/repowise/core/pipeline/phases/analysis.py@@ -24,6 +24,10 @@ from repowise.core.pipeline.progress import ProgressCallbackfrom ._common import _phase_done+# Shown for the model-only decision sources of a deterministic run, which may+# well have a key configured.+STRUCTURAL_RUN_REASON = "this run builds from code; repowise generate adds them"+logger = structlog.get_logger(__name__)@@ -382,8 +386,13 @@ async def _run_decision_extraction(parsed_files: list[Any],source_map: dict[str, bytes] | None = None,progress: ProgressCallback | None,+ no_model_reason: str | None = None,) -> Any | None:- """Extract architectural decisions from source and git history."""+ """Extract architectural decisions from source and git history.++ *no_model_reason* replaces the no-provider reason when the caller chose a+ run without a model rather than having none configured.+ """try:from repowise.core.analysis.decision_extractor import DecisionExtractorfrom repowise.core.analysis.decisions.policy import resolve_policy@@ -442,6 +451,7 @@ async def _run_decision_extraction(enabled=enabled,discovery=discovery,provider_available=llm_client is not None,+ no_model_reason=no_model_reason,)_phase_done(progress, "decisions")@@ -500,6 +510,7 @@ def _report_decision_sources(enabled: Any,discovery: DiscoveryOutcome,provider_available: bool,+ no_model_reason: str | None = None,) -> None:"""Say per source what was found, found nothing, failed, or never ran.@@ -511,7 +522,9 @@ def _report_decision_sources(failures = dict(getattr(report, "failures", {}) or {})if discovery.report.status == "failed":failures["session_discovery"] = discovery.report.reason- runtime, not_run = _decision_sources_not_run(policy, discovery, provider_available)+ runtime, not_run = _decision_sources_not_run(+ policy, discovery, provider_available, no_model_reason+ )# ``session`` is mined outside the extractor, so it is never listed as empty.considered = set(enabled) | {DISCOVERY_SOURCE}# A grounded candidate is a finding even before a second sighting promotes it.@@ -576,14 +589,20 @@ def _decision_headline(report: Any) -> str:def _decision_sources_not_run(- policy: Any, discovery: DiscoveryOutcome, provider_available: bool+ policy: Any,+ discovery: DiscoveryOutcome,+ provider_available: bool,+ no_model_reason: str | None = None,) -> tuple[dict[str, Any], set[str]]:"""Runtime status per source and the togglable sources that never ran.Broad discovery is always considered; its own reason overrides the policy'sas the more specific one."""- runtime = {rt.key: rt for rt in policy.runtime(provider_available=provider_available)}+ runtime = {+ rt.key: _with_no_model_reason(rt, no_model_reason)+ for rt in policy.runtime(provider_available=provider_available)+ }not_run = {keyfor key, rt in runtime.items()@@ -591,8 +610,14 @@ def _decision_sources_not_run(}if discovery.report.status in ("not_run", "skipped_no_provider"):not_run.add(DISCOVERY_SOURCE)- if discovery.report.reason:- runtime[DISCOVERY_SOURCE] = replace(- runtime[DISCOVERY_SOURCE], reason=discovery.report.reason- )+ discovery_reason = _with_no_model_reason(discovery.report, no_model_reason).reason+ if discovery_reason:+ runtime[DISCOVERY_SOURCE] = replace(runtime[DISCOVERY_SOURCE], reason=discovery_reason)return runtime, not_run+++def _with_no_model_reason(status: Any, no_model_reason: str | None) -> Any:+ """*status* with *no_model_reason* when no model was chosen rather than missing."""+ if no_model_reason and status.status == "skipped_no_provider":+ return replace(status, reason=no_model_reason)+ return statusdiff --git a/tests/unit/cli/test_commands.py b/tests/unit/cli/test_commands.pyindex 621180868..80a4e8bf5 100644--- a/tests/unit/cli/test_commands.py+++ b/tests/unit/cli/test_commands.py@@ -309,7 +309,7 @@ class TestInitYesFlag:side_effect=_fake_prompt_wiki_style,),patch(- "repowise.cli.commands.init_cmd._prepare.resolve_provider",+ "repowise.cli.commands.init_cmd._prepare._resolve_provider_stage",side_effect=Exception("stop early"),),):@@ -344,7 +344,7 @@ class TestInitYesFlag:),# Stop before the real pipeline runs.patch(- "repowise.cli.commands.init_cmd._prepare.resolve_provider",+ "repowise.cli.commands.init_cmd._prepare._resolve_provider_stage",side_effect=Exception("stop early"),),):diff --git a/tests/unit/cli/test_init_noninteractive.py b/tests/unit/cli/test_init_noninteractive.pyindex 635f6fd17..90fc17df4 100644--- a/tests/unit/cli/test_init_noninteractive.py+++ b/tests/unit/cli/test_init_noninteractive.py@@ -230,41 +230,34 @@ class TestProseFlag:assert result.exit_code == 0, result.output@pytest.mark.parametrize(- "flags", [["--no-prose"], ["--index-only"], ["--docs", "deterministic"]]+ "flags",+ [+ ["--no-prose"],+ ["--no-prose", "--provider", "openai"],+ ["--index-only"],+ ["--docs", "deterministic"],+ ],)- def test_scripted_structural_init_does_not_auto_detect_a_decision_provider(+ def test_no_prose_never_builds_a_provider_with_keys_set(self, runner, tmp_path, keyless_env, monkeypatch, flags):+ """`--no-prose` means zero model calls, whatever keys or flags are present."""from unittest.mock import Mock- resolver = Mock(return_value=None)- monkeypatch.setattr(- "repowise.cli.commands.init_cmd._prepare.resolve_provider", resolver- )+ monkeypatch.setenv("OPENAI_API_KEY", "sk-dummy-openai")+ monkeypatch.setenv("ANTHROPIC_API_KEY", "sk-ant-dummy")+ factory = Mock(side_effect=AssertionError("a --no-prose run built an LLM provider"))+ for module in (+ "repowise.core.providers",+ "repowise.core.providers.llm",+ "repowise.core.providers.llm.registry",+ ):+ monkeypatch.setattr(f"{module}.get_provider", factory)result = runner.invoke(cli, ["init", str(tmp_path), *flags, "--yes"])assert result.exit_code == 0, result.output- resolver.assert_not_called()-- @pytest.mark.parametrize("opt_in", ["provider", "key"])- def test_structural_init_preserves_explicit_decision_provider_opt_in(- self, runner, tmp_path, keyless_env, monkeypatch, opt_in- ):- from unittest.mock import Mock-- resolver = Mock(return_value=None)- monkeypatch.setattr(- "repowise.cli.commands.init_cmd._prepare.resolve_provider", resolver- )- flags = ["--provider", "openai"] if opt_in == "provider" else []- if opt_in == "key":- monkeypatch.setenv("OPENAI_API_KEY", "test-key")- result = runner.invoke(- cli, ["init", str(tmp_path), "--no-prose", "--yes", *flags]- )- assert result.exit_code == 0, result.output- resolver.assert_called_once_with(- "openai" if opt_in == "provider" else None, None, tmp_path- )+ factory.assert_not_called()+ assert "No LLM provider is configured" not in result.output+ assert "this run builds from code" in result.outputdef test_index_only_prints_deprecation(self, runner, tmp_path, keyless_env):"""The deprecated alias still works and says so."""diff --git a/tests/unit/pipeline/test_decision_source_reporting.py b/tests/unit/pipeline/test_decision_source_reporting.pyindex 632dca1dc..0715fac13 100644--- a/tests/unit/pipeline/test_decision_source_reporting.py+++ b/tests/unit/pipeline/test_decision_source_reporting.py@@ -129,6 +129,25 @@ async def test_a_source_that_never_ran_is_not_an_honest_zero(_patched):assert "git history" in not_runassert "No LLM provider" in not_run++async def test_a_structural_run_says_why_instead_of_no_provider(_patched):+ """A run that chose no model must not claim none is configured."""+ progress = _RecordingProgress()++ await _run_decision_extraction(+ _patched,+ llm_client=None,+ graph_builder=SimpleNamespace(graph=lambda: None),+ git_meta_map={},+ parsed_files=[],+ progress=progress,+ no_model_reason="this run builds from code",+ )++ not_run = next(t for lvl, t in progress.messages if lvl == "info" and "Not run" in t)+ assert "pull requests (this run builds from code)" in not_run+ assert "No LLM provider" not in not_run+nothing = [t for lvl, t in progress.messages if lvl == "info" and "Nothing found" in t]for line in nothing:assert "pull requests" not in line