Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion mempalace/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ def normalize_wing_name(name: str) -> str:
The same rule is applied by ``init`` when persisting `topics_by_wing`
and when writing `mempalace.yaml`, so the miner's lookup matches at
mine time regardless of the source dirname.

Leading/trailing separators are stripped so a path-encoded dirname like
``-home-user-proj`` yields ``home_user_proj`` rather than a leading-
underscore slug that ``sanitize_name`` (and thus the MCP write tools)
would reject.
"""
return name.lower().replace(" ", "_").replace("-", "_")
return name.lower().replace(" ", "_").replace("-", "_").strip("_")


def sanitize_name(value: str, field_name: str = "name") -> str:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ def test_normalize_wing_name_mixed():
assert normalize_wing_name("My-Cool App") == "my_cool_app"


def test_normalize_wing_name_strips_leading_separator():
# Claude Code path-encoded project dirs begin with a separator; the slug
# must not start with "_" or sanitize_name / MCP writes would reject it.
assert normalize_wing_name("-home-user-linux-book") == "home_user_linux_book"


def test_normalize_wing_name_strips_trailing_separator():
assert normalize_wing_name("project-") == "project"


# --- sanitize_name ---


Expand Down
Loading