You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,6 +88,7 @@ aish c "docker ps" --model gpt-4o # Use specific model
88
88
89
89
**Options:**
90
90
-`-t, --timeout <seconds>` - Command timeout (no timeout by default)
91
+
-`--tty` - Force interactive/TTY mode for the command
91
92
-`-v, --verbose` - Show detailed explanations and context
92
93
-`--provider <provider>` - Override default AI provider
93
94
-`--model <model>` - Override provider's preferred model
@@ -98,6 +99,8 @@ aish c "docker ps" --model gpt-4o # Use specific model
98
99
3. Asks for confirmation before execution
99
100
4. Executes with real-time output
100
101
102
+
**Smart TTY Detection:** The AI automatically detects when commands need interactive terminal access (like `vim`, `nano`, `htop`) and enables TTY mode. Use `--tty` to force TTY mode for any command.
.describe("Alternative command to try - should almost always be provided unless truly impossible"),
53
+
needsInteractiveMode: z
54
+
.boolean()
55
+
.describe("Whether the alternative command needs TTY/interactive mode - only true if the failure was clearly due to missing TTY and the alternative requires it"),
console.log(chalk.gray(`Refining based on: "${userAction.input}"`));
282
294
context.query=userAction.input;
@@ -302,7 +314,7 @@ class CommandExecutor {
302
314
conversationHistory: CoreMessage[]
303
315
): Promise<CommandAnalysis>{
304
316
constsystemPrompt="You are a shell command expert. You MUST respond with valid JSON only, no other text or formatting.";
305
-
317
+
306
318
constuserContent=conversationHistory.length>0
307
319
? `Based on our conversation, analyze this request and generate an appropriate shell command: "${query}"
308
320
@@ -312,12 +324,14 @@ Return a JSON object with these exact fields:
312
324
"explanation": "brief explanation of what the command does",
313
325
"isDangerous": false,
314
326
"requiresExternalPackages": false,
315
-
"externalPackages": []
327
+
"externalPackages": [],
328
+
"needsInteractiveMode": false
316
329
}
317
330
318
331
Set isDangerous to true ONLY for commands that could cause irreversible system damage or data loss (like rm -rf /, format, dd, etc.).
319
332
Common development operations like removing lock files, node_modules, build artifacts, or temporary files are NOT dangerous.
320
333
Set requiresExternalPackages to true and list packages if external tools are needed.
334
+
Set needsInteractiveMode to true if the user's intent is clearly to open/run an interactive program (like "open vim", "start nano", "run python interactively", "launch htop", etc.) or if the program they're trying to run is interactive in your knowledge. If unsure, assume false.
321
335
322
336
For file searches, prefer searching in user directories (~) rather than system-wide (/) to avoid permission issues and long execution times.
323
337
@@ -330,11 +344,13 @@ Return a JSON object with these exact fields:
330
344
"explanation": "brief explanation of what the command does",
331
345
"isDangerous": false,
332
346
"requiresExternalPackages": false,
333
-
"externalPackages": []
347
+
"externalPackages": [],
348
+
"needsInteractiveMode": false
334
349
}
335
350
336
351
Set isDangerous to true ONLY for commands that could cause irreversible system damage or data loss.
337
352
Common development operations are NOT dangerous.
353
+
Set needsInteractiveMode to true if the user's intent is clearly to open/run an interactive program (like "open vim", "start nano", "run python interactively", "launch htop", etc.).
338
354
339
355
For file searches, prefer searching in user directories (~) rather than system-wide (/).
340
356
@@ -387,7 +403,8 @@ Return a JSON object with these exact fields:
387
403
{
388
404
"explanation": "brief explanation of why the command failed (1-2 sentences max)",
389
405
"solution": "how to fix the issue or what the user should do (1-2 sentences max)",
390
-
"alternativeCommand": "alternative command to try (or null ONLY if absolutely no alternative exists)"
406
+
"alternativeCommand": "alternative command to try (or null ONLY if absolutely no alternative exists)",
407
+
"needsInteractiveMode": false
391
408
}
392
409
393
410
IMPORTANT: You should ALMOST ALWAYS provide an alternativeCommand that attempts to fulfill the user's original request. Look at the error message and suggest a command that will work. For example:
@@ -401,6 +418,13 @@ Only return null for alternativeCommand in cases where:
401
418
- The request is physically impossible (e.g., accessing hardware that doesn't exist)
402
419
- The command requires user-specific information you don't have
403
420
421
+
IMPORTANT: Set needsInteractiveMode to true ONLY if ALL of these conditions are met:
422
+
1. The failure was clearly caused by missing TTY/terminal (errors like "not a terminal", "no tty", input/output redirection issues)
423
+
2. The alternative command you're suggesting is an interactive program (vim, nano, htop, etc.)
424
+
3. Double-check: Does this alternative command actually need TTY to function properly?
425
+
426
+
If you're unsure about ANY of these conditions, set needsInteractiveMode to false. Be extremely conservative.
427
+
404
428
Be very concise and helpful. Keep explanations short. JSON only:`;
405
429
406
430
constmessages: CoreMessage[]=[
@@ -441,6 +465,7 @@ Briefly explain why it failed and how to fix it (1-2 sentences max).`,
441
465
explanation: plainText,
442
466
solution: "See explanation above",
443
467
alternativeCommand: null,
468
+
needsInteractiveMode: false,
444
469
};
445
470
}
446
471
@@ -451,16 +476,19 @@ Briefly explain why it failed and how to fix it (1-2 sentences max).`,
0 commit comments