chrometools-mcp 1.8.2 → 2.2.0
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/CHANGELOG.md +757 -494
- package/README.md +219 -41
- package/browser/browser-manager.js +206 -0
- package/browser/page-manager.js +298 -0
- package/index.js +525 -1892
- package/package.json +55 -55
- package/recorder/page-object-generator.js +720 -0
- package/recorder/recorder-script.js +118 -12
- package/recorder/scenario-executor.js +970 -946
- package/recorder/scenario-storage.js +253 -29
- package/server/tool-definitions.js +620 -0
- package/server/tool-schemas.js +295 -0
- package/utils/code-generators/code-generator-base.js +61 -0
- package/utils/code-generators/file-appender.js +202 -0
- package/utils/code-generators/playwright-python.js +84 -0
- package/utils/code-generators/playwright-typescript.js +95 -0
- package/utils/code-generators/selenium-java.js +123 -0
- package/utils/code-generators/selenium-python.js +82 -0
- package/utils/css-utils.js +151 -0
- package/utils/image-processing.js +236 -0
- package/utils/platform-utils.js +62 -0
- package/utils/url-to-project.js +141 -0
- package/index.js.backup +0 -3674
- package/utils/project-detector.js +0 -87
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* utils/project-detector.js
|
|
3
|
-
*
|
|
4
|
-
* Utilities for detecting the current project root directory.
|
|
5
|
-
* Uses cascade strategy: env variables → Git root → cwd fallback
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { execSync } from 'child_process';
|
|
9
|
-
import path from 'path';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Find Git repository root from a starting path
|
|
13
|
-
* @param {string} startPath - Path to start searching from
|
|
14
|
-
* @returns {string|null} - Git root path or null if not in a Git repository
|
|
15
|
-
*/
|
|
16
|
-
function findGitRoot(startPath = process.cwd()) {
|
|
17
|
-
try {
|
|
18
|
-
const root = execSync('git rev-parse --show-toplevel', {
|
|
19
|
-
cwd: startPath,
|
|
20
|
-
encoding: 'utf-8',
|
|
21
|
-
stdio: ['pipe', 'pipe', 'ignore'] // Suppress stderr
|
|
22
|
-
}).trim();
|
|
23
|
-
|
|
24
|
-
// Normalize path separators for Windows
|
|
25
|
-
return path.normalize(root);
|
|
26
|
-
} catch {
|
|
27
|
-
// Not in a Git repository or git command not available
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Detect project root directory using cascade strategy
|
|
34
|
-
*
|
|
35
|
-
* Priority:
|
|
36
|
-
* 1. CLAUDE_PROJECT_DIR environment variable
|
|
37
|
-
* 2. PROJECT_DIR environment variable (custom)
|
|
38
|
-
* 3. Git repository root
|
|
39
|
-
* 4. Current working directory (fallback)
|
|
40
|
-
*
|
|
41
|
-
* @returns {string} - Detected project root path
|
|
42
|
-
*/
|
|
43
|
-
export function detectProjectRoot() {
|
|
44
|
-
// 1. Try CLAUDE_PROJECT_DIR (Claude Code specific)
|
|
45
|
-
if (process.env.CLAUDE_PROJECT_DIR) {
|
|
46
|
-
const claudeDir = path.normalize(process.env.CLAUDE_PROJECT_DIR);
|
|
47
|
-
console.log('[chrometools-mcp] Project root from CLAUDE_PROJECT_DIR:', claudeDir);
|
|
48
|
-
return claudeDir;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// 2. Try PROJECT_DIR (custom env variable)
|
|
52
|
-
if (process.env.PROJECT_DIR) {
|
|
53
|
-
const projectDir = path.normalize(process.env.PROJECT_DIR);
|
|
54
|
-
console.log('[chrometools-mcp] Project root from PROJECT_DIR:', projectDir);
|
|
55
|
-
return projectDir;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 3. Try Git root
|
|
59
|
-
const gitRoot = findGitRoot();
|
|
60
|
-
if (gitRoot) {
|
|
61
|
-
console.log('[chrometools-mcp] Project root from Git:', gitRoot);
|
|
62
|
-
return gitRoot;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// 4. Fallback to current working directory
|
|
66
|
-
const cwd = process.cwd();
|
|
67
|
-
console.log('[chrometools-mcp] Project root fallback to cwd:', cwd);
|
|
68
|
-
return cwd;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Get scenarios directory path from base directory
|
|
73
|
-
* @param {string} baseDir - Base directory
|
|
74
|
-
* @returns {string} - Path to scenarios directory
|
|
75
|
-
*/
|
|
76
|
-
export function getScenariosDir(baseDir) {
|
|
77
|
-
return path.join(baseDir, 'scenarios');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Get secrets directory path from base directory
|
|
82
|
-
* @param {string} baseDir - Base directory
|
|
83
|
-
* @returns {string} - Path to secrets directory
|
|
84
|
-
*/
|
|
85
|
-
export function getSecretsDir(baseDir) {
|
|
86
|
-
return path.join(baseDir, 'secrets');
|
|
87
|
-
}
|