From 54c441af6f564d3e4b4e329fc0fee96a0de1840d Mon Sep 17 00:00:00 2001 From: xray Date: Thu, 9 Jul 2026 10:59:21 +0200 Subject: [PATCH] feat: Shell-Kommando-Erkennung im CLI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- cli/crowdcode.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cli/crowdcode.js b/cli/crowdcode.js index 9550a17..d1a5335 100644 --- a/cli/crowdcode.js +++ b/cli/crowdcode.js @@ -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 });