Skip to content

Commit 422c80a

Browse files
committed
fix(mcp): include project fallback for workspace short links
Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 0b2e5c9 commit 422c80a

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/basic_memory/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,18 @@ def add_candidate(value: str | None) -> None:
372372
add_candidate(f"{normalized_project}/{remainder}")
373373
add_candidate(remainder)
374374

375+
if workspace_project_prefix and not include_project and not workspace_qualified:
376+
# Trigger: short lookup in a workspace where new canonical links omit project prefixes.
377+
# Why: older rows in that same workspace may still be stored as `project/path`.
378+
# Outcome: try the project-prefixed legacy form after the workspace-qualified form.
379+
add_candidate(
380+
build_canonical_permalink(
381+
normalized_project,
382+
normalized_path,
383+
include_project=True,
384+
)
385+
)
386+
375387
if include_project and not workspace_qualified:
376388
add_candidate(
377389
build_canonical_permalink(

tests/test_permalink_utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ def test_short_permalink_candidates_include_workspace_and_project_forms():
4747
]
4848

4949

50+
def test_short_workspace_candidate_keeps_project_legacy_when_project_prefix_disabled():
51+
candidates = build_permalink_resolution_candidates(
52+
"notes/example",
53+
"main",
54+
include_project=False,
55+
workspace_permalink="personal",
56+
)
57+
58+
assert candidates == [
59+
"notes/example",
60+
"personal/main/notes/example",
61+
"main/notes/example",
62+
]
63+
64+
5065
def test_qualified_permalink_reference_preserves_lookup_syntax():
5166
assert (
5267
build_qualified_permalink_reference(

0 commit comments

Comments
 (0)