feat: Shell-Kommando-Erkennung im CLI
pwd, ls, git, curl, pip etc. werden direkt lokal ausgeführt, nicht ans LLM geschickt. Erkennung wie in VSCode-Extension (shellFirstWords-Liste, kein ?/. am Ende = nat. Sprache).
This commit is contained in:
parent
b9dadb479a
commit
54c441af6f
1 changed files with 28 additions and 0 deletions
|
|
@ -519,6 +519,34 @@ async function main() {
|
|||
}
|
||||
if (!trimmed) continue;
|
||||
|
||||
// ─── Shell-Kommando-Erkennung (direkt ausführen, nicht ans LLM) ─────
|
||||
const SHELL_COMMANDS = [
|
||||
'pwd', 'ls', 'll', 'cd', 'git', 'npm', 'npx', 'node', 'python', 'python3',
|
||||
'pip', 'curl', 'wget', 'docker', 'docker-compose', 'ps', 'top', 'htop',
|
||||
'df', 'du', 'whoami', 'env', 'which', 'whereis', 'ssh', 'scp', 'make',
|
||||
'cargo', 'go', 'rustc', 'date', 'uptime', 'uname', 'hostname', 'id', 'free',
|
||||
'netstat', 'ss', 'ip', 'ping', 'traceroute', 'nslookup', 'dig', 'tree',
|
||||
'wc', 'sort', 'uniq', 'cut', 'awk', 'sed', 'tr', 'diff', 'cmp', 'stat',
|
||||
'file', 'type', 'printenv', 'history', 'screen', 'tmux', 'bash', 'sh',
|
||||
'zsh', 'source', '.',
|
||||
];
|
||||
const firstWord = trimmed.split(/\s+/)[0];
|
||||
const isShellCmd = SHELL_COMMANDS.includes(firstWord) && !/[?!.]$/.test(trimmed);
|
||||
if (isShellCmd) {
|
||||
const lines = trimmed.split('\n').filter(l => l.trim());
|
||||
process.stdout.write(`\n${C.dim}⚡ ${trimmed}${C.reset}\n`);
|
||||
for (const cmd of lines) {
|
||||
try {
|
||||
const out = execSync(cmd.trim(), { cwd: WORKSPACE, timeout: 10000, encoding: 'utf8', maxBuffer: 1024 * 512 });
|
||||
console.log(`${C.grey}${out || '(keine Ausgabe)'}${C.reset}`);
|
||||
} catch (e) {
|
||||
console.log(`${C.red}${e.stderr || e.message}${C.reset}`);
|
||||
}
|
||||
}
|
||||
console.log('');
|
||||
continue;
|
||||
}
|
||||
|
||||
// @mentions auflösen
|
||||
const enhanced = await resolveMentions(trimmed);
|
||||
history.push({ role: 'user', content: enhanced });
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue