Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

feat(llm): add GitHub Copilot CLI provider (#3710)

Taejeong Kwon7320f81300a1
diff --git a/docs/agent/INTEGRATIONS.md b/docs/agent/INTEGRATIONS.md
index cae9913a8..48baacb1c 100644
--- a/docs/agent/INTEGRATIONS.md
+++ b/docs/agent/INTEGRATIONS.md
@@ -44,7 +44,7 @@ either way.
| [Cursor](https://cursor.com/docs/context/mcp) | Good | Yes | Yes | No | No | Yes | No | No | Yes |
| [OpenCode](https://opencode.ai/docs/mcp-servers/) | Good | Yes | No | No | No | Yes | No | Yes | No |
| [Hermes](https://hermes-agent.nousresearch.com/docs/user-guide/features/mcp) | Good | Yes | No | No | No | Yes | No | 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 | No |
+| [GitHub Copilot CLI](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference) | Good | Yes | No | No | No | Yes | No | Yes | No |
| [Kiro](https://kiro.dev/docs/mcp/configuration) | Good | Yes | No | No | No | Yes | No | No | No |
Target ids for `--target=`: `claude-code`, `codex`, `vscode`, `cursor`, `opencode`, `hermes`, `copilot`, `kiro`.
diff --git a/docs/architecture/agent-platform.md b/docs/architecture/agent-platform.md
index dc0d41f70..72b3a0761 100644
--- a/docs/architecture/agent-platform.md
+++ b/docs/architecture/agent-platform.md
@@ -13,8 +13,8 @@ An agent can touch repowise in two independent ways:
- Indexing backend: the agent's own CLI runs as the LLM that writes the
wiki, using the user's existing login, with no API key.
-An agent can have either, both or neither. GitHub Copilot CLI, for example, is
-an integration target with a registered identity and no indexing backend.
+An agent can have either, both or neither. GitHub Copilot CLI is both an
+integration target and an indexing backend through its authenticated local CLI.
**Contents**
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 18797c4b8..d80f61620 100644
--- a/packages/cli/src/repowise/cli/commands/init_cmd/command.py
+++ b/packages/cli/src/repowise/cli/commands/init_cmd/command.py
@@ -125,7 +125,8 @@ def _run_workspace_init(opts: InitOptions, scan: Any) -> None:
default=None,
help=(
"LLM provider name (anthropic, openai, openrouter, gemini, "
- "deepseek, kimi, ollama, litellm, codex_cli, claude_cli, opencode, "
+ "deepseek, kimi, ollama, litellm, codex_cli, copilot_cli, claude_cli, "
+ "opencode, "
"edenai, mock). "
"In a terminal, a missing key is prompted for; openai also asks for "
"an optional OpenAI-compatible Base URL."
diff --git a/packages/core/src/repowise/core/agents/identity.py b/packages/core/src/repowise/core/agents/identity.py
index 049fc1f7e..ace59327d 100644
--- a/packages/core/src/repowise/core/agents/identity.py
+++ b/packages/core/src/repowise/core/agents/identity.py
@@ -225,6 +225,7 @@ COPILOT = AgentIdentity(
executable="copilot",
install_hint="npm install -g @github/copilot",
login_hint="copilot login",
+ indexing_provider="copilot_cli",
)
KIRO = AgentIdentity(
slug="kiro", display_name="Kiro", executable="kiro-cli", login_hint="kiro-cli login"
diff --git a/packages/core/src/repowise/core/providers/llm/__init__.py b/packages/core/src/repowise/core/providers/llm/__init__.py
index 7b3f81428..0143f4a4d 100644
--- a/packages/core/src/repowise/core/providers/llm/__init__.py
+++ b/packages/core/src/repowise/core/providers/llm/__init__.py
@@ -21,6 +21,7 @@ Built-in providers:
codex_cli — local authenticated Codex CLI via codex exec
claude_cli — local authenticated Claude Code CLI via claude -p
opencode — local opencode CLI via opencode run
+ copilot_cli — local authenticated GitHub Copilot CLI
mock — deterministic test provider
"""
diff --git a/packages/core/src/repowise/core/providers/llm/copilot_cli.py b/packages/core/src/repowise/core/providers/llm/copilot_cli.py
new file mode 100644
index 000000000..cd15e6c5b
--- /dev/null
+++ b/packages/core/src/repowise/core/providers/llm/copilot_cli.py
@@ -0,0 +1,130 @@
+"""GitHub Copilot CLI provider for repowise.
+
+Runs the authenticated Copilot CLI as a tool-free JSONL text generator. The
+shared agent-CLI base handles subprocess lifecycle, prompt transport, timeout,
+cancellation, concurrency, and errors.
+"""
+
+from __future__ import annotations
+
+from typing import Any
+
+from repowise.core.providers.llm.agent_cli import (
+ AgentCliProvider,
+ iter_jsonl,
+ model_label,
+ normalize_model,
+ tail,
+)
+from repowise.core.providers.llm.base import GeneratedResponse, ProviderError
+from repowise.core.reasoning import ReasoningMode
+
+# Copilot treats an unknown allowlist entry as no available tools. Omitting this
+# flag exposes the CLI's default tools, so keep the explicit empty-list sentinel.
+_NO_TOOLS_ALLOWLIST = "repowise_no_tools"
+
+
+def _combine_prompt(system_prompt: str, user_prompt: str) -> str:
+ return (
+ "System instructions for this task:\n\n"
+ f"{system_prompt.strip()}\n\n"
+ "---\n\n"
+ "User request and context:\n\n"
+ f"{user_prompt.strip()}\n\n"
+ "You have no tools available. Do not attempt to call tools; answer directly."
+ )
+
+
+def _token_count(value: object) -> int:
+ if isinstance(value, (int, float)) and not isinstance(value, bool):
+ return max(0, int(value))
+ return 0
+
+
+def _parse_jsonl(stdout: str) -> tuple[str, dict[str, Any]]:
+ content_parts: list[str] = []
+ accounting: dict[str, Any] = {}
+
+ for event in iter_jsonl(stdout):
+ if not isinstance(event, dict):
+ continue
+ data = event.get("data")
+ if not isinstance(data, dict):
+ continue
+
+ if event.get("type") == "assistant.message":
+ content = data.get("content")
+ if isinstance(content, str) and content.strip():
+ content_parts.append(content)
+ elif event.get("type") == "session.usage_checkpoint":
+ snapshot = data.get("accountingSnapshot")
+ if isinstance(snapshot, dict):
+ accounting = snapshot
+
+ return "\n".join(content_parts), accounting
+
+
+def _model_label(model: str | None) -> str:
+ return model_label(normalize_model(model, "copilot_cli", None), "copilot_cli")
+
+
+class CopilotCliProvider(AgentCliProvider):
+ """LLM provider backed by the user's authenticated GitHub Copilot CLI."""
+
+ provider_name = "copilot_cli"
+ agent_slug = "copilot"
+ command_label = "copilot"
+ concurrency_env = "REPOWISE_COPILOT_CLI_CONCURRENCY"
+
+ def build_command(self, system_prompt: str, reasoning: ReasoningMode) -> list[str]:
+ cmd = [
+ self._executable,
+ "--output-format",
+ "json",
+ "--no-ask-user",
+ f"--available-tools={_NO_TOOLS_ALLOWLIST}",
+ "--disable-builtin-mcps",
+ "--no-custom-instructions",
+ "--silent",
+ "-C",
+ str(self._repo_path),
+ ]
+ if self._model:
+ cmd.extend(["--model", self._model])
+ return cmd
+
+ def build_stdin(self, system_prompt: str, user_prompt: str) -> str:
+ return _combine_prompt(system_prompt, user_prompt)
+
+ def parse_output(self, stdout: str, stderr: str) -> GeneratedResponse:
+ content, accounting = _parse_jsonl(stdout)
+ if not content:
+ raise ProviderError(
+ "copilot_cli",
+ "copilot completed but no text was found in JSONL output.",
+ )
+
+ token_details = accounting.get("tokenDetails")
+ token_details = token_details if isinstance(token_details, dict) else {}
+ cache_read = token_details.get("cache_read")
+ cache_read = cache_read if isinstance(cache_read, dict) else {}
+ input_tokens = _token_count(accounting.get("lastCallInputTokens"))
+ output_tokens = _token_count(accounting.get("lastCallOutputTokens"))
+ usage: dict[str, Any] = {
+ "source": "copilot_cli_jsonl",
+ "model": self.model_name,
+ "stderr": tail(stderr, 1_000),
+ }
+ if accounting:
+ if "totalPremiumRequestCost" in accounting:
+ usage["totalPremiumRequestCost"] = accounting["totalPremiumRequestCost"]
+ else:
+ usage["estimated"] = True
+
+ return GeneratedResponse(
+ content=content,
+ input_tokens=input_tokens,
+ output_tokens=output_tokens,
+ cached_tokens=_token_count(cache_read.get("tokenCount")),
+ usage=usage,
+ )
\ No newline at end of file
diff --git a/packages/core/src/repowise/core/providers/llm/specs.py b/packages/core/src/repowise/core/providers/llm/specs.py
index c2609922c..56cff0c12 100644
--- a/packages/core/src/repowise/core/providers/llm/specs.py
+++ b/packages/core/src/repowise/core/providers/llm/specs.py
@@ -154,7 +154,7 @@ _SPECS: tuple[ProviderSpec, ...] = (
),
ProviderSpec(
name="openrouter",
- picker_rank=10,
+ picker_rank=11,
impl=f"{_LLM}.openrouter:OpenRouterProvider",
label="OpenRouter",
default_model="google/gemini-3.5-flash-lite",
@@ -221,7 +221,7 @@ _SPECS: tuple[ProviderSpec, ...] = (
),
ProviderSpec(
name="ollama",
- picker_rank=9,
+ picker_rank=10,
impl=f"{_LLM}.ollama:OllamaProvider",
label="Ollama (Local)",
default_model="qwen3.5:4b",
@@ -237,7 +237,7 @@ _SPECS: tuple[ProviderSpec, ...] = (
),
ProviderSpec(
name="litellm",
- picker_rank=11,
+ picker_rank=12,
impl=f"{_LLM}.litellm:LiteLLMProvider",
label="LiteLLM",
default_model="groq/openai/gpt-oss-120b",
@@ -298,6 +298,20 @@ _SPECS: tuple[ProviderSpec, ...] = (
agent="opencode",
note="uses your opencode CLI setup",
),
+ ProviderSpec(
+ name="copilot_cli",
+ picker_rank=9,
+ impl=f"{_LLM}.copilot_cli:CopilotCliProvider",
+ label="GitHub Copilot (Local CLI)",
+ default_model="copilot_cli/default",
+ models=("copilot_cli/default",),
+ keyless=True,
+ needs_repo_cwd=True,
+ local=True,
+ zero_cost=True,
+ agent="copilot",
+ note="uses your Copilot CLI login",
+ ),
ProviderSpec(
name="mock",
impl=f"{_LLM}.mock:MockProvider",
diff --git a/tests/providers/test_registry.py b/tests/providers/test_registry.py
index 2a5d5446a..d0b0ccf9f 100644
--- a/tests/providers/test_registry.py
+++ b/tests/providers/test_registry.py
@@ -27,6 +27,7 @@ class TestListProviders:
assert "ollama" in providers
assert "litellm" in providers
assert "codex_cli" in providers
+ assert "copilot_cli" in providers
assert "mock" in providers
assert "kimi" in providers
@@ -117,5 +118,5 @@ class TestCustomProviderRegistration:
assert received.get("api_key") == "key-123"
def test_builtin_count(self) -> None:
- """Sanity check: we have exactly 13 built-in providers."""
- assert len(_BUILTIN_PROVIDERS) == 13
+ """Sanity check: we have exactly 14 built-in providers."""
+ assert len(_BUILTIN_PROVIDERS) == 14
diff --git a/tests/unit/cli/test_agent_matrix.py b/tests/unit/cli/test_agent_matrix.py
index c9678b0ad..f7a5c16f3 100644
--- a/tests/unit/cli/test_agent_matrix.py
+++ b/tests/unit/cli/test_agent_matrix.py
@@ -200,6 +200,13 @@ def test_the_indexing_column_matches_the_identities() -> None:
assert GEN._cell(row, "indexing_provider") == expected, row["id"]
+def test_the_attribution_column_matches_the_supported_agents() -> None:
+ """Attribution is derived from each target's capture adapter."""
+ for row in GEN.agent_rows():
+ expected = "Yes" if row["capture_adapter"] else "No"
+ assert GEN._cell(row, "capture_adapter") == expected, row["id"]
+
+
def test_the_hooks_column_cannot_lie() -> None:
"""A target's declared HOOKS capability agrees with its hook adapter.
diff --git a/tests/unit/cli/test_init_ux.py b/tests/unit/cli/test_init_ux.py
index ec1013d62..51216fa7e 100644
--- a/tests/unit/cli/test_init_ux.py
+++ b/tests/unit/cli/test_init_ux.py
@@ -246,6 +246,7 @@ def test_the_keyless_providers_get_setup_help_instead_of_a_key_prompt() -> None:
"codex_cli",
"claude_cli",
"opencode",
+ "copilot_cli",
"ollama",
}
for name, lines in provider_selection._LOCAL_PROVIDER_SETUP.items():
@@ -520,6 +521,7 @@ def test_picker_rows_keep_their_order() -> None:
"claude_cli",
"codex_cli",
"opencode",
+ "copilot_cli",
"ollama",
"openrouter",
"litellm",
diff --git a/tests/unit/server/mcp/test_answer_synthesis_timeout.py b/tests/unit/server/mcp/test_answer_synthesis_timeout.py
index 76b7b42ac..953f7eb94 100644
--- a/tests/unit/server/mcp/test_answer_synthesis_timeout.py
+++ b/tests/unit/server/mcp/test_answer_synthesis_timeout.py
@@ -193,6 +193,7 @@ def test_every_builtin_provider_has_a_deliberate_budget():
"codex_cli": 180.0,
"claude_cli": 180.0,
"opencode": 180.0,
+ "copilot_cli": 180.0,
}
assert set(expected) == set(_BUILTIN_PROVIDERS), (
"a provider was added or removed; decide its interactive budget here"
diff --git a/tests/unit/test_providers/test_agent_cli_contract.py b/tests/unit/test_providers/test_agent_cli_contract.py
index 658132b91..4f5d69524 100644
--- a/tests/unit/test_providers/test_agent_cli_contract.py
+++ b/tests/unit/test_providers/test_agent_cli_contract.py
@@ -20,6 +20,7 @@ from repowise.core.providers.llm.agent_cli import AgentCliProvider
from repowise.core.providers.llm.base import GeneratedResponse, ProviderError
from repowise.core.providers.llm.claude_cli import ClaudeCliProvider
from repowise.core.providers.llm.codex_cli import CodexCliProvider
+from repowise.core.providers.llm.copilot_cli import CopilotCliProvider
from repowise.core.providers.llm.opencode import OpenCodeProvider
from repowise.core.providers.llm.registry import _BUILTIN_PROVIDERS
@@ -74,6 +75,26 @@ def _opencode_stdout(text: str) -> str:
)
+def _copilot_stdout(text: str) -> str:
+ return _jsonl(
+ {
+ "type": "assistant.message",
+ "data": {"content": text, "toolRequests": []},
+ },
+ {
+ "type": "session.usage_checkpoint",
+ "data": {
+ "accountingSnapshot": {
+ "lastCallInputTokens": 120,
+ "lastCallOutputTokens": 40,
+ "totalPremiumRequestCost": 1,
+ "tokenDetails": {"cache_read": {"tokenCount": 30}},
+ }
+ },
+ },
+ )
+
+
BACKENDS = [
Backend(
ClaudeCliProvider,
@@ -105,6 +126,15 @@ BACKENDS = [
env={"OPENCODE_DISABLE_PROJECT_CONFIG": "true"},
repo_cwd=True,
),
+ Backend(
+ CopilotCliProvider,
+ "gpt-5.5",
+ _copilot_stdout,
+ tokens=(120, 40, 30),
+ books_cost=False,
+ repo_flag="-C",
+ env=None,
+ ),
]
diff --git a/tests/unit/test_providers/test_copilot_cli_provider.py b/tests/unit/test_providers/test_copilot_cli_provider.py
new file mode 100644
index 000000000..d5b965c2c
--- /dev/null
+++ b/tests/unit/test_providers/test_copilot_cli_provider.py
@@ -0,0 +1,101 @@
+"""Unit tests for CopilotCliProvider; the CLI subprocess is mocked."""
+
+from __future__ import annotations
+
+import json
+from typing import Any
+
+import pytest
+
+from repowise.core.providers.llm.base import ProviderError
+from repowise.core.providers.llm.copilot_cli import CopilotCliProvider
+
+
+def _jsonl(*events: dict[str, Any]) -> str:
+ return "".join(json.dumps(event) + "\n" for event in events)
+
+
+def _captured_jsonl(text: str = "PONG") -> str:
+ return _jsonl(
+ {
+ "type": "assistant.message",
+ "data": {"content": text, "toolRequests": []},
+ },
+ {
+ "type": "session.usage_checkpoint",
+ "data": {
+ "accountingSnapshot": {
+ "lastCallInputTokens": 3425,
+ "lastCallOutputTokens": 5,
+ "totalPremiumRequestCost": 1,
+ "tokenDetails": {"cache_read": {"tokenCount": 0}},
+ }
+ },
+ },
+ )
+
+
+def test_build_command_uses_jsonl_and_exposes_no_tools(monkeypatch, tmp_path):
+ monkeypatch.setattr("shutil.which", lambda _cmd: "/usr/bin/copilot")
+ provider = CopilotCliProvider(model="gpt-5.5", repo_path=tmp_path)
+
+ command = provider.build_command("system", "auto")
+
+ assert command[0] == "/usr/bin/copilot"
+ assert "--output-format" in command
+ assert command[command.index("--output-format") + 1] == "json"
+ assert "--no-ask-user" in command
+ assert "--available-tools=repowise_no_tools" in command
+ assert "--disable-builtin-mcps" in command
+ assert "--no-custom-instructions" in command
+ assert "--allow-all-tools" not in command
+ assert "-p" not in command
+ assert command[command.index("-C") + 1] == str(tmp_path.resolve())
+ assert command[command.index("--model") + 1] == "gpt-5.5"
+
+
+def test_build_stdin_combines_system_and_user_prompts(monkeypatch, tmp_path):
+ monkeypatch.setattr("shutil.which", lambda _cmd: "/usr/bin/copilot")
+ provider = CopilotCliProvider(repo_path=tmp_path)
+
+ prompt = provider.build_stdin("system rules", "user context")
+
+ assert "system rules" in prompt
+ assert "user context" in prompt
+ assert "You have no tools available" in prompt
+
+
+def test_parse_captured_jsonl_and_usage(monkeypatch, tmp_path):
+ monkeypatch.setattr("shutil.which", lambda _cmd: "/usr/bin/copilot")
+ provider = CopilotCliProvider(repo_path=tmp_path)
+
+ result = provider.parse_output(_captured_jsonl("answer"), "")
+
+ assert result.content == "answer"
+ assert result.input_tokens == 3425
+ assert result.output_tokens == 5
+ assert result.cached_tokens == 0
+ assert result.usage["source"] == "copilot_cli_jsonl"
+ assert result.usage["totalPremiumRequestCost"] == 1
+
+
+def test_parse_output_marks_missing_usage_as_estimated(monkeypatch, tmp_path):
+ monkeypatch.setattr("shutil.which", lambda _cmd: "/usr/bin/copilot")
+ provider = CopilotCliProvider(repo_path=tmp_path)
+
+ result = provider.parse_output(
+ _jsonl({"type": "assistant.message", "data": {"content": "ok"}}),
+ "",
+ )
+
+ assert result.content == "ok"
+ assert result.input_tokens == result.output_tokens == result.cached_tokens == 0
+ assert result.usage["estimated"] is True
+
+
+def test_parse_output_requires_assistant_text(monkeypatch, tmp_path):
+ monkeypatch.setattr("shutil.which", lambda _cmd: "/usr/bin/copilot")
+ provider = CopilotCliProvider(repo_path=tmp_path)
+
+ with pytest.raises(ProviderError, match="no text was found"):
+ provider.parse_output(_jsonl({"type": "session.usage_checkpoint", "data": {}}), "")
\ No newline at end of file