Skip to content

Commit c277f33

Browse files
author
feifei
committed
feat: merge main into feature-branch and resolve merge conflicts
2 parents 1b60ce1 + 567130b commit c277f33

27 files changed

+3447
-131
lines changed

src/api/providers/mistral.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ export class MistralHandler implements ApiHandler {
2525
throw new Error("Mistral API key is required")
2626
}
2727

28-
this.options = options
28+
// Set default model ID if not provided
29+
this.options = {
30+
...options,
31+
apiModelId: options.apiModelId || mistralDefaultModelId,
32+
}
33+
2934
const baseUrl = this.getBaseUrl()
3035
console.debug(`[Roo Code] MistralHandler using baseUrl: ${baseUrl}`)
3136
this.client = new Mistral({
@@ -36,6 +41,7 @@ export class MistralHandler implements ApiHandler {
3641

3742
private getBaseUrl(): string {
3843
const modelId = this.options.apiModelId ?? mistralDefaultModelId
44+
console.debug(`[Roo Code] MistralHandler using modelId: ${modelId}`)
3945
if (modelId?.startsWith("codestral-")) {
4046
return this.options.mistralCodestralUrl || "https://codestral.mistral.ai"
4147
}
@@ -45,7 +51,7 @@ export class MistralHandler implements ApiHandler {
4551
async *createMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream {
4652
const response = await this.client.chat.stream({
4753
model: this.options.apiModelId || mistralDefaultModelId,
48-
messages: convertToMistralMessages(messages),
54+
messages: [{ role: "system", content: systemPrompt }, ...convertToMistralMessages(messages)],
4955
maxTokens: this.options.includeMaxTokens ? this.getModel().info.maxTokens : undefined,
5056
temperature: this.options.modelTemperature ?? MISTRAL_DEFAULT_TEMPERATURE,
5157
})

src/core/prompts/sections/modes.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import * as path from "path"
22
import * as vscode from "vscode"
33
import { promises as fs } from "fs"
4-
import { modes, ModeConfig } from "../../../shared/modes"
4+
import { ModeConfig, getAllModesWithPrompts } from "../../../shared/modes"
55

66
export async function getModesSection(context: vscode.ExtensionContext): Promise<string> {
77
const settingsDir = path.join(context.globalStorageUri.fsPath, "settings")
88
await fs.mkdir(settingsDir, { recursive: true })
99
const customModesPath = path.join(settingsDir, "cline_custom_modes.json")
1010

11+
// Get all modes with their overrides from extension state
12+
const allModes = await getAllModesWithPrompts(context)
13+
1114
return `====
1215
1316
MODES
1417
15-
- When referring to modes, always use their display names. The built-in modes are:
16-
${modes.map((mode: ModeConfig) => ` * "${mode.name}" mode - ${mode.roleDefinition.split(".")[0]}`).join("\n")}
17-
Custom modes will be referred to by their configured name property.
18+
- These are the currently available modes:
19+
${allModes.map((mode: ModeConfig) => ` * "${mode.name}" mode (${mode.slug}) - ${mode.roleDefinition.split(".")[0]}`).join("\n")}
1820
1921
- Custom modes can be configured in two ways:
2022
1. Globally via '${customModesPath}' (created automatically on startup)

src/shared/modes.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as vscode from "vscode"
12
import { TOOL_GROUPS, ToolGroup, ALWAYS_AVAILABLE_TOOLS } from "./tool-groups"
23

34
// Mode types
@@ -239,6 +240,19 @@ export const defaultPrompts: Readonly<CustomModePrompts> = Object.freeze(
239240
),
240241
)
241242

243+
// Helper function to get all modes with their prompt overrides from extension state
244+
export async function getAllModesWithPrompts(context: vscode.ExtensionContext): Promise<ModeConfig[]> {
245+
const customModes = (await context.globalState.get<ModeConfig[]>("customModes")) || []
246+
const customModePrompts = (await context.globalState.get<CustomModePrompts>("customModePrompts")) || {}
247+
248+
const allModes = getAllModes(customModes)
249+
return allModes.map((mode) => ({
250+
...mode,
251+
roleDefinition: customModePrompts[mode.slug]?.roleDefinition ?? mode.roleDefinition,
252+
customInstructions: customModePrompts[mode.slug]?.customInstructions ?? mode.customInstructions,
253+
}))
254+
}
255+
242256
// Helper function to safely get role definition
243257
export function getRoleDefinition(modeSlug: string, customModes?: ModeConfig[]): string {
244258
const mode = getModeBySlug(modeSlug, customModes)

0 commit comments

Comments
 (0)