gm-cc 2.0.169 → 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/.claude-plugin/marketplace.json +1 -1
- package/hooks/pre-tool-use-hook.js +27 -13
- package/package.json +1 -1
- package/plugin.json +1 -1
|
@@ -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.
|
|
7
|
+
"version": "2.0.172",
|
|
8
8
|
"metadata": {
|
|
9
9
|
"description": "State machine agent with hooks, skills, and automated git enforcement"
|
|
10
10
|
},
|
|
@@ -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) => {
|
|
@@ -99,15 +99,22 @@ const run = () => {
|
|
|
99
99
|
if (cwd) opts.cwd = cwd;
|
|
100
100
|
if (input !== undefined) opts.input = input;
|
|
101
101
|
const r = spawnSync(bin, args, opts);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return
|
|
102
|
+
if (!r.stdout && !r.stderr && r.error) return `[spawn error: ${r.error.message}]`;
|
|
103
|
+
const stdout = (r.stdout || '').trimEnd();
|
|
104
|
+
const stderr = stripFooter(r.stderr || '').trimEnd();
|
|
105
|
+
if (stdout && stderr) return stdout + '\n[stderr]\n' + stderr;
|
|
106
|
+
return stripFooter(stdout || stderr);
|
|
106
107
|
};
|
|
107
108
|
try {
|
|
108
109
|
let result;
|
|
109
110
|
if (lang === 'bash' || lang === 'cmd') {
|
|
110
|
-
|
|
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
|
+
}
|
|
111
118
|
} else if (lang === 'python' || lang === 'py') {
|
|
112
119
|
result = spawnDirect('python3', ['-c', code]);
|
|
113
120
|
if (!result || result.startsWith('[spawn error:')) result = spawnDirect('python', ['-c', code]);
|
|
@@ -120,12 +127,14 @@ const run = () => {
|
|
|
120
127
|
result = spawnDirect('bun', ['run', tmpFile]);
|
|
121
128
|
try { fs.unlinkSync(tmpFile); } catch (e) {}
|
|
122
129
|
if (result) result = result.split(tmpFile).join('<script>');
|
|
130
|
+
} else if (lang === 'agent-browser') {
|
|
131
|
+
result = spawnDirect('agent-browser', ['eval', '--stdin'], code);
|
|
123
132
|
} else {
|
|
124
133
|
result = runExec(['x', 'gm-exec', 'exec', `--lang=${lang}`, ...(cwd ? [`--cwd=${cwd}`] : []), code]);
|
|
125
134
|
}
|
|
126
|
-
return { block: true, reason: `
|
|
135
|
+
return { block: true, reason: `exec ran successfully. Output:\n\n${result || '(no output)'}` };
|
|
127
136
|
} catch (e) {
|
|
128
|
-
return { block: true, reason: (e.stdout || '') + (e.stderr || '') || e.message || '(exec failed)' };
|
|
137
|
+
return { block: true, reason: `exec ran. Error:\n\n${(e.stdout || '') + (e.stderr || '') || e.message || '(exec failed)'}` };
|
|
129
138
|
}
|
|
130
139
|
}
|
|
131
140
|
|
|
@@ -140,13 +149,18 @@ const run = () => {
|
|
|
140
149
|
const input = tool_input || {};
|
|
141
150
|
const script = input.script || input.code || '';
|
|
142
151
|
if (script && !input.url && !input.navigate) {
|
|
143
|
-
const
|
|
152
|
+
const sFooter = (s) => s.replace(/\n\[Running tools\][\s\S]*$/, '').trimEnd();
|
|
144
153
|
try {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
const tmpFile = path.join(os.tmpdir(), `gm-exec-${Date.now()}.mjs`);
|
|
155
|
+
fs.writeFileSync(tmpFile, script, 'utf-8');
|
|
156
|
+
const r = spawnSync('bun', ['run', tmpFile], { encoding: 'utf-8', timeout: 65000 });
|
|
157
|
+
try { fs.unlinkSync(tmpFile); } catch (e) {}
|
|
158
|
+
const stdout = (r.stdout || '').trimEnd();
|
|
159
|
+
const stderr = sFooter(r.stderr || '').trimEnd();
|
|
160
|
+
const out = stdout && stderr ? stdout + '\n[stderr]\n' + stderr : sFooter(stdout || stderr);
|
|
161
|
+
return { block: true, reason: `exec ran successfully. Output:\n\n${out || '(no output)'}` };
|
|
148
162
|
} catch (e) {
|
|
149
|
-
return { block: true, reason: (e.stdout || '') + (e.stderr || '') || e.message || '(exec failed)' };
|
|
163
|
+
return { block: true, reason: `exec ran. Error:\n\n${(e.stdout || '') + (e.stderr || '') || e.message || '(exec failed)'}` };
|
|
150
164
|
}
|
|
151
165
|
}
|
|
152
166
|
}
|
package/package.json
CHANGED