feat: Implement a user-approved shell command execution tool and a Windows installer script.
This commit is contained in:
@@ -11,7 +11,11 @@ internal static class CommandTool
|
||||
{
|
||||
public static Action<string> Log { get; set; } = Console.WriteLine;
|
||||
|
||||
[Description("Execute a shell command after user approval. Prompts with [Y/n] before running. Note: For file editing and operations, use the built-in file tools (ReadFile, ReplaceLines, InsertAfter, DeleteRange, CreateFile, etc.) instead of shell commands.")]
|
||||
#if WINDOWS
|
||||
[Description("Execute a PowerShell command after user approval. Prompts with [Y/n] before running. Note: For file editing and operations, use the built-in file tools (ReadFile, ReplaceLines, InsertAfter, DeleteRange, CreateFile, etc.) instead of shell commands.")]
|
||||
#else
|
||||
[Description("Execute a Bash shell command after user approval. Prompts with [Y/n] before running. Note: For file editing and operations, use the built-in file tools (ReadFile, ReplaceLines, InsertAfter, DeleteRange, CreateFile, etc.) instead of shell commands.")]
|
||||
#endif
|
||||
public static string ExecuteCommand(
|
||||
[Description("The shell command to execute.")] string command)
|
||||
{
|
||||
@@ -41,8 +45,13 @@ internal static class CommandTool
|
||||
{
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
#if WINDOWS
|
||||
FileName = "powershell.exe",
|
||||
Arguments = $"-NoProfile -Command \"{command}\"",
|
||||
#else
|
||||
FileName = "/bin/bash",
|
||||
Arguments = $"-c \"{command}\"",
|
||||
#endif
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
|
||||
Reference in New Issue
Block a user