Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
8 changes: 2 additions & 6 deletions packages/types/src/experiment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import type { Keys, Equals, AssertEqual } from "./type-fu.js"
* ExperimentId
*/

export const experimentIds = [
"powerSteering",
"marketplace",
"concurrentFileReads",
"disableCompletionCommand",
] as const
export const experimentIds = ["powerSteering", "concurrentFileReads", "disableCompletionCommand", "marketplace", "multiFileApplyDiff"] as const

export const experimentIdsSchema = z.enum(experimentIds)

Expand All @@ -26,6 +21,7 @@ export const experimentsSchema = z.object({
marketplace: z.boolean(),
concurrentFileReads: z.boolean(),
disableCompletionCommand: z.boolean(),
multiFileApplyDiff: z.boolean(),
})

export type Experiments = z.infer<typeof experimentsSchema>
Expand Down
32 changes: 29 additions & 3 deletions src/core/assistant-message/presentAssistantMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { fetchInstructionsTool } from "../tools/fetchInstructionsTool"
import { listFilesTool } from "../tools/listFilesTool"
import { getReadFileToolDescription, readFileTool } from "../tools/readFileTool"
import { writeToFileTool } from "../tools/writeToFileTool"
import { applyDiffTool } from "../tools/applyDiffTool"
import { applyDiffTool } from "../tools/multiApplyDiffTool"
import { insertContentTool } from "../tools/insertContentTool"
import { searchAndReplaceTool } from "../tools/searchAndReplaceTool"
import { listCodeDefinitionNamesTool } from "../tools/listCodeDefinitionNamesTool"
Expand All @@ -31,6 +31,8 @@ import { formatResponse } from "../prompts/responses"
import { validateToolUse } from "../tools/validateToolUse"
import { Task } from "../task/Task"
import { codebaseSearchTool } from "../tools/codebaseSearchTool"
import { experiments, EXPERIMENT_IDS } from "../../shared/experiments"
import { applyDiffToolLegacy } from "../tools/applyDiffTool"

/**
* Processes and presents assistant message content to the user interface.
Expand Down Expand Up @@ -384,9 +386,33 @@ export async function presentAssistantMessage(cline: Task) {
case "write_to_file":
await writeToFileTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
break
case "apply_diff":
await applyDiffTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
case "apply_diff": {
// Get the provider and state to check experiment settings
const provider = cline.providerRef.deref()
let isMultiFileApplyDiffEnabled = false

if (provider) {
const state = await provider.getState()
isMultiFileApplyDiffEnabled = experiments.isEnabled(
state.experiments ?? {},
EXPERIMENT_IDS.MULTI_FILE_APPLY_DIFF,
)
}

if (isMultiFileApplyDiffEnabled) {
await applyDiffTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
} else {
await applyDiffToolLegacy(
cline,
block,
askApproval,
handleError,
pushToolResult,
removeClosingTag,
)
}
break
}
case "insert_content":
await insertContentTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
break
Expand Down
Loading