@@ -2092,6 +2092,32 @@ def _get_example_paths(self, project: str, limit: int = 5) -> list[str]:
20922092 except BaseException :
20932093 return []
20942094
2095+ def _resolve_path_by_suffix (self , path : str , project : str ) -> str | None :
2096+ """Find a stored source_path ending with *path* when the exact lookup misses.
2097+
2098+ Returns the full path only when exactly one candidate matches; None otherwise.
2099+ """
2100+ try :
2101+ results = self .collection .get (
2102+ where = {"project" : project },
2103+ include = ["metadatas" ],
2104+ )
2105+ if not results ["metadatas" ]:
2106+ return None
2107+
2108+ all_paths = {_normalize_source_path (str (m .get ("source_path" , "" ))) for m in results ["metadatas" ] if m .get ("source_path" )}
2109+
2110+ suffix = "/" + path .lstrip ("/" )
2111+ matches = [p for p in all_paths if p .endswith (suffix ) or p == path ]
2112+
2113+ if len (matches ) == 1 :
2114+ return matches [0 ]
2115+ return None
2116+ except (KeyboardInterrupt , SystemExit ):
2117+ raise
2118+ except BaseException :
2119+ return None
2120+
20952121 def _reconstruct_document_content (self , source_path : str , project : str ) -> str :
20962122 """Reconstruct full document content from its chunks in ChromaDB.
20972123
@@ -2418,6 +2444,13 @@ async def get_document(self, path: str, project: str, ctx: Context | None = None
24182444
24192445 # Reconstruct full content from chunks
24202446 merged_content = self ._reconstruct_document_content (normalized_path , project )
2447+
2448+ if not merged_content :
2449+ resolved_path = self ._resolve_path_by_suffix (normalized_path , project )
2450+ if resolved_path :
2451+ normalized_path = resolved_path
2452+ merged_content = self ._reconstruct_document_content (normalized_path , project )
2453+
24212454 if not merged_content :
24222455 # Provide example paths from this project to help discoverability
24232456 example_paths = self ._get_example_paths (project , limit = 5 )
0 commit comments