gm-copilot-cli 2.0.172 → 2.0.174
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 +38 -25
- package/index.html +1 -1
- package/manifest.yml +1 -1
- package/package.json +1 -1
- package/tools.json +1 -1
package/copilot-profile.md
CHANGED
|
@@ -78,11 +78,29 @@ 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', browser: 'agent-browser', ab: 'agent-browser' };
|
|
81
|
+
const langAliases = { js: 'nodejs', javascript: 'nodejs', ts: 'typescript', node: 'nodejs', py: 'python', sh: 'bash', shell: 'bash', zsh: 'bash', powershell: 'bash', ps1: 'bash', cmd: '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
|
-
const
|
|
85
|
-
|
|
84
|
+
const IS_WIN = process.platform === 'win32';
|
|
85
|
+
const gmExecLangs = new Set(['go', 'rust', 'c', 'cpp', 'java']);
|
|
86
|
+
const langExts = { nodejs: 'mjs', typescript: 'ts', deno: 'ts', python: 'py', bash: IS_WIN ? 'ps1' : 'sh', go: 'go', rust: 'rs', c: 'c', cpp: 'cpp', java: 'java' };
|
|
87
|
+
const spawnDirect = (bin, args, input) => {
|
|
88
|
+
const opts = { encoding: 'utf-8', timeout: 60000 };
|
|
89
|
+
if (cwd) opts.cwd = cwd;
|
|
90
|
+
if (input !== undefined) opts.input = input;
|
|
91
|
+
const r = spawnSync(bin, args, opts);
|
|
92
|
+
if (!r.stdout && !r.stderr && r.error) return `[spawn error: ${r.error.message}]`;
|
|
93
|
+
const stdout = (r.stdout || '').trimEnd();
|
|
94
|
+
const stderr = stripFooter(r.stderr || '').trimEnd();
|
|
95
|
+
if (stdout && stderr) return stdout + '\n[stderr]\n' + stderr;
|
|
96
|
+
return stripFooter(stdout || stderr);
|
|
97
|
+
};
|
|
98
|
+
const runWithFile = (lang, code) => {
|
|
99
|
+
const ext = langExts[lang] || lang;
|
|
100
|
+
const tmpFile = path.join(os.tmpdir(), `gm-exec-${Date.now()}.${ext}`);
|
|
101
|
+
fs.writeFileSync(tmpFile, code, 'utf-8');
|
|
102
|
+
const r = spawnSync('bun', ['x', 'gm-exec', 'exec', `--lang=${lang}`, `--file=${tmpFile}`, ...(cwd ? [`--cwd=${cwd}`] : [])], { encoding: 'utf-8', timeout: 65000 });
|
|
103
|
+
try { fs.unlinkSync(tmpFile); } catch (e) {}
|
|
86
104
|
let out = stripFooter((r.stdout || '') + (r.stderr || ''));
|
|
87
105
|
const bgMatch = out.match(/Command running in background with ID:\s*(\S+)/);
|
|
88
106
|
if (bgMatch) {
|
|
@@ -94,43 +112,38 @@ const run = () => {
|
|
|
94
112
|
}
|
|
95
113
|
return out;
|
|
96
114
|
};
|
|
97
|
-
const spawnDirect = (bin, args, input) => {
|
|
98
|
-
const opts = { encoding: 'utf-8', timeout: 30000 };
|
|
99
|
-
if (cwd) opts.cwd = cwd;
|
|
100
|
-
if (input !== undefined) opts.input = input;
|
|
101
|
-
const r = spawnSync(bin, args, opts);
|
|
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);
|
|
107
|
-
};
|
|
108
115
|
try {
|
|
109
116
|
let result;
|
|
110
|
-
if (lang === 'bash'
|
|
111
|
-
const
|
|
117
|
+
if (lang === 'bash') {
|
|
118
|
+
const ext = IS_WIN ? 'ps1' : 'sh';
|
|
119
|
+
const shFile = path.join(os.tmpdir(), `gm-exec-${Date.now()}.${ext}`);
|
|
112
120
|
fs.writeFileSync(shFile, code, 'utf-8');
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
result
|
|
121
|
+
if (IS_WIN) {
|
|
122
|
+
result = spawnDirect('powershell', ['-NoProfile', '-NonInteractive', '-File', shFile]);
|
|
123
|
+
try { fs.unlinkSync(shFile); } catch (e) {}
|
|
124
|
+
if (!result || result.startsWith('[spawn error:')) result = runWithFile('bash', code);
|
|
125
|
+
} else {
|
|
126
|
+
result = spawnDirect('bash', [shFile]);
|
|
127
|
+
try { fs.unlinkSync(shFile); } catch (e) {}
|
|
128
|
+
if (!result || result.startsWith('[spawn error:')) result = runWithFile('bash', code);
|
|
117
129
|
}
|
|
118
|
-
} else if (lang === 'python'
|
|
130
|
+
} else if (lang === 'python') {
|
|
119
131
|
result = spawnDirect('python3', ['-c', code]);
|
|
120
132
|
if (!result || result.startsWith('[spawn error:')) result = spawnDirect('python', ['-c', code]);
|
|
121
133
|
} else if (!lang || lang === 'nodejs' || lang === 'typescript' || lang === 'deno') {
|
|
122
|
-
const
|
|
123
|
-
const ext = extMap[lang] || 'mjs';
|
|
134
|
+
const ext = lang === 'typescript' || lang === 'deno' ? 'ts' : 'mjs';
|
|
124
135
|
const tmpFile = path.join(os.tmpdir(), `gm-exec-${Date.now()}.${ext}`);
|
|
125
|
-
const wrapped = `const __result = await (async () => {\n${code}\n})();\nif (__result !== undefined) {
|
|
136
|
+
const wrapped = `const __result = await (async () => {\n${code}\n})();\nif (__result !== undefined) { if (typeof __result === 'object') { console.log(JSON.stringify(__result, null, 2)); } else { console.log(__result); } }`;
|
|
126
137
|
fs.writeFileSync(tmpFile, wrapped, 'utf-8');
|
|
127
138
|
result = spawnDirect('bun', ['run', tmpFile]);
|
|
128
139
|
try { fs.unlinkSync(tmpFile); } catch (e) {}
|
|
129
140
|
if (result) result = result.split(tmpFile).join('<script>');
|
|
130
141
|
} else if (lang === 'agent-browser') {
|
|
131
142
|
result = spawnDirect('agent-browser', ['eval', '--stdin'], code);
|
|
143
|
+
} else if (gmExecLangs.has(lang)) {
|
|
144
|
+
result = runWithFile(lang, code);
|
|
132
145
|
} else {
|
|
133
|
-
result =
|
|
146
|
+
result = runWithFile(lang, code);
|
|
134
147
|
}
|
|
135
148
|
return { block: true, reason: `exec ran successfully. Output:\n\n${result || '(no output)'}` };
|
|
136
149
|
} catch (e) {
|
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.174";
|
|
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