gm-cc 2.0.213 → 2.0.215

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.
@@ -4,7 +4,7 @@
4
4
  "name": "AnEntrypoint"
5
5
  },
6
6
  "description": "State machine agent with hooks, skills, and automated git enforcement",
7
- "version": "2.0.213",
7
+ "version": "2.0.215",
8
8
  "metadata": {
9
9
  "description": "State machine agent with hooks, skills, and automated git enforcement"
10
10
  },
@@ -368,6 +368,23 @@ const run = () => {
368
368
  const AB_CMDS = new Set(['open','goto','navigate','close','quit','exit','back','forward','reload','click','dblclick','type','fill','press','check','uncheck','select','drag','upload','hover','focus','scroll','scrollintoview','wait','screenshot','pdf','snapshot','get','is','find','eval','connect','tab','frame','dialog','state','session','network','cookies','storage','set','trace','profiler','record','console','errors','highlight','inspect','diff','keyboard','mouse','install','upgrade','confirm','deny','auth','device','window']);
369
369
  const AB_GLOBAL_FLAGS = new Set(['--cdp','--headed','--headless','--session','--session-name','--auto-connect','--profile','--allow-file-access','--color-scheme','-p','--platform','--device']);
370
370
  const AB_GLOBAL_FLAGS_WITH_VALUE = new Set(['--cdp','--session','--session-name','--profile','--color-scheme','-p','--platform','--device']);
371
+ function loadAbProfile(dir) {
372
+ if (!dir) return [];
373
+ try {
374
+ const cfg = JSON.parse(fs.readFileSync(path.join(dir, '.agent-browser.json'), 'utf8'));
375
+ const flags = [];
376
+ if (cfg.headed) flags.push('--headed');
377
+ if (cfg.headless) flags.push('--headless');
378
+ if (cfg.profile) flags.push('--profile', cfg.profile);
379
+ if (cfg.cdp) flags.push('--cdp', String(cfg.cdp));
380
+ if (cfg.platform || cfg.p) flags.push('-p', cfg.platform || cfg.p);
381
+ if (cfg.device) flags.push('--device', cfg.device);
382
+ if (cfg['allow-file-access']) flags.push('--allow-file-access');
383
+ if (cfg['color-scheme']) flags.push('--color-scheme', cfg['color-scheme']);
384
+ return flags;
385
+ } catch { return []; }
386
+ }
387
+ const abProfileFlags = loadAbProfile(projectDir || cwd || process.cwd());
371
388
  const AB_SESSION_STATE = path.join(os.tmpdir(), 'gm-ab-sessions.json');
372
389
  function readAbSessions() { try { return JSON.parse(fs.readFileSync(AB_SESSION_STATE, 'utf8')); } catch { return {}; } }
373
390
  function writeAbSessions(s) { try { fs.writeFileSync(AB_SESSION_STATE, JSON.stringify(s)); } catch {} }
@@ -396,11 +413,21 @@ const run = () => {
396
413
  if (isClose) delete sessions[sessionName];
397
414
  writeAbSessions(sessions);
398
415
  const openSessions = Object.entries(sessions);
416
+ function mergeProfileFlags(userGlobalArgs) {
417
+ const userFlagSet = new Set(userGlobalArgs.filter(f => f.startsWith('-')));
418
+ const filtered = [];
419
+ for (let i = 0; i < abProfileFlags.length; i++) {
420
+ const f = abProfileFlags[i];
421
+ if (f.startsWith('-') && userFlagSet.has(f)) { if (AB_GLOBAL_FLAGS_WITH_VALUE.has(f)) i++; continue; }
422
+ filtered.push(f);
423
+ }
424
+ return [...filtered, ...userGlobalArgs];
425
+ }
399
426
  if (AB_CMDS.has(firstWord)) {
400
427
  const lines = safeCode.split('\n').map(l => l.trim()).filter(Boolean);
401
428
  if (lines.length === 1) {
402
429
  const { globalArgs, rest } = parseAbLine(lines[0]);
403
- result = spawnDirect(abBin, [...globalArgs, ...rest]);
430
+ result = spawnDirect(abBin, [...mergeProfileFlags(globalArgs), ...rest]);
404
431
  } else {
405
432
  const hasClose = lines.some(l => { const w = (parseAbLine(l).rest[0]||'').toLowerCase(); return ['close','quit','exit'].includes(w); });
406
433
  const cmds = lines.map(l => {
@@ -408,14 +435,15 @@ const run = () => {
408
435
  const w = (rest[0]||'').toLowerCase();
409
436
  if (['open','goto','navigate'].includes(w)) sessions[sessionName] = { url: rest[1]||'?', ts: Date.now() };
410
437
  if (['close','quit','exit'].includes(w)) delete sessions[sessionName];
411
- return [...globalArgs, ...rest];
438
+ if (!AB_CMDS.has(w)) return [...mergeProfileFlags(globalArgs), 'eval', l.trim()];
439
+ return [...mergeProfileFlags(globalArgs), ...rest];
412
440
  });
413
441
  writeAbSessions(sessions);
414
442
  result = spawnDirect(abBin, ['batch'], JSON.stringify(cmds));
415
443
  if (!hasClose && openSessions.length > 0) result += `\n\n[tab] Browser session "${sessionName}" still open. Close when done:\n exec:agent-browser\n close`;
416
444
  }
417
445
  } else {
418
- result = spawnDirect(abBin, ['eval', '--stdin'], safeCode);
446
+ result = spawnDirect(abBin, [...abProfileFlags, 'eval', '--stdin'], safeCode);
419
447
  }
420
448
  if (openSessions.length > 1) {
421
449
  const stale = openSessions.filter(([n]) => n !== sessionName).map(([n,v]) => ` "${n}" → ${v.url} (${Math.round((Date.now()-v.ts)/60000)}min ago)`).join('\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-cc",
3
- "version": "2.0.213",
3
+ "version": "2.0.215",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm",
3
- "version": "2.0.213",
3
+ "version": "2.0.215",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": {
6
6
  "name": "AnEntrypoint",
@@ -8,22 +8,24 @@ allowed-tools: agent-browser, Bash(exec:agent-browser*)
8
8
 
9
9
  ## Two Pathways
10
10
 
11
- **`exec:agent-browser` (primary)** — run browser CLI commands or JavaScript eval via Bash. Each line in the body is a CLI command. Lines that are not recognized CLI commands are automatically routed through `eval --stdin`. Supports multi-command batches in a single block.
11
+ **Page control** — use the `agent-browser` tool directly for all browser interaction: navigating, clicking, filling forms, taking screenshots, reading snapshots. This is the primary pathway for driving the browser.
12
+
13
+ **Code execution** — use `exec:agent-browser` via Bash when you need to run JavaScript in the page context. The body is piped to `eval --stdin`. Use this for DOM inspection, custom extraction logic, or anything requiring programmatic page access.
12
14
 
13
15
  ```
14
16
  exec:agent-browser
15
- open http://localhost:3001
16
- wait 2000
17
- snapshot -i
17
+ document.title
18
18
  ```
19
19
 
20
+ Multi-line `exec:agent-browser` blocks where lines are recognized CLI commands run as a batch instead of eval — useful for sequencing page control steps when the `agent-browser` tool isn't available:
21
+
20
22
  ```
21
23
  exec:agent-browser
22
- document.title
24
+ open http://localhost:3001
25
+ wait 2000
26
+ snapshot -i
23
27
  ```
24
28
 
25
- **`agent-browser` tool (alternative)** — call the MCP tool directly with a single CLI command at a time. Use when you only need one command and don't need batching.
26
-
27
29
  **Always close tabs when done**: every `open` is tracked. Use `exec:agent-browser\nclose` (or `--session <name> close`) when finished. Leaving sessions open accumulates stale tabs — the hook will warn you when other sessions are still open.
28
30
 
29
31
  ## Core Workflow