memoir-cli 2.5.1 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/adapters/restore.js +18 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memoir-cli",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"description": "Sync AI memory across devices. Back up and restore Claude, Gemini, Codex, Cursor, Copilot, Windsurf configs. Snapshot coding sessions and resume on another machine. Migrate instructions between AI assistants.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
package/src/adapters/restore.js
CHANGED
|
@@ -72,23 +72,29 @@ function remapProjectPaths(backupDir, adapterSource) {
|
|
|
72
72
|
// A "home key" is a dir that: has memory/, OR is a prefix of other dirs, AND is not a sub-project
|
|
73
73
|
// Also detect alternate local encodings (e.g. -C-Users-X and C--Users-X are the same machine)
|
|
74
74
|
const foreignHomeKeys = new Set();
|
|
75
|
-
const localAltKeys = new Set(); // alternate encodings of local home dir
|
|
76
75
|
|
|
77
|
-
//
|
|
76
|
+
// Extract the local username from homedir for matching alternate encodings
|
|
78
77
|
const home = os.homedir();
|
|
79
|
-
const
|
|
78
|
+
const localUsername = path.basename(home).toLowerCase();
|
|
80
79
|
|
|
80
|
+
// All dirs that belong to this machine (primary key + alternate encodings)
|
|
81
|
+
const localDirs = new Set();
|
|
82
|
+
localDirs.add(localHomeKey);
|
|
83
|
+
|
|
84
|
+
// Find alternate local encodings — dirs that contain the same username
|
|
85
|
+
// e.g. on Windows with user "Asian-Beast": both -C-Users-Asian-Beast and C--Users-Asian-Beast
|
|
81
86
|
for (const entry of backupEntries) {
|
|
82
|
-
|
|
83
|
-
if
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const entryNormalized = entry.replace(/^[-]/, '').toLowerCase().replace(/[-]/g, '');
|
|
87
|
-
if (entryNormalized === homeNormalized || homeNormalized.endsWith(entryNormalized) || entryNormalized.endsWith(homeNormalized)) {
|
|
88
|
-
// This is an alternate encoding of the local home — treat as local, not foreign
|
|
89
|
-
localAltKeys.add(entry);
|
|
90
|
-
continue;
|
|
87
|
+
if (entry === localHomeKey) continue;
|
|
88
|
+
// Check if this dir contains the local username (case-insensitive)
|
|
89
|
+
if (entry.toLowerCase().includes(localUsername)) {
|
|
90
|
+
localDirs.add(entry);
|
|
91
91
|
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
for (const entry of backupEntries) {
|
|
95
|
+
// Skip dirs that belong to this machine (primary or alternate)
|
|
96
|
+
const isLocal = [...localDirs].some(ld => entry === ld || entry.startsWith(ld + '-'));
|
|
97
|
+
if (isLocal) continue;
|
|
92
98
|
|
|
93
99
|
// Is this a sub-project of another backup dir? Then skip — its parent handles it
|
|
94
100
|
const isSubProject = backupEntries.some(other =>
|
|
@@ -96,10 +102,6 @@ function remapProjectPaths(backupDir, adapterSource) {
|
|
|
96
102
|
);
|
|
97
103
|
if (isSubProject) continue;
|
|
98
104
|
|
|
99
|
-
// Is this a sub-project of an alternate local key? Skip too
|
|
100
|
-
const isAltSubProject = [...localAltKeys].some(alt => entry.startsWith(alt + '-'));
|
|
101
|
-
if (isAltSubProject) continue;
|
|
102
|
-
|
|
103
105
|
// Has memory/ subfolder = definitely a home key
|
|
104
106
|
const hasMemory = fs.existsSync(path.join(projectsDir, entry, 'memory'));
|
|
105
107
|
// Is a prefix of other dirs = likely a home key
|