gm-skill 2.0.1267 → 2.0.1268

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.1268` — 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,84 @@ function writeJsonFile(fp, value) {
420
420
  try { fs.writeFileSync(fp, JSON.stringify(value, null, 2)); } catch (_) {}
421
421
  }
422
422
 
423
+ function msPlaywrightCacheRoots() {
424
+ const roots = [];
425
+ if (process.env.PLAYWRIGHT_BROWSERS_PATH) roots.push(process.env.PLAYWRIGHT_BROWSERS_PATH);
426
+ if (process.platform === 'win32') {
427
+ if (process.env.LOCALAPPDATA) roots.push(path.join(process.env.LOCALAPPDATA, 'ms-playwright'));
428
+ } else if (process.platform === 'darwin') {
429
+ if (process.env.HOME) roots.push(path.join(process.env.HOME, 'Library', 'Caches', 'ms-playwright'));
430
+ } else {
431
+ if (process.env.HOME) roots.push(path.join(process.env.HOME, '.cache', 'ms-playwright'));
432
+ }
433
+ return roots.filter(r => r && fs.existsSync(r));
434
+ }
435
+
436
+ function chromiumExeFromCacheRoot(root) {
437
+ try {
438
+ const entries = fs.readdirSync(root)
439
+ .filter(n => /^chromium-\d+$/.test(n))
440
+ .sort((a, b) => parseInt(b.split('-')[1], 10) - parseInt(a.split('-')[1], 10));
441
+ const subdirs = process.platform === 'win32'
442
+ ? ['chrome-win64', 'chrome-win']
443
+ : process.platform === 'darwin'
444
+ ? ['chrome-mac/Chromium.app/Contents/MacOS/Chromium']
445
+ : ['chrome-linux'];
446
+ const exeName = process.platform === 'win32' ? 'chrome.exe'
447
+ : process.platform === 'darwin' ? null
448
+ : 'chrome';
449
+ for (const e of entries) {
450
+ for (const sub of subdirs) {
451
+ const p = exeName ? path.join(root, e, sub, exeName) : path.join(root, e, sub);
452
+ if (fs.existsSync(p)) return p;
453
+ }
454
+ }
455
+ } catch (_) {}
456
+ return null;
457
+ }
458
+
459
+ function findBundledChromium() {
460
+ for (const root of msPlaywrightCacheRoots()) {
461
+ const exe = chromiumExeFromCacheRoot(root);
462
+ if (exe) return exe;
463
+ }
464
+ try {
465
+ const npmR = spawnSync('npm', ['root', '-g'], { encoding: 'utf-8', shell: true, windowsHide: true, timeout: 5000 });
466
+ if (npmR.status === 0 && npmR.stdout.trim()) {
467
+ const root = npmR.stdout.trim().split(/\r?\n/).pop();
468
+ const pwBrowsers = path.join(root, 'playwriter', 'node_modules', '@xmorse', 'playwright-core', '.local-browsers');
469
+ if (fs.existsSync(pwBrowsers)) {
470
+ const exe = chromiumExeFromCacheRoot(pwBrowsers);
471
+ if (exe) return exe;
472
+ }
473
+ }
474
+ } catch (_) {}
475
+ return null;
476
+ }
477
+
478
+ function ensureBundledChromium(pw) {
479
+ const existing = findBundledChromium();
480
+ if (existing) return { exe: existing, installed: false };
481
+ const installer = pw && pw.cmd
482
+ ? { cmd: pw.cmd, args: [...pw.baseArgs, 'install', 'chromium'], shell: pw.shell }
483
+ : { cmd: 'npx', args: ['-y', 'playwright', 'install', 'chromium'], shell: true };
484
+ logEvent('bootstrap', 'browser.chromium-install.start', { via: installer.cmd });
485
+ const r = spawnSync(installer.cmd, installer.args, {
486
+ encoding: 'utf-8',
487
+ timeout: 600000,
488
+ shell: installer.shell,
489
+ windowsHide: true,
490
+ env: { ...process.env, PLAYWRIGHT_BROWSERS_PATH: process.env.PLAYWRIGHT_BROWSERS_PATH || '' },
491
+ });
492
+ logEvent('bootstrap', 'browser.chromium-install.done', { status: r.status });
493
+ const after = findBundledChromium();
494
+ if (after) return { exe: after, installed: true };
495
+ return { exe: null, installed: false, error: r.stderr || r.stdout || 'install failed' };
496
+ }
497
+
423
498
  function findChrome() {
499
+ const bundled = findBundledChromium();
500
+ if (bundled) return bundled;
424
501
  if (process.platform === 'win32') {
425
502
  const candidates = [
426
503
  path.join(process.env.PROGRAMFILES || 'C:\\Program Files', 'Google', 'Chrome', 'Application', 'chrome.exe'),
@@ -630,7 +707,7 @@ function runPlaywriter(pw, args, timeoutMs) {
630
707
  function scrubBrowserRunnerText(s) {
631
708
  if (!s || typeof s !== 'string') return s;
632
709
  let t = s;
633
- t = t.replace(/playwriter/gi, 'managed browser session');
710
+ t = t.replace(/(^|[^A-Za-z0-9_\\/.-])playwriter(?![A-Za-z0-9_\\/.-])/gi, (m, pre) => `${pre}managed browser session`);
634
711
  t = t.replace(/Click the[^.\n]*?extension[^.\n]*?icon[^.\n]*?\.?/gi, '');
635
712
  t = t.replace(/(connected\s+)?browser\s+extension(\s+is)?\s+not\s+connected\b[^.\n]*\.?/gi, '');
636
713
  t = t.replace(/no\s+connected\s+browsers?\b[^.\n]*\.?/gi, '');
@@ -670,8 +747,13 @@ function getOrCreateBrowserSession(cwd, claudeSessionId, pw) {
670
747
  }
671
748
  }
672
749
  cleanDeadProfileFragments(cwd);
673
- const chrome = findChrome();
674
- if (!chrome) throw new Error('Chrome not found. Please install Google Chrome.');
750
+ let chrome = findBundledChromium();
751
+ if (!chrome) {
752
+ const ensured = ensureBundledChromium(pw);
753
+ if (ensured.exe) chrome = ensured.exe;
754
+ }
755
+ if (!chrome) chrome = findChrome();
756
+ if (!chrome) throw new Error('No chromium binary available. Run: npx playwright install chromium');
675
757
  const profileDir = acquireProfileDir(cwd);
676
758
  const port = findFreePortSync();
677
759
  const chromeArgs = [
@@ -701,7 +783,7 @@ function getOrCreateBrowserSession(cwd, claudeSessionId, pw) {
701
783
  sleepSync(300);
702
784
  }
703
785
  if (!alive) throw new Error(`Chrome failed to open debug port ${port}`);
704
- const newR = runPlaywriter(pw, ['session', 'new', `--direct=localhost:${port}`], 30000);
786
+ const newR = runPlaywriter(pw, ['session', 'new', '--direct', `localhost:${port}`], 30000);
705
787
  if (newR.status !== 0) throw new Error(`managed browser session start failed: ${scrubBrowserRunnerText(newR.stderr || newR.stdout || 'unknown')}`);
706
788
  const stripAnsi = (s) => s.replace(/\x1b\[[0-9;]*m/g, '');
707
789
  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.1268",
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.1268",
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.1268"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=16.0.0"