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.

feat(init): the plan screen offers to keep machine-specific files out of git (#4256)

Raghav Chamadiya49f0c3cefb95
diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/_finish.py b/packages/cli/src/repowise/cli/commands/init_cmd/_finish.py
index 95ad8435d..e0ccb3215 100644
--- a/packages/cli/src/repowise/cli/commands/init_cmd/_finish.py
+++ b/packages/cli/src/repowise/cli/commands/init_cmd/_finish.py
@@ -408,6 +408,17 @@ def _write_editor_files(run: InitRun, steps: Any) -> list[Path]:
return files_written
+def _keep_out_of_git(run: InitRun) -> None:
+ """The plan screen's exclude offer, over the machine-specific files now on disk."""
+ if not run.git_exclude:
+ return
+ from repowise.cli.git_exclude import add_to_exclude, keep_out_candidates
+
+ added = add_to_exclude(run.repo_path, keep_out_candidates(run.repo_path))
+ if added:
+ console.print(f" [dim]Kept out of git (.git/info/exclude): {', '.join(added)}[/dim]")
+
+
def complete_setup(run: InitRun) -> None:
"""State, read views and editor files, hook offers, then the completion panel."""
opts = run.opts
@@ -417,6 +428,7 @@ def complete_setup(run: InitRun) -> None:
with steps.step("state"):
write_run_state(run)
files_written = _write_editor_files(run, steps)
+ _keep_out_of_git(run)
_record_init_outcome(run)
offer_hook_install(
diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/_options.py b/packages/cli/src/repowise/cli/commands/init_cmd/_options.py
index 5c5aa5a47..6ea31b833 100644
--- a/packages/cli/src/repowise/cli/commands/init_cmd/_options.py
+++ b/packages/cli/src/repowise/cli/commands/init_cmd/_options.py
@@ -81,6 +81,8 @@ class InitRun:
editor_options: Any = None
#: The plan screen's answer to repointing the global MCP entry; None = not asked.
global_mcp_consent: bool | None = None
+ #: The plan screen's answer: add machine-specific files to .git/info/exclude.
+ git_exclude: bool = False
config: dict[str, Any] = field(default_factory=dict)
language: str = "en"
max_file_pages: int | None = None
diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/_plan.py b/packages/cli/src/repowise/cli/commands/init_cmd/_plan.py
index 6c5a6c378..a38341df4 100644
--- a/packages/cli/src/repowise/cli/commands/init_cmd/_plan.py
+++ b/packages/cli/src/repowise/cli/commands/init_cmd/_plan.py
@@ -44,6 +44,7 @@ class _Answers:
selection: Any = None
sync: bool = True
this_repo_only: bool = False
+ git_exclude: bool = False
def _outside_lines(run: InitRun) -> tuple[str, ...]:
@@ -70,6 +71,17 @@ def _embedders(run: InitRun) -> tuple[str, str]:
return template_run_embedder(resolved, requested), resolved
+def _keep_out(run: InitRun, editor_setup: bool) -> tuple[str, ...]:
+ """Machine-specific files the run leaves visible to git, written now or by this run."""
+ from repowise.cli.editor_setup import planned_project_files
+ from repowise.cli.git_exclude import keep_out_candidates
+
+ from ._prepare import _editor_options
+
+ planned = planned_project_files(run.repo_path, _editor_options(run)) if editor_setup else ()
+ return keep_out_candidates(run.repo_path, planned)
+
+
def _state(run: InitRun, base: PlanState, answers: _Answers) -> PlanState:
"""The screen for the run as it stands."""
from repowise.cli.editor_setup import planned_agents
@@ -78,6 +90,7 @@ def _state(run: InitRun, base: PlanState, answers: _Answers) -> PlanState:
free_embedder, model_embedder = _embedders(run)
agents = planned_agents(run.repo_path, _editor_options(run)) if base.editor_setup else ()
+ keep_out = _keep_out(run, base.editor_setup)
return replace(
base,
run_mode=run.opts.run_mode,
@@ -87,6 +100,8 @@ def _state(run: InitRun, base: PlanState, answers: _Answers) -> PlanState:
agents=agents,
sync=answers.sync,
this_repo_only=answers.this_repo_only,
+ keep_out=keep_out,
+ git_exclude=answers.git_exclude and bool(keep_out),
commit_limit=_commit_limit(run),
)
@@ -184,6 +199,12 @@ def _edit_plan(run: InitRun, scan: Any, editor_setup: bool, answers: _Answers) -
" Keep the index in sync after each commit (post-commit hook)?",
default=answers.sync,
)
+ keep_out = _keep_out(run, editor_setup)
+ if keep_out:
+ answers.git_exclude = click.confirm(
+ f" Keep {', '.join(keep_out)} out of git (adds to .git/info/exclude)?",
+ default=answers.git_exclude,
+ )
def _apply(run: InitRun, base: PlanState, answers: _Answers) -> None:
@@ -206,6 +227,7 @@ def _apply(run: InitRun, base: PlanState, answers: _Answers) -> None:
run.opts = opts
if base.can_keep_global:
run.global_mcp_consent = not answers.this_repo_only
+ run.git_exclude = answers.git_exclude
def _leave_repo_as_it_was(run: InitRun) -> None:
@@ -237,6 +259,8 @@ def _until_enter(
elif action == THIS_REPO:
answers.this_repo_only = not answers.this_repo_only
else:
+ # What the screen showed: on only while there is something to exclude.
+ answers.git_exclude = state.git_exclude
return
diff --git a/packages/cli/src/repowise/cli/editor_setup.py b/packages/cli/src/repowise/cli/editor_setup.py
index c3d98d9c7..4bc480de5 100644
--- a/packages/cli/src/repowise/cli/editor_setup.py
+++ b/packages/cli/src/repowise/cli/editor_setup.py
@@ -268,6 +268,34 @@ def planned_agents(repo_path: Path, options: EditorSetupOptions) -> tuple[str, .
return tuple(row["display_name"] for row in rows if row["id"] in ticked)
+def planned_project_files(repo_path: Path, options: EditorSetupOptions) -> tuple[str, ...]:
+ """Root-relative files :func:`write_editor_project_files` may write with *options*.
+
+ A superset, as ``describe_paths`` is. The Claude Code setup also runs the
+ CLAUDE.md generator, which no target describes.
+ """
+ from repowise.cli.agent_targets.registry import get_target
+ from repowise.cli.agent_targets.targets.claude_code import ID as CLAUDE_CODE
+ from repowise.cli.agent_targets.types import Scope
+ from repowise.cli.uninstall.generated_files import generated_blocks
+
+ resolved = _resolve_configured_project_file_optouts(repo_path, options)
+ paths: list[str] = []
+ for integration in _resolve_integrations(None):
+ if integration.project_file_id in resolved.disabled_project_files:
+ continue
+ target = get_target(integration.integration_id)
+ described = target.describe_paths(Scope.PROJECT, repo_path=repo_path) if target else []
+ for raw in described:
+ try:
+ paths.append(Path(raw).relative_to(repo_path).as_posix())
+ except ValueError:
+ continue
+ if integration.integration_id == CLAUDE_CODE:
+ paths.extend(b.relative_path for b in generated_blocks() if b.id == "claude-md")
+ return tuple(dict.fromkeys(paths))
+
+
def select_agents_interactively(
console_obj: Any,
repo_path: Path,
diff --git a/packages/cli/src/repowise/cli/git_exclude.py b/packages/cli/src/repowise/cli/git_exclude.py
new file mode 100644
index 000000000..30cd0e8fe
--- /dev/null
+++ b/packages/cli/src/repowise/cli/git_exclude.py
@@ -0,0 +1,103 @@
+"""Keeping repowise's machine-specific files out of git, through ``.git/info/exclude``.
+
+Only the clone-local exclude file is written, never ``.gitignore``: whether a
+file is shared is the team's call, and an exclude line is invisible to them.
+Which files count is :data:`~repowise.core.owned_paths.MACHINE_SPECIFIC_FILES`.
+"""
+
+from __future__ import annotations
+
+import subprocess
+from collections.abc import Iterable
+from pathlib import Path
+
+from repowise.core.owned_paths import MACHINE_SPECIFIC_FILES
+
+HEADER = "# repowise (machine-specific)"
+
+
+def _git(repo_path: Path, *args: str) -> subprocess.CompletedProcess[str] | None:
+ try:
+ return subprocess.run(
+ ["git", *args],
+ cwd=repo_path,
+ capture_output=True,
+ text=True,
+ timeout=10,
+ )
+ except (OSError, subprocess.SubprocessError):
+ return None
+
+
+def _layout(repo_path: Path) -> tuple[Path, str] | None:
+ """``(exclude file, repo prefix inside the work tree)``, or ``None`` outside git.
+
+ ``--git-path`` resolves a linked worktree's ``.git`` file to the common
+ dir, where git reads ``info/exclude`` for every worktree.
+ """
+ result = _git(repo_path, "rev-parse", "--show-prefix", "--git-path", "info/exclude")
+ if result is None or result.returncode != 0:
+ return None
+ lines = result.stdout.splitlines()
+ if len(lines) < 2:
+ return None
+ prefix, exclude = lines[0].strip(), Path(lines[1].strip())
+ if not exclude.is_absolute():
+ exclude = repo_path / exclude
+ return exclude, prefix
+
+
+def _listed(repo_path: Path, args: tuple[str, ...], paths: list[str]) -> set[str]:
+ result = _git(repo_path, *args, "--", *paths)
+ if result is None:
+ return set()
+ return {line.strip() for line in result.stdout.splitlines() if line.strip()}
+
+
+def keep_out_candidates(repo_path: Path, planned: Iterable[str] = ()) -> tuple[str, ...]:
+ """Machine-specific files git would still see: present or *planned*, untracked, not ignored."""
+ if _layout(repo_path) is None:
+ return ()
+ wanted = set(planned)
+ paths = [p for p in MACHINE_SPECIFIC_FILES if p in wanted or (repo_path / p).is_file()]
+ if not paths:
+ return ()
+ tracked = _listed(repo_path, ("ls-files",), paths)
+ paths = [p for p in paths if p not in tracked]
+ if not paths:
+ return ()
+ ignored = _listed(repo_path, ("check-ignore", "--no-index"), paths)
+ return tuple(p for p in paths if p not in ignored)
+
+
+def _missing_block(existing: str, lines: Iterable[str]) -> tuple[list[str], str]:
+ """``(lines not in *existing*, text to append)``; the header only once per file."""
+ present = {line.strip() for line in existing.splitlines()}
+ added = [line for line in dict.fromkeys(lines) if line not in present]
+ if not added:
+ return [], ""
+ block = ([] if HEADER in present else [HEADER]) + added
+ lead = "" if not existing or existing.endswith("\n") else "\n"
+ return added, lead + "\n".join(block) + "\n"
+
+
+def add_to_exclude(repo_path: Path, paths: Iterable[str]) -> list[str]:
+ """Append the missing *paths* to the exclude file; returns the lines added.
+
+ Anchored to the repo (``/<prefix><path>``) so a same-named file elsewhere
+ stays visible. A no-op outside git or when every line is already there.
+ """
+ layout = _layout(repo_path)
+ if layout is None:
+ return []
+ exclude, prefix = layout
+ try:
+ existing = exclude.read_text(encoding="utf-8") if exclude.is_file() else ""
+ added, text = _missing_block(existing, (f"/{prefix}{p}" for p in paths))
+ if added:
+ exclude.parent.mkdir(parents=True, exist_ok=True)
+ with exclude.open("a", encoding="utf-8", newline="\n") as fh:
+ fh.write(text)
+ except (OSError, UnicodeDecodeError):
+ return []
+ return added
diff --git a/packages/cli/src/repowise/cli/ui/plan_screen/render.py b/packages/cli/src/repowise/cli/ui/plan_screen/render.py
index 7b45fe04c..11a73827b 100644
--- a/packages/cli/src/repowise/cli/ui/plan_screen/render.py
+++ b/packages/cli/src/repowise/cli/ui/plan_screen/render.py
@@ -21,7 +21,7 @@ from repowise.core.index_scope import FAST_TO_FULL_COMMAND
#: What ``e`` opens, named so the key is not a blind door.
EDIT_PREVIEW = (
"scope, run mode, excludes, commit limit, file pages, embedder, agents and "
- "sync, plus concurrency, style and language with a model"
+ "sync, keeping machine-specific files out of git, plus concurrency, style and language with a model"
)
@@ -105,6 +105,15 @@ def _connect_rows(state: PlanState) -> list[tuple[str, str]]:
return [("Connect", agents), ("Keep in sync", sync)]
+def _keep_out_line(state: PlanState) -> str:
+ """The ``.git/info/exclude`` offer, on or off in words."""
+ files = ", ".join(escape(p) for p in state.keep_out)
+ if state.git_exclude:
+ return f"Keep out of git: {files} [dim](adds to .git/info/exclude)[/dim]"
+ them = "it" if len(state.keep_out) == 1 else "them"
+ return f"[dim]Keep out of git: off for {files} (e adds {them} to .git/info/exclude)[/dim]"
+
+
def _plan_heading(state: PlanState) -> str:
if state.chosen is None:
return f" [{BRAND}]The plan[/] [dim]free, runs on this machine[/dim]"
@@ -187,6 +196,8 @@ def render_plan(console: Console, state: PlanState) -> None:
*_connect_rows(state),
]
console.print(key_value_table(rows, label_width=14, value_style=""), highlight=False)
+ if state.keep_out:
+ _say(console, _keep_out_line(state), indent=2)
_print_model_offer(console, state)
_print_outside(console, state)
console.print()
diff --git a/packages/cli/src/repowise/cli/ui/plan_screen/state.py b/packages/cli/src/repowise/cli/ui/plan_screen/state.py
index c381dfaab..b67e0881f 100644
--- a/packages/cli/src/repowise/cli/ui/plan_screen/state.py
+++ b/packages/cli/src/repowise/cli/ui/plan_screen/state.py
@@ -60,6 +60,9 @@ class PlanState:
outside: tuple[str, ...] = ()
this_repo_only: bool = False
large_repo: bool = False
+ #: Machine-specific files git would see, and whether Enter excludes them.
+ keep_out: tuple[str, ...] = ()
+ git_exclude: bool = False
#: Commits git history walks at most (``--commit-limit`` or config.yaml).
commit_limit: int = 5000
diff --git a/packages/core/src/repowise/core/owned_paths.py b/packages/core/src/repowise/core/owned_paths.py
index 9d2babf1d..6f6d5fb7b 100644
--- a/packages/core/src/repowise/core/owned_paths.py
+++ b/packages/core/src/repowise/core/owned_paths.py
@@ -38,27 +38,33 @@ OWNED_PATTERNS: tuple[str, ...] = (
".kiro/steering/repowise.md",
)
-#: Root-relative. Markdown holds the writers' exactly marked blocks: the
-#: CLAUDE.md and AGENTS.md generators, and the instruction blocks of the codex,
-#: opencode, hermes, copilot, vscode and cursor targets. The JSON and TOML
-#: files hold a ``repowise`` server entry, hook or extension recommendation
-#: from the agent targets (claude code, vscode, cursor, kiro, codex, opencode).
-MANAGED_FILES: tuple[str, ...] = (
- ".claude/CLAUDE.md",
- "AGENTS.md",
- ".github/copilot-instructions.md",
- ".cursor/rules/repowise.mdc",
- ".mcp.json",
- ".claude/settings.local.json",
- ".vscode/mcp.json",
- ".vscode/extensions.json",
- ".cursor/mcp.json",
- ".kiro/settings/mcp.json",
- ".codex/config.toml",
- ".codex/hooks.json",
- "opencode.json",
- "opencode.jsonc",
-)
+#: Root-relative, each with whether it is machine-specific: worth keeping out
+#: of git per clone rather than shared with the team. ``.mcp.json`` and
+#: the other agents' configs stay shared. Markdown holds the writers' exactly
+#: marked blocks: the CLAUDE.md and AGENTS.md generators, and the instruction
+#: blocks of the codex, opencode, hermes, copilot, vscode and cursor targets.
+#: The JSON and TOML files hold a ``repowise`` server entry, hook or extension
+#: recommendation from the agent targets (claude code, vscode, cursor, kiro,
+#: codex, opencode).
+_MANAGED: dict[str, bool] = {
+ ".claude/CLAUDE.md": True,
+ "AGENTS.md": False,
+ ".github/copilot-instructions.md": True,
+ ".cursor/rules/repowise.mdc": False,
+ ".mcp.json": False,
+ ".claude/settings.local.json": True,
+ ".vscode/mcp.json": True,
+ ".vscode/extensions.json": True,
+ ".cursor/mcp.json": False,
+ ".kiro/settings/mcp.json": False,
+ ".codex/config.toml": False,
+ ".codex/hooks.json": False,
+ "opencode.json": False,
+ "opencode.jsonc": False,
+}
+MANAGED_FILES: tuple[str, ...] = tuple(_MANAGED)
+#: The managed files ``init`` offers to add to ``.git/info/exclude``.
+MACHINE_SPECIFIC_FILES: tuple[str, ...] = tuple(p for p, machine in _MANAGED.items() if machine)
#: The VS Code extension the vscode target recommends in ``extensions.json``.
EXTENSION_ID = "repowise-dev.repowise"
diff --git a/tests/unit/cli/test_git_exclude.py b/tests/unit/cli/test_git_exclude.py
new file mode 100644
index 000000000..6a4912583
--- /dev/null
+++ b/tests/unit/cli/test_git_exclude.py
@@ -0,0 +1,202 @@
+"""Keeping machine-specific generated files out of git through ``.git/info/exclude``."""
+
+from __future__ import annotations
+
+import subprocess
+from pathlib import Path
+from typing import Any
+
+import pytest
+from rich.console import Console
+
+from repowise.cli.git_exclude import HEADER, add_to_exclude, keep_out_candidates
+from repowise.cli.ui.plan_screen import PlanState, render_plan
+from repowise.cli.ui.repo_scanner import RepoScanInfo
+from repowise.core.owned_paths import MACHINE_SPECIFIC_FILES, MANAGED_FILES
+
+
+def _git(cwd: Path, *args: str) -> str:
+ return subprocess.run(
+ ["git", *args], cwd=cwd, check=True, capture_output=True, text=True
+ ).stdout
+
+
+def repo(tmp_path: Path) -> Path:
+ root = tmp_path / "repo"
+ root.mkdir()
+ _git(root, "init", "-q")
+ _git(root, "config", "user.email", "[email protected]")
+ _git(root, "config", "user.name", "t")
+ (root / "README.md").write_text("hi\n", encoding="utf-8")
+ _git(root, "add", "README.md")
+ _git(root, "commit", "-q", "-m", "init")
+ return root
+
+
+def _write(root: Path, *paths: str) -> None:
+ # At most three fixture files per test: one write each is the whole job.
+ for rel in paths:
+ (root / rel).parent.mkdir(parents=True, exist_ok=True)
+ (root / rel).write_text("x\n", encoding="utf-8")
+
+
+def _status(root: Path) -> str:
+ return _git(root, "status", "--short", "--untracked-files=all")
+
+
+# -- the registry -------------------------------------------------------------
+
+
+def test_machine_specific_is_an_attribute_of_the_managed_list() -> None:
+ assert set(MACHINE_SPECIFIC_FILES) <= set(MANAGED_FILES)
+ for path in (
+ ".claude/CLAUDE.md",
+ ".github/copilot-instructions.md",
+ ".vscode/mcp.json",
+ ".vscode/extensions.json",
+ ".claude/settings.local.json",
+ ):
+ assert path in MACHINE_SPECIFIC_FILES
+ # Teams share the MCP config.
+ assert ".mcp.json" not in MACHINE_SPECIFIC_FILES
+
+
+def test_the_planned_files_cover_every_machine_specific_file_init_writes(tmp_path: Path) -> None:
+ from repowise.cli.editor_setup import EditorSetupOptions, planned_project_files
+
+ planned = planned_project_files(tmp_path, EditorSetupOptions())
+ assert {".claude/CLAUDE.md", ".vscode/mcp.json", ".github/copilot-instructions.md"} <= set(
+ planned
+ )
+ no_claude_md = EditorSetupOptions(disabled_project_files=frozenset({"claude_md"}))
+ assert ".claude/CLAUDE.md" not in planned_project_files(tmp_path, no_claude_md)
+
+
+# -- the writer ---------------------------------------------------------------
+
+
+def test_exclude_hides_the_files_and_a_second_run_adds_nothing(repo: Path) -> None:
+ _write(repo, ".claude/CLAUDE.md", ".vscode/mcp.json", ".mcp.json")
+ exclude = repo / ".git" / "info" / "exclude"
+ before = exclude.read_text(encoding="utf-8")
+
+ candidates = keep_out_candidates(repo)
+ assert candidates == (".claude/CLAUDE.md", ".vscode/mcp.json")
+ assert add_to_exclude(repo, candidates) == ["/.claude/CLAUDE.md", "/.vscode/mcp.json"]
+
+ after = exclude.read_text(encoding="utf-8")
+ assert after.startswith(before)
+ assert after.count(HEADER) == 1
+ assert _status(repo).split() == ["??", ".mcp.json"]
+ # Idempotent, and nothing left to offer.
+ assert add_to_exclude(repo, candidates) == []
+ assert exclude.read_text(encoding="utf-8") == after
+ assert keep_out_candidates(repo) == ()
+ assert not (repo / ".gitignore").exists()
+
+
+def test_tracked_and_already_ignored_files_are_not_offered(repo: Path) -> None:
+ _write(repo, ".claude/CLAUDE.md", ".vscode/mcp.json", ".github/copilot-instructions.md")
+ _git(repo, "add", ".claude/CLAUDE.md")
+ (repo / ".gitignore").write_text(".vscode/\n", encoding="utf-8")
+ assert keep_out_candidates(repo) == (".github/copilot-instructions.md",)
+
+
+def test_planned_files_are_offered_before_they_exist(repo: Path) -> None:
+ assert keep_out_candidates(repo, [".vscode/mcp.json", ".mcp.json"]) == (".vscode/mcp.json",)
+
+
+def test_a_linked_worktree_writes_the_common_exclude(repo: Path, tmp_path: Path) -> None:
+ wt = tmp_path / "wt"
+ _git(repo, "worktree", "add", "-q", str(wt))
+ assert (wt / ".git").is_file()
+ _write(wt, ".claude/CLAUDE.md")
+
+ assert add_to_exclude(wt, keep_out_candidates(wt)) == ["/.claude/CLAUDE.md"]
+ assert "/.claude/CLAUDE.md" in (repo / ".git" / "info" / "exclude").read_text("utf-8")
+ assert ".claude" not in _status(wt)
+
+
+def test_a_repo_in_a_subdirectory_anchors_its_prefix(repo: Path) -> None:
+ sub = repo / "pkg"
+ _write(sub, ".claude/CLAUDE.md")
+ assert add_to_exclude(sub, keep_out_candidates(sub)) == ["/pkg/.claude/CLAUDE.md"]
+ assert ".claude" not in _status(repo)
+
+
+def test_outside_git_nothing_is_offered_or_written(tmp_path: Path) -> None:
+ _write(tmp_path, ".claude/CLAUDE.md")
+ assert keep_out_candidates(tmp_path) == ()
+ assert add_to_exclude(tmp_path, [".claude/CLAUDE.md"]) == []
+
+
+# -- the plan screen ----------------------------------------------------------
+
+
+def _render(state: PlanState) -> str:
+ console = Console(record=True, width=120, color_system=None)
+ render_plan(console, state)
+ return " ".join(console.export_text().split())
+
+
+_SCAN = RepoScanInfo(total_files=50, language_counts={"Python": 30}, total_commits=40)
+_FILES = (".claude/CLAUDE.md", ".vscode/mcp.json")
+
+
+def test_the_plan_names_the_files_off_by_default() -> None:
+ out = _render(PlanState(repo_name="demo", scan=_SCAN, keep_out=_FILES))
+ assert (
+ "Keep out of git: off for .claude/CLAUDE.md, .vscode/mcp.json "
+ "(e adds them to .git/info/exclude)"
+ ) in out
+
+
+def test_the_plan_line_when_on_and_absent_with_nothing_to_offer() -> None:
+ on = _render(PlanState(repo_name="demo", scan=_SCAN, keep_out=_FILES, git_exclude=True))
+ assert "Keep out of git: .claude/CLAUDE.md, .vscode/mcp.json (adds to .git/info/exclude)" in on
+ assert "Keep out of git:" not in _render(PlanState(repo_name="demo", scan=_SCAN))
+
+
+def test_e_accepts_the_offer_and_enter_records_it(
+ repo: Path, monkeypatch: Any
+) -> None:
+ from repowise.cli.commands.init_cmd import _finish, _plan
+ from repowise.cli.ui import plan_screen
+
+ _write(repo, ".claude/CLAUDE.md")
+ run = _init_run(repo)
+ monkeypatch.setattr(_plan, "agent_providers_set_up", lambda _r: ())
+ monkeypatch.setattr(
+ "repowise.cli.ui.provider_selection._detect_provider_status", lambda _r: {}
+ )
+ monkeypatch.setattr(_plan, "interactive_advanced_config", lambda *a, **k: None)
+ monkeypatch.setattr("repowise.cli.commands.init_cmd._questions._apply_advanced_answers",
+ lambda *a: None)
+ asked: list[str] = []
+
+ def confirm(text: str, default: bool = False) -> bool:
+ asked.append(text)
+ return True
+
+ monkeypatch.setattr(_plan.click, "confirm", confirm)
+ keys = iter([plan_screen.EDIT, plan_screen.START])
+ monkeypatch.setattr(_plan, "read_plan_key", lambda *_a: next(keys))
+ _plan.run_plan_screen(run, _SCAN)
+
+ assert asked == [" Keep .claude/CLAUDE.md out of git (adds to .git/info/exclude)?"]
+ assert run.git_exclude is True
+ _finish._keep_out_of_git(run)
+ assert "/.claude/CLAUDE.md" in (repo / ".git" / "info" / "exclude").read_text("utf-8")
+
+
+def _init_run(repo: Path) -> Any:
+ from repowise.cli.commands.init_cmd._options import InitOptions, InitRun
+
+ fields = {name: None for name in InitOptions.__dataclass_fields__}
+ fields.update(
+ exclude=(), coverage_report=(), run_mode="standard", concurrency=10,
+ onboarding=True, editor_setup=False, save_key=True, yes=False, index_only=False,
+ follow_renames=False, skip_tests=False, skip_infra=False,
+ )
+ return InitRun(opts=InitOptions(**fields), repo_path=repo, start=0.0, is_interactive=True)