Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions crates/goose-mcp/src/developer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,29 +660,35 @@ impl DeveloperRouter {
file_text: &str,
) -> Result<Vec<Content>, ToolError> {
// Normalize line endings based on platform
let normalized_text = normalize_line_endings(file_text);
let mut normalized_text = normalize_line_endings(file_text); // Make mutable

// Ensure the text ends with a newline
if !normalized_text.ends_with('\n') {
normalized_text.push('\n');
}

// Write to the file
std::fs::write(path, normalized_text)
std::fs::write(path, &normalized_text) // Write the potentially modified text
.map_err(|e| ToolError::ExecutionError(format!("Failed to write file: {}", e)))?;

// Try to detect the language from the file extension
let language = lang::get_language_identifier(path);

// The assistant output does not show the file again because the content is already in the tool request
// but we do show it to the user here
// but we do show it to the user here, using the final written content
Ok(vec![
Content::text(format!("Successfully wrote to {}", path.display()))
.with_audience(vec![Role::Assistant]),
Content::text(formatdoc! {r#"
Content::text(formatdoc! {
r#"
### {path}
```{language}
{content}
```
"#,
path=path.display(),
language=language,
content=file_text,
content=&normalized_text // Use the final normalized_text for user feedback
})
.with_audience(vec![Role::User])
.with_priority(0.2),
Expand Down
Loading