Roo-Code/src/core
Hannes Rudolph 951cefc0fc
Refactor: Improve file tool context formatting and diff error guidance (#2278)
* refactor: Change read_file result format to XML

Modifies how the result of the `read_file` tool is presented
in the conversation history sent to the AI model.

Previously, the format was:
[read_file for 'path/to/file'] Result:
{content_or_error}

This commit changes the format to use XML tags for better
structure and potentially easier parsing by the model:
<file>
  <path>path/to/file</path>
  <content>
{content_or_error}
  </content>
</file>

This change only affects the `read_file` tool result formatting
within the user context message constructed in `src/core/Cline.ts`.
Other tool result formats remain unchanged.

* fix: Update error message for better clarity in multi-search-replace strategy

Refines the error message returned when no sufficiently similar match is found during the multi-search-replace operation. The message now includes a clearer instruction to use the read_file tool for obtaining the latest file content before attempting to apply the diff again.

* refactor: Update readFileTool to return results in XML format

Modifies the `readFileTool` function to format the output as XML, enhancing the structure of the returned file content. This change aligns with previous updates to ensure consistent result formatting across tools.

* refactor: Simplify result handling for tool responses in Cline

This update refines the handling of tool responses in the `Cline` class by removing the XML formatting for `read_file` results and consolidating the logic for pushing results to the user message content. The changes ensure that all tool results are processed uniformly, improving code clarity and maintainability.

* test: Update read_file tests to validate XML formatted results

This commit modifies the assertions in the `read_file` tool tests to check for the expected XML format in the results. The changes ensure that the output structure aligns with recent updates to the tool's response formatting, enhancing test accuracy and reliability.

* test: Refactor assertions in read_file tests to use expected XML variable

This commit updates the `read_file` tool tests to utilize a predefined variable for the expected XML output, improving readability and maintainability of the test code. The changes ensure consistency in the expected results across multiple test cases.
2025-04-04 18:26:25 -04:00
..
__tests__ Refactor: Improve file tool context formatting and diff error guidance (#2278) 2025-04-04 18:26:25 -04:00
assistant-message Fix: Restore file truncation backward compatibility and fix regressions (#2022) 2025-03-27 01:56:10 -04:00
config Add profile management functions to API (#2251) 2025-04-03 01:40:07 -04:00
diff Refactor: Improve file tool context formatting and diff error guidance (#2278) 2025-04-04 18:26:25 -04:00
ignore Add support for a .rooignore file 2025-03-05 10:17:43 -05:00
mentions Revert "feat @-mention window path style & file with space (#1924)" (#2162) 2025-03-31 15:56:47 -05:00
prompts Remove the single diff strategy and make multi-diff the default (#2133) 2025-03-30 23:07:31 -04:00
sliding-window Relax provider profiles schema and log parse error to PostHog (#2139) 2025-03-30 23:07:34 -07:00
tools Refactor: Improve file tool context formatting and diff error guidance (#2278) 2025-04-04 18:26:25 -04:00
webview Ironing out some kinks when running evals with high parallelism (#2280) 2025-04-04 09:08:12 -07:00
Cline.ts Ironing out some kinks when running evals with high parallelism (#2280) 2025-04-04 09:08:12 -07:00
CodeActionProvider.ts feat: prioritize "Add to Context" and add line number tracking (#2063) 2025-03-28 12:01:16 -04:00
EditorUtils.ts feat: prioritize "Add to Context" and add line number tracking (#2063) 2025-03-28 12:01:16 -04:00
mode-validator.ts Automatically generate roo-code.d.ts (including type generation via zod-to-ts) (#2024) 2025-03-27 09:38:56 -07:00