feat: normalize project paths for cross-device sync#30
Open
merv-nexura wants to merge 3 commits into
Open
Conversation
Different home directories across machines (e.g., /Users/merv vs
/Users/mervynlally) caused project data to be siloed — each device
created separate project directories under ~/.claude/projects/ and
neither could see the other's sessions or memories.
Introduces PathMapper which normalizes home directory slugs in remote
keys to ${HOME} on push and resolves them back to the local home
directory on pull. File content (session .jsonl, memory .md) also gets
the same treatment, following the existing MCP normalization pattern.
Backward compatible: legacy remote keys without ${HOME} pass through
unchanged. A boundary-aware prefix check prevents -Users-merv from
falsely matching -Users-mervynlally.
Adds `claude-sync migrate` which finds remote project keys using literal
home directory paths and replaces them with normalized ${HOME} keys. If
a normalized version already exists, the legacy key is simply deleted.
Includes --dry-run flag to preview changes without modifying storage.
Safe to run multiple times — already-normalized keys are skipped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PathMapperthat normalizes home directory slugs in remote storage keys to${HOME}on push and resolves them back to the local home directory on pull.jsonl, memory.md) also gets home dir normalization, following the existing MCP normalization pattern frommcp.go/Users/mervvs/Users/mervynlally) create separate project directories under~/.claude/projects/and can't see each other's sessions or memoriesHow it works
projects/-Users-merv-nexura/memory/MEMORY.md→ remote keyprojects/${HOME}-nexura/memory/MEMORY.md.ageprojects/-Users-mervynlally-nexura/memory/MEMORY.md${HOME}passes through unchanged (backward compatible)-Users-mervwon't falsely match-Users-mervynlallythanks to boundary-aware prefix checkingFiles changed
internal/sync/pathmap.goPathMapperstruct with normalize/resolve for both keys and contentinternal/sync/pathmap_test.gointernal/sync/sync.goPathMapperintoSyncer,remoteKey(),localPath(),uploadFile(),downloadFile()internal/sync/sync_push_pull_test.goTest plan
make checkpasses (fmt, vet, tests)TestCrossDeviceProjectSync— push from/Users/merv, pull on/Users/mervynlally, files land under correct project dir with resolved pathsTestCrossDeviceProjectSync_BothDirections— bidirectional: A→B→B→A with correct path resolution each wayTestCrossDeviceProjectSync_LegacyKeyPassthrough— old remote keys without${HOME}still workTestNormalizeRemoteKey_PrefixCollision—/Users/mervdoes NOT match/Users/mervynlally