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(cli): make --no-editor-setup mean no editor setup, and name the files init wrote (#1572)

Swati Ahuja79b597897178
diff --git a/docs/architecture/editor-files.md b/docs/architecture/editor-files.md
index 0bec13885..825873631 100644
--- a/docs/architecture/editor-files.md
+++ b/docs/architecture/editor-files.md
@@ -379,14 +379,26 @@ read project-local config, so theirs are no-ops.
The distill command-rewrite hook is machine-wide too, but it is offered
separately (`offer_distill_rewrite_hook`) because it is strictly opt-in.
-`--no-editor-setup` turns off that machine-wide group, including the rewrite
-hook offer, and leaves the project-local files alone:
+`--no-editor-setup` turns off **both** groups: the machine-wide registrations
+above, including the rewrite hook offer, *and* the project-local files
+(`.mcp.json`, `.claude/CLAUDE.md`, `.vscode/mcp.json`,
+`.vscode/extensions.json`). Only `.repowise/` is written.
```bash
-# Index the repo, leave everything outside it untouched
+# Index the repo, write nothing into it and nothing outside it
repowise init --no-editor-setup --yes .
```
+It used to cover the machine-wide half only, and said so — which meant there
+was no combination of flags that indexed a repo without writing four files into
+the working tree, since VS Code had no opt-out flag of its own. Issue #1499 is
+the report of exactly that. One switch, one meaning.
+
+`.repowise/mcp.json` is the one deliberate exception and is written either way.
+No editor reads it unless pointed at it, and it is what `repowise mcp .` prints
+— so skipping it would mean opting out of editor setup also opted out of ever
+opting back in.
+
Reach for it whenever the checkout or the binary running `init` is temporary:
a scratch clone, a release smoke test from a throwaway venv, a git worktree, a
benchmark loop over many repos. Each config holds a **single** `repowise` MCP
@@ -395,11 +407,19 @@ and the breakage only shows up later, when the path it now points at is gone
and the MCP server quietly stops loading. `init` prints a notice when it is
about to repoint an existing entry, but the flag is how you avoid it.
-One exception, so the two flags do not cancel each other out: `--no-editor-setup
+Two exceptions, so the flags do not cancel each other out. `--no-editor-setup
--no-distill-hook` still records the `distill.commands.enabled: false` opt-out in
this repo's `config.yaml`. That record is repo-local, and it is the only thing
that gates an already-installed global rewrite hook off here.
+The same reasoning covers the instruction files: `--no-editor-setup
+--no-claude-md` still records `editor_files.claude_md: false`, and likewise for
+`--no-agents-md`. Those flags mean "never generate this file", not "skip it this
+once", and the generator declining on its way past used to be the only thing
+that wrote the preference down — so suppressing the writes would also have
+suppressed the memory of the refusal, and the next `repowise update` would have
+generated the file anyway. A preference is not a write.
+
`REPOWISE_SKIP_EDITOR_SETUP=1` is the same switch as an env var, which is the
better fit for CI and sandboxes where no one is passing flags by hand. Either
source disables setup; the flag never re-enables what the env var turned off.
diff --git a/docs/reference/CLI_REFERENCE.md b/docs/reference/CLI_REFERENCE.md
index a9eac8f60..76ea04eee 100644
--- a/docs/reference/CLI_REFERENCE.md
+++ b/docs/reference/CLI_REFERENCE.md
@@ -172,7 +172,7 @@ All three reach the indexing knobs; the LLM-only knobs appear only when model-wr
| `--agents` / `--no-agents` | Generate or skip managed `AGENTS.md` for Codex. Persists the preference. |
| `--codex` / `--no-codex` | Generate or skip project-local Codex MCP/hooks setup. Interactive runs prompt when Codex CLI is installed and logged in; non-interactive runs require `--codex`. |
| `--distill-hook` / `--no-distill-hook` | Install or skip the Distill command-rewrite hook (Claude Code PreToolUse). Strictly opt-in: interactive runs prompt (default No); `--no-distill-hook` also gates the repo off in config so a globally installed hook stays inert here. In workspace mode the verdict applies to every selected repo. See [DISTILL.md](../agent/DISTILL.md). |
-| `--editor-setup` / `--no-editor-setup` | Register repowise in your machine-wide editor config: the Claude Code (`~/.claude/settings.json`) and Claude Desktop MCP server entry, plus the Claude Code PostToolUse/SessionStart hooks. Default: on. `--no-editor-setup` indexes the repo without touching anything outside it, which is what you want for a scratch checkout, a throwaway venv, or a CI run: each config holds a single `repowise` MCP key, so a second `init` repoints it at the newest repo instead of adding a second entry. It also skips the `--distill-hook` offer, which installs a user-level hook, though `--no-distill-hook` still records its opt-out in this repo's config. Project-local files are unaffected. `REPOWISE_SKIP_EDITOR_SETUP=1` is the same switch for CI and sandboxes, and it wins: with it set, an explicit `--editor-setup` does not turn registration back on. |
+| `--editor-setup` / `--no-editor-setup` | Wire repowise into your editors, both halves at once. Machine-wide: the Claude Code (`~/.claude/settings.json`) and Claude Desktop MCP server entry, plus the Claude Code PostToolUse/SessionStart hooks. Project-local: `.mcp.json`, `.claude/CLAUDE.md`, `.vscode/mcp.json`, `.vscode/extensions.json`. Default: on. `--no-editor-setup` indexes the repo writing nothing into it and nothing outside it — only `.repowise/` is touched — which is what you want for a scratch checkout, a throwaway venv, a git worktree, or a CI run: each config holds a single `repowise` MCP key, so a second `init` repoints it at the newest repo instead of adding a second entry. `repowise mcp .` still prints the config to connect a client by hand. It also skips the `--distill-hook` offer, which installs a user-level hook; `--no-distill-hook`, `--no-claude-md` and `--no-agents-md` still record their opt-outs in this repo's config, because those flags mean "never", not "not this run". `REPOWISE_SKIP_EDITOR_SETUP=1` is the same switch for CI and sandboxes, and it wins: with it set, an explicit `--editor-setup` does not turn setup back on. |
| `--seed-from` | Seed the index from an explicit base checkout instead of the auto-detected one. Rarely needed: inside a linked git worktree the base is detected and seeded automatically. See [WORKTREES.md](../scale/WORKTREES.md). |
| `--no-seed` | Disable worktree auto-seeding and run a full init even inside a linked worktree. |
| `--yes` / `-y` | Skip confirmation prompts |
diff --git a/packages/cli/src/repowise/cli/agent_targets/types.py b/packages/cli/src/repowise/cli/agent_targets/types.py
index b6dafd124..0c12303da 100644
--- a/packages/cli/src/repowise/cli/agent_targets/types.py
+++ b/packages/cli/src/repowise/cli/agent_targets/types.py
@@ -415,8 +415,16 @@ class InstallLifecycle(Protocol):
def write_project_files(
self, console_obj: object, repo_path: Path, options: object
- ) -> None:
- """Write project-local config or instruction files for this agent."""
+ ) -> list[Path]:
+ """Write project-local config or instruction files, returning the paths.
+
+ The return value is what ``init`` prints as its end-of-run manifest, so
+ it lists what was *written*, not what was intended: a file the
+ integration declined to touch (unparseable JSONC) or failed to generate
+ is left out. Reporting a path init did not write is worse than
+ reporting none at all, because the manifest exists to be checked
+ against ``git status``.
+ """
...
def register_client(self, console_obj: object, repo_path: Path) -> None:
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 57c2523dc..3658006d3 100644
--- a/packages/cli/src/repowise/cli/commands/init_cmd/command.py
+++ b/packages/cli/src/repowise/cli/commands/init_cmd/command.py
@@ -544,15 +544,16 @@ def _run_generation_phase(
"editor_setup",
default=True,
help=(
- "Register repowise with your machine-wide editor config: the Claude "
- "Code / Claude Desktop MCP server entry, the Claude Code hooks, and "
- "the distill rewrite-hook offer. Default: on. Use --no-editor-setup to "
- "index a repo without touching anything outside it — there is one "
- "global 'repowise' MCP key, so a second init would otherwise repoint "
- "it at this repo. Project-local files are unaffected (see "
- "--no-claude-md, --no-codex). REPOWISE_SKIP_EDITOR_SETUP=1 does the "
+ "Wire repowise into your editors. Covers both halves: the machine-wide "
+ "config (the Claude Code / Claude Desktop MCP entry, the Claude Code "
+ "hooks, the distill rewrite-hook offer) and the project-local files "
+ "(.mcp.json, .claude/CLAUDE.md, .vscode/mcp.json, "
+ ".vscode/extensions.json). Default: on. Use --no-editor-setup to index "
+ "a repo without writing anything into it or outside it; only "
+ ".repowise/ is touched, and 'repowise mcp .' still prints the config "
+ "to connect a client by hand. REPOWISE_SKIP_EDITOR_SETUP=1 does the "
"same thing for CI and sandboxes, and wins: with it set, --editor-setup "
- "does not turn registration back on."
+ "does not turn setup back on."
),
)
@click.option(
@@ -1064,7 +1065,10 @@ def init_command(
# either generating docs or customizing an index-only run (the latter
# previously got no say). One checklist, pre-ticked from detection, in
# place of the three sequential yes/no prompts each integration used to own.
- if is_interactive and (generate_docs or customize):
+ # Not asked when editor setup is off: every answer would be discarded by
+ # `write_editor_project_files`, and a checklist whose result cannot act is
+ # worse than no checklist.
+ if editor_setup and is_interactive and (generate_docs or customize):
editor_options = select_agents_interactively(console, repo_path, editor_options)
# Merge exclude_patterns from config.yaml and --exclude/-x flags
@@ -1491,10 +1495,14 @@ def init_command(
if commit_limit is not None:
save_config_partial(repo_path, commit_limit=resolved_commit_limit)
- write_editor_project_files(
+ # One flag, one meaning: --no-editor-setup now suppresses the project-local
+ # writes as well as the global registration. The paths come back so the
+ # completion panel can name what landed in the working tree.
+ files_written = write_editor_project_files(
console,
repo_path,
options=editor_options,
+ no_editor_setup=not editor_setup,
)
register_editor_clients(console, repo_path, no_editor_setup=not editor_setup)
@@ -1648,4 +1656,5 @@ def init_command(
run_mode=run_mode,
provider=provider,
setup=_setup_outcome,
+ files_written=files_written,
)
diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/reporting.py b/packages/cli/src/repowise/cli/commands/init_cmd/reporting.py
index 6af3db716..73e0ff5a0 100644
--- a/packages/cli/src/repowise/cli/commands/init_cmd/reporting.py
+++ b/packages/cli/src/repowise/cli/commands/init_cmd/reporting.py
@@ -8,6 +8,7 @@ happens here.
from __future__ import annotations
import time
+from pathlib import Path
from typing import Any
from repowise.cli.helpers import console
@@ -20,6 +21,7 @@ from repowise.cli.ui import (
build_status_notes,
format_elapsed,
print_analysis_summary,
+ print_files_written,
)
@@ -120,12 +122,17 @@ def show_completion(
run_mode: str,
provider: Any,
setup: Any = None,
+ files_written: list[Path] | None = None,
) -> None:
"""Render the final completion panel (index-only or full mode).
*setup* is the :class:`~repowise.cli.editor_setup.EditorSetupOutcome`
snapshot, so the next-step panel and the MCP status note reflect what setup
actually did. Passed as ``None`` only by callers with nothing to report.
+
+ *files_written* is what editor setup put in the working tree, straight from
+ the writers. Printed below the panel and dim: it is a receipt, and the run's
+ result is the panel above it.
"""
elapsed = time.monotonic() - start
@@ -301,6 +308,8 @@ def show_completion(
console.print(_line)
console.print()
+ print_files_written(console, Path(repo_path), files_written or [])
+
_show_generation_checks(result)
diff --git a/packages/cli/src/repowise/cli/commands/init_cmd/workspace.py b/packages/cli/src/repowise/cli/commands/init_cmd/workspace.py
index 164401d07..eef6f65a8 100644
--- a/packages/cli/src/repowise/cli/commands/init_cmd/workspace.py
+++ b/packages/cli/src/repowise/cli/commands/init_cmd/workspace.py
@@ -276,6 +276,10 @@ class _WorkspaceCtx:
embedder_was_requested: bool
resolved_commit_limit: int
run_mode: str = "standard"
+ #: Mirrors the single-repo flag. A workspace writes project files per repo,
+ #: so --no-editor-setup has to reach every one of them, not just the
+ #: primary's client registration.
+ editor_setup: bool = True
@dataclass
@@ -482,6 +486,7 @@ def _ingest_and_generate_repo(repo: Any, idx: int, total: int, ctx: _WorkspaceCt
console,
repo.path,
options=ctx.editor_options,
+ no_editor_setup=not ctx.editor_setup,
)
# Persist provider/model config per-repo when doing full generation
@@ -754,6 +759,7 @@ def _workspace_init(
provider=provider,
ws_config=ws_config,
editor_options=editor_options,
+ editor_setup=editor_setup,
index_only=index_only,
dry_run=dry_run,
force=force,
diff --git a/packages/cli/src/repowise/cli/editor_integrations/claude.py b/packages/cli/src/repowise/cli/editor_integrations/claude.py
index 507f01dd2..11b42f69e 100644
--- a/packages/cli/src/repowise/cli/editor_integrations/claude.py
+++ b/packages/cli/src/repowise/cli/editor_integrations/claude.py
@@ -28,15 +28,18 @@ class ClaudeCodeSetup:
console_obj: Any,
repo_path: Path,
options: EditorSetupOptions,
- ) -> None:
+ ) -> list[Path]:
from repowise.cli.mcp_config import save_root_mcp_config
- save_root_mcp_config(repo_path)
- maybe_generate_claude_md(
+ written = [Path(save_root_mcp_config(repo_path))]
+ claude_md = maybe_generate_claude_md(
console_obj,
repo_path,
no_claude_md=self.project_file_id in options.disabled_project_files,
)
+ if claude_md is not None:
+ written.append(claude_md)
+ return written
def register_client(self, console_obj: Any, repo_path: Path) -> None:
from repowise.cli.editor_integrations.claude_config import (
@@ -46,25 +49,26 @@ class ClaudeCodeSetup:
register_with_claude_code,
register_with_claude_desktop,
)
+ from repowise.cli.ui.brand import OK, WARN
# Read-only probe first: the merge below silently repoints the single
# global "repowise" entry, so say so before it happens.
clobber = describe_mcp_registration_change(repo_path)
if clobber:
- console_obj.print(f" [yellow]![/yellow] {clobber}")
+ console_obj.print(f" [{WARN}]![/] {clobber}")
desktop = register_with_claude_desktop(repo_path)
if desktop:
- console_obj.print(f" [green]✓[/green] Claude Desktop MCP registered ({desktop})")
+ console_obj.print(f" [{OK}]✓[/] Claude Desktop MCP registered ({desktop})")
code = register_with_claude_code(repo_path)
if code:
- console_obj.print(f" [green]✓[/green] Claude Code MCP registered ({code})")
+ console_obj.print(f" [{OK}]✓[/] Claude Code MCP registered ({code})")
hooks = install_claude_code_hooks()
if hooks:
console_obj.print(
- " [green]✓[/green] Claude Code hooks registered (PostToolUse, SessionStart)"
+ f" [{OK}]✓[/] Claude Code hooks registered (PostToolUse, SessionStart)"
)
if _uses_lean_tool_surface(repo_path):
@@ -74,7 +78,7 @@ class ClaudeCodeSetup:
)
elif enable_tool_search_in_claude_code():
console_obj.print(
- " [green]✓[/green] Claude Code tool-search enabled (defers MCP tool schemas)"
+ f" [{OK}]✓[/] Claude Code tool-search enabled (defers MCP tool schemas)"
)
def refresh_project_files(
@@ -124,8 +128,15 @@ def maybe_generate_claude_md(
repo_path: Path,
*,
no_claude_md: bool = False,
-) -> None:
- """Generate CLAUDE.md if enabled in config and not opted out."""
+) -> Path | None:
+ """Generate CLAUDE.md if enabled in config and not opted out.
+
+ Returns the path written, or ``None`` for every path that does not write:
+ opted out, disabled in config, or the generator raising. The completion
+ panel's manifest is built from these, so "we tried and it failed" has to
+ read as "not written" rather than being reported to the user as a file that
+ is now in their tree.
+ """
cfg = load_config(repo_path)
if no_claude_md:
@@ -143,22 +154,36 @@ def maybe_generate_claude_md(
)
except ImportError:
pass
- return
+ return None
if not _claude_md_enabled(repo_path):
- return
+ return None
from repowise.cli.ui import OWL_SPINNER
+ from repowise.cli.ui.brand import OK, WARN
try:
with console_obj.status(" Generating .claude/CLAUDE.md…", spinner=OWL_SPINNER):
- run_async(_write_claude_md_async(repo_path))
- console_obj.print(" [green]✓[/green] .claude/CLAUDE.md updated")
+ written = run_async(_write_claude_md_async(repo_path))
except Exception as exc:
- console_obj.print(f" [yellow].claude/CLAUDE.md skipped: {exc}[/yellow]")
-
-
-async def _write_claude_md_async(repo_path: Path) -> None:
- """Fetch indexed repo data and write CLAUDE.md."""
+ console_obj.print(f" [{WARN}].claude/CLAUDE.md skipped: {exc}[/]")
+ return None
+ if written is None:
+ # The repo is not in the database yet, so the generator had nothing to
+ # write from and returned without touching disk. Silent before, which
+ # is how a run could print no error and produce no file.
+ console_obj.print(f" [{WARN}].claude/CLAUDE.md skipped: repo not indexed yet[/]")
+ return None
+ console_obj.print(f" [{OK}]✓[/] .claude/CLAUDE.md updated")
+ return written
+
+
+async def _write_claude_md_async(repo_path: Path) -> Path | None:
+ """Fetch indexed repo data and write CLAUDE.md, returning the path.
+
+ ``None`` when the repository is not in the database, which is the one path
+ here that returns without writing. The caller reports it, because a
+ manifest that lists a file nobody wrote is worse than one that lists none.
+ """
from repowise.core.generation.editor_files import ClaudeMdGenerator, EditorFileDataFetcher
from repowise.core.persistence import (
@@ -177,9 +202,9 @@ async def _write_claude_md_async(repo_path: Path) -> None:
async with get_session(sf) as session:
repo = await get_repository_by_path(session, str(repo_path))
if repo is None:
- return
+ return None
fetcher = EditorFileDataFetcher(session, repo.id, repo_path)
data = await fetcher.fetch()
finally:
await engine.dispose()
- ClaudeMdGenerator().write(repo_path, data)
+ return ClaudeMdGenerator().write(repo_path, data)
diff --git a/packages/cli/src/repowise/cli/editor_integrations/codex.py b/packages/cli/src/repowise/cli/editor_integrations/codex.py
index 7d33fe3bb..fbdbed557 100644
--- a/packages/cli/src/repowise/cli/editor_integrations/codex.py
+++ b/packages/cli/src/repowise/cli/editor_integrations/codex.py
@@ -25,48 +25,56 @@ class CodexSetup:
console_obj: Any,
repo_path: Path,
options: EditorSetupOptions,
- ) -> None:
+ ) -> list[Path]:
from repowise.cli.mcp_config import (
is_codex_cli_installed,
is_codex_logged_in,
save_codex_hooks_config,
save_codex_mcp_config,
)
+ from repowise.cli.ui.brand import OK, WARN
setup_override = options.integration_overrides.get(self.integration_id)
agents_override = options.project_file_overrides.get(self.project_file_id)
agents_override_present = self.project_file_id in options.project_file_overrides
- if setup_override is False:
- if agents_override_present:
- maybe_generate_agents_md(console_obj, repo_path, agents_md=agents_override)
- return
- if setup_override is None:
+ # Codex is opt-in, and stays that way. It is the one integration that
+ # already got this right — nothing is written unless --codex or the
+ # checklist asked for it — which is why #1499 names the other two.
+ if setup_override is None or setup_override is False:
if agents_override_present:
- maybe_generate_agents_md(console_obj, repo_path, agents_md=agents_override)
- return
+ written = maybe_generate_agents_md(
+ console_obj, repo_path, agents_md=agents_override
+ )
+ return [written] if written is not None else []
+ return []
installed = is_codex_cli_installed()
logged_in = is_codex_logged_in() if installed else False
config_path = save_codex_mcp_config(repo_path)
- console_obj.print(f" [green]✓[/green] Codex MCP registered ({config_path})")
+ console_obj.print(f" [{OK}]✓[/] Codex MCP registered ({config_path})")
hooks_path = save_codex_hooks_config(repo_path)
- console_obj.print(f" [green]✓[/green] Codex hooks registered ({hooks_path})")
- maybe_generate_agents_md(
+ console_obj.print(f" [{OK}]✓[/] Codex hooks registered ({hooks_path})")
+ written = [Path(config_path), Path(hooks_path)]
+ agents_path = maybe_generate_agents_md(
console_obj,
repo_path,
agents_md=True if agents_override is None else agents_override,
)
+ if agents_path is not None:
+ written.append(agents_path)
- if setup_override is True and not installed:
+ if not installed:
console_obj.print(
- " [yellow]Codex CLI was not detected; install with "
- "'npm install -g @openai/codex' before using this config.[/yellow]"
+ f" [{WARN}]Codex CLI was not detected; install with "
+ "'npm install -g @openai/codex' before using this config.[/]"
)
- elif setup_override is True and not logged_in:
+ elif not logged_in:
console_obj.print(
- " [yellow]Codex CLI is not logged in; run 'codex login' before using this config.[/yellow]"
+ f" [{WARN}]Codex CLI is not logged in; run 'codex login' "
+ "before using this config.[/]"
)
+ return written
def register_client(self, console_obj: Any, repo_path: Path) -> None:
"""Codex setup is project-local and does not require global registration."""
@@ -95,12 +103,18 @@ def maybe_generate_agents_md(
*,
agents_md: bool | None = None,
default: bool = True,
-) -> None:
- """Generate AGENTS.md if enabled in config and not opted out."""
+) -> Path | None:
+ """Generate AGENTS.md if enabled in config and not opted out.
+
+ Returns the path written, or ``None`` for every path that does not write —
+ same contract as ``maybe_generate_claude_md``, so the completion panel's
+ manifest never claims a file the run failed to produce.
+ """
from repowise.cli.editor_files import should_generate_editor_file
from repowise.cli.helpers import run_async
from repowise.cli.ui import OWL_SPINNER
+ from repowise.cli.ui.brand import OK, WARN
if not should_generate_editor_file(
repo_path,
@@ -108,13 +122,15 @@ def maybe_generate_agents_md(
default=default,
override=agents_md,
):
- return
+ return None
try:
with console_obj.status(" Generating AGENTS.md…", spinner=OWL_SPINNER):
run_async(_write_agents_md_async(repo_path))
- console_obj.print(" [green]✓[/green] AGENTS.md updated")
+ console_obj.print(f" [{OK}]✓[/] AGENTS.md updated")
except Exception as exc:
- console_obj.print(f" [yellow]AGENTS.md skipped: {exc}[/yellow]")
+ console_obj.print(f" [{WARN}]AGENTS.md skipped: {exc}[/]")
+ return None
+ return repo_path / "AGENTS.md"
async def _write_agents_md_async(repo_path: Path) -> None:
diff --git a/packages/cli/src/repowise/cli/editor_integrations/vscode.py b/packages/cli/src/repowise/cli/editor_integrations/vscode.py
index 5e4a79056..1bc871927 100644
--- a/packages/cli/src/repowise/cli/editor_integrations/vscode.py
+++ b/packages/cli/src/repowise/cli/editor_integrations/vscode.py
@@ -26,10 +26,10 @@ class VSCodeSetup:
console_obj: Any,
repo_path: Path,
options: EditorSetupOptions,
- ) -> None:
+ ) -> list[Path]:
if self.project_file_id in options.disabled_project_files:
- return
- _write_vscode_files(console_obj, repo_path)
+ return []
+ return _write_vscode_files(console_obj, repo_path)
def register_client(self, console_obj: Any, repo_path: Path) -> None:
"""VS Code reads the workspace .vscode/mcp.json; no user-level setup needed."""
@@ -47,29 +47,39 @@ class VSCodeSetup:
_write_vscode_files(console_obj, repo_path)
-def _write_vscode_files(console_obj: Any, repo_path: Path) -> None:
- """Write or merge the managed .vscode files, skipping any JSONC file safely."""
+def _write_vscode_files(console_obj: Any, repo_path: Path) -> list[Path]:
+ """Write or merge the managed .vscode files, skipping any JSONC file safely.
+
+ Returns the paths actually written. A file we declined to touch is not in
+ the list, which is what keeps the end-of-run manifest a record of what
+ happened rather than a restatement of what we intended.
+ """
from repowise.cli.mcp_config import (
save_vscode_extensions_config,
save_vscode_mcp_config,
)
+ from repowise.cli.ui.brand import OK, WARN
+ written: list[Path] = []
try:
mcp_path = save_vscode_mcp_config(repo_path)
- console_obj.print(f" [green]✓[/green] VS Code MCP configured ({mcp_path})")
+ console_obj.print(f" [{OK}]✓[/] VS Code MCP configured ({mcp_path})")
+ written.append(Path(mcp_path))
except ValueError:
console_obj.print(
- " [yellow].vscode/mcp.json left unchanged (not valid JSON; it may contain "
- 'comments). Add a "repowise" server under "servers" manually.[/yellow]'
+ f" [{WARN}].vscode/mcp.json left unchanged (not valid JSON; it may contain "
+ 'comments). Add a "repowise" server under "servers" manually.[/]'
)
try:
ext_path = save_vscode_extensions_config(repo_path)
- console_obj.print(f" [green]✓[/green] VS Code extension recommended ({ext_path})")
+ console_obj.print(f" [{OK}]✓[/] VS Code extension recommended ({ext_path})")
+ written.append(Path(ext_path))
except ValueError:
console_obj.print(
- " [yellow].vscode/extensions.json left unchanged (not valid JSON; it may "
+ f" [{WARN}].vscode/extensions.json left unchanged (not valid JSON; it may "
'contain comments). Add "repowise-dev.repowise" to "recommendations" '
- "manually.[/yellow]"
+ "manually.[/]"
)
+ return written
diff --git a/packages/cli/src/repowise/cli/editor_setup.py b/packages/cli/src/repowise/cli/editor_setup.py
index c0cd8aadb..51dfca83b 100644
--- a/packages/cli/src/repowise/cli/editor_setup.py
+++ b/packages/cli/src/repowise/cli/editor_setup.py
@@ -285,8 +285,29 @@ def write_editor_project_files(
options: EditorSetupOptions | None = None,
disabled_project_files: Iterable[str] | None = None,
integrations: tuple[InstallLifecycle, ...] | None = None,
-) -> None:
- """Write common MCP config and project-local editor files."""
+ no_editor_setup: bool = False,
+) -> list[Path]:
+ """Write project-local editor files. Returns the paths written.
+
+ **``--no-editor-setup`` now covers this too.** It used to gate only
+ :func:`register_editor_clients`, the *global* half — so a user who read the
+ flag as "leave my repo alone" still got ``.mcp.json``, ``.claude/CLAUDE.md``
+ and two ``.vscode`` files written into their working tree, and there was no
+ combination of flags that indexed a repo without writing into it (VS Code
+ had no opt-out flag at all). The flag's own help text admitted the gap
+ rather than closing it. Now one switch means one thing.
+
+ ``.repowise/mcp.json`` is written either way, and is the one deliberate
+ exception. It lives in the directory the index already occupies, no editor
+ reads it unless pointed at it, and it is what ``repowise mcp .`` prints —
+ the escape hatch this flag's own message sends people to. Skipping it would
+ mean opting out of editor setup also opted out of ever opting back in.
+
+ The return value is the manifest the completion panel prints. It is
+ collected from the integrations rather than hardcoded so the list cannot
+ drift from the writes: an integration that stops writing a file stops
+ reporting it in the same edit.
+ """
from repowise.cli.mcp_config import save_mcp_config
@@ -294,8 +315,42 @@ def write_editor_project_files(
resolved_options = options or EditorSetupOptions(
disabled_project_files=frozenset(disabled_project_files or ()),
)
+
+ if is_editor_setup_disabled(no_editor_setup):
+ _persist_project_file_optouts(repo_path, resolved_options)
+ return []
+
+ written: list[Path] = []
for integration in _resolve_integrations(integrations):
- integration.write_project_files(console_obj, repo_path, resolved_options)
+ # ``or []`` rather than a required return: an integration that has
+ # nothing to report is not a broken one, and this keeps the protocol
+ # widening backwards-compatible for any out-of-tree implementation.
+ written.extend(
+ integration.write_project_files(console_obj, repo_path, resolved_options) or []
+ )
+ return written
+
+
+def _persist_project_file_optouts(repo_path: Path, options: EditorSetupOptions) -> None:
+ """Record ``--no-claude-md`` / ``--no-agents-md`` even when nothing is written.
+
+ Those flags mean "never generate this file", not "skip it this once", and
+ the only thing that ever wrote them to ``config.yaml`` was the generator
+ itself on its way to declining. Skipping the integrations therefore also
+ skipped the memory of the opt-out, so ``init --no-editor-setup
+ --no-claude-md`` wrote nothing now and then let the next ``repowise update``
+ generate the file the user had just refused.
+
+ A preference is not a write, so it survives the switch that turns writes
+ off. This mirrors the carve-out ``--no-distill-hook`` already has, for the
+ same reason.
+ """
+ from repowise.cli.editor_files import set_editor_file_enabled
+
+ for file_id in sorted(options.disabled_project_files):
+ set_editor_file_enabled(repo_path, file_id, False)
+ for file_id, enabled in sorted(options.project_file_overrides.items()):
+ set_editor_file_enabled(repo_path, file_id, enabled)
def register_editor_clients(
diff --git a/packages/cli/src/repowise/cli/ui/__init__.py b/packages/cli/src/repowise/cli/ui/__init__.py
index bf144677d..b9200dc01 100644
--- a/packages/cli/src/repowise/cli/ui/__init__.py
+++ b/packages/cli/src/repowise/cli/ui/__init__.py
@@ -57,6 +57,7 @@ from repowise.cli.ui.result_panels import (
build_contextual_next_steps,
build_status_notes,
print_analysis_summary,
+ print_files_written,
)
from repowise.cli.ui.workspace_selection import (
interactive_primary_select,
@@ -98,6 +99,7 @@ __all__ = [
"mini",
"print_analysis_summary",
"print_banner",
+ "print_files_written",
"print_index_only_intro",
"print_phase_header",
"print_scan_summary",
diff --git a/packages/cli/src/repowise/cli/ui/result_panels.py b/packages/cli/src/repowise/cli/ui/result_panels.py
index 32bcd2f58..cdc79f10e 100644
--- a/packages/cli/src/repowise/cli/ui/result_panels.py
+++ b/packages/cli/src/repowise/cli/ui/result_panels.py
@@ -18,6 +18,7 @@ below it, where they were always supposed to live.
from __future__ import annotations
+from pathlib import Path
from typing import Any
from rich.console import Console, Group
@@ -237,3 +238,36 @@ def build_status_notes(setup: Any) -> list[str]:
notes.extend(f" [dim]{line}.[/dim]" for line in missing)
return notes
+
+
+def print_files_written(console: Console, repo_path: Path, paths: list[Path]) -> None:
+ """List what init wrote into the working tree, below the panel and dim.
+
+ Init writes editor and MCP config outside ``.repowise/`` — ``.mcp.json``,
+ ``.claude/CLAUDE.md``, the two ``.vscode`` files — and until this existed it
+ named none of them at the end of a run. The only trace was a green tick per
+ file, printed minutes earlier and scrolled away, so the first time most
+ people saw the list was in ``git status``.
+
+ Deliberately the quietest thing on the screen: it is a receipt, not a
+ result, and the reader who does not care should be able to skip it in one
+ glance. It is also the reason the note names ``--no-editor-setup`` — that
+ flag now genuinely writes none of this, so the sentence has somewhere to
+ send anyone who does not want the files.
+ """
+ if not paths:
+ return
+
+ relative: list[str] = []
+ for path in paths:
+ try:
+ relative.append(path.relative_to(repo_path).as_posix())
+ except ValueError:
+ relative.append(str(path))
+
+ console.print()
+ console.print(" [dim]Written to your repo (not gitignored): " + ", ".join(relative) + "[/dim]")
+ console.print(
+ " [dim]These wire your editor to the index. "
+ "[bold]repowise init --no-editor-setup[/bold] skips them.[/dim]"
+ )
diff --git a/tests/unit/cli/test_editor_setup.py b/tests/unit/cli/test_editor_setup.py
index f89aa9909..b258128ff 100644
--- a/tests/unit/cli/test_editor_setup.py
+++ b/tests/unit/cli/test_editor_setup.py
@@ -565,6 +565,10 @@ def test_write_editor_project_files_saves_common_mcp_before_integrations(
raise AssertionError("not used")
monkeypatch.setattr(mcp_config, "save_mcp_config", fake_save_mcp_config)
+ # conftest sets this suite-wide, and it now gates the project-local writes
+ # as well as the machine-wide registration. This test is about the dispatch
+ # loop, so it opts out the same way the other agent-target tests do.
+ monkeypatch.delenv("REPOWISE_SKIP_EDITOR_SETUP", raising=False)
write_editor_project_files(
_silent_console(),
@@ -607,6 +611,7 @@ def test_write_editor_project_files_uses_pre_resolved_options(
calls.append(("fake-project", repo_path, received_options))
monkeypatch.setattr(mcp_config, "save_mcp_config", fake_save_mcp_config)
+ monkeypatch.delenv("REPOWISE_SKIP_EDITOR_SETUP", raising=False)
write_editor_project_files(
_silent_console(),
@@ -1310,3 +1315,115 @@ def test_enable_tool_search_preserves_existing_settings(tmp_path: Path, monkeypa
data = json.loads(settings.read_text(encoding="utf-8"))
assert data["env"] == {"FOO": "bar", "ENABLE_TOOL_SEARCH": "true"}
assert data["mcpServers"] == {"repowise": {}}
+
+
+def test_no_editor_setup_writes_no_project_files(
+ tmp_path: Path,
+ monkeypatch: Any,
+) -> None:
+ """``--no-editor-setup`` now means what it says.
+
+ It used to gate only the machine-wide registration, so a run that asked to
+ be left alone still got `.mcp.json`, `.claude/CLAUDE.md` and two `.vscode`
+ files written into the working tree — and VS Code had no opt-out flag of its
+ own, so no combination of flags avoided it (issue #1499).
+ """
+ calls: list[str] = []
+
+ def fake_save_mcp_config(repo_path: Path) -> Path:
+ calls.append("mcp")
+ return repo_path / ".repowise" / "mcp.json"
+
+ class FakeIntegration:
+ integration_id = "fake"
+
+ def write_project_files(
+ self,
+ console_obj: object,
+ repo_path: Path,
+ options: EditorSetupOptions,
+ ) -> list[Path]:
+ calls.append("fake-project")
+ return [repo_path / "fake.json"]
+
+ monkeypatch.setattr(mcp_config, "save_mcp_config", fake_save_mcp_config)
+ monkeypatch.delenv("REPOWISE_SKIP_EDITOR_SETUP", raising=False)
+
+ written = write_editor_project_files(
+ _silent_console(),
+ tmp_path,
+ integrations=(FakeIntegration(),), # type: ignore[arg-type]
+ no_editor_setup=True,
+ )
+
+ assert written == []
+ # `.repowise/mcp.json` is the one deliberate exception: no editor reads it
+ # unless pointed at it, and it is what `repowise mcp .` prints, so skipping
+ # it would mean opting out of setup also opted out of opting back in.
+ assert calls == ["mcp"]
+
+
+def test_env_var_also_suppresses_project_files(
+ tmp_path: Path,
+ monkeypatch: Any,
+) -> None:
+ """``REPOWISE_SKIP_EDITOR_SETUP`` is documented as the same switch, so it
+ covers the same ground. Worth pinning because it is a live behaviour change
+ for any CI or benchmark harness that exports it: those runs now get no
+ project-local files either."""
+
+ class FakeIntegration:
+ integration_id = "fake"
+
+ def write_project_files(
+ self,
+ console_obj: object,
+ repo_path: Path,
+ options: EditorSetupOptions,
+ ) -> list[Path]:
+ raise AssertionError("integrations must not run when setup is skipped")
+
+ monkeypatch.setattr(mcp_config, "save_mcp_config", lambda p: p / ".repowise" / "mcp.json")
+ monkeypatch.setenv("REPOWISE_SKIP_EDITOR_SETUP", "1")
+
+ assert (
+ write_editor_project_files(
+ _silent_console(),
+ tmp_path,
+ integrations=(FakeIntegration(),), # type: ignore[arg-type]
+ )
+ == []
+ )
+
+
+def test_project_file_optouts_are_recorded_even_when_setup_is_off(
+ tmp_path: Path,
+ monkeypatch: Any,
+) -> None:
+ """``--no-editor-setup --no-claude-md`` still records the opt-out.
+
+ The flag means "never generate this file", not "skip it this run", and the
+ generator declining on its way past used to be the only thing that wrote the
+ preference down. Suppressing the writes without this would suppress the
+ memory of the refusal too, and the next ``repowise update`` would generate
+ the file the user had just refused.
+ """
+ from repowise.cli.helpers import load_config
+
+ (tmp_path / ".repowise").mkdir(parents=True, exist_ok=True)
+ monkeypatch.setattr(mcp_config, "save_mcp_config", lambda p: p / ".repowise" / "mcp.json")
+
+ write_editor_project_files(
+ _silent_console(),
+ tmp_path,
+ options=EditorSetupOptions(
+ disabled_project_files=frozenset({"claude_md"}),
+ project_file_overrides={"agents_md": False},
+ ),
+ integrations=(),
+ no_editor_setup=True,
+ )
+
+ editor_files = load_config(tmp_path).get("editor_files", {})
+ assert editor_files.get("claude_md") is False
+ assert editor_files.get("agents_md") is False