gm-copilot-cli 2.0.161 → 2.0.163
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/agents/gm.md +13 -1
- package/copilot-profile.md +1 -1
- package/hooks/pre-tool-use-hook.js +36 -1
- package/manifest.yml +1 -1
- package/package.json +1 -1
- package/tools.json +1 -1
package/agents/gm.md
CHANGED
|
@@ -50,7 +50,19 @@ Scope: All available skills and their mandatory usage rules. Every skill listed
|
|
|
50
50
|
|
|
51
51
|
**`gm` agent** — Subagent orchestration. MANDATORY for parallel work waves. Launch via Task tool with subagent_type gm:gm. Maximum 3 per wave. Independent items run simultaneously; dependent items wait. Sequential execution of independent items is forbidden.
|
|
52
52
|
|
|
53
|
-
**`exec` via Bash** —
|
|
53
|
+
**`exec` via Bash interception** — Run raw code by using the Bash tool with an `exec` prefix. The hook intercepts it, runs via gm-exec, and returns output as the tool result. Syntax:
|
|
54
|
+
```
|
|
55
|
+
exec:<lang>
|
|
56
|
+
<code or shell commands here>
|
|
57
|
+
```
|
|
58
|
+
- `exec:nodejs` or just `exec` (default) — JavaScript/TypeScript via bun
|
|
59
|
+
- `exec:python` — Python
|
|
60
|
+
- `exec:bash` or `exec:sh` — Shell commands (multi-line supported)
|
|
61
|
+
- `exec:cmd` — Windows cmd.exe
|
|
62
|
+
- `exec:go`, `exec:rust`, `exec:c`, `exec:cpp`, `exec:java`, `exec:deno` — compiled langs
|
|
63
|
+
- Optional `cwd` field on the Bash tool input sets working directory
|
|
64
|
+
- Output returned as tool result synchronously (up to 30s)
|
|
65
|
+
- Use this for ALL code execution instead of `bun x gm-exec exec` — cleaner and more direct
|
|
54
66
|
|
|
55
67
|
|
|
56
68
|
|
package/copilot-profile.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const { execSync } = require('child_process');
|
|
5
|
+
const { execSync, spawnSync } = require('child_process');
|
|
6
6
|
|
|
7
7
|
const isGemini = process.env.GEMINI_PROJECT_DIR !== undefined;
|
|
8
8
|
|
|
@@ -65,6 +65,41 @@ const run = () => {
|
|
|
65
65
|
|
|
66
66
|
if (tool_name === 'Bash') {
|
|
67
67
|
const command = (tool_input?.command || '').trim();
|
|
68
|
+
|
|
69
|
+
const execMatch = command.match(/^exec(?::(\S+))?\n([\s\S]+)$/);
|
|
70
|
+
if (execMatch) {
|
|
71
|
+
const lang = execMatch[1] || 'nodejs';
|
|
72
|
+
const code = execMatch[2];
|
|
73
|
+
const cwd = tool_input?.cwd;
|
|
74
|
+
const stripFooter = (s) => s.replace(/\n\[Running tools\][\s\S]*$/, '').trimEnd();
|
|
75
|
+
try {
|
|
76
|
+
let args;
|
|
77
|
+
if (lang === 'bash' || lang === 'sh' || lang === 'cmd') {
|
|
78
|
+
args = ['x', 'gm-exec', 'bash'];
|
|
79
|
+
if (cwd) args.push(`--cwd=${cwd}`);
|
|
80
|
+
args.push(code);
|
|
81
|
+
} else {
|
|
82
|
+
args = ['x', 'gm-exec', 'exec', `--lang=${lang}`];
|
|
83
|
+
if (cwd) args.push(`--cwd=${cwd}`);
|
|
84
|
+
args.push(code);
|
|
85
|
+
}
|
|
86
|
+
const r = spawnSync('bun', args, { encoding: 'utf-8', timeout: 30000 });
|
|
87
|
+
let result = stripFooter((r.stdout || '') + (r.stderr || ''));
|
|
88
|
+
const bgMatch = result.match(/Command running in background with ID:\s*(\S+)/);
|
|
89
|
+
if (bgMatch) {
|
|
90
|
+
const taskId = bgMatch[1];
|
|
91
|
+
spawnSync('bun', ['x', 'gm-exec', 'sleep', taskId, '60'], { encoding: 'utf-8', timeout: 70000 });
|
|
92
|
+
const sr = spawnSync('bun', ['x', 'gm-exec', 'status', taskId], { encoding: 'utf-8', timeout: 15000 });
|
|
93
|
+
result = stripFooter((sr.stdout || '') + (sr.stderr || ''));
|
|
94
|
+
spawnSync('bun', ['x', 'gm-exec', 'close', taskId], { encoding: 'utf-8', timeout: 10000 });
|
|
95
|
+
}
|
|
96
|
+
return { block: true, reason: result || '(no output)' };
|
|
97
|
+
} catch (e) {
|
|
98
|
+
const err = (e.stdout || '') + (e.stderr || '') || e.message;
|
|
99
|
+
return { block: true, reason: err || '(exec failed)' };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
68
103
|
if (!/^bun x gm-exec(@[^\s]*)?(\s|$)/.test(command) && !/^git /.test(command) && !/^bun x codebasesearch/.test(command) && !/(\bclaude\b)/.test(command) && !/^npm install .* \/config\/.gmweb\/npm-global\/lib\/node_modules\/gm-exec/.test(command) && !/^bun install --cwd \/config\/.gmweb\/npm-global\/lib\/node_modules\/gm-exec/.test(command)) {
|
|
69
104
|
let helpText = '';
|
|
70
105
|
try { helpText = '\n\n' + execSync('bun x gm-exec --help', { timeout: 10000 }).toString().trim(); } catch (e) {}
|
package/manifest.yml
CHANGED
package/package.json
CHANGED