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
feat(agents): add GitHub Copilot CLI and Kiro targets, Copilot instructions for VS Code (#3173)
Raghav Chamadiyac8d3caa03df3
diff --git a/README.md b/README.mdindex d078e193b..e6f49f133 100644--- a/README.md+++ b/README.md@@ -527,7 +527,7 @@ languages moving up the ladder: **[roadmap →](ROADMAP.md#languages)**## Supported agents and editors-**Six agents wired end to end · two at the Full tier · every other MCP host one+**Eight agents wired end to end · two at the Full tier · every other MCP host onepaste away.**<p>@@ -537,13 +537,12 @@ paste away.**</p><p><strong>Good tier </strong>+ <img src="https://img.shields.io/badge/VS_Code-007ACC?style=flat-square&logo=visualstudiocode&logoColor=white" alt="VS Code" /><img src="https://img.shields.io/badge/Cursor-000000?style=flat-square&logo=cursor&logoColor=white" alt="Cursor" /><img src="https://img.shields.io/badge/OpenCode-000000?style=flat-square&logo=opencode&logoColor=white" alt="OpenCode" /><img src="https://img.shields.io/badge/Hermes-000000?style=flat-square&logoColor=white" alt="Hermes" />-</p>-<p>- <strong>Basic tier </strong>- <img src="https://img.shields.io/badge/VS_Code-007ACC?style=flat-square&logo=visualstudiocode&logoColor=white" alt="VS Code" />+ <img src="https://img.shields.io/badge/GitHub_Copilot_CLI-000000?style=flat-square&logo=githubcopilot&logoColor=white" alt="GitHub Copilot CLI" />+ <img src="https://img.shields.io/badge/Kiro-790ECB?style=flat-square&logoColor=white" alt="Kiro" /></p>**Full** is every surface Repowise has: MCP tools, skills, slash commands, a manageddiff --git a/docs/agent/INTEGRATIONS.md b/docs/agent/INTEGRATIONS.mdindex f5be9b10f..881b1e5b3 100644--- a/docs/agent/INTEGRATIONS.md+++ b/docs/agent/INTEGRATIONS.md@@ -31,16 +31,18 @@ example). It is separate from the tier: it says nothing about the session.|---|---|---|---|---|---|---|---|---|| [Claude Code](https://docs.claude.com/en/docs/claude-code) | Full | Yes | Yes | Plugin | Plugin | Yes | Yes | Yes || [Codex CLI](https://developers.openai.com/codex/cli) | Full | Yes | Yes | Plugin | Yes | Yes | Yes | Yes |-| [VS Code](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) | Basic | Yes | No | No | No | No | No | No |+| [VS Code](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) | Good | Yes | No | No | No | Yes | No | No || [Cursor](https://cursor.com/docs/context/mcp) | Good | Yes | No | No | No | Yes | No | No || [OpenCode](https://opencode.ai/docs/mcp-servers/) | Good | Yes | No | No | No | Yes | No | Yes || [Hermes](https://hermes-agent.nousresearch.com/docs/user-guide/features/mcp) | Good | Yes | No | No | No | Yes | No | No |+| [GitHub Copilot CLI](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference) | Good | Yes | No | No | No | Yes | No | No |+| [Kiro](https://kiro.dev/docs/mcp/configuration) | Good | Yes | No | No | No | Yes | No | No |-Target ids for `--target=`: `claude-code`, `codex`, `vscode`, `cursor`, `opencode`, `hermes`.+Target ids for `--target=`: `claude-code`, `codex`, `vscode`, `cursor`, `opencode`, `hermes`, `copilot`, `kiro`.### What Good tier does not include-Cursor, OpenCode and Hermes sit at Good, and the honest version of that is worth stating+VS Code, Cursor, OpenCode, Hermes, GitHub Copilot CLI and Kiro sit at Good, and the honest version of that is worth statingplainly. These agents get the MCP tools and the config repowise writes.They do **not** get hook-level interception: repowise never sees a toolcall before it runs, never rewrites a noisy command, and never annotates@@ -51,12 +53,6 @@ That is a real integration and it is most of the value. It is not thesame product Full-tier agents get, and breadth that overclaims depth isworse than narrower breadth.-### Basic tier--VS Code sits at Basic. repowise writes-no instructions file or skills there, so the MCP tools are reachable but-nothing tells the agent when to use them.-## Paste-configEvery other MCP host is served without writing a descriptor for it. Printdiff --git a/docs/agent/VSCODE.md b/docs/agent/VSCODE.mdindex ca8682932..dcd5c3b95 100644--- a/docs/agent/VSCODE.md+++ b/docs/agent/VSCODE.md@@ -104,12 +104,15 @@ dark.One install registers the Repowise MCP server with VS Code, so agent-modeassistants query the index through purpose-built tools instead of guessing fromopen files. For editors that read a config file, run **Repowise: Configure MCP-for this Workspace** to write `.vscode/mcp.json`.+for this Workspace** to write `.vscode/mcp.json`. `repowise init` and+`repowise agents add --target=vscode` also add a managed section to <!-- repowise-drift-ignore -->+`.github/copilot-instructions.md`, which Copilot Chat reads on every request.+Your own text in that file is kept; `repowise agents remove` takes out only the+managed section.-VS Code sits at the **Basic** support tier, and the honest version of that is+VS Code sits at the **Good** support tier, and the honest version of that isworth knowing before you compare it to the Claude Code or Codex setup. You get-the MCP tools and the config to reach them, but no managed instructions file or-skills telling the agent when to use them. You do not get hook-level+the MCP tools, the config to reach them and the managed instructions. You do not get hook-levelinterception: repowise never sees a tool call before it runs, never rewrites anoisy command, and never annotates a result afterwards, and there is notranscript mining after the session. What the extension itself surfaces in thediff --git a/packages/cli/src/repowise/cli/agent_targets/registry.py b/packages/cli/src/repowise/cli/agent_targets/registry.pyindex cd983ebae..c67e083bd 100644--- a/packages/cli/src/repowise/cli/agent_targets/registry.py+++ b/packages/cli/src/repowise/cli/agent_targets/registry.py@@ -34,6 +34,8 @@ _TARGET_MODULES: dict[str, str] = {"cursor": "repowise.cli.agent_targets.targets.cursor:TARGET","opencode": "repowise.cli.agent_targets.targets.opencode:TARGET","hermes": "repowise.cli.agent_targets.targets.hermes:TARGET",+ "copilot": "repowise.cli.agent_targets.targets.copilot:TARGET",+ "kiro": "repowise.cli.agent_targets.targets.kiro:TARGET",}#: Resolved when :meth:`resolve_target_flag` is asked for ``auto`` and nothingdiff --git a/packages/cli/src/repowise/cli/agent_targets/targets/copilot.py b/packages/cli/src/repowise/cli/agent_targets/targets/copilot.pynew file mode 100644index 000000000..569c3945a--- /dev/null+++ b/packages/cli/src/repowise/cli/agent_targets/targets/copilot.py@@ -0,0 +1,308 @@+"""GitHub Copilot CLI as an agent target.++Good tier: MCP plus the managed instructions block, no hook or transcript+adapter yet.++Host facts, each checked against the source named beside it:++* MCP lives in ``~/.copilot/mcp-config.json`` (``$COPILOT_HOME`` overrides the+ directory) under ``mcpServers``; the entry is+ ``{"type": "stdio", "command", "args", "tools": ["*"]}``.+ https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference+* There is no project-local MCP file (github/copilot-cli#2528), so the one+ user entry names no repo and the server resolves the repo it is launched in.+ Assumed, not documented: the CLI starts MCP servers in the session's cwd.+* The CLI reads ``.github/copilot-instructions.md``, the file the ``vscode``+ target already manages, so project scope shares that block rather than+ writing a second file (same reference page), plus an empty marker pair that+ records Copilot CLI as one of the block's owners.+* VS Code also writes into ``~/.copilot`` (``ide/``, skills, agents, hooks), so+ only the ``copilot`` binary counts as an install (codegraph ``copilot-cli.ts``,+ codebase-memory-mcp ``cli.c``).+"""++from __future__ import annotations++import contextlib+import json+import os+from pathlib import Path++from repowise.core.agents import identity++from ..formats.server_entry import RemoteServerEntryError+from ..types import (+ Capability,+ DoctorReport,+ DoctorStatus,+ FileAction,+ FileWrite,+ InstallMethod,+ Registration,+ Scope,+ WriteResult,+)+from . import vscode++IDENTITY = identity.COPILOT+ID = IDENTITY.cli_target_id+DISPLAY_NAME = IDENTITY.display_name+DOCS_URL = (+ "https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference"+)++#: Same switch as VS Code, because it is the same project file.+PROJECT_FILE_ID = vscode.PROJECT_FILE_ID++SERVER_NAME = "repowise"++METHODS = (+ InstallMethod(+ id="direct",+ provides=frozenset({Capability.MCP, Capability.INSTRUCTIONS}),+ managed_by="repowise",+ preferred=True,+ ),+)+++def config_dir() -> Path:+ """``$COPILOT_HOME`` when set and not blank, else ``~/.copilot``."""+ configured = (os.environ.get("COPILOT_HOME") or "").strip()+ return Path(configured).expanduser() if configured else Path.home() / ".copilot"+++def mcp_config_path() -> Path:+ return config_dir() / "mcp-config.json"+++def server_entry() -> dict:+ """The user-scope entry: pinned binary, no repo path (see module docstring)."""+ from repowise.cli.mcp_config import resolve_repowise_command++ return {+ "type": "stdio",+ "command": resolve_repowise_command(),+ "args": ["mcp", "--transport", "stdio"],+ }+++def write_mcp_config() -> FileWrite:+ """Merge our entry into ``mcp-config.json``, keeping sibling servers.++ ``tools`` is seeded only on a new entry: a user who narrowed it chose to.+ Raises ``ValueError`` for a file that is not a JSON object.+ """+ from ..formats.json_merge import load_json_object_or_value_error, write_json_config+ from ..formats.server_entry import is_remote_entry++ path = mcp_config_path()+ existing = load_json_object_or_value_error(path, path.name) if path.exists() else {}+ servers = existing.get("mcpServers", {})+ if not isinstance(servers, dict):+ raise ValueError(f"{path.name} 'mcpServers' must be a JSON object")+ stored = servers.get(SERVER_NAME)+ if isinstance(stored, dict):+ # Copilot accepts "local" as well as "stdio"; any ``url`` means not ours.+ local_type = "local" if stored.get("type") == "local" else "stdio"+ if "url" in stored or is_remote_entry(stored, local_type=local_type):+ raise RemoteServerEntryError(f"{path.name} 'repowise' is wired to a remote server")+ entry = {**stored, **server_entry()}+ else:+ entry = {**server_entry(), "tools": ["*"]}+ existing["mcpServers"] = {**servers, SERVER_NAME: entry}+ path.parent.mkdir(parents=True, exist_ok=True)+ return FileWrite(path=path, action=write_json_config(path, existing))+++def _reads_repowise() -> bool:+ try:+ data = json.loads(mcp_config_path().read_text(encoding="utf-8"))+ except (OSError, ValueError):+ return False+ servers = data.get("mcpServers") if isinstance(data, dict) else None+ return isinstance(servers, dict) and SERVER_NAME in servers+++#: Empty marker pair beside the shared block. The block alone cannot say who+#: asked for it, so this is Copilot's claim on it for ``other_managers_of``.+OWNER_START = "<!-- REPOWISE_COPILOT_CLI:START -->"+OWNER_END = "<!-- REPOWISE_COPILOT_CLI:END -->"+++def _owns_block(repo_path: Path) -> bool:+ from ..formats import marker_block+ from ..formats.marker_block import BlockState++ path = vscode.instructions_path(repo_path)+ return marker_block.inspect(path, OWNER_START, OWNER_END).state is BlockState.PRESENT+++def detect(repo_path: Path | None = None) -> list[Registration]:+ """User registration from ``mcp-config.json``; project from our owner marker."""+ found = []+ if _reads_repowise():+ found.append(Registration(method="direct", scope=Scope.USER, config_path=mcp_config_path()))+ if repo_path is not None and _owns_block(repo_path):+ found.append(+ Registration(+ method="direct",+ scope=Scope.PROJECT,+ config_path=vscode.instructions_path(repo_path),+ detail="managed instructions block",+ )+ )+ return found+++def _prune_config_dir() -> None:+ """Remove the config dir only if our uninstall left it empty."""+ directory = config_dir()+ if directory.is_symlink():+ return+ with contextlib.suppress(OSError):+ directory.rmdir()+++class CopilotTarget:+ """Descriptor for GitHub Copilot CLI. See the module docstring."""++ id = ID+ display_name = DISPLAY_NAME+ docs_url = DOCS_URL+ hook_adapter = IDENTITY.hook_adapter+ session_adapter = IDENTITY.session_adapter+ methods = METHODS+ project_file_id = PROJECT_FILE_ID++ def supports_scope(self, scope: Scope) -> bool:+ """User scope is the MCP entry, project scope the instructions block."""+ return True++ def is_present(self, repo_path: Path | None = None) -> bool:+ """The ``copilot`` binary on PATH; ``~/.copilot`` is shared with VS Code."""+ return IDENTITY.is_installed()++ def detect(self, repo_path: Path | None = None) -> list[Registration]:+ return detect(repo_path)++ def install(+ self,+ scope: Scope,+ options: object = None,+ *,+ repo_path: Path | None = None,+ ) -> WriteResult:+ result = WriteResult()+ if scope is Scope.PROJECT:+ if repo_path is None:+ raise ValueError("project-scope install needs a repo_path")+ try:+ written = vscode.write_instructions(repo_path)+ except (OSError, ValueError) as exc:+ path = vscode.instructions_path(repo_path)+ result.record(path, FileAction.KEPT, f"could not be written ({exc})")+ result.note(f"{path} could not be written ({exc}).")+ return result+ action = written.action+ if action is not FileAction.KEPT:+ from ..formats import marker_block++ claimed = marker_block.upsert(written.path, "", OWNER_START, OWNER_END)+ if claimed is FileAction.KEPT:+ action = FileAction.KEPT+ elif action is FileAction.UNCHANGED and claimed is not FileAction.UNCHANGED:+ action = FileAction.UPDATED+ result.record(written.path, action)+ if action is FileAction.KEPT:+ result.note(+ f"{written.path} left unchanged: its Repowise markers are unpaired or "+ "duplicated, or the file could not be read. Fix it by hand and re-run."+ )+ return result++ path = mcp_config_path()+ try:+ written = write_mcp_config()+ result.record(written.path, written.action)+ except RemoteServerEntryError:+ result.record(path, FileAction.KEPT, 'its "repowise" entry names a remote server')+ result.note(+ f'{path} left unchanged: its "repowise" entry names a remote server. Run '+ "'repowise agents remove --target=copilot' first if you want the local "+ "server instead."+ )+ except (OSError, ValueError) as exc:+ result.record(path, FileAction.KEPT, f"could not be rewritten ({exc})")+ result.note(+ f"{path} left unchanged ({exc}). Run 'repowise agents print-config "+ "copilot --scope=user' and paste the entry under \"mcpServers\"."+ )+ return result++ def uninstall(self, scope: Scope, *, repo_path: Path | None = None) -> WriteResult:+ result = WriteResult()+ if scope is Scope.PROJECT:+ if repo_path is None:+ raise ValueError("project-scope uninstall needs a repo_path")+ from ..formats import marker_block++ released = marker_block.remove(+ vscode.instructions_path(repo_path), OWNER_START, OWNER_END+ )+ path, action, reason = vscode.remove_instructions(repo_path, exclude=ID)+ if action is FileAction.KEPT:+ result.note(f"{path} kept: {reason}.")+ if released:+ action, reason = FileAction.REMOVED, None+ elif released and action is FileAction.NOT_FOUND:+ action = FileAction.REMOVED+ result.record(path, action, reason)+ return result++ from .cursor import _remove_server_entry++ path, action, reason = _remove_server_entry(mcp_config_path())+ result.record(path, action, reason)+ if action is FileAction.REMOVED:+ _prune_config_dir()+ return result++ def print_config(self, scope: Scope, *, repo_path: Path | None = None) -> str:+ """The user entry; Copilot CLI has no project MCP file to paste into."""+ return json.dumps(+ {"mcpServers": {SERVER_NAME: {**server_entry(), "tools": ["*"]}}}, indent=2+ )++ def describe_paths(self, scope: Scope, *, repo_path: Path | None = None) -> list[str]:+ if scope is Scope.USER:+ return [str(mcp_config_path())]+ return [str(vscode.instructions_path(repo_path or Path.cwd()))]++ def doctor(self) -> DoctorReport:+ """User-scope health; the project block needs a repo to check."""+ from ..formats.json_merge import load_json_object_or_value_error++ path = mcp_config_path()+ if _reads_repowise():+ return DoctorReport(target_id=ID, status=DoctorStatus.OK)+ if path.exists():+ try:+ load_json_object_or_value_error(path, path.name)+ except (OSError, ValueError):+ return DoctorReport(+ target_id=ID,+ status=DoctorStatus.BROKEN,+ issues=(f"{path} is not a JSON object, so Copilot CLI cannot read it.",),+ repairable=False,+ fix_command="repowise agents add --target=copilot",+ )+ return DoctorReport(+ target_id=ID,+ status=DoctorStatus.NOT_INSTALLED,+ issues=("GitHub Copilot CLI is not wired at user scope.",),+ fix_command="repowise agents add --target=copilot",+ )+++TARGET = CopilotTarget()diff --git a/packages/cli/src/repowise/cli/agent_targets/targets/kiro.py b/packages/cli/src/repowise/cli/agent_targets/targets/kiro.pynew file mode 100644index 000000000..fe577b9b5--- /dev/null+++ b/packages/cli/src/repowise/cli/agent_targets/targets/kiro.py@@ -0,0 +1,315 @@+"""Kiro as an agent target.++Good tier: MCP plus a steering file, no hook or transcript adapter. Kiro's two+hook formats disagree in its own docs, so none are written.++Host facts, each checked against the source named beside it:++* MCP lives in ``.kiro/settings/mcp.json`` (workspace) and+ ``~/.kiro/settings/mcp.json`` (user) under ``mcpServers``; an entry is+ ``command`` plus ``args``, with no ``type`` field.+ https://kiro.dev/docs/mcp/configuration+* Every ``*.md`` in ``.kiro/steering/`` (or ``~/.kiro/steering/``) is loaded as+ context, so repowise owns ``steering/repowise.md`` outright and needs no+ marker block. No frontmatter: the inclusion key names are unverified.+ https://kiro.dev/docs/steering+* Kiro IDE ships with MCP turned off; the CLI reads the same file ungated+ (codegraph ``kiro.ts``). Install says so.+* ``$KIRO_HOME`` overrides ``~/.kiro`` (codebase-memory-mcp ``cli.c``; Kiro's+ docs are silent), so the user scope honours it.+* Assumed, not documented: Kiro launches a user-scope server in the workspace+ directory, which is how the path-less user entry finds its repo.+"""++from __future__ import annotations++import contextlib+import json+import os+import shutil+from pathlib import Path++from repowise.core.agents import identity++from ..formats.server_entry import RemoteServerEntryError+from ..types import (+ Capability,+ DoctorReport,+ DoctorStatus,+ FileAction,+ FileWrite,+ InstallMethod,+ Registration,+ Scope,+ WriteResult,+)++IDENTITY = identity.KIRO+ID = IDENTITY.cli_target_id+DISPLAY_NAME = IDENTITY.display_name+DOCS_URL = "https://kiro.dev/docs/mcp/configuration"++PROJECT_FILE_ID = "kiro_steering"++SERVER_NAME = "repowise"++METHODS = (+ InstallMethod(+ id="direct",+ provides=frozenset({Capability.MCP, Capability.INSTRUCTIONS}),+ managed_by="repowise",+ preferred=True,+ ),+)++#: First line of every steering file repowise writes; how uninstall knows the+#: file is ours rather than a hand-written one with the same name.+STEERING_HEADER = "<!-- Managed by Repowise. 'repowise agents remove --target=kiro' deletes it. -->"+++def steering_text() -> str:+ from ..instructions import DISTILL_SECTION++ return f"{STEERING_HEADER}\n\n{DISTILL_SECTION}\n"+++def config_dir(scope: Scope, repo_path: Path | None = None) -> Path:+ if scope is Scope.USER:+ configured = (os.environ.get("KIRO_HOME") or "").strip()+ return Path(configured).expanduser() if configured else Path.home() / ".kiro"+ if repo_path is None:+ raise ValueError("project scope needs a repo_path")+ return repo_path / ".kiro"+++def mcp_config_path(scope: Scope, repo_path: Path | None = None) -> Path:+ return config_dir(scope, repo_path) / "settings" / "mcp.json"+++def steering_path(scope: Scope, repo_path: Path | None = None) -> Path:+ return config_dir(scope, repo_path) / "steering" / "repowise.md"+++def server_entry(scope: Scope, repo_path: Path | None = None) -> dict:+ """Project: bare command plus repo path, like ``.mcp.json``. User: pinned, no path."""+ from repowise.cli.mcp_config import generate_mcp_config, resolve_repowise_command++ if scope is Scope.USER:+ return {"command": resolve_repowise_command(), "args": ["mcp", "--transport", "stdio"]}+ if repo_path is None:+ raise ValueError("project scope needs a repo_path")+ generated = generate_mcp_config(repo_path)["mcpServers"][SERVER_NAME]+ return {"command": generated["command"], "args": generated["args"]}+++def write_mcp_config(scope: Scope, repo_path: Path | None = None) -> FileWrite:+ """Merge our entry into ``mcp.json``; raises ``ValueError`` on a bad file."""+ from ..formats.json_merge import (+ load_json_object_or_value_error,+ merge_server_entries,+ write_json_config,+ )+ from ..formats.server_entry import is_remote_entry++ path = mcp_config_path(scope, repo_path)+ existing = load_json_object_or_value_error(path, path.name) if path.exists() else {}+ servers = existing.get("mcpServers", {})+ if not isinstance(servers, dict):+ raise ValueError(f"{path.name} 'mcpServers' must be a JSON object")+ servers = dict(servers)+ stored = servers.get(SERVER_NAME)+ if isinstance(stored, dict) and is_remote_entry(stored, local_type="stdio"):+ raise RemoteServerEntryError(f"{path.name} 'repowise' is wired to a remote server")+ merge_server_entries(servers, {SERVER_NAME: server_entry(scope, repo_path)})+ existing["mcpServers"] = servers+ path.parent.mkdir(parents=True, exist_ok=True)+ return FileWrite(path=path, action=write_json_config(path, existing))+++def _read(path: Path) -> str | None:+ """File text, ``None`` when absent; raises ``OSError``/``ValueError`` when unreadable."""+ if not path.exists():+ return None+ return path.read_text(encoding="utf-8")+++def write_steering(scope: Scope, repo_path: Path | None = None) -> tuple[FileWrite, str | None]:+ """Write the whole steering file; a same-named file we did not write is kept."""+ from ..formats.json_merge import atomic_write_text++ path = steering_path(scope, repo_path)+ text = steering_text()+ current = _read(path)+ if current is not None:+ if current.replace("\r\n", "\n") == text:+ return FileWrite(path=path, action=FileAction.UNCHANGED), None+ if not current.startswith(STEERING_HEADER):+ return FileWrite(path=path, action=FileAction.KEPT), "not written by repowise"+ path.parent.mkdir(parents=True, exist_ok=True)+ atomic_write_text(path, text, newline="\n")+ action = FileAction.CREATED if current is None else FileAction.UPDATED+ return FileWrite(path=path, action=action), None+++def _remove_steering(path: Path) -> tuple[Path, FileAction, str | None]:+ try:+ current = _read(path)+ except (OSError, ValueError):+ return path, FileAction.KEPT, "the file could not be read, so its contents are unknown"+ if current is None:+ return path, FileAction.NOT_FOUND, None+ if not current.startswith(STEERING_HEADER):+ return path, FileAction.KEPT, "not written by repowise"+ try:+ path.unlink()+ except OSError as exc:+ return path, FileAction.FAILED, f"could not be deleted ({exc})"+ return path, FileAction.REMOVED, None+++def _reads_repowise(path: Path) -> bool:+ try:+ data = json.loads(path.read_text(encoding="utf-8"))+ except (OSError, ValueError):+ return False+ servers = data.get("mcpServers") if isinstance(data, dict) else None+ return isinstance(servers, dict) and SERVER_NAME in servers+++def detect(repo_path: Path | None = None) -> list[Registration]:+ """Every ``mcp.json`` naming repowise, user scope first. Never raises."""+ scopes: list[tuple[Scope, Path | None]] = [(Scope.USER, None)]+ if repo_path is not None:+ scopes.append((Scope.PROJECT, repo_path))+ return [+ Registration(method="direct", scope=scope, config_path=mcp_config_path(scope, repo))+ for scope, repo in scopes+ if _reads_repowise(mcp_config_path(scope, repo))+ ]+++def _prune_dirs(scope: Scope, repo_path: Path | None) -> None:+ """``rmdir`` what uninstall emptied; a non-empty or linked dir is left."""+ root = config_dir(scope, repo_path)+ for candidate in (root / "settings", root / "steering", root):+ if candidate.is_symlink():+ continue+ with contextlib.suppress(OSError):+ candidate.rmdir()+++class KiroTarget:+ """Descriptor for Kiro. See the module docstring."""++ id = ID+ display_name = DISPLAY_NAME+ docs_url = DOCS_URL+ hook_adapter = IDENTITY.hook_adapter+ session_adapter = IDENTITY.session_adapter+ methods = METHODS+ project_file_id = PROJECT_FILE_ID++ def supports_scope(self, scope: Scope) -> bool:+ return True++ def is_present(self, repo_path: Path | None = None) -> bool:+ """``kiro-cli`` or the IDE's ``kiro`` on PATH, or a Kiro home dir."""+ if IDENTITY.is_installed() or shutil.which("kiro"):+ return True+ return config_dir(Scope.USER).is_dir()++ def detect(self, repo_path: Path | None = None) -> list[Registration]:+ return detect(repo_path)++ def install(+ self,+ scope: Scope,+ options: object = None,+ *,+ repo_path: Path | None = None,+ ) -> WriteResult:+ result = WriteResult()+ if scope is Scope.PROJECT and repo_path is None:+ raise ValueError("project-scope install needs a repo_path")++ path = mcp_config_path(scope, repo_path)+ try:+ written = write_mcp_config(scope, repo_path)+ result.record(written.path, written.action)+ except RemoteServerEntryError:+ result.record(path, FileAction.KEPT, 'its "repowise" entry names a remote server')+ result.note(+ f'{path} left unchanged: its "repowise" entry names a remote server. Run '+ "'repowise agents remove --target=kiro' first if you want the local server."+ )+ except (OSError, ValueError) as exc:+ result.record(path, FileAction.KEPT, f"could not be rewritten ({exc})")+ result.note(+ f"{path} left unchanged ({exc}). Run 'repowise agents print-config kiro' "+ 'and paste the entry under "mcpServers".'+ )++ try:+ steering, reason = write_steering(scope, repo_path)+ result.record(steering.path, steering.action, reason)+ if reason:+ result.note(f"{steering.path} left unchanged: {reason}.")+ except (OSError, ValueError) as exc:+ steering_file = steering_path(scope, repo_path)+ result.record(steering_file, FileAction.KEPT, f"could not be written ({exc})")+ result.note(f"{steering_file} could not be written ({exc}).")++ if result.changed:+ result.note("Kiro IDE ships with MCP disabled; enable MCP in its settings.")+ return result++ def uninstall(self, scope: Scope, *, repo_path: Path | None = None) -> WriteResult:+ result = WriteResult()+ if scope is Scope.PROJECT and repo_path is None:+ raise ValueError("project-scope uninstall needs a repo_path")+ from .cursor import _remove_server_entry++ result.record(*_remove_server_entry(mcp_config_path(scope, repo_path)))+ result.record(*_remove_steering(steering_path(scope, repo_path)))+ if any(f.action is FileAction.REMOVED for f in result.files):+ _prune_dirs(scope, repo_path)+ return result++ def print_config(self, scope: Scope, *, repo_path: Path | None = None) -> str:+ repo = None if scope is Scope.USER else repo_path or Path.cwd()+ return json.dumps({"mcpServers": {SERVER_NAME: server_entry(scope, repo)}}, indent=2)++ def describe_paths(self, scope: Scope, *, repo_path: Path | None = None) -> list[str]:+ 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."""+ from ..formats.json_merge import load_json_object_or_value_error++ path = mcp_config_path(Scope.USER)+ if _reads_repowise(path):+ return DoctorReport(target_id=ID, status=DoctorStatus.OK)+ if path.exists():+ try:+ load_json_object_or_value_error(path, path.name)+ except (OSError, ValueError):+ return DoctorReport(+ target_id=ID,+ status=DoctorStatus.BROKEN,+ issues=(f"{path} is not a JSON object, so Kiro cannot read it.",),+ repairable=False,+ fix_command="repowise agents add --target=kiro",+ )+ return DoctorReport(+ target_id=ID,+ status=DoctorStatus.NOT_INSTALLED,+ issues=(+ "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",+ )+++TARGET = KiroTarget()diff --git a/packages/cli/src/repowise/cli/agent_targets/targets/vscode.py b/packages/cli/src/repowise/cli/agent_targets/targets/vscode.pyindex 48197c8d3..4474a0a23 100644--- a/packages/cli/src/repowise/cli/agent_targets/targets/vscode.py+++ b/packages/cli/src/repowise/cli/agent_targets/targets/vscode.py@@ -1,10 +1,16 @@"""VS Code as an agent target.-Basic tier, and the descriptor makes that structural rather than editorial: it-names neither a hook adapter nor a transcript adapter, and wires MCP without-instructions or skills, so :func:`derive_tier` places it at Basic. VS Code gets-the MCP server and an extension recommendation; it has no hook protocol for-repowise to intercept tool calls through, and no transcript format to mine.+Good tier, and the descriptor makes that structural rather than editorial: it+names neither a hook adapter nor a transcript adapter, so :func:`derive_tier`+cannot place it at Full however many files it writes. VS Code gets the MCP+server, an extension recommendation and the managed instructions block in+``.github/copilot-instructions.md``; it has no hook protocol for repowise to+intercept tool calls through, and no transcript format to mine.++Copilot Chat reads ``.github/copilot-instructions.md`` in every chat request:+https://code.visualstudio.com/docs/copilot/customization/custom-instructions+Copilot CLI reads the same file, so the ``copilot`` target shares this block+rather than writing a second one, and uninstall asks before stripping it.The distinguishing quirk is that both files it writes may legally containcomments — VS Code accepts JSONC throughout ``.vscode/``. So this target is the@@ -51,7 +57,7 @@ PROJECT_FILE_ID = "vscode_mcp"METHODS = (InstallMethod(id="direct",- provides=frozenset({Capability.MCP}),+ provides=frozenset({Capability.MCP, Capability.INSTRUCTIONS}),managed_by="repowise",preferred=True,),@@ -66,6 +72,10 @@ def extensions_config_path(repo_path: Path) -> Path:return repo_path / ".vscode" / "extensions.json"+def instructions_path(repo_path: Path) -> Path:+ return repo_path / ".github" / "copilot-instructions.md"++def server_entry(repo_path: Path) -> dict:"""The ``.vscode/mcp.json`` server entry.@@ -143,6 +153,56 @@ def write_extensions_config(repo_path: Path) -> FileWrite:return FileWrite(path=config_path, action=write_json_config(config_path, merged))+def write_instructions(repo_path: Path) -> FileWrite:+ """Upsert the managed block into ``.github/copilot-instructions.md``.++ A file users write in, so no prefix: install appends to what is there and+ uninstall deletes the file only when our block was all it held.+ """+ from ..formats import marker_block+ from ..instructions import DISTILL_MARKER_END, DISTILL_MARKER_START, DISTILL_SECTION++ path = instructions_path(repo_path)+ path.parent.mkdir(parents=True, exist_ok=True)+ action = marker_block.upsert(+ path, f"\n{DISTILL_SECTION}\n", DISTILL_MARKER_START, DISTILL_MARKER_END+ )+ return FileWrite(path=path, action=action)+++def remove_instructions(repo_path: Path, *, exclude: str) -> tuple[Path, FileAction, str | None]:+ """Strip the managed block unless another wired target still reads it.++ Shared with the ``copilot`` target, which passes its own id as *exclude*.+ Same guard as ``AGENTS.md`` in ``opencode.py``: see+ :func:`..registry.other_managers_of`.+ """+ from ..formats import marker_block+ from ..formats.marker_block import BlockState+ from ..instructions import DISTILL_MARKER_END, DISTILL_MARKER_START+ from ..registry import other_managers_of++ path = instructions_path(repo_path)+ state = marker_block.inspect(path, DISTILL_MARKER_START, DISTILL_MARKER_END).state+ if state is BlockState.PRESENT:+ owners = other_managers_of(path, exclude=exclude, scope=Scope.PROJECT, repo_path=repo_path)+ if owners:+ from ..registry import all_targets++ ids = ",".join(t.id for t in all_targets() if t.display_name in owners)+ return path, FileAction.KEPT, (+ f"{' and '.join(owners)} still reads the same managed block; to remove "+ f"it too, run 'repowise agents remove --target={ids}'"+ )+ if marker_block.remove(path, DISTILL_MARKER_START, DISTILL_MARKER_END):+ return path, FileAction.REMOVED, None+ if state in (BlockState.ABSENT_FILE, BlockState.ABSENT):+ return path, FileAction.NOT_FOUND, None+ # PRESENT with no other owner means the write failed rather than a refusal.+ action = FileAction.FAILED if state is BlockState.PRESENT else FileAction.KEPT+ return path, action, marker_block.refusal_reason(state)++def _remove_server_entry(config_path: Path) -> tuple[Path, FileAction, str | None]:"""Drop ``servers.repowise``, preserving sibling servers."""from ..formats.json_merge import load_json_object_or_value_error, write_json_config@@ -219,20 +279,20 @@ def _remove_extension_recommendation(config_path: Path) -> tuple[Path, FileActiodef _prune_project_dir(repo_path: Path) -> None:- """Remove ``.vscode/`` once uninstall emptied it, and never otherwise.+ """Remove ``.vscode/`` and ``.github/`` once uninstall emptied them, never otherwise.``rmdir`` rather than a recursive delete, so a directory still holdinganything at all, ours or the user's ``settings.json``, is left exactly as itis. The symlink guard is Cursor's: following a junction to delete somethingoutside the repo is not a risk worth a tidy directory."""- directory = mcp_config_path(repo_path).parent- if directory.is_symlink() or not directory.is_dir():- return- try:- directory.rmdir()- except OSError:- return+ for directory in (mcp_config_path(repo_path).parent, instructions_path(repo_path).parent):+ if directory.is_symlink() or not directory.is_dir():+ continue+ try:+ directory.rmdir()+ except OSError:+ continuedef detect(repo_path: Path | None = None) -> list[Registration]:@@ -359,13 +419,30 @@ class VSCodeTarget:f'it may contain comments). Add "{EXTENSION_ID}" to "recommendations" '"manually.")+ try:+ written = write_instructions(repo_path)+ except (ValueError, OSError) as exc:+ result.record(instructions_path(repo_path), FileAction.KEPT, f"could not be written ({exc})")+ result.note(f".github/copilot-instructions.md could not be written ({exc}).")+ else:+ reason = None+ if written.action is FileAction.KEPT:+ from ..formats import marker_block+ from ..instructions import DISTILL_MARKER_END, DISTILL_MARKER_START++ state = marker_block.inspect(+ written.path, DISTILL_MARKER_START, DISTILL_MARKER_END+ ).state+ reason = marker_block.refusal_reason(state)+ result.note(f"{written.path} left unchanged: {reason}.")+ result.record(written.path, written.action, reason)return resultdef uninstall(self, scope: Scope, *, repo_path: Path | None = None) -> WriteResult:- """Remove the server entry and the extension recommendation.+ """Remove the server entry, the extension recommendation and our block.- Both files, because :meth:`install` writes both and- :meth:`describe_paths` names both. Leaving the recommendation behind+ Every file, because :meth:`install` writes each and+ :meth:`describe_paths` names each. Leaving the recommendation behindmeant ``agents remove --target=vscode`` still had the editor promptingevery contributor to install an extension for an integration that wasjust removed — and said nothing about the file it had skipped.@@ -375,6 +452,10 @@ class VSCodeTarget:return resultresult.record(*_remove_server_entry(mcp_config_path(repo_path)))result.record(*_remove_extension_recommendation(extensions_config_path(repo_path)))+ path, action, reason = remove_instructions(repo_path, exclude=ID)+ result.record(path, action, reason)+ if action is FileAction.KEPT:+ result.note(f"{path} kept: {reason}.")# Only when something of ours actually went, matching Cursor. Pruning# unconditionally deleted a `.vscode/` that happened to be empty and# that this uninstall had just reported finding nothing in.@@ -389,7 +470,11 @@ class VSCodeTarget:if scope is not Scope.PROJECT:return []repo = repo_path or Path.cwd()- return [str(mcp_config_path(repo)), str(extensions_config_path(repo))]+ return [+ str(mcp_config_path(repo)),+ str(extensions_config_path(repo)),+ str(instructions_path(repo)),+ ]def doctor(self) -> DoctorReport:"""Health is repo-scoped, so a bare call can only report the honest answer.diff --git a/packages/cli/src/repowise/cli/editor_integrations/vscode.py b/packages/cli/src/repowise/cli/editor_integrations/vscode.pyindex bba77b7bb..0a4991cfb 100644--- a/packages/cli/src/repowise/cli/editor_integrations/vscode.py+++ b/packages/cli/src/repowise/cli/editor_integrations/vscode.py@@ -6,15 +6,17 @@ from pathlib import Pathfrom typing import Anyfrom repowise.cli.agent_targets.targets import vscode as vscode_target+from repowise.cli.agent_targets.types import FileActionfrom repowise.cli.editor_setup import EditorSetupOptionsclass VSCodeSetup:"""Project-local VS Code setup integration.- Writes the workspace MCP server config (.vscode/mcp.json) and recommends the- repowise extension (.vscode/extensions.json). Both are repo-shared files, so- they use the bare ``repowise`` command like the committed ``.mcp.json``.+ Writes the workspace MCP server config (.vscode/mcp.json), recommends the+ repowise extension (.vscode/extensions.json) and upserts the managed block+ in .github/copilot-instructions.md. All are repo-shared files, so the MCP+ entry uses the bare ``repowise`` command like the committed ``.mcp.json``."""#: Read from the descriptor rather than restated, so the ids have one home.@@ -87,4 +89,18 @@ def _write_vscode_files(console_obj: Any, repo_path: Path) -> list[Path]:'contain comments). Add "repowise-dev.repowise" to "recommendations" '"manually.[/]")++ try:+ instructions = vscode_target.write_instructions(repo_path)+ except (OSError, ValueError) as exc:+ console_obj.print(f" [{WARN}].github/copilot-instructions.md not written ({exc}).[/]")+ else:+ if instructions.action is FileAction.KEPT:+ console_obj.print(+ f" [{WARN}].github/copilot-instructions.md left unchanged: its Repowise "+ "markers are unpaired or duplicated, or it could not be read.[/]"+ )+ else:+ console_obj.print(f" [{OK}]✓[/] Copilot instructions updated ({instructions.path})")+ written.append(instructions.path)return writtendiff --git a/packages/core/src/repowise/core/agents/identity.py b/packages/core/src/repowise/core/agents/identity.pyindex 082c43a38..fff656025 100644--- a/packages/core/src/repowise/core/agents/identity.py+++ b/packages/core/src/repowise/core/agents/identity.py@@ -207,6 +207,16 @@ OPENCODE = AgentIdentity(indexing_provider="opencode",)HERMES = AgentIdentity(slug="hermes", display_name="Hermes", executable="hermes")+COPILOT = AgentIdentity(+ slug="copilot",+ display_name="GitHub Copilot CLI",+ executable="copilot",+ install_hint="npm install -g @github/copilot",+ login_hint="copilot login",+)+KIRO = AgentIdentity(+ slug="kiro", display_name="Kiro", executable="kiro-cli", login_hint="kiro-cli login"+)#: Registered identities, by slug. Order is not load-bearing here — the order#: agents are *presented* in belongs to the target registry, which is where a@@ -339,6 +349,6 @@ def resolve_client_identity(client_name: str | None) -> str:#: The agents shipped with repowise, registered through the same seam a#: third-party package would use, so the alias-disjointness check covers them too.-for _shipped in (CLAUDE_CODE, CODEX, VSCODE, CURSOR, OPENCODE, HERMES):+for _shipped in (CLAUDE_CODE, CODEX, VSCODE, CURSOR, OPENCODE, HERMES, COPILOT, KIRO):register_identity(_shipped)del _shippeddiff --git a/tests/unit/agents/test_identity.py b/tests/unit/agents/test_identity.pyindex ca7c9689b..a56e50322 100644--- a/tests/unit/agents/test_identity.py+++ b/tests/unit/agents/test_identity.py@@ -125,7 +125,7 @@ def test_the_published_target_ids_are_exactly_what_users_already_type() -> None:``--target=`` ids are in the README, in INTEGRATIONS.md and in people'sshell history. Deriving them from the slug is an implementation choice; that- the derivation still produces these six strings is the constraint, and+ the derivation still produces these strings is the constraint, andrestating the formula here would assert nothing."""assert [agent.cli_target_id for agent in SHIPPED] == [@@ -135,6 +135,8 @@ def test_the_published_target_ids_are_exactly_what_users_already_type() -> None:"cursor","opencode","hermes",+ "copilot",+ "kiro",]@@ -188,6 +190,8 @@ def test_registering_a_colliding_alias_is_refused() -> None:("Cursor", "cursor"),("OpenCode", "opencode"),("Hermes", "hermes"),+ ("GitHub Copilot CLI", "copilot"),+ ("Kiro", "kiro"),],)def test_announced_names_resolve_through_punctuation_and_case(@@ -252,8 +256,8 @@ def test_the_unknown_sentinel_is_labelled_rather_than_echoed() -> None:assert identity.get_identity(UNKNOWN_AGENT) is None-def test_the_shipped_registry_is_the_six_integrated_agents() -> None:- """Frozen, so a seventh is a deliberate edit rather than a side effect."""+def test_the_shipped_registry_is_the_integrated_agents() -> None:+ """Frozen, so a new agent is a deliberate edit rather than a side effect."""assert [agent.slug for agent in identity.all_identities()] == ["claude_code","codex",@@ -261,6 +265,8 @@ def test_the_shipped_registry_is_the_six_integrated_agents() -> None:"cursor","opencode","hermes",+ "copilot",+ "kiro",]diff --git a/tests/unit/cli/conftest.py b/tests/unit/cli/conftest.pyindex 14e212254..437586b63 100644--- a/tests/unit/cli/conftest.py+++ b/tests/unit/cli/conftest.py@@ -18,7 +18,7 @@ between a test writing to a temp directory and a test writing to thedeveloper's real ``opencode.jsonc``. A test that wants the variable set sets ititself.-``HERMES_HOME`` and ``LOCALAPPDATA`` are the same hole, one variable further+``HERMES_HOME``, ``COPILOT_HOME``, ``KIRO_HOME`` and ``LOCALAPPDATA`` are the same hole, one variable furtheralong. The Hermes target reads ``HERMES_HOME`` first and then, on Windows only,``%LOCALAPPDATA%\\hermes``, never ``~/.hermes`` there, so redirecting homecovers neither. ``LOCALAPPDATA`` is *redirected* rather than cleared, because@@ -46,6 +46,8 @@ def _isolated_home(tmp_path_factory, monkeypatch):monkeypatch.setenv("USERPROFILE", str(fake_home))monkeypatch.delenv("XDG_CONFIG_HOME", raising=False)monkeypatch.delenv("HERMES_HOME", raising=False)+ monkeypatch.delenv("COPILOT_HOME", raising=False)+ monkeypatch.delenv("KIRO_HOME", raising=False)monkeypatch.setenv("LOCALAPPDATA", str(fake_home / "AppData" / "Local"))monkeypatch.setattr(Path, "home", lambda: fake_home)return fake_homediff --git a/tests/unit/cli/data/agent_target_baseline.json b/tests/unit/cli/data/agent_target_baseline.jsonindex 1c9cd5890..da7d47bf3 100644--- a/tests/unit/cli/data/agent_target_baseline.json+++ b/tests/unit/cli/data/agent_target_baseline.json@@ -8,6 +8,10 @@"content": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"repowise-augment --client codex\",\n \"timeout\": 10,\n \"statusMessage\": \"Loading repowise context...\"\n }\n ]\n }\n ],\n \"PostToolUse\": [\n {\n \"matcher\": \"Bash|shell_command\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"repowise-augment --client codex\",\n \"timeout\": 10,\n \"statusMessage\": \"Checking repowise freshness...\"\n }\n ]\n },\n {\n \"matcher\": \"apply_patch|Edit|Write\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"repowise-augment --client codex\",\n \"timeout\": 10,\n \"statusMessage\": \"Checking repowise freshness...\"\n }\n ]\n }\n ]\n }\n}\n","newlines": "platform"},+ ".github/copilot-instructions.md": {+ "content": "<!-- REPOWISE_DISTILL:START \u2014 Do not edit below this line. Auto-generated by Repowise. -->\n### Output Distillation\n\n- Prefer `repowise distill <cmd>` for noisy commands \u2014 test runs, builds, `git status`/`log`/`diff`, searches, file listings. It runs the command unchanged (exit code preserved) and prints a compact, errors-first rendering; every error line survives.\n- Output may contain a marker like `[repowise#a1b2c3d4e5f6: 230 lines omitted (~6.1k tokens); restore: repowise expand a1b2c3d4e5f6]`. The omitted content is fully preserved \u2014 run `repowise expand <ref>` to retrieve it, or `repowise expand <ref> -q <regex>` for just the matching lines.\n- Never re-run a command to see omitted output; expand the marker instead.\n- For structure-level questions about a large indexed file (\"what's in here\", \"which function handles X\"), `get_context([\"path\"], include=[\"skeleton\"])` returns the file with bodies elided \u2014 every signature plus the bodies of the most central symbols \u2014 at a fraction of the cost of a full Read.\n<!-- REPOWISE_DISTILL:END -->\n",+ "newlines": "lf"+ },".mcp.json": {"content": "{\n \"mcpServers\": {\n \"repowise\": {\n \"command\": \"repowise\",\n \"args\": [\n \"mcp\",\n \"{REPO}\",\n \"--transport\",\n \"stdio\"\n ],\n \"description\": \"repowise: codebase intelligence \\u2014 docs, graph, git signals, dead code, decisions\"\n }\n }\n}\n","newlines": "platform"diff --git a/tests/unit/cli/test_agent_targets.py b/tests/unit/cli/test_agent_targets.pyindex 38713272d..54847c9a1 100644--- a/tests/unit/cli/test_agent_targets.py+++ b/tests/unit/cli/test_agent_targets.py@@ -47,7 +47,16 @@ def test_registry_exposes_the_shipped_targets() -> None:Order is load-bearing: it is the order agents appear in prompts, in``--target=all`` and in listings, and new ids append rather than sort in."""- assert ALL_IDS == ["claude-code", "codex", "vscode", "cursor", "opencode", "hermes"]+ assert ALL_IDS == [+ "claude-code",+ "codex",+ "vscode",+ "cursor",+ "opencode",+ "hermes",+ "copilot",+ "kiro",+ ]@pytest.mark.parametrize("target_id", ALL_IDS)@@ -122,10 +131,12 @@ def test_tiers_are_derived_from_the_adapters_a_target_names() -> None:"""Full requires both deep surfaces; VS Code has neither, so it cannot claim it."""assert tier_of("claude-code") is Tier.FULLassert tier_of("codex") is Tier.FULL- assert tier_of("vscode") is Tier.BASIC+ assert tier_of("vscode") is Tier.GOODassert tier_of("cursor") is Tier.GOODassert tier_of("opencode") is Tier.GOODassert tier_of("hermes") is Tier.GOOD+ assert tier_of("copilot") is Tier.GOOD+ assert tier_of("kiro") is Tier.GOODdef test_a_target_cannot_reach_full_without_a_session_adapter() -> None:@@ -692,7 +703,7 @@ def test_vscode_install_survives_a_vscode_path_that_is_a_file(tmp_path: Path) ->result = vscode_target.TARGET.install(Scope.PROJECT, repo_path=repo)assert (repo / ".vscode").is_file()- assert all(f.action is FileAction.KEPT for f in result.files)+ assert all(f.action is FileAction.KEPT for f in result.files if f.path.parent.name == ".vscode")assert result.notes@@ -1074,6 +1085,8 @@ def test_every_target_doctor_survives_a_non_utf8_config(tmp_path: Path, monkeypaPath(".claude") / "settings.json",Path(".codex") / "hooks.json",Path(".config") / "opencode" / "opencode.jsonc",+ Path(".copilot") / "mcp-config.json",+ Path(".kiro") / "settings" / "mcp.json",):target_file = home / relativetarget_file.parent.mkdir(parents=True, exist_ok=True)@@ -3354,3 +3367,353 @@ def test_yaml_merge_keeps_an_inline_list_inline_and_still_findable() -> None:added, "platform_toolsets", "cli", ["hermes-cli", "othersrv"])assert restored == text+++# ---------------------------------------------------------------------------+# GitHub Copilot instructions (.github/copilot-instructions.md)+# ---------------------------------------------------------------------------+++def _copilot_instructions(repo: Path) -> Path:+ return repo / ".github" / "copilot-instructions.md"+++def test_vscode_instructions_coexist_with_the_users_own_text(tmp_path: Path) -> None:+ """Install appends our block; uninstall gives back the user's bytes exactly."""+ from repowise.cli.agent_targets.instructions import DISTILL_MARKER_START++ repo = tmp_path / "repo"+ path = _copilot_instructions(repo)+ path.parent.mkdir(parents=True)+ original = "# Team rules\n\nUse tabs.\n"+ path.write_text(original, encoding="utf-8", newline="\n")+ target = get_target("vscode")++ target.install(Scope.PROJECT, repo_path=repo)+ text = path.read_text(encoding="utf-8")+ assert text.startswith(original.rstrip())+ assert DISTILL_MARKER_START in text+ assert target.install(Scope.PROJECT, repo_path=repo).files[-1].action is FileAction.UNCHANGED++ result = target.uninstall(Scope.PROJECT, repo_path=repo)+ assert {f.path: f.action for f in result.files}[path] is FileAction.REMOVED+ assert path.read_bytes() == original.encode("utf-8")+++def test_vscode_instructions_round_trip_to_no_file(tmp_path: Path) -> None:+ repo = tmp_path / "repo"+ repo.mkdir()+ target = get_target("vscode")++ target.install(Scope.PROJECT, repo_path=repo)+ assert _copilot_instructions(repo).exists()+ target.uninstall(Scope.PROJECT, repo_path=repo)++ assert not (repo / ".github").exists()+ assert not (repo / ".vscode").exists()+++# ---------------------------------------------------------------------------+# GitHub Copilot CLI+# ---------------------------------------------------------------------------+++def _copilot():+ from repowise.cli.agent_targets.targets import copilot++ return copilot+++def test_copilot_writes_the_mcp_config_json_shape(tmp_path: Path) -> None:+ copilot = _copilot()+ path = Path.home() / ".copilot" / "mcp-config.json"+ path.parent.mkdir(parents=True)+ path.write_text(+ json.dumps({"mcpServers": {"other": {"type": "stdio", "command": "x"}}}), encoding="utf-8"+ )++ result = copilot.TARGET.install(Scope.USER)++ assert result.files[0].action is FileAction.UPDATED+ servers = json.loads(path.read_text(encoding="utf-8"))["mcpServers"]+ assert servers["other"] == {"type": "stdio", "command": "x"}+ entry = servers["repowise"]+ assert entry["type"] == "stdio"+ assert entry["args"] == ["mcp", "--transport", "stdio"]+ assert entry["tools"] == ["*"]+ assert copilot.TARGET.install(Scope.USER).files[0].action is FileAction.UNCHANGED+++def test_copilot_keeps_a_tools_list_the_user_narrowed(tmp_path: Path) -> None:+ copilot = _copilot()+ copilot.TARGET.install(Scope.USER)+ path = copilot.mcp_config_path()+ data = json.loads(path.read_text(encoding="utf-8"))+ data["mcpServers"]["repowise"]["tools"] = ["get_answer"]+ path.write_text(json.dumps(data), encoding="utf-8")++ copilot.TARGET.install(Scope.USER)++ assert json.loads(path.read_text(encoding="utf-8"))["mcpServers"]["repowise"]["tools"] == [+ "get_answer"+ ]+++def test_copilot_follows_copilot_home(tmp_path: Path, monkeypatch) -> None:+ copilot = _copilot()+ home = tmp_path / "copilot-home"+ monkeypatch.setenv("COPILOT_HOME", f" {home} ")++ copilot.TARGET.install(Scope.USER)++ assert (home / "mcp-config.json").exists()+ assert not (Path.home() / ".copilot").exists()+ assert copilot.TARGET.detect()[0].config_path == home / "mcp-config.json"+ assert copilot.TARGET.doctor().status.value == "ok"+++def _which_copilot(monkeypatch, present: bool) -> None:+ monkeypatch.setattr(+ "repowise.core.agents.identity.shutil.which",+ lambda name: "/bin/copilot" if present and name == "copilot" else None,+ )+++def test_copilot_is_present_only_with_its_binary(monkeypatch) -> None:+ """VS Code fills ``~/.copilot`` too (ide, skills, agents, hooks, mcp-config)."""+ _which_copilot(monkeypatch, False)+ copilot = _copilot()+ for name in ("ide", "skills", "agents", "hooks"):+ (Path.home() / ".copilot" / name).mkdir(parents=True)+ (Path.home() / ".copilot" / "mcp-config.json").write_text("{}", encoding="utf-8")++ assert not copilot.TARGET.is_present()+ _which_copilot(monkeypatch, True)+ assert copilot.TARGET.is_present()+++def test_copilot_home_expands_a_tilde(monkeypatch) -> None:+ monkeypatch.setenv("COPILOT_HOME", "~/elsewhere")+ assert _copilot().config_dir() == Path.home() / "elsewhere"+++def test_copilot_leaves_a_local_entry_carrying_a_url_alone() -> None:+ copilot = _copilot()+ path = copilot.mcp_config_path()+ path.parent.mkdir(parents=True)+ stored = {"mcpServers": {"repowise": {"type": "local", "url": "https://x"}}}+ path.write_text(json.dumps(stored), encoding="utf-8")++ result = copilot.TARGET.install(Scope.USER)++ assert result.files[0].action is FileAction.KEPT+ assert json.loads(path.read_text(encoding="utf-8")) == stored+++def test_copilot_user_scope_round_trips_to_nothing() -> None:+ copilot = _copilot()+ copilot.TARGET.install(Scope.USER)++ result = copilot.TARGET.uninstall(Scope.USER)++ assert result.files[0].action is FileAction.REMOVED+ assert not (Path.home() / ".copilot").exists()+++def test_copilot_project_registration_comes_from_its_own_claim(tmp_path: Path) -> None:+ """The shared block alone, as VS Code writes it, is not a Copilot registration."""+ copilot = _copilot()+ repo = tmp_path / "repo"+ repo.mkdir()++ get_target("vscode").install(Scope.PROJECT, repo_path=repo)+ assert copilot.TARGET.detect(repo) == []++ result = copilot.TARGET.install(Scope.PROJECT, repo_path=repo)+ assert result.files[0].action is FileAction.UPDATED+ assert {r.scope for r in copilot.TARGET.detect(repo)} == {Scope.PROJECT}+ assert copilot.TARGET.install(Scope.PROJECT, repo_path=repo).files[0].action is (+ FileAction.UNCHANGED+ )+++def test_copilot_project_scope_round_trips_to_no_file(tmp_path: Path) -> None:+ copilot = _copilot()+ repo = tmp_path / "repo"+ repo.mkdir()++ copilot.TARGET.install(Scope.PROJECT, repo_path=repo)+ result = copilot.TARGET.uninstall(Scope.PROJECT, repo_path=repo)++ assert result.files[0].action is FileAction.REMOVED+ assert not _copilot_instructions(repo).exists()+++def test_copilot_doctor_calls_a_non_object_config_broken() -> None:+ copilot = _copilot()+ path = copilot.mcp_config_path()+ path.parent.mkdir(parents=True)+ path.write_text("[]", encoding="utf-8")++ report = copilot.TARGET.doctor()++ assert report.status.value == "broken"+ assert copilot.TARGET.install(Scope.USER).files[0].action is FileAction.KEPT+ assert path.read_text(encoding="utf-8") == "[]"+++# ---------------------------------------------------------------------------+# Kiro+# ---------------------------------------------------------------------------+++def _kiro():+ from repowise.cli.agent_targets.targets import kiro++ return kiro++[email protected]("scope", [Scope.PROJECT, Scope.USER])+def test_kiro_installs_mcp_and_steering_then_round_trips_to_nothing(+ scope: Scope, tmp_path: Path+) -> None:+ kiro = _kiro()+ repo = tmp_path / "repo"+ repo.mkdir()+ root = repo / ".kiro" if scope is Scope.PROJECT else Path.home() / ".kiro"++ result = kiro.TARGET.install(scope, repo_path=repo)++ assert {f.action for f in result.files} == {FileAction.CREATED}+ entry = json.loads((root / "settings" / "mcp.json").read_text(encoding="utf-8"))[+ "mcpServers"+ ]["repowise"]+ assert "type" not in entry+ if scope is Scope.PROJECT:+ assert entry["command"] == "repowise"+ assert str(repo.resolve()).replace("\\", "/") in entry["args"]+ else:+ assert entry["args"] == ["mcp", "--transport", "stdio"]+ steering = (root / "steering" / "repowise.md").read_text(encoding="utf-8")+ assert steering.startswith(kiro.STEERING_HEADER)+ assert not steering.startswith("---")+ assert {r.scope for r in kiro.TARGET.detect(repo)} == {scope}+ assert {f.action for f in kiro.TARGET.install(scope, repo_path=repo).files} == {+ FileAction.UNCHANGED+ }++ removed = kiro.TARGET.uninstall(scope, repo_path=repo)++ assert {f.action for f in removed.files} == {FileAction.REMOVED}+ assert not root.exists()+ assert kiro.TARGET.detect(repo) == []+++def test_kiro_keeps_a_sibling_server_and_a_steering_file_it_did_not_write(+ tmp_path: Path,+) -> None:+ kiro = _kiro()+ repo = tmp_path / "repo"+ settings = repo / ".kiro" / "settings" / "mcp.json"+ settings.parent.mkdir(parents=True)+ settings.write_text(json.dumps({"mcpServers": {"other": {"command": "x"}}}), encoding="utf-8")+ steering = repo / ".kiro" / "steering" / "repowise.md"+ steering.parent.mkdir(parents=True)+ steering.write_text("my own notes\n", encoding="utf-8")++ result = kiro.TARGET.install(Scope.PROJECT, repo_path=repo)++ assert {f.path: f.action for f in result.files}[steering] is FileAction.KEPT+ assert steering.read_text(encoding="utf-8") == "my own notes\n"+ kiro.TARGET.uninstall(Scope.PROJECT, repo_path=repo)+ assert json.loads(settings.read_text(encoding="utf-8")) == {+ "mcpServers": {"other": {"command": "x"}}+ }+ assert steering.read_text(encoding="utf-8") == "my own notes\n"+++def test_kiro_doctor_reports_each_user_state() -> None:+ kiro = _kiro()+ assert kiro.TARGET.doctor().status.value == "not-installed"++ path = kiro.mcp_config_path(Scope.USER)+ path.parent.mkdir(parents=True)+ path.write_text("[]", encoding="utf-8")+ assert kiro.TARGET.doctor().status.value == "broken"++ path.unlink()+ kiro.TARGET.install(Scope.USER)+ assert kiro.TARGET.doctor().status.value == "ok"+++def test_kiro_install_notes_that_the_ide_ships_with_mcp_off(tmp_path: Path) -> None:+ result = _kiro().TARGET.install(Scope.USER)+ assert any("MCP disabled" in note for note in result.notes)+++def test_copilot_instructions_survive_removing_vscode_while_copilot_cli_reads_them(+ tmp_path: Path,+) -> None:+ from repowise.cli.agent_targets.registry import removing++ repo = tmp_path / "repo"+ repo.mkdir()+ vscode_target, copilot_target = get_target("vscode"), get_target("copilot")+ vscode_target.install(Scope.PROJECT, repo_path=repo)+ copilot_target.install(Scope.USER)+ copilot_target.install(Scope.PROJECT, repo_path=repo)+ path = _copilot_instructions(repo)++ result = vscode_target.uninstall(Scope.PROJECT, repo_path=repo)++ assert {f.path: f.action for f in result.files}[path] is FileAction.KEPT+ assert any("GitHub Copilot CLI" in note for note in result.notes)+ assert path.exists()++ vscode_target.install(Scope.PROJECT, repo_path=repo)+ with removing(["vscode", "copilot"]):+ vscode_target.uninstall(Scope.PROJECT, repo_path=repo)+ copilot_target.uninstall(Scope.PROJECT, repo_path=repo)+ assert not path.exists()+++def test_a_project_only_copilot_install_keeps_the_block_when_vscode_is_removed(+ tmp_path: Path,+) -> None:+ """add copilot --scope=project, add vscode, remove vscode: the block stays."""+ repo = tmp_path / "repo"+ repo.mkdir()+ get_target("copilot").install(Scope.PROJECT, repo_path=repo)+ get_target("vscode").install(Scope.PROJECT, repo_path=repo)++ result = get_target("vscode").uninstall(Scope.PROJECT, repo_path=repo)++ path = _copilot_instructions(repo)+ assert {f.path: f.action for f in result.files}[path] is FileAction.KEPT+ assert any("--target=copilot" in note for note in result.notes)+ assert path.exists()+++def test_kiro_user_scope_follows_kiro_home(tmp_path: Path, monkeypatch) -> None:+ kiro = _kiro()+ monkeypatch.setenv("KIRO_HOME", str(tmp_path / "kh"))++ kiro.TARGET.install(Scope.USER)++ assert (tmp_path / "kh" / "settings" / "mcp.json").exists()+ assert not (Path.home() / ".kiro").exists()+++def test_removing_vscode_and_copilot_together_leaves_no_file(tmp_path: Path) -> None:+ from repowise.cli.agent_targets.registry import removing++ repo = tmp_path / "repo"+ repo.mkdir()+ get_target("copilot").install(Scope.PROJECT, repo_path=repo)+ get_target("vscode").install(Scope.PROJECT, repo_path=repo)++ with removing(["vscode", "copilot"]):+ get_target("vscode").uninstall(Scope.PROJECT, repo_path=repo)+ get_target("copilot").uninstall(Scope.PROJECT, repo_path=repo)++ assert not _copilot_instructions(repo).exists()diff --git a/tests/unit/cli/test_agents_cmd.py b/tests/unit/cli/test_agents_cmd.pyindex 879142c3c..1db037fd9 100644--- a/tests/unit/cli/test_agents_cmd.py+++ b/tests/unit/cli/test_agents_cmd.py@@ -77,12 +77,14 @@ def test_bare_agents_lists_every_registered_target_as_json(repo: Path) -> None:"cursor","opencode","hermes",+ "copilot",+ "kiro",]for row in payload["agents"]:# The keys the table renders, so a dropped one is a broken table.assert set(row) >= {"id", "tier", "present", "registrations", "method"}assert payload["agents"][0]["tier"] == "full"- assert payload["agents"][2]["tier"] == "basic"+ assert payload["agents"][2]["tier"] == "good"def test_list_reports_registrations_as_a_list_not_a_boolean(repo: Path) -> None:@@ -361,6 +363,8 @@ def test_doctor_reports_one_row_per_agent_from_its_own_descriptor(repo: Path) ->"Agent: cursor","Agent: opencode","Agent: hermes",+ "Agent: copilot",+ "Agent: kiro",]# Nothing is wired on a clean machine, and an agent you do not use is not a# problem with your setup.diff --git a/tests/unit/cli/test_vscode_setup.py b/tests/unit/cli/test_vscode_setup.pyindex 20552fc46..ad59407f9 100644--- a/tests/unit/cli/test_vscode_setup.py+++ b/tests/unit/cli/test_vscode_setup.py@@ -171,11 +171,12 @@ def test_save_vscode_extensions_config_rejects_jsonc_without_writing(tmp_path: P# ----------------------------------------------------------------------------def test_vscode_setup_writes_both_project_files(tmp_path: Path) -> None:+def test_vscode_setup_writes_every_project_file(tmp_path: Path) -> None:VSCodeSetup().write_project_files(_silent_console(), tmp_path, EditorSetupOptions())assert (tmp_path / ".vscode" / "mcp.json").exists()assert (tmp_path / ".vscode" / "extensions.json").exists()+ assert (tmp_path / ".github" / "copilot-instructions.md").exists()def test_vscode_setup_skips_when_project_file_disabled(tmp_path: Path) -> None: