diff options
Diffstat (limited to 'modules/core/terminal.js')
| -rw-r--r-- | modules/core/terminal.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/modules/core/terminal.js b/modules/core/terminal.js index ad4b105..10608d1 100644 --- a/modules/core/terminal.js +++ b/modules/core/terminal.js @@ -176,7 +176,33 @@ const unknown = !known; return { cmd, args, known, destructive, system, unknown, hasSuspicious }; } + // v4.6.58: this terminal has no shell. `;` at least failed loudly, but `&&`/`||` + // folded the right-hand side into the left command's argv, and a `|` arriving from + // the AI run_command tool (which bypasses splitPipe) degraded to an empty pattern + // matching every line. Both are silent wrong answers — refuse instead (packet §1). + detectComposition(input) { + const s = String(input || ''); + let inSingle = false, inDouble = false; + for (let i = 0; i < s.length; i++) { + const ch = s[i]; + if (ch === '"' && !inSingle) { inDouble = !inDouble; continue; } + if (ch === "'" && !inDouble) { inSingle = !inSingle; continue; } + if (inSingle || inDouble) continue; + if (ch === '&' && s[i + 1] === '&') return '&&'; + if (ch === '|' && s[i + 1] === '|') return '||'; + if (ch === '|') return '|'; + if (ch === ';') return ';'; + } + return null; + } async checkAndRun(rawInput) { + const badOp = this.detectComposition(rawInput); + if (badOp) { + this.terminal.print('⚠️ No shell here — `' + badOp + '` is not interpreted. ' + + 'Run one command per line (the interactive terminal supports `cmd | cmd`; ' + + 'AI run_command does not).', 'error'); + return; + } const { cmd, args, known, destructive, system, unknown, hasSuspicious } = this._classify(rawInput); // Level 3 Audit: just log and allow if (this.level === 3) { |