chrometools-mcp 1.9.1 → 2.3.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/CHANGELOG.md CHANGED
@@ -2,6 +2,311 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [2.3.2] - 2025-12-25
6
+
7
+ ### Changed
8
+ - **appendScenarioToFile** - Simplified architecture: MCP server no longer reads test files
9
+ - Removed `FileAppender.validateFile()` and `FileAppender.readFile()` calls
10
+ - Removed `generator.appendTest()` call - no longer merges content server-side
11
+ - Returns only test code (without imports) via `testCode` field
12
+ - Changed `action: "write_file"` → `action: "append_test"` (more accurate description)
13
+ - Claude Code now responsible for reading file, appending test, and writing back
14
+ - Clearer separation of concerns: MCP generates code, Claude Code handles file I/O
15
+ - Location: `index.js:2126-2215`
16
+
17
+ ## [2.3.1] - 2024-12-25
18
+
19
+ ### Fixed
20
+ - **executeScenario** - Fixed scenario execution when current page URL doesn't match scenario's entryUrl
21
+ - Added automatic navigation to entryUrl before executing scenario
22
+ - Normalizes URLs for comparison (ignores trailing slashes, query params like `nr`, `redirect_ts`)
23
+ - Prevents timeout errors when scenario expects different page than currently open
24
+ - Example: If scenario recorded on `ya.ru` but current page is `ya.ru/search/`, automatically navigates to `ya.ru`
25
+ - Logs navigation events to console for debugging
26
+ - Location: `index.js:1951-1987`
27
+
28
+ - **appendScenarioToFile** - Unified response format with exportScenarioAsCode for better Claude Code compatibility
29
+ - Changed `action: "append_to_file"` → `action: "write_file"` (clearer action)
30
+ - Changed `updatedContent` → `testCode` (same field name as exportScenarioAsCode)
31
+ - Added `content` field (duplicate of testCode for compatibility)
32
+ - Simplified instruction: single-step "Write the testCode..." instead of two-step "Read... then write..."
33
+ - Improved error message when file not found: now suggests using exportScenarioAsCode instead
34
+ - Location: `index.js:2191-2229`
35
+
36
+ ## [2.3.0] - 2024-12-25
37
+
38
+ ### Breaking Changes
39
+ - **exportScenarioAsCode** - Removed append-to-file functionality to eliminate confusion
40
+ - **REMOVED** parameters: `appendToFile`, `testName`, `insertPosition`, `referenceTestName`
41
+ - Now exclusively creates NEW test files (returns JSON with `action: "create_new_file"`)
42
+ - Returns JSON format with `action`, `suggestedFileName`, `testCode`, `instruction` fields
43
+ - Claude Code writes files based on returned JSON (MCP server no longer writes files directly)
44
+ - Migration: Use new `appendScenarioToFile` tool instead of `appendToFile` parameter
45
+
46
+ ### Added
47
+ - **appendScenarioToFile** - NEW tool for appending tests to existing files
48
+ - Parameters: `scenarioName`, `language`, `targetFile` (required)
49
+ - Optional: `testName`, `insertPosition`, `referenceTestName`, `cleanSelectors`, `includeComments`, `generatePageObject`, `pageObjectClassName`
50
+ - Returns JSON with `action: "append_to_file"`, `targetFile`, `updatedContent`, `instruction`
51
+ - Safely appends tests without overwriting existing tests
52
+ - Claude Code writes updated file content based on returned JSON
53
+ - Location: `index.js:2041-2186`, `server/tool-definitions.js:577-628`
54
+
55
+ ### Changed
56
+ - **exportScenarioAsCode** - Changed return format from plain text to structured JSON
57
+ - Returns: `{action, suggestedFileName, testCode, instruction, pageObject?}`
58
+ - Suggests filename based on scenario name and language
59
+ - Includes clear instructions for Claude Code to create files
60
+ - Location: `index.js:2188-2357`, `server/tool-definitions.js:542-576`
61
+ - **File writing responsibility** - Moved from MCP server to Claude Code
62
+ - MCP tools now return JSON with file content + instructions
63
+ - Claude Code uses Write tool to create/update files
64
+ - Eliminates risk of MCP server directly overwriting files
65
+
66
+ ### Documentation
67
+ - **README.md** - Split exportScenarioAsCode documentation into two sections
68
+ - exportScenarioAsCode: For creating new test files
69
+ - appendScenarioToFile: For appending to existing files
70
+ - Updated tool count: 39+ → 40+ tools
71
+ - Added clear examples for both tools with JSON response formats
72
+ - Location: `README.md:11,17,652-806`
73
+
74
+ ## [2.2.1] - 2024-12-24
75
+
76
+ ### Improved
77
+ - **exportScenarioAsCode** - Clarified tool description to prevent accidental test file overwrites
78
+ - Added explicit warning: default mode (without `appendToFile`) returns code for NEW file
79
+ - Emphasized that `appendToFile` parameter is **REQUIRED** to safely add tests to existing files
80
+ - Updated `appendToFile` parameter description to highlight safety aspect
81
+ - Updated `insertPosition` and `referenceTestName` descriptions to clarify they only work with `appendToFile`
82
+ - Added warning section in README.md documentation
83
+ - Location: `server/tool-definitions.js:544,575-589`, `README.md:667-669`
84
+
85
+ ## [2.2.0] - 2025-12-21
86
+
87
+ ### Added
88
+ - **Page Object Model (POM) Generator** - New `generatePageObject` MCP tool for automated Page Object creation
89
+ - Analyzes current page and extracts interactive elements (inputs, buttons, links, etc.)
90
+ - Smart selector generation: prioritizes id > name > data-testid > unique class > CSS path
91
+ - Auto-generates meaningful element names from labels, placeholders, text content
92
+ - Groups elements by semantic sections (header, nav, form, footer, etc.)
93
+ - Supports 4 frameworks: Playwright TypeScript/Python, Selenium Python/Java
94
+ - Generates helper methods automatically (fill/click methods for common actions)
95
+ - Example: `generatePageObject({ framework: 'playwright-typescript' })`
96
+ - Location: `recorder/page-object-generator.js`, `index.js:46,2098-2136`
97
+
98
+ - **Page Object Integration in exportScenarioAsCode** - Optional Page Object generation when exporting scenarios
99
+ - New parameter `generatePageObject` (default: false) to generate both test code and Page Object class
100
+ - New parameter `pageObjectClassName` for custom Page Object class names
101
+ - Opens scenario's entry URL and analyzes page structure automatically
102
+ - Returns JSON with both `testCode` and `pageObjectCode` when enabled
103
+ - Example: `exportScenarioAsCode({ scenarioName: "login", language: "playwright-typescript", generatePageObject: true })`
104
+ - Location: `index.js:2090-2186`, `server/tool-schemas.js:281-282`, `server/tool-definitions.js:565-572`
105
+
106
+ - **Append Mode for exportScenarioAsCode** - Ability to append generated tests to existing test files
107
+ - New parameter `appendToFile`: Path to existing test file to append to (enables append mode)
108
+ - New parameter `testName`: Override test name (default: from scenario name)
109
+ - New parameter `insertPosition`: Where to insert test - 'end' (default), 'before', or 'after' a reference test
110
+ - New parameter `referenceTestName`: Reference test name for 'before'/'after' insertion
111
+ - Supports all 4 frameworks: Playwright TypeScript/Python, Selenium Python/Java
112
+ - Automatic file validation (extension must match language)
113
+ - Automatic backup before file modification (.backup extension)
114
+ - Smart test name conversion (camelCase for Java, snake_case for Python, kebab-case for TypeScript)
115
+ - Framework-specific parsing: brace counting for TypeScript/Java, indentation-based for Python
116
+ - PEP 8 compliance: 2 blank lines between Python functions
117
+ - Example: `exportScenarioAsCode({ scenarioName: "new_test", language: "playwright-typescript", appendToFile: "./tests/suite.spec.ts" })`
118
+ - Location: `utils/code-generators/file-appender.js` (new 177 lines), `index.js:2044-2116`, `server/tool-schemas.js:283-286`, `utils/code-generators/*.js`
119
+
120
+ ### Fixed
121
+ - **Dependency Resolution with projectId** - Fixed collision errors when executing scenarios with dependencies
122
+ - Dependencies now correctly inherit parent scenario's projectId when not explicitly specified
123
+ - Explicit dependency projectId in metadata takes precedence over inherited value
124
+ - Fixes error: "Dependency 'test': Multiple scenarios named 'test' found"
125
+ - Location: `recorder/scenario-executor.js:63-119`
126
+
127
+ ## [2.1.1] - 2025-12-21
128
+
129
+ ### Fixed
130
+ - **executeScenario Timeout Fix** - Prevents hanging when no browser tab is attached
131
+ - Auto-opens browser at scenario's entryUrl if no page is open
132
+ - Added timeout protection (1s) for page state checks to prevent hanging on `isClosed()`
133
+ - Added 30s timeout for browser opening operation
134
+ - Added 5min timeout for scenario execution with clear error messages
135
+ - Location: `browser/page-manager.js:255-290`, `index.js:1875-1955`
136
+
137
+ - **URL Validation Fix** - Fixed false negative in scenario exit URL validation
138
+ - Added 500ms wait before URL check to allow navigation/redirects to complete
139
+ - Changed from `page.url()` to `page.evaluate(() => window.location.href)` for more reliable current URL
140
+ - Fixes issue where correct URL was reported as wrong due to timing
141
+ - Location: `recorder/scenario-executor.js:186-191`
142
+
143
+ - **Global Timeout Protection** - All MCP tools now protected from hanging
144
+ - Added `executeToolWithTimeout()` wrapper for all tool calls
145
+ - Default timeout: 2 minutes for regular tools, 6 minutes for executeScenario
146
+ - Tools return clear error messages instead of hanging indefinitely
147
+ - Location: `index.js:183-217`
148
+
149
+ ### Changed
150
+ - **Code Refactoring** - Reduced index.js from 3761 to 2093 lines (-44%)
151
+ - Extracted tool schemas to `server/tool-schemas.js` (34 schemas, 282 lines)
152
+ - Extracted tool definitions to `server/tool-definitions.js` (41 tools, 569 lines)
153
+ - Extracted browser management to `browser/browser-manager.js` (207 lines)
154
+ - Extracted page management to `browser/page-manager.js` (268 lines)
155
+ - Extracted image processing to `utils/image-processing.js` (254 lines)
156
+ - Extracted CSS utilities to `utils/css-utils.js` (163 lines)
157
+ - Extracted platform utilities to `utils/platform-utils.js` (63 lines)
158
+ - Better code organization and maintainability
159
+
160
+ ## [2.1.0] - 2025-12-21
161
+
162
+ ### Added
163
+ - **Name Collision Detection** - Smart handling of scenarios with same name across different projects
164
+ - `executeScenario` now detects when multiple scenarios share the same name
165
+ - Returns helpful error with list of available `projectId` values
166
+ - Optional `projectId` parameter to disambiguate: `executeScenario({ name: "login", projectId: "google" })`
167
+ - Location: `recorder/scenario-storage.js:111-163`, `recorder/scenario-executor.js:33,49-61,86-90`, `index.js:1677,3558-3571,3597-3600`
168
+
169
+ ### Changed
170
+ - **URL-Based Scenario Organization** - Scenarios now organized by website domain instead of file system project
171
+ - Project ID automatically extracted from URL where recording starts: `https://google.com` → `google`
172
+ - Main domain only (subdomains stripped): `mail.google.com` → `google`
173
+ - Ports included for ALL domains: `localhost:3000` → `localhost-3000`, `example.com:8080` → `example-8080`
174
+ - Protocol ignored: `http` and `https` both map to same projectId
175
+ - File URLs: `file:///` → `local`
176
+ - Location: `utils/url-to-project.js`, `recorder/recorder-script.js:30-78`
177
+
178
+ - **Global Scenario Access** - All tools now return scenarios from ALL websites
179
+ - `listScenarios()` returns ALL scenarios with `projectId`, `entryUrl`, `exitUrl` metadata
180
+ - `searchScenarios()` searches ALL scenarios across all websites
181
+ - Agent can filter results by `projectId`, `entryUrl`, or `exitUrl` as needed
182
+ - Removed `allProjects` parameter (no longer needed, always returns all)
183
+ - Location: `index.js:3586-3610`
184
+
185
+ - **Simplified API** - Recorder no longer depends on file system project detection
186
+ - `injectRecorder()` signature changed from `(page, projectDir, projectId, projectPath)` to `(page)`
187
+ - Project ID determined automatically from page URL in browser context
188
+ - Removed dependency on `utils/project-detector.js`
189
+ - Location: `recorder/recorder-script.js:1710-1763`, `index.js:3512-3533`
190
+
191
+ ### Added
192
+ - **URL Normalization Utilities** - New module for extracting project ID from URLs
193
+ - `urlToProjectId(url)` - Extract and sanitize domain-based project ID
194
+ - `sanitizeProjectId(id)` - Clean project IDs (lowercase, alphanumeric, hyphens)
195
+ - Browser-compatible version injected into recorder widget
196
+ - Location: `utils/url-to-project.js`
197
+
198
+ ### Migration
199
+ - **Automatic v2.1.0 Migration** - Old project-based scenarios removed on first run
200
+ - Deletes `~/.config/chrometools-mcp/projects/` directory from v2.0
201
+ - Deletes old global index
202
+ - Creates `.migration-v2.1.0-done` flag file
203
+ - One-time migration, starts fresh with URL-based organization
204
+ - Location: `index.js:780-811`
205
+
206
+ ### Removed
207
+ - **Removed `utils/project-detector.js`** - No longer needed for URL-based organization
208
+ - **Removed helper functions** - `getProjectId()`, `getProjectDir()`, `getCurrentProjectDir()`
209
+ - **Removed old scenarios** - All v2.0 scenarios deleted during migration
210
+
211
+ ### Documentation
212
+ - **Updated README.md** - Complete rewrite of Recorder Tools section
213
+ - Explained URL-based storage approach with examples
214
+ - Updated all tool descriptions and examples
215
+ - Documented domain extraction rules
216
+ - Added filtering examples for agents
217
+ - Location: `README.md:507-618`
218
+
219
+ ## [2.0.2] - 2025-12-21
220
+
221
+ ### Fixed
222
+ - **Project Detection for VS Code** - Improved project root detection for IDE environments
223
+ - Added support for `INIT_CWD` and `npm_config_local_prefix` environment variables
224
+ - Added `findProjectRootByMarkers()` to detect project by package.json, pom.xml, etc.
225
+ - Walks up parent directories to find Git root when cwd is IDE installation
226
+ - Now correctly detects `C:\prj\automation` instead of `Microsoft VS Code` when running in VS Code
227
+ - Location: `utils/project-detector.js:38-68`, `utils/project-detector.js:85-140`
228
+
229
+ ### Added
230
+ - **Enhanced Project Detection Strategy** - Multiple fallback mechanisms for project root detection
231
+ - Priority: CLAUDE_PROJECT_DIR → PROJECT_DIR → INIT_CWD → npm prefix → Git root → markers → parent Git → cwd
232
+ - Supports 8+ project markers: package.json, pom.xml, build.gradle, Cargo.toml, go.mod, etc.
233
+ - Better logging with `console.error` for debugging project detection
234
+
235
+ ### Documentation
236
+ - **VS Code Setup Guide** - Add instructions for setting PROJECT_DIR in MCP config for VS Code users
237
+
238
+ ## [2.0.1] - 2025-12-21
239
+
240
+ ### Fixed
241
+ - **Recorder Auto-Reinjection** - Fixed critical bug where recorder widget didn't reinject after page navigation
242
+ - Updated `setupRecorderAutoReinjection()` to use new v2.0 API signature
243
+ - Fixed both navigation (`framenavigated`) and reload (`load`) event handlers
244
+ - Recorder now correctly passes `projectDir`, `projectId`, and `projectPath` instead of deprecated `baseDir`
245
+ - Location: `index.js:483-486`, `index.js:499-502`
246
+
247
+ ## [2.0.0] - 2025-12-21
248
+
249
+ ### Breaking Changes
250
+ - **Project-Based Scenario Storage** - Complete restructuring of scenario storage system
251
+ - Scenarios now stored in `~/.config/chrometools-mcp/projects/{projectName}/scenarios/`
252
+ - Each project has its own isolated scenario storage
253
+ - Automatic project detection via `detectProjectRoot()` (CLAUDE_PROJECT_DIR → PROJECT_DIR → git root → cwd)
254
+ - Global index file at `~/.config/chrometools-mcp/index.json` for fast scenario discovery
255
+ - Scenarios include `projectId` and `projectPath` in metadata
256
+ - Old scenarios in `~/.config/chrometools-mcp/scenarios/` will no longer be accessible
257
+ - Location: `index.js:66-159`, `recorder/scenario-storage.js`
258
+
259
+ - **Removed `directory` parameter** - All scenario tools no longer accept explicit directory parameter
260
+ - Removed from: `enableRecorder`, `executeScenario`, `listScenarios`, `searchScenarios`, `getScenarioInfo`, `deleteScenario`, `exportScenarioAsCode`
261
+ - Project directory is now automatically determined
262
+ - Simplifies API and improves consistency
263
+ - Location: `index.js:1659-1750` (tool definitions)
264
+
265
+ ### Added
266
+ - **Global Scenario Index** - Fast O(1) scenario lookups without filesystem scanning
267
+ - Location: `~/.config/chrometools-mcp/index.json`
268
+ - Contains all projects and their scenarios
269
+ - Enables quick discovery of scenarios across all projects
270
+ - AI-friendly: agents can read global index to understand all available scenarios
271
+ - Location: `index.js:103-159`, `recorder/scenario-storage.js:23-136`
272
+
273
+ - **Multi-Project Filtering** - New `allProjects` parameter for `listScenarios` and `searchScenarios`
274
+ - `allProjects: false` (default) - shows only current project's scenarios
275
+ - `allProjects: true` - shows scenarios from all projects
276
+ - Enables cross-project scenario discovery and reuse
277
+ - Location: `index.js:1685`, `index.js:1697`, `recorder/scenario-storage.js:385-453`
278
+
279
+ - **Cross-Project Dependency Support** - Scenarios can depend on scenarios from other projects
280
+ - Dependencies automatically resolved across projects via global index
281
+ - Enables scenario reuse between projects
282
+ - Location: `recorder/scenario-executor.js:27-121`
283
+
284
+ - **Storage Path in Tool Descriptions** - All scenario tools now document storage location
285
+ - Every tool description includes: "Scenarios are stored in ~/.config/chrometools-mcp/projects/{projectName}/scenarios/"
286
+ - Helps AI agents understand where to find scenarios
287
+ - Includes reference to global index location
288
+ - Location: `index.js:1660`, `index.js:1668`, `index.js:1681`, etc.
289
+
290
+ ### Changed
291
+ - **Scenario Storage Functions** - Updated all storage functions for new architecture
292
+ - `saveScenario(scenario, projectId, projectPath)` - now requires project info instead of baseDir
293
+ - `loadScenario(name, includeSecrets, projectId)` - searches globally, optional project filter
294
+ - `listScenarios(projectId, allProjects)` - reads from global index
295
+ - `searchScenarios(query, projectId, allProjects)` - searches global index
296
+ - `deleteScenario(name, projectId)` - finds and deletes from correct project
297
+ - Location: `recorder/scenario-storage.js:191-500`
298
+
299
+ - **Recorder Injection** - Updated to pass project information
300
+ - `injectRecorder(page, projectDir, projectId, projectPath)` - now accepts project details
301
+ - Scenarios saved with project context automatically
302
+ - Location: `recorder/recorder-script.js:1659`
303
+
304
+ ### Migration Guide
305
+ - **Old scenarios are inaccessible** - Scenarios in `~/.config/chrometools-mcp/scenarios/` will no longer be found
306
+ - To migrate: Manually move scenarios to new structure or re-record them
307
+ - New structure: `~/.config/chrometools-mcp/projects/{projectName}/scenarios/`
308
+ - **No code changes needed** - All changes are internal, MCP tool interface remains compatible (except removed `directory` parameter)
309
+
5
310
  ## [1.9.1] - 2025-12-19
6
311
 
7
312
  ### Fixed