Skip to content

Commit f86e96d

Browse files
committed
refactor: separate mode and support prompts
- Rename customPrompts to customModePrompts for mode-specific prompts - Add new customSupportPrompts type for support action prompts - Update types to be more specific (CustomModePrompts and CustomSupportPrompts) - Fix all related tests and component implementations
1 parent 085d428 commit f86e96d

File tree

13 files changed

+119
-99
lines changed

13 files changed

+119
-99
lines changed

src/core/Cline.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ export class Cline {
809809
})
810810
}
811811

812-
const { browserViewportSize, mode, customPrompts, preferredLanguage } =
812+
const { browserViewportSize, mode, customModePrompts, preferredLanguage } =
813813
(await this.providerRef.deref()?.getState()) ?? {}
814814
const { customModes } = (await this.providerRef.deref()?.getState()) ?? {}
815815
const systemPrompt = await (async () => {
@@ -825,7 +825,7 @@ export class Cline {
825825
this.diffStrategy,
826826
browserViewportSize,
827827
mode,
828-
customPrompts,
828+
customModePrompts,
829829
customModes,
830830
this.customInstructions,
831831
preferredLanguage,

src/core/prompts/__tests__/system.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe("SYSTEM_PROMPT", () => {
162162
undefined, // diffStrategy
163163
undefined, // browserViewportSize
164164
defaultModeSlug, // mode
165-
undefined, // customPrompts
165+
undefined, // customModePrompts
166166
undefined, // customModes
167167
)
168168

@@ -178,7 +178,7 @@ describe("SYSTEM_PROMPT", () => {
178178
undefined, // diffStrategy
179179
"1280x800", // browserViewportSize
180180
defaultModeSlug, // mode
181-
undefined, // customPrompts
181+
undefined, // customModePrompts
182182
undefined, // customModes
183183
)
184184

@@ -196,7 +196,7 @@ describe("SYSTEM_PROMPT", () => {
196196
undefined, // diffStrategy
197197
undefined, // browserViewportSize
198198
defaultModeSlug, // mode
199-
undefined, // customPrompts
199+
undefined, // customModePrompts
200200
undefined, // customModes
201201
)
202202

@@ -212,7 +212,7 @@ describe("SYSTEM_PROMPT", () => {
212212
undefined, // diffStrategy
213213
undefined, // browserViewportSize
214214
defaultModeSlug, // mode
215-
undefined, // customPrompts
215+
undefined, // customModePrompts
216216
undefined, // customModes
217217
)
218218

@@ -228,7 +228,7 @@ describe("SYSTEM_PROMPT", () => {
228228
undefined, // diffStrategy
229229
"900x600", // different viewport size
230230
defaultModeSlug, // mode
231-
undefined, // customPrompts
231+
undefined, // customModePrompts
232232
undefined, // customModes
233233
)
234234

@@ -244,7 +244,7 @@ describe("SYSTEM_PROMPT", () => {
244244
new SearchReplaceDiffStrategy(), // Use actual diff strategy from the codebase
245245
undefined, // browserViewportSize
246246
defaultModeSlug, // mode
247-
undefined, // customPrompts
247+
undefined, // customModePrompts
248248
undefined, // customModes
249249
undefined, // globalCustomInstructions
250250
undefined, // preferredLanguage
@@ -264,7 +264,7 @@ describe("SYSTEM_PROMPT", () => {
264264
new SearchReplaceDiffStrategy(), // Use actual diff strategy from the codebase
265265
undefined, // browserViewportSize
266266
defaultModeSlug, // mode
267-
undefined, // customPrompts
267+
undefined, // customModePrompts
268268
undefined, // customModes
269269
undefined, // globalCustomInstructions
270270
undefined, // preferredLanguage
@@ -284,7 +284,7 @@ describe("SYSTEM_PROMPT", () => {
284284
new SearchReplaceDiffStrategy(), // Use actual diff strategy from the codebase
285285
undefined, // browserViewportSize
286286
defaultModeSlug, // mode
287-
undefined, // customPrompts
287+
undefined, // customModePrompts
288288
undefined, // customModes
289289
undefined, // globalCustomInstructions
290290
undefined, // preferredLanguage
@@ -304,7 +304,7 @@ describe("SYSTEM_PROMPT", () => {
304304
undefined, // diffStrategy
305305
undefined, // browserViewportSize
306306
defaultModeSlug, // mode
307-
undefined, // customPrompts
307+
undefined, // customModePrompts
308308
undefined, // customModes
309309
undefined, // globalCustomInstructions
310310
"Spanish", // preferredLanguage
@@ -334,7 +334,7 @@ describe("SYSTEM_PROMPT", () => {
334334
undefined, // diffStrategy
335335
undefined, // browserViewportSize
336336
"custom-mode", // mode
337-
undefined, // customPrompts
337+
undefined, // customModePrompts
338338
customModes, // customModes
339339
"Global instructions", // globalCustomInstructions
340340
)
@@ -351,7 +351,7 @@ describe("SYSTEM_PROMPT", () => {
351351
})
352352

353353
it("should use promptComponent roleDefinition when available", async () => {
354-
const customPrompts = {
354+
const customModePrompts = {
355355
[defaultModeSlug]: {
356356
roleDefinition: "Custom prompt role definition",
357357
customInstructions: "Custom prompt instructions",
@@ -366,7 +366,7 @@ describe("SYSTEM_PROMPT", () => {
366366
undefined,
367367
undefined,
368368
defaultModeSlug,
369-
customPrompts,
369+
customModePrompts,
370370
undefined,
371371
)
372372

@@ -377,7 +377,7 @@ describe("SYSTEM_PROMPT", () => {
377377
})
378378

379379
it("should fallback to modeConfig roleDefinition when promptComponent has no roleDefinition", async () => {
380-
const customPrompts = {
380+
const customModePrompts = {
381381
[defaultModeSlug]: {
382382
customInstructions: "Custom prompt instructions",
383383
// No roleDefinition provided
@@ -392,7 +392,7 @@ describe("SYSTEM_PROMPT", () => {
392392
undefined,
393393
undefined,
394394
defaultModeSlug,
395-
customPrompts,
395+
customModePrompts,
396396
undefined,
397397
)
398398

@@ -432,7 +432,7 @@ describe("addCustomInstructions", () => {
432432
undefined, // diffStrategy
433433
undefined, // browserViewportSize
434434
"architect", // mode
435-
undefined, // customPrompts
435+
undefined, // customModePrompts
436436
undefined, // customModes
437437
)
438438

@@ -448,7 +448,7 @@ describe("addCustomInstructions", () => {
448448
undefined, // diffStrategy
449449
undefined, // browserViewportSize
450450
"ask", // mode
451-
undefined, // customPrompts
451+
undefined, // customModePrompts
452452
undefined, // customModes
453453
)
454454

src/core/prompts/system.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
Mode,
33
modes,
4-
CustomPrompts,
4+
CustomModePrompts,
55
PromptComponent,
66
getRoleDefinition,
77
defaultModeSlug,
@@ -97,7 +97,7 @@ export const SYSTEM_PROMPT = async (
9797
diffStrategy?: DiffStrategy,
9898
browserViewportSize?: string,
9999
mode: Mode = defaultModeSlug,
100-
customPrompts?: CustomPrompts,
100+
customModePrompts?: CustomModePrompts,
101101
customModes?: ModeConfig[],
102102
globalCustomInstructions?: string,
103103
preferredLanguage?: string,
@@ -115,7 +115,7 @@ export const SYSTEM_PROMPT = async (
115115
}
116116

117117
// Check if it's a custom mode
118-
const promptComponent = getPromptComponent(customPrompts?.[mode])
118+
const promptComponent = getPromptComponent(customModePrompts?.[mode])
119119
// Get full mode config from custom modes or fall back to built-in modes
120120
const currentMode = getModeBySlug(mode, customModes) || modes.find((m) => m.slug === mode) || modes[0]
121121

0 commit comments

Comments
 (0)