Roo-Code/src/integrations/editor/IEditingProvider.ts
Roo Code 73e88bdf4b feat: Add file-based editing mode to bypass diff view (#6001)
- Created IEditingProvider interface to abstract file editing operations
- Implemented FileWriter class for direct file system writes without diff view
- Updated Task class to use IEditingProvider interface instead of DiffViewProvider directly
- Added fileBasedEditing setting to global settings and UI
- Updated all file editing tools to use the new interface
- Added comprehensive tests for FileWriter class
- Updated existing tests to work with the new interface

This feature allows users to skip the diff view and apply edits directly to files,
which is useful for users who prefer to review changes in their own editor or
version control system.
2025-07-21 11:05:20 +00:00

77 lines
2 KiB
TypeScript

import { ClineSayTool } from "../../shared/ExtensionMessage"
import { Task } from "../../core/task/Task"
/**
* Interface for file editing providers.
* This abstraction allows switching between different editing strategies:
* - DiffViewProvider: Shows visual diff in editor before applying changes
* - FileWriter: Writes directly to file system without visual feedback
*/
export interface IEditingProvider {
/**
* Whether the provider is currently editing a file
*/
isEditing: boolean
/**
* The type of edit operation (create or modify)
*/
editType?: "create" | "modify"
/**
* The original content of the file being edited
*/
originalContent?: string
/**
* Open a file for editing
* @param relPath Relative path to the file
*/
open(relPath: string): Promise<void>
/**
* Update the file content
* @param content The new content
* @param isFinal Whether this is the final update
*/
update(content: string, isFinal: boolean): Promise<void>
/**
* Save the changes to the file
* @param diagnosticsEnabled Whether to check for diagnostics after saving
* @param writeDelayMs Delay in milliseconds before writing
* @returns Object containing diagnostic messages, user edits, and final content
*/
saveChanges(
diagnosticsEnabled?: boolean,
writeDelayMs?: number,
): Promise<{
newProblemsMessage: string | undefined
userEdits: string | undefined
finalContent: string | undefined
}>
/**
* Push the result of a write operation to the task
* @param task The current task
* @param cwd Current working directory
* @param isNewFile Whether this is a new file
* @returns Formatted XML response message
*/
pushToolWriteResult(task: Task, cwd: string, isNewFile: boolean): Promise<string>
/**
* Revert any pending changes
*/
revertChanges(): Promise<void>
/**
* Reset the provider state
*/
reset(): Promise<void>
/**
* Scroll to the first difference (only applicable for diff-based providers)
*/
scrollToFirstDiff?(): void
}