fix: expand ~ in split command directory argument#361
fix: expand ~ in split command directory argument#361bensig merged 1 commit intoMemPalace:developfrom
Conversation
Path("~/foo") does not expand tilde on its own, causing
`mempalace split ~/some/dir` to silently find no files.
Fix by calling .expanduser().resolve() in both places the
path is constructed: cmd_split in cli.py (defensive, at the
CLI boundary) and main() in split_mega_files.py (the root cause).
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
PR Review: fix: expand ~ in split command directory argumentExecutive Summary
Affected Areas: Business Impact: Users passing Flow Changes: Ratings
PR Health
Guidelines Compliance
High Priority Issues(Must fix before merge) [Bug] #1: Incomplete fix —
|
web3guru888
left a comment
There was a problem hiding this comment.
Clean fix — tilde expansion is one of those silent failures that's really hard to debug when it bites you. Good call resolving in both the CLI entry point and the underlying split_mega_files.py.
One thought: you might want to add a quick test case (test_split_tilde_expansion or similar) to prevent regression, since the Path("~/foo") behavior varies subtly across platforms.
🔭 Reviewed as part of the MemPalace-AGI integration project — autonomous research with perfect memory. Community interaction updates are posted regularly on the dashboard.
bensig
left a comment
There was a problem hiding this comment.
Code review + security audit clean.
…n conflicts Merge upstream/develop: MemPalace#177, MemPalace#361, MemPalace#449, MemPalace#450 (benchmarks, tilde expand, duplicate cache vars, test fixture cleanup). Merge upstream/main: MemPalace#666 (z3tz3r0's block reason disambiguation). Conflict resolution: keep our scoped "For THIS save" phrasing instead of MemPalace#666's absolute "Do NOT write to auto-memory" — both memory systems are used in tandem. Also drop "AAAK-compressed" from diary instructions since diary_write is plain text, not AAAK dialect. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…iterdir OSError) - Expand ~ in split command dir/output-dir args (upstream MemPalace#361) - Use yield+close in KG test fixture to prevent SQLite leaks (MemPalace#450) - Use char/3.8 token estimate for consistency (MemPalace#609) - Handle OSError from iterdir on broken symlinks/reparse points (MemPalace#558) Closes DOT-488.
…iterdir OSError) - Expand ~ in split command dir/output-dir args (upstream MemPalace#361) - Use yield+close in KG test fixture to prevent SQLite leaks (MemPalace#450) - Use char/3.8 token estimate for consistency (MemPalace#609) - Handle OSError from iterdir on broken symlinks/reparse points (MemPalace#558) Closes DOT-488.
…iterdir OSError) - Expand ~ in split command dir/output-dir args (upstream MemPalace#361) - Use yield+close in KG test fixture to prevent SQLite leaks (MemPalace#450) - Use char/3.8 token estimate for consistency (MemPalace#609) - Handle OSError from iterdir on broken symlinks/reparse points (MemPalace#558) Closes DOT-488.
Port of upstream dc14347 (PR MemPalace#361) — Path("~/foo") does not expand the tilde on its own, causing `mempalace split ~/some/dir` to silently find no files because src_dir.glob("*.txt") never resolves into the user's home. Fix in both places the path is constructed: cmd_split in cli.py (defensive, at the CLI boundary, before handing argv to the inner parser) and main() in split_mega_files.py (the root cause when invoked directly). Upstream: MemPalace@dc14347 Co-authored-by: Brooke Whatnall <[email protected]> Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Problem
mempalace split ~/some/dirsilently finds no files becausePath("~/foo")does not expand the tilde — it treats~as a literal directory name.Root cause
In
split_mega_files.py:Pathdoes not callos.path.expanduserautomatically, so any~-prefixed path is never resolved to the real home directory.Fix
Two one-line changes:
mempalace/split_mega_files.py(root cause):mempalace/cli.py(defensive fix at the CLI boundary):.resolve()is added alongside.expanduser()so relative paths (e.g.mempalace split .) also work correctly.Reproduction