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.

fix(init): --resume skips the interactive questionnaire (#2106)

Nehal kanak kuniyil thottathilcdb2155af268
diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/command.py b/packages/cli/src/repowise/cli/commands/init_cmd/command.py
index fb3ecce61..b45730304 100644
--- a/packages/cli/src/repowise/cli/commands/init_cmd/command.py
+++ b/packages/cli/src/repowise/cli/commands/init_cmd/command.py
@@ -465,6 +465,25 @@ def _run_generation_phase(
# ---------------------------------------------------------------------------
+def _interactive_gate(
+ *,
+ isatty: bool,
+ provider_name: str | None,
+ index_only: bool,
+ yes: bool,
+ resume: bool,
+) -> bool:
+ """Whether the interactive questionnaire runs.
+
+ Interactive requires a TTY, no explicit provider, docs on, and neither
+ --yes nor --resume. --resume skips the gate because the prior run
+ already answered every question and those answers are on disk
+ (config.yaml); re-asking would let a resumed run diverge from the pages
+ already written with them (issue #2098).
+ """
+ return isatty and provider_name is None and not index_only and not yes and not resume
+
+
@click.command("init")
@click.argument("path", required=False, default=None)
@click.option(
@@ -1024,7 +1043,23 @@ def init_command(
# ---- Interactive mode (TTY, no explicit flags) ----
# --yes forces non-interactive even on a TTY (mirrors the workspace path),
# so a scripted `init -y` never blocks on the mode-selection menu.
- is_interactive = sys.stdin.isatty() and provider_name is None and not index_only and not yes
+ # --resume skips the gate too: the prior run already answered every
+ # question, and those answers are on disk (config.yaml), so re-asking
+ # would let a resumed run diverge from the pages already written with
+ # them (issue #2098).
+ is_interactive = _interactive_gate(
+ isatty=sys.stdin.isatty(),
+ provider_name=provider_name,
+ index_only=index_only,
+ yes=yes,
+ resume=resume,
+ )
+
+ if resume:
+ console.print(
+ f"[bold]Resuming[/] the previous run in {repo_path}, "
+ "reusing the answers it already saved to config.yaml."
+ )
# Output language picked in the advanced-mode generation section; None
# until chosen. Resolved below: flag > this > config.yaml > English.
diff --git a/tests/unit/cli/test_init_noninteractive.py b/tests/unit/cli/test_init_noninteractive.py
index a89d63768..5105c6c80 100644
--- a/tests/unit/cli/test_init_noninteractive.py
+++ b/tests/unit/cli/test_init_noninteractive.py
@@ -17,10 +17,46 @@ from click.testing import CliRunner
from repowise.cli import cost_gate
from repowise.cli.commands.init_cmd._interactive import offer_hook_install
+from repowise.cli.commands.init_cmd.command import _interactive_gate
from repowise.cli.helpers import NO_SAVE_KEY_ENV, save_config
from repowise.cli.main import cli
+class TestInteractiveGate:
+ """The questionnaire gate: --resume must skip it (issue #2098)."""
+
+ def test_tty_with_no_flags_is_interactive(self) -> None:
+ assert _interactive_gate(
+ isatty=True, provider_name=None, index_only=False, yes=False, resume=False
+ )
+
+ def test_resume_skips_the_gate_on_a_tty(self) -> None:
+ """A resume must not re-ask questions the prior run already answered."""
+ assert not _interactive_gate(
+ isatty=True, provider_name=None, index_only=False, yes=False, resume=True
+ )
+
+ def test_yes_skips_the_gate(self) -> None:
+ assert not _interactive_gate(
+ isatty=True, provider_name=None, index_only=False, yes=True, resume=False
+ )
+
+ def test_explicit_provider_skips_the_gate(self) -> None:
+ assert not _interactive_gate(
+ isatty=True, provider_name="anthropic", index_only=False, yes=False, resume=False
+ )
+
+ def test_index_only_skips_the_gate(self) -> None:
+ assert not _interactive_gate(
+ isatty=True, provider_name=None, index_only=True, yes=False, resume=False
+ )
+
+ def test_non_tty_skips_the_gate(self) -> None:
+ assert not _interactive_gate(
+ isatty=False, provider_name=None, index_only=False, yes=False, resume=False
+ )
+
+
def _est(usd: float) -> SimpleNamespace:
"""A stand-in for a cost estimate, which the gate only reads two fields of."""
return SimpleNamespace(estimated_cost_usd=usd, cost_range=None, is_calibrated=False)