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(doctor): note a Claude Code MCP entry that serves another repo (#3649)

Swati Ahuja81da424eac2d
diff --git a/packages/cli/src/repowise/cli/agent_targets/targets/claude_code.py b/packages/cli/src/repowise/cli/agent_targets/targets/claude_code.py
index 4d8906a81..fc21af9b4 100644
--- a/packages/cli/src/repowise/cli/agent_targets/targets/claude_code.py
+++ b/packages/cli/src/repowise/cli/agent_targets/targets/claude_code.py
@@ -541,7 +541,7 @@ class ClaudeCodeTarget:
paths.append(str(desktop))
return paths
- def doctor(self) -> DoctorReport:
+ def doctor(self, repo_path: Path | None = None) -> DoctorReport:
"""Health of the Claude Code wiring, with one command to fix it.
Reports a stale rewrite-hook matcher explicitly. An entry whose matcher
diff --git a/packages/cli/src/repowise/cli/agent_targets/targets/codex.py b/packages/cli/src/repowise/cli/agent_targets/targets/codex.py
index a831ffd0e..f9f37f5d5 100644
--- a/packages/cli/src/repowise/cli/agent_targets/targets/codex.py
+++ b/packages/cli/src/repowise/cli/agent_targets/targets/codex.py
@@ -1188,7 +1188,7 @@ class CodexTarget:
str(instructions_path(repo)),
]
- def doctor(self) -> DoctorReport:
+ def doctor(self, repo_path: Path | None = None) -> DoctorReport:
"""Health of the Codex wiring.
The stale-matcher case matters more here than anywhere else: Codex is
diff --git a/packages/cli/src/repowise/cli/agent_targets/targets/copilot.py b/packages/cli/src/repowise/cli/agent_targets/targets/copilot.py
index 569c3945a..a6754d1f6 100644
--- a/packages/cli/src/repowise/cli/agent_targets/targets/copilot.py
+++ b/packages/cli/src/repowise/cli/agent_targets/targets/copilot.py
@@ -279,7 +279,7 @@ class CopilotTarget:
return [str(mcp_config_path())]
return [str(vscode.instructions_path(repo_path or Path.cwd()))]
- def doctor(self) -> DoctorReport:
+ def doctor(self, repo_path: Path | None = None) -> DoctorReport:
"""User-scope health; the project block needs a repo to check."""
from ..formats.json_merge import load_json_object_or_value_error
diff --git a/packages/cli/src/repowise/cli/agent_targets/targets/cursor.py b/packages/cli/src/repowise/cli/agent_targets/targets/cursor.py
index b4fb7067d..74925b67e 100644
--- a/packages/cli/src/repowise/cli/agent_targets/targets/cursor.py
+++ b/packages/cli/src/repowise/cli/agent_targets/targets/cursor.py
@@ -536,11 +536,11 @@ class CursorTarget:
repo = repo_path or Path.cwd()
return [str(mcp_config_path(repo)), str(rules_path(repo))]
- def doctor(self) -> DoctorReport:
+ def doctor(self, repo_path: Path | None = None) -> DoctorReport:
"""Health of the one user-level surface, the rewrite hook.
- The MCP config and rules file are workspace-local and ``doctor()`` takes
- no repo path, so they are not judged here.
+ The MCP config and rules file are workspace-local, so they are not
+ judged here.
"""
from repowise.cli.agent_adapters.cursor import cursor_rewrite_hook_matcher, user_hooks_path
diff --git a/packages/cli/src/repowise/cli/agent_targets/targets/hermes.py b/packages/cli/src/repowise/cli/agent_targets/targets/hermes.py
index 1ee0ec997..9a4375001 100644
--- a/packages/cli/src/repowise/cli/agent_targets/targets/hermes.py
+++ b/packages/cli/src/repowise/cli/agent_targets/targets/hermes.py
@@ -989,11 +989,13 @@ class HermesTarget:
return [str(config_path())]
return [str(instructions_path(repo_path or Path.cwd()))]
- def doctor(self) -> DoctorReport:
- """User-scope health, which is the only half a bare call can see.
+ def doctor(self, repo_path: Path | None = None) -> DoctorReport:
+ """User-scope health. The repo's ``AGENTS.md`` block only counts with it.
- ``doctor()`` takes no repo path, so the repo's ``AGENTS.md`` is out of
- reach and reporting on its behalf would be a claim nothing checked.
+ The MCP entry is what makes repowise reachable at all (see ``detect``),
+ so with *repo_path* an unwired user scope is the whole answer. A wired
+ one stays OK without the block, since the server still resolves the
+ repo it is launched in; the missing instructions are noted instead.
An unreadable config **is** reported as ``BROKEN`` here, which is where
this differs from OpenCode. That target declines to call an unparseable
@@ -1005,7 +1007,18 @@ class HermesTarget:
"""
path = config_path()
if _reads_repowise():
- return DoctorReport(target_id=ID, status=DoctorStatus.OK)
+ if repo_path is None or any(r.scope is Scope.PROJECT for r in detect(repo_path)):
+ return DoctorReport(target_id=ID, status=DoctorStatus.OK)
+ return DoctorReport(
+ target_id=ID,
+ status=DoctorStatus.OK,
+ # An OK row prints only its issue, so the remedy lives in it.
+ issues=(
+ f"{instructions_path(repo_path)} has no repowise block, so Hermes "
+ "is not told to use repowise in this repo (run: repowise agents "
+ "add --target=hermes --scope=project).",
+ ),
+ )
if path.exists() and not _parses(path):
return DoctorReport(
@@ -1026,7 +1039,9 @@ class HermesTarget:
target_id=ID,
status=DoctorStatus.NOT_INSTALLED,
issues=(
- "Hermes is not wired at user scope; the managed AGENTS.md block is "
+ "Hermes is not wired at user scope."
+ if repo_path is not None
+ else "Hermes is not wired at user scope; the managed AGENTS.md block is "
"repo-local, so run this from a repo to check that half.",
),
fix_command="repowise agents add --target=hermes",
diff --git a/packages/cli/src/repowise/cli/agent_targets/targets/kiro.py b/packages/cli/src/repowise/cli/agent_targets/targets/kiro.py
index fe577b9b5..5ded27a59 100644
--- a/packages/cli/src/repowise/cli/agent_targets/targets/kiro.py
+++ b/packages/cli/src/repowise/cli/agent_targets/targets/kiro.py
@@ -283,12 +283,12 @@ class KiroTarget:
repo = repo_path or Path.cwd()
return [str(mcp_config_path(scope, repo)), str(steering_path(scope, repo))]
- def doctor(self) -> DoctorReport:
- """User-scope health; the workspace half needs a repo to check."""
+ def doctor(self, repo_path: Path | None = None) -> DoctorReport:
+ """User-scope health, plus the workspace half when *repo_path* is given."""
from ..formats.json_merge import load_json_object_or_value_error
path = mcp_config_path(Scope.USER)
- if _reads_repowise(path):
+ if detect(repo_path):
return DoctorReport(target_id=ID, status=DoctorStatus.OK)
if path.exists():
try:
@@ -305,7 +305,9 @@ class KiroTarget:
target_id=ID,
status=DoctorStatus.NOT_INSTALLED,
issues=(
- "Kiro is not wired at user scope; workspace wiring is repo-local, "
+ "Kiro is not wired at user scope or in this repo."
+ if repo_path is not None
+ else "Kiro is not wired at user scope; workspace wiring is repo-local, "
"so run this from a repo to check that half.",
),
fix_command="repowise agents add --target=kiro",
diff --git a/packages/cli/src/repowise/cli/agent_targets/targets/opencode.py b/packages/cli/src/repowise/cli/agent_targets/targets/opencode.py
index 7c4457643..1df076d56 100644
--- a/packages/cli/src/repowise/cli/agent_targets/targets/opencode.py
+++ b/packages/cli/src/repowise/cli/agent_targets/targets/opencode.py
@@ -756,14 +756,14 @@ class OpenCodeTarget:
str(instructions_path(scope, repo)),
]
- def doctor(self) -> DoctorReport:
- """User-scope health, which is the only half a bare call can see.
+ def doctor(self, repo_path: Path | None = None) -> DoctorReport:
+ """User-scope health, plus the project config when *repo_path* is given.
- ``doctor()`` takes no repo path, so the project config is out of reach
- and reporting ``OK`` on its behalf would be a claim nothing checked.
- Unlike Cursor and VS Code there *is* something user-level to look at, so
- a wired user config is reported as wired and the repo-scoped half is
- named as the part still unchecked.
+ Without a repo path the project config is out of reach and reporting
+ ``OK`` on its behalf would be a claim nothing checked. Unlike Cursor and
+ VS Code there *is* something user-level to look at, so a wired user
+ config is reported as wired and the repo-scoped half is named as the
+ part still unchecked.
**An unparseable config is never reported as BROKEN here**, which is
where this differs from every other target. ``BROKEN`` fails the whole
@@ -781,7 +781,7 @@ class OpenCodeTarget:
# in the listing and not-installed here, and the fix command printed
# here then wrote a second entry into the other file.
candidates = config_paths(Scope.USER)
- if any(path.exists() and _reads_repowise(path) for path in candidates):
+ if detect(repo_path):
return DoctorReport(target_id=ID, status=DoctorStatus.OK)
unreadable = [
@@ -810,7 +810,9 @@ class OpenCodeTarget:
target_id=ID,
status=DoctorStatus.NOT_INSTALLED,
issues=(
- "OpenCode is not wired at user scope; workspace wiring is repo-local, "
+ "OpenCode is not wired at user scope or in this repo."
+ if repo_path is not None
+ else "OpenCode is not wired at user scope; workspace wiring is repo-local, "
"so run this from a repo to check that half.",
),
fix_command="repowise agents add --target=opencode",
diff --git a/packages/cli/src/repowise/cli/agent_targets/targets/vscode.py b/packages/cli/src/repowise/cli/agent_targets/targets/vscode.py
index 4474a0a23..d623f2bda 100644
--- a/packages/cli/src/repowise/cli/agent_targets/targets/vscode.py
+++ b/packages/cli/src/repowise/cli/agent_targets/targets/vscode.py
@@ -476,17 +476,24 @@ class VSCodeTarget:
str(instructions_path(repo)),
]
- def doctor(self) -> DoctorReport:
- """Health is repo-scoped, so a bare call can only report the honest answer.
+ def doctor(self, repo_path: Path | None = None) -> DoctorReport:
+ """Health is repo-scoped, so only a call with *repo_path* can say OK.
Without a repo path there is nothing user-level to inspect. Reporting
``OK`` would be a claim we have not checked, so this reports
not-installed with the command that would wire it.
"""
+ if repo_path is not None and detect(repo_path):
+ return DoctorReport(target_id=ID, status=DoctorStatus.OK)
+ issue = (
+ "VS Code is not wired in this repo."
+ if repo_path is not None
+ else "VS Code wiring is workspace-local; run this from a repo to check it."
+ )
return DoctorReport(
target_id=ID,
status=DoctorStatus.NOT_INSTALLED,
- issues=("VS Code wiring is workspace-local; run this from a repo to check it.",),
+ issues=(issue,),
fix_command="repowise init",
)
diff --git a/packages/cli/src/repowise/cli/agent_targets/types.py b/packages/cli/src/repowise/cli/agent_targets/types.py
index b4f3f97b1..7180a130b 100644
--- a/packages/cli/src/repowise/cli/agent_targets/types.py
+++ b/packages/cli/src/repowise/cli/agent_targets/types.py
@@ -379,8 +379,11 @@ class AgentTarget(Protocol):
"""
...
- def doctor(self) -> DoctorReport:
- """This target's health, with one command that would fix it."""
+ def doctor(self, repo_path: Path | None = None) -> DoctorReport:
+ """This target's health, with one command that would fix it.
+
+ *repo_path* lets a target with repo-local wiring check that half too.
+ """
...
diff --git a/packages/cli/src/repowise/cli/commands/doctor_cmd/repo_checks.py b/packages/cli/src/repowise/cli/commands/doctor_cmd/repo_checks.py
index df1da3ce3..131aa6bc9 100644
--- a/packages/cli/src/repowise/cli/commands/doctor_cmd/repo_checks.py
+++ b/packages/cli/src/repowise/cli/commands/doctor_cmd/repo_checks.py
@@ -730,7 +730,7 @@ def _run_repo_checks(
checks.extend(_distill_checks(repo_path))
# 12. Claude Code MCP registration: wedged-path detection
- registration_check, registration_wedged = _claude_registration_check()
+ registration_check, registration_wedged = _claude_registration_check(repo_path)
checks.append(registration_check)
# 12b. Does that registration actually start? Reported separately, because
@@ -739,7 +739,7 @@ def _run_repo_checks(
checks.append(_mcp_responds_check())
# 13. Per-agent health, reported by each agent's own descriptor
- agent_checks, agents_need_refresh = _agent_target_checks()
+ agent_checks, agents_need_refresh = _agent_target_checks(repo_path)
checks.extend(agent_checks)
all_ok = all(c.ok for c in checks)
@@ -993,7 +993,9 @@ def _run_repo_checks(
return all_ok, checks
-def _agent_target_checks() -> tuple[list[DoctorCheck], bool]:
+def _agent_target_checks(
+ repo_path: _DoctorPath | None = None,
+) -> tuple[list[DoctorCheck], bool]:
"""One row per agent, reported by that agent's own descriptor.
Nothing here knows what any particular agent's health means: each
@@ -1032,7 +1034,7 @@ def _agent_target_checks() -> tuple[list[DoctorCheck], bool]:
for target in targets:
name = f"Agent: {target.id}"
try:
- report = target.doctor()
+ report = target.doctor(repo_path=repo_path)
except Exception as exc:
checks.append(_check(name, True, f"Could not check: {exc}"))
continue
@@ -1120,7 +1122,9 @@ def _mcp_responds_check() -> DoctorCheck:
return _check(CHECK_NAME, True, f"Could not check: {exc}")
-def _claude_registration_check() -> tuple[DoctorCheck, bool]:
+def _claude_registration_check(
+ repo_path: _DoctorPath | None = None,
+) -> tuple[DoctorCheck, bool]:
"""Detect a wedged Claude Code MCP registration (stale paths).
The global ``~/.claude/settings.json`` entry can end up pointing at a
@@ -1130,6 +1134,11 @@ def _claude_registration_check() -> tuple[DoctorCheck, bool]:
``(check, wedged)``; ``wedged`` drives the ``--repair`` re-registration.
Absence of a registration is informational, never a failure.
+ With *repo_path*, an entry serving a different repo gets an advisory note
+ unless another Claude Code scope registers this repo. Advisory because the
+ entry is not broken, and never repaired: repointing the one global entry
+ would break the repo it serves.
+
This is a *static* check. Whether the server actually starts is
``_mcp_responds_check``.
"""
@@ -1154,11 +1163,84 @@ def _claude_registration_check() -> tuple[DoctorCheck, bool]:
problems.append(f"registered path missing: {target}")
if problems:
return _check(name, False, "; ".join(problems) + " (rerun with --repair)"), True
+ if target is not None and repo_path is not None and not _registers_repo(target, repo_path):
+ detail = (
+ f"serves {target}; this repo is not registered (run `repowise agents add "
+ "--target=claude-code --scope=project` for a project entry)"
+ )
+ return _check(name, True, detail), False
return _check(name, True, target or "registered"), False
except Exception as exc:
return _check(name, True, f"Could not check: {exc}"), False
+def _registers_repo(target: str, repo_path: _DoctorPath) -> bool:
+ """Whether Claude Code serves *repo_path* from the global entry or another scope.
+
+ The global *target* counts when it is what init registers for this repo
+ (the workspace root inside a workspace). Otherwise a repowise entry naming
+ this repo in ``.mcp.json`` (project scope) or ``~/.claude.json`` (user or
+ local scope) counts; one copied from another repo does not.
+ """
+ from repowise.cli.agent_targets.targets.claude_code import project_mcp_config_path
+ from repowise.cli.editor_integrations.claude_config import (
+ _resolve_mcp_target,
+ _stored_repowise_entry,
+ )
+ from repowise.cli.helpers import _same_path
+
+ served = (repo_path, _resolve_mcp_target(repo_path))
+
+ def serves(path: str) -> bool:
+ # Claude Code starts a project server in the repo, so a relative path
+ # is relative to it.
+ return any(_same_path(repo_path / path, s) for s in served)
+
+ def names_repo(entry: object) -> bool:
+ path = _registration_target(entry) if isinstance(entry, dict) else None
+ return path is not None and serves(path)
+
+ if serves(target):
+ return True
+ other_scopes = [
+ _stored_repowise_entry(project_mcp_config_path(repo_path)),
+ *_claude_json_entries(repo_path),
+ ]
+ return any(names_repo(e) for e in other_scopes)
+
+
+def _claude_json_entries(repo_path: _DoctorPath) -> list[object]:
+ """Repowise entries in ``~/.claude.json``: user scope, then this repo's local scope.
+
+ Read here only, best effort: an unreadable file yields nothing, so the
+ worst case is the advisory note above.
+ """
+ import json
+
+ from repowise.cli.helpers import _same_path
+
+ try:
+ data = json.loads((_DoctorPath.home() / ".claude.json").read_text(encoding="utf-8"))
+ except (OSError, ValueError):
+ return []
+ if not isinstance(data, dict):
+ return []
+ scopes = [data]
+ projects = data.get("projects")
+ if isinstance(projects, dict):
+ scopes += [
+ v
+ for k, v in projects.items()
+ if isinstance(v, dict) and _same_path(_DoctorPath(k), repo_path)
+ ]
+ entries: list[object] = []
+ for scope in scopes:
+ servers = scope.get("mcpServers")
+ if isinstance(servers, dict) and "repowise" in servers:
+ entries.append(servers["repowise"])
+ return entries
+
+
def _registration_target(entry: dict) -> str | None:
"""The repo/workspace path a registration serves, or None if unrecognized.
diff --git a/tests/unit/cli/test_agent_targets.py b/tests/unit/cli/test_agent_targets.py
index 6f79eb556..81cbd9116 100644
--- a/tests/unit/cli/test_agent_targets.py
+++ b/tests/unit/cli/test_agent_targets.py
@@ -3745,3 +3745,79 @@ def test_removing_vscode_and_copilot_together_leaves_no_file(tmp_path: Path) ->
get_target("copilot").uninstall(Scope.PROJECT, repo_path=repo)
assert not _copilot_instructions(repo).exists()
+
+
+# ---------------------------------------------------------------------------
+# doctor(repo_path): repo-local wiring is checked when doctor runs in a repo
+# ---------------------------------------------------------------------------
+
+
+def test_vscode_doctor_checks_the_repo_it_is_given(tmp_path: Path) -> None:
+ target = get_target("vscode")
+ repo = tmp_path / "repo"
+ repo.mkdir()
+
+ report = target.doctor(repo_path=repo)
+ assert report.status is DoctorStatus.NOT_INSTALLED
+ assert "run this from a repo" not in report.issues[0]
+
+ target.install(Scope.PROJECT, repo_path=repo)
+ assert target.doctor(repo_path=repo).status is DoctorStatus.OK
+
+
+def test_kiro_doctor_counts_the_repo_wiring(tmp_path: Path) -> None:
+ kiro = _kiro()
+ repo = tmp_path / "repo"
+ repo.mkdir()
+
+ report = kiro.TARGET.doctor(repo_path=repo)
+ assert report.status is DoctorStatus.NOT_INSTALLED
+ assert "run this from a repo" not in report.issues[0]
+
+ kiro.TARGET.install(Scope.PROJECT, repo_path=repo)
+ assert kiro.TARGET.doctor(repo_path=repo).status is DoctorStatus.OK
+ assert kiro.TARGET.doctor().status is DoctorStatus.NOT_INSTALLED
+
+
+def test_opencode_doctor_counts_the_repo_wiring(tmp_path: Path, monkeypatch) -> None:
+ opencode = _opencode()
+ monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path / "xdg"))
+ repo = tmp_path / "repo"
+ repo.mkdir()
+
+ report = opencode.TARGET.doctor(repo_path=repo)
+ assert report.status is DoctorStatus.NOT_INSTALLED
+ assert "run this from a repo" not in report.issues[0]
+
+ opencode.TARGET.install(Scope.PROJECT, repo_path=repo)
+ assert opencode.TARGET.doctor(repo_path=repo).status is DoctorStatus.OK
+ assert opencode.TARGET.doctor().status is DoctorStatus.NOT_INSTALLED
+
+
+def test_hermes_doctor_in_a_repo_does_not_ask_to_be_run_from_one(
+ hermes_home: Path, tmp_path: Path
+) -> None:
+ target = get_target("hermes")
+ report = target.doctor(repo_path=tmp_path)
+ assert report.status is DoctorStatus.NOT_INSTALLED
+ assert report.issues == ("Hermes is not wired at user scope.",)
+
+
+def test_hermes_doctor_in_a_repo_notes_a_missing_instructions_block(
+ hermes_home: Path, tmp_path: Path
+) -> None:
+ target = get_target("hermes")
+ repo = tmp_path / "repo"
+ repo.mkdir()
+ target.install(Scope.USER)
+
+ # User scope alone stays the bare-call answer.
+ assert target.doctor().issues == ()
+
+ report = target.doctor(repo_path=repo)
+ assert report.status is DoctorStatus.OK
+ assert "has no repowise block" in report.issues[0]
+ assert "repowise agents add --target=hermes --scope=project" in report.issues[0]
+
+ target.install(Scope.PROJECT, repo_path=repo)
+ assert target.doctor(repo_path=repo).issues == ()
diff --git a/tests/unit/cli/test_doctor_registration.py b/tests/unit/cli/test_doctor_registration.py
index aa47a08a8..60faf560c 100644
--- a/tests/unit/cli/test_doctor_registration.py
+++ b/tests/unit/cli/test_doctor_registration.py
@@ -106,3 +106,103 @@ def test_registration_target_extraction(tmp_path: Path) -> None:
assert _registration_target({"args": "mcp"}) is None
assert _registration_target({}) is None
assert _registration_target({"args": ["mcp", "--transport", "stdio"]}) is None
+
+
+def test_entry_serving_another_repo_is_advisory(tmp_path: Path) -> None:
+ # Not broken state, so it must not fail the run; and doctor never
+ # repoints the one global entry.
+ other, repo = tmp_path / "other", tmp_path / "repo"
+ other.mkdir()
+ repo.mkdir()
+ _write_settings(_entry(other))
+ check, wedged = _claude_registration_check(repo)
+ assert check.ok is True
+ assert wedged is False
+ assert f"serves {other}; this repo is not registered" in check.detail
+ assert "repowise agents add --target=claude-code --scope=project" in check.detail
+
+
+def test_entry_serving_this_repo_is_ok(tmp_path: Path) -> None:
+ repo = tmp_path / "repo"
+ repo.mkdir()
+ _write_settings(_entry(repo))
+ check, _ = _claude_registration_check(repo)
+ assert check.ok is True
+ assert "not registered" not in check.detail
+
+
+def test_project_mcp_json_covers_a_global_entry_elsewhere(tmp_path: Path) -> None:
+ other, repo = tmp_path / "other", tmp_path / "repo"
+ other.mkdir()
+ repo.mkdir()
+ _write_settings(_entry(other))
+ (repo / ".mcp.json").write_text(
+ json.dumps({"mcpServers": {"repowise": _entry(repo)}}), encoding="utf-8"
+ )
+ check, _ = _claude_registration_check(repo)
+ assert check.ok is True
+ assert "not registered" not in check.detail
+
+
+def test_workspace_entry_covers_its_member_repos(tmp_path: Path) -> None:
+ workspace = tmp_path / "ws"
+ repo = workspace / "repo"
+ repo.mkdir(parents=True)
+ (workspace / ".repowise-workspace.yaml").write_text("repos: []\n", encoding="utf-8")
+ _write_settings(_entry(workspace))
+ check, _ = _claude_registration_check(repo)
+ assert check.ok is True
+ assert "not registered" not in check.detail
+
+
+def _write_project_entry(repo: Path, target: Path | str) -> None:
+ (repo / ".mcp.json").write_text(
+ json.dumps({"mcpServers": {"repowise": _entry(target)}}), encoding="utf-8"
+ )
+
+
+def test_project_mcp_json_copied_from_another_repo_does_not_count(tmp_path: Path) -> None:
+ other, repo = tmp_path / "other", tmp_path / "repo"
+ other.mkdir()
+ repo.mkdir()
+ _write_settings(_entry(other))
+ _write_project_entry(repo, other)
+ check, _ = _claude_registration_check(repo)
+ assert check.ok is True
+ assert "this repo is not registered" in check.detail
+
+
+def test_relative_project_entry_counts(tmp_path: Path) -> None:
+ other, repo = tmp_path / "other", tmp_path / "repo"
+ other.mkdir()
+ repo.mkdir()
+ _write_settings(_entry(other))
+ _write_project_entry(repo, ".")
+ check, _ = _claude_registration_check(repo)
+ assert "not registered" not in check.detail
+
+
+def test_local_scope_entry_in_claude_json_counts(tmp_path: Path) -> None:
+ other, repo = tmp_path / "other", tmp_path / "repo"
+ other.mkdir()
+ repo.mkdir()
+ _write_settings(_entry(other))
+ (Path.home() / ".claude.json").write_text(
+ json.dumps({"projects": {str(repo): {"mcpServers": {"repowise": _entry(repo)}}}}),
+ encoding="utf-8",
+ )
+ check, _ = _claude_registration_check(repo)
+ assert "not registered" not in check.detail
+
+
+def test_local_scope_entry_for_another_repo_does_not_count(tmp_path: Path) -> None:
+ other, repo = tmp_path / "other", tmp_path / "repo"
+ other.mkdir()
+ repo.mkdir()
+ _write_settings(_entry(other))
+ (Path.home() / ".claude.json").write_text(
+ json.dumps({"projects": {str(other): {"mcpServers": {"repowise": _entry(repo)}}}}),
+ encoding="utf-8",
+ )
+ check, _ = _claude_registration_check(repo)
+ assert "this repo is not registered" in check.detail