aboutsummaryrefslogtreecommitdiff
path: root/modules/core/module-aiassist.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-09-29 13:49:18 +0200
committerAgando <roduccomm@gmail.com>2026-09-29 13:49:18 +0200
commit014573d72dee7088408475fedb3ffc9381e719e0 (patch)
tree1f6702afa57cecfd92d6799b81b02f811059155c /modules/core/module-aiassist.js
parentdd50ae715f3a648aeb42fb524fe1b106a0c084c7 (diff)
fix: parse per-call captured output for unknown-cmd error (race-free under Promise.all)
Diffstat (limited to 'modules/core/module-aiassist.js')
-rw-r--r--modules/core/module-aiassist.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/core/module-aiassist.js b/modules/core/module-aiassist.js
index 85aae46..145e248 100644
--- a/modules/core/module-aiassist.js
+++ b/modules/core/module-aiassist.js
@@ -2267,10 +2267,10 @@ buildSystemPrompt() {
// unknown commands return an error instead of routing back to AI
this.terminal.security._aiToolDepth++;
try { await this.terminal.security.checkAndRun(cmd); } finally { this.terminal.security._aiToolDepth--; this.terminal.print = originalPrint; }
- const unknownCmd = this.terminal.security._lastUnknownCmd;
- if (unknownCmd) {
- const sug = this.terminal.security.suggest(unknownCmd);
- return JSON.stringify({ error: `Command not found: ${unknownCmd}`, suggestion: sug ? sug.cmd : null });
+ // Parse per-call captured output (race-free) — not shared security state
+ const nfMatch = output.match(/Command not found: (\S+?)(?:\. Did you mean: (\S+)\?)?/);
+ if (nfMatch) {
+ return JSON.stringify({ error: `Command not found: ${nfMatch[1]}`, suggestion: nfMatch[2] || null });
}
// 📸 Diff and append shadow report
const shadowDiff = this._diffShadowVFS();