Skip to content

Commit fc6f19f

Browse files
authored
Merge pull request #1008 from RooVetGit/improve_modes_prompt
Make sure the agent knows about all available modes with the correct overrides
2 parents 38f1092 + e66b085 commit fc6f19f

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

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)