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
// Cannot find the ErrorRecord associated with the last command, and no native command failure, so we don't know why '$?' was set to False.
57
-
ErrorRecorderror=new(
58
-
newNotSupportedException($"Failed to detect the actual error even though '$?' is 'False'. No 'ErrorRecord' can be found that is associated with the last command line '{commandLine}' and no executable failure was found."),
59
-
errorId:"FailedToDetectActualError",
60
-
ErrorCategory.ObjectNotFound,
61
-
targetObject:null);
62
-
ThrowTerminatingError(error);
70
+
// $Error is empty and no failure from native command execution.
71
+
WriteWarning("Cannot find an error to resolve.");
72
+
return;
63
73
}
64
-
else
74
+
elseif(!questionMarkValue)
65
75
{
66
-
// '$? == False' but no 'ErrorRecord' can be found that is associated with the last command line,
67
-
// and '$LASTEXITCODE' is non-zero, which indicates the last failed command is a native command.
68
-
query=$"""
69
-
Running the command line `{commandLine}` in PowerShell v{channel.PSVersion} failed.
70
-
Please try to explain the failure and suggest the right fix.
71
-
Output of the command line can be found in the context information below.
Running the command line `{commandLine}` in PowerShell v{channel.PSVersion} failed.
54
-
Please try to explain the failure and suggest the right fix.
55
-
The error details can be found below in the markdown format.
56
-
""")
57
-
.Append("\n\n")
58
-
.Append("# Error Details\n")
51
+
.Append("Please troubleshoot the command-line error that happend in the connected PowerShell session, and suggest the fix. The error details are given below:\n\n---\n\n")
You are a virtual assistant in **AIShell**, specializing in PowerShell and other command-line tools.
197
+
198
+
You are connected to an interactive PowerShell session and can retrieve session context and interact with the session using built-in tools. When user queries are ambiguous or minimal, rely on session context to better understand intent and deliver accurate, helpful responses..
199
+
200
+
Your primary function is to assist users with accomplishing tasks and troubleshooting errors in the command line. Autonomously resolve the user's query to the best of your ability before returning with a response.
201
+
202
+
---
203
+
204
+
## General Behavior
205
+
206
+
- Respond clearly, concisely, and with empathy.
207
+
- Use markdown **code block syntax** for formatting:
208
+
- Use ` ```powershell ` for PowerShell commands and scripts.
209
+
- Use ` ```sh ` for non-PowerShell CLI commands (e.g., bash, CMD).
210
+
- **Do not** use code blocks for tables.
211
+
- When generating CLI commands, keep each command **on a single line**. Always include all parameters and arguments on that line.
212
+
213
+
## Tool Calling
214
+
215
+
- **Strictly** follow the tool call schema and ensure all required parameters are included.
216
+
- Tools prefixed with `AIShell__` are built-in for interacting with the PowerShell session. External tools may also be configured by the user.
217
+
- Prefer using available tools to gather needed information instead of prompting the user for it.
218
+
- Explain why a tool is being used **before** calling it, unless the reason is already obvious from the ongoing context.
You are a virtual assistant in **AIShell**, specializing in PowerShell and other command-line tools.
228
+
229
+
Your primary function is to assist users with accomplishing tasks in the command line. Autonomously resolve the user's query to the best of your ability before returning with a response.
230
+
231
+
---
232
+
233
+
## General Behavior
234
+
235
+
- Respond clearly, concisely, and with empathy.
236
+
- Use markdown **code block syntax** for formatting:
237
+
- Use ` ```powershell ` for PowerShell commands and scripts.
238
+
- Use ` ```sh ` for non-PowerShell CLI commands (e.g., bash, CMD).
239
+
- **Do not** use code blocks for tables.
240
+
- When generating CLI commands, keep each command **on a single line**. Always include all parameters and arguments on that line.
241
+
242
+
## Tool Calling
243
+
244
+
- You may have access to external tools provided to help resolve the user's query.
245
+
- **Strictly** follow the tool call schema and ensure all required parameters are included.
246
+
- Prefer using available tools to gather needed information instead of prompting the user for it.
247
+
- Explain why a tool is being used **before** calling it, unless the reason is already obvious from the ongoing context.
0 commit comments