Skip to content

Commit 1646572

Browse files
phernandezgithub-actions[bot]claude
authored
fix: Rename write_note entity_type to note_type for clarity (#419)
Signed-off-by: phernandez <paul@basicmachines.co> Signed-off-by: Paul Hernandez <60959+phernandez@users.noreply.github.com> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
1 parent f0d7398 commit 1646572

8 files changed

Lines changed: 33 additions & 33 deletions

File tree

docs/ai-assistant-guide-extended.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ Adopt GraphQL instead of REST for our API layer.
557557
""",
558558
folder="decisions",
559559
tags=["decision", "api", "graphql"],
560-
entity_type="decision",
560+
note_type="decision",
561561
project="main"
562562
)
563563
```
@@ -594,7 +594,7 @@ await write_note(
594594
""",
595595
folder="meetings",
596596
tags=["meeting", "api", "team"],
597-
entity_type="meeting",
597+
note_type="meeting",
598598
project="main"
599599
)
600600
```
@@ -646,7 +646,7 @@ Specification for user authentication system using JWT tokens.
646646
""",
647647
folder="specs",
648648
tags=["spec", "auth", "security"],
649-
entity_type="spec",
649+
note_type="spec",
650650
project="main"
651651
)
652652
```
@@ -1612,7 +1612,7 @@ await write_note(
16121612
{related_entities}
16131613
""",
16141614
folder="decisions",
1615-
entity_type="decision",
1615+
note_type="decision",
16161616
project="main"
16171617
)
16181618
```
@@ -2687,14 +2687,14 @@ await write_note(
26872687

26882688
### Content Management
26892689

2690-
**write_note(title, content, folder, tags, entity_type, project)**
2690+
**write_note(title, content, folder, tags, note_type, project)**
26912691
- Create or update markdown notes
26922692
- Parameters:
26932693
- `title` (required): Note title
26942694
- `content` (required): Markdown content
26952695
- `folder` (required): Destination folder
26962696
- `tags` (optional): List of tags
2697-
- `entity_type` (optional): Entity type (note, person, meeting, etc.)
2697+
- `note_type` (optional): Type of note (stored in frontmatter). Can be "note", "person", "meeting", "guide", etc.
26982698
- `project` (required unless default_project_mode): Target project
26992699
- Returns: Created/updated entity with permalink
27002700
- Example:
@@ -2704,7 +2704,7 @@ await write_note(
27042704
content="# API Design\n...",
27052705
folder="specs",
27062706
tags=["api", "design"],
2707-
entity_type="spec",
2707+
note_type="spec",
27082708
project="main"
27092709
)
27102710
```

src/basic_memory/api/routers/project_router.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ async def sync_project(
113113
force_full: bool = Query(
114114
False, description="Force full scan, bypassing watermark optimization"
115115
),
116-
run_in_background: bool = Query(True, description="Run in background")
116+
run_in_background: bool = Query(True, description="Run in background"),
117117
):
118118
"""Force project filesystem sync to database.
119119
@@ -142,7 +142,9 @@ async def sync_project(
142142
"message": f"Filesystem sync initiated for project '{project_config.name}'",
143143
}
144144
else:
145-
report = await sync_service.sync(project_config.home, project_config.name, force_full=force_full)
145+
report = await sync_service.sync(
146+
project_config.home, project_config.name, force_full=force_full
147+
)
146148
logger.info(
147149
f"Filesystem sync completed for project: {project_config.name} (force_full={force_full})"
148150
)

src/basic_memory/file_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def dump_frontmatter(post: frontmatter.Post) -> str:
213213
sort_keys=False,
214214
allow_unicode=True,
215215
default_flow_style=False,
216-
Dumper=yaml.SafeDumper
216+
Dumper=yaml.SafeDumper,
217217
)
218218

219219
# Construct the final markdown with frontmatter

src/basic_memory/mcp/tools/write_note.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
# Define TagType as a Union that can accept either a string or a list of strings or None
1717
TagType = Union[List[str], str, None]
1818

19-
# Define TagType as a Union that can accept either a string or a list of strings or None
20-
TagType = Union[List[str], str, None]
21-
2219

