@@ -161,7 +161,7 @@ export const ApplyPatchTool = Tool.define("apply_patch", {
161161 // Build per-file metadata for UI rendering (used for both permission and result)
162162 const files = fileChanges . map ( ( change ) => ( {
163163 filePath : change . filePath ,
164- relativePath : path . relative ( Instance . worktree , change . movePath ?? change . filePath ) ,
164+ relativePath : path . relative ( Instance . worktree , change . movePath ?? change . filePath ) . replaceAll ( "\\" , "/" ) ,
165165 type : change . type ,
166166 diff : change . diff ,
167167 before : change . oldContent ,
@@ -172,7 +172,7 @@ export const ApplyPatchTool = Tool.define("apply_patch", {
172172 } ) )
173173
174174 // Check permissions if needed
175- const relativePaths = fileChanges . map ( ( c ) => path . relative ( Instance . worktree , c . filePath ) )
175+ const relativePaths = fileChanges . map ( ( c ) => path . relative ( Instance . worktree , c . filePath ) . replaceAll ( "\\" , "/" ) )
176176 await ctx . ask ( {
177177 permission : "edit" ,
178178 patterns : relativePaths ,
@@ -242,13 +242,13 @@ export const ApplyPatchTool = Tool.define("apply_patch", {
242242 // Generate output summary
243243 const summaryLines = fileChanges . map ( ( change ) => {
244244 if ( change . type === "add" ) {
245- return `A ${ path . relative ( Instance . worktree , change . filePath ) } `
245+ return `A ${ path . relative ( Instance . worktree , change . filePath ) . replaceAll ( "\\" , "/" ) } `
246246 }
247247 if ( change . type === "delete" ) {
248- return `D ${ path . relative ( Instance . worktree , change . filePath ) } `
248+ return `D ${ path . relative ( Instance . worktree , change . filePath ) . replaceAll ( "\\" , "/" ) } `
249249 }
250250 const target = change . movePath ?? change . filePath
251- return `M ${ path . relative ( Instance . worktree , target ) } `
251+ return `M ${ path . relative ( Instance . worktree , target ) . replaceAll ( "\\" , "/" ) } `
252252 } )
253253 let output = `Success. Updated the following files:\n${ summaryLines . join ( "\n" ) } `
254254
@@ -264,7 +264,7 @@ export const ApplyPatchTool = Tool.define("apply_patch", {
264264 const limited = errors . slice ( 0 , MAX_DIAGNOSTICS_PER_FILE )
265265 const suffix =
266266 errors . length > MAX_DIAGNOSTICS_PER_FILE ? `\n... and ${ errors . length - MAX_DIAGNOSTICS_PER_FILE } more` : ""
267- output += `\n\nLSP errors detected in ${ path . relative ( Instance . worktree , target ) } , please fix:\n<diagnostics file="${ target } ">\n${ limited . map ( LSP . Diagnostic . pretty ) . join ( "\n" ) } ${ suffix } \n</diagnostics>`
267+ output += `\n\nLSP errors detected in ${ path . relative ( Instance . worktree , target ) . replaceAll ( "\\" , "/" ) } , please fix:\n<diagnostics file="${ target } ">\n${ limited . map ( LSP . Diagnostic . pretty ) . join ( "\n" ) } ${ suffix } \n</diagnostics>`
268268 }
269269 }
270270
0 commit comments