gm-skill 2.0.1267 → 2.0.1269

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/README.md CHANGED
@@ -35,7 +35,7 @@ An earlier generation fanned out fifteen per-platform downstream repos (gm-cc, g
35
35
 
36
36
  ## Version
37
37
 
38
- `2.0.1267` — auto-bumped from the canonical `gm` repo. Every push to `AnEntrypoint/gm` (or any cascading sibling crate) republishes this package.
38
+ `2.0.1269` — auto-bumped from the canonical `gm` repo. Every push to `AnEntrypoint/gm` (or any cascading sibling crate) republishes this package.
39
39
 
40
40
  ## Source of truth
41
41
 
@@ -420,7 +420,85 @@ function writeJsonFile(fp, value) {
420
420
  try { fs.writeFileSync(fp, JSON.stringify(value, null, 2)); } catch (_) {}
421
421
  }
422
422
 
423
+ function bundledBrowserCacheRoots() {
424
+ const roots = [];
425
+ const envOverride = process.env.PLAYWRIGHT_BROWSERS_PATH;
426
+ if (envOverride) roots.push(envOverride);
427
+ if (process.platform === 'win32') {
428
+ if (process.env.LOCALAPPDATA) roots.push(path.join(process.env.LOCALAPPDATA, 'ms-playwright'));
429
+ } else if (process.platform === 'darwin') {
430
+ if (process.env.HOME) roots.push(path.join(process.env.HOME, 'Library', 'Caches', 'ms-playwright'));
431
+ } else {
432
+ if (process.env.HOME) roots.push(path.join(process.env.HOME, '.cache', 'ms-playwright'));
433
+ }
434
+ return roots.filter(r => r && fs.existsSync(r));
435
+ }
436
+
437
+ function chromiumExeFromCacheRoot(root) {
438
+ try {
439
+ const entries = fs.readdirSync(root)
440
+ .filter(n => /^chromium-\d+$/.test(n))
441
+ .sort((a, b) => parseInt(b.split('-')[1], 10) - parseInt(a.split('-')[1], 10));
442
+ const subdirs = process.platform === 'win32'
443
+ ? ['chrome-win64', 'chrome-win']
444
+ : process.platform === 'darwin'
445
+ ? ['chrome-mac/Chromium.app/Contents/MacOS/Chromium']
446
+ : ['chrome-linux'];
447
+ const exeName = process.platform === 'win32' ? 'chrome.exe'
448
+ : process.platform === 'darwin' ? null
449
+ : 'chrome';
450
+ for (const e of entries) {
451
+ for (const sub of subdirs) {
452
+ const p = exeName ? path.join(root, e, sub, exeName) : path.join(root, e, sub);
453
+ if (fs.existsSync(p)) return p;
454
+ }
455
+ }
456
+ } catch (_) {}
457
+ return null;
458
+ }
459
+
460
+ function findBundledChromium() {
461
+ for (const root of bundledBrowserCacheRoots()) {
462
+ const exe = chromiumExeFromCacheRoot(root);
463
+ if (exe) return exe;
464
+ }
465
+ try {
466
+ const npmR = spawnSync('npm', ['root', '-g'], { encoding: 'utf-8', shell: true, windowsHide: true, timeout: 5000 });
467
+ if (npmR.status === 0 && npmR.stdout.trim()) {
468
+ const root = npmR.stdout.trim().split(/\r?\n/).pop();
469
+ const localBrowsers = path.join(root, 'playwriter', 'node_modules', '@xmorse', 'playwright-core', '.local-browsers');
470
+ if (fs.existsSync(localBrowsers)) {
471
+ const exe = chromiumExeFromCacheRoot(localBrowsers);
472
+ if (exe) return exe;
473
+ }
474
+ }
475
+ } catch (_) {}
476
+ return null;
477
+ }
478
+
479
+ function ensureBundledChromium(pw) {
480
+ const existing = findBundledChromium();
481
+ if (existing) return { exe: existing, installed: false };
482
+ if (!pw || !pw.cmd) {
483
+ return { exe: null, installed: false, error: 'playwriter not available to install browser' };
484
+ }
485
+ const installer = { cmd: pw.cmd, args: [...pw.baseArgs, 'install', 'chromium'], shell: pw.shell };
486
+ logEvent('bootstrap', 'browser.bundled-install.start', { via: 'playwriter' });
487
+ const r = spawnSync(installer.cmd, installer.args, {
488
+ encoding: 'utf-8',
489
+ timeout: 600000,
490
+ shell: installer.shell,
491
+ windowsHide: true,
492
+ });
493
+ logEvent('bootstrap', 'browser.bundled-install.done', { status: r.status });
494
+ const after = findBundledChromium();
495
+ if (after) return { exe: after, installed: true };
496
+ return { exe: null, installed: false, error: r.stderr || r.stdout || 'install failed' };
497
+ }
498
+
423
499
  function findChrome() {
500
+ const bundled = findBundledChromium();
501
+ if (bundled) return bundled;
424
502
  if (process.platform === 'win32') {
425
503
  const candidates = [
426
504
  path.join(process.env.PROGRAMFILES || 'C:\\Program Files', 'Google', 'Chrome', 'Application', 'chrome.exe'),
@@ -630,7 +708,7 @@ function runPlaywriter(pw, args, timeoutMs) {
630
708
  function scrubBrowserRunnerText(s) {
631
709
  if (!s || typeof s !== 'string') return s;
632
710
  let t = s;
633
- t = t.replace(/playwriter/gi, 'managed browser session');
711
+ t = t.replace(/(^|[^A-Za-z0-9_\\/.-])playwriter(?![A-Za-z0-9_\\/.-])/gi, (m, pre) => `${pre}managed browser session`);
634
712
  t = t.replace(/Click the[^.\n]*?extension[^.\n]*?icon[^.\n]*?\.?/gi, '');
635
713
  t = t.replace(/(connected\s+)?browser\s+extension(\s+is)?\s+not\s+connected\b[^.\n]*\.?/gi, '');
636
714
  t = t.replace(/no\s+connected\s+browsers?\b[^.\n]*\.?/gi, '');
@@ -670,8 +748,13 @@ function getOrCreateBrowserSession(cwd, claudeSessionId, pw) {
670
748
  }
671
749
  }
672
750
  cleanDeadProfileFragments(cwd);
673
- const chrome = findChrome();
674
- if (!chrome) throw new Error('Chrome not found. Please install Google Chrome.');
751
+ let chrome = findBundledChromium();
752
+ if (!chrome) {
753
+ const ensured = ensureBundledChromium(pw);
754
+ if (ensured.exe) chrome = ensured.exe;
755
+ }
756
+ if (!chrome) chrome = findChrome();
757
+ if (!chrome) throw new Error('No chromium binary available. Run: bun x playwriter@latest install chromium');
675
758
  const profileDir = acquireProfileDir(cwd);
676
759
  const port = findFreePortSync();
677
760
  const chromeArgs = [
@@ -701,7 +784,7 @@ function getOrCreateBrowserSession(cwd, claudeSessionId, pw) {
701
784
  sleepSync(300);
702
785
  }
703
786
  if (!alive) throw new Error(`Chrome failed to open debug port ${port}`);
704
- const newR = runPlaywriter(pw, ['session', 'new', `--direct=localhost:${port}`], 30000);
787
+ const newR = runPlaywriter(pw, ['session', 'new', '--direct', `localhost:${port}`], 30000);
705
788
  if (newR.status !== 0) throw new Error(`managed browser session start failed: ${scrubBrowserRunnerText(newR.stderr || newR.stdout || 'unknown')}`);
706
789
  const stripAnsi = (s) => s.replace(/\x1b\[[0-9;]*m/g, '');
707
790
  const out = stripAnsi(newR.stdout || '').trim();
package/gm.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm",
3
- "version": "2.0.1267",
3
+ "version": "2.0.1269",
4
4
  "description": "Spool-dispatch orchestration engine with unified state machine, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-skill",
3
- "version": "2.0.1267",
3
+ "version": "2.0.1269",
4
4
  "description": "Canonical universal harness — AI-native software engineering via skill-driven orchestration; bootstraps plugkit for task execution and session isolation. Install in any AI coding agent host.",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  "gm.json"
40
40
  ],
41
41
  "dependencies": {
42
- "gm-plugkit": "^2.0.1267"
42
+ "gm-plugkit": "^2.0.1269"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=16.0.0"