gm-copilot-cli 2.0.212 → 2.0.216
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/copilot-profile.md +1 -1
- package/hooks/pre-tool-use-hook.js +107 -7
- package/index.html +1 -1
- package/manifest.yml +1 -1
- package/package.json +1 -1
- package/skills/agent-browser/SKILL.md +17 -3
- package/tools.json +1 -1
package/copilot-profile.md
CHANGED
|
@@ -241,7 +241,7 @@ const run = () => {
|
|
|
241
241
|
const rawLang = (execMatch[1] || '').toLowerCase();
|
|
242
242
|
const code = execMatch[2];
|
|
243
243
|
if (/^\s*agent-browser\s/.test(code)) {
|
|
244
|
-
return deny(`Do not call agent-browser via exec:bash. Use exec:agent-browser instead:\n\nexec:agent-browser\n
|
|
244
|
+
return deny(`Do not call agent-browser via exec:bash. Use exec:agent-browser instead:\n\nexec:agent-browser\nopen http://example.com\n\nMultiple commands in one block:\n\nexec:agent-browser\nopen http://localhost:3001\nwait 2000\nsnapshot -i\n\nFor JS eval (DOM inspection, custom logic):\n\nexec:agent-browser\ndocument.title\n\nCLI commands (open, click, screenshot, snapshot, wait, console, tab, etc.) run directly.\nAnything that is not a CLI command goes through eval --stdin.\nClose tabs when done: exec:agent-browser\\nclose`);
|
|
245
245
|
}
|
|
246
246
|
const cwd = tool_input?.cwd;
|
|
247
247
|
|
|
@@ -279,7 +279,8 @@ const run = () => {
|
|
|
279
279
|
const langExts = { nodejs: 'mjs', typescript: 'ts', deno: 'ts', python: 'py', bash: 'sh', powershell: 'ps1', go: 'go', rust: 'rs', c: 'c', cpp: 'cpp', java: 'java' };
|
|
280
280
|
|
|
281
281
|
const spawnDirect = (bin, args, stdin) => {
|
|
282
|
-
const
|
|
282
|
+
const spawnCwd = cwd || (lang === 'agent-browser' ? process.cwd() : undefined);
|
|
283
|
+
const opts = { encoding: 'utf-8', timeout: 60000, windowsHide: true, ...(spawnCwd && { cwd: spawnCwd }), ...(stdin !== undefined && { input: stdin }) };
|
|
283
284
|
const r = spawnSync(bin, args, opts);
|
|
284
285
|
if (!r.stdout && !r.stderr && r.error) return `[spawn error: ${r.error.message}]`;
|
|
285
286
|
const out = (r.stdout || '').trimEnd(), err = stripFooter(r.stderr || '').trimEnd();
|
|
@@ -364,11 +365,110 @@ const run = () => {
|
|
|
364
365
|
const wrapped = `const __result = await (async () => {\n${safeCode}\n})();\nif (__result !== undefined) { if (typeof __result === 'object') { console.log(JSON.stringify(__result, null, 2)); } else { console.log(__result); } }`;
|
|
365
366
|
result = runWithFile(lang || 'nodejs', wrapped);
|
|
366
367
|
} else if (lang === 'agent-browser') {
|
|
367
|
-
const abBin = localBin('agent-browser');
|
|
368
|
-
|
|
369
|
-
|
|
368
|
+
const abBin = fs.existsSync(localBin('agent-browser')) ? localBin('agent-browser') : 'agent-browser';
|
|
369
|
+
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']);
|
|
370
|
+
const AB_GLOBAL_FLAGS = new Set(['--cdp','--headed','--headless','--session','--session-name','--auto-connect','--profile','--allow-file-access','--color-scheme','-p','--platform','--device']);
|
|
371
|
+
const AB_GLOBAL_FLAGS_WITH_VALUE = new Set(['--cdp','--session','--session-name','--profile','--color-scheme','-p','--platform','--device']);
|
|
372
|
+
function loadAbProfile(dir) {
|
|
373
|
+
if (!dir) return { flags: [], env: {} };
|
|
374
|
+
const candidates = ['agent-browser.json', '.agent-browser.json'];
|
|
375
|
+
for (const name of candidates) {
|
|
376
|
+
try {
|
|
377
|
+
const cfg = JSON.parse(fs.readFileSync(path.join(dir, name), 'utf8'));
|
|
378
|
+
const flags = [], env = {};
|
|
379
|
+
if (cfg.headed) { flags.push('--headed'); env.AGENT_BROWSER_HEADED = '1'; }
|
|
380
|
+
if (cfg.headless) flags.push('--headless');
|
|
381
|
+
if (cfg.profile) { flags.push('--profile', cfg.profile); env.AGENT_BROWSER_PROFILE = cfg.profile; }
|
|
382
|
+
if (cfg.cdp) flags.push('--cdp', String(cfg.cdp));
|
|
383
|
+
if (cfg.platform || cfg.p) flags.push('-p', cfg.platform || cfg.p);
|
|
384
|
+
if (cfg.device) flags.push('--device', cfg.device);
|
|
385
|
+
if (cfg['allow-file-access']) flags.push('--allow-file-access');
|
|
386
|
+
if (cfg['color-scheme']) { flags.push('--color-scheme', cfg['color-scheme']); env.AGENT_BROWSER_COLOR_SCHEME = cfg['color-scheme']; }
|
|
387
|
+
return { flags, env };
|
|
388
|
+
} catch {}
|
|
389
|
+
}
|
|
390
|
+
return { flags: [], env: {} };
|
|
391
|
+
}
|
|
392
|
+
const { flags: abProfileFlags, env: abProfileEnv } = loadAbProfile(process.cwd());
|
|
393
|
+
// If profile config exists and no daemon is running, pre-start the daemon with correct cwd
|
|
394
|
+
if (abProfileFlags.length > 0) {
|
|
395
|
+
const portFile = path.join(os.tmpdir(), 'agent-shell.port');
|
|
396
|
+
const daemonRunning = fs.existsSync(portFile);
|
|
397
|
+
if (!daemonRunning) {
|
|
398
|
+
// Start daemon in background from correct cwd so it picks up agent-browser.json
|
|
399
|
+
require('child_process').spawn(abBin, ['open', 'about:blank'], {
|
|
400
|
+
detached: true, stdio: 'ignore',
|
|
401
|
+
cwd: process.cwd(),
|
|
402
|
+
env: { ...process.env, ...abProfileEnv },
|
|
403
|
+
windowsHide: true
|
|
404
|
+
}).unref();
|
|
405
|
+
// Wait for daemon to bind
|
|
406
|
+
spawnSync('cmd.exe', ['/c', 'ping -n 3 127.0.0.1 > nul'], { windowsHide: true, timeout: 5000 });
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const AB_SESSION_STATE = path.join(os.tmpdir(), 'gm-ab-sessions.json');
|
|
410
|
+
function readAbSessions() { try { return JSON.parse(fs.readFileSync(AB_SESSION_STATE, 'utf8')); } catch { return {}; } }
|
|
411
|
+
function writeAbSessions(s) { try { fs.writeFileSync(AB_SESSION_STATE, JSON.stringify(s)); } catch {} }
|
|
412
|
+
function parseAbLine(line) {
|
|
413
|
+
const tokens = line.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) || [];
|
|
414
|
+
const globalArgs = [], rest = [];
|
|
415
|
+
let i = 0;
|
|
416
|
+
while (i < tokens.length) {
|
|
417
|
+
if (AB_GLOBAL_FLAGS.has(tokens[i])) {
|
|
418
|
+
globalArgs.push(tokens[i]);
|
|
419
|
+
if (AB_GLOBAL_FLAGS_WITH_VALUE.has(tokens[i]) && i + 1 < tokens.length && !tokens[i+1].startsWith('--')) {
|
|
420
|
+
globalArgs.push(tokens[++i]);
|
|
421
|
+
}
|
|
422
|
+
i++;
|
|
423
|
+
} else { rest.push(...tokens.slice(i)); break; }
|
|
424
|
+
}
|
|
425
|
+
return { globalArgs, rest };
|
|
426
|
+
}
|
|
427
|
+
const firstLineParsed = parseAbLine(safeCode.trim().split('\n')[0].trim());
|
|
428
|
+
const firstWord = (firstLineParsed.rest[0] || '').toLowerCase();
|
|
429
|
+
const sessionName = (() => { const si = firstLineParsed.globalArgs.indexOf('--session'); return si >= 0 ? firstLineParsed.globalArgs[si+1] : 'default'; })();
|
|
430
|
+
const isOpen = ['open','goto','navigate'].includes(firstWord);
|
|
431
|
+
const isClose = ['close','quit','exit'].includes(firstWord);
|
|
432
|
+
const sessions = readAbSessions();
|
|
433
|
+
if (isOpen) sessions[sessionName] = { url: (firstLineParsed.rest[1] || '?'), ts: Date.now() };
|
|
434
|
+
if (isClose) delete sessions[sessionName];
|
|
435
|
+
writeAbSessions(sessions);
|
|
436
|
+
const openSessions = Object.entries(sessions);
|
|
437
|
+
function mergeProfileFlags(userGlobalArgs) {
|
|
438
|
+
const userFlagSet = new Set(userGlobalArgs.filter(f => f.startsWith('-')));
|
|
439
|
+
const filtered = [];
|
|
440
|
+
for (let i = 0; i < abProfileFlags.length; i++) {
|
|
441
|
+
const f = abProfileFlags[i];
|
|
442
|
+
if (f.startsWith('-') && userFlagSet.has(f)) { if (AB_GLOBAL_FLAGS_WITH_VALUE.has(f)) i++; continue; }
|
|
443
|
+
filtered.push(f);
|
|
444
|
+
}
|
|
445
|
+
return [...filtered, ...userGlobalArgs];
|
|
446
|
+
}
|
|
447
|
+
if (AB_CMDS.has(firstWord)) {
|
|
448
|
+
const lines = safeCode.split('\n').map(l => l.trim()).filter(Boolean);
|
|
449
|
+
if (lines.length === 1) {
|
|
450
|
+
const { globalArgs, rest } = parseAbLine(lines[0]);
|
|
451
|
+
result = spawnDirect(abBin, [...globalArgs, ...rest]);
|
|
452
|
+
} else {
|
|
453
|
+
const hasClose = lines.some(l => { const w = (parseAbLine(l).rest[0]||'').toLowerCase(); return ['close','quit','exit'].includes(w); });
|
|
454
|
+
const cmds = lines.map(l => {
|
|
455
|
+
const { globalArgs, rest } = parseAbLine(l);
|
|
456
|
+
const w = (rest[0]||'').toLowerCase();
|
|
457
|
+
if (['open','goto','navigate'].includes(w)) sessions[sessionName] = { url: rest[1]||'?', ts: Date.now() };
|
|
458
|
+
if (['close','quit','exit'].includes(w)) delete sessions[sessionName];
|
|
459
|
+
if (!AB_CMDS.has(w)) return [...globalArgs, 'eval', l.trim()];
|
|
460
|
+
return [...globalArgs, ...rest];
|
|
461
|
+
});
|
|
462
|
+
writeAbSessions(sessions);
|
|
463
|
+
result = spawnDirect(abBin, ['batch'], JSON.stringify(cmds));
|
|
464
|
+
if (!hasClose && openSessions.length > 0) result += `\n\n[tab] Browser session "${sessionName}" still open. Close when done:\n exec:agent-browser\n close`;
|
|
465
|
+
}
|
|
370
466
|
} else {
|
|
371
|
-
result = spawnDirect(
|
|
467
|
+
result = spawnDirect(abBin, ['eval', '--stdin'], safeCode);
|
|
468
|
+
}
|
|
469
|
+
if (openSessions.length > 1) {
|
|
470
|
+
const stale = openSessions.filter(([n]) => n !== sessionName).map(([n,v]) => ` "${n}" → ${v.url} (${Math.round((Date.now()-v.ts)/60000)}min ago)`).join('\n');
|
|
471
|
+
result = (result || '') + `\n\n[tab] ${openSessions.length - 1} other session(s) still open:\n${stale}\n Close with: exec:agent-browser\\nclose (or --session <name> close)`;
|
|
372
472
|
}
|
|
373
473
|
} else {
|
|
374
474
|
result = runWithFile(lang, safeCode);
|
|
@@ -384,7 +484,7 @@ const run = () => {
|
|
|
384
484
|
try { helpText = '\n\n' + execSync(`"${localBin('gm-exec')}" --help`, { timeout: 10000, windowsHide: true }).toString().trim(); } catch (e) {
|
|
385
485
|
try { helpText = '\n\n' + execSync('bun x gm-exec --help', { timeout: 10000, windowsHide: true }).toString().trim(); } catch {}
|
|
386
486
|
}
|
|
387
|
-
return deny(`Bash is restricted to exec:<lang> and git.\n\nexec:<lang> syntax (lang auto-detected if omitted):\n exec:nodejs / exec:python / exec:bash / exec:typescript\n exec:go / exec:rust / exec:java / exec:c / exec:cpp\n exec:cmd ← runs cmd.exe /c on Windows\n exec:agent-browser ←
|
|
487
|
+
return deny(`Bash is restricted to exec:<lang> and git.\n\nexec:<lang> syntax (lang auto-detected if omitted):\n exec:nodejs / exec:python / exec:bash / exec:typescript\n exec:go / exec:rust / exec:java / exec:c / exec:cpp\n exec:cmd ← runs cmd.exe /c on Windows\n exec:agent-browser ← browser CLI (open, click, snapshot, wait, tab, console...)\n OR JS eval when body is not a CLI command\n exec ← auto-detects language\n\nexec:agent-browser examples:\n open http://localhost:3001 ← navigate\n snapshot -i ← get element refs\n wait 2000 ← wait ms\n console ← read browser console\n close ← ALWAYS close when done\n document.title ← JS eval (not a CLI command)\n\nMultiple CLI commands in one block run as batch:\n exec:agent-browser\n open http://localhost:3001\n wait 2000\n snapshot -i\n\nTask management shortcuts (body = args):\n exec:status\n <task_id>\n\n exec:sleep\n <task_id> [seconds] [--next-output]\n\n exec:type\n <task_id>\n <input to send to stdin>\n\n exec:close\n <task_id>\n\n exec:runner\n start|stop|status\n\nCode search shortcut:\n exec:codesearch\n <natural language query>\n\nbun x gm-exec${helpText}\n\nAll other Bash commands are blocked.`);
|
|
388
488
|
}
|
|
389
489
|
}
|
|
390
490
|
|
package/index.html
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<script type="module">
|
|
19
19
|
import { createElement as h, applyDiff, Fragment } from "webjsx";
|
|
20
20
|
const PLATFORM_NAME="Copilot CLI",PLATFORM_TYPE="CLI Tool",PLATFORM_TYPE_COLOR="#3b82f6";
|
|
21
|
-
const DESCRIPTION="State machine agent with hooks, skills, and automated git enforcement",VERSION="2.0.
|
|
21
|
+
const DESCRIPTION="State machine agent with hooks, skills, and automated git enforcement",VERSION="2.0.216";
|
|
22
22
|
const GITHUB_URL="https://github.com/AnEntrypoint/gm-copilot-cli",BADGE_LABEL="copilot-cli";
|
|
23
23
|
const FEATURES=[{"title":"State Machine","desc":"Immutable PLAN→EXECUTE→EMIT→VERIFY→COMPLETE phases with full mutable tracking"},{"title":"Semantic Search","desc":"Natural language codebase exploration via codesearch skill — no grep needed"},{"title":"Hooks","desc":"Pre-tool, session-start, prompt-submit, and stop hooks for full lifecycle control"},{"title":"Agents","desc":"gm, codesearch, and websearch agents pre-configured and ready to use"},{"title":"MCP Integration","desc":"Model Context Protocol server support built in"},{"title":"Auto-Recovery","desc":"Supervisor hierarchy ensures the system never crashes"}],INSTALL_STEPS=[{"desc":"Install via GitHub CLI","cmd":"gh extension install AnEntrypoint/gm-copilot-cli"},{"desc":"Restart your terminal — activates automatically"}];
|
|
24
24
|
const CURRENT_PLATFORM="gm-copilot-cli";
|
package/manifest.yml
CHANGED
package/package.json
CHANGED
|
@@ -8,11 +8,25 @@ allowed-tools: agent-browser, Bash(exec:agent-browser*)
|
|
|
8
8
|
|
|
9
9
|
## Two Pathways
|
|
10
10
|
|
|
11
|
-
**
|
|
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
12
|
|
|
13
|
-
**
|
|
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.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
```
|
|
16
|
+
exec:agent-browser
|
|
17
|
+
document.title
|
|
18
|
+
```
|
|
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
|
+
|
|
22
|
+
```
|
|
23
|
+
exec:agent-browser
|
|
24
|
+
open http://localhost:3001
|
|
25
|
+
wait 2000
|
|
26
|
+
snapshot -i
|
|
27
|
+
```
|
|
28
|
+
|
|
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.
|
|
16
30
|
|
|
17
31
|
## Core Workflow
|
|
18
32
|
|