Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(code): recognize ssh clone URLs with userinfo (#1421)
yeyitech7bbdc7090476
diff --git a/openviking/utils/code_hosting_utils.py b/openviking/utils/code_hosting_utils.pyindex c57e1fde0..637018ff8 100644--- a/openviking/utils/code_hosting_utils.py+++ b/openviking/utils/code_hosting_utils.py@@ -13,6 +13,18 @@ from urllib.parse import urlparsefrom openviking_cli.utils.config import get_openviking_config+def _extract_host(url: str) -> str:+ """Extract normalized host for supported git/code-hosting URL forms."""+ if url.startswith("git@"):+ rest = url[4:]+ if ":" not in rest:+ return ""+ return rest.split(":", 1)[0].strip().lower()++ parsed = urlparse(url)+ return (parsed.hostname or parsed.netloc or "").strip().lower()++def parse_code_hosting_url(url: str) -> Optional[str]:"""Parse code hosting platform URL to get org/repo path.@@ -32,6 +44,7 @@ def parse_code_hosting_url(url: str) -> Optional[str]:+ config.code.code_hosting_domains))+ host = _extract_host(url)# Handle git@ SSH URLs: git@host:org/repo.gitif url.startswith("git@"):@@ -60,7 +73,7 @@ def parse_code_hosting_url(url: str) -> Optional[str]:# For GitHub/GitLab URLs with org/repo structureif (- parsed.netloc in config.code.github_domains + config.code.gitlab_domains+ host in config.code.github_domains + config.code.gitlab_domainsand len(path_parts) >= 2):# Take first two parts: org/repo@@ -86,7 +99,7 @@ def is_github_url(url: str) -> bool:True if the URL is a GitHub URL"""config = get_openviking_config()- return urlparse(url).netloc in config.code.github_domains+ return _extract_host(url) in config.code.github_domainsdef is_gitlab_url(url: str) -> bool:@@ -99,7 +112,7 @@ def is_gitlab_url(url: str) -> bool:True if the URL is a GitLab URL"""config = get_openviking_config()- return urlparse(url).netloc in config.code.gitlab_domains+ return _extract_host(url) in config.code.gitlab_domainsdef is_code_hosting_url(url: str) -> bool:@@ -127,7 +140,7 @@ def is_code_hosting_url(url: str) -> bool:host_part = url[4:].split(":", 1)[0]return host_part in all_domains- return urlparse(url).netloc in all_domains+ return _extract_host(url) in all_domainsdef validate_git_ssh_uri(url: str) -> None:@@ -173,7 +186,7 @@ def is_git_repo_url(url: str) -> bool:))parsed = urlparse(url)- if parsed.netloc not in all_domains:+ if _extract_host(url) not in all_domains:return Falsepath_parts = [p for p in parsed.path.split("/") if p]# Strip .git suffix from last part for countingdiff --git a/tests/test_code_hosting_utils.py b/tests/test_code_hosting_utils.pyindex 67c048e90..9f9fa14fa 100644--- a/tests/test_code_hosting_utils.py+++ b/tests/test_code_hosting_utils.py@@ -81,6 +81,14 @@ def test_parse_code_hosting_url_https_dotgit():assert parse_code_hosting_url("https://github.com/org/repo.git") == "org/repo"+def test_parse_code_hosting_url_ssh_with_userinfo():+ assert parse_code_hosting_url("ssh://[email protected]/org/repo.git") == "org/repo"+++def test_parse_code_hosting_url_https_with_explicit_port():+ assert parse_code_hosting_url("https://github.com:443/org/repo.git") == "org/repo"++# --- validate_git_ssh_uri ---@@ -118,6 +126,14 @@ def test_is_code_hosting_url_https():assert is_code_hosting_url("https://github.com/org/repo") is True+def test_is_code_hosting_url_ssh_with_userinfo():+ assert is_code_hosting_url("ssh://[email protected]/org/repo.git") is True+++def test_is_code_hosting_url_https_with_explicit_port():+ assert is_code_hosting_url("https://github.com:443/org/repo") is True++# --- is_git_repo_url ---@@ -129,6 +145,14 @@ def test_is_git_repo_url_https_repo():assert is_git_repo_url("https://github.com/org/repo") is True+def test_is_git_repo_url_ssh_with_userinfo():+ assert is_git_repo_url("ssh://[email protected]/org/repo.git") is True+++def test_is_git_repo_url_https_with_explicit_port():+ assert is_git_repo_url("https://github.com:443/org/repo") is True++def test_is_git_repo_url_https_issues():assert is_git_repo_url("https://github.com/org/repo/issues/123") is False