memoir-cli 2.5.1 → 2.5.3

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/bin/memoir.js CHANGED
@@ -249,6 +249,7 @@ program
249
249
  chalk.white(`memoir ${VERSION} → ${chalk.green.bold(latest)}`),
250
250
  { padding: 1, borderStyle: 'round', borderColor: 'green', dimBorder: true }
251
251
  ) + '\n');
252
+ process.exit(0); // Exit immediately — old process still has old VERSION
252
253
  } catch (err) {
253
254
  console.error(chalk.red('\n✖ Update failed:'), err.message);
254
255
  console.log(chalk.gray('Try manually: ') + chalk.cyan('npm install -g memoir-cli'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memoir-cli",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
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",
@@ -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
- // Detect alternate local encodings by checking if a dir resolves to the same homedir
76
+ // Extract the local username from homedir for matching alternate encodings
78
77
  const home = os.homedir();
79
- const homeNormalized = home.toLowerCase().replace(/[\\/:]/g, '');
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
- // Skip dirs that already match the primary local key
83
- if (entry === localHomeKey || entry.startsWith(localHomeKey + '-')) continue;
84
-
85
- // Check if this entry is an alternate encoding of the local home dir
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