gm-kilo 2.0.170 → 2.0.172
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/hooks/pre-tool-use-hook.js +10 -2
- package/package.json +1 -1
|
@@ -78,7 +78,7 @@ const run = () => {
|
|
|
78
78
|
if (/^\s*(echo |ls |cd |mkdir |rm |cat |grep |find |export |source |#!)/.test(src)) return 'bash';
|
|
79
79
|
return 'nodejs';
|
|
80
80
|
};
|
|
81
|
-
const langAliases = { js: 'nodejs', javascript: 'nodejs', ts: 'typescript', node: 'nodejs', py: 'python', sh: 'bash', shell: 'bash', zsh: 'bash' };
|
|
81
|
+
const langAliases = { js: 'nodejs', javascript: 'nodejs', ts: 'typescript', node: 'nodejs', py: 'python', sh: 'bash', shell: 'bash', zsh: 'bash', browser: 'agent-browser', ab: 'agent-browser' };
|
|
82
82
|
const lang = langAliases[rawLang] || rawLang || detectLang(code);
|
|
83
83
|
const stripFooter = (s) => s.replace(/\n\[Running tools\][\s\S]*$/, '').trimEnd();
|
|
84
84
|
const runExec = (args) => {
|
|
@@ -108,7 +108,13 @@ const run = () => {
|
|
|
108
108
|
try {
|
|
109
109
|
let result;
|
|
110
110
|
if (lang === 'bash' || lang === 'cmd') {
|
|
111
|
-
|
|
111
|
+
const shFile = path.join(os.tmpdir(), `gm-exec-${Date.now()}.ps1`);
|
|
112
|
+
fs.writeFileSync(shFile, code, 'utf-8');
|
|
113
|
+
result = spawnDirect('powershell', ['-NoProfile', '-NonInteractive', '-File', shFile]);
|
|
114
|
+
try { fs.unlinkSync(shFile); } catch (e) {}
|
|
115
|
+
if (!result || result.startsWith('[spawn error:')) {
|
|
116
|
+
result = runExec(['x', 'gm-exec', 'bash', ...(cwd ? [`--cwd=${cwd}`] : []), code]);
|
|
117
|
+
}
|
|
112
118
|
} else if (lang === 'python' || lang === 'py') {
|
|
113
119
|
result = spawnDirect('python3', ['-c', code]);
|
|
114
120
|
if (!result || result.startsWith('[spawn error:')) result = spawnDirect('python', ['-c', code]);
|
|
@@ -121,6 +127,8 @@ const run = () => {
|
|
|
121
127
|
result = spawnDirect('bun', ['run', tmpFile]);
|
|
122
128
|
try { fs.unlinkSync(tmpFile); } catch (e) {}
|
|
123
129
|
if (result) result = result.split(tmpFile).join('<script>');
|
|
130
|
+
} else if (lang === 'agent-browser') {
|
|
131
|
+
result = spawnDirect('agent-browser', ['eval', '--stdin'], code);
|
|
124
132
|
} else {
|
|
125
133
|
result = runExec(['x', 'gm-exec', 'exec', `--lang=${lang}`, ...(cwd ? [`--cwd=${cwd}`] : []), code]);
|
|
126
134
|
}
|