fix: room detection checks keywords against folder paths
detect_room() now matches folder path parts against room keywords, not just the room name. Fixes docs/ files routing to general instead of documentation room — "docs" wasn't a substring of "documentation" but is now matched via the persisted keywords list. Found during end-to-end testing after merging #108 keyword persistence.
This commit is contained in:
+3
-2
@@ -311,11 +311,12 @@ def detect_room(filepath: Path, content: str, rooms: list, project_path: Path) -
|
|||||||
filename = filepath.stem.lower()
|
filename = filepath.stem.lower()
|
||||||
content_lower = content[:2000].lower()
|
content_lower = content[:2000].lower()
|
||||||
|
|
||||||
# Priority 1: folder path contains room name
|
# Priority 1: folder path matches room name or keywords
|
||||||
path_parts = relative.replace("\\", "/").split("/")
|
path_parts = relative.replace("\\", "/").split("/")
|
||||||
for part in path_parts[:-1]: # skip filename itself
|
for part in path_parts[:-1]: # skip filename itself
|
||||||
for room in rooms:
|
for room in rooms:
|
||||||
if room["name"].lower() in part or part in room["name"].lower():
|
candidates = [room["name"].lower()] + [k.lower() for k in room.get("keywords", [])]
|
||||||
|
if any(part == c or c in part or part in c for c in candidates):
|
||||||
return room["name"]
|
return room["name"]
|
||||||
|
|
||||||
# Priority 2: filename matches room name
|
# Priority 2: filename matches room name
|
||||||
|
|||||||
Reference in New Issue
Block a user