fix: [BUG] write_note Tool Fails to Update Existing Files in Some Situations. (#80)

This commit is contained in:
github-actions[bot]
2025-04-05 22:31:40 -05:00
committed by GitHub
parent 248214cb11
commit 9bff1f732e
2 changed files with 37 additions and 1 deletions
+6 -1
View File
@@ -92,7 +92,12 @@ class EntityParser:
async def parse_file(self, path: Path | str) -> EntityMarkdown:
"""Parse markdown file into EntityMarkdown."""
absolute_path = self.base_path / path
# Check if the path is already absolute
if isinstance(path, Path) and path.is_absolute() or (isinstance(path, str) and Path(path).is_absolute()):
absolute_path = Path(path)
else:
absolute_path = self.base_path / path
# Parse frontmatter and content using python-frontmatter
post = frontmatter.load(str(absolute_path))
+31
View File
@@ -217,6 +217,37 @@ def test_parse_empty_content():
assert len(result.relations) == 0
@pytest.mark.asyncio
async def test_parse_file_with_absolute_path(test_config, entity_parser):
"""Test parsing a file with an absolute path."""
content = dedent("""
---
type: component
permalink: absolute_path_test
---
# Absolute Path Test
A file with an absolute path.
""")
# Create a test file in the project directory
test_file = test_config.home / "absolute_path_test.md"
test_file.write_text(content)
# Get the absolute path to the test file
absolute_path = test_file.resolve()
# Parse the file using the absolute path
entity = await entity_parser.parse_file(absolute_path)
# Verify the file was parsed correctly
assert entity.frontmatter.permalink == "absolute_path_test"
assert "Absolute Path Test" in entity.content
assert entity.created is not None
assert entity.modified is not None
# @pytest.mark.asyncio
# async def test_parse_file_invalid_yaml(test_config, entity_parser):
# """Test parsing file with invalid YAML frontmatter."""