mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
feat: implement experimental features system
- Add experiments.ts to manage experimental features - Refactor experimental diff strategy into experiments system - Add UI components for managing experimental features - Add tests for experimental tools - Update system prompts to handle experiments
This commit is contained in:
@@ -40,6 +40,12 @@ import { singleCompletionHandler } from "../../utils/single-completion-handler"
|
||||
import { getCommitInfo, searchCommits, getWorkingState } from "../../utils/git"
|
||||
import { ConfigManager } from "../config/ConfigManager"
|
||||
import { CustomModesManager } from "../config/CustomModesManager"
|
||||
import {
|
||||
EXPERIMENT_IDS,
|
||||
experimentConfigs,
|
||||
experiments as Experiments,
|
||||
experimentDefault,
|
||||
} from "../../shared/experiments"
|
||||
import { CustomSupportPrompts, supportPrompt } from "../../shared/support-prompt"
|
||||
|
||||
import { ACTION_NAMES } from "../CodeActionProvider"
|
||||
@@ -118,7 +124,7 @@ type GlobalStateKey =
|
||||
| "customModePrompts"
|
||||
| "customSupportPrompts"
|
||||
| "enhancementApiConfigId"
|
||||
| "experimentalDiffStrategy"
|
||||
| "experiments" // Map of experiment IDs to their enabled state
|
||||
| "autoApprovalEnabled"
|
||||
| "customModes" // Array of custom modes
|
||||
|
||||
@@ -339,7 +345,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
fuzzyMatchThreshold,
|
||||
mode,
|
||||
customInstructions: globalInstructions,
|
||||
experimentalDiffStrategy,
|
||||
experiments,
|
||||
} = await this.getState()
|
||||
|
||||
const modePrompt = customModePrompts?.[mode] as PromptComponent
|
||||
@@ -354,7 +360,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
task,
|
||||
images,
|
||||
undefined,
|
||||
experimentalDiffStrategy,
|
||||
Experiments.isEnabled(experiments, EXPERIMENT_IDS.DIFF_STRATEGY),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -367,7 +373,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
fuzzyMatchThreshold,
|
||||
mode,
|
||||
customInstructions: globalInstructions,
|
||||
experimentalDiffStrategy,
|
||||
experiments,
|
||||
} = await this.getState()
|
||||
|
||||
const modePrompt = customModePrompts?.[mode] as PromptComponent
|
||||
@@ -382,7 +388,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
undefined,
|
||||
undefined,
|
||||
historyItem,
|
||||
experimentalDiffStrategy,
|
||||
Experiments.isEnabled(experiments, EXPERIMENT_IDS.DIFF_STRATEGY),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1044,14 +1050,14 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
diffEnabled,
|
||||
mcpEnabled,
|
||||
fuzzyMatchThreshold,
|
||||
experimentalDiffStrategy,
|
||||
experiments,
|
||||
} = await this.getState()
|
||||
|
||||
// Create diffStrategy based on current model and settings
|
||||
const diffStrategy = getDiffStrategy(
|
||||
apiConfiguration.apiModelId || apiConfiguration.openRouterModelId || "",
|
||||
fuzzyMatchThreshold,
|
||||
experimentalDiffStrategy,
|
||||
Experiments.isEnabled(experiments, EXPERIMENT_IDS.DIFF_STRATEGY),
|
||||
)
|
||||
const cwd =
|
||||
vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0) || ""
|
||||
@@ -1072,6 +1078,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
customInstructions,
|
||||
preferredLanguage,
|
||||
diffEnabled,
|
||||
experiments,
|
||||
)
|
||||
|
||||
await this.postMessageToWebview({
|
||||
@@ -1207,14 +1214,28 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
vscode.window.showErrorMessage("Failed to get list api configuration")
|
||||
}
|
||||
break
|
||||
case "experimentalDiffStrategy":
|
||||
await this.updateGlobalState("experimentalDiffStrategy", message.bool ?? false)
|
||||
// Update diffStrategy in current Cline instance if it exists
|
||||
if (this.cline) {
|
||||
await this.cline.updateDiffStrategy(message.bool ?? false)
|
||||
case "updateExperimental": {
|
||||
if (!message.values) {
|
||||
break
|
||||
}
|
||||
|
||||
const updatedExperiments = {
|
||||
...((await this.getGlobalState("experiments")) ?? experimentDefault),
|
||||
...message.values,
|
||||
}
|
||||
|
||||
await this.updateGlobalState("experiments", updatedExperiments)
|
||||
|
||||
// Update diffStrategy in current Cline instance if it exists
|
||||
if (message.values[EXPERIMENT_IDS.DIFF_STRATEGY] !== undefined && this.cline) {
|
||||
await this.cline.updateDiffStrategy(
|
||||
Experiments.isEnabled(updatedExperiments, EXPERIMENT_IDS.DIFF_STRATEGY),
|
||||
)
|
||||
}
|
||||
|
||||
await this.postStateToWebview()
|
||||
break
|
||||
}
|
||||
case "updateMcpTimeout":
|
||||
if (message.serverName && typeof message.timeout === "number") {
|
||||
try {
|
||||
@@ -1873,8 +1894,8 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
customModePrompts,
|
||||
customSupportPrompts,
|
||||
enhancementApiConfigId,
|
||||
experimentalDiffStrategy,
|
||||
autoApprovalEnabled,
|
||||
experiments,
|
||||
} = await this.getState()
|
||||
|
||||
const allowedCommands = vscode.workspace.getConfiguration("roo-cline").get<string[]>("allowedCommands") || []
|
||||
@@ -1914,9 +1935,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
customModePrompts: customModePrompts ?? {},
|
||||
customSupportPrompts: customSupportPrompts ?? {},
|
||||
enhancementApiConfigId,
|
||||
experimentalDiffStrategy: experimentalDiffStrategy ?? false,
|
||||
autoApprovalEnabled: autoApprovalEnabled ?? false,
|
||||
customModes: await this.customModesManager.getCustomModes(),
|
||||
experiments: experiments ?? experimentDefault,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2039,9 +2060,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
customModePrompts,
|
||||
customSupportPrompts,
|
||||
enhancementApiConfigId,
|
||||
experimentalDiffStrategy,
|
||||
autoApprovalEnabled,
|
||||
customModes,
|
||||
experiments,
|
||||
] = await Promise.all([
|
||||
this.getGlobalState("apiProvider") as Promise<ApiProvider | undefined>,
|
||||
this.getGlobalState("apiModelId") as Promise<string | undefined>,
|
||||
@@ -2109,9 +2130,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
this.getGlobalState("customModePrompts") as Promise<CustomModePrompts | undefined>,
|
||||
this.getGlobalState("customSupportPrompts") as Promise<CustomSupportPrompts | undefined>,
|
||||
this.getGlobalState("enhancementApiConfigId") as Promise<string | undefined>,
|
||||
this.getGlobalState("experimentalDiffStrategy") as Promise<boolean | undefined>,
|
||||
this.getGlobalState("autoApprovalEnabled") as Promise<boolean | undefined>,
|
||||
this.customModesManager.getCustomModes(),
|
||||
this.getGlobalState("experiments") as Promise<Record<string, boolean> | undefined>,
|
||||
])
|
||||
|
||||
let apiProvider: ApiProvider
|
||||
@@ -2225,7 +2246,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
customModePrompts: customModePrompts ?? {},
|
||||
customSupportPrompts: customSupportPrompts ?? {},
|
||||
enhancementApiConfigId,
|
||||
experimentalDiffStrategy: experimentalDiffStrategy ?? false,
|
||||
experiments: experiments ?? experimentDefault,
|
||||
autoApprovalEnabled: autoApprovalEnabled ?? false,
|
||||
customModes,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user