Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 2 additions & 5 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export type ClineEvents = {
export type TaskOptions = {
provider: ClineProvider
apiConfiguration: ProviderSettings
customInstructions?: string
enableDiff?: boolean
enableCheckpoints?: boolean
fuzzyMatchThreshold?: number
Expand Down Expand Up @@ -134,7 +133,6 @@ export class Task extends EventEmitter<ClineEvents> {
isPaused: boolean = false
pausedModeSlug: string = defaultModeSlug
private pauseInterval: NodeJS.Timeout | undefined
customInstructions?: string

// API
readonly apiConfiguration: ProviderSettings
Expand Down Expand Up @@ -194,7 +192,6 @@ export class Task extends EventEmitter<ClineEvents> {
constructor({
provider,
apiConfiguration,
customInstructions,
enableDiff = false,
enableCheckpoints = true,
fuzzyMatchThreshold = 1.0,
Expand Down Expand Up @@ -234,7 +231,6 @@ export class Task extends EventEmitter<ClineEvents> {

this.urlContentFetcher = new UrlContentFetcher(provider.context)
this.browserSession = new BrowserSession(provider.context)
this.customInstructions = customInstructions
this.diffEnabled = enableDiff
this.fuzzyMatchThreshold = fuzzyMatchThreshold
this.consecutiveMistakeLimit = consecutiveMistakeLimit
Expand Down Expand Up @@ -1417,6 +1413,7 @@ export class Task extends EventEmitter<ClineEvents> {
browserViewportSize,
mode,
customModePrompts,
customInstructions,
experiments,
enableMcpServerCreation,
browserToolEnabled,
Expand All @@ -1442,7 +1439,7 @@ export class Task extends EventEmitter<ClineEvents> {
mode,
customModePrompts,
customModes,
this.customInstructions,
customInstructions,
this.diffEnabled,
experiments,
enableMcpServerCreation,
Expand Down
3 changes: 0 additions & 3 deletions src/core/task/__tests__/Task.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,21 +275,18 @@ describe("Cline", () => {
const cline = new Task({
provider: mockProvider,
apiConfiguration: mockApiConfig,
customInstructions: "custom instructions",
fuzzyMatchThreshold: 0.95,
task: "test task",
startTask: false,
})

expect(cline.customInstructions).toBe("custom instructions")
expect(cline.diffEnabled).toBe(false)
})

it("should use default fuzzy match threshold when not provided", async () => {
const cline = new Task({
provider: mockProvider,
apiConfiguration: mockApiConfig,
customInstructions: "custom instructions",
enableDiff: true,
fuzzyMatchThreshold: 0.95,
task: "test task",
Expand Down
28 changes: 2 additions & 26 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { supportPrompt } from "../../shared/support-prompt"
import { GlobalFileNames } from "../../shared/globalFileNames"
import { HistoryItem } from "../../shared/HistoryItem"
import { ExtensionMessage } from "../../shared/ExtensionMessage"
import { Mode, PromptComponent, defaultModeSlug } from "../../shared/modes"
import { Mode, defaultModeSlug } from "../../shared/modes"
import { experimentDefault } from "../../shared/experiments"
import { formatLanguage } from "../../shared/language"
import { Terminal } from "../../integrations/terminal/Terminal"
Expand Down Expand Up @@ -449,33 +449,21 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
options: Partial<
Pick<
TaskOptions,
| "customInstructions"
| "enableDiff"
| "enableCheckpoints"
| "fuzzyMatchThreshold"
| "consecutiveMistakeLimit"
| "experiments"
"enableDiff" | "enableCheckpoints" | "fuzzyMatchThreshold" | "consecutiveMistakeLimit" | "experiments"
>
> = {},
) {
const {
apiConfiguration,
customModePrompts,
diffEnabled: enableDiff,
enableCheckpoints,
fuzzyMatchThreshold,
mode,
customInstructions: globalInstructions,
experiments,
} = await this.getState()

const modePrompt = customModePrompts?.[mode] as PromptComponent
const effectiveInstructions = [globalInstructions, modePrompt?.customInstructions].filter(Boolean).join("\n\n")

const cline = new Task({
provider: this,
apiConfiguration,
customInstructions: effectiveInstructions,
enableDiff,
enableCheckpoints,
fuzzyMatchThreshold,
Expand Down Expand Up @@ -503,22 +491,15 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements

const {
apiConfiguration,
customModePrompts,
diffEnabled: enableDiff,
enableCheckpoints,
fuzzyMatchThreshold,
mode,
customInstructions: globalInstructions,
experiments,
} = await this.getState()

const modePrompt = customModePrompts?.[mode] as PromptComponent
const effectiveInstructions = [globalInstructions, modePrompt?.customInstructions].filter(Boolean).join("\n\n")

const cline = new Task({
provider: this,
apiConfiguration,
customInstructions: effectiveInstructions,
enableDiff,
enableCheckpoints,
fuzzyMatchThreshold,
Expand Down Expand Up @@ -962,11 +943,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
async updateCustomInstructions(instructions?: string) {
// User may be clearing the field.
await this.updateGlobalState("customInstructions", instructions || undefined)

if (this.getCurrentCline()) {
this.getCurrentCline()!.customInstructions = instructions || undefined
}

await this.postStateToWebview()
}

Expand Down
39 changes: 0 additions & 39 deletions src/core/webview/__tests__/ClineProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,45 +806,6 @@ describe("ClineProvider", () => {
expect(mockPostMessage).toHaveBeenCalled()
})

test("uses mode-specific custom instructions in Cline initialization", async () => {
// Setup mock state
const modeCustomInstructions = "Code mode instructions"
const mockApiConfig = {
apiProvider: "openrouter",
}

jest.spyOn(provider, "getState").mockResolvedValue({
apiConfiguration: mockApiConfig,
customModePrompts: {
code: { customInstructions: modeCustomInstructions },
},
mode: "code",
diffEnabled: true,
enableCheckpoints: false,
fuzzyMatchThreshold: 1.0,
experiments: experimentDefault,
} as any)

// Initialize Cline with a task
await provider.initClineWithTask("Test task")

// Verify Cline was initialized with mode-specific instructions
expect(Task).toHaveBeenCalledWith({
provider,
apiConfiguration: mockApiConfig,
customInstructions: modeCustomInstructions,
enableDiff: true,
enableCheckpoints: false,
fuzzyMatchThreshold: 1.0,
task: "Test task",
experiments: experimentDefault,
rootTask: undefined,
parentTask: undefined,
taskNumber: 1,
onCreated: expect.any(Function),
})
})

test("handles mode-specific custom instructions updates", async () => {
await provider.resolveWebviewView(mockWebviewView)
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
Expand Down