gm-copilot-cli 2.0.164 → 2.0.166
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 +13 -0
- package/manifest.yml +1 -1
- package/package.json +1 -1
- package/tools.json +1 -1
package/copilot-profile.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
5
6
|
const { execSync, spawnSync } = require('child_process');
|
|
6
7
|
|
|
7
8
|
const isGemini = process.env.GEMINI_PROJECT_DIR !== undefined;
|
|
@@ -100,6 +101,18 @@ const run = () => {
|
|
|
100
101
|
if (cwd) args.push(`--cwd=${cwd}`);
|
|
101
102
|
args.push(code);
|
|
102
103
|
} else {
|
|
104
|
+
const isMultiLine = code.includes('\n');
|
|
105
|
+
if (isMultiLine) {
|
|
106
|
+
const extMap = { nodejs: 'mjs', typescript: 'ts', python: 'py', go: 'go', rust: 'rs', deno: 'ts' };
|
|
107
|
+
const ext = extMap[lang] || 'mjs';
|
|
108
|
+
const tmpFile = path.join(os.tmpdir(), `gm-exec-${Date.now()}.${ext}`);
|
|
109
|
+
fs.writeFileSync(tmpFile, code, 'utf-8');
|
|
110
|
+
args = ['x', 'gm-exec', 'exec', `--lang=${lang}`, `--file=${tmpFile}`];
|
|
111
|
+
if (cwd) args.push(`--cwd=${cwd}`);
|
|
112
|
+
const result = runExec(args);
|
|
113
|
+
try { fs.unlinkSync(tmpFile); } catch (e) {}
|
|
114
|
+
return { block: true, reason: result || '(no output)' };
|
|
115
|
+
}
|
|
103
116
|
args = ['x', 'gm-exec', 'exec', `--lang=${lang}`];
|
|
104
117
|
if (cwd) args.push(`--cwd=${cwd}`);
|
|
105
118
|
args.push(code);
|
package/manifest.yml
CHANGED
package/package.json
CHANGED