chrome-devtools-mcp-for-extension 0.25.1 → 0.25.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.
@@ -149,14 +149,29 @@ export function resolveUserDataDir(opts) {
149
149
  try {
150
150
  const name = detectProjectName(projectRoot);
151
151
  console.error(`[profiles] MCP_PROJECT_ROOT name="${name}"`);
152
- // v0.25.0: Legacy-first approach - check if legacy profile exists
152
+ // v0.25.0: Check profiles in priority order
153
+ // 1. Legacy profile
153
154
  const realRoot = realpathSafe(projectRoot);
154
155
  const legacyHash = shortHash(realRoot);
155
156
  const legacyKey = `${sanitize(name)}_${legacyHash}`;
156
157
  const legacyPath = projectProfilePath(legacyKey, clientId, channel);
157
- // If legacy profile exists, use it
158
+ // Pre-calculate stable identity
159
+ const identity = resolveStableIdentity(projectRoot, opts.env);
160
+ const stableKey = `${sanitize(name)}_${identity.id}`;
161
+ const stablePath = projectProfilePath(stableKey, clientId, channel);
158
162
  if (fs.existsSync(legacyPath)) {
159
163
  console.error(`[profiles] Legacy profile exists, using it: ${legacyPath}`);
164
+ // Create stable identity symlink for future moves
165
+ if (legacyPath !== stablePath && !fs.existsSync(stablePath)) {
166
+ try {
167
+ fs.mkdirSync(path.dirname(stablePath), { recursive: true });
168
+ fs.symlinkSync(legacyPath, stablePath, 'dir');
169
+ console.error(`[profiles] ✅ Created stable identity link: ${stablePath} -> ${legacyPath}`);
170
+ }
171
+ catch (e) {
172
+ console.error(`[profiles] ⚠️ Failed to create stable identity link: ${e}`);
173
+ }
174
+ }
160
175
  const result = {
161
176
  path: legacyPath,
162
177
  reason: 'MCP_PROJECT_ROOT',
@@ -167,25 +182,35 @@ export function resolveUserDataDir(opts) {
167
182
  channel,
168
183
  identitySource: 'directory-fallback',
169
184
  };
170
- console.error(`[profiles] resolved(MCP_PROJECT_ROOT, legacy): ${result.path} (root=${projectRoot}, name=${name}, hash=${legacyHash}, client=${clientId})`);
171
185
  return result;
172
186
  }
173
- // Legacy profile doesn't exist - use stable identity
174
- const identity = resolveStableIdentity(projectRoot, opts.env);
175
- console.error(`[profiles] No legacy profile, using stable identity: ${identity.source} (${identity.confidence}) raw="${identity.raw}"`);
176
- const key = `${sanitize(name)}_${identity.id}`;
177
- const p = projectProfilePath(key, clientId, channel);
187
+ // 2. Check stable identity profile
188
+ if (fs.existsSync(stablePath)) {
189
+ console.error(`[profiles] Stable identity profile exists: ${stablePath}`);
190
+ const result = {
191
+ path: stablePath,
192
+ reason: 'MCP_PROJECT_ROOT',
193
+ projectKey: stableKey,
194
+ projectName: sanitize(name),
195
+ hash: identity.id,
196
+ clientId,
197
+ channel,
198
+ identitySource: identity.source,
199
+ };
200
+ return result;
201
+ }
202
+ // 3. Create new with stable identity
203
+ console.error(`[profiles] Creating new profile with stable identity: ${identity.source}`);
178
204
  const result = {
179
- path: p,
205
+ path: stablePath,
180
206
  reason: 'MCP_PROJECT_ROOT',
181
- projectKey: key,
207
+ projectKey: stableKey,
182
208
  projectName: sanitize(name),
183
209
  hash: identity.id,
184
210
  clientId,
185
211
  channel,
186
212
  identitySource: identity.source,
187
213
  };
188
- console.error(`[profiles] resolved(MCP_PROJECT_ROOT, stable): ${result.path} (root=${projectRoot}, name=${name}, identity=${identity.source}, client=${clientId})`);
189
214
  return result;
190
215
  }
191
216
  catch (e) {
@@ -200,14 +225,29 @@ export function resolveUserDataDir(opts) {
200
225
  try {
201
226
  const name = detectProjectName(initializedRoot);
202
227
  console.error(`[profiles] Initialized root name="${name}"`);
203
- // v0.25.0: Legacy-first approach - check if legacy profile exists
228
+ // v0.25.0: Check profiles in priority order
229
+ // 1. Legacy profile
204
230
  const realRoot = realpathSafe(initializedRoot);
205
231
  const legacyHash = shortHash(realRoot);
206
232
  const legacyKey = `${sanitize(name)}_${legacyHash}`;
207
233
  const legacyPath = projectProfilePath(legacyKey, clientId, channel);
208
- // If legacy profile exists, use it
234
+ // Pre-calculate stable identity
235
+ const identity = resolveStableIdentity(initializedRoot, opts.env);
236
+ const stableKey = `${sanitize(name)}_${identity.id}`;
237
+ const stablePath = projectProfilePath(stableKey, clientId, channel);
209
238
  if (fs.existsSync(legacyPath)) {
210
239
  console.error(`[profiles] Legacy profile exists, using it: ${legacyPath}`);
240
+ // Create stable identity symlink for future moves
241
+ if (legacyPath !== stablePath && !fs.existsSync(stablePath)) {
242
+ try {
243
+ fs.mkdirSync(path.dirname(stablePath), { recursive: true });
244
+ fs.symlinkSync(legacyPath, stablePath, 'dir');
245
+ console.error(`[profiles] ✅ Created stable identity link: ${stablePath} -> ${legacyPath}`);
246
+ }
247
+ catch (e) {
248
+ console.error(`[profiles] ⚠️ Failed to create stable identity link: ${e}`);
249
+ }
250
+ }
211
251
  const result = {
212
252
  path: legacyPath,
213
253
  reason: 'AUTO',
@@ -218,25 +258,35 @@ export function resolveUserDataDir(opts) {
218
258
  channel,
219
259
  identitySource: 'directory-fallback',
220
260
  };
221
- console.error(`[profiles] resolved(INITIALIZED_ROOT, legacy): ${result.path} (root=${initializedRoot}, name=${name}, hash=${legacyHash}, client=${clientId})`);
222
261
  return result;
223
262
  }
224
- // Legacy profile doesn't exist - use stable identity
225
- const identity = resolveStableIdentity(initializedRoot, opts.env);
226
- console.error(`[profiles] No legacy profile, using stable identity: ${identity.source} (${identity.confidence}) raw="${identity.raw}"`);
227
- const key = `${sanitize(name)}_${identity.id}`;
228
- const p = projectProfilePath(key, clientId, channel);
263
+ // 2. Check stable identity profile
264
+ if (fs.existsSync(stablePath)) {
265
+ console.error(`[profiles] Stable identity profile exists: ${stablePath}`);
266
+ const result = {
267
+ path: stablePath,
268
+ reason: 'AUTO',
269
+ projectKey: stableKey,
270
+ projectName: sanitize(name),
271
+ hash: identity.id,
272
+ clientId,
273
+ channel,
274
+ identitySource: identity.source,
275
+ };
276
+ return result;
277
+ }
278
+ // 3. Create new with stable identity
279
+ console.error(`[profiles] Creating new profile with stable identity: ${identity.source}`);
229
280
  const result = {
230
- path: p,
281
+ path: stablePath,
231
282
  reason: 'AUTO',
232
- projectKey: key,
283
+ projectKey: stableKey,
233
284
  projectName: sanitize(name),
234
285
  hash: identity.id,
235
286
  clientId,
236
287
  channel,
237
288
  identitySource: identity.source,
238
289
  };
239
- console.error(`[profiles] resolved(INITIALIZED_ROOT, stable): ${result.path} (root=${initializedRoot}, name=${name}, identity=${identity.source}, client=${clientId})`);
240
290
  return result;
241
291
  }
242
292
  catch (e) {
@@ -251,14 +301,32 @@ export function resolveUserDataDir(opts) {
251
301
  console.error(`[profiles] AUTO detection: root="${root}"`);
252
302
  const name = detectProjectName(root);
253
303
  console.error(`[profiles] AUTO detection: name="${name}"`);
254
- // v0.25.0: Legacy-first approach - check if legacy profile exists
304
+ // v0.25.0: Check profiles in priority order:
305
+ // 1. Legacy (realpath-based) profile
306
+ // 2. Stable identity profile (for moved projects)
307
+ // 3. Create new with stable identity
308
+ // 1. Check legacy profile
255
309
  const realRoot = realpathSafe(root);
256
310
  const legacyHash = shortHash(realRoot);
257
311
  const legacyKey = `${sanitize(name)}_${legacyHash}`;
258
312
  const legacyPath = projectProfilePath(legacyKey, clientId, channel);
259
- // If legacy profile exists, use it (no migration needed)
313
+ // Pre-calculate stable identity for potential symlink creation
314
+ const identity = resolveStableIdentity(root, opts.env);
315
+ const stableKey = `${sanitize(name)}_${identity.id}`;
316
+ const stablePath = projectProfilePath(stableKey, clientId, channel);
260
317
  if (fs.existsSync(legacyPath)) {
261
318
  console.error(`[profiles] Legacy profile exists, using it: ${legacyPath}`);
319
+ // Also create stable identity symlink for future moves (if different and not exists)
320
+ if (legacyPath !== stablePath && !fs.existsSync(stablePath)) {
321
+ try {
322
+ fs.mkdirSync(path.dirname(stablePath), { recursive: true });
323
+ fs.symlinkSync(legacyPath, stablePath, 'dir');
324
+ console.error(`[profiles] ✅ Created stable identity link for future moves: ${stablePath} -> ${legacyPath}`);
325
+ }
326
+ catch (e) {
327
+ console.error(`[profiles] ⚠️ Failed to create stable identity link: ${e}`);
328
+ }
329
+ }
262
330
  const result = {
263
331
  path: legacyPath,
264
332
  reason: 'AUTO',
@@ -272,22 +340,35 @@ export function resolveUserDataDir(opts) {
272
340
  console.error(`[profiles] resolved(AUTO, legacy): ${result.path} (root=${root}, name=${name}, hash=${legacyHash}, client=${clientId})`);
273
341
  return result;
274
342
  }
275
- // Legacy profile doesn't exist - use stable identity for new profile
276
- const identity = resolveStableIdentity(root, opts.env);
277
- console.error(`[profiles] No legacy profile, using stable identity: ${identity.source} (${identity.confidence}) raw="${identity.raw}"`);
278
- const key = `${sanitize(name)}_${identity.id}`;
279
- const p = projectProfilePath(key, clientId, channel);
343
+ // 2. Check stable identity profile (for moved projects)
344
+ if (fs.existsSync(stablePath)) {
345
+ console.error(`[profiles] Stable identity profile exists (project may have moved): ${stablePath}`);
346
+ const result = {
347
+ path: stablePath,
348
+ reason: 'AUTO',
349
+ projectKey: stableKey,
350
+ projectName: sanitize(name),
351
+ hash: identity.id,
352
+ clientId,
353
+ channel,
354
+ identitySource: identity.source,
355
+ };
356
+ console.error(`[profiles] resolved(AUTO, stable-existing): ${result.path} (root=${root}, name=${name}, identity=${identity.source}, client=${clientId})`);
357
+ return result;
358
+ }
359
+ // 3. Neither exists - create new with stable identity
360
+ console.error(`[profiles] No existing profile, creating with stable identity: ${identity.source} (${identity.confidence}) raw="${identity.raw}"`);
280
361
  const result = {
281
- path: p,
362
+ path: stablePath,
282
363
  reason: 'AUTO',
283
- projectKey: key,
364
+ projectKey: stableKey,
284
365
  projectName: sanitize(name),
285
366
  hash: identity.id,
286
367
  clientId,
287
368
  channel,
288
369
  identitySource: identity.source,
289
370
  };
290
- console.error(`[profiles] resolved(AUTO, stable): ${result.path} (root=${root}, name=${name}, identity=${identity.source}, client=${clientId})`);
371
+ console.error(`[profiles] resolved(AUTO, stable-new): ${result.path} (root=${root}, name=${name}, identity=${identity.source}, client=${clientId})`);
291
372
  return result;
292
373
  }
293
374
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-devtools-mcp-for-extension",
3
- "version": "0.25.1",
3
+ "version": "0.25.3",
4
4
  "description": "MCP server for Chrome extension development with Web Store automation. Fork of chrome-devtools-mcp with extension-specific tools.",
5
5
  "type": "module",
6
6
  "bin": "./scripts/cli.mjs",