-
-
Notifications
You must be signed in to change notification settings - Fork 596
Composer V2: Replace replaceInFile with editFile as the primary targeted-edit tool #2305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
1721fdc
6230201
f519781
b5190fe
5dfaf82
d601865
79217c6
71726fa
372fc54
fbd6b57
e928dde
64c66cc
d9bd7e4
7dacb39
5555369
c40d362
1ba9690
29282aa
9fd81ff
f49998e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,24 +2,24 @@ import { ToolManager } from "@/tools/toolManager"; | |
| import { ToolResultFormatter } from "@/tools/ToolResultFormatter"; | ||
|
|
||
| /** | ||
| * ActionBlockStreamer processes streaming chunks to detect and handle writeToFile blocks. | ||
| * ActionBlockStreamer processes streaming chunks to detect and handle writeFile blocks. | ||
| * | ||
| * 1. Accumulates chunks in a buffer | ||
| * 2. Detects complete writeToFile blocks | ||
| * 3. Calls the writeToFile tool when a complete block is found | ||
| * 2. Detects complete writeFile blocks | ||
| * 3. Calls the writeFile tool when a complete block is found | ||
| * 4. Returns chunks as-is otherwise | ||
| */ | ||
| export class ActionBlockStreamer { | ||
| private buffer = ""; | ||
|
|
||
| constructor( | ||
| private toolManager: typeof ToolManager, | ||
| private writeToFileTool: any | ||
| private writeFileTool: any | ||
| ) {} | ||
|
|
||
| private findCompleteBlock(str: string) { | ||
| // Regex for both formats | ||
| const regex = /<writeToFile>[\s\S]*?<\/writeToFile>/; | ||
| const regex = /<writeFile>[\s\S]*?<\/writeFile>/; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Keep matching legacy Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The block detector now matches only Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Restricting block detection to Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In the CopilotPlus streaming path, Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The updated parser now matches only Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The stream parser now matches only Useful? React with 👍 / 👎.
wenzhengjiang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const match = str.match(regex); | ||
|
|
||
| if (!match || match.index === undefined) { | ||
|
|
@@ -71,13 +71,13 @@ export class ActionBlockStreamer { | |
|
|
||
| // Call the tool | ||
| try { | ||
| const result = await this.toolManager.callTool(this.writeToFileTool, { | ||
| const result = await this.toolManager.callTool(this.writeFileTool, { | ||
| path: filePath, | ||
| content: fileContent, | ||
| }); | ||
|
|
||
| // Format tool result using ToolResultFormatter for consistency with agent mode | ||
| const formattedResult = ToolResultFormatter.format("writeToFile", result); | ||
| const formattedResult = ToolResultFormatter.format("writeFile", result); | ||
| yield { ...chunk, content: `\n${formattedResult}\n` }; | ||
| } catch (err: any) { | ||
| yield { ...chunk, content: `\nError: ${err?.message || err}\n` }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stream parser now only matches
<writeFile>...</writeFile>blocks, so any model output that still emits legacy<writeToFile>tags will be ignored and never executed. This is a practical compatibility break during upgrades/ongoing chats (and there are still prompt strings in the repo that mentionwriteToFile), so users can get raw XML in the response instead of an applied file change.Useful? React with 👍 / 👎.