@guanzhu.me/pw-cli 0.0.21 → 0.0.22

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/pw-cli.js CHANGED
@@ -718,9 +718,17 @@ async function handleRunScript(rawArgv) {
718
718
  break;
719
719
  }
720
720
  }
721
- // Merge any flags after run-script into options
722
- const afterOptions = parsePwCliGlobalOptions(flags);
723
- Object.assign(options, afterOptions);
721
+ // Merge only explicitly specified flags after run-script into options
722
+ // (avoid overwriting earlier options with defaults from parsePwCliGlobalOptions)
723
+ if (flags.length > 0) {
724
+ const defaults = parsePwCliGlobalOptions([]);
725
+ const afterOptions = parsePwCliGlobalOptions(flags);
726
+ for (const [key, value] of Object.entries(afterOptions)) {
727
+ if (value !== defaults[key]) {
728
+ options[key] = value;
729
+ }
730
+ }
731
+ }
724
732
 
725
733
  const positionals = afterRs.slice(restIdx);
726
734
  const [scriptPath, ...scriptArgs] = positionals;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guanzhu.me/pw-cli",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "Persistent Playwright browser CLI with headed defaults, profile support, queueing, and script execution",
5
5
  "bin": {
6
6
  "pw-cli": "./bin/pw-cli.js"
@@ -322,11 +322,14 @@ class CDPRelayServer {
322
322
  }
323
323
 
324
324
  _connectBrowser(clientName) {
325
- const relayUrl = `${this._wsHost}${this._extensionPath}`;
326
- const url = new URL('chrome-extension://mmlmfjhmonkocbjadbfplnigmagldckm/connect.html');
327
- url.searchParams.set('mcpRelayUrl', relayUrl);
325
+ const mcpRelayEndpoint = `${this._wsHost}${this._extensionPath}`;
326
+ // Support both the new official extension ID and the legacy one
327
+ const extensionId = process.env.PLAYWRIGHT_MCP_EXTENSION_ID || 'mmlmfjhmonkocbjadbfplnigmagldckm';
328
+ const url = new URL(`chrome-extension://${extensionId}/connect.html`);
329
+ url.searchParams.set('mcpRelayUrl', mcpRelayEndpoint);
328
330
  url.searchParams.set('client', JSON.stringify({ name: clientName }));
329
331
  url.searchParams.set('protocolVersion', '1');
332
+ url.searchParams.set('newTab', 'true');
330
333
  if (this._extensionToken) {
331
334
  url.searchParams.set('token', this._extensionToken);
332
335
  }
@@ -354,13 +357,6 @@ class CDPRelayServer {
354
357
  return;
355
358
  }
356
359
  if (url.pathname === this._extensionPath) {
357
- if (this._extensionToken) {
358
- const token = url.searchParams.get('token');
359
- if (token !== this._extensionToken) {
360
- socket.close(4003, 'Invalid token');
361
- return;
362
- }
363
- }
364
360
  this._handleExtensionConnection(socket);
365
361
  return;
366
362
  }