mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 22:54:24 +01:00
fix developer mcp for windows (#1966)
This commit is contained in:
@@ -22,6 +22,7 @@ use mcp_core::{
|
|||||||
protocol::ServerCapabilities,
|
protocol::ServerCapabilities,
|
||||||
resource::Resource,
|
resource::Resource,
|
||||||
tool::Tool,
|
tool::Tool,
|
||||||
|
Content,
|
||||||
};
|
};
|
||||||
use mcp_core::{
|
use mcp_core::{
|
||||||
prompt::{Prompt, PromptArgument, PromptTemplate},
|
prompt::{Prompt, PromptArgument, PromptTemplate},
|
||||||
@@ -30,7 +31,6 @@ use mcp_core::{
|
|||||||
use mcp_server::router::CapabilitiesBuilder;
|
use mcp_server::router::CapabilitiesBuilder;
|
||||||
use mcp_server::Router;
|
use mcp_server::Router;
|
||||||
|
|
||||||
use mcp_core::content::Content;
|
|
||||||
use mcp_core::role::Role;
|
use mcp_core::role::Role;
|
||||||
|
|
||||||
use self::shell::{
|
use self::shell::{
|
||||||
@@ -507,7 +507,8 @@ impl DeveloperRouter {
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| ToolError::ExecutionError(e.to_string()))?;
|
.map_err(|e| ToolError::ExecutionError(e.to_string()))?;
|
||||||
|
|
||||||
let output_str = String::from_utf8_lossy(&output.stdout);
|
let stdout_str = String::from_utf8_lossy(&output.stdout);
|
||||||
|
let output_str = stdout_str;
|
||||||
|
|
||||||
// Check the character count of the output
|
// Check the character count of the output
|
||||||
const MAX_CHAR_COUNT: usize = 400_000; // 409600 chars = 400KB
|
const MAX_CHAR_COUNT: usize = 400_000; // 409600 chars = 400KB
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ pub struct ShellConfig {
|
|||||||
impl Default for ShellConfig {
|
impl Default for ShellConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
// Use cmd.exe for simpler command execution
|
// Execute PowerShell commands directly
|
||||||
Self {
|
Self {
|
||||||
executable: "cmd.exe".to_string(),
|
executable: "powershell.exe".to_string(),
|
||||||
arg: "/C".to_string(),
|
arg: "-NoProfile -NonInteractive -Command".to_string(),
|
||||||
redirect_syntax: "2>&1".to_string(), // cmd.exe also supports this syntax
|
redirect_syntax: "2>&1".to_string(),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Self {
|
Self {
|
||||||
@@ -32,8 +32,13 @@ pub fn get_shell_config() -> ShellConfig {
|
|||||||
|
|
||||||
pub fn format_command_for_platform(command: &str) -> String {
|
pub fn format_command_for_platform(command: &str) -> String {
|
||||||
let config = get_shell_config();
|
let config = get_shell_config();
|
||||||
// For all shells, no braces needed
|
if cfg!(windows) {
|
||||||
format!("{} {}", command, config.redirect_syntax)
|
// For PowerShell, wrap the command in braces to handle special characters
|
||||||
|
format!("{{ {} }} {}", command, config.redirect_syntax)
|
||||||
|
} else {
|
||||||
|
// For other shells, no braces needed
|
||||||
|
format!("{} {}", command, config.redirect_syntax)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expand_path(path_str: &str) -> String {
|
pub fn expand_path(path_str: &str) -> String {
|
||||||
|
|||||||
Reference in New Issue
Block a user