chrome-devtools-mcp-for-extension 0.25.7 → 0.25.8
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/build/src/profile-resolver.js +64 -28
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ import crypto from 'node:crypto';
|
|
|
18
18
|
import fs from 'node:fs';
|
|
19
19
|
import os from 'node:os';
|
|
20
20
|
import path from 'node:path';
|
|
21
|
+
import { fileURLToPath } from 'node:url';
|
|
21
22
|
import { detectClientType } from './client-detector.js';
|
|
22
23
|
import { detectProjectName, detectProjectRoot } from './project-detector.js';
|
|
23
24
|
import { getProjectRoot } from './project-root-state.js';
|
|
@@ -30,49 +31,84 @@ export function resolveUserDataDir(opts) {
|
|
|
30
31
|
if (opts.rootsInfo) {
|
|
31
32
|
const stableProfilePath = path.join(CACHE_ROOT, 'profiles', opts.rootsInfo.profileKey, opts.rootsInfo.clientName, channel);
|
|
32
33
|
const normalized = pathNormalize(stableProfilePath);
|
|
33
|
-
// v0.25.
|
|
34
|
-
//
|
|
34
|
+
// v0.25.8: Comprehensive migration from legacy profile formats to stable identity profile
|
|
35
|
+
// Handles:
|
|
36
|
+
// - v0.18.x: URI+client+version hash, directory name as project name
|
|
37
|
+
// - v0.19.0-v0.25.4: URI+client hash (no version), directory name as project name
|
|
38
|
+
// - v0.25.5+: stable identity hash, package.json name as project name
|
|
35
39
|
if (!fs.existsSync(stableProfilePath) && opts.rootsInfo.rootsUris.length > 0) {
|
|
36
40
|
try {
|
|
37
41
|
const firstUri = opts.rootsInfo.rootsUris[0];
|
|
38
42
|
const url = new URL(firstUri);
|
|
39
43
|
if (url.protocol === 'file:') {
|
|
40
|
-
|
|
44
|
+
// Extract directory name for OLD project name (v0.25.4以前)
|
|
45
|
+
const rootPath = fileURLToPath(url);
|
|
41
46
|
const realRoot = realpathSafe(rootPath);
|
|
42
|
-
|
|
47
|
+
const dirName = path.basename(realRoot);
|
|
48
|
+
const oldProjectName = sanitize(dirName); // e.g., "adlogger" from "adLogger"
|
|
49
|
+
const newProjectName = opts.rootsInfo.projectName; // e.g., "adblocker" from package.json
|
|
50
|
+
// Try both old and new project names
|
|
51
|
+
const projectNamesToTry = [oldProjectName];
|
|
52
|
+
if (newProjectName !== oldProjectName) {
|
|
53
|
+
projectNamesToTry.push(newProjectName);
|
|
54
|
+
}
|
|
55
|
+
// Legacy hash formats to try
|
|
56
|
+
const sortedUris = [...opts.rootsInfo.rootsUris].sort();
|
|
57
|
+
const clientName = opts.rootsInfo.clientName;
|
|
58
|
+
const clientVersion = opts.rootsInfo.clientVersion;
|
|
43
59
|
const legacyHashFormats = [
|
|
44
|
-
// Format 1: v0.25.4
|
|
60
|
+
// Format 1: v0.19.0-v0.25.4 (URI+client, no version)
|
|
45
61
|
{
|
|
46
62
|
name: 'uri+client',
|
|
47
|
-
hash:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
hash: crypto
|
|
64
|
+
.createHash('sha256')
|
|
65
|
+
.update(JSON.stringify({
|
|
66
|
+
roots: sortedUris,
|
|
67
|
+
client: clientName,
|
|
68
|
+
}))
|
|
69
|
+
.digest('hex')
|
|
70
|
+
.slice(0, 8),
|
|
55
71
|
},
|
|
56
|
-
// Format 2:
|
|
72
|
+
// Format 2: v0.18.x (URI+client+version) - try common version strings
|
|
73
|
+
...['1.0.0', '0.1.0', clientVersion].map((version) => ({
|
|
74
|
+
name: `uri+client+version(${version})`,
|
|
75
|
+
hash: crypto
|
|
76
|
+
.createHash('sha256')
|
|
77
|
+
.update(JSON.stringify({
|
|
78
|
+
roots: sortedUris,
|
|
79
|
+
client: clientName,
|
|
80
|
+
version,
|
|
81
|
+
}))
|
|
82
|
+
.digest('hex')
|
|
83
|
+
.slice(0, 8),
|
|
84
|
+
})),
|
|
85
|
+
// Format 3: Directory path hash
|
|
57
86
|
{
|
|
58
87
|
name: 'directory-path',
|
|
59
88
|
hash: shortHash(realRoot),
|
|
60
89
|
},
|
|
61
90
|
];
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
console.error(`[profiles] Migration:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
91
|
+
// Try all combinations of project name × hash format
|
|
92
|
+
let migrated = false;
|
|
93
|
+
for (const projName of projectNamesToTry) {
|
|
94
|
+
if (migrated)
|
|
95
|
+
break;
|
|
96
|
+
for (const format of legacyHashFormats) {
|
|
97
|
+
const legacyKey = `${projName}_${format.hash}`;
|
|
98
|
+
const legacyPath = path.join(CACHE_ROOT, 'profiles', legacyKey, opts.rootsInfo.clientName, channel);
|
|
99
|
+
if (fs.existsSync(legacyPath)) {
|
|
100
|
+
console.error(`[profiles] Migration: Found legacy profile (${format.name}, project=${projName}): ${legacyPath}`);
|
|
101
|
+
console.error(`[profiles] Migration: Creating symlink to stable profile: ${stableProfilePath}`);
|
|
102
|
+
try {
|
|
103
|
+
fs.mkdirSync(path.dirname(stableProfilePath), { recursive: true });
|
|
104
|
+
fs.symlinkSync(legacyPath, stableProfilePath, 'dir');
|
|
105
|
+
console.error(`[profiles] Migration: ✅ Symlink created successfully`);
|
|
106
|
+
migrated = true;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
console.error(`[profiles] Migration: ⚠️ Failed to create symlink: ${e}`);
|
|
111
|
+
}
|
|
76
112
|
}
|
|
77
113
|
}
|
|
78
114
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome-devtools-mcp-for-extension",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.8",
|
|
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",
|