Canonicalize GitHub repo resolution for ambiguous product repos

This commit is contained in:
nidhi-singh02
2026-04-22 18:14:14 +05:30
committed by Trevin Chow
parent 0f03a67166
commit d0b990e211
4 changed files with 154 additions and 1 deletions
+38
View File
@@ -260,6 +260,44 @@ class CliV3Tests(unittest.TestCase):
fake_progress.show_promo.assert_called_once_with("both", diag=diag)
self.assertIn("# rendered", stdout.getvalue())
def test_main_canonicalizes_explicit_github_repo_flags(self):
report = self.make_report()
diag = {
"available_sources": ["grounding"],
"providers": {"google": True, "openai": False, "xai": False},
"x_backend": None,
"bird_installed": True,
"bird_authenticated": False,
"bird_username": None,
"native_web_backend": "brave",
}
with mock.patch.object(cli.env, "get_config", return_value={}), \
mock.patch.object(cli.pipeline, "diagnose", return_value=diag), \
mock.patch.object(cli.pipeline, "run", return_value=report) as run_mock, \
mock.patch.object(cli, "emit_output", return_value="# rendered"), \
mock.patch.object(sys, "argv", [
"last30days.py",
"claude",
"code",
"vs",
"codex",
"--github-repo",
"openai/codex,anthropics/claude-code-action",
]):
stdout = io.StringIO()
stderr = io.StringIO()
with redirect_stdout(stdout), redirect_stderr(stderr):
rc = cli.main()
self.assertEqual(0, rc)
# In vs-mode the main_runner is the first pipeline.run call; sub-runs
# for competitor entities follow with their own per-entity github_repos.
kwargs = run_mock.call_args_list[0].kwargs
self.assertEqual(
["openai/codex", "anthropics/claude-code"],
kwargs["github_repos"],
)
self.assertIn("[GitHub] Canonicalized repos:", stderr.getvalue())
if __name__ == "__main__":
unittest.main()
+18
View File
@@ -109,6 +109,24 @@ class TestBuildContextSummary(unittest.TestCase):
self.assertEqual(resolve._build_context_summary(items), "")
class TestCanonicalizeGithubRepos(unittest.TestCase):
def test_rewrites_integration_repo_to_canonical_product(self):
repos = ["openai/codex", "anthropics/claude-code-action"]
result = resolve.canonicalize_github_repos("claude code vs codex", repos, cap=None)
self.assertEqual(result, ["openai/codex", "anthropics/claude-code"])
def test_preserves_action_repo_when_topic_intends_action(self):
repos = ["anthropics/claude-code-action", "openai/codex"]
result = resolve.canonicalize_github_repos("claude code action setup", repos, cap=None)
self.assertIn("anthropics/claude-code-action", result)
self.assertNotIn("anthropics/claude-code", result)
def test_dedupes_case_insensitive_after_canonicalization(self):
repos = ["Anthropics/Claude-Code-Action", "anthropics/claude-code"]
result = resolve.canonicalize_github_repos("claude code", repos, cap=None)
self.assertEqual(result, ["Anthropics/Claude-Code"])
class TestAutoResolve(unittest.TestCase):
def test_no_backend_returns_empty(self):
result = resolve.auto_resolve("test topic", {})