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
import re
from pathlib import Path
from scripts.build_support.readme import pypi_long_description, rewrite_relative_urls
RAW = "https://raw.githubusercontent.com/volcengine/OpenViking/main/"
BLOB = "https://github.com/volcengine/OpenViking/blob/main/"
def test_rewrites_relative_html_images_and_links():
text = (
'<a href="docs/a.md"><picture><source srcset="docs/images/x-dark.svg">'
'<img src="docs/images/x.svg"></picture></a>'
)
assert rewrite_relative_urls(text) == (
f'<a href="{BLOB}docs/a.md"><picture><source srcset="{RAW}docs/images/x-dark.svg">'
f'<img src="{RAW}docs/images/x.svg"></picture></a>'
)
def test_rewrites_relative_markdown_images_and_links():
text = " see [LICENSE](./LICENSE) and [bench](./benchmark)"
assert rewrite_relative_urls(text) == (
f" see [LICENSE]({BLOB}LICENSE) and [bench]({BLOB}benchmark)"
)
def test_keeps_absolute_urls_and_anchors():
text = '[a](https://x.dev/p) [b](#section) <img src="https://x.dev/i.png"> <a href="mailto:[email protected]">m</a>'
assert rewrite_relative_urls(text) == text
def test_repository_readme_has_no_relative_targets():
readme = Path(__file__).resolve().parents[2] / "README.md"
description = pypi_long_description(readme)
targets = re.findall(r'(?:src|srcset|href)="([^"]*)"', description)
targets += re.findall(r"\]\(([^)\s]+)", description)
relative = [t for t in targets if not re.match(r"^(?:https?:|mailto:|#)", t)]
assert relative == []
def test_pypi_removes_github_utm_from_cloud_links_only(tmp_path):
"""复用渠道不误标为 GitHub,业务参数、锚点和其他来源保持不变。"""
readme = tmp_path / "README.md"
product = "https://www.volcengine.com/product/openviking-service"
console = "https://console.volcengine.com/vikingdb/openviking/region:openviking+cn-beijing"
text = (
f"[云服务]({product}?plan=personal&utm_medium=referral&utm_source=github&utm_campaign=readme#plans) "
f'<a href="{console}?utm_source=github&utm_content=card&lang=zh&utm_term=agent">控制台</a> '
f"[文档来源]({product}?utm_source=opensource_docs&utm_medium=referral) "
"[其他链接](https://example.com/?utm_source=github)"
)
readme.write_text(text, encoding="utf-8")
assert pypi_long_description(readme) == (
f"[云服务]({product}?plan=personal#plans) "
f'<a href="{console}?lang=zh">控制台</a> '
f"[文档来源]({product}?utm_source=opensource_docs&utm_medium=referral) "
"[其他链接](https://example.com/?utm_source=github)"
)
assert readme.read_text(encoding="utf-8") == text