2320
@mcp.tool(
2421
description="Create or update a markdown note. Returns a markdown formatted summary of the semantic content.",
@@ -29,7 +26,7 @@ async def write_note(
2926
folder: str,
3027
project: Optional[str] = None,
3128
tags: list[str] | str | None = None,
32-
entity_type: str = "note",
29+
note_type: str = "note",
3330
context: Context | None = None,
3431
) -> str:
3532
"""Write a markdown note to the knowledge base.
@@ -70,7 +67,8 @@ async def write_note(
7067
available projects.
7168
tags: Tags to categorize the note. Can be a list of strings, a comma-separated string, or None.
7269
Note: If passing from external MCP clients, use a string format (e.g. "tag1,tag2,tag3")
73-
entity_type: Type of entity to create. Defaults to "note". Can be "guide", "report", "config", etc.
70+
note_type: Type of note to create (stored in frontmatter). Defaults to "note".
71+
Can be "guide", "report", "config", "person", etc.
7472
context: Optional FastMCP context for performance caching.
7573
7674
Returns:
@@ -96,14 +94,14 @@ async def write_note(
9694
content="# Weekly Standup\\n\\n- [decision] Use SQLite for storage #tech"
9795
)
9896
99-
# Create a note with tags and entity type
97+
# Create a note with tags and note type
10098
write_note(
10199
project="work-project",
102100
title="API Design",
103101
folder="specs",
104102
content="# REST API Specification\\n\\n- implements [[Authentication]]",
105103
tags=["api", "design"],
106-
entity_type="guide"
104+
note_type="guide"
107105
)
108106
109107
# Update existing note (same title/folder)
@@ -147,7 +145,7 @@ async def write_note(
147145
entity = Entity(
148146
title=title,
149147
folder=folder,
150-
entity_type=entity_type,
148+
entity_type=note_type,
151149
content_type="text/markdown",
152150
content=content,
153151
entity_metadata=metadata,

tests/api/test_project_router.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,7 @@ async def test_sync_project_endpoint_foreground_with_changes(
588588
assert "deleted" in data
589589

590590
# At least one of these should have changes
591-
has_changes = (
592-
len(data["new"]) > 0 or len(data["modified"]) > 0 or len(data["deleted"]) > 0
593-
)
591+
has_changes = len(data["new"]) > 0 or len(data["modified"]) > 0 or len(data["deleted"]) > 0
594592
assert has_changes or data["total"] >= 0 # Either changes detected or empty sync is valid
595593

596594
finally:

tests/mcp/test_tool_read_note.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ async def test_read_note_preserves_functionality_with_security(self, app, test_p
402402
Additional content with various formatting.
403403
""").strip(),
404404
tags=["security", "test", "full-feature"],
405-
entity_type="guide",
405+
note_type="guide",
406406
)
407407

408408
# Test reading by permalink

tests/mcp/test_tool_write_note.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ async def test_write_note_with_custom_entity_type(app, test_project):
538538
folder="guides",
539539
content="# Guide Content\nThis is a guide",
540540
tags=["guide", "documentation"],
541-
entity_type="guide",
541+
note_type="guide",
542542
)
543543

544544
assert result
@@ -574,14 +574,14 @@ async def test_write_note_with_custom_entity_type(app, test_project):
574574

575575
@pytest.mark.asyncio
576576
async def test_write_note_with_report_entity_type(app, test_project):
577-
"""Test creating a note with entity_type="report"."""
577+
"""Test creating a note with note_type="report"."""
578578
result = await write_note.fn(
579579
project=test_project.name,
580580
title="Monthly Report",
581581
folder="reports",
582582
content="# Monthly Report\nThis is a monthly report",
583583
tags=["report", "monthly"],
584-
entity_type="report",
584+
note_type="report",
585585
)
586586

587587
assert result
@@ -599,13 +599,13 @@ async def test_write_note_with_report_entity_type(app, test_project):
599599

600600
@pytest.mark.asyncio
601601
async def test_write_note_with_config_entity_type(app, test_project):
602-
"""Test creating a note with entity_type="config"."""
602+
"""Test creating a note with note_type="config"."""
603603
result = await write_note.fn(
604604
project=test_project.name,
605605
title="System Config",
606606
folder="config",
607607
content="# System Configuration\nThis is a config file",
608-
entity_type="config",
608+
note_type="config",
609609
)
610610

611611
assert result
@@ -659,21 +659,21 @@ async def test_write_note_update_existing_with_different_entity_type(app, test_p
659659
folder="test",
660660
content="# Initial Content\nThis starts as a note",
661661
tags=["test"],
662-
entity_type="note",
662+
note_type="note",
663663
)
664664

665665
assert result1
666666
assert "# Created note" in result1
667667
assert f"project: {test_project.name}" in result1
668668

669-
# Update the same note with a different entity_type
669+
# Update the same note with a different note_type
670670
result2 = await write_note.fn(
671671
project=test_project.name,
672672
title="Changeable Type",
673673
folder="test",
674674
content="# Updated Content\nThis is now a guide",
675675
tags=["guide"],
676-
entity_type="guide",
676+
note_type="guide",
677677
)
678678

679679
assert result2
@@ -976,7 +976,7 @@ async def test_write_note_security_with_all_parameters(self, app, test_project):
976976
folder="../../../etc/malicious",
977977
content="# Malicious Content\nThis should be blocked by security validation.",
978978
tags=["malicious", "test"],
979-
entity_type="guide",
979+
note_type="guide",
980980
)
981981

982982
assert isinstance(result, str)
@@ -1026,7 +1026,7 @@ async def test_write_note_preserves_functionality_with_security(self, app, test_
10261026
Additional content with various formatting.
10271027
""").strip(),
10281028
tags=["security", "test", "full-feature"],
1029-
entity_type="guide",
1029+
note_type="guide",
10301030
)
10311031

10321032
# Should succeed normally

tests/services/test_entity_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,9 @@ async def test_edit_entity_replace_section_strips_duplicate_header(
13151315

13161316
# Count occurrences of "## Testing" - should only be 1
13171317
testing_header_count = file_content.count("## Testing")
1318-
assert testing_header_count == 1, f"Expected 1 '## Testing' header, found {testing_header_count}"
1318+
assert testing_header_count == 1, (
1319+
f"Expected 1 '## Testing' header, found {testing_header_count}"
1320+
)
13191321

13201322
assert "New content for testing section" in file_content
13211323
assert "Original content" not in file_content

0 commit comments

Comments
 (0)