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(parse): preserve text file parser metadata (#3480)
Wu JiaCheng5ab30d3e048f
diff --git a/openviking/parse/parsers/text.py b/openviking/parse/parsers/text.pyindex 6e2515038..f5e22a176 100644--- a/openviking/parse/parsers/text.py+++ b/openviking/parse/parsers/text.py@@ -29,7 +29,10 @@ class TextParser(BaseParser):async def parse(self, source: Union[str, Path], instruction: str = "", **kwargs) -> ParseResult:"""Parse from file path or content string."""- return await self._md_parser.parse(source, **kwargs)+ result = await self._md_parser.parse(source, instruction=instruction, **kwargs)+ result.source_format = "text"+ result.parser_name = "TextParser"+ return resultasync def parse_content(self, content: str, source_path: Optional[str] = None, instruction: str = "", **kwargsdiff --git a/tests/parse/parsers/test_text.py b/tests/parse/parsers/test_text.pynew file mode 100644index 000000000..89b64e25b--- /dev/null+++ b/tests/parse/parsers/test_text.py@@ -0,0 +1,25 @@+from types import SimpleNamespace+from unittest.mock import AsyncMock++from openviking.parse.base import NodeType, ResourceNode, create_parse_result+from openviking.parse.parsers.text import TextParser+++async def test_file_parse_preserves_text_parser_metadata_and_instruction(tmp_path):+ source = tmp_path / "notes.txt"+ source.write_text("Plain text content", encoding="utf-8")+ delegate_parse = AsyncMock(+ return_value=create_parse_result(+ root=ResourceNode(type=NodeType.ROOT),+ source_format="markdown",+ parser_name="MarkdownParser",+ )+ )+ parser = TextParser.__new__(TextParser)+ parser._md_parser = SimpleNamespace(parse=delegate_parse)++ result = await parser.parse(source, instruction="preserve this", marker=True)++ delegate_parse.assert_awaited_once_with(source, instruction="preserve this", marker=True)+ assert result.source_format == "text"+ assert result.parser_name == "TextParser"