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: support short-format URIs in VikingURI and VikingFS access control (#402)
r266-techf694540c0356
diff --git a/openviking/storage/viking_fs.py b/openviking/storage/viking_fs.pyindex afa1f9167..5b5afbb62 100644--- a/openviking/storage/viking_fs.py+++ b/openviking/storage/viking_fs.py@@ -945,7 +945,7 @@ class VikingFS:if ctx.role == Role.ROOT:return Trueif not uri.startswith("viking://"):- return False+ uri = VikingURI.normalize(uri)parts = [p for p in uri[len("viking://") :].strip("/").split("/") if p]if not parts:diff --git a/openviking_cli/utils/uri.py b/openviking_cli/utils/uri.pyindex 144ae0348..24b6805e7 100644--- a/openviking_cli/utils/uri.py+++ b/openviking_cli/utils/uri.py@@ -38,10 +38,13 @@ class VikingURI:"""Initialize URI handler.+ Accepts both full-format (viking://...) and short-format (/resources, resources)+ URIs. Short-format URIs are automatically normalized to full format.+Args:- uri: URI string+ uri: URI string (full or short format)"""- self.uri = uri+ self.uri = self.normalize(uri)self._parsed = self._parse()def _parse(self) -> Dict[str, str]:diff --git a/tests/unit/test_uri_short_format.py b/tests/unit/test_uri_short_format.pynew file mode 100644index 000000000..b4315ef7f--- /dev/null+++ b/tests/unit/test_uri_short_format.py@@ -0,0 +1,106 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: Apache-2.0+"""Tests for VikingURI short-format URI normalization.++Verifies that VikingURI accepts short-format paths (e.g., '/resources',+'user/memories') in addition to full-format URIs ('viking://resources').++Ref: https://github.com/volcengine/OpenViking/issues/259+"""++import pytest++from openviking_cli.utils.uri import VikingURI+++class TestVikingURIShortFormat:+ """VikingURI should accept and auto-normalize short-format URIs."""++ def test_slash_prefix_path(self):+ """'/resources' should be normalized to 'viking://resources'."""+ uri = VikingURI("/resources")+ assert uri.uri == "viking://resources"+ assert uri.scope == "resources"++ def test_bare_path(self):+ """'resources' should be normalized to 'viking://resources'."""+ uri = VikingURI("resources")+ assert uri.uri == "viking://resources"+ assert uri.scope == "resources"++ def test_slash_prefix_nested(self):+ """'/user/memories/preferences' should normalize correctly."""+ uri = VikingURI("/user/memories/preferences")+ assert uri.uri == "viking://user/memories/preferences"+ assert uri.scope == "user"++ def test_bare_nested_path(self):+ """'agent/skills/pdf' should normalize correctly."""+ uri = VikingURI("agent/skills/pdf")+ assert uri.uri == "viking://agent/skills/pdf"+ assert uri.scope == "agent"++ def test_full_format_unchanged(self):+ """Full-format URIs should pass through unchanged."""+ uri = VikingURI("viking://resources/my_project")+ assert uri.uri == "viking://resources/my_project"++ def test_root_slash(self):+ """'/' should normalize to 'viking://'."""+ uri = VikingURI("/")+ assert uri.uri == "viking://"+ assert uri.scope == ""++ def test_full_root(self):+ """'viking://' should work as before."""+ uri = VikingURI("viking://")+ assert uri.uri == "viking://"+ assert uri.scope == ""++ def test_join_after_short_format(self):+ """join() should work on auto-normalized URIs."""+ uri = VikingURI("/resources")+ joined = uri.join("my_project")+ assert joined.uri == "viking://resources/my_project"++ def test_parent_after_short_format(self):+ """parent should work on auto-normalized URIs."""+ uri = VikingURI("/user/memories/preferences")+ parent = uri.parent+ assert parent is not None+ assert parent.uri == "viking://user/memories"++ def test_is_valid_short_format(self):+ """is_valid should accept short-format URIs after normalization."""+ assert VikingURI.is_valid("/resources")+ assert VikingURI.is_valid("user/memories")++ def test_invalid_scope_still_rejected(self):+ """Invalid scopes should still raise ValueError."""+ with pytest.raises(ValueError, match="Invalid scope"):+ VikingURI("/invalid_scope/foo")++ def test_normalize_idempotent(self):+ """Normalizing an already-normalized URI should be idempotent."""+ original = "viking://resources/docs"+ assert VikingURI.normalize(original) == original+ assert (+ VikingURI.normalize(VikingURI.normalize("/resources/docs")) == "viking://resources/docs"+ )++ @pytest.mark.parametrize(+ "short,expected",+ [+ ("/resources", "viking://resources"),+ ("/user", "viking://user"),+ ("/agent/skills", "viking://agent/skills"),+ ("/session/abc123", "viking://session/abc123"),+ ("/queue", "viking://queue"),+ ("/temp", "viking://temp"),+ ("resources/images", "viking://resources/images"),+ ],+ )+ def test_all_scopes(self, short, expected):+ """All valid scopes should work with short format."""+ uri = VikingURI(short)+ assert uri.uri == expected