feat: shell command explanation option (#173)
# Shell Command Explanation Option ## Description This PR adds an option to explain shell commands when the user is prompted to approve them (Fixes #110). When reviewing a shell command, users can now select "Explain this command" to get a detailed explanation of what the command does before deciding whether to approve or reject it. ## Changes - Added a new "EXPLAIN" option to the `ReviewDecision` enum - Updated the command review UI to include an "Explain this command (x)" option - Implemented the logic to send the command to the LLM for explanation using the same model as the agent - Added a display for the explanation in the command review UI - Updated all relevant components to pass the explanation through the component tree ## Benefits - Improves user understanding of shell commands before approving them - Reduces the risk of approving potentially harmful commands - Enhances the educational aspect of the tool, helping users learn about shell commands - Maintains the same workflow with minimal UI changes ## Testing - Manually tested the explanation feature with various shell commands - Verified that the explanation is displayed correctly in the UI - Confirmed that the user can still approve or reject the command after viewing the explanation ## Screenshots  ## Additional Notes The explanation is generated using the same model as the agent, ensuring consistency in the quality and style of explanations. --------- Signed-off-by: crazywolf132 <crazywolf132@gmail.com>
This commit is contained in:
@@ -32,6 +32,7 @@ export type CommandConfirmation = {
|
||||
review: ReviewDecision;
|
||||
applyPatch?: ApplyPatchCommand | undefined;
|
||||
customDenyMessage?: string;
|
||||
explanation?: string;
|
||||
};
|
||||
|
||||
const alreadyProcessedResponses = new Set();
|
||||
|
||||
@@ -309,7 +309,13 @@ async function askUserPermission(
|
||||
alwaysApprovedCommands.add(key);
|
||||
}
|
||||
|
||||
// Any decision other than an affirmative (YES / ALWAYS) aborts execution.
|
||||
// Handle EXPLAIN decision by returning null to continue with the normal flow
|
||||
// but with a flag to indicate that an explanation was requested
|
||||
if (decision === ReviewDecision.EXPLAIN) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Any decision other than an affirmative (YES / ALWAYS) or EXPLAIN aborts execution.
|
||||
if (decision !== ReviewDecision.YES && decision !== ReviewDecision.ALWAYS) {
|
||||
const note =
|
||||
decision === ReviewDecision.NO_CONTINUE
|
||||
|
||||
@@ -7,4 +7,8 @@ export enum ReviewDecision {
|
||||
* future identical instances for the remainder of the session.
|
||||
*/
|
||||
ALWAYS = "always",
|
||||
/**
|
||||
* User wants an explanation of what the command does before deciding.
|
||||
*/
|
||||
EXPLAIN = "explain",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user