feat: codegraph
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
from pathlib import Path
|
||||
|
||||
from agentci.adapters.codegraph import CodeGraphClient
|
||||
|
||||
|
||||
class FakeProcess:
|
||||
returncode = 0
|
||||
|
||||
async def communicate(self) -> tuple[bytes, bytes]:
|
||||
return b"", b""
|
||||
|
||||
|
||||
async def test_initializes_index_and_excludes_it_from_git(
|
||||
tmp_path: Path, monkeypatch
|
||||
) -> None:
|
||||
workspace = tmp_path / "repo"
|
||||
(workspace / ".git" / "info").mkdir(parents=True)
|
||||
calls: list[tuple[object, ...]] = []
|
||||
|
||||
async def create_subprocess_exec(*args, **_kwargs):
|
||||
calls.append(args)
|
||||
return FakeProcess()
|
||||
|
||||
monkeypatch.setattr(
|
||||
"agentci.adapters.codegraph.asyncio.create_subprocess_exec",
|
||||
create_subprocess_exec,
|
||||
)
|
||||
|
||||
await CodeGraphClient().prepare(workspace)
|
||||
|
||||
assert calls == [("codegraph", "init", str(workspace))]
|
||||
assert (workspace / ".git" / "info" / "exclude").read_text() == ".codegraph/\n"
|
||||
|
||||
|
||||
async def test_syncs_an_existing_index_without_duplicating_exclude(
|
||||
tmp_path: Path, monkeypatch
|
||||
) -> None:
|
||||
workspace = tmp_path / "repo"
|
||||
(workspace / ".git" / "info").mkdir(parents=True)
|
||||
(workspace / ".codegraph").mkdir()
|
||||
exclude = workspace / ".git" / "info" / "exclude"
|
||||
exclude.write_text("# local excludes\n.codegraph/\n")
|
||||
calls: list[tuple[object, ...]] = []
|
||||
|
||||
async def create_subprocess_exec(*args, **_kwargs):
|
||||
calls.append(args)
|
||||
return FakeProcess()
|
||||
|
||||
monkeypatch.setattr(
|
||||
"agentci.adapters.codegraph.asyncio.create_subprocess_exec",
|
||||
create_subprocess_exec,
|
||||
)
|
||||
|
||||
await CodeGraphClient().prepare(workspace)
|
||||
|
||||
assert calls == [("codegraph", "sync", str(workspace))]
|
||||
assert exclude.read_text() == "# local excludes\n.codegraph/\n"
|
||||
@@ -1,8 +1,19 @@
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
from agentci.adapters.codex import CodexClient, _session_id
|
||||
|
||||
|
||||
def test_enables_codegraph_in_shared_codex_config() -> None:
|
||||
root = Path(__file__).parents[1]
|
||||
config = tomllib.loads((root / "codex" / "config.toml").read_text())
|
||||
|
||||
codegraph = config["mcp_servers"]["codegraph"]
|
||||
assert codegraph["command"] == "codegraph"
|
||||
assert codegraph["args"] == ["serve", "--mcp"]
|
||||
assert codegraph["env"]["CODEGRAPH_TELEMETRY"] == "0"
|
||||
|
||||
|
||||
def test_extracts_thread_id_from_jsonl() -> None:
|
||||
output = '\n'.join(
|
||||
[
|
||||
@@ -49,6 +60,7 @@ def test_configures_research_agent_and_optional_context7_key(tmp_path) -> None:
|
||||
assert parsed["model"] == "research-model"
|
||||
assert parsed["model_reasoning_effort"] == "high"
|
||||
assert parsed["web_search"] == "live"
|
||||
assert parsed["mcp_servers"]["codegraph"]["enabled"] is False
|
||||
assert 'url = "https://mcp.context7.com/mcp"' in agent
|
||||
assert 'url = "https://mcp.grep.app"' in agent
|
||||
assert "ctx7-secret" not in agent
|
||||
|
||||
Reference in New Issue
Block a user