Skip to content

Commit baa346d

Browse files
committed
Remove preferredLanguage and just rely on VSCode language
1 parent ae6903b commit baa346d

File tree

22 files changed

+1667
-387
lines changed

22 files changed

+1667
-387
lines changed

src/__mocks__/vscode.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
const vscode = {
2+
env: {
3+
language: "en", // Default language for tests
4+
appName: "Visual Studio Code Test",
5+
appHost: "desktop",
6+
appRoot: "/test/path",
7+
machineId: "test-machine-id",
8+
sessionId: "test-session-id",
9+
shell: "/bin/zsh",
10+
},
211
window: {
312
showInformationMessage: jest.fn(),
413
showErrorMessage: jest.fn(),

src/core/Cline.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,6 @@ export class Cline {
11021102
browserViewportSize,
11031103
mode,
11041104
customModePrompts,
1105-
preferredLanguage,
11061105
experiments,
11071106
enableMcpServerCreation,
11081107
browserToolEnabled,
@@ -1124,7 +1123,6 @@ export class Cline {
11241123
customModePrompts,
11251124
customModes,
11261125
this.customInstructions,
1127-
preferredLanguage,
11281126
this.diffEnabled,
11291127
experiments,
11301128
enableMcpServerCreation,
@@ -3665,13 +3663,12 @@ export class Cline {
36653663
customModePrompts,
36663664
experiments = {} as Record<ExperimentId, boolean>,
36673665
customInstructions: globalCustomInstructions,
3668-
preferredLanguage,
36693666
} = (await this.providerRef.deref()?.getState()) ?? {}
36703667
const currentMode = mode ?? defaultModeSlug
36713668
const modeDetails = await getFullModeDetails(currentMode, customModes, customModePrompts, {
36723669
cwd,
36733670
globalCustomInstructions,
3674-
preferredLanguage,
3671+
vscodeLanguage: vscode.env.language,
36753672
})
36763673
details += `\n\n# Current Mode\n`
36773674
details += `<slug>${currentMode}</slug>\n`

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

Lines changed: 1413 additions & 2 deletions
Large diffs are not rendered by default.

src/core/prompts/__tests__/custom-system-prompt.test.ts

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ const mockContext = {
4646
} as unknown as vscode.ExtensionContext
4747

4848
describe("File-Based Custom System Prompt", () => {
49-
const experiments = {}
50-
5149
beforeEach(() => {
5250
// Reset mocks before each test
5351
jest.clearAllMocks()
@@ -66,18 +64,17 @@ describe("File-Based Custom System Prompt", () => {
6664
const prompt = await SYSTEM_PROMPT(
6765
mockContext,
6866
"test/path", // Using a relative path without leading slash
69-
false,
70-
undefined,
71-
undefined,
72-
undefined,
73-
defaultModeSlug,
74-
customModePrompts,
75-
undefined,
76-
undefined,
77-
undefined,
78-
undefined,
79-
experiments,
80-
true,
67+
false, // supportsComputerUse
68+
undefined, // mcpHub
69+
undefined, // diffStrategy
70+
undefined, // browserViewportSize
71+
defaultModeSlug, // mode
72+
customModePrompts, // customModePrompts
73+
undefined, // customModes
74+
undefined, // globalCustomInstructions
75+
undefined, // diffEnabled
76+
undefined, // experiments
77+
true, // enableMcpServerCreation
8178
)
8279

8380
// Should contain default sections
@@ -101,26 +98,24 @@ describe("File-Based Custom System Prompt", () => {
10198
const prompt = await SYSTEM_PROMPT(
10299
mockContext,
103100
"test/path", // Using a relative path without leading slash
104-
false,
105-
undefined,
106-
undefined,
107-
undefined,
108-
defaultModeSlug,
109-
undefined,
110-
undefined,
111-
undefined,
112-
undefined,
113-
undefined,
114-
experiments,
115-
true,
101+
false, // supportsComputerUse
102+
undefined, // mcpHub
103+
undefined, // diffStrategy
104+
undefined, // browserViewportSize
105+
defaultModeSlug, // mode
106+
undefined, // customModePrompts
107+
undefined, // customModes
108+
undefined, // globalCustomInstructions
109+
undefined, // diffEnabled
110+
undefined, // experiments
111+
true, // enableMcpServerCreation
116112
)
117113

118114
// Should contain role definition and file-based system prompt
119115
expect(prompt).toContain(modes[0].roleDefinition)
120116
expect(prompt).toContain(fileCustomSystemPrompt)
121117

122118
// Should not contain any of the default sections
123-
expect(prompt).not.toContain("TOOL USE")
124119
expect(prompt).not.toContain("CAPABILITIES")
125120
expect(prompt).not.toContain("MODES")
126121
})
@@ -146,26 +141,24 @@ describe("File-Based Custom System Prompt", () => {
146141
const prompt = await SYSTEM_PROMPT(
147142
mockContext,
148143
"test/path", // Using a relative path without leading slash
149-
false,
150-
undefined,
151-
undefined,
152-
undefined,
153-
defaultModeSlug,
154-
customModePrompts,
155-
undefined,
156-
undefined,
157-
undefined,
158-
undefined,
159-
experiments,
160-
true,
144+
false, // supportsComputerUse
145+
undefined, // mcpHub
146+
undefined, // diffStrategy
147+
undefined, // browserViewportSize
148+
defaultModeSlug, // mode
149+
customModePrompts, // customModePrompts
150+
undefined, // customModes
151+
undefined, // globalCustomInstructions
152+
undefined, // diffEnabled
153+
undefined, // experiments
154+
true, // enableMcpServerCreation
161155
)
162156

163157
// Should contain custom role definition and file-based system prompt
164158
expect(prompt).toContain(customRoleDefinition)
165159
expect(prompt).toContain(fileCustomSystemPrompt)
166160

167161
// Should not contain any of the default sections
168-
expect(prompt).not.toContain("TOOL USE")
169162
expect(prompt).not.toContain("CAPABILITIES")
170163
expect(prompt).not.toContain("MODES")
171164
})

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import { getCapabilitiesSection } from "../sections/capabilities"
33
import { DiffStrategy, DiffResult } from "../../diff/types"
44

55
describe("addCustomInstructions", () => {
6-
test("adds preferred language to custom instructions", async () => {
6+
test("adds vscode language to custom instructions", async () => {
77
const result = await addCustomInstructions(
88
"mode instructions",
99
"global instructions",
1010
"/test/path",
1111
"test-mode",
12-
{ preferredLanguage: "French" },
12+
{ vscodeLanguage: "fr" },
1313
)
1414

1515
expect(result).toContain("Language Preference:")
16-
expect(result).toContain("You should always speak and think in the French language")
16+
expect(result).toContain('You should always speak and think in the "fr" language')
1717
})
1818

19-
test("works without preferred language", async () => {
19+
test("works without vscode language", async () => {
2020
const result = await addCustomInstructions(
2121
"mode instructions",
2222
"global instructions",

0 commit comments

Comments
 (0)