Skip to content

Commit 0c357ec

Browse files
committed
merge changes from move_note
Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 64a4739 commit 0c357ec

4 files changed

Lines changed: 21 additions & 6 deletions

File tree

src/basic_memory/cli/commands/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414
"import_chatgpt",
1515
"tool",
1616
"project",
17-
"cloud",
1817
]

src/basic_memory/cli/commands/cloud/core_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,4 +395,4 @@ def unmount() -> None:
395395
@cloud_app.command("mount-status")
396396
def mount_status() -> None:
397397
"""Show current mount status."""
398-
show_mount_status()
398+
show_mount_status()

src/basic_memory/mcp/tools/move_note.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from basic_memory.mcp.async_client import client
1010
from basic_memory.mcp.server import mcp
1111
from basic_memory.mcp.tools.utils import call_post, call_get
12-
from basic_memory.mcp.project_session import get_active_project
12+
from basic_memory.mcp.project_context import get_active_project
1313
from basic_memory.schemas import EntityResponse
1414
from basic_memory.schemas.project_info import ProjectList
1515
from basic_memory.utils import validate_project_path
@@ -429,6 +429,19 @@ async def move_note(
429429
logger.info(f"Detected cross-project move attempt: {identifier} -> {destination_path}")
430430
return cross_project_error
431431

432+
# Get the source entity information for extension validation
433+
source_ext = "md" # Default to .md if we can't determine source extension
434+
try:
435+
# Fetch source entity information to get the current file extension
436+
url = f"{project_url}/knowledge/entities/{identifier}"
437+
response = await call_get(client, url)
438+
source_entity = EntityResponse.model_validate(response.json())
439+
if "." in source_entity.file_path:
440+
source_ext = source_entity.file_path.split(".")[-1]
441+
except Exception as e:
442+
# If we can't fetch the source entity, default to .md extension
443+
logger.debug(f"Could not fetch source entity for extension check: {e}")
444+
432445
# Validate that destination path includes a file extension
433446
if "." not in destination_path or not destination_path.split(".")[-1]:
434447
logger.warning(f"Move failed - no file extension provided: {destination_path}")
@@ -444,7 +457,7 @@ async def move_note(
444457
445458
## Try again with extension:
446459
```
447-
move_note("{identifier}", "{destination_path}.EXTENSION")
460+
move_note("{identifier}", "{destination_path}.{source_ext}")
448461
```
449462
450463
All examples in Basic Memory expect file extensions to be explicitly provided.

tests/mcp/test_tool_move_note.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,19 @@ async def test_move_note_invalid_destination_path(client, test_project):
206206

207207

208208
@pytest.mark.asyncio
209-
async def test_move_note_missing_file_extension(client):
209+
async def test_move_note_missing_file_extension(client, test_project):
210210
"""Test moving note without file extension in destination path."""
211211
# Create initial note
212212
await write_note.fn(
213+
project=test_project.name,
213214
title="ExtensionTest",
214215
folder="source",
215216
content="# Extension Test\nTesting extension validation.",
216217
)
217218

218219
# Test path without extension
219220
result = await move_note.fn(
221+
project=test_project.name,
220222
identifier="source/extension-test",
221223
destination_path="target/renamed-note",
222224
)
@@ -230,6 +232,7 @@ async def test_move_note_missing_file_extension(client):
230232

231233
# Test path with empty extension (edge case)
232234
result = await move_note.fn(
235+
project=test_project.name,
233236
identifier="source/extension-test",
234237
destination_path="target/renamed-note.",
235238
)
@@ -239,7 +242,7 @@ async def test_move_note_missing_file_extension(client):
239242
assert "must include a file extension" in result
240243

241244
# Test that note still exists at original location
242-
content = await read_note.fn("source/extension-test")
245+
content = await read_note.fn("source/extension-test", project=test_project.name)
243246
assert "# Extension Test" in content
244247
assert "Testing extension validation" in content
245248

0 commit comments

Comments
 (0)