mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
fix formatting on files
Signed-off-by: phernandez <paul@basicmachines.co>
This commit is contained in:
@@ -94,7 +94,9 @@ class BasicMemoryConfig(BaseSettings):
|
||||
"""Ensure configuration is valid after initialization."""
|
||||
# Ensure main project exists
|
||||
if "main" not in self.projects: # pragma: no cover
|
||||
self.projects["main"] = str(Path(os.getenv("BASIC_MEMORY_HOME", Path.home() / "basic-memory")))
|
||||
self.projects["main"] = str(
|
||||
Path(os.getenv("BASIC_MEMORY_HOME", Path.home() / "basic-memory"))
|
||||
)
|
||||
|
||||
# Ensure default project is valid
|
||||
if self.default_project not in self.projects: # pragma: no cover
|
||||
|
||||
@@ -17,12 +17,12 @@ async def _detect_cross_project_move_attempt(
|
||||
identifier: str, destination_path: str, current_project: str
|
||||
) -> Optional[str]:
|
||||
"""Detect potential cross-project move attempts and return guidance.
|
||||
|
||||
|
||||
Args:
|
||||
identifier: The note identifier being moved
|
||||
destination_path: The destination path
|
||||
current_project: The current active project
|
||||
|
||||
|
||||
Returns:
|
||||
Error message with guidance if cross-project move is detected, None otherwise
|
||||
"""
|
||||
@@ -31,36 +31,40 @@ async def _detect_cross_project_move_attempt(
|
||||
response = await call_get(client, "/projects/projects")
|
||||
project_list = ProjectList.model_validate(response.json())
|
||||
project_names = [p.name.lower() for p in project_list.projects]
|
||||
|
||||
|
||||
# Check if destination path contains any project names
|
||||
dest_lower = destination_path.lower()
|
||||
path_parts = dest_lower.split("/")
|
||||
|
||||
|
||||
# Look for project names in the destination path
|
||||
for part in path_parts:
|
||||
if part in project_names and part != current_project.lower():
|
||||
# Found a different project name in the path
|
||||
matching_project = next(p.name for p in project_list.projects if p.name.lower() == part)
|
||||
matching_project = next(
|
||||
p.name for p in project_list.projects if p.name.lower() == part
|
||||
)
|
||||
return _format_cross_project_error_response(
|
||||
identifier, destination_path, current_project, matching_project
|
||||
)
|
||||
|
||||
|
||||
# Check if the destination path looks like it might be trying to reference another project
|
||||
# (e.g., contains common project-like patterns)
|
||||
if any(keyword in dest_lower for keyword in ["project", "workspace", "repo"]):
|
||||
# This might be a cross-project attempt, but we can't be sure
|
||||
# Return a general guidance message
|
||||
available_projects = [p.name for p in project_list.projects if p.name != current_project]
|
||||
available_projects = [
|
||||
p.name for p in project_list.projects if p.name != current_project
|
||||
]
|
||||
if available_projects:
|
||||
return _format_potential_cross_project_guidance(
|
||||
identifier, destination_path, current_project, available_projects
|
||||
)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
# If we can't detect, don't interfere with normal error handling
|
||||
logger.debug(f"Could not check for cross-project move: {e}")
|
||||
return None
|
||||
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@@ -116,7 +120,7 @@ def _format_potential_cross_project_guidance(
|
||||
other_projects = ", ".join(available_projects[:3]) # Show first 3 projects
|
||||
if len(available_projects) > 3:
|
||||
other_projects += f" (and {len(available_projects) - 3} others)"
|
||||
|
||||
|
||||
return dedent(f"""
|
||||
# Move Failed - Check Project Context
|
||||
|
||||
|
||||
@@ -694,7 +694,9 @@ class EntityService(BaseService[EntityModel]):
|
||||
|
||||
updates["permalink"] = new_permalink
|
||||
if old_permalink is None:
|
||||
logger.info(f"Generated permalink for entity with null permalink: {new_permalink}")
|
||||
logger.info(
|
||||
f"Generated permalink for entity with null permalink: {new_permalink}"
|
||||
)
|
||||
else:
|
||||
logger.info(f"Updated permalink: {old_permalink} -> {new_permalink}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